Hello there. This is my problem. I have everything ok related with getprocadress. The only problem is that I'm missing something in my code.

1 db "The function", 0 <- in .data

invoke GetProcAddress, eax, ADDR 1 <- in .code

And now in the code, I have:


mov eax, adressh
call eax

What do I need to do now?

Thank you.
Posted on 2009-08-17 11:46:24 by filipev
The first parameter of GetProcAddress has to be the ImageBase of a loaded Module which exports functions
The next is the exact name of one of them (see for -A or -W for ANSI/UNICODE)

Then you surely can save the address of the function in an address and later call it

To see what went wrong you should at first see as I mentioned if you did not mispelled anything
If all is correct, the simpliest way to check what's happening is to debug your executable and see what GetProcAddress returns and why (GetLastError).
Posted on 2009-08-17 16:10:49 by n0rb
It is not an executable its a dll...
Posted on 2009-08-18 03:36:53 by filipev

Krnl32 DB "Kernel32.dll", 0
lpTextArray DB  "ExitProcess", 0, "CreateFileA", 0
Mov Ebx, Offset lpTextArray

Invoke GetModuleHandle, Addr Krnl32
Invoke GetProcAddress, Eax, Ebx


Here's a bit of code that I used in a few projects.  Eax wil hold the address to ExitProcess after you run it the first time.  If you update Ebx you can reuse the code and find the address to CreateFileA with a simple loop
Posted on 2009-08-18 12:03:56 by GoldStar611

Hello there. This is my problem. I have everything ok related with getprocadress. The only problem is that I'm missing something in my code.

1 db "The function", 0 <- in .data

invoke GetProcAddress, eax, ADDR 1 <- in .code

And now in the code, I have:


mov eax, adressh
call eax

What do I need to do now?

Thank you.


You should also name your labels beginning with a character. You can't really use just the number 1 as the assembler won't be able to tell if it's a label or a numeric constant.
Posted on 2009-08-18 12:17:22 by Synfire
The number 1 was just to tell it was something else there.
Posted on 2009-08-18 17:16:34 by filipev
The number 1 was a label.

It could have said anything, for example, "homer_was_here" would work.
Posted on 2009-08-19 06:35:58 by Homer
Hi filipev,

You have not explained what your problem is so here's a general example of GetProcAddress;

.DATA
; The name of the executable (yes a DLL is an executable)
ModuleName DB "MyDll.dll",0
; The name of the function
ProcName DB "MyExportedProc",0

.DATA?
;A couple of DWORD buffers for data
hModule DD ?
pProc DD ?

.CODE
;First we need a handle to the module containing the function
invoke LoadLibrary,offset ModuleName
;Save the handle to free it later
mov hModule, eax

;Next get the function address, the function *must* be exported by the DLL
;Building DLLs and exporting functions is beyond the scope of this example
invoke GetProcAddress,hModule,offset ProcName
;Save the pointer to the function
mov pProc, eax

;Finally we call the function
;first push any parameters in reverse order (32 bit only)
;Lets say it has 1 parameter and it should be NULL
push NULL
mov eax, pProc
call eax

;Lets assume the function was STDCALL otherwise we have to adjust ESP (32 bit only)
;ADD ESP,4

;Before you terminate your program be sure to free the library
invoke FreeLibrary, hModule
invoke ExitProcess, 0
Posted on 2009-08-25 04:39:30 by donkey