News:

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

[Niewbies]: translate invoke with GetProcAddress

Started by cicciounico, July 12, 2010, 10:21:41 AM

Previous topic - Next topic

cicciounico

Hi,
How can translate:

LOCAL sinfo  :STARTUPINFO
invoke RtlZeroMemory, addr sinfo, sizeof STARTUPINFO
with GetProcAddress?

I have try to write this code:
invoke MyGet,ADDR NtDllName,ADDR MyCriptStr ; RtlZeroMemory
mov hwndProc, eax 
push sizeof STARTUPINFO
push addr sinfo <-- Here Error
call hwndProc  ;invoke RtlZeroMemory, addr sinfo, sizeof STARTUPINFO

Thanks

Ghandi


push addr sinfo <-- Here Error

could be

lea eax, sinfo
push eax


You cannot directly push the address of a local variable, you need to point a register at it or reference it in some indirect way then push that reference. I'm sure someone else can word it correctly, i just know what has caused me errors, lol. I also recall reading that it is better to use the variable name for 'sizeof' rather than the structure it represents. But thinking about it, if the structure is declared and the local is declared as an instance of that structure, what is the actual difference between:


push sizeof STARTUPINFO

or

push sizeof sinfo



Can someone shed some light on that?

HR,
Ghandi

cicciounico

Yesssss!   :bg
Now work!
This is a correction:
push sizeof STARTUPINFO
lea eax, sinfo
push eax

thanks    :U   :cheekygreen:

dedndave

Quotepush sizeof STARTUPINFO

or

push sizeof sinfo



Can someone shed some light on that?

just a guess here....

the assembler treats STARTUPINFO as a structure, but treats sinfo as just an offset

sinsi

There should be no difference in using the var or the struc. The only catch is is you have an array of strucs, if you use 'sizeof var' you get the total size of all structures whereas using 'type var' gives you the size of one structure.
Light travels faster than sound, that's why some people seem bright until you hear them.