mirror of
https://gitlab.com/Mr_Goldberg/goldberg_emulator.git
synced 2025-04-14 23:38:05 +02:00
Add 32bit registry view editing to ColdClientLoader.
This commit is contained in:
parent
629473b53e
commit
e88f92cf4a
1 changed files with 37 additions and 0 deletions
|
@ -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.
|
||||
|
|
Loading…
Reference in a new issue