Home

thiscall

Thiscall is a calling convention used for non-static C++ member functions on 32-bit x86 platforms, most commonly with Microsoft Visual C++ on Windows. It defines how the this pointer (the object instance) and function arguments are passed and how the stack is cleaned up when a member function is called.

In this convention, the implicit this pointer is passed in the ECX register. The explicit function arguments

Thiscall is mainly associated with the Microsoft Visual C++ compiler on 32-bit Windows. Some other Windows toolchains,

Portability considerations apply when interfacing with code compiled under different ABIs or on different architectures. Because

are
passed
on
the
stack
in
right-to-left
order.
The
callee
(the
called
function)
is
responsible
for
cleaning
up
the
stack,
making
thiscall
similar
to
stdcall
in
terms
of
stack
cleanup,
but
with
the
this
pointer
supplied
in
ECX
rather
than
on
the
stack.
The
function’s
return
value
is
placed
in
EAX,
as
with
other
32-bit
integer
and
floating-point
returns.
such
as
MinGW
GCC,
implement
__thiscall
to
emulate
MSVC
behavior.
On
64-bit
Windows,
there
is
no
separate
__thiscall;
the
Windows
x64
ABI
uses
a
single
convention
for
member
functions,
with
the
this
pointer
passed
in
a
general-purpose
register
(such
as
RCX)
according
to
the
platform’s
64-bit
rules.
thiscall
relies
on
a
register
for
this
and
a
specific
stack-cleanup
model,
code
compiled
with
this
convention
may
not
be
portable
to
non-Microsoft
or
non-32-bit
environments
without
proper
interop
measures.