0

So here is what I asking:

lea eax, [esp]
push    104h        ; Count
push    offset a__2 ; ".\\"
push    eax     ; Dest
call    _strncpy
add esp, 0Ch

Can you please explain me this asm code snippet. The eax register late is assigned as an character pointer to an global variable. My reall question is how allocated memory on stack that doesn't poped at the end of the functions is written on c++ language.

Edited by sasho648

2
Contributors
1
Reply
2
Views
4 Years
Discussion Span
Last Post by deceptikon
0

Can you please explain me this asm code snippet.

It looks straightforward to me. Arguments are pushed onto the stack, _strncpy() is called, and the stack is adjusted to "remove" the arguments. Which parts are confusing you?

My reall question is how allocated memory on stack that doesn't poped at the end of the functions is written on c++ language.

In C++ all memory pushed onto the stack in or by the function will be popped. Attempts to use a pointer to any local variables or parameters after the function returns invokes undefined behavior because you're referencing memory that's highly likely to be reused almost immediately for other things.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.