The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: -Alex- on April 22, 2011, 02:44:56 AM

Title: Invoke result of GetProcAddress
Post by: -Alex- on April 22, 2011, 02:44:56 AM
Hey guys, here is my question:

I want to invoke an API, however, its not defined, so i use GetProcAddress. How i can use "invoke" on the result, instead of pushing all parameters by hand and then call the address.

I want to use it like this:
mov UndocumentedApi,rv(GetProcAddress,hModule,"ApiName")
invoke UndocumentedApi,param1,param2,param3,paramX

Thanks (:
Title: Re: Invoke result of GetProcAddress
Post by: dedndave on April 22, 2011, 02:50:26 AM
ApiName PROTO :DWORD,:DWORD,:DWORD,:DWORD
Title: Re: Invoke result of GetProcAddress
Post by: -Alex- on April 22, 2011, 02:59:58 AM
I get "error A2001: immediate operand not allowed" on the "mov UndocumentedApi,rv(GetProcAddress,hModule,"ApiName")" line.
Title: Re: Invoke result of GetProcAddress
Post by: dedndave on April 22, 2011, 03:56:59 AM
yah - i have seen this before
let me see if i can find an example...
Title: Re: Invoke result of GetProcAddress
Post by: dedndave on April 22, 2011, 04:03:45 AM
here is an example of something similar
http://www.masm32.com/board/index.php?topic=11772.msg89003#msg89003

he creates a jmp table entry

func        db 0FFh,025h ; define a jump entry
            dd pFunc


then...
SetConsoleIcon  EQU <pr1 PTR func>

"pr1" is used because the function has 1 parameter
use "pr4" for 4 parameters, etc

after that, the function can be invoked
Title: Re: Invoke result of GetProcAddress
Post by: hutch-- on April 22, 2011, 04:23:48 AM
Alex,

Have a look at "Specialised Prototypes" in the "High Level Macro Help file in MASM32. Write the prototype, place the address of the function in the appropriate variable then "invoke" the function like normal.
Title: Re: Invoke result of GetProcAddress
Post by: -Alex- on April 22, 2011, 11:08:07 AM
Thank you both, i used the SPROTO macro, and its working fine  :U