WheapCheckForAndReportErrorsFromPreviousSession

VOID __stdcall WheapCheckForAndReportErrorsFromPreviousSession(){
  int BootErrorPacket; 
  _WHEA_ERROR_PACKET_V2 *v1; 
  bool v2; 
  __int64 v3; 
  NTSTATUS EnvironmentVariable; 
  UINT64 *Attributes; 
  _WHEA_ERROR_RECORD *Record; 
  __int64 v7; 
  __int64 Value[3]; 
  unsigned int v9; 
  UINT64 ValueLength; 
  int v11; 
  _WHEA_ERROR_PACKET_V2 *BootPacket; 

  BootPacket = 0i64;
  v11 = 0;
  v9 = 0;
  Record = 0i64;
  BootErrorPacket = PshedGetBootErrorPacket(&v11, &BootPacket);
  v1 = BootPacket;
  v2 = BootErrorPacket < 0;
  v3 = 0i64;
  v7 = 0i64;
  if( v2 )
    v1 = 0i64;
  BootPacket = v1;
  do
  {
    if( (int)PshedReadErrorRecord(0i64, v3, &v7, &v9, &Record) < 0 )
      break;
    if( Record )
    {
      if( Record->Header.Signature == 1380274243 && Record->Header.Length <= v9 )
      {
        if( WheapReportPersistedErrorRecord(Record) == 1 )
          PshedClearErrorRecord(
            (unsigned __int16)((unsigned int)HIDWORD(Record->Header.PersistenceInfo.AsULONGLONG) >> 8),
            Record->Header.RecordId);
        ExFreePoolWithTag(Record, 0x44485350u);
      }
      else
      {
        ExFreePoolWithTag(Record, 0x44485350u);
        Record = 0i64;
      }
    }
    v3 = v7;
  }
  while( v7 != -1 );
  if( BootPacket )
  {
    WheapReportBootError(BootPacket);
    ExFreePoolWithTag(BootPacket, 0x44485350u);
    BootPacket = 0i64;
  }
  Value[0] = 0i64;
  LODWORD(ValueLength) = 8;
  EnvironmentVariable = HalGetEnvironmentVariableEx(
                          (WCHAR *)L"UncorrectedBadMemoryPage",
                          &WheapHardwareErrorGuid,
                          Value,
                          &ValueLength,
                          0i64);
  if( (_DWORD)ValueLength && EnvironmentVariable >= 0 && WheaPersistBadPageToBcd(Value[0]) >= 0 )
  {
    LODWORD(Attributes) = 7;
    HalSetEnvironmentVariableEx(
      (WCHAR *)L"UncorrectedBadMemoryPage",
      &WheapHardwareErrorGuid,
      0i64,
      0i64,
      (UINT64)Attributes);
  }
}

Referenced by:

WheaInitialize