flat assembler
Message board for the users of flat assembler.

Index > Windows > COFF OBJ FILES AND DLL's

Author
Thread Post new topic Reply to topic
metalfishx



Joined: 30 Sep 2004
Posts: 65
Location: Florida, Uruguay
metalfishx
Hello everybody. Smile Im new ussing flat assembly language. Im trying to make a dll that export some functions, but, im intent to make it as object, not the final dll. Is there a way to do that? Confused

Thanks!

_________________
---------------------------------------
Roberto A. Berrospe Machin
Ruta Internet, Florida Uruguay
---------------------------------------
Post 30 Sep 2004, 12:37
View user's profile Send private message Visit poster's website Reply with quote
roticv



Joined: 19 Jun 2003
Posts: 374
Location: Singapore
roticv
Post 30 Sep 2004, 13:35
View user's profile Send private message Visit poster's website MSN Messenger Reply with quote
metalfishx



Joined: 30 Sep 2004
Posts: 65
Location: Florida, Uruguay
metalfishx
Thanks rotic.. but maybe is because im new ussing assembly language, but i cannot see how to use that you give to me Confused my poor experience is ussing MASM32

Here i atach the code that im trying to convert to obj.. i just need a dll, but in obj format (if is possible) Confused


Code:
format PE GUI 4.0 DLL
entry DllEntryPoint

include '%fasminc%\win32a.inc'

section '.data' data readable writable
        vaintret dd        ?
        varstrret db        "Hello World!!!"

section '.code' code readable executable

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

proc testint,param1
    mov eax,[param1]
    add eax,100
    mov [vaintret],eax
    mov eax,vaintret
    return
endp

proc teststr
    mov eax,varstrret
    return
endp


section '.edata' export data readable
  export 'testobj.dll',\
         testint,'testing',\
         teststr,'teststr'

section '.reloc' fixups data discardable       

_________________
---------------------------------------
Roberto A. Berrospe Machin
Ruta Internet, Florida Uruguay
---------------------------------------
Post 30 Sep 2004, 14:07
View user's profile Send private message Visit poster's website Reply with quote
roticv



Joined: 19 Jun 2003
Posts: 374
Location: Singapore
roticv
Replace the format PE GUI 4.0 DLL with format MS COFF
Post 30 Sep 2004, 16:42
View user's profile Send private message Visit poster's website MSN Messenger Reply with quote
metalfishx



Joined: 30 Sep 2004
Posts: 65
Location: Florida, Uruguay
metalfishx
Hi roticv. Well yes, i was testing some formats.. if i use format MS COFF fasm give me an error in: entry DllEntryPoint, and if i remove that, then i receive an error in: section '.edata' export data readable ... i cannot find the way to do this.. but thanks for your recomendations. Smile
Post 30 Sep 2004, 17:17
View user's profile Send private message Visit poster's website Reply with quote
pelaillo
Missing in inaction


Joined: 19 Jun 2003
Posts: 878
Location: Colombia
pelaillo
metalfishx,
entry point and exports are to be decided when linking final dll (or exe) file. COFF format does not hold this information because they could be linked in different ways and with different formats/products (releases).
i.e. the flexibility of COFF format permit you to produce one time a standalone exe and another time a dll with the same object files.
Post 30 Sep 2004, 17:54
View user's profile Send private message Yahoo Messenger Reply with quote
Vortex



Joined: 17 Jun 2003
Posts: 318
Vortex
Hi metalfishx,

Here is an example for you. Consider this DLL source code exporting these two functions translated from Hutch's masm32.lib :
Code:
StdOut : prints a NULL terminated string
locate  : puts the cursor to the coordinates x,y
    


Consfunc.asm
Code:
format MS COFF
public DllEntryPoint
public StdOut
public locate

extrn  GetStdHandle:dword
extrn  SetConsoleCursorPosition:dword
extrn  WriteFile:dword
extrn 'lstrlenA' as lstrlen:dword

Include '%fasminc%\win32a.inc'

section '.code' code readable executable

proc DllEntryPoint, hinstDLL,fdwReason,lpvReserved 

        mov     eax,TRUE 
        return 

endp 

proc StdOut,lpszText

hOutPut         dd ?
bWritten                dd ?
sl              dd ?
enter
        invoke GetStdHandle,STD_OUTPUT_HANDLE
        mov           [hOutPut], eax
        invoke        lstrlen,[lpszText]
        mov               [sl],eax
        lea         eax,[bWritten]
        invoke        WriteFile,[hOutPut],[lpszText],[sl],eax,NULL
        mov             eax,[bWritten]
        return

endp

proc locate,x,y

    _hOutPut  dd ?
    xyVar dd ?
    enter

    invoke GetStdHandle,STD_OUTPUT_HANDLE
    mov [_hOutPut], eax

    mov  ecx,[x]
    mov  eax,[y]
    shl  eax, 16
    mov  ax, cx

    invoke SetConsoleCursorPosition,[_hOutPut],eax

    return

endp
    


Creating the DLL with the linker GoLink authored by Jeremy Gordon:

http://www.godevtool.com

Code:
set fasminc=\fasmw\include
\fasm\fasm Consfunc.asm
\goasm\golink /dll /entry DllEntryPoint /export StdOut /export locate Consfunc.obj kernel32.dll
    


An example using this DLL:
Code:
format PE CONSOLE 4.0
entry start

Include '%fasminc%\win32a.inc'
Include '%fasminc%\macro\if.inc'

section '.data' data readable writeable

msg        db 'Console application',0

section '.code' code readable executable
start:
        push    esi
 xor     esi,esi
@@:
  inc     esi
 invoke  locate,esi,esi
      invoke  StdOut,msg
  cmp     esi,10
      jne     @b
  pop     esi     
    invoke  ExitProcess,0

section '.idata' import data readable writeable

  library kernel32,'kernel32.dll',\
          Consfunc,'Consfunc.dll'

  import kernel32,\
         ExitProcess,'ExitProcess'

  import Consfunc,\
         StdOut,'StdOut',\
         locate,'locate'
    


If you would like to create an import library for this DLL, please let me know.


Description:
Download
Filename: FasmDLL2.zip
Filesize: 2.7 KB
Downloaded: 125 Time(s)


_________________
Code it... That's all...
Post 30 Sep 2004, 18:19
View user's profile Send private message Visit poster's website Reply with quote
metalfishx



Joined: 30 Sep 2004
Posts: 65
Location: Florida, Uruguay
metalfishx
Thanks a lot.. for the answers, works fine! and i know now how to use externals with "extern" Smile Thanks to all! Wink

_________________
---------------------------------------
Roberto A. Berrospe Machin
Ruta Internet, Florida Uruguay
---------------------------------------
Post 01 Oct 2004, 12:41
View user's profile Send private message Visit poster's website 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.