← Learn

Introduction to Windows API

Author
Moise Medici
Updated
23 Jan 2026 · Completed

thiscall

The thiscall convention is Microsoft-specific for C++, so it appears often in C++ samples. The this argument is passed via ECX, while the rest are pushed in the stack. this is a pointer to an instance of a struct, and inside the function the struct arguments are generally used or initialized. In the example below, the first argument of the struct (x) is used by dereferencing it [ecx]. If a second argument was needed it would be taken via [ecx + 4] or any other number based on the size of the previous arguments.

FUN PROC
push ebp
mov ebp, esp
; ECX = this
mov eax, [ecx] ; eax = this->x
add eax, [ebp+8] ; + b (first stack arg)
pop ebp
ret 4 ; callee cleans 1 stack arg (b)
FUN ENDP

The caller simply populates ECX and pushes any extra arguments on the stack:

mov ecx, thisPtr
push b
call FUN_thiscall
; EAX = result