Skip the patch when already patched
parent
8aef1cfa79
commit
2d3d6fc2bb
|
@ -26,38 +26,55 @@ int check_cpu() {
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int is_env_variable_set(const char* variablename, const char* expectedvalue) {
|
||||
char currentvalue[256];
|
||||
DWORD length = GetEnvironmentVariableA(variablename, currentvalue, sizeof(currentvalue));
|
||||
|
||||
if (length > 0 && length < sizeof(currentvalue)) {
|
||||
return strcmp(currentvalue, expectedvalue) == 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
//Set User's Environment variable via registry
|
||||
// static void openssl_patch(void) {
|
||||
// const char* variablename = "OPENSSL_ia32cap";
|
||||
// const char* variablevalue = "~0x20000000";
|
||||
static void openssl_patch(void) {
|
||||
const char* variablename = "OPENSSL_ia32cap";
|
||||
const char* variablevalue = "~0x20000000";
|
||||
|
||||
// HKEY hKey;
|
||||
// if (RegOpenKeyExA(HKEY_CURRENT_USER, "Environment", 0, KEY_SET_VALUE, &hKey) == ERROR_SUCCESS) {
|
||||
// if (RegSetValueExA(hKey, variablename, 0, REG_SZ, (const BYTE*)variablevalue, strlen(variablevalue) + 1) == ERROR_SUCCESS) {
|
||||
// dprintf("OpenSSL Patch: Applied successfully, set the user environment variable %s to %s\n", variablename, variablevalue);
|
||||
// } else {
|
||||
// dprintf("OpenSSL Patch: Error: Failed to set the user environment variable.\n");
|
||||
// }
|
||||
if (is_env_variable_set(variablename, variablevalue)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// RegCloseKey(hKey);
|
||||
HKEY hKey;
|
||||
if (RegOpenKeyExA(HKEY_CURRENT_USER, "Environment", 0, KEY_SET_VALUE, &hKey) == ERROR_SUCCESS) {
|
||||
if (RegSetValueExA(hKey, variablename, 0, REG_SZ, (const BYTE*)variablevalue, strlen(variablevalue) + 1) == ERROR_SUCCESS) {
|
||||
dprintf("OpenSSL Patch: Applied successfully. User environment variable %s set to %s\n", variablename, variablevalue);
|
||||
SendMessageTimeoutA(HWND_BROADCAST, WM_SETTINGCHANGE, 0, (LPARAM)"Environment", SMTO_ABORTIFHUNG, 5000, NULL);
|
||||
dprintf(
|
||||
"Please close this windows and reopen the game to enjoy.\n"
|
||||
);
|
||||
ExitProcess(0);
|
||||
} else {
|
||||
dprintf("OpenSSL Patch: Error: Failed to set the user environment variable.\n");
|
||||
}
|
||||
|
||||
// SendMessageTimeoutA(HWND_BROADCAST, WM_SETTINGCHANGE, 0, (LPARAM)"Environment", SMTO_ABORTIFHUNG, 5000, NULL);
|
||||
// } else {
|
||||
// dprintf("OpenSSL Patch: Error: Failed to open the user environment registry key.\n");
|
||||
// }
|
||||
// }
|
||||
RegCloseKey(hKey);
|
||||
} else {
|
||||
dprintf("OpenSSL Patch: Error: Failed to open the user environment registry key.\n");
|
||||
}
|
||||
}
|
||||
|
||||
//Set environment variable for current process
|
||||
static void openssl_patch(void) {
|
||||
const wchar_t* variablename = L"OPENSSL_ia32cap";
|
||||
const wchar_t* variablevalue = L"~0x20000000";
|
||||
// static void openssl_patch(void) {
|
||||
// const wchar_t* variablename = L"OPENSSL_ia32cap";
|
||||
// const wchar_t* variablevalue = L"~0x20000000";
|
||||
|
||||
if (SetEnvironmentVariableW(variablename, variablevalue)) {
|
||||
dprintf("OpenSSL Patch: Applied successfully, set the environment variable %ls to %ls\n", variablename, variablevalue);
|
||||
} else {
|
||||
dprintf("OpenSSL Patch: Error: Failed to set the environment variable.\n");
|
||||
}
|
||||
}
|
||||
// if (SetEnvironmentVariableW(variablename, variablevalue)) {
|
||||
// dprintf("OpenSSL Patch: Applied successfully, set the environment variable %ls to %ls\n", variablename, variablevalue);
|
||||
// } else {
|
||||
// dprintf("OpenSSL Patch: Error: Failed to set the environment variable.\n");
|
||||
// }
|
||||
// }
|
||||
|
||||
HRESULT openssl_patch_apply(const struct openssl_patch_config *cfg) {
|
||||
HRESULT hr;
|
||||
|
|
Loading…
Reference in New Issue