Question to ordinal experts (or exports :)
I modified the example that comes with FASM a little bit and new version of 'import' macro.
When I import 2 ordinal everything's fine, but 3 - W2K says
can't find ordinal 3 in dll. There is even a special exception code for
this. I checked the images - everything in place.
And also , it seems to me that ordinal base doesn't
matter if the function imported by ordinal. At least for 2 imp func,
loader didn't care.
And is an ordinal 0 reserved for entry function?



; ========dll code ===================
format PE GUI 4.0 DLL at 10000000h
entry DLL_init
macro align value { rb (value-1) - (RVA $ + value-1) mod value }
include '%fasm_inc%\stdcall.inc'
include '%fasm_inc%\user.inc'
include '%fasm_inc%\export.inc'
include '%fasm_inc%\import.inc'

section '.code' code readable executable
align 4

DLL_init:
mov eax,10 ; successful initialization
ret 0Ch

align 4
HiOrd:
invoke MessageBox, 0, szHi, 0, MB_OK
ret

align 4
HelloOrd:
invoke MessageBox, 0, szHello, 0, MB_OK
ret

section '.data' data readable writeable
szHi db "Hi!",0
szHello db "Hello",0

section '.idata' import data readable writeable
library kernel,'KERNEL32.DLL',\
user,'user32.dll'
kernel:
import ExitProcess, 'ExitProcess'
user:
import MessageBox, 'MessageBoxA'

section '.edata' export data readable

dd 0,0,0,RVA dlldemo_name,0 ;ordinal base = 1 - doesn't matter if don't only by ordinals
dd 3,0,RVA addresses_table,0,0

addresses_table:
dd RVA HiOrd,\
RVA HelloOrd,\
RVA HelloOrd ; for simplicity

dlldemo_name db 'dl2.dll',0

section '.reloc' fixups data readable discardable



;=================USE DLL code =======================================

format PE GUI 4.0
entry start
include '%fasm_inc%\stdcall.inc'
include '%fasm_inc%\import.inc'

section '.code' code readable executable
start:
call
invoke HelloOrd
invoke ExProc
invoke ExitProcess,0

section '.idata' import data readable writeable
library kernel,'KERNEL32.DLL',\
dl2, 'dl2.dll'
kernel:
import ExitProcess, $8d , AddAtomA, 1, AddAtomW, 2

dl2:
import HiOrd, 1, HelloOrd,2 , ExProc,3

section '.reloc' fixups data readable discardable
Posted on 2002-08-19 19:49:56 by Sergo
Sorry,
ADD, the problem was I compiled one dll but load another at run-time.
Posted on 2002-08-22 16:03:19 by Sergo