From e24225a811d22e3819d9d629ddec9cb521bb7d23 Mon Sep 17 00:00:00 2001 From: ThirteenAG Date: Sat, 25 Oct 2025 16:36:31 +0300 Subject: [PATCH 1/3] add more WM_USER messages - WM_USER_GET_CURRENT_GAMEID - WM_USER_GET_MODULE_INFO --- Windows/MainWindow.cpp | 75 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) diff --git a/Windows/MainWindow.cpp b/Windows/MainWindow.cpp index ae585d2fd1..d3f1c32f3f 100644 --- a/Windows/MainWindow.cpp +++ b/Windows/MainWindow.cpp @@ -98,6 +98,8 @@ int verysleepy__useSendMessage = 1; const UINT WM_VERYSLEEPY_MSG = WM_APP + 0x3117; const UINT WM_USER_GET_BASE_POINTER = WM_APP + 0x3118; // 0xB118 const UINT WM_USER_GET_EMULATION_STATE = WM_APP + 0x3119; // 0xB119 +const UINT WM_USER_GET_CURRENT_GAMEID = WM_APP + 0x311A; // 0xB11A +const UINT WM_USER_GET_MODULE_INFO = WM_APP + 0x311B; // 0xB11B // Respond TRUE to a message with this param value to indicate support. const WPARAM VERYSLEEPY_WPARAM_SUPPORTED = 0; @@ -665,6 +667,79 @@ namespace MainWindow case WM_USER_GET_EMULATION_STATE: return (u32)(Core_IsActive() && GetUIState() == UISTATE_INGAME); + case WM_USER_GET_CURRENT_GAMEID: + { + // Return game ID as a string + // wParam: pointer to buffer + // lParam: size of buffer + if (!PSP_IsInited()) + { + return 0; + } + const std::string gameID = Reporting::CurrentGameID(); + if (gameID.empty()) + { + return 0; + } + char* buffer = reinterpret_cast(wParam); + const size_t bufferSize = static_cast(lParam); + if (!buffer || bufferSize == 0) + { + // Return required size + return gameID.length() + 1; + } + // Copy the game ID to the buffer + const size_t copySize = std::min(bufferSize - 1, gameID.length()); + std::copy(gameID.begin(), gameID.begin() + copySize, buffer); + buffer[copySize] = '\0'; + return gameID.length(); + } + break; + case WM_USER_GET_MODULE_INFO: + { + // Get module information by name + // wParam: pointer to module name (null-terminated string) + // lParam: 0 = address, 1 = size, 2 = active flag + // Returns: u64 packed with module info, or 0 if not found + if (!PSP_IsInited() || !g_symbolMap) + { + return 0; + } + const char* moduleName = reinterpret_cast(wParam); + if (!moduleName) + { + return 0; + } + // Get all modules from symbol map + auto modules = g_symbolMap->getAllModules(); + for (const auto& module : modules) + { + if (module.name == moduleName) + { + switch (lParam) + { + case 0: + // Return address as u32 (low 32 bits) + return (u64)module.address; + case 1: + // Return size as u32 (low 32 bits) + return (u64)module.size; + case 2: + // Return active flag in bit 0, padded with zeros + return (u64)(module.active ? 1 : 0); + case 3: + // Return all info packed: address (bits 0-31), size (bits 32-62), active (bit 63) + return ((u64)module.address) | (((u64)module.size) << 32) | (module.active ? (1ULL << 63) : 0); + default: + return 0; + } + } + } + // Module not found + return 0; + } + break; + // Hack to kill the white line underneath the menubar. // From https://stackoverflow.com/questions/57177310/how-to-paint-over-white-line-between-menu-bar-and-client-area-of-window case WM_NCPAINT: From 6bf48c4f889adf9f2a9d13ffd138420a7f2b14ab Mon Sep 17 00:00:00 2001 From: ThirteenAG Date: Sat, 25 Oct 2025 21:34:41 +0300 Subject: [PATCH 2/3] WM_USER_GET_CURRENT_GAMEID: pack return value into a pair of u64 --- Windows/MainWindow.cpp | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/Windows/MainWindow.cpp b/Windows/MainWindow.cpp index d3f1c32f3f..a6bb9200ac 100644 --- a/Windows/MainWindow.cpp +++ b/Windows/MainWindow.cpp @@ -669,9 +669,9 @@ namespace MainWindow case WM_USER_GET_CURRENT_GAMEID: { - // Return game ID as a string - // wParam: pointer to buffer - // lParam: size of buffer + // Return game ID packed as u64 + // wParam: 0 = first 8 chars, 1 = next 7 chars + // Returns: packed u64 with 8 bytes of game ID if (!PSP_IsInited()) { return 0; @@ -681,18 +681,15 @@ namespace MainWindow { return 0; } - char* buffer = reinterpret_cast(wParam); - const size_t bufferSize = static_cast(lParam); - if (!buffer || bufferSize == 0) + u64 packed = 0; + const size_t offset = (wParam == 0) ? 0 : 8; + const size_t maxLen = std::min(gameID.length() - offset, size_t(8)); + for (size_t i = 0; i < maxLen; ++i) { - // Return required size - return gameID.length() + 1; + const u8 c = static_cast(gameID[offset + i]); + packed |= ((u64)c << (i * 8)); } - // Copy the game ID to the buffer - const size_t copySize = std::min(bufferSize - 1, gameID.length()); - std::copy(gameID.begin(), gameID.begin() + copySize, buffer); - buffer[copySize] = '\0'; - return gameID.length(); + return packed; } break; case WM_USER_GET_MODULE_INFO: From 93f29ac51fdbb8bf0afb19010241a8b4b3cf55e6 Mon Sep 17 00:00:00 2001 From: ThirteenAG Date: Sat, 25 Oct 2025 21:50:18 +0300 Subject: [PATCH 3/3] WM_USER_GET_CURRENT_GAMEID: return 4 u32 values (compatibility with 32 bit builds) --- Windows/MainWindow.cpp | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/Windows/MainWindow.cpp b/Windows/MainWindow.cpp index a6bb9200ac..cd1b2f8775 100644 --- a/Windows/MainWindow.cpp +++ b/Windows/MainWindow.cpp @@ -669,9 +669,9 @@ namespace MainWindow case WM_USER_GET_CURRENT_GAMEID: { - // Return game ID packed as u64 - // wParam: 0 = first 8 chars, 1 = next 7 chars - // Returns: packed u64 with 8 bytes of game ID + // Return game ID as four u32 values + // wParam: 0-3 = which u32 to return (chars 0-3, 4-7, 8-11, 12-15) + // Returns: packed u32 with 4 bytes of game ID if (!PSP_IsInited()) { return 0; @@ -681,13 +681,15 @@ namespace MainWindow { return 0; } - u64 packed = 0; - const size_t offset = (wParam == 0) ? 0 : 8; - const size_t maxLen = std::min(gameID.length() - offset, size_t(8)); - for (size_t i = 0; i < maxLen; ++i) + const size_t offset = (wParam & 0x3) * 4; // 0, 4, 8, 12 + u32 packed = 0; + for (size_t i = 0; i < 4; ++i) { - const u8 c = static_cast(gameID[offset + i]); - packed |= ((u64)c << (i * 8)); + if (offset + i < gameID.length()) + { + const u8 c = static_cast(gameID[offset + i]); + packed |= ((u32)c << (i * 8)); + } } return packed; }