WheapLoadPolicy

VOID __stdcall WheapLoadPolicy(){
  WCHAR v0; 
  bool v1; 
  int v2; 
  int v3; 
  struct _UNICODE_STRING DestinationString; 
  UINT64 Type; 
  UINT64 ResultDataSize; 
  int Data; 
  LODWORD(ResultDataSize) = 0;
  LODWORD(Type) = 0;
  Data = 0;
  DestinationString = 0i64;
  if( WheaRegPolicyDisableOffline != -1 )
    WheapPolicyDisableOffline = WheaRegPolicyDisableOffline != 0;
  if( WheaRegPolicyMemPersistOffline != -1 )
  {
    v1 = WheaRegPolicyMemPersistOffline == 0;
    goto LABEL_8;
  }
  RtlInitUnicodeString(&DestinationString, L"Kernel-PersistDefectiveMemoryList", v0);
  if( ZwQueryLicenseValue(&DestinationString, &Type, &Data, 4ui64, &ResultDataSize) >= 0
    && (_DWORD)Type == 4
    && (_DWORD)ResultDataSize == 4 )
  {
    v1 = Data == 0;
LABEL_8:
    WheapPolicyMemPersistOffline = !v1;
  }
  if( WheaRegPolicyMemPfaDisable != -1 )
    WheapPolicyMemPfaDisable = WheaRegPolicyMemPfaDisable != 0;
  v2 = WheaRegPolicyMemPfaPageCount;
  if( (unsigned int)(WheaRegPolicyMemPfaPageCount - 1) <= 0xFFFF
    || (v2 = WheapMaxCorrectedMCEOutstanding, (unsigned int)(WheapMaxCorrectedMCEOutstanding - 1) <= 0xFFFF) )
  {
    WheapPolicyMemPfaPageCount = v2;
  }
  v3 = WheaRegPolicyMemPfaThreshold;
  if( (unsigned int)(WheaRegPolicyMemPfaThreshold - 1) <= 0xFFFF
    || (v3 = WheapSingleBitEccErrorThreshold, (unsigned int)(WheapSingleBitEccErrorThreshold - 1) <= 0xFFFF) )
  {
    WheapPolicyMemPfaThreshold = v3;
  }
  if( (unsigned int)WheaRegPolicyMemPfaTimeout <= 0x93A80 )
    WheapPolicyMemPfaTimeout = 10000000i64 * (unsigned int)WheaRegPolicyMemPfaTimeout;
  if( !WheapPolicyMemPfaPageCount || !WheapPolicyMemPfaThreshold )
    WheapPolicyMemPfaDisable = 1;
  if( WheaRegPolicyIgnoreDummyWrite != -1 )
    WheapPolicyIgnoreDummyWrite = WheaRegPolicyIgnoreDummyWrite != 0;
  if( WheapRegPolicyRestoreCmciEnabled != -1 )
    WheapPolicyRestoreCmciEnabled = WheapRegPolicyRestoreCmciEnabled != 0;
  HalWheaUpdateCmciPolicy(7u, (unsigned __int8)WheapPolicyRestoreCmciEnabled);
  if( WheapRegPolicyRestoreCmciMaxAttempts != -1 )
    WheapPolicyRestoreCmciMaxAttempts = WheapRegPolicyRestoreCmciMaxAttempts;
  HalWheaUpdateCmciPolicy(8u, WheapPolicyRestoreCmciMaxAttempts);
  if( WheapRegPolicyRestoreCmciErrorLimit != -1 )
    WheapPolicyRestoreCmciErrorLimit = WheapRegPolicyRestoreCmciErrorLimit;
  HalWheaUpdateCmciPolicy(9u, WheapPolicyRestoreCmciErrorLimit);
  if( WheapRegPolicyCmciThresholdCount != -1 )
  {
    WheapPolicyCmciThresholdCount = WheapRegPolicyCmciThresholdCount;
    HalWheaUpdateCmciPolicy(0xAu, WheapRegPolicyCmciThresholdCount);
  }
  if( WheapRegPolicyCmciThresholdTime != -1 )
  {
    WheapPolicyCmciThresholdTime = WheapRegPolicyCmciThresholdTime;
    HalWheaUpdateCmciPolicy(0xBu, WheapRegPolicyCmciThresholdTime);
  }
  if( WheapRegPolicyCmciThresholdPollCount != -1 )
  {
    WheapPolicyCmciThresholdPollCount = WheapRegPolicyCmciThresholdPollCount;
    HalWheaUpdateCmciPolicy(0xCu, WheapRegPolicyCmciThresholdPollCount);
  }
  if( WheaRegPolicyDisableOffline != -1 )
    WheaRegistryKeysPresent |= 1u;
  if( WheaRegPolicyMemPersistOffline != -1 )
    WheaRegistryKeysPresent |= 2u;
  if( WheaRegPolicyMemPfaDisable != -1 )
    WheaRegistryKeysPresent |= 4u;
  if( WheaRegPolicyMemPfaPageCount != -1 )
    WheaRegistryKeysPresent |= 8u;
  if( WheaRegPolicyMemPfaThreshold != -1 )
    WheaRegistryKeysPresent |= 0x10u;
  if( WheaRegPolicyMemPfaTimeout != -1 )
    WheaRegistryKeysPresent |= 0x20u;
  if( WheapSingleBitEccErrorThreshold != -1 )
    WheaRegistryKeysPresent |= 0x40u;
  if( WheapMaxCorrectedMCEOutstanding != -1 )
    WheaRegistryKeysPresent |= 0x80u;
  if( WheaRegPolicyIgnoreDummyWrite != -1 )
    WheaRegistryKeysPresent |= 0x100u;
  if( WheapRegPolicyRestoreCmciEnabled != -1 )
    WheaRegistryKeysPresent |= 0x200u;
  if( WheapRegPolicyRestoreCmciMaxAttempts != -1 )
    WheaRegistryKeysPresent |= 0x400u;
  if( WheapRegPolicyRestoreCmciErrorLimit != -1 )
    WheaRegistryKeysPresent |= 0x800u;
  if( WheapRegPolicyCmciThresholdCount != -1 )
    WheaRegistryKeysPresent |= 0x1000u;
  if( WheapRegPolicyCmciThresholdTime != -1 )
    WheaRegistryKeysPresent |= 0x2000u;
  if( WheapRegPolicyCmciThresholdPollCount != -1 )
    WheaRegistryKeysPresent |= 0x4000u;
}

Referenced by:

WheaInitialize