HalpInitGenericErrorSourceEntryV2

__int64 __fastcall HalpInitGenericErrorSourceEntryV2(__int64 a1, _QWORD *a2){
  unsigned int v4; 
  _DWORD *PoolWithTag; 
  _DWORD *v6; 
  __int64 v7; 
  char v8; 
  _QWORD *v9; 
  unsigned int v10; 
  VOID *v11; 
  __int64 v12; 
  char *v13; 
  __int128 v14; 
  void *v15; 
  void *v16; 
  void *v17; 
  int Src[2]; 
  __int64 v20; 
  int v21; 
  int v22; 
  int v23; 
  int v24; 
  char pszDest[16]; 
  __int128 v26; 
  __int64 v27; 
  __int64 v28; 
  v4 = 0;
  PoolWithTag = ExAllocatePoolWithTag(NonPagedPoolNx, 0x428ui64, 0x206C6148ui64);
  v6 = PoolWithTag;
  if( !PoolWithTag )
  {
LABEL_21:
    v4 = -1073741670;
    goto LABEL_22;
  }
  memset((INT64)PoolWithTag, 0i64);
  v6[12] = *(_DWORD *)(a1 + 44);
  MmMapIoSpaceEx(*(_LARGE_INTEGER *)(a1 + 56), 8ui64, 0x204ui64);
  *((_QWORD *)v6 + 5) = v7;
  v27 = *(_QWORD *)(a1 + 56);
  v28 = *(unsigned int *)(a1 + 44);
  *(_OWORD *)pszDest = 0i64;
  v26 = 0i64;
  Src[0] = 1733060695;
  Src[1] = 1;
  v20 = 80i64;
  v22 = -2147483615;
  v21 = 1280201291;
  v23 = 2;
  v24 = 48;
  RtlStringCchCopyA(pszDest, 0x20ui64, (PSTR)"Error_Status_block_register");
  WheaLogInternalEvent(Src);
  if( !*((_QWORD *)v6 + 5) )
    goto LABEL_14;
  v8 = *(_BYTE *)(a1 + 95);
  if( v8 == 3 )
  {
    if( *(_BYTE *)(a1 + 93) == 32 )
      v6[18] = 4;
  }
  else if( v8 == 4 && *(_BYTE *)(a1 + 93) == 64 )
  {
    v6[18] = 8;
  }
  v9 = ExAllocatePoolWithTag(NonPagedPoolNx, 8ui64, 0x206C6148ui64);
  *((_QWORD *)v6 + 8) = v9;
  if( !v9
    || (*v9 = *(_QWORD *)(a1 + 96),
        v10 = *(_DWORD *)(a1 + 16) + 80 + v6[12],
        v11 = ExAllocatePoolWithTag(NonPagedPoolNx, v10, 0x206C6148ui64),
        (*((_QWORD *)v6 + 3) = v11) == 0i64) )
  {
LABEL_14:
    v15 = (void *)*((_QWORD *)v6 + 5);
    if( v15 )
      MmUnmapIoSpace(v15, 8ui64);
    v16 = (void *)*((_QWORD *)v6 + 8);
    if( v16 )
      ExFreePoolWithTag(v16, 0x206C6148u);
    v17 = (void *)*((_QWORD *)v6 + 3);
    if( v17 )
      ExFreePoolWithTag(v17, 0x206C6148u);
    ExFreePoolWithTag(v6, 0x206C6148u);
    v6 = 0i64;
    goto LABEL_21;
  }
  memset((INT64)v11, 0i64);
  v12 = 7i64;
  **((_DWORD **)v6 + 3) = 1095059543;
  *(_DWORD *)(*((_QWORD *)v6 + 3) + 4i64) = 3;
  *(_DWORD *)(*((_QWORD *)v6 + 3) + 8i64) = v10;
  *(_DWORD *)(*((_QWORD *)v6 + 3) + 16i64) = 6;
  *(_DWORD *)(*((_QWORD *)v6 + 3) + 24i64) = *(_DWORD *)(a1 + 28);
  *(_DWORD *)(*((_QWORD *)v6 + 3) + 28i64) = 5;
  *(GUID *)(*((_QWORD *)v6 + 3) + 32i64) = GENERIC_NOTIFY_TYPE_GUID;
  *(_DWORD *)(*((_QWORD *)v6 + 3) + 56i64) = 7;
  *(_DWORD *)(*((_QWORD *)v6 + 3) + 64i64) = 80;
  *(_DWORD *)(*((_QWORD *)v6 + 3) + 68i64) = v6[12];
  v13 = (char *)(v6 + 22);
  do
  {
    *(_OWORD *)v13 = *(_OWORD *)a1;
    *((_OWORD *)v13 + 1) = *(_OWORD *)(a1 + 16);
    *((_OWORD *)v13 + 2) = *(_OWORD *)(a1 + 32);
    *((_OWORD *)v13 + 3) = *(_OWORD *)(a1 + 48);
    *((_OWORD *)v13 + 4) = *(_OWORD *)(a1 + 64);
    *((_OWORD *)v13 + 5) = *(_OWORD *)(a1 + 80);
    *((_OWORD *)v13 + 6) = *(_OWORD *)(a1 + 96);
    v13 += 128;
    v14 = *(_OWORD *)(a1 + 112);
    a1 += 128i64;
    *((_OWORD *)v13 - 1) = v14;
    --v12;
  }
  while( v12 );
  *(_OWORD *)v13 = *(_OWORD *)a1;
  *((_OWORD *)v13 + 1) = *(_OWORD *)(a1 + 16);
  *((_OWORD *)v13 + 2) = *(_OWORD *)(a1 + 32);
  *((_OWORD *)v13 + 3) = *(_OWORD *)(a1 + 48);
  *((_QWORD *)v13 + 8) = *(_QWORD *)(a1 + 64);
  *((_DWORD *)v13 + 18) = *(_DWORD *)(a1 + 72);
LABEL_22:
  *a2 = v6;
  return v4;
}

Referenced by:

HalpInitializeGenericErrorSource