flat assembler
Message board for the users of flat assembler.
Index
> Windows > DLL Question |
Author |
|
pelaillo 11 Oct 2003, 18:15
Follow the scheme as the fasm example dll.
Then make your function and to get a return value, store it in eax before returning (ret). If your return value is not an integer, use eax value as pointer to your custom data structure. Assembly makes no distinction between VOID and other functions. The difference is in the caller (eax value is neglected). You can use other registers but remember: working in Win32 requires that you preserve them. (If you change the contents of eax, ecx, edx is OK, but others could cause an undesired effect) Regards, |
|||
11 Oct 2003, 18:15 |
|
Todd 11 Oct 2003, 20:22
Thank you for your reply, that helps me out some. I've tried this out, but I can't seem to get it to work. Maybe someone could tell me what it is I'm doing wrong here. I realize that this function does nothing, but I'm just testing returning a value. When I import this function into another program it generates an error, usually something like "testdll1.dll can't load at the desired address". Here's my code:
Code: format PE GUI 4.0 DLL entry DllEntryPoint include '%include%\win32a.inc' section '.code' code readable executable proc DllEntryPoint, hinstDLL,fdwReason,lpvReserved enter mov eax,TRUE return proc TestFunction enter mov eax,65 return section '.edata' export data readable export 'testdll1.dll',\ TestFunction,'TestFunction' section '.reloc' fixups data discardable |
|||
11 Oct 2003, 20:22 |
|
pelaillo 11 Oct 2003, 22:37
For some obscure reason, Windows requires that you import at least one function from the win API, also if you don't need it. So this will work for you:
Code: format PE GUI 4.0 DLL entry DllEntryPoint include '%include%\win32a.inc' section '.code' code readable executable proc DllEntryPoint, hinstDLL,fdwReason,lpvReserved enter invoke GetModuleHandle mov eax,TRUE return proc TestFunction enter mov eax,65 return section '.edata' export data readable export 'testdll1.dll',\ TestFunction,'TestFunction' section '.idata' import data readable writeable library kernel,'KERNEL32.DLL' import kernel,GetModuleHandle,'GetModuleHandleA' section '.reloc' fixups data discardable |
|||
11 Oct 2003, 22:37 |
|
Todd 12 Oct 2003, 00:52
Oh, that seems like a very strange rule, but it works. Thanks!
|
|||
12 Oct 2003, 00:52 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.