From e88f92cf4a89a253ea0549cf397f05ef2b64c290 Mon Sep 17 00:00:00 2001 From: redpolline <11156324-redpolline@users.noreply.gitlab.com> Date: Sun, 23 Jun 2024 22:27:38 -0400 Subject: [PATCH] Add 32bit registry view editing to ColdClientLoader. --- steamclient_loader/ColdClientLoader.cpp | 37 +++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/steamclient_loader/ColdClientLoader.cpp b/steamclient_loader/ColdClientLoader.cpp index 8b15871..f322ff6 100644 --- a/steamclient_loader/ColdClientLoader.cpp +++ b/steamclient_loader/ColdClientLoader.cpp @@ -141,6 +141,7 @@ int APIENTRY wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance return 0; } HKEY Registrykey; + HKEY Registrykey_32BitView; // Declare some variables to be used for Steam registry. DWORD UserId = 0x03100004771F810D & 0xffffffff; DWORD ProcessID = GetCurrentProcessId(); @@ -149,8 +150,12 @@ int APIENTRY wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance DWORD keyType = REG_SZ; WCHAR OrgSteamCDir[MAX_PATH] = { 0 }; WCHAR OrgSteamCDir64[MAX_PATH] = { 0 }; + WCHAR OrgSteamCDir_32BitView[MAX_PATH] = { 0 }; + WCHAR OrgSteamCDir64_32BitView[MAX_PATH] = { 0 }; DWORD Size1 = MAX_PATH; DWORD Size2 = MAX_PATH; + DWORD Size3 = MAX_PATH; + DWORD Size4 = MAX_PATH; if (RegOpenKeyExW(HKEY_CURRENT_USER, L"Software\\Valve\\Steam\\ActiveProcess", 0, KEY_ALL_ACCESS, &Registrykey) == ERROR_SUCCESS) { orig_steam = true; @@ -169,30 +174,53 @@ int APIENTRY wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance return 0; } } + if (RegOpenKeyExW(HKEY_CURRENT_USER, L"Software\\Valve\\Steam\\ActiveProcess", 0, KEY_ALL_ACCESS | KEY_WOW64_32KEY, &Registrykey_32BitView) == ERROR_SUCCESS) + { + orig_steam = true; + // Get original values to restore later. + RegQueryValueExW(Registrykey_32BitView, L"SteamClientDll", 0, &keyType, (LPBYTE)& OrgSteamCDir_32BitView, &Size3); + RegQueryValueExW(Registrykey_32BitView, L"SteamClientDll64", 0, &keyType, (LPBYTE)& OrgSteamCDir64_32BitView, &Size4); + } else { + if (RegCreateKeyExW(HKEY_CURRENT_USER, L"Software\\Valve\\Steam\\ActiveProcess", 0, 0, REG_OPTION_NON_VOLATILE, + KEY_ALL_ACCESS | KEY_WOW64_32KEY, NULL, &Registrykey_32BitView, NULL) != ERROR_SUCCESS) + { + MessageBoxA(NULL, "Unable to patch Steam process informations on the Windows registry.", "ColdClientLoader", MB_ICONERROR); + TerminateProcess(processInfo.hProcess, NULL); + return 0; + } + } // Set values to Windows registry. RegSetValueExA(Registrykey, "ActiveUser", NULL, REG_DWORD, (LPBYTE)& UserId, sizeof(DWORD)); RegSetValueExA(Registrykey, "pid", NULL, REG_DWORD, (LPBYTE)& ProcessID, sizeof(DWORD)); + RegSetValueExA(Registrykey_32BitView, "ActiveUser", NULL, REG_DWORD, (LPBYTE)& UserId, sizeof(DWORD)); + RegSetValueExA(Registrykey_32BitView, "pid", NULL, REG_DWORD, (LPBYTE)& ProcessID, sizeof(DWORD)); { // Before saving to the registry check again if the path was valid and if the file exist if (GetFileAttributesW(ClientPath) != INVALID_FILE_ATTRIBUTES) { RegSetValueExW(Registrykey, L"SteamClientDll", NULL, REG_SZ, (LPBYTE)ClientPath, (DWORD)(lstrlenW(ClientPath) * sizeof(WCHAR)) + 1); + RegSetValueExW(Registrykey_32BitView, L"SteamClientDll", NULL, REG_SZ, (LPBYTE)ClientPath, (DWORD)(lstrlenW(ClientPath) * sizeof(WCHAR)) + 1); } else { RegSetValueExW(Registrykey, L"SteamClientDll", NULL, REG_SZ, (LPBYTE)"", 0); + RegSetValueExW(Registrykey_32BitView, L"SteamClientDll", NULL, REG_SZ, (LPBYTE)"", 0); } if (GetFileAttributesW(Client64Path) != INVALID_FILE_ATTRIBUTES) { RegSetValueExW(Registrykey, L"SteamClientDll64", NULL, REG_SZ, (LPBYTE)Client64Path, (DWORD)(lstrlenW(Client64Path) * sizeof(WCHAR)) + 1); + RegSetValueExW(Registrykey_32BitView, L"SteamClientDll64", NULL, REG_SZ, (LPBYTE)Client64Path, (DWORD)(lstrlenW(Client64Path) * sizeof(WCHAR)) + 1); } else { RegSetValueExW(Registrykey, L"SteamClientDll64", NULL, REG_SZ, (LPBYTE)"", 0); + RegSetValueExW(Registrykey_32BitView, L"SteamClientDll64", NULL, REG_SZ, (LPBYTE)"", 0); } } RegSetValueExA(Registrykey, "Universe", NULL, REG_SZ, (LPBYTE)"Public", (DWORD)lstrlenA("Public") + 1); + RegSetValueExA(Registrykey_32BitView, "Universe", NULL, REG_SZ, (LPBYTE)"Public", (DWORD)lstrlenA("Public") + 1); // Close the HKEY Handle. RegCloseKey(Registrykey); + RegCloseKey(Registrykey_32BitView); ResumeThread(processInfo.hThread); WaitForSingleObject(processInfo.hThread, INFINITE); @@ -209,6 +237,15 @@ int APIENTRY wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance // Close the HKEY Handle. RegCloseKey(Registrykey); } + if (RegOpenKeyExW(HKEY_CURRENT_USER, L"Software\\Valve\\Steam\\ActiveProcess", 0, KEY_ALL_ACCESS | KEY_WOW64_32KEY, &Registrykey_32BitView) == ERROR_SUCCESS) + { + // Restore the values. + RegSetValueExW(Registrykey_32BitView, L"SteamClientDll", NULL, REG_SZ, (LPBYTE)OrgSteamCDir_32BitView, Size3); + RegSetValueExW(Registrykey_32BitView, L"SteamClientDll64", NULL, REG_SZ, (LPBYTE)OrgSteamCDir64_32BitView, Size4); + + // Close the HKEY Handle. + RegCloseKey(Registrykey_32BitView); + } } // Close the SharedMem handles.