Add automatically apply OpenSSL patch for Intel Gen 10+ CPUs #43

Open
kagaminehaku wants to merge 5 commits from kagaminehaku/segatools:develop into develop
Showing only changes of commit 97d2d6b9bc - Show all commits

View File

@ -4,7 +4,7 @@
#include "util/dprintf.h"
#include "platform/opensslpatch.h"
static char* GetCpuName() {
static char* get_cpu_name() {
kagaminehaku marked this conversation as resolved Outdated

Please use snake_case instead of camelCase for the function names.

Please use snake_case instead of camelCase for the function names.

Still camelCase.

Still camelCase.
FILE* fp;
char buffer[128];
char* cpu_info = NULL;
@ -30,7 +30,7 @@ static char* GetCpuName() {
return cpu_info;
}
static int CheckCpu(char* cpuname) {
static int check_cpu(char* cpuname) {
if (strstr(cpuname, "Core 2 Duo") || strstr(cpuname, "Core 2 Quad") ||
(strstr(cpuname, "Pentium") && !strstr(cpuname, "G")) || strstr(cpuname, "Celeron")) {
return 0;
@ -59,14 +59,14 @@ static int CheckCpu(char* cpuname) {
return 0;
}
static void OpenSSLPatch(void) {
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);
dprintf("OpenSSL Patch: Applied successfully, set the user environment variable %s to %s\n", variablename, variablevalue);
kagaminehaku marked this conversation as resolved Outdated

Either remove the space before " :" or remove it all together as it's redundant in my opinion.

Either remove the space before " :" or remove it all together as it's redundant in my opinion.
} else {
dprintf("OpenSSL Patch: Error: Failed to set the user environment variable.\n");
}
@ -80,14 +80,14 @@ static void OpenSSLPatch(void) {
}
int openssl_patch_apply(void) {
char* cpuname = GetCpuName();
char* cpuname = get_cpu_name();
if (cpuname == NULL) {
dprintf("OpenSSL Patch: Error: Unable to detect CPU.\n");
return 1;
}
if (CheckCpu(cpuname)) {
OpenSSLPatch();
if (check_cpu(cpuname)) {
openssl_patch();
kagaminehaku marked this conversation as resolved Outdated

I would only keep this print, change it to add that the patch applied successfully and remove the

dprintf("OpenSSL Patch applied successfully.\n");
I would only keep this print, change it to add that the patch applied successfully and remove the ```c dprintf("OpenSSL Patch applied successfully.\n"); ```
}
free(cpuname);
return 0;