diff --git a/src/common/Logging.cpp b/src/common/Logging.cpp index 7cb10bd13..7a8cc892a 100644 --- a/src/common/Logging.cpp +++ b/src/common/Logging.cpp @@ -248,54 +248,96 @@ void log_init_popup_msg() g_bFullScreen = vSettings.bFullScreen; } -int CxbxMessageBox(const char* msg, UINT uType, HWND hWnd, int default_return) +MsgDlgRet CxbxMessageBox(const char* msg, MsgDlgRet ret_default, UINT uType, HWND hWnd) { + // If user is using exclusive fullscreen, we need to refrain all popups. if (g_bFullScreen) { - return default_return; + return ret_default; } - return MessageBox(hWnd, msg, /*lpCaption=*/TEXT("Cxbx-Reloaded"), uType); + int ret = MessageBox(hWnd, msg, /*lpCaption=*/TEXT("Cxbx-Reloaded"), uType); + + switch (ret) { + default: + case IDCANCEL: + return MsgDlgRet::RET_CANCEL; + case IDOK: + return MsgDlgRet::RET_OK; + case IDABORT: + return MsgDlgRet::RET_ABORT; + case IDRETRY: + return MsgDlgRet::RET_RETRY; + case IDIGNORE: + return MsgDlgRet::RET_IGNORE; + case IDYES: + return MsgDlgRet::RET_YES; + case IDNO: + return MsgDlgRet::RET_NO; + } } -void CxbxShowError(const char* msg, HWND hWnd) -{ - const UINT uType = MB_OK | MB_TOPMOST | MB_SETFOREGROUND | MB_ICONERROR; // Note : MB_ICONERROR == MB_ICONSTOP == MB_ICONHAND - - (void)CxbxMessageBox(msg, uType, hWnd); -} - -void CxbxPopupMessageEx(CXBXR_MODULE cxbxr_module, LOG_LEVEL level, CxbxMsgDlgIcon icon, const char *message, ...) +MsgDlgRet CxbxPopupMessageEx(void* hwnd, CXBXR_MODULE cxbxr_module, LOG_LEVEL level, MsgDlgIcon icon, MsgDlgButtons buttons, MsgDlgRet ret_default, const char *message, ...) { char Buffer[1024]; va_list argp; - UINT uType = MB_OK | MB_TOPMOST | MB_SETFOREGROUND; + UINT uType = MB_TOPMOST | MB_SETFOREGROUND; + + // If there's no message, then return default value. + if (!message) { + uType |= MB_ICONERROR | MB_OK; + (void)CxbxMessageBox("message is null pointer", ret_default, uType, reinterpret_cast(hwnd)); + return ret_default; + } switch (icon) { - case CxbxMsgDlgIcon::Warn: { + case MsgDlgIcon::Warn: { uType |= MB_ICONWARNING; break; } - case CxbxMsgDlgIcon::Error: { - uType |= MB_ICONERROR; + case MsgDlgIcon::Error: { + uType |= MB_ICONERROR; // Note : MB_ICONERROR == MB_ICONSTOP == MB_ICONHAND break; } - case CxbxMsgDlgIcon::Info: { + case MsgDlgIcon::Info: { uType |= MB_ICONINFORMATION; break; } - case CxbxMsgDlgIcon::Unknown: + case MsgDlgIcon::Question: + case MsgDlgIcon::Unknown: default: { uType |= MB_ICONQUESTION; break; } } + switch (buttons) { + default: + case MsgDlgButtons::OK: + uType |= MB_OK; + break; + case MsgDlgButtons::OK_CANCEL: + uType |= MB_OKCANCEL; + break; + case MsgDlgButtons::ABORT_RETRY_IGNORE: + uType |= MB_RETRYCANCEL; + break; + case MsgDlgButtons::YES_NO_CANCEL: + uType |= MB_YESNOCANCEL; + break; + case MsgDlgButtons::YES_NO: + uType |= MB_YESNO; + break; + case MsgDlgButtons::RETRY_CANCEL: + uType |= MB_RETRYCANCEL; + break; + } + va_start(argp, message); vsprintf(Buffer, message, argp); va_end(argp); EmuLogOutputEx(cxbxr_module, level, "Popup : %s", Buffer); - (void)CxbxMessageBox(Buffer, uType); + return CxbxMessageBox(Buffer, ret_default, uType, reinterpret_cast(hwnd)); } const bool needs_escape(const wint_t _char) diff --git a/src/common/Logging.h b/src/common/Logging.h index b2d47f442..c43270d5f 100644 --- a/src/common/Logging.h +++ b/src/common/Logging.h @@ -137,27 +137,56 @@ void log_generate_active_filter_output(const CXBXR_MODULE cxbxr_module); // Then users will have a chance of popup message appear during start of emulation in full screen. void log_init_popup_msg(); -typedef enum class _CxbxMsgDlgIcon { - Info = 0, +typedef enum class _MsgDlgIcon { + Unknown = 0, + Question, + Info, Warn, - Error, - Unknown -} CxbxMsgDlgIcon; - -int CxbxMessageBox(const char* msg, UINT uType = MB_OK, HWND hWnd = NULL, int default_return = IDCANCEL); + Error +} MsgDlgIcon; -void CxbxShowError(const char* msg, HWND hWnd = NULL); +typedef enum class _MsgDlgButtons { + Unknown = 0, + OK, + OK_CANCEL, + ABORT_RETRY_IGNORE, + YES_NO_CANCEL, + YES_NO, + RETRY_CANCEL +} MsgDlgButtons; -void CxbxPopupMessageEx(CXBXR_MODULE cxbxr_module, LOG_LEVEL level, CxbxMsgDlgIcon icon, const char* message, ...); +typedef enum class _MsgDlgRet { + RET_Unknown = 0, + RET_OK, + RET_CANCEL, + RET_ABORT, + RET_RETRY, + RET_IGNORE, + RET_YES, + RET_NO +} MsgDlgRet; -#define CxbxPopupMessage(level, icon, fmt, ...) CxbxPopupMessageEx(LOG_PREFIX, level, icon, fmt, ##__VA_ARGS__) +MsgDlgRet CxbxPopupMessageEx(void* hwnd, CXBXR_MODULE cxbxr_module, LOG_LEVEL level, MsgDlgIcon icon, MsgDlgButtons buttons, MsgDlgRet ret_default, const char* message, ...); + +#define CxbxPopupMessage(hwnd, level, icon, buttons, ret_default, fmt, ...) CxbxPopupMessageEx(hwnd, LOG_PREFIX, level, icon, buttons, ret_default, fmt, ## __VA_ARGS__) +#define CxbxPopupMsgUnknown(hwnd, level, buttons, ret_default, fmt, ...) CxbxPopupMessage(hwnd, level, MsgDlgIcon::Unknown, buttons, ret_default, fmt, ## __VA_ARGS__) +#define CxbxPopupMsgQuestion(hwnd, level, buttons, ret_default, fmt, ...) CxbxPopupMessage(hwnd, level, MsgDlgIcon::Question, buttons, ret_default, fmt, ## __VA_ARGS__) +#define CxbxPopupMsgQuestionSimple(hwnd, fmt, ...) CxbxPopupMessage(hwnd, LOG_LEVEL::INFO, MsgDlgIcon::Question, MsgDlgButtons::YES_NO_CANCEL, MsgDlgRet::RET_CANCEL, fmt, ## __VA_ARGS__) +#define CxbxPopupMsgInfo(hwnd, buttons, ret_default, fmt, ...) CxbxPopupMessage(hwnd, LOG_LEVEL::INFO, MsgDlgIcon::Info, buttons, ret_default, fmt, ## __VA_ARGS__) +#define CxbxPopupMsgInfoSimple(hwnd, fmt, ...) CxbxPopupMsgInfo(hwnd, MsgDlgButtons::OK, MsgDlgRet::RET_OK, fmt, ## __VA_ARGS__) +#define CxbxPopupMsgWarn(hwnd, buttons, ret_default, fmt, ...) CxbxPopupMessage(hwnd, LOG_LEVEL::WARNING, MsgDlgIcon::Warn, buttons, ret_default, fmt, ## __VA_ARGS__) +#define CxbxPopupMsgWarnSimple(hwnd, fmt, ...) CxbxPopupMsgWarn(hwnd, MsgDlgButtons::OK, MsgDlgRet::RET_OK, fmt, ## __VA_ARGS__) +#define CxbxPopupMsgError(hwnd, buttons, ret_default, fmt, ...) CxbxPopupMessage(hwnd, LOG_LEVEL::ERROR2, MsgDlgIcon::Error, buttons, ret_default, fmt, ## __VA_ARGS__) +#define CxbxPopupMsgErrorSimple(hwnd, fmt, ...) CxbxPopupMsgError(hwnd, MsgDlgButtons::OK, MsgDlgRet::RET_OK, fmt, ## __VA_ARGS__) +#define CxbxPopupMsgFatal(hwnd, buttons, ret_default, fmt, ...) CxbxPopupMessage(hwnd, LOG_LEVEL::FATAL, MsgDlgIcon::Error, buttons, ret_default, fmt, ## __VA_ARGS__) +#define CxbxPopupMsgFatalSimple(hwnd, fmt, ...) CxbxPopupMsgFatal(hwnd, MsgDlgButtons::OK, MsgDlgRet::RET_OK, fmt, ## __VA_ARGS__) #define LOG_TEST_CASE(message) do { static bool bTestCaseLogged = false; \ if (bTestCaseLogged) break; \ bTestCaseLogged = true; \ if (!g_CurrentLogPopupTestcase) break;\ LOG_CHECK_ENABLED(LOG_LEVEL::INFO) { \ - CxbxPopupMessage(LOG_LEVEL::INFO, CxbxMsgDlgIcon::Info, "Please report that %s shows the following message:\nLOG_TEST_CASE: %s\nIn %s (%s line %d)", \ + CxbxPopupMsgInfoSimple(nullptr, "Please report that %s shows the following message:\nLOG_TEST_CASE: %s\nIn %s (%s line %d)", \ CxbxKrnl_Xbe->m_szAsciiTitle, message, __func__, __FILE__, __LINE__); } } while (0) // was g_pCertificate->wszTitleName diff --git a/src/common/Settings.cpp b/src/common/Settings.cpp index 58206479b..8fea9723f 100644 --- a/src/common/Settings.cpp +++ b/src/common/Settings.cpp @@ -27,6 +27,8 @@ // * // ****************************************************************** +#define LOG_PREFIX CXBXR_MODULE::CXBXR + #include "Settings.hpp" #include "core\kernel\support\Emu.h" #include "EmuShared.h" @@ -221,7 +223,7 @@ bool Settings::Init() bRet = LoadConfig(); if (!bRet) { - MessageBox(nullptr, szSettings_setup_error, "Cxbx-Reloaded", MB_OK); + (void)CxbxPopupMsgErrorSimple(nullptr, szSettings_setup_error); return false; } @@ -834,13 +836,13 @@ CXBX_DATA Settings::SetupFile(std::string& file_path_out) setupFile = GenerateExecDirectoryStr(); #else // Only support for Qt compile build. - int iRet = MessageBox(nullptr, szSettings_save_user_option_message, "Cxbx-Reloaded", MB_YESNOCANCEL | MB_ICONQUESTION); + MsgDlgRet eRet = CxbxPopupMsgQuestionSimple(nullptr, szSettings_save_user_option_message); - if (iRet == IDYES) { + if (eRet == MsgDlgRet::RET_YES) { setupFile = GenerateExecDirectoryStr(); data_ret = CXBX_DATA_EXECDIR; } - else if (iRet == IDNO) { + else if (eRet == MsgDlgRet::RET_NO) { setupFile = GenerateUserProfileDirectoryStr(); data_ret = CXBX_DATA_APPDATA; if (setupFile.size() != 0) { @@ -857,7 +859,7 @@ CXBX_DATA Settings::SetupFile(std::string& file_path_out) #endif if (data_ret == CXBX_DATA_INVALID) { - MessageBox(nullptr, szSettings_setup_error, "Cxbx-Reloaded", MB_OK); + (void)CxbxPopupMsgErrorSimple(nullptr, szSettings_setup_error); } else { setupFile.append(szSettings_settings_file); diff --git a/src/core/hle/D3D8/Direct3D9/Direct3D9.cpp b/src/core/hle/D3D8/Direct3D9/Direct3D9.cpp index dd136ba97..63b0af4d5 100644 --- a/src/core/hle/D3D8/Direct3D9/Direct3D9.cpp +++ b/src/core/hle/D3D8/Direct3D9/Direct3D9.cpp @@ -600,7 +600,7 @@ VOID CxbxInitWindow(bool bFullInit) if (hRenderWindowThread == NULL) { char szBuffer[1024] = { 0 }; sprintf(szBuffer, "Creating EmuRenderWindowThread Failed: %08X", GetLastError()); - CxbxPopupMessage(LOG_LEVEL::FATAL, CxbxMsgDlgIcon::Error, szBuffer); + (void)CxbxPopupMsgFatalSimple(nullptr, szBuffer); EmuShared::Cleanup(); ExitProcess(0); } diff --git a/src/core/hle/XAPI/Xapi.cpp b/src/core/hle/XAPI/Xapi.cpp index 9a923360c..b61ae7ef6 100644 --- a/src/core/hle/XAPI/Xapi.cpp +++ b/src/core/hle/XAPI/Xapi.cpp @@ -1188,7 +1188,7 @@ DWORD WINAPI XTL::EMUPATCH(XLaunchNewImageA) if (PathFileExists(szDashboardPath)) { - (void)CxbxMessageBox("The title is rebooting to dashboard", MB_OK, CxbxKrnl_hEmuParent); + (void)CxbxPopupMsgInfoSimple(nullptr, "The title is rebooting to dashboard"); lpTitlePath = "C:\\xboxdash.xbe"; xboxkrnl::LaunchDataPage->Header.dwLaunchDataType = LDT_FROM_DASHBOARD; // Other options include LDT_NONE, LDT_FROM_DEBUGGER_CMDLINE and LDT_FROM_UPDATE diff --git a/src/core/kernel/exports/EmuKrnlHal.cpp b/src/core/kernel/exports/EmuKrnlHal.cpp index 9a129c1f8..d0caeb443 100644 --- a/src/core/kernel/exports/EmuKrnlHal.cpp +++ b/src/core/kernel/exports/EmuKrnlHal.cpp @@ -613,7 +613,7 @@ XBSYSAPI EXPORTNUM(49) xboxkrnl::VOID DECLSPEC_NORETURN NTAPI xboxkrnl::HalRetur retryAttempt++; // Terminate after 5 seconds of failure. if (retryAttempt >= (5 * (1000 / 100))) { - CxbxShowError("Could not reboot, new emulation process did not take over."); + CxbxPopupMsgErrorSimple(nullptr, "Could not reboot, new emulation process did not take over."); break; } } diff --git a/src/core/kernel/exports/EmuKrnlRtl.cpp b/src/core/kernel/exports/EmuKrnlRtl.cpp index d1d3a6ba5..4e042ff7e 100644 --- a/src/core/kernel/exports/EmuKrnlRtl.cpp +++ b/src/core/kernel/exports/EmuKrnlRtl.cpp @@ -243,7 +243,7 @@ XBSYSAPI EXPORTNUM(264) xboxkrnl::VOID NTAPI xboxkrnl::RtlAssert ss << ")"; - CxbxPopupMessage(LOG_LEVEL::WARNING, CxbxMsgDlgIcon::Warn, ss.str().c_str()); + (void)CxbxPopupMsgWarnSimple(nullptr, ss.str().c_str()); } // ****************************************************************** diff --git a/src/core/kernel/init/CxbxKrnl.cpp b/src/core/kernel/init/CxbxKrnl.cpp index b6a3469b5..fcb729acd 100644 --- a/src/core/kernel/init/CxbxKrnl.cpp +++ b/src/core/kernel/init/CxbxKrnl.cpp @@ -622,7 +622,7 @@ bool CreateSettings() { g_Settings = new Settings(); if (g_Settings == nullptr) { - CxbxShowError(szSettings_alloc_error); + CxbxPopupMsgErrorSimple(nullptr, szSettings_alloc_error); return false; } @@ -647,10 +647,11 @@ bool HandleFirstLaunch() bool bElevated = CxbxIsElevated(); if (bElevated && !g_Settings->m_core.allowAdminPrivilege) { - int ret = CxbxMessageBox("Cxbx-Reloaded has detected that it has been launched with Administrator rights.\n" + MsgDlgRet ret = CxbxPopupMsgWarn(nullptr, MsgDlgButtons::YES_NO, MsgDlgRet::RET_NO, + "Cxbx-Reloaded has detected that it has been launched with Administrator rights.\n" "\nThis is dangerous, as a maliciously modified Xbox titles could take control of your system.\n" - "\nAre you sure you want to continue?", MB_YESNO | MB_ICONWARNING); - if (ret != IDYES) { + "\nAre you sure you want to continue?"); + if (ret != MsgDlgRet::RET_YES) { return false; } } @@ -749,9 +750,9 @@ void CxbxKrnlEmulate(unsigned int reserved_systems, blocks_reserved_t blocks_res } if (!isReady) { EmuLog(LOG_LEVEL::WARNING, "GUI process is not ready!"); - int mbRet = CxbxMessageBox("GUI process is not ready, do you wish to retry?", - MB_ICONWARNING | MB_RETRYCANCEL | MB_TOPMOST | MB_SETFOREGROUND); - if (mbRet == IDRETRY) { + MsgDlgRet mbRet = CxbxPopupMsgWarn(nullptr, MsgDlgButtons::RETRY_CANCEL, MsgDlgRet::RET_CANCEL, + "GUI process is not ready, do you wish to retry?"); + if (mbRet == MsgDlgRet::RET_RETRY) { continue; } CxbxKrnlShutDown(); @@ -880,7 +881,7 @@ void CxbxKrnlEmulate(unsigned int reserved_systems, blocks_reserved_t blocks_res // verify base of code of our executable is 0x00001000 if (ExeNtHeader->OptionalHeader.BaseOfCode != CXBX_BASE_OF_CODE) { - CxbxPopupMessage(LOG_LEVEL::FATAL, CxbxMsgDlgIcon::Error, "Cxbx-Reloaded executuable requires it's base of code to be 0x00001000"); + (void)CxbxPopupMsgFatalSimple(nullptr, "Cxbx-Reloaded executuable requires it's base of code to be 0x00001000"); return; // TODO : Halt(0); } @@ -888,7 +889,7 @@ void CxbxKrnlEmulate(unsigned int reserved_systems, blocks_reserved_t blocks_res // verify virtual_memory_placeholder is located at 0x00011000 if ((UINT_PTR)(&(virtual_memory_placeholder[0])) != (XBE_IMAGE_BASE + CXBX_BASE_OF_CODE)) { - CxbxPopupMessage(LOG_LEVEL::FATAL, CxbxMsgDlgIcon::Error, "virtual_memory_placeholder is not loaded to base address 0x00011000 (which is a requirement for Xbox emulation)"); + (void)CxbxPopupMsgFatalSimple(nullptr, "virtual_memory_placeholder is not loaded to base address 0x00011000 (which is a requirement for Xbox emulation)"); return; // TODO : Halt(0); } #endif @@ -947,7 +948,7 @@ void CxbxKrnlEmulate(unsigned int reserved_systems, blocks_reserved_t blocks_res EEPROM = CxbxRestoreEEPROM(szFilePath_EEPROM_bin); if (EEPROM == nullptr) { - CxbxPopupMessage(LOG_LEVEL::FATAL, CxbxMsgDlgIcon::Error, "Couldn't init EEPROM!"); + (void)CxbxPopupMsgFatalSimple(nullptr, "Couldn't init EEPROM!"); return; // TODO : Halt(0); } @@ -1606,7 +1607,7 @@ bool CxbxLockFilePath() } if (GetLastError() == ERROR_ALREADY_EXISTS) { - CxbxShowError("Data path directory is currently in used.\nUse different data path directory or stop emulation from another process."); + CxbxPopupMsgErrorSimple(nullptr, "Data path directory is currently in used.\nUse different data path directory or stop emulation from another process."); CloseHandle(hMapDataHash); return false; } @@ -1650,7 +1651,7 @@ __declspec(noreturn) void CxbxKrnlCleanupEx(CXBXR_MODULE cxbxr_module, const cha vsprintf(szBuffer2, szErrorMessage, argp); va_end(argp); - CxbxPopupMessageEx(cxbxr_module, LOG_LEVEL::FATAL, CxbxMsgDlgIcon::Error, "Received Fatal Message:\n\n* %s\n", szBuffer2); // Will also EmuLogEx + (void)CxbxPopupMessageEx(nullptr, cxbxr_module, LOG_LEVEL::FATAL, MsgDlgIcon::Error, MsgDlgButtons::OK, MsgDlgRet::RET_OK, "Received Fatal Message:\n\n* %s\n", szBuffer2); // Will also EmuLogEx } EmuLogInit(LOG_LEVEL::INFO, "MAIN: Terminating Process"); @@ -1853,12 +1854,12 @@ void CxbxPrintUEMInfo(ULONG ErrorCode) auto it = UEMErrorTable.find(ErrorCode); if (it != UEMErrorTable.end()) { - std::string ErrorMessage = "Fatal error. " + it->second + ". This error screen will persist indefinitely. Stop the emulation to close it"; - CxbxPopupMessage(LOG_LEVEL::FATAL, CxbxMsgDlgIcon::Error, ErrorMessage.c_str()); + std::string ErrorMessage = "Fatal error. " + it->second + ". This error screen will persist indefinitely. Stop the emulation to close it."; + (void)CxbxPopupMsgFatalSimple(nullptr, ErrorMessage.c_str()); } else { - CxbxPopupMessage(LOG_LEVEL::FATAL, CxbxMsgDlgIcon::Error, "Unknown fatal error. This error screen will persist indefinitely. Stop the emulation to close it"); + (void)CxbxPopupMsgFatalSimple(nullptr, "Unknown fatal error. This error screen will persist indefinitely. Stop the emulation to close it."); } } diff --git a/src/core/kernel/support/Emu.cpp b/src/core/kernel/support/Emu.cpp index e7e0bb16c..796348136 100644 --- a/src/core/kernel/support/Emu.cpp +++ b/src/core/kernel/support/Emu.cpp @@ -25,6 +25,8 @@ // * // ****************************************************************** +#define LOG_PREFIX CXBXR_MODULE::X86 + // prevent name collisions namespace xboxkrnl { @@ -201,7 +203,7 @@ void EmuExceptionNonBreakpointUnhandledShow(LPEXCEPTION_POINTERS e) " Press \"Cancel\" to debug.", e->ExceptionRecord->ExceptionCode, EIPToString(e->ContextRecord->Eip).c_str()); - if (CxbxMessageBox(buffer, MB_ICONSTOP | MB_OKCANCEL, g_hEmuWindow, IDOK) == IDOK) + if (CxbxPopupMsgFatal(nullptr, MsgDlgButtons::OK_CANCEL, MsgDlgRet::RET_OK, buffer) == MsgDlgRet::RET_OK) { EmuExceptionExitProcess(); } @@ -366,13 +368,13 @@ int ExitException(LPEXCEPTION_POINTERS e) fflush(stdout); - (void)CxbxMessageBox("Warning: Could not safely terminate process!", MB_OK, g_hEmuWindow); + (void)CxbxPopupMsgFatalSimple(nullptr, "Warning: Could not safely terminate process!"); count++; if(count > 1) { - (void)CxbxMessageBox("Warning: Multiple Problems!", MB_OK, g_hEmuWindow); + (void)CxbxPopupMsgFatalSimple(nullptr, "Warning: Multiple Problems!"); return EXCEPTION_CONTINUE_SEARCH; } diff --git a/src/emulator/cxbxr-emu.cpp b/src/emulator/cxbxr-emu.cpp index 5dbeb7c18..7190f39db 100644 --- a/src/emulator/cxbxr-emu.cpp +++ b/src/emulator/cxbxr-emu.cpp @@ -27,6 +27,8 @@ // cxbxr-emu.cpp : Defines the exported functions for the DLL application. +#define LOG_PREFIX CXBXR_MODULE::CXBXR + #include "Cxbx.h" // For FUNC_EXPORTS #include "VerifyAddressRanges.h" // For VerifyBaseAddr() //#include "CxbxKrnl/Emu.h" @@ -128,25 +130,25 @@ DWORD WINAPI Emulate(unsigned int reserved_systems, blocks_reserved_t blocks_res /*! Verify our host executable, cxbxr-ldr.exe, is loaded to base address 0x00010000 */ if (!VerifyBaseAddr()) { - CxbxShowError("cxbx-ldr.exe was not loaded to base address 0x00010000 (which is a requirement for Xbox emulation)"); + (void)CxbxPopupMsgErrorSimple(nullptr, "cxbx-ldr.exe was not loaded to base address 0x00010000 (which is a requirement for Xbox emulation)"); return EXIT_FAILURE; } LPSTR CommandLine = GetCommandLine(); if (!CommandLine) { - CxbxShowError("Couldn't retrieve command line!"); + (void)CxbxPopupMsgErrorSimple(nullptr, "Couldn't retrieve command line!"); return EXIT_FAILURE; } int argc = 0; PCHAR *argv = CommandLineToArgvA(CommandLine, &argc); if (!argv) { - CxbxShowError("Couldn't parse command line!"); + (void)CxbxPopupMsgErrorSimple(nullptr, "Couldn't parse command line!"); return EXIT_FAILURE; } if (!cli_config::GenConfig(argv, argc)) { - CxbxShowError("Couldn't convert parsed command line!"); + (void)CxbxPopupMsgErrorSimple(nullptr, "Couldn't convert parsed command line!"); LocalFree(argv); return EXIT_FAILURE; } @@ -154,24 +156,24 @@ DWORD WINAPI Emulate(unsigned int reserved_systems, blocks_reserved_t blocks_res /*! verify load argument is included */ if (!cli_config::hasKey("load")) { - CxbxShowError("No /load argument in command line!"); + (void)CxbxPopupMsgErrorSimple(nullptr, "No /load argument in command line!"); return EXIT_FAILURE; } /*! initialize shared memory */ if (!EmuShared::Init(cli_config::GetSessionID())) { - CxbxShowError("Could not map shared memory!"); + (void)CxbxPopupMsgErrorSimple(nullptr, "Could not map shared memory!"); return EXIT_FAILURE; } if (!HandleFirstLaunch()) { - CxbxShowError("First launch failed!"); + (void)CxbxPopupMsgErrorSimple(nullptr, "First launch failed!"); EmuShared::Cleanup(); return EXIT_FAILURE; } if (!reserved_systems) { - CxbxShowError("Unable to preserve any system's memory ranges!"); + (void)CxbxPopupMsgErrorSimple(nullptr, "Unable to preserve any system's memory ranges!"); EmuShared::Cleanup(); return EXIT_FAILURE; } diff --git a/src/gui/WinMain.cpp b/src/gui/WinMain.cpp index 9fe266c6b..bac28b250 100644 --- a/src/gui/WinMain.cpp +++ b/src/gui/WinMain.cpp @@ -25,6 +25,8 @@ // * // ****************************************************************** +#define LOG_PREFIX CXBXR_MODULE::CXBXR + #include "WndMain.h" #include "AddressRanges.h" // For VerifyWow64() @@ -52,26 +54,26 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine // First detect if we are running on WoW64, if not, prevent Cxbx-Reloaded from starting // Cxbx-Reloaded needs access to high memory, only exposed to WoW64. if (!VerifyWow64()) { - CxbxShowError("Cxbx-Reloaded can only run under WoW64\nThis means either a 64-bit version of Windows or Wine with a 64-bit prefix"); + CxbxPopupMsgErrorSimple(nullptr, "Cxbx-Reloaded can only run under WoW64\nThis means either a 64-bit version of Windows or Wine with a 64-bit prefix"); return EXIT_FAILURE; } #ifndef CXBXR_EMU /*! verify Cxbx.exe is loaded to base address 0x00010000 */ if (!VerifyBaseAddr()) { - CxbxShowError("Cxbx.exe is not loaded to base address 0x00010000 (which is a requirement for Xbox emulation)"); + CxbxPopupMsgErrorSimple(nullptr, "Cxbx.exe is not loaded to base address 0x00010000 (which is a requirement for Xbox emulation)"); return EXIT_FAILURE; } #endif if (!cli_config::GenConfig(__argv, __argc)) { - CxbxShowError("Couldn't convert parsed command line!"); + CxbxPopupMsgErrorSimple(nullptr, "Couldn't convert parsed command line!"); return EXIT_FAILURE; } /*! initialize shared memory */ if (!EmuShared::Init(cli_config::GetSessionID())) { - CxbxShowError("Could not map shared memory!"); + CxbxPopupMsgErrorSimple(nullptr, "Could not map shared memory!"); return EXIT_FAILURE; } @@ -86,7 +88,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine EmuShared::Cleanup(); return EXIT_SUCCESS; #else - CxbxShowError("Emulation must be launched from cxbxr-ldr.exe!"); + CxbxPopupMsgErrorSimple(nullptr, "Emulation must be launched from cxbxr-ldr.exe!"); EmuShared::Cleanup(); return EXIT_FAILURE; #endif @@ -137,7 +139,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine /*! if an error occurred, notify user */ if(MainWindow->HasError()) { - CxbxShowError(MainWindow->GetError().c_str()); + CxbxPopupMsgErrorSimple(nullptr, MainWindow->GetError().c_str()); } delete MainWindow;