flat assembler
Message board for the users of flat assembler.

Index > Windows > Cannot Export

Author
Thread Post new topic Reply to topic
comrade



Joined: 16 Jun 2003
Posts: 1150
Location: Russian Federation
comrade 09 Feb 2004, 05:35
hook.asm:
Code:
;##########################################################################
format PE GUI 4.0 DLL
entry DllEntryPoint
;##########################################################################
_TITLE          equ  "hook"
_NAME           equ  "hook"
_VERSION        equ  "0.0"
_VERSIONTEXT    equ  _VERSION
;##########################################################################
include "%include%/win32am.inc"
include "%include%/equates/kernel32.inc"
include "%include%/equates/user32.inc"
include "%include%/macro/if.inc"
include "%include%/macro/macros.inc"
OFFSET equ
;##########################################################################
;##########################################################################
section ".code" code readable executable
;##########################################################################
;##########################################################################
;##########################################################################
proc DllEntryPoint,hInstance,fdwReason,lpvReserved
        enter
        xor     eax,eax
        inc     eax
        return
;##########################################################################
user32!wsprintfA:
        mov     eax,[ExitProcess]
        retn
;##########################################################################
user32!MessageBoxA:
        mov     eax,[esp+08h]
        showstr "user32.MessageBoxA",eax
        jmp     [MessageBox]
;##########################################################################
kernel32!CreateFileA:
        mov     eax,[esp+04h]
        showstr "kernel32.CreateFileA",eax
        jmp     [CreateFile]
;##########################################################################
kernel32!LoadLibraryA:
        mov     eax,[esp+04h]
        showstr "kernel32.LoadLibraryA",eax
        jmp     [LoadLibrary]
;##########################################################################
kernel32!GetCurrentDirectoryA:
        mov     eax,[esp+04h]
        showstr "kernel32.GetCurrentDirectoryA",eax
        jmp     [LoadLibrary]
;##########################################################################
kernel32!SetCurrentDirectoryA:
        mov     eax,[esp+04h]
        showstr "kernel32.SetCurrentDirectoryA",eax
        jmp     [LoadLibrary]
;##########################################################################
wsock32!gethostbyname:
        mov     eax,[esp+04h]
        showstr "wsock32.gethostbyname",eax
        jmp     [gethostbyname]
;##########################################################################
;##########################################################################
;##########################################################################
;##########################################################################
section ".data" data readable writeable
        data import
                library kernel32,"kernel32.dll",user32,"user32.dll",wsock32,"wsock32.dll"
                include "%include%/apia/kernel32.inc"
                include "%include%/apia/user32.inc"
                include "%include%/apia/wsock32.inc"
        end data
        data export
                export <_TITLE,".dll">,user32!wsprintfA,"wsprintfA",\
                                       kernel32!CreateFileA,"CreateFileA",\
                                       kernel32!LoadLibraryA,"LoadLibraryA",\
                                       kernel32!GetCurrentDirectoryA,"GetCurrentDirectoryA",\
                                       kernel32!SetCurrentDirectoryA,"SetCurrentDirectoryA",\
                                       user32!MessageBoxA,"MessageBoxA",\
                                       wsock32!gethostbyname,"gethostbyname"
        end data
;##########################################################################
;##########################################################################
        szLibTitle      db      _TITLE,0
;##########################################################################
;##########################################################################
section ".rsrc" resource data readable
        ; identifiers
        IDV_MAIN                = 01
        ; resources
        directory RT_VERSION,versions
        resource versions,IDV_MAIN,SUBLANG_NEUTRAL+LANG_NEUTRAL,version
        ; version
        version version,VOS__WINDOWS32,VFT_APP,VFT2_UNKNOWN,SUBLANG_NEUTRAL+LANG_NEUTRAL,0,\
                "FileDescription",_TITLE,\
                "LegalCopyright",<0A9h," comrade">,\
                "FileVersion",_VERSION,\
                "ProductVersion",_VERSION,\
                "ProductName",_TITLE,\
                "InternalName",_NAME,\
                "OriginalFilename",<_NAME,".dll">
;##########################################################################
section ".reloc" fixups data discardable
;##########################################################################
;##########################################################################    


and test.asm:
Code:
;##########################################################################
format PE GUI 4.0
entry start
;##########################################################################
include "%include%/win32am.inc"
include "%include%/equates/kernel32.inc"
include "%include%/equates/user32.inc"
include "%include%/macro/if.inc"
include "%include%/macro/macros.inc"
OFFSET equ
;##########################################################################
;##########################################################################
section ".code" code readable executable
;##########################################################################
start:
;##########################################################################
;##########################################################################
        push    ebx esi edi
 push    400000h
     push    400000h
     push    400000h
     push    400000h
     push    400000h
     call    [msgxbox]
   pop     edi esi ebx
 stdcall [ExitProcess],0
;##########################################################################
;##########################################################################
;##########################################################################
;##########################################################################
section ".data" import data readable writeable
     library kernel32,"kernel32.dll",user32,"user32.dll",hook,"hook.dll"
   include "%include%/apia/kernel32.inc"
     include "%include%/apia/user32.inc"
       import hook,msgxbox,"MessageBoxA"
;##########################################################################    


Windows (2000 Pro SP4) will not be able to find hook.dll!MessageBoxA if its exported just after user32!wsprintfA (see hook.asm), but works in the position that I pasted in. Same goes for other exported function. Export table structure seems fine, and PEditor interprets it as fine. Windows, though, refuses to find DLL if it has some wrong position in call to export macro:

Code:
---------------------------
output.exe - Entry Point Not Found
---------------------------
The procedure entry point MessageBoxA could not be located in the dynamic link library hook.dll. 
---------------------------
OK   
---------------------------    

_________________
comrade (comrade64@live.com; http://comrade.ownz.com/)
Post 09 Feb 2004, 05:35
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger ICQ Number Reply with quote
decard



Joined: 11 Sep 2003
Posts: 1092
Location: Poland
decard 09 Feb 2004, 06:52
doesn't the functions in export section need to be sorted alphabetically?
Post 09 Feb 2004, 06:52
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 09 Feb 2004, 12:32
Yes, sorted alphabetically and remember that is case sensitive.
regards,
pelaillo
Post 09 Feb 2004, 12:32
View user's profile Send private message Yahoo Messenger Reply with quote
comrade



Joined: 16 Jun 2003
Posts: 1150
Location: Russian Federation
comrade 09 Feb 2004, 13:24
Thank you Smile

_________________
comrade (comrade64@live.com; http://comrade.ownz.com/)
Post 09 Feb 2004, 13:24
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger ICQ Number 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-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.