replace CxbxShowError to CxbxPopupMsg prefix to include in log record

This commit is contained in:
RadWolfie 2020-06-10 22:53:08 -05:00
parent 458b332e8e
commit ce3626eb9d
11 changed files with 150 additions and 70 deletions

View File

@ -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;
}
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;
}
return MessageBox(hWnd, msg, /*lpCaption=*/TEXT("Cxbx-Reloaded"), uType);
}
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>(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>(hwnd));
}
const bool needs_escape(const wint_t _char)

View File

@ -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;
Error
} MsgDlgIcon;
int CxbxMessageBox(const char* msg, UINT uType = MB_OK, HWND hWnd = NULL, int default_return = IDCANCEL);
typedef enum class _MsgDlgButtons {
Unknown = 0,
OK,
OK_CANCEL,
ABORT_RETRY_IGNORE,
YES_NO_CANCEL,
YES_NO,
RETRY_CANCEL
} MsgDlgButtons;
void CxbxShowError(const char* msg, HWND hWnd = NULL);
typedef enum class _MsgDlgRet {
RET_Unknown = 0,
RET_OK,
RET_CANCEL,
RET_ABORT,
RET_RETRY,
RET_IGNORE,
RET_YES,
RET_NO
} MsgDlgRet;
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, ...);
#define CxbxPopupMessage(level, icon, fmt, ...) CxbxPopupMessageEx(LOG_PREFIX, level, icon, fmt, ##__VA_ARGS__)
#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

View File

@ -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);

View File

@ -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);
}

View File

@ -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

View File

@ -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;
}
}

View File

@ -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());
}
// ******************************************************************

View File

@ -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.");
}
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;