Holy cow, I wrote a book!
If you want to figure out some quirks of a calling
you can always ask the compiler to do it for you,
on the not unreasonable assumption that the compiler
understands calling conventions.
"When a __stdcall
function returns a large structure by value,
there is a hidden first parameter that specifies the
address the return value should be stored.
But if the function is a C++ instance method,
then there is also a hidden this
Which goes first, the return value parameter
or the this pointer?"
This is another case of
You don't need to ask me a question the compiler can answer more accurately.
LargeStructure __stdcall TestMe();
void foo(Something *something)
LargeStructure x = something->TestMe();
You could compile this into a program and
then look in the debugger,
or just ask the compiler to generate an assembly
I prefer the assembly listing, since it saves a few
and the compiler provides helpful symbolic names.
00015 mov eax, DWORD PTR _something$[ebp]
; LargeStructure x = something->TestMe();
00018 lea ecx, DWORD PTR _x$[ebp]
0001e push ecx
0001f push eax
00020 call ?TestMe@Something@@
We see that the last thing pushed onto the stack
(and therefore the top parameter on the stack
at the point of the call)
is the something parameter,
which is the this
for the function.
The this pointer goes ahead of the
output structure pointer.