flat assembler
Message board for the users of flat assembler.

Index > Windows > DLLs

Author
Thread Post new topic Reply to topic
Crinan



Joined: 05 Dec 2006
Posts: 28
Location: New Zealand
Crinan 06 Dec 2011, 20:20
Can someone point me in the right direction to find out about coding DLLs?
I have searched the documentation and the examples so far without success.
I have also searched various subjects here with different search arguments but have not yet found anything useful. I see though, that many people work with DLL coding so I must be missing something . . .
Post 06 Dec 2011, 20:20
View user's profile Send private message Reply with quote
AsmGuru62



Joined: 28 Jan 2004
Posts: 1561
Location: Toronto, Canada
AsmGuru62 06 Dec 2011, 21:09
In FASM EXAMPLES folder (if I recall) there must be code sample for building a DLL.
Post 06 Dec 2011, 21:09
View user's profile Send private message Send e-mail Reply with quote
Overflowz



Joined: 03 Sep 2010
Posts: 1046
Overflowz 06 Dec 2011, 21:51
Simple DLL with exports only.
Code:
format PE GUI 4.0 DLL
include 'WIN32AX.INC'
section '.text' code readable executable
myfunction1:
   some code here.
   ret
myfunction2:
   another code here.
   ret
section '.edata' export data readable
export '',myfunction1,'myfunction1',\
          myfunction2,'myfunction2'
section '.reloc' fixups data readable discardable    


This DLL will have 2 exports with names myfunction1 and myfunction2.
Simple right ? Wink
Post 06 Dec 2011, 21:51
View user's profile Send private message Reply with quote
Crinan



Joined: 05 Dec 2006
Posts: 28
Location: New Zealand
Crinan 06 Dec 2011, 22:28
Overflowz, thanks. That's a start anyway! I'll try to use it somehow.
Amsguru62, I've already looked at the examples but cannot find anthing on this subject.
Post 06 Dec 2011, 22:28
View user's profile Send private message Reply with quote
AsmGuru62



Joined: 28 Jan 2004
Posts: 1561
Location: Toronto, Canada
AsmGuru62 07 Dec 2011, 15:09
Strange... this is what I got in my FASM EXAMPLES folder:
Code:
; --- THIS IS DLL CODE ITSELF ---
;
; DLL creation example
;
format PE GUI 4.0 DLL
entry DllEntryPoint

include 'win32a.inc'

section '.text' code readable executable

proc DllEntryPoint hinstDLL,fdwReason,lpvReserved
      mov     eax,TRUE
    ret
endp

; VOID ShowErrorMessage(HWND hWnd,DWORD dwError);

proc ShowErrorMessage hWnd,dwError
  local lpBuffer:DWORD
        lea     eax,[lpBuffer]
      invoke  FormatMessage,FORMAT_MESSAGE_ALLOCATE_BUFFER+FORMAT_MESSAGE_FROM_SYSTEM,0,[dwError],LANG_NEUTRAL,eax,0,0
    invoke  MessageBox,[hWnd],[lpBuffer],NULL,MB_ICONERROR+MB_OK
        invoke  LocalFree,[lpBuffer]
        ret
endp

; VOID ShowLastError(HWND hWnd);

proc ShowLastError hWnd
  invoke  GetLastError
        stdcall ShowErrorMessage,[hWnd],eax
 ret
endp

section '.idata' import data readable writeable

  library kernel,'KERNEL32.DLL',\
      user,'USER32.DLL'

  import kernel,\
      GetLastError,'GetLastError',\
    SetLastError,'SetLastError',\
    FormatMessage,'FormatMessageA',\
         LocalFree,'LocalFree'

  import user,\
     MessageBox,'MessageBoxA'

section '.edata' export data readable

  export 'ERRORMSG.DLL',\
       ShowErrorMessage,'ShowErrorMessage',\
    ShowLastError,'ShowLastError'

section '.reloc' fixups data discardable
    

And this is an example of an EXE which uses this DLL:
Code:

format PE GUI 4.0
entry start

include 'win32a.inc'

section '.text' code readable executable

  start:
      invoke  ShowLastError,HWND_DESKTOP
  invoke  ExitProcess,0

section '.idata' import data readable writeable

  library kernel,'KERNEL32.DLL',\
    errormsg,'ERRORMSG.DLL'

  import kernel,\
        ExitProcess,'ExitProcess'

  import errormsg,\
     ShowLastError,'ShowLastError'
    
Post 07 Dec 2011, 15:09
View user's profile Send private message Send e-mail Reply with quote
Crinan



Joined: 05 Dec 2006
Posts: 28
Location: New Zealand
Crinan 07 Dec 2011, 19:34
Oops, my mistake!
I was looking in flatassembler.net/examples, and didn't think of looking in fasm examples. How stupid is that? (No reply required)
Post 07 Dec 2011, 19:34
View user's profile Send private message Reply with quote
DOS386



Joined: 08 Dec 2006
Posts: 1898
DOS386 12 Dec 2011, 02:02
> How stupid is that?

I don't know.

> No reply required

http://board.flatassembler.net/topic.php?t=11170 "DeLL HeLL"
Post 12 Dec 2011, 02:02
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2023, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.