News:

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

How to invoke a pointer to a function.

Started by tilman, September 20, 2011, 02:09:05 PM

Previous topic - Next topic

Vortex

Hi tilman,

The _invoke macro does not perform any checking. Assemblers SolAsm and Fasm don't do any type of checking too.

tilman

Oh dear, let's up I won't have to use them any time soon ;0

dancho

Fasm does checking the count of parameters in procedure calls if you include extended headers ( win32axp.inc or win32wxp.inc )
in your file...


drizz

Hi,

Here are some examples:
http://www.masm32.com/board/index.php?topic=8134.msg59391#msg59391 (look here first)
http://www.masm32.com/board/index.php?topic=11110.msg82041#msg82041
http://www.masm32.com/board/index.php?topic=5299.msg39702#msg39702
http://www.masm32.com/board/index.php?topic=5302.msg39704#msg39704

Quote from: tilman on September 20, 2011, 04:01:29 PM
Thanks a lot for your help, I just found the answer here
...
I actually discovered another simplification of the official solution:
++ for answering your question by yourself

Quote from: tilman on September 20, 2011, 05:31:05 PMI actually switched to WinInc
+ for using WinInc

Quote from: tilman on September 20, 2011, 05:49:33 PMBecause, as I understand it, that's the whole point of using invoke over call (and yes, I tried to get by with just call and I failed and invoke saved my bacon :bg)
+ for stating why is masm/jwasm better than other assemblers

Quote from: tilman on September 20, 2011, 06:10:48 PM
Oh dear, let's up I won't have to use them any time soon ;0
+  :lol

Thats 5 pluses from me  :)  :U
The truth cannot be learned ... it can only be recognized.

ToutEnMasm


To use invoke with a pointer on a proc,you need just some declare
Quote
   TestProc PROTO  :DWORD    

   Pfunction TYPEDEF PROTO   :DWORD
   Ffunction TYPEDEF PTR Pfunction
   function TEXTEQU <Ffunction ptr ADRfunction>
.data
ADRfunction dd TestProc
.code
.....
                invoke function,NULL   
here is the function who is call
Quote
;################################################################
TestProc PROC  arg:DWORD
         Local  retour:DWORD
         mov retour,1
   
   invoke MessageBox,NULL,SADR("Succeed"),SADR("call to function"),MB_OK

FindeTestProc:
         mov eax,retour
         ret
TestProc endp