[+] AuProcesses::StartupParameters::ntLikeHookCreateProcessW

This commit is contained in:
Reece Wilson 2023-10-18 04:55:56 +01:00
parent fc4c1054c3
commit 513a7aec7e
2 changed files with 58 additions and 6 deletions

View File

@ -67,5 +67,33 @@ namespace Aurora::Processes
IO::IOHandle handleInputStream;
AuOptionalEx<HWInfo::CpuBitId> optAffinity;
#if defined(AURORA_IS_MODERNNT_DERIVED)
#if defined(CreateProcess)
AuSupplierConsumer<BOOL,
LPCWSTR,
LPWSTR,
LPSECURITY_ATTRIBUTES,
LPSECURITY_ATTRIBUTES,
BOOL,
DWORD,
LPVOID,
LPCWSTR,
LPSTARTUPINFOW,
LPPROCESS_INFORMATION> ntLikeHookCreateProcessW;
#else
AuSupplierConsumer<int,
void *,
void *,
void *,
void *,
int,
unsigned long,
void *,
void *,
void *,
void *> ntLikeHookCreateProcessW;
#endif
#endif
};
}

View File

@ -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)
{