This is all very specific to Windows, we are not talking about standard C ++ here.
Documentation Check StartServiceDispatcher has only one argument and is declared as a WINAPI , which in turn means __stcall calling convention.
For stand-alone functions, __stdcall is one of two main calling conventions. The other is __cdecl . The difference in machine code levels is simply the one who restores the stack pointer: with __stdcall it is the function itself, and with __cdecl it is the call code.
When a function is actually __stdcall , but called as if it were __cdecl , the situation is that there are two attempts to restore the stack pointer: one at the exit of the function and one in the calling code, The function in the function will succeed. Depending on how you try to call the code, it can completely ruin things (for example, simply adding the required offset, treating the stack pointer as relative) or it may not have a harmful effect. But this most likely creates a mess, since the assumption about the value of the stack pointer when returning from the function is incorrect.
When the function is actually __cdecl , it will not restore the stack pointer itself, since this is the responsibility of the call code. And if the calling code treats it as __stdcall , then the calling code will not restore it, since the function does this from the presentation of the calling code. As a result, if you did not receive an early failure (due to broken assumptions), then you should repeat that repeated calls, say, in a loop, will contain stack space.
All this is very important. Undefined Behavior.
And one property of Undefined Behavior is that it can do anything, including, apparently, the work of & hellip;
Cheers and hth.,