The cleanup responsibility is the same whether the function is imported or integrated in the calling module. It's the calling convention alone that dictates who should do the cleanup.
How do I know when to cleanup the stack
-
15-07-2023 - |
Question
I have a function in C & C++ that looks like:
__declspec(dllexport) bool CreateSocket(SSLSocket* ssl_info);
I believe that by default should use the cdecl
calling convention.
If in assembly I import the module and do:
push sockinfo
call [CreateSocket]
Do I have to do: add esp, 0x04
to restore the stack? Or is it restored automatically because it is an imported function? I ask this because for printf
which is cdecl
convention and imported, I have to clean up the stack myself. For WINAPI
I don't have to do that.
Do I have to do this for exported/all functions or just for functions I write myself?
Solution
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow