flat assembler
Message board for the users of flat assembler.

Index > Windows > Problema creating DLL with FASM (newbie in fasm)

Author
Thread Post new topic Reply to topic
Fungos Bauux



Joined: 19 Jan 2005
Posts: 31
Location: CWB
Fungos Bauux
Im trying to create a DLL that will talk with JAVA RMI, but windows says that my dlls is invalid.

DLL:

Code:
format pe dll
entry start

include 'win32a.inc'

section '.code' code readable executable

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

; void readString(char *);
proc readString pStr
        ret
endp

section '.edata' export data readable

  export 'MY.DLL',\
         readString,'readString'

section '.reloc' fixups data discardable
    


my test loader is this:
Code:
format pe console
entry start

include 'win32a.inc'

section '.code' code readable executable

  start:
        invoke  readString, myString
        invoke  ExitProcess, 0

section '.data' data readable writeable

  myString      db      'Some string',0

section '.idata' import data readable writeable

  library kernel,'KERNEL32.DLL',\
          mydll,'MY.DLL'

  import kernel,\
         ExitProcess,'ExitProcess'

  import mydll,\
         readString,'readString'
    


what im doing wrong?
Post 12 Jan 2006, 02:00
View user's profile Send private message Visit poster's website MSN Messenger ICQ Number Reply with quote
RedGhost



Joined: 18 May 2005
Posts: 443
Location: BC, Canada
RedGhost
hey i created a test dll/program with your code

dll
Code:
format pe dll
entry start

include '%fasminc%\win32a.inc'

section '.code' code readable executable

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

; void readString(char *);
proc readString pStr
        invoke MessageBoxA, 0, [pStr], 0, 0
        ret
endp

section '.idata' import data readable writeable

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

  import kernel,\
         ExitProcess,'ExitProcess'

  import user,\
         MessageBoxA,'MessageBoxA'


section '.edata' export data readable

  export 'MY.DLL',\
         readString,'readString'

section '.reloc' fixups data discardable 
    


exe
Code:
format pe gui
entry start

include '%fasminc%\win32a.inc'

section '.code' code readable executable

  start:
        invoke  readString, myString
        invoke  ExitProcess, 0

section '.data' data readable writeable

  myString      db      'Some string',0

section '.idata' import data readable writeable

  library kernel,'KERNEL32.DLL',\
          mydll,'MY.DLL'

  import kernel,\
         ExitProcess,'ExitProcess'

  import mydll,\
         readString,'readString'
    


i also tested with "pe console" aswell to be sure

sure enough the MessageBoxA with "Some String" was called when i ran the exe without problem, are you sure your naming it "MY.DLL" ?

_________________
redghost.ca
Post 12 Jan 2006, 03:45
View user's profile Send private message AIM Address MSN Messenger Reply with quote
madmatt



Joined: 07 Oct 2003
Posts: 1045
Location: Michigan, USA
madmatt
A couple of suggestions:

Code:
format PE GUI 4.0 DLL    


also, I'm not an expert on java, but I think it uses c style parameters,
so you would need a procedure defined like this:

Code:
proc c readString pStr    


the c being use for the c calling convention, to test you would need to use the cinvoke, I think.
Post 12 Jan 2006, 08:31
View user's profile Send private message Reply with quote
Fungos Bauux



Joined: 19 Jan 2005
Posts: 31
Location: CWB
Fungos Bauux
Quote:

are you sure your naming it "MY.DLL" ?


yup.. Sad very strange, yours code works fine here. but mine doesnt, maybe my readString with only a ret is the problem? anyone can verify this?

@madmatt:

Thanks, I will need that. But fasm isnt accepting "proc c readString pStr" it gives error at "endp".

cinvoke fasm compiled.
Post 12 Jan 2006, 16:14
View user's profile Send private message Visit poster's website MSN Messenger ICQ Number Reply with quote
Tomasz Grysztar
Assembly Artist


Joined: 16 Jun 2003
Posts: 7718
Location: Kraków, Poland
Tomasz Grysztar
Please look at the section "Problems" in the Windows FAQ (it's the sticky thread in this forum) - there are two threads that refer exactly to the problem you've got here.

Fungos Bauux wrote:
Thanks, I will need that. But fasm isnt accepting "proc c readString pStr" it gives error at "endp".

It should be "proc readString c pStr". Look here for the complete information on the "proc" macro syntax.
Post 12 Jan 2006, 16:54
View user's profile Send private message Visit poster's website Reply with quote
Fungos Bauux



Joined: 19 Jan 2005
Posts: 31
Location: CWB
Fungos Bauux
Sorry Tomasz, but I have read that threads, but I was thinking mine wasnt related.

Thank you guys. Smile
Post 12 Jan 2006, 18:00
View user's profile Send private message Visit poster's website MSN Messenger ICQ Number Reply with quote
madmatt



Joined: 07 Oct 2003
Posts: 1045
Location: Michigan, USA
madmatt
Sorry for that mistake, Fungos Bauux
Post 13 Jan 2006, 02:13
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.

Powered by rwasa.