From 519ba4b26e1d330a5a9836e99e35e1d732cf4be1 Mon Sep 17 00:00:00 2001 From: Jamie Reece Wilson Date: Thu, 8 Jun 2023 09:52:53 +0100 Subject: [PATCH] [*] Fix up AuProcess version handling handling. Includes a new secret env-var. (amended) --- Source/Process/AuProcessSectionView.NT.cpp | 31 +++++++++++++++++++ Source/Process/AuProcessSectionView.NT.hpp | 4 ++- .../AuProcessSectionViewReserved.NT.cpp | 7 +---- 3 files changed, 35 insertions(+), 7 deletions(-) diff --git a/Source/Process/AuProcessSectionView.NT.cpp b/Source/Process/AuProcessSectionView.NT.cpp index 0ce68393..77de0993 100644 --- a/Source/Process/AuProcessSectionView.NT.cpp +++ b/Source/Process/AuProcessSectionView.NT.cpp @@ -399,9 +399,40 @@ namespace Aurora::Process return this->allocations; } + void ProcessSectionView::DoVanillaDriverlessExtesionWin7Test() + { + #if defined(AURORA_PLATFORM_WIN32) + + #define WIN_7_WARN "WARNING: ADDRESS SPACE CANNOT BE RESERVED ON OLDER NT KERNELS. \r\n" \ + "AuProcess::ReserveAddressSpace(AuUInt uOffset) is about to lie about reserving the address space, yield the entire address space, and leave a note to terminate the application if an explicit fixed-offset request is made." + + SysPushErrorUnimplemented("Win7_ReserveAddressSpace_RS4_REQ"); + + AuUInt uEnvSize {}; + ::getenv_s(&uEnvSize, nullptr, 0, "AURORA_FORCE_RANDOM_ADDRESS_WITHOUT_VIRTALLOC2"); + if (uEnvSize) + { + // bah + // enjoy return not respecting what was provided as the expected offset. + // this is not a workaround for missing functionality in the operating systems userland and kernel abstraction. + // this will just prevent us from panicing preemptively. + this->bPanicOnEx = true; + } + else + { + AuLogWarn(WIN_7_WARN); + this->bPanicOnEx = false; + } + #else + AuLogWarn("I don't know this platform - AuProcess"); + this->bPanicOnEx = true; + #endif + } + AUKN_SYM AuSPtr GetGlobalProcessSpace() { static ProcessSectionView gSingleton; + gSingleton.DoVanillaDriverlessExtesionWin7Test(); return AuUnsafeRaiiToShared(&gSingleton); } } \ No newline at end of file diff --git a/Source/Process/AuProcessSectionView.NT.hpp b/Source/Process/AuProcessSectionView.NT.hpp index 8bd16d12..08be70d1 100644 --- a/Source/Process/AuProcessSectionView.NT.hpp +++ b/Source/Process/AuProcessSectionView.NT.hpp @@ -11,10 +11,12 @@ namespace Aurora::Process { struct ProcessSectionView : IProcessSectionView { - bool bPanicOnEx {}; + bool bPanicOnEx { true }; // SysAssert(this->bPanicOnEx) - it's inverted! true -> dont panic AuThreadPrimitives::SpinLock spinlock; AuList> allocations; + void DoVanillaDriverlessExtesionWin7Test(); + AuUInt GetStart() override; AuUInt GetEnd() override; diff --git a/Source/Process/AuProcessSectionViewReserved.NT.cpp b/Source/Process/AuProcessSectionViewReserved.NT.cpp index 4220d40e..4bd3c63f 100644 --- a/Source/Process/AuProcessSectionViewReserved.NT.cpp +++ b/Source/Process/AuProcessSectionViewReserved.NT.cpp @@ -559,13 +559,8 @@ namespace Aurora::Process if (!pVirtualAlloc2) // allow modified windows runtimes #endif { - #define WIN_7_WARN "WARNING: ADDRESS SPACE CANNOT BE RESERVED ON OLDER NT KERNELS. \r\n" \ - "AuProcess::ReserveAddressSpace(AuUInt uOffset) is about to lie about reserving the address space, yield the entire address space, and leave a note to terminate the application if an explicit fixed-offset request is made." - - SysPushErrorUnimplemented("Win7_ReserveAddressSpace_RS4_REQ"); - AuLogWarn(WIN_7_WARN); static ProcessSectionView gSingleton; - gSingleton.bPanicOnEx = true; + gSingleton.DoVanillaDriverlessExtesionWin7Test(); return AuUnsafeRaiiToShared(&gSingleton); }