Hello everyone,
I am having trouble to load a DLL function by Ordinal.
Is this code right?

invoke LoadLibrary, addr DLLName
.IF eax!=NULL
mov DLLModule, eax
push ebx
xor ebx, ebx
mov bx, 23
invoke GetProcAddress, DLLModule, ebx
.IF eax!=NULL
mov DLLFuncAddr, eax
pop ebx

GetProcAddress is returning NULL. :(
What could be wrong here?
Thanks for any help.
Posted on 2002-02-07 20:30:42 by dilau
Hi Dilau,

It looks like you've numbered your functions in the dll which I'm thinking could be the problem. Personally I would find it a bit diffcult to remember what the numbers would do so I name mine and use the code below in my main program somewhere.

szMyDllFunction db "MyDllProcName", 0
Dllname db "Test.dll", 0
HelloWorld db "Hello World!", 0

local hLib:DWORD

; Load dll...
invoke LoadLibrary, addr Dllname
mov hLib, eax

invoke GetProcAddress, hLib, addr szMyDllFunction

; Just for testing, send some text...
mov edx, offset HelloWorld
push edx

; Call our DLL function...
call eax

; Free the dll...
invoke FreeLibrary, hLib

The dll (test.dll) would then have a function named "MyDllProcName" which would be exported...

I never tested the code above but it should work. And of course this code should also have error checking. Which is pretty simple.

See ya,
Posted on 2002-02-07 21:05:50 by JamesE
Maybe that function isn't exported by ordinal, or you have the wrong number.....

Have you tried calling GetLastError to find out what the problem was?
Posted on 2002-02-07 21:21:59 by sluggy
iirc, you can't GetProcAddress by ordinal from kernel32.dll, that might
be your problem.
Posted on 2002-02-08 13:25:28 by f0dder
Posted on 2002-02-08 18:12:17 by hutch--
Thanks guys. :)
The problem was between the keyboard and the chair: me! :D (this is a joke we use here in Brazil, I don't know if it exists in English so I translated it)
The problem is that I was loading the wrong DLL! :(
Thanks again guys.
Posted on 2002-02-08 22:26:59 by dilau