From e24225a811d22e3819d9d629ddec9cb521bb7d23 Mon Sep 17 00:00:00 2001 From: ThirteenAG Date: Sat, 25 Oct 2025 16:36:31 +0300 Subject: [PATCH] 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: