Reworded error message displayed when cxbxr fails to launch an xbe
This commit is contained in:
parent
30956c1044
commit
e37bb218ba
|
@ -47,13 +47,13 @@ bool CxbxIsElevated() {
|
||||||
return fRet;
|
return fRet;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CxbxExec(bool useDebugger, HANDLE* hProcess, bool requestHandleProcess) {
|
std::optional<std::string> CxbxExec(bool useDebugger, HANDLE* hProcess, bool requestHandleProcess) {
|
||||||
|
|
||||||
STARTUPINFO startupInfo = { 0 };
|
STARTUPINFO startupInfo = { 0 };
|
||||||
PROCESS_INFORMATION processInfo = { 0 };
|
PROCESS_INFORMATION processInfo = { 0 };
|
||||||
std::string szProcArgsBuffer;
|
std::string szProcArgsBuffer;
|
||||||
if (!cli_config::GenCMD(szProcArgsBuffer)) {
|
if (!cli_config::GenCMD(szProcArgsBuffer)) {
|
||||||
return false;
|
return std::make_optional<std::string>("Failed to retrieve the command line arguments to launch the new emulation process");
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Set a configuration variable for this. For now it will be within the same folder as Cxbx.exe
|
// TODO: Set a configuration variable for this. For now it will be within the same folder as Cxbx.exe
|
||||||
|
@ -69,7 +69,7 @@ bool CxbxExec(bool useDebugger, HANDLE* hProcess, bool requestHandleProcess) {
|
||||||
cpu load cycles to get the task done.
|
cpu load cycles to get the task done.
|
||||||
*/
|
*/
|
||||||
if (CreateProcess(nullptr, const_cast<LPSTR>(szProcArgsBuffer.c_str()), nullptr, nullptr, false, 0, nullptr, nullptr, &startupInfo, &processInfo) == 0) {
|
if (CreateProcess(nullptr, const_cast<LPSTR>(szProcArgsBuffer.c_str()), nullptr, nullptr, false, 0, nullptr, nullptr, &startupInfo, &processInfo) == 0) {
|
||||||
return 0;
|
return std::make_optional<std::string>("Failed to create the new emulation process (another instance of cxbxr is already running?)");
|
||||||
}
|
}
|
||||||
CloseHandle(processInfo.hThread);
|
CloseHandle(processInfo.hThread);
|
||||||
|
|
||||||
|
@ -80,7 +80,7 @@ bool CxbxExec(bool useDebugger, HANDLE* hProcess, bool requestHandleProcess) {
|
||||||
CloseHandle(processInfo.hProcess);
|
CloseHandle(processInfo.hProcess);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 1;
|
return std::nullopt;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -30,6 +30,7 @@
|
||||||
#include "common/ReserveAddressRanges.h"
|
#include "common/ReserveAddressRanges.h"
|
||||||
#include "common\xbe\Xbe.h"
|
#include "common\xbe\Xbe.h"
|
||||||
#include "Logging.h"
|
#include "Logging.h"
|
||||||
|
#include <optional>
|
||||||
|
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <multimon.h>
|
#include <multimon.h>
|
||||||
|
@ -188,8 +189,6 @@ void CxbxInitFilePaths();
|
||||||
bool CxbxLockFilePath();
|
bool CxbxLockFilePath();
|
||||||
void CxbxUnlockFilePath();
|
void CxbxUnlockFilePath();
|
||||||
|
|
||||||
bool CxbxExec(bool useDebugger, HANDLE* hProcess, bool requestHandleProcess);
|
|
||||||
|
|
||||||
bool CxbxIsElevated();
|
bool CxbxIsElevated();
|
||||||
|
|
||||||
/*! kernel thunk table */
|
/*! kernel thunk table */
|
||||||
|
@ -229,6 +228,8 @@ extern char szFilePath_Xbe[xbox::max_path*2];
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
std::optional<std::string> CxbxExec(bool useDebugger, HANDLE *hProcess, bool requestHandleProcess);
|
||||||
|
|
||||||
// Returns the last Win32 error, in string format. Returns an empty string if there is no error.
|
// Returns the last Win32 error, in string format. Returns an empty string if there is no error.
|
||||||
extern std::string CxbxGetLastErrorString(char * lpszFunction);
|
extern std::string CxbxGetLastErrorString(char * lpszFunction);
|
||||||
|
|
||||||
|
|
|
@ -1330,9 +1330,9 @@ void CxbxLaunchNewXbe(const std::string& XbePath) {
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (!CxbxExec(false, nullptr, false))
|
if (const auto &err = CxbxExec(false, nullptr, false))
|
||||||
{
|
{
|
||||||
CxbxKrnlCleanup("Could not launch %s", XbePath.c_str());
|
CxbxKrnlCleanup("Could not launch %s\n\nThe reason was: %s", XbePath.c_str(), err->c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2261,7 +2261,7 @@ void WndMain::StartEmulation(HWND hwndParent, DebuggerState LocalDebuggerState /
|
||||||
// Check then close existing debugger monitor.
|
// Check then close existing debugger monitor.
|
||||||
DebuggerMonitorClose();
|
DebuggerMonitorClose();
|
||||||
|
|
||||||
if (!CxbxExec(true, &m_hDebuggerProc, true)) {
|
if (CxbxExec(true, &m_hDebuggerProc, true)) {
|
||||||
PopupError(m_hwnd, "Failed to start emulation with the debugger.\n\nYou will need to build CxbxDebugger manually.");
|
PopupError(m_hwnd, "Failed to start emulation with the debugger.\n\nYou will need to build CxbxDebugger manually.");
|
||||||
|
|
||||||
printf("WndMain: %s debugger shell failed.\n", m_Xbe->m_szAsciiTitle);
|
printf("WndMain: %s debugger shell failed.\n", m_Xbe->m_szAsciiTitle);
|
||||||
|
@ -2274,8 +2274,8 @@ void WndMain::StartEmulation(HWND hwndParent, DebuggerState LocalDebuggerState /
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
if (!CxbxExec(false, nullptr, false)) {
|
if (const auto &err = CxbxExec(false, nullptr, false)) {
|
||||||
PopupError(m_hwnd, "Emulation failed.\n\n If this message repeats, the Xbe is not supported.");
|
PopupError(m_hwnd, err->c_str());
|
||||||
|
|
||||||
printf("WndMain: %s shell failed.\n", m_Xbe->m_szAsciiTitle);
|
printf("WndMain: %s shell failed.\n", m_Xbe->m_szAsciiTitle);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue