WheapAddSectionFromGenericErrorData

NTSTATUS __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 MaxSectionsPerRecord; 
  NTSTATUS v10; 
  _WHEA_ERROR_RECORD_SECTION_DESCRIPTOR *SectionDescriptor; 
  __int64 v12; 
  unsigned int v13; 
  _WHEA_ERROR_RECORD_SECTION_DESCRIPTOR *v14; 
  size_t ErrorDataLength; 
  _WHEA_GENERIC_ERROR_DATA_ENTRY_V2 *v16; 

  SectionCount = Record->Header.SectionCount;
  MaxSectionsPerRecord = Source->MaxSectionsPerRecord;
  if( (unsigned int)SectionCount >= MaxSectionsPerRecord )
    return -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 * MaxSectionsPerRecord + 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 -1073741789;
  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((char *)Record + v13, (char *)ErrorEntry + v12, ErrorDataLength);
  ++Record->Header.SectionCount;
  return v10;
}

Referenced by:

WheapCreateRecordFromGenericErrorData