From 40e8d78d168320a51f8ecb587afe3191e108105c Mon Sep 17 00:00:00 2001 From: gibbed Date: Wed, 6 Jun 2018 19:56:03 -0500 Subject: [PATCH] [Kernel] Allow specifying of additional command-line passed to guest. --- src/xenia/kernel/xboxkrnl/xboxkrnl_module.cc | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/xenia/kernel/xboxkrnl/xboxkrnl_module.cc b/src/xenia/kernel/xboxkrnl/xboxkrnl_module.cc index 9fca76715..0410bc0fd 100644 --- a/src/xenia/kernel/xboxkrnl/xboxkrnl_module.cc +++ b/src/xenia/kernel/xboxkrnl/xboxkrnl_module.cc @@ -27,6 +27,8 @@ #include "xenia/kernel/xboxkrnl/xboxkrnl_private.h" #include "xenia/kernel/xthread.h" +DEFINE_string(cl, "", "Specify additional command-line provided to guest."); + DEFINE_bool(kernel_debug_monitor, false, "Enable debug monitor."); DEFINE_bool(kernel_cert_monitor, false, "Enable cert monitor."); DEFINE_bool(kernel_pix, false, "Enable PIX."); @@ -174,13 +176,20 @@ XboxkrnlModule::XboxkrnlModule(Emulator* emulator, KernelState* kernel_state) // The name of the xex. Not sure this is ever really used on real devices. // Perhaps it's how swap disc/etc data is sent? // Always set to "default.xex" (with quotes) for now. - uint32_t pExLoadedCommandLine = memory_->SystemHeapAlloc(1024); + // TODO(gibbed): set this to the actual module name. + std::string command_line("\"default.xex\""); + if (FLAGS_cl.length()) { + command_line += " " + FLAGS_cl; + } + uint32_t command_line_length = + xe::align(static_cast(command_line.length()) + 1, 1024u); + uint32_t pExLoadedCommandLine = memory_->SystemHeapAlloc(command_line_length); auto lpExLoadedCommandLine = memory_->TranslateVirtual(pExLoadedCommandLine); export_resolver_->SetVariableMapping( "xboxkrnl.exe", ordinals::ExLoadedCommandLine, pExLoadedCommandLine); - char command_line[] = "\"default.xex\""; - std::memcpy(lpExLoadedCommandLine, command_line, - xe::countof(command_line) + 1); + std::memset(lpExLoadedCommandLine, 0, command_line_length); + std::memcpy(lpExLoadedCommandLine, command_line.c_str(), + command_line.length()); // XboxKrnlVersion (8b) // Kernel version, looks like 2b.2b.2b.2b.