Here is a test piece of code I'm having difficulties with and for the live of me can not figure out
how to make it work. Nasm is assembling my code different than I expect. The string is not copied
to the stack buffer but somewhere else. How can I make this piece work without globals?
PROC testproc,source
LOCAL buf,128
lea eax,[@buf]
scall RtlZeroMemory,eax,128 ;zero stack buffer
lcall strlen,[@source] ;get lenght of string, local call
mov ecx,eax ;copy length
lea edi,[@buf] ;get address of local buffer
lea esi,[@source] ;get source address in data
mov esi,[esi] ;dereference
xor eax,eax ;clear eax
inc ecx ;adjust for 0
while ecx,g,0
mov al,[esi] ;loop through source string and copy to dest
mov [edi],al <====== ;MOV BYTE PTR SS:[EDI],AL
inc esi
inc edi
dec ecx
wend ;until ecx = zer0 = string lenght
lea eax,[@buf] ;print string to console
scall StdOut,eax
ENDP
00401412 |. 89C1 MOV ECX,EAX
00401414 |. 8D7D 80 LEA EDI,DWORD PTR SS:[EBP-80]
00401417 |. 8D75 08 LEA ESI,DWORD PTR SS:[EBP+8]
0040141A |. 8B36 MOV ESI,DWORD PTR DS:[ESI]
0040141C |. 31C0 XOR EAX,EAX
0040141E |. 41 INC ECX
0040141F |> 81F9 00000000 /CMP ECX,0
00401425 |. 0F8E 09000000 |JLE StringMa.00401434
0040142B |. 8A06 |MOV AL,BYTE PTR DS:[ESI]
0040142D |. 8807 |MOV BYTE PTR DS:[EDI],AL <======
0040142F |. 46 |INC ESI
00401430 |. 47 |INC EDI
00401431 |. 49 |DEC ECX
00401432 |.^EB EB \JMP SHORT StringMa.0040141F
I would also like to do this:
lea edi,[@buf] ;Local buffer
scall strcpy,edi,[@source] ;DLL call
lea eax,[@buf]
scall StdOut,eax ;print to console
Tx Klod