WheaAddErrorSourceDeviceDriver

NTSTATUS __stdcall WheaAddErrorSourceDeviceDriver(VOID *Context, INT64 a2, UINT64 a3){
  INT64 v3; 
  unsigned __int8 *PoolWithTag; 
  __int64 v5; 
  unsigned __int8 *v6; 
  unsigned int v9; 
  unsigned int v10; 
  _GUID v11; 
  __int128 v12; 
  NTSTATUS PacketLength; 
  unsigned __int8 *v14; 
  int v15; 
  _WHEA_ERROR_SOURCE_DESCRIPTOR Descriptor; 

  PoolWithTag = 0i64;
  v5 = (unsigned int)a3;
  v6 = 0i64;
  if( !*(_QWORD *)(a2 + 28) || !*(_QWORD *)(a2 + 36) )
    return -1073741811;
  if( *(_DWORD *)a2 == 2 )
  {
    v9 = *(_DWORD *)(a2 + 48) + 2;
    v10 = *(_DWORD *)(a2 + 44) * v9;
    if( !*(&stru_140CF2E80 + 6344) )
      WheaConfigureErrorSource(WheaErrSrcTypeDeviceDriver, &WheaDeviceDriverDefaultSourceConfig, a3, v3);
    memset(&Descriptor, 0i64, sizeof(Descriptor));
    Descriptor.Info.DeviceDriverDescriptor.LogTag = *(_WORD *)(a2 + 20);
    *(_OWORD *)&Descriptor.Info.DeviceDriverDescriptor.Config.Initialize = *(_OWORD *)(a2 + 28);
    Descriptor.Info.XpfCmcDescriptor.Banks[0].ControlData = (unsigned __int64)WheapCorrectErrorSourceDeviceDriver;
    Descriptor.Length = 972;
    Descriptor.Version = 11;
    Descriptor.Type = WheaErrSrcTypeDeviceDriver;
    Descriptor.State = WheaErrSrcStateStopped;
    Descriptor.NumRecordsToPreallocate = v5;
    Descriptor.MaxSectionsPerRecord = v9;
    Descriptor.ErrorSourceId = 0;
    Descriptor.Flags = 0;
    Descriptor.MaxRawDataLength = v10;
    Descriptor.Info.DeviceDriverDescriptor.PacketBuffer = 0i64;
    Descriptor.Info.DeviceDriverDescriptor.PacketStateBuffer = 0i64;
    v11 = *(_GUID *)(a2 + 68);
    Descriptor.Info.DeviceDriverDescriptor.CreatorId = *(_GUID *)(a2 + 52);
    v12 = *(_OWORD *)(a2 + 4);
    Descriptor.Info.DeviceDriverDescriptor.PartitionId = v11;
    *(_OWORD *)(&Descriptor.Info.IpfMcaDescriptor + 1) = v12;
    if( (_DWORD)v5 && v10 )
    {
      PacketLength = WheapDeviceDriverGetPacketLength(*(_DWORD *)(a2 + 44) * v9, v9);
      PoolWithTag = (unsigned __int8 *)ExAllocatePoolWithTag(
                                         0x200ui64,
                                         (unsigned int)(v5 * PacketLength),
                                         1095059543i64);
      v14 = (unsigned __int8 *)ExAllocatePoolWithTag(0x200ui64, 104 * v5, 1095059543i64);
      v6 = v14;
      if( !PoolWithTag || !v14 )
        return -1073741670;
      *(_QWORD *)&Descriptor.Info.DeviceDriverDescriptor.MaxSectionDataLength = *(_QWORD *)(a2 + 44);
      Descriptor.Info.DeviceDriverDescriptor.PacketBuffer = PoolWithTag;
      Descriptor.Info.DeviceDriverDescriptor.PacketStateBuffer = v14;
      *(_QWORD *)&Descriptor.Info.DeviceDriverDescriptor.PacketLength = __PAIR64__(v5, PacketLength);
    }
    v15 = WheaAddErrorSource(&Descriptor, Context);
    if( v15 < 0 )
    {
      if( PoolWithTag )
        ExFreePoolWithTag(PoolWithTag, 0x41454857u);
      if( v6 )
        ExFreePoolWithTag(v6, 0x41454857u);
    }
    return v15;
  }
  return -1073741584;
}

Referenced by:

WheaAddErrorSourceDeviceDriverV1