HalpInterruptRegisterController

__int64 __fastcall HalpInterruptRegisterController(__int64 a1){
  unsigned int v1; 
  int v3; 
  int v4; 
  INT64 v5; 
  __int16 v6; 
  WCHAR v7; 
  unsigned __int16 Length; 
  PSTR MemoryInternal; 
  __int64 v10; 
  UNICODE_STRING *v11; 
  unsigned __int64 v12; 
  unsigned __int64 v13; 
  unsigned int v14; 
  UINT8 *v15; 
  __int64 *v16; 
  int v18; 
  struct _UNICODE_STRING DestinationString; 
  WCHAR SourceString[80]; 
  v1 = 0;
  DestinationString = 0i64;
  if( HalpInterruptRegistrationAllowed )
  {
    if( !a1 )
      return(unsigned int)-1073741811;
    if( *(_DWORD *)a1 != 1 )
      return(unsigned int)-1073741811;
    if( *(_DWORD *)(a1 + 4) != 232 )
      return(unsigned int)-1073741811;
    if( (*(_DWORD *)(a1 + 212) & 0xFFFFF800) != 0 )
      return(unsigned int)-1073741811;
    v3 = *(_DWORD *)(a1 + 204);
    if( !v3 )
      return(unsigned int)-1073741811;
    if( (unsigned int)(v3 - 1) > 1 )
      return(unsigned int)-1073741637;
    v4 = *(_DWORD *)(a1 + 208);
    if( v4 == -1 )
      return(unsigned int)-1073741811;
    if( HalpInterruptLookupController(v4) )
      return(unsigned int)-1073741635;
    if( *(_QWORD *)(a1 + 88)
      && *(_QWORD *)(a1 + 96)
      && !*(_QWORD *)(a1 + 64)
      && ((v6 & 1) == 0 || *(_QWORD *)(a1 + 8))
      && *(_QWORD *)(a1 + 16)
      && ((v6 & 2) == 0 || *(_QWORD *)(a1 + 24) && *(_DWORD *)(a1 + 216))
      && (!*(_DWORD *)(a1 + 228) || *(_QWORD *)(a1 + 128) && *(_QWORD *)(a1 + 136))
      && ((v6 & 0x400) == 0 || *(_QWORD *)(a1 + 176)) )
    {
      HalpInterruptBuildKnownResourceIdString(a1, v5, SourceString);
      RtlInitUnicodeString(&DestinationString, SourceString, v7);
      if( (*(_DWORD *)(a1 + 212) & 0x100) != 0 && (unsigned __int8)HalpIsPartitionCpuManager() && qword_140C4A168 )
        *(_DWORD *)(a1 + 212) ^= v18;
      Length = DestinationString.Length;
      MemoryInternal = HalpMmAllocateMemoryInternal(
                         (((*(_DWORD *)(a1 + 200) + 359) & 0xFFFFFFF8) + DestinationString.Length + 9) & 0xFFFFFFF8,
                         MmCached);
      v10 = (__int64)MemoryInternal;
      if( MemoryInternal )
      {
        memset((INT64)MemoryInternal, 0i64);
        v12 = (v10 + 359) & 0xFFFFFFFFFFFFFFF8ui64;
        *(_QWORD *)(v10 + 16) = v12;
        v13 = *(unsigned int *)(a1 + 200) + 7i64 + v12;
        *(_QWORD *)(v10 + 248) = v10 + 240;
        *(_QWORD *)(v10 + 240) = v10 + 240;
        *(_QWORD *)(v10 + 264) = v10 + 256;
        *(_QWORD *)(v10 + 256) = v10 + 256;
        *(_QWORD *)(v10 + 336) = v13 & 0xFFFFFFFFFFFFFFF8ui64;
        *(_DWORD *)(v10 + 24) = *(_DWORD *)(a1 + 200);
        *(_OWORD *)(v10 + 32) = *(_OWORD *)(a1 + 8);
        *(_OWORD *)(v10 + 48) = *(_OWORD *)(a1 + 24);
        *(_OWORD *)(v10 + 64) = *(_OWORD *)(a1 + 40);
        *(_OWORD *)(v10 + 80) = *(_OWORD *)(a1 + 56);
        *(_OWORD *)(v10 + 96) = *(_OWORD *)(a1 + 72);
        *(_OWORD *)(v10 + 112) = *(_OWORD *)(a1 + 88);
        *(_OWORD *)(v10 + 128) = *(_OWORD *)(a1 + 104);
        *(_OWORD *)(v10 + 144) = *(_OWORD *)(a1 + 120);
        *(_OWORD *)(v10 + 160) = *(_OWORD *)(a1 + 136);
        *(_OWORD *)(v10 + 176) = *(_OWORD *)(a1 + 152);
        *(_OWORD *)(v10 + 192) = *(_OWORD *)(a1 + 168);
        *(_QWORD *)(v10 + 208) = *(_QWORD *)(a1 + 184);
        *(_DWORD *)(v10 + 220) = *(_DWORD *)(a1 + 212);
        *(_DWORD *)(v10 + 216) = *(_DWORD *)(a1 + 204);
        *(_DWORD *)(v10 + 228) = *(_DWORD *)(a1 + 216);
        *(_DWORD *)(v10 + 232) = *(_DWORD *)(a1 + 208);
        *(_DWORD *)(v10 + 280) = *(_DWORD *)(a1 + 220);
        *(_DWORD *)(v10 + 284) = *(_DWORD *)(a1 + 224);
        *(_QWORD *)(v10 + 272) = 0i64;
        *(_DWORD *)(v10 + 288) = *(_DWORD *)(a1 + 228);
        v14 = *(_DWORD *)(a1 + 200);
        if( v14 )
        {
          v15 = *(UINT8 **)(a1 + 192);
          if( v15 )
            memmove(*(UINT8 **)(v10 + 16), v15, v14);
        }
        *(_WORD *)(v10 + 328) = 0;
        *(_WORD *)(v10 + 330) = Length + 2;
        RtlCopyUnicodeString((UNICODE_STRING *)(v10 + 328), &DestinationString, v11);
        v16 = (__int64 *)qword_140C4B858;
        if( *(ULONG_PTR **)qword_140C4B858 != &HalpRegisteredInterruptControllers )
          __fastfail(3u);
        ++HalpInterruptControllerCount;
        *(_QWORD *)v10 = &HalpRegisteredInterruptControllers;
        *(_QWORD *)(v10 + 8) = v16;
        *v16 = v10;
        qword_140C4B858 = v10;
      }
      else
      {
        return(unsigned int)-1073741670;
      }
    }
    else
    {
      return(unsigned int)-1073741811;
    }
  }
  else
  {
    return(unsigned int)-1073741431;
  }
  return v1;
}

Referenced by:

HalpApicRegisterIoUnit
HalpPicDiscover