From 1446d9193af4d4f13c780b46a4bf762129042e6d Mon Sep 17 00:00:00 2001 From: momo5502 Date: Wed, 23 Oct 2024 18:41:29 +0200 Subject: [PATCH] Support hardcoded environment variables --- src/windows-emulator/emulator_utils.hpp | 7 +++++++ src/windows-emulator/windows_emulator.cpp | 4 ++++ 2 files changed, 11 insertions(+) diff --git a/src/windows-emulator/emulator_utils.hpp b/src/windows-emulator/emulator_utils.hpp index 5e0b1b25..5c54742d 100644 --- a/src/windows-emulator/emulator_utils.hpp +++ b/src/windows-emulator/emulator_utils.hpp @@ -122,6 +122,13 @@ public: return emulator_object(*this->emu_, potential_start); } + wchar_t* copy_string(const std::wstring_view str) + { + UNICODE_STRING uc_str{}; + this->make_unicode_string(uc_str, str); + return uc_str.Buffer; + } + void make_unicode_string(UNICODE_STRING& result, const std::wstring_view str) { constexpr auto element_size = sizeof(str[0]); diff --git a/src/windows-emulator/windows_emulator.cpp b/src/windows-emulator/windows_emulator.cpp index 1e386437..ad2baad5 100644 --- a/src/windows-emulator/windows_emulator.cpp +++ b/src/windows-emulator/windows_emulator.cpp @@ -226,6 +226,10 @@ namespace proc_params.StandardInput = STDIN_HANDLE.h; proc_params.StandardError = proc_params.StandardOutput; + proc_params.Environment = allocator.copy_string(L"=::=::\\"); + allocator.copy_string(L"EMULATOR=1"); + allocator.copy_string(L"COMPUTERNAME=momo"); + allocator.copy_string(L""); std::wstring command_line = L"\"" + file.wstring() + L"\"";