typedef int(__stdcall *__MessageBoxA)(HWND, LPCSTR, LPCSTR, UINT);
As I said, im trying to learn how to reverse engineer programs using C++ / Assembly, so I'm going through some open source projects I found on the internet. But can anyone explain what this line does? Im not advanced in C++, which is why I'm going through sources.
Your code is C language. So it also compiles fine in C++.
Let 's go step by step.
int __stdcall MessageBoxA(HWND, LPCSTR, LPCSTR, UINT);
int(__stdcall *ptr)(HWND, LPCSTR, LPCSTR, UINT);
ptr = NULL;
/ assign a correct adress
ptr = MessageBoxA;
// call the function with parameters using the pointer
(*ptr)(hWnd, NULL, NULL, 0);
typedef int(__stdcall *__MessageBoxA)(HWND, LPCSTR, LPCSTR, UINT);
So a pointer to a function variable can be declared.
__MessageBoxA ptr1 = NULL;
__stdcall is the way the function is called by the compiler ( Are parameters passed from left to right or reverse ? Is return value passed through stack memory or CPU register ?) - details most people don't care as long as caller and called agree
Regards