Example of the program running: https://www.youtube.com/watch?v=3famXyrOGEs
Make sure to have Steam already running in the background.
Last active
September 28, 2024 17:15
-
-
Save Aetopia/fe1bea9f8f313a0fd882de929c55d04a to your computer and use it in GitHub Desktop.
Dynamically terminating the Steam WebHelper.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <windows.h> | |
#define printf __builtin_printf | |
BOOL EnumWindowsProc(HWND hWnd, LPARAM lParam) | |
{ | |
DWORD maxCount = GetWindowTextLengthW(hWnd) + 1; | |
WCHAR className[256] = {}, windowText[maxCount] = {}; | |
GetClassNameW(hWnd, className, 256); | |
GetWindowTextW(hWnd, windowText, maxCount); | |
if (!wcscmp(L"vguiPopupWindow", className)) | |
// while (!IsWindowVisible(hWnd)) | |
ShowWindow(hWnd, SW_HIDE); | |
// return FALSE; | |
return TRUE; | |
} | |
INT WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, INT nShowCmd) | |
{ | |
HKEY keyHandle = NULL, subKeyHandle = NULL; | |
HANDLE eventHandle = CreateEventW(NULL, TRUE, FALSE, NULL), | |
threadHandle = OpenThread(THREAD_SUSPEND_RESUME, FALSE, GetWindowThreadProcessId(FindWindowW(L"vguiPopupWindow", L"Untitled"), NULL)); | |
WCHAR keyName[255] = {}, runningAppName[255] = {}; | |
HWND windowHandle = NULL; | |
BOOL appRunning = FALSE; | |
DWORD i = 0, dataSize = 0; | |
// | |
// printf("%ld\n", threadHandle); | |
RegOpenKeyExW(HKEY_CURRENT_USER, L"SOFTWARE\\Valve\\Steam\\Apps", 0, KEY_ALL_ACCESS, &keyHandle); | |
while (TRUE) | |
{ | |
RegNotifyChangeKeyValue(keyHandle, TRUE, REG_NOTIFY_CHANGE_LAST_SET, eventHandle, TRUE); | |
WaitForSingleObject(eventHandle, INFINITE); | |
while (!RegEnumKeyExW(keyHandle, i, keyName, &((DWORD){255}), NULL, NULL, NULL, NULL)) | |
{ | |
RegOpenKeyExW(keyHandle, keyName, 0, KEY_ALL_ACCESS, &subKeyHandle); | |
RegGetValueW(subKeyHandle, NULL, L"Name", RRF_RT_REG_SZ, NULL, NULL, &dataSize); | |
WCHAR *appName = _malloca(dataSize); | |
if (dataSize) | |
{ | |
RegGetValueW(subKeyHandle, NULL, L"Name", RRF_RT_REG_SZ, NULL, appName, &dataSize); | |
RegGetValueW(subKeyHandle, NULL, L"Running", RRF_RT_REG_DWORD, NULL, &appRunning, &((DWORD){sizeof(BOOL)})); | |
if (appRunning && !wcslen(runningAppName)) | |
{ | |
printf("%ld\n", windowHandle); | |
EnumWindows(EnumWindowsProc, 0); | |
SuspendThread(threadHandle); | |
printf("%ls | %ls | %ld\n", keyName, appName, appRunning); | |
system("taskkill /f /im steamwebhelper.exe"); | |
wcscpy(runningAppName, appName); | |
} | |
else if (!appRunning && !wcscmp(runningAppName, appName)) | |
{ | |
memset(runningAppName, 0, sizeof(runningAppName)); | |
printf("%ls | %ls | %ld\n", keyName, appName, appRunning); | |
ResumeThread(threadHandle); | |
} | |
} | |
RegCloseKey(subKeyHandle); | |
i += 1; | |
} | |
i = 0; | |
} | |
RegCloseKey(keyHandle); | |
return EXIT_SUCCESS; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment