News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Invoke result of GetProcAddress

Started by -Alex-, April 22, 2011, 02:44:56 AM

Previous topic - Next topic

-Alex-

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 (:

dedndave

ApiName PROTO :DWORD,:DWORD,:DWORD,:DWORD

-Alex-

I get "error A2001: immediate operand not allowed" on the "mov UndocumentedApi,rv(GetProcAddress,hModule,"ApiName")" line.

dedndave

yah - i have seen this before
let me see if i can find an example...

dedndave

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

hutch--

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.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

-Alex-

Thank you both, i used the SPROTO macro, and its working fine  :U