WheapAddSectionFromGenericErrorData

INT64 __stdcall WheapAddSectionFromGenericErrorData(
        WHEA_ERROR_SOURCE_DESCRIPTOR *Source,
        WHEA_ERROR_RECORD *Record,
        UINT64 BufferSize,
        WHEA_GENERIC_ERROR_DATA_ENTRY_V2 *ErrorEntry,
        UINT64 ErrorEntryLength,
        UINT8 Structured){
  __int64 SectionCount; 
  unsigned int v8; 
  unsigned int v10; 
  _WHEA_ERROR_RECORD_SECTION_DESCRIPTOR *SectionDescriptor; 
  __int64 v12; 
  unsigned int v13; 
  _WHEA_ERROR_RECORD_SECTION_DESCRIPTOR *v14; 
  unsigned int ErrorDataLength; 
  WHEA_GENERIC_ERROR_DATA_ENTRY_V2 *v16; 
  SectionCount = Record->Header.SectionCount;
  v8 = *((_DWORD *)Source + 6);
  if( (unsigned int)SectionCount >= v8 )
    return(unsigned int)-1073741789;
  v10 = 0;
  SectionDescriptor = Record->SectionDescriptor;
  v12 = 72i64;
  if( (_WORD)SectionCount )
  {
    v14 = &SectionDescriptor[SectionCount - 1];
    v13 = v14->SectionOffset + v14->SectionLength;
    SectionDescriptor = v14 + 1;
  }
  else
  {
    v13 = 72 * v8 + 128;
  }
  if( Structured )
  {
    ErrorDataLength = ErrorEntry->ErrorDataLength;
    v16 = ErrorEntry;
    if( ErrorEntry->Revision.AsUSHORT != 768 )
      v12 = 64i64;
  }
  else
  {
    ErrorDataLength = ErrorEntryLength;
    v16 = (WHEA_GENERIC_ERROR_DATA_ENTRY_V2 *)&GENERIC_SECTION_GUID;
    v12 = 0i64;
  }
  if( (unsigned int)BufferSize - v13 < ErrorDataLength )
  {
    return(unsigned int)-1073741789;
  }
  else
  {
    SectionDescriptor->SectionOffset = v13;
    SectionDescriptor->SectionLength = ErrorDataLength;
    SectionDescriptor->Revision.AsUSHORT = 768;
    SectionDescriptor->ValidBits.AsUCHAR = ErrorEntry->ValidBits;
    SectionDescriptor->Flags.AsULONG = ErrorEntry->Flags;
    SectionDescriptor->SectionType = v16->SectionType;
    SectionDescriptor->FRUId = ErrorEntry->FRUId;
    SectionDescriptor->SectionSeverity = ErrorEntry->ErrorSeverity;
    *(_OWORD *)SectionDescriptor->FRUText = *(_OWORD *)ErrorEntry->FRUText;
    *(_DWORD *)&SectionDescriptor->FRUText[16] = *(_DWORD *)&ErrorEntry->FRUText[16];
    memmove((UINT8 *)Record + v13, (UINT8 *)ErrorEntry + v12, ErrorDataLength);
    ++Record->Header.SectionCount;
  }
  return v10;
}

Referenced by:

WheapCreateRecordFromGenericErrorData