From b794532a8e128aaf81979ae4080d0385e9e148ba Mon Sep 17 00:00:00 2001 From: Nemoumbra Date: Sun, 11 Aug 2024 20:20:07 +0300 Subject: [PATCH] Tabulation fix + potential misaligned read fix --- Core/HLE/sceKernelModule.cpp | 8 +++++--- Windows/resource.h | 16 ++++++++-------- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/Core/HLE/sceKernelModule.cpp b/Core/HLE/sceKernelModule.cpp index e840ad4577..03ddb4860d 100644 --- a/Core/HLE/sceKernelModule.cpp +++ b/Core/HLE/sceKernelModule.cpp @@ -1219,8 +1219,9 @@ static void parsePrxLibInfo(const u8* ptr, u32 headerSize) { // The lib info prefix looks like {'\', 'y', 'r', '=', '`', 'c', '`', '0'} (Big Endian) const u64_le lib_info_prefix = 0x306063603D72795C; - auto lib_info_ptr = reinterpret_cast(ptr); - if (*lib_info_ptr != lib_info_prefix) { + + // 'ptr' can potentially be misaligned here so let's use a memcmp instead of dereferencing 8 bytes at 'ptr' + if (memcmp(ptr, &lib_info_prefix, 8) != 0) { // That's very wrong! WARN_LOG(Log::sceModule, "~SCE module, unexpected header (not an error)"); return; @@ -1236,13 +1237,14 @@ static void parsePrxLibInfo(const u8* ptr, u32 headerSize) { } nameBuffer[12] = '\0'; - u8 versionBuffer[8] = "?.?.?.?"; + u8 versionBuffer[7 + 1] = "?.?.?.?"; for (int i = 0; i < 4; ++i, ++ptr) { u8 symbol = *ptr - 0x14u; if (isprint(symbol)) { versionBuffer[2 * i] = symbol; } } + // The null byte is already in its place, no need to assign it manually INFO_LOG(Log::sceModule, "~SCE module: Lib-PSP %s (SDK %s)", nameBuffer, versionBuffer); } diff --git a/Windows/resource.h b/Windows/resource.h index 9a4c943a54..d7fce4a416 100644 --- a/Windows/resource.h +++ b/Windows/resource.h @@ -61,7 +61,7 @@ #define IDD_GEDBG_TAB_MATRICES 255 #define IDD_GEDBG_STEPCOUNT 256 #define IDD_CPUWATCH 257 -#define IDD_EDITSYMBOLS 258 +#define IDD_EDITSYMBOLS 258 #define IDC_STOPGO 1001 #define IDC_ADDRESS 1002 @@ -123,12 +123,12 @@ #define IDC_SHOWOFFSETS 1200 #define IDC_GEDBG_PRIMCOUNTER 1201 #define IDC_BUTTON_SEARCH 1204 -#define IDC_EDITSYMBOLS_SCAN 1205 -#define IDC_EDITSYMBOLS_REMOVE 1206 -#define IDC_EDITSYMBOLS_ADDRESS 1207 -#define IDC_EDITSYMBOLS_SIZE 1208 -#define IDC_EDITSYMBOLS_OK 1209 -#define IDC_EDITSYMBOLS_CANCEL 1210 +#define IDC_EDITSYMBOLS_SCAN 1205 +#define IDC_EDITSYMBOLS_REMOVE 1206 +#define IDC_EDITSYMBOLS_ADDRESS 1207 +#define IDC_EDITSYMBOLS_SIZE 1208 +#define IDC_EDITSYMBOLS_OK 1209 +#define IDC_EDITSYMBOLS_CANCEL 1210 #define ID_FILE_EXIT 40000 #define ID_DEBUG_SAVEMAPFILE 40001 @@ -354,7 +354,7 @@ #define IDC_DISASM_FMT_INT 40233 #define IDC_DISASM_FMT_FLOAT 40234 #define IDC_DISASM_FMT_STR 40235 -#define ID_DISASM_EDITSYMBOLS 40236 +#define ID_DISASM_EDITSYMBOLS 40236 // Dummy option to let the buffered rendering hotkey cycle through all the options.