If I try to use the LoadLibrary to load User32.dll the function returns error 14007 (ERROR_SXS_KEY_NOT_FOUND). This is the code I use:
SetLastError(0); //To make sure there are no previous errors.
HINSTANCE hUserModule = LoadLibrary(L"User32.dll");
if (hUserModule == NULL) { //Checking if hUserModule is NULL
MessageBoxA(NULL, "Fatal error", "", 16);
ExitProcess(0);
} //hUserModule is not NULL
printf("%d\n", GetLastError()); //14007
DWORD paMessageBoxA = (DWORD)GetProcAddress(hUserModule, "MessageBoxA");
__MessageBoxA MsgBox = (__MessageBoxA)paMessageBoxA; //typedef int(__stdcall *__MessageBoxA)(HWND, LPCSTR, LPCSTR, UINT);
MsgBox(NULL, "", "", 64); //Application crahses
So the hUserModule is not NULL, but also not valid. Why is this?
EDIT: GetModuleHandle also doesn't work