I have read MSDN documentation, I have looked at other examples, and have also asked for help from others. No one has so far found a fix so StackOverflow is my last hope.
Currently my goal is to call a function from a DLL. The example given below uses the simple windows MessageBox()
function located in user32.dll
. This has been done before, however when I attempt to do this in C it crashes around the call to GetProcAddress()
.
HMODULE hLib;
func_msgBox msgBox;
hLib = LoadLibrary("C:\\WINDOWS\\system32\\user32.dll");
if (hLib != NULL) {
printf("[+] - Loaded our library");
msgBox = (func_msgBox)GetProcAddress(hLib, "MessageBox");
if (msgBox != NULL) {
printf("[+] - Recieved our process address");
(func_msgBox)(NULL, "test", "test", 0);
printf("[+] - Called our function");
}
}
printf("Error: %s", GetLastError());
FreeLibrary(hLib);