Loader : Moved HandleFirstLaunch() and LaunchEmulation() towards shared source file (CxbxKrnl.cpp), and call it from our DLL's Emulate() function.
This commit is contained in:
parent
daffa99825
commit
37f5a751a1
|
@ -872,6 +872,70 @@ void ImportLibraries(XbeImportEntry *pImportDirectory)
|
|||
}
|
||||
}
|
||||
|
||||
bool HandleFirstLaunch()
|
||||
{
|
||||
bool bFirstLaunch;
|
||||
g_EmuShared->GetIsFirstLaunch(&bFirstLaunch);
|
||||
|
||||
/* check if process is launch with elevated access then prompt for continue on or not. */
|
||||
if (!bFirstLaunch) {
|
||||
g_Settings = new Settings();
|
||||
if (g_Settings == nullptr) {
|
||||
MessageBox(nullptr, szSettings_alloc_error, "Cxbx-Reloaded", MB_OK);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!g_Settings->Init()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
log_get_settings();
|
||||
|
||||
bool bElevated = CxbxIsElevated();
|
||||
if (bElevated && !g_Settings->m_core.allowAdminPrivilege) {
|
||||
int ret = MessageBox(NULL, "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?", "Cxbx-Reloaded", MB_YESNO | MB_ICONWARNING);
|
||||
if (ret != IDYES) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
g_EmuShared->SetIsFirstLaunch(true);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void LaunchEmulation(int argc, char* argv[])
|
||||
{
|
||||
// NOTE: This is designated for standalone kernel mode launch without GUI
|
||||
if (g_Settings != nullptr) {
|
||||
|
||||
// Reset to default
|
||||
g_EmuShared->Reset();
|
||||
|
||||
g_Settings->Verify();
|
||||
g_Settings->SyncToEmulator();
|
||||
|
||||
// We don't need to keep Settings open plus allow emulator to use unused memory.
|
||||
delete g_Settings;
|
||||
g_Settings = nullptr;
|
||||
|
||||
// Perform identical to what GUI will do to certain EmuShared's variable before launch.
|
||||
g_EmuShared->SetIsEmulating(true);
|
||||
|
||||
// NOTE: This setting the ready status is optional. Internal kernel process is checking if GUI is running.
|
||||
// Except if enforce check, then we need to re-set ready status every time for non-GUI.
|
||||
//g_EmuShared->SetIsReady(true);
|
||||
}
|
||||
|
||||
/* Initialize Cxbx File Paths */
|
||||
CxbxInitFilePaths();
|
||||
|
||||
CxbxKrnlMain(argc, argv);
|
||||
}
|
||||
|
||||
void CxbxKrnlMain(int argc, char* argv[])
|
||||
{
|
||||
// Skip '/load' switch
|
||||
|
|
|
@ -224,8 +224,10 @@ bool CxbxKrnlVerifyVersion(const char *szVersion);
|
|||
|
||||
extern bool g_bIsDebugKernel;
|
||||
|
||||
bool HandleFirstLaunch();
|
||||
|
||||
/*! Cxbx Kernel Entry Point */
|
||||
void CxbxKrnlMain(int argc, char* argv[]);
|
||||
void LaunchEmulation(int argc, char* argv[]);
|
||||
|
||||
/*! initialize emulation */
|
||||
__declspec(noreturn) void CxbxKrnlInit(void *pTLSData, Xbe::TLS *pTLS, Xbe::LibraryVersion *LibraryVersion, DebugMode DbgMode, const char *szDebugFilename, Xbe::Header *XbeHeader, uint32_t XbeHeaderSize, void (*Entry)(), int BootFlags);
|
||||
|
|
|
@ -38,6 +38,7 @@
|
|||
#include "VerifyAddressRanges.h" // For VerifyBaseAddr() and VerifyAddressRanges()
|
||||
//#include "CxbxKrnl/Emu.h"
|
||||
#include "EmuShared.h"
|
||||
#include "core\kernel\init\CxbxKrnl.h" // For HandleFirstLaunch() and LaunchEmulation()
|
||||
//#include <commctrl.h>
|
||||
|
||||
PCHAR*
|
||||
|
@ -149,13 +150,13 @@ DWORD WINAPI Emulate(int system)
|
|||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
// TODO : Call HandleFirstLaunch();
|
||||
HandleFirstLaunch();
|
||||
|
||||
LPSTR CommandLine = GetCommandLine();
|
||||
int argc;
|
||||
PCHAR *argv = CommandLineToArgvA(CommandLine, &argc);
|
||||
|
||||
// TODO : Call LaunchEmulation(argc, argv);
|
||||
LaunchEmulation(argc, argv);
|
||||
|
||||
LocalFree(argv);
|
||||
|
||||
|
|
|
@ -40,72 +40,6 @@
|
|||
name = 'Microsoft.Windows.Common-Controls' version = '6.0.0.0' \
|
||||
processorArchitecture = '*' publicKeyToken = '6595b64144ccf1df' language = '*'\"")
|
||||
|
||||
// TODO : Move HandleFirstLaunch() to a file shared with the CxbxEmulator project
|
||||
bool HandleFirstLaunch()
|
||||
{
|
||||
bool bFirstLaunch;
|
||||
g_EmuShared->GetIsFirstLaunch(&bFirstLaunch);
|
||||
|
||||
/* check if process is launch with elevated access then prompt for continue on or not. */
|
||||
if (!bFirstLaunch) {
|
||||
g_Settings = new Settings();
|
||||
if (g_Settings == nullptr) {
|
||||
MessageBox(nullptr, szSettings_alloc_error, "Cxbx-Reloaded", MB_OK);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!g_Settings->Init()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
log_get_settings();
|
||||
|
||||
bool bElevated = CxbxIsElevated();
|
||||
if (bElevated && !g_Settings->m_core.allowAdminPrivilege) {
|
||||
int ret = MessageBox(NULL, "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?", "Cxbx-Reloaded", MB_YESNO | MB_ICONWARNING);
|
||||
if (ret != IDYES) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
g_EmuShared->SetIsFirstLaunch(true);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// TODO : Move LaunchEmulation() to a file shared with the CxbxEmulator project
|
||||
void LaunchEmulation(int argc, char* argv[])
|
||||
{
|
||||
// NOTE: This is designated for standalone kernel mode launch without GUI
|
||||
if (g_Settings != nullptr) {
|
||||
|
||||
// Reset to default
|
||||
g_EmuShared->Reset();
|
||||
|
||||
g_Settings->Verify();
|
||||
g_Settings->SyncToEmulator();
|
||||
|
||||
// We don't need to keep Settings open plus allow emulator to use unused memory.
|
||||
delete g_Settings;
|
||||
g_Settings = nullptr;
|
||||
|
||||
// Perform identical to what GUI will do to certain EmuShared's variable before launch.
|
||||
g_EmuShared->SetIsEmulating(true);
|
||||
|
||||
// NOTE: This setting the ready status is optional. Internal kernel process is checking if GUI is running.
|
||||
// Except if enforce check, then we need to re-set ready status every time for non-GUI.
|
||||
//g_EmuShared->SetIsReady(true);
|
||||
}
|
||||
|
||||
/* Initialize Cxbx File Paths */
|
||||
CxbxInitFilePaths();
|
||||
|
||||
CxbxKrnlMain(argc, argv);
|
||||
}
|
||||
|
||||
/*! program entry point */
|
||||
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue