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

Open
kagaminehaku wants to merge 5 commits from kagaminehaku/segatools:develop into develop
First-time contributor

It ensures that only intel cpus of gen 10 or newer will have the OpenSSL patch applied, other cpus are skipped.
Uses user-level environment variables

It ensures that only intel cpus of gen 10 or newer will have the OpenSSL patch applied, other cpus are skipped. Uses user-level environment variables
kagaminehaku added 1 commit 2024-10-15 21:17:09 +00:00
Dniel97 requested changes 2024-10-16 07:09:24 +00:00
@ -0,0 +4,4 @@
#include "util/dprintf.h"
#include "platform/opensslpatch.h"
int ChecknPatch(void) {
Owner

Please use snake_case instead of camelCase for the function names.

Please use snake_case instead of camelCase for the function names.
Owner

Still camelCase.

Still camelCase.
kagaminehaku marked this conversation as resolved
@ -0,0 +15,4 @@
if (CheckCpu(cpuname)) {
OpenSSLPatch();
dprintf("OpenSSL Patch applied successfully.\n");
Owner

To make it clear where the printed message in the console came from, prefix every string with "OpenSSL Patch:" or similar.

To make it clear where the printed message in the console came from, prefix every string with "OpenSSL Patch:" or similar.
kagaminehaku marked this conversation as resolved
@ -0,0 +17,4 @@
OpenSSLPatch();
dprintf("OpenSSL Patch applied successfully.\n");
} else {
dprintf("Info: OpenSSL Patch is not required (AMD or Intel < 10th gen or older CPU detected).\n");
Owner

Please remove that, as this will just clutter the output.

Please remove that, as this will just clutter the output.
kagaminehaku marked this conversation as resolved
@ -0,0 +87,4 @@
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("Successfully set the user environment variable %s to %s\n", variablename, variablevalue);
Owner

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"); ```
kagaminehaku marked this conversation as resolved
@ -0,0 +2,4 @@
#include <windows.h>
int ChecknPatch(void);
Owner

Only add the function you need to access from outside so in your case only ChecknPatch(). All other functions can be static.

Only add the function you need to access from outside so in your case only `ChecknPatch()`. All other functions can be static.
kagaminehaku marked this conversation as resolved
@ -28,6 +29,8 @@ HRESULT platform_hook_init(
assert(platform_id != NULL);
assert(redir_mod != NULL);
ChecknPatch();
Owner

I would rename it to something more descriptive, like openssl_patch_apply().

I would rename it to something more descriptive, like `openssl_patch_apply()`.
kagaminehaku marked this conversation as resolved
kagaminehaku added 1 commit 2024-10-16 08:02:05 +00:00
Dniel97 requested changes 2024-10-16 08:22:20 +00:00
@ -0,0 +66,4 @@
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);
Owner

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.
kagaminehaku marked this conversation as resolved
kagaminehaku added 1 commit 2024-10-16 08:54:02 +00:00
kagaminehaku added 1 commit 2024-10-18 06:34:45 +00:00
kagaminehaku added 1 commit 2024-10-18 06:44:57 +00:00
This pull request can be merged automatically.
You are not authorized to merge this pull request.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u develop:kagaminehaku-develop
git checkout kagaminehaku-develop
Sign in to join this conversation.
No reviewers
No Milestone
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: Dniel97/segatools#43
No description provided.