Skip to content

Commit

Permalink
error 126 oh mama
Browse files Browse the repository at this point in the history
  • Loading branch information
freedom7341 committed Jul 27, 2024
1 parent cab94ca commit 0dd9861
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 24 deletions.
64 changes: 41 additions & 23 deletions CscdSvc/hook.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,7 @@ __declspec(dllexport) BOOL CALLBACK InstallUserHook()
WCHAR szFullPath[MAX_PATH];
USERAPIHOOKINFO uah;

OutputDebugString(L"InstallUserHook called\n");

SvcMessageEvent(TEXT("InstallUserHook"));
OutputDebugString(TEXT("InstallUserHook called\n"));

// Unregister before we do anything
// TODO: kill uxtheme kill uxtheme
Expand Down Expand Up @@ -74,9 +72,9 @@ __declspec(dllexport) BOOL CALLBACK InstallUserHook()
\* * * */
__declspec(dllexport) BOOL CALLBACK InitUserHook(UAPIHK State, PUSERAPIHOOK puah)
{
OutputDebugString(L"InitUserHook called\n");
OutputDebugString(TEXT("InitUserHook called\n"));

SvcMessageEvent(TEXT("InstallUserHook called"));
SvcMessageEvent(TEXT("InitUserHook called"));

// Don't initialize if the state isn't appropriate.
if (!puah || State != uahLoadInit)
Expand All @@ -85,7 +83,7 @@ __declspec(dllexport) BOOL CALLBACK InitUserHook(UAPIHK State, PUSERAPIHOOK puah
return TRUE;
}

OutputDebugString(L"InitUserHook initializing\n");
OutputDebugString(TEXT("InitUserHook initializing\n"));

SvcMessageEvent(TEXT("InitUserHook initializing"));

Expand Down Expand Up @@ -163,7 +161,6 @@ __declspec(dllexport) BOOL CALLBACK InitUserHook(UAPIHK State, PUSERAPIHOOK puah
\* * * */
__declspec(dllexport) BOOL CALLBACK RemoveUserHook(VOID)
{
MessageBox(NULL, L"test", L"RemoveUserHook called", MB_OK);
return UnregisterUserApiHookDelay();
}

Expand All @@ -188,33 +185,54 @@ BOOL WINAPI RegisterUserApiHookDelay(HINSTANCE hInstance, PUSERAPIHOOKINFO ApiHo
dwMajorVersion = (DWORD)(LOBYTE(LOWORD(dwVersion)));
dwMinorVersion = (DWORD)(HIBYTE(LOWORD(dwVersion)));

if (hLib)
if (!hLib)
{
if ((dwMajorVersion == 5) && (dwMinorVersion == 1))
{
USERAPIHOOKINFO_XP uah;
RUAH_XP fLib = (RUAH_XP)GetProcAddress(hLib, "RegisterUserApiHook");
// Failed to load DLL
OutputDebugString(TEXT("Failed to load user32\n"));

uah.hInstance = hInstance;
uah.CallbackFunc = (FARPROC)InitUserHook;
return FALSE;
}

bRet = fLib(&uah);
}
else if (((dwMajorVersion == 5) && (dwMinorVersion == 2))
|| (dwMajorVersion >= 6))
// Windows XP specific
if ((dwMajorVersion == 5) && (dwMinorVersion == 1))
{
USERAPIHOOKINFO_XP uah;
RUAH_XP fLib = (RUAH_XP)GetProcAddress(hLib, "RegisterUserApiHook");

if (fLib == NULL)
{
RUAH fLib = (RUAH)GetProcAddress(hLib, "RegisterUserApiHook");
// Failed to load DLL
OutputDebugString(TEXT("Failed to load RegisterUserApiHook\n"));

bRet = fLib(ApiHookInfo);
return FALSE;
}

FreeLibrary(hLib);
uah.hInstance = hInstance;
uah.CallbackFunc = (FARPROC)InitUserHook;

SvcMessageEvent(TEXT("RegisterUserApiHook"));
bRet = fLib(&uah);
}
// Server 2003 and newer
else if (((dwMajorVersion == 5) && (dwMinorVersion == 2))
|| (dwMajorVersion >= 6))
{
RUAH fLib = (RUAH)GetProcAddress(hLib, "RegisterUserApiHook");

return bRet;
if (fLib == NULL)
{
// Failed to load DLL
OutputDebugString(TEXT("Failed to load RegisterUserApiHook\n"));

return FALSE;
}

bRet = fLib(ApiHookInfo);
}

FreeLibrary(hLib);

return bRet;

// ApiHook is not support on Windows
// 2000 or below!
return FALSE;
Expand Down
3 changes: 2 additions & 1 deletion CscdSvc/svc.c
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,8 @@ VOID SvcMessageEvent(LPTSTR szFunction)

StringCchPrintf(Buffer, 80, TEXT("%s failed with %d"), szFunction, GetLastError());

MessageBox(NULL, Buffer, SVCNAME, MB_SERVICE_NOTIFICATION | MB_OK);
//MessageBox(NULL, Buffer, SVCNAME, MB_SERVICE_NOTIFICATION | MB_OK);
MessageBox(NULL, Buffer, SVCNAME, MB_OK);

return;
}

0 comments on commit 0dd9861

Please sign in to comment.