[Kernel] Update ExLoadedCommandLine based on executable name
This commit is contained in:
parent
2c087406d6
commit
0ee6c77d91
|
@ -41,6 +41,8 @@ DEFINE_uint32(max_signed_profiles, 4,
|
||||||
DEFINE_uint32(kernel_build_version, 1888, "Define current kernel version",
|
DEFINE_uint32(kernel_build_version, 1888, "Define current kernel version",
|
||||||
"Kernel");
|
"Kernel");
|
||||||
|
|
||||||
|
DECLARE_string(cl);
|
||||||
|
|
||||||
namespace xe {
|
namespace xe {
|
||||||
namespace kernel {
|
namespace kernel {
|
||||||
|
|
||||||
|
@ -386,6 +388,25 @@ void KernelState::SetExecutableModule(object_ref<UserModule> module) {
|
||||||
variable_ptr, executable_module_->path(),
|
variable_ptr, executable_module_->path(),
|
||||||
xboxkrnl::XboxkrnlModule::kExLoadedImageNameSize);
|
xboxkrnl::XboxkrnlModule::kExLoadedImageNameSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Setup the kernel's ExLoadedCommandLine field
|
||||||
|
export_entry = processor()->export_resolver()->GetExportByOrdinal(
|
||||||
|
"xboxkrnl.exe", ordinals::ExLoadedCommandLine);
|
||||||
|
if (export_entry) {
|
||||||
|
char* variable_ptr =
|
||||||
|
memory()->TranslateVirtual<char*>(export_entry->variable_ptr);
|
||||||
|
|
||||||
|
std::string module_name =
|
||||||
|
fmt::format("\"{}.xex\"", executable_module_->name());
|
||||||
|
if (!cvars::cl.empty()) {
|
||||||
|
module_name += " " + cvars::cl;
|
||||||
|
}
|
||||||
|
|
||||||
|
xe::string_util::copy_truncating(
|
||||||
|
variable_ptr, module_name,
|
||||||
|
xboxkrnl::XboxkrnlModule::kExLoadedCommandLineSize);
|
||||||
|
}
|
||||||
|
|
||||||
// Spin up deferred dispatch worker.
|
// Spin up deferred dispatch worker.
|
||||||
// TODO(benvanik): move someplace more appropriate (out of ctor, but around
|
// TODO(benvanik): move someplace more appropriate (out of ctor, but around
|
||||||
// here).
|
// here).
|
||||||
|
|
|
@ -193,7 +193,8 @@ XboxkrnlModule::XboxkrnlModule(Emulator* emulator, KernelState* kernel_state)
|
||||||
command_line += " " + cvars::cl;
|
command_line += " " + cvars::cl;
|
||||||
}
|
}
|
||||||
uint32_t command_line_length =
|
uint32_t command_line_length =
|
||||||
xe::align(static_cast<uint32_t>(command_line.length()) + 1, 1024u);
|
xe::align(static_cast<uint32_t>(command_line.length()) + 1,
|
||||||
|
static_cast<uint32_t>(kExLoadedCommandLineSize));
|
||||||
uint32_t pExLoadedCommandLine = memory_->SystemHeapAlloc(command_line_length);
|
uint32_t pExLoadedCommandLine = memory_->SystemHeapAlloc(command_line_length);
|
||||||
auto lpExLoadedCommandLine = memory_->TranslateVirtual(pExLoadedCommandLine);
|
auto lpExLoadedCommandLine = memory_->TranslateVirtual(pExLoadedCommandLine);
|
||||||
export_resolver_->SetVariableMapping(
|
export_resolver_->SetVariableMapping(
|
||||||
|
|
|
@ -28,6 +28,8 @@ namespace xboxkrnl {
|
||||||
class XboxkrnlModule : public KernelModule {
|
class XboxkrnlModule : public KernelModule {
|
||||||
public:
|
public:
|
||||||
static constexpr size_t kExLoadedImageNameSize = 255 + 1;
|
static constexpr size_t kExLoadedImageNameSize = 255 + 1;
|
||||||
|
static constexpr size_t kExLoadedCommandLineSize =
|
||||||
|
1024; // Based on max size provided for XamLoaderGetLaunchData
|
||||||
|
|
||||||
XboxkrnlModule(Emulator* emulator, KernelState* kernel_state);
|
XboxkrnlModule(Emulator* emulator, KernelState* kernel_state);
|
||||||
virtual ~XboxkrnlModule();
|
virtual ~XboxkrnlModule();
|
||||||
|
|
Loading…
Reference in New Issue