resolved camelCase and the " :" problem

This commit is contained in:
Kagamine Haku 2024-10-16 15:53:52 +07:00
parent f39b9ce3a0
commit 97d2d6b9bc

View File

@ -4,7 +4,7 @@
#include "util/dprintf.h" #include "util/dprintf.h"
#include "platform/opensslpatch.h" #include "platform/opensslpatch.h"
static char* GetCpuName() { static char* get_cpu_name() {
FILE* fp; FILE* fp;
char buffer[128]; char buffer[128];
char* cpu_info = NULL; char* cpu_info = NULL;
@ -30,7 +30,7 @@ static char* GetCpuName() {
return cpu_info; 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") || if (strstr(cpuname, "Core 2 Duo") || strstr(cpuname, "Core 2 Quad") ||
(strstr(cpuname, "Pentium") && !strstr(cpuname, "G")) || strstr(cpuname, "Celeron")) { (strstr(cpuname, "Pentium") && !strstr(cpuname, "G")) || strstr(cpuname, "Celeron")) {
return 0; return 0;
@ -59,14 +59,14 @@ static int CheckCpu(char* cpuname) {
return 0; return 0;
} }
static void OpenSSLPatch(void) { static void openssl_patch(void) {
const char* variablename = "OPENSSL_ia32cap"; const char* variablename = "OPENSSL_ia32cap";
const char* variablevalue = "~0x20000000"; const char* variablevalue = "~0x20000000";
HKEY hKey; HKEY hKey;
if (RegOpenKeyExA(HKEY_CURRENT_USER, "Environment", 0, KEY_SET_VALUE, &hKey) == ERROR_SUCCESS) { 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) { 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);
} else { } else {
dprintf("OpenSSL Patch: Error: Failed to set the user environment variable.\n"); 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) { int openssl_patch_apply(void) {
char* cpuname = GetCpuName(); char* cpuname = get_cpu_name();
if (cpuname == NULL) { if (cpuname == NULL) {
dprintf("OpenSSL Patch: Error: Unable to detect CPU.\n"); dprintf("OpenSSL Patch: Error: Unable to detect CPU.\n");
return 1; return 1;
} }
if (CheckCpu(cpuname)) { if (check_cpu(cpuname)) {
OpenSSLPatch(); openssl_patch();
} }
free(cpuname); free(cpuname);
return 0; return 0;