I'm just learning how to create a dll with C++.
There appears this :
BOOL WINAPI DllMain(HINSTANCE hinstDLL,DWORD fdwReason,LPVOID lpvReserved)
And I can not understand what is "WINAPI"
in DllMain()
?
I know that a function is :
typeReturn functionName (params) { function body }
typeReturn
: is the value that function returns,
functionName
: is the name of the function,
params
: are the parameters for the function,
{function body} : is the code inside in the function.
...
Then, following the explanation, what does WINAPI
mean in C++ that or __stdcall
?
I'm not asking what means WINAPI
itself.
************ UPDATE **************
C++ has (calling conventions) that is used to put in memory each parameter given in a special way. please read correctly the question and avoid mark it as duplicate, because people learning c/c++ needs learn without fall into confusions
WINAPI
is defined as __stdcall
.
Actually __stdcall
is a calling convention And different calling conventions push parameters in different ways, Bellow are some of c/c++
Calling Conventions :
In x86 :
C
calling convention (__cdecl
). The main characteristics of __cdecl
calling convention are :
Standard calling convention (__stdcall
). The main characteristics of __stdcall
calling convention are :
Fast calling convention (__fastcall
). he main characteristics of __fastcall
calling convention are :
'@'
character and appending a '@'
and the number of bytes (decimal) of space required by the arguments. In x64 :
In x64
, only __fastcall
exists. All other attributes are ignored.
The x64
Application Binary Interface (ABI) uses a four register fast-call calling convention by default.
Notice : When you call a function, what happens at the assembly level is all the passed-in parameters are pushed to the stack or placed in registers or placed in static storage, then the program jumps to a different area of code. The new area of code looks at the stack and expects the parameters to be placed there.
Different calling conventions push parameters in different ways. Some might push the first parameter first, or some might push the first param last. Or some might keep a parameter in a register and not push it at all.
By specifying a calling convention, you are telling the compiler how the parameters are to be pushed.