flat assembler
Message board for the users of flat assembler.

Index > Windows > DLL not useable from Delphi

Author
Thread Post new topic Reply to topic
BertaS



Joined: 11 Sep 2005
Posts: 4
BertaS
Hi, i'm new to FASM. I recently used MASM too create a DLL. I want to use this DLL with my Delphi app.
There was no Problem with the MASM DLL. But I want to use MMX, SSE and such and so i switched to FASM. I think it is a lot better then MASM and it supports SIMD Extensions.
Now I wrote a tiny test-dll with FASM and if I try to load it from my Delphi app it tells me something like: "test.dll" is not a valid Windows Application. What did I do wrong? Here is the code of the DLL:

[code]
format PE GUI 4.0 DLL
entry DLLEntryPoint

include 'F:\fasm\INCLUDE\win32a.inc'

section '.code' code readable executable

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


proc DoItFASM Number1:DWORD, Number2:DWORD
mov eax, [Number1]
mov ecx, [Number2]
add eax, ecx ;I know, it's ridiculous
ret
endp

section '.edata' export data readable
export 'test.dll', DoItFASM, 'DoItFASM'

section '.reloc' fixups data discardable
[/code]
Post 11 Sep 2005, 09:58
View user's profile Send private message Reply with quote
decard



Joined: 11 Sep 2003
Posts: 1092
Location: Poland
decard
It seems that it doesn't work because it doesn't have an import section. Add some imports, it will work then.
Post 11 Sep 2005, 10:18
View user's profile Send private message Visit poster's website Reply with quote
BertaS



Joined: 11 Sep 2005
Posts: 4
BertaS
Thanks a lot. I'll try that.
Post 11 Sep 2005, 10:20
View user's profile Send private message Reply with quote
BertaS



Joined: 11 Sep 2005
Posts: 4
BertaS
Didn't work.
Added this:

Code:
section '.idata' import data readable writeable
        library kernel, 'KERNEL32.DLL', user, 'USER32.DLL'

        import kernel, GetLastError, 'GetLastError'
        import user, MessageBox, 'MessageBoxA'
    


This is what Windows tells me:
"The application or DLL "test.dll" is not a valid Windows image"

Any idea?
Post 11 Sep 2005, 11:03
View user's profile Send private message Reply with quote
decard



Joined: 11 Sep 2003
Posts: 1092
Location: Poland
decard
That's because import macro doesn't actually import any function if you don't use it somewhere. Try to add a "dummy" reference to any function, for example:

Code:
dd GetLastError    

(add it somewhere in code section.
Post 11 Sep 2005, 12:14
View user's profile Send private message Visit poster's website Reply with quote
BertaS



Joined: 11 Sep 2005
Posts: 4
BertaS
Very Happy
Okay, that did it!
Thank you VERY much! That was a big help for me!
Hope I can help you someday.
Post 11 Sep 2005, 14: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-2020, Tomasz Grysztar. Also on YouTube, Twitter.

Website powered by rwasa.