Even after reading some answers here on SO regarding this topic, I'm having a bad time trying to understand what exactly the following syntax does:
typedef BOOL (WINAPI *DllEntryProc)(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpReserved);
My guess:
It defines the DllEntryProc
data type as an alias for BOOL
, where DllEntryProc
is a pointer to a function that takes one HINSTANCE
, one DWORD
and one LPVOID
as arguments and returns a WINAPI
?
The code above is part of this article regarding how to load a DLL from memory. The function is then called like this:
DllEntryProc entry = (DllEntryProc) someValue;
(*entry)((HINSTANCE)baseAddress, DLL_PROCESS_ATTACH, 0);
Returning a BOOL
(thanks to that typedef), right?
It defines the DllEntryProc
data type as an alias for BOOL, where DllEntryProc is a pointer to a function that takes one HINSTANCE, one DWORD and one LPVOID as arguments and returns a WINAPI BOOL
typedef BOOL (WINAPI *DllEntryProc)(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpReserved);
DllEntryProc
is a new type like int
and you can declare variables of this type just like you can declare variables of type int
.
DllEntryProc somevar;
Now the value that you can assign to somevar
should be of type DllEntryProc
which is a pointer to a function of the said type.