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

Open
kagaminehaku wants to merge 5 commits from kagaminehaku/segatools:develop into develop
6 changed files with 41 additions and 5 deletions
Showing only changes of commit cef3406691 - Show all commits

View File

@ -23,6 +23,7 @@
#include "platform/platform.h"
#include "platform/vfs.h"
#include "platform/system.h"
#include "platform/opensslpatch.h"
void platform_config_load(struct platform_config *cfg, const wchar_t *filename)
{
@ -41,6 +42,7 @@ void platform_config_load(struct platform_config *cfg, const wchar_t *filename)
nusec_config_load(&cfg->nusec, filename);
vfs_config_load(&cfg->vfs, filename);
system_config_load(&cfg->system, filename);
openssl_patch_config_load(&cfg->openssl, filename);
}
void amvideo_config_load(struct amvideo_config *cfg, const wchar_t *filename)
@ -355,3 +357,18 @@ void epay_config_load(struct epay_config *cfg, const wchar_t *filename)
cfg->enable = GetPrivateProfileIntW(L"epay", L"enable", 1, filename);
}
void openssl_patch_config_load(struct openssl_patch_config *cfg, const wchar_t *filename)
{
// Ensure the config structure and filename are valid
assert(cfg != NULL);
assert(filename != NULL);
// Read the "enable" key from the "[openssl]" section of the configuration file
cfg->enable = GetPrivateProfileIntW(
L"openssl", // Section name
L"enable", // Key name
1, // Default value if the key is not found (disabled by default)
filename // INI file name
);
}

View File

@ -36,3 +36,4 @@ void nusec_config_load(struct nusec_config *cfg, const wchar_t *filename);
void pcbid_config_load(struct pcbid_config *cfg, const wchar_t *filename);
void vfs_config_load(struct vfs_config *cfg, const wchar_t *filename);
void system_config_load(struct system_config *cfg, const wchar_t *filename);
void openssl_patch_config_load(struct openssl_patch_config *cfg, const wchar_t *filename);

View File

@ -79,16 +79,25 @@ static void openssl_patch(void) {
}
}
int openssl_patch_apply(void) {
HRESULT openssl_patch_apply(const struct openssl_patch_config *cfg) {
HRESULT hr;
assert(cfg != NULL);
if (!cfg->enable) {
return S_FALSE;
}
char* cpuname = get_cpu_name();
if (cpuname == NULL) {
dprintf("OpenSSL Patch: Error: Unable to detect CPU.\n");
return 1;
return S_FALSE;
}
if (check_cpu(cpuname)) {
openssl_patch();
}
free(cpuname);
return 0;
return S_OK;
}

View File

@ -1,3 +1,7 @@
#pragma once
int openssl_patch_apply(void);
struct openssl_patch_config {
int enable;
};
HRESULT openssl_patch_apply(const struct openssl_patch_config *cfg);

View File

@ -29,7 +29,11 @@ HRESULT platform_hook_init(
assert(platform_id != NULL);
assert(redir_mod != NULL);
openssl_patch_apply();
hr = openssl_patch_apply(&cfg->openssl);
if (FAILED(hr)) {
return hr;
}
hr = amvideo_hook_init(&cfg->amvideo, redir_mod);

View File

@ -29,6 +29,7 @@ struct platform_config {
struct nusec_config nusec;
struct vfs_config vfs;
struct system_config system;
struct openssl_patch_config openssl;
};
HRESULT platform_hook_init(