diff --git a/Source/RNG/AuRNGEntropy.cpp b/Source/RNG/AuRNGEntropy.cpp index 4406db89..b6e0f2e6 100644 --- a/Source/RNG/AuRNGEntropy.cpp +++ b/Source/RNG/AuRNGEntropy.cpp @@ -114,14 +114,6 @@ namespace Aurora::RNG static AuUInt32 RngWin32(AuUInt8 *pBuf, AuUInt32 uLen) { - if (pRtlGenRandom) - { - if (pRtlGenRandom(pBuf, uLen)) - { - return uLen; - } - } - if (pBCryptGenRandom) { if (AuSwInfo::IsWindows10OrGreater() || @@ -133,11 +125,21 @@ namespace Aurora::RNG } } + if (pRtlGenRandom(pBuf, uLen)) + { + return uLen; + } + if (pBCryptGenRandom(NULL, reinterpret_cast(pBuf), uLen, BCRYPT_USE_SYSTEM_PREFERRED_RNG) == 0) { return uLen; } } + else if (pRtlGenRandom && + pRtlGenRandom(pBuf, uLen)) + { + return uLen; + } #if defined(AURORA_RNG_HAS_OLD_WINCRYPT) if (gCryptoProv) @@ -169,7 +171,7 @@ namespace Aurora::RNG static AuUInt64 gTimeHolder; static AuUInt64 gTime = (gTimeHolder = AuTime::SteadyClockJiffies()) >= 10'000'000ull ? 1 : - AuPageRoundUp((10'000'000ull / gTimeHolder), 1024); + AuPageRoundUp(10'000'000ull, 1024) / gTimeHolder; return AuTime::SteadyClockNS() * gTime / 10'000ull; #endif } diff --git a/Source/SWInfo/AuSWInfo.NT.cpp b/Source/SWInfo/AuSWInfo.NT.cpp index 779858f6..0d698388 100644 --- a/Source/SWInfo/AuSWInfo.NT.cpp +++ b/Source/SWInfo/AuSWInfo.NT.cpp @@ -88,13 +88,11 @@ namespace Aurora::SWInfo #endif - void InitNTInfo(OSInformation &osInfo) + void InitNTInfoNoAllocate(OSInformation &osInfo) { OSVERSIONINFOEX info {}; info.dwOSVersionInfoSize = sizeof(info); - osInfo = AuMove(OSInformation(&gKernelString, &gUserlandBrand, &gUserlandDesktopEnv, &gBuildString, Aurora::Build::EPlatform::eEnumInvalid)); - #if defined(AURORA_PLATFORM_WIN32) Win32SetIsServer(osInfo); osInfo.bIsEnterprise = osInfo.bIsServer;//IsWindowsEnterpriseBranch(); @@ -103,8 +101,6 @@ namespace Aurora::SWInfo osInfo.bIsEnterprise = false; #endif - gUserlandDesktopEnv = "Desktop Window Manager"; - if (GetVersionExA(reinterpret_cast(&info))) { osInfo.uKernelPatch = info.dwBuildNumber; @@ -131,7 +127,18 @@ namespace Aurora::SWInfo osInfo.uUserlandMinor = ovi.wServicePackMajor; osInfo.uUserlandPatch = ovi.wServicePackMinor; } - + #endif + } + + void InitNTInfo(OSInformation &osInfo) + { + osInfo = AuMove(OSInformation(&gKernelString, &gUserlandBrand, &gUserlandDesktopEnv, &gBuildString, Aurora::Build::EPlatform::eEnumInvalid)); + + InitNTInfoNoAllocate(osInfo); + + gUserlandDesktopEnv = "Desktop Window Manager"; + + #if defined(AURORA_PLATFORM_WIN32) HKEY hKey; if (RegOpenKeyExW(HKEY_LOCAL_MACHINE, L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion", 0, KEY_READ, &hKey) == ERROR_SUCCESS) { diff --git a/Source/SWInfo/AuSWInfo.NT.hpp b/Source/SWInfo/AuSWInfo.NT.hpp index 82c38204..be184c0f 100644 --- a/Source/SWInfo/AuSWInfo.NT.hpp +++ b/Source/SWInfo/AuSWInfo.NT.hpp @@ -10,4 +10,5 @@ namespace Aurora::SWInfo { void InitNTInfo(OSInformation &info); + void InitNTInfoNoAllocate(OSInformation &info); } \ No newline at end of file diff --git a/Source/SWInfo/AuSWInfo.cpp b/Source/SWInfo/AuSWInfo.cpp index 57da39e7..76e884a0 100644 --- a/Source/SWInfo/AuSWInfo.cpp +++ b/Source/SWInfo/AuSWInfo.cpp @@ -30,6 +30,7 @@ namespace Aurora::SWInfo AUKN_SYM const OSInformation &GetPlatformInfo() { + SysAssert(gInfo, "No Platform Information Initialized"); return *gInfo; } @@ -48,4 +49,13 @@ namespace Aurora::SWInfo gTempInfo.ePlatform = Build::kCurrentPlatform; gInfo = &gTempInfo; } + + void InitSwInfoEarly() + { + #if defined(AURORA_IS_MODERNNT_DERIVED) + InitNTInfoNoAllocate(gTempInfo); + gTempInfo.ePlatform = Build::kCurrentPlatform; + gInfo = &gTempInfo; + #endif + } } \ No newline at end of file diff --git a/Source/SWInfo/AuSWInfo.hpp b/Source/SWInfo/AuSWInfo.hpp index a0e267b7..d368a51c 100644 --- a/Source/SWInfo/AuSWInfo.hpp +++ b/Source/SWInfo/AuSWInfo.hpp @@ -10,4 +10,5 @@ namespace Aurora::SWInfo { void InitSwInfo(); + void InitSwInfoEarly(); } \ No newline at end of file diff --git a/Source/Time/AuClock.cpp b/Source/Time/AuClock.cpp index 65edd7df..30af360c 100644 --- a/Source/Time/AuClock.cpp +++ b/Source/Time/AuClock.cpp @@ -133,7 +133,7 @@ gInitOnce.Call([] { Aurora::InitNTAddresses(); - AuSwInfo::InitSwInfo(); + AuSwInfo::InitSwInfoEarly(); if constexpr (AuBuild::kCurrentPlatform == AuBuild::EPlatform::ePlatformWin32) {