i did my proc and called it this way

xx db "string",0

push offset xx
call test

test proc param1:dword

lea eax, param1
test endp

debugging with softice it assembles to
lea eax,
when i do d@(ebp+8) it shows what i want, but when i pass this instruction and do a d eax, eax points to some place in mem which isnt where my string is. anyone know what may be causing it ?

thanks in advance
Posted on 2002-05-12 19:36:02 by The Keeper
you already have xx's offset when "push offset xx"

so use this

mov eax, param1

instead of "lea eax, param1"
Posted on 2002-05-12 20:08:31 by muzidowa
Yep, don't have the 'param1' in the function prototype, have this instead:

test proc
pop param1
lea eax, param1
test endp

The way you had it was setting up a stack frame to hold one parameter, but the trouble was you had already manually PUSHed that parameter, so it was not inside the stack frame when you tried to reference it. When you manually PUSH parameters, you also need to manually POP them, all this is taken care of by MASM when you use the INVOKE syntax and have your function header how you originally posted.
Posted on 2002-05-12 20:13:20 by sluggy
Im surprised no one pointed out that 'test' is an ASM command.

Im also surprised to hear it even compiled..

Posted on 2002-05-12 21:15:08 by NaN
ahem sluggy... first, using a local *will* set up a
stack frame. Next, even without a stack frame and locals
(ie, doing "pop eax") it wouldn't work, since the first
thing on the stack is the return address. Thus, you'd
get the return address in eax, and the ret would take
you to the string... which 99% of the time will result
in a GPF.

Also, you do *not* have to do invoke to take advantage
of proc parms, you *can* do manual pushes if you want to
(not that there's usually any advantage in doing this),
and as long as you use stdcall (or another callee-fixes-stack
calling convention), things will work just fine.

Keeper, your lea code makes eax point to the parameter
on the stack. Since this parameter is a dword pointer
(and not the string itself), the correct way to get eax
to point to the string is... a simple mov.

NaN: *grin*
Posted on 2002-05-13 06:59:04 by f0dder
Err... assembled. :grin:
Posted on 2002-05-14 09:23:35 by NaN
Even bigger :grin:
Posted on 2002-05-14 09:34:40 by f0dder

pop ecx
pop eax
jmp ecx
blah ENDP

Posted on 2002-05-14 09:42:31 by Mirno