Hello everyone,
I am having trouble to load a DLL function by Ordinal.
Is this code right?
GetProcAddress is returning NULL. :(
What could be wrong here?
Thanks for any help.
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
.ENDIF
pop ebx
.ENDIF
GetProcAddress is returning NULL. :(
What could be wrong here?
Thanks for any help.
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.
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,
James
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.
.data
szMyDllFunction db "MyDllProcName", 0
Dllname db "Test.dll", 0
HelloWorld db "Hello World!", 0
.code
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,
James
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?
Have you tried calling GetLastError to find out what the problem was?
iirc, you can't GetProcAddress by ordinal from kernel32.dll, that might
be your problem.
be your problem.
dilau,
Have a look at this thread.
http://www.asmcommunity.net/board/showthread.php?postid=23464.msg23464
Regards,
hutch@movsd.com
Have a look at this thread.
http://www.asmcommunity.net/board/showthread.php?postid=23464.msg23464
Regards,
hutch@movsd.com
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.
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.