As title, what exactly does LOCAL do? This question come to my mind when i tried to do this:

LOCAL output[64]
push ecx
lea ecx,output
mov byte ptr[ecx],65
invoke SetDlgItemText,hwnd,1005,addr output
pop ecx

I can see that there is an A at my DlgItem but XP just says that my program has made some kind of error :/
Then i started to think about what LOCAL do...

so... anyone? :tongue:
Posted on 2004-06-23 17:35:26 by bj1500
LOCAL reserves a certain number of bytes on the stack and assigns it a label based on it's offset from EBP. For example :

myproc PROC

would reserve 4 bytes (DWORD) on the stack
Posted on 2004-06-23 17:55:43 by donkey
Okey i understand :)
Posted on 2004-06-23 18:51:19 by bj1500

Also, the variables you use (on the stack) contain garbage when you enter a procedure.
Posted on 2004-06-23 19:15:19 by Jurgen
Hum, i still can't fix this problem.

I am sure that A is displayed on my item on my dialog, and then XP shows that my program have made a error and close my program.
No really error message are shown so i dont can figure out what where the problem is :(
Posted on 2004-06-24 06:38:25 by bj1500
Try replacing with

mov word ptr,65
Posted on 2004-06-24 07:56:14 by roticv
Still not working :(
Posted on 2004-06-24 08:08:58 by bj1500

Still not working :(

have you tried running your code through a debugger/commenting out lines/otherwise trying to determine which line your code is breaking on? also, due to your indentation, are you trying to access something off the stack from a different procedure? i'm not whether that will work or not, not having MASM installed at the moment (i really should start win32asming again).
Posted on 2004-06-24 08:34:11 by jademtech
Hum i works when i commenting out this line:
invoke SetDlgItemText,hwnd,1005,addr output
Posted on 2004-06-24 08:40:20 by bj1500
Hum this is strange, looks like SetDlgItemText messing up some other registers so when i put pusha before and popa after it works
Posted on 2004-06-24 08:42:24 by bj1500
What registers are you referring to? It is normal for api to mess up eax, edx and ecx.
Posted on 2004-06-24 09:37:38 by roticv
I'm using all of them
So i should always save eax,edx,ecx before calling any API when i'm using these register in my code?
Posted on 2004-06-24 09:40:04 by bj1500
If you require their values to be preserved. Generally if I do not want the values to be changed by any api calls I place them in ebx, edi or esi, since their values will not be modified by an api. When I am kind of short on registers, then I would use push/pushad/pop/popad to preserve the values in the register
Posted on 2004-06-24 09:44:55 by roticv