From 513a7aec7e102f2f628cbf2d9c9369f89d7e4b99 Mon Sep 17 00:00:00 2001 From: Jamie Reece Wilson Date: Wed, 18 Oct 2023 04:55:56 +0100 Subject: [PATCH] [+] AuProcesses::StartupParameters::ntLikeHookCreateProcessW --- .../Aurora/Processes/StartupParameters.hpp | 28 +++++++++++++++ Source/Processes/AuProcess.NT.cpp | 36 +++++++++++++++---- 2 files changed, 58 insertions(+), 6 deletions(-) diff --git a/Include/Aurora/Processes/StartupParameters.hpp b/Include/Aurora/Processes/StartupParameters.hpp index c05f6181..9fed81a6 100644 --- a/Include/Aurora/Processes/StartupParameters.hpp +++ b/Include/Aurora/Processes/StartupParameters.hpp @@ -67,5 +67,33 @@ namespace Aurora::Processes IO::IOHandle handleInputStream; AuOptionalEx optAffinity; + + #if defined(AURORA_IS_MODERNNT_DERIVED) + #if defined(CreateProcess) + AuSupplierConsumer ntLikeHookCreateProcessW; + #else + AuSupplierConsumer ntLikeHookCreateProcessW; + #endif + #endif }; } \ No newline at end of file diff --git a/Source/Processes/AuProcess.NT.cpp b/Source/Processes/AuProcess.NT.cpp index 4a2881d0..a98cbbbd 100644 --- a/Source/Processes/AuProcess.NT.cpp +++ b/Source/Processes/AuProcess.NT.cpp @@ -580,6 +580,7 @@ namespace Aurora::Processes { envVars = this->startup_.environmentVariables; } + std::wstring envVarBlock; if (envVars.size() || !this->startup_.bInheritEnvironmentVariables) @@ -597,12 +598,35 @@ namespace Aurora::Processes uCreateFlags |= CREATE_UNICODE_ENVIRONMENT; } - auto result = CreateProcessW(Locale::ConvertFromUTF8(this->startup_.process).c_str(), - Locale::ConvertFromUTF8(this->windowsCli_).data(), - NULL, NULL, true, - uCreateFlags, - envVarBlock.size() ? envVarBlock.data() : nullptr, - wcwd.size() ? wcwd.data() : nullptr, &startupInfo, &this->processInfo_); + BOOL result {}; + + if (auto &func = this->startup_.ntLikeHookCreateProcessW) + { + result = func(Locale::ConvertFromUTF8(this->startup_.process).c_str(), + Locale::ConvertFromUTF8(this->windowsCli_).data(), + NULL, + NULL, + true, + uCreateFlags, + envVarBlock.size() ? envVarBlock.data() : nullptr, + wcwd.size() ? wcwd.data() : nullptr, + &startupInfo, + &this->processInfo_); + + } + else + { + result = CreateProcessW(Locale::ConvertFromUTF8(this->startup_.process).c_str(), + Locale::ConvertFromUTF8(this->windowsCli_).data(), + NULL, + NULL, + true, + uCreateFlags, + envVarBlock.size() ? envVarBlock.data() : nullptr, + wcwd.size() ? wcwd.data() : nullptr, + &startupInfo, + &this->processInfo_); + } if (!result) {