static bool running_on_win8_or_later(void) { PEB *peb = get_own_peb(); return (peb->OSMajorVersion > 6 || (peb->OSMajorVersion == 6 && peb->OSMinorVersion >= 2)); }
NTSTATUS WINAPI redirect_RtlInitializeCriticalSectionEx(RTL_CRITICAL_SECTION* crit, ULONG spincount, ULONG flags) { /* We cannot allow ntdll!RtlpAllocateDebugInfo to be called as it * uses its own free list RtlCriticalSectionDebugSList which is * shared w/ the app and can result in mixing app and private heap * objects but with the wrong Heap handle, leading to crashes * (xref Dr. Memory i#333). */ LOG(GLOBAL, LOG_LOADER, 2, "%s: "PFX"\n", __FUNCTION__, crit); IF_CLIENT_INTERFACE(ASSERT(get_own_teb()->ProcessEnvironmentBlock == get_private_peb() || standalone_library)); if (crit == NULL) return STATUS_INVALID_PARAMETER; if (TEST(RTL_CRITICAL_SECTION_FLAG_STATIC_INIT, flags)) { /* We're supposed to use a memory pool but it's not * clear whether it really matters so we ignore this flag. */ LOG(GLOBAL, LOG_LOADER, 2, "%s: ignoring static-init flag\n", __FUNCTION__); } memset(crit, 0, sizeof(*crit)); crit->LockCount = -1; if (get_own_peb()->NumberOfProcessors < 2) crit->SpinCount = 0; else crit->SpinCount = (spincount & ~0x80000000); if (TEST(RTL_CRITICAL_SECTION_FLAG_NO_DEBUG_INFO, flags)) crit->DebugInfo = NULL; else { crit->DebugInfo = wrapped_dr_alloc(0, sizeof(*crit->DebugInfo)); } if (crit->DebugInfo != NULL) { memset(crit->DebugInfo, 0, sizeof(*crit->DebugInfo)); crit->DebugInfo->CriticalSection = crit; crit->DebugInfo->ProcessLocksList.Blink = &(crit->DebugInfo->ProcessLocksList); crit->DebugInfo->ProcessLocksList.Flink = &(crit->DebugInfo->ProcessLocksList); } return STATUS_SUCCESS; }