HalpExtRegisterResourceDescriptor

NTSTATUS __stdcall HalpExtRegisterResourceDescriptor(
        _HANDLE uINT,
        _CSRT_RESOURCE_GROUP_HEADER *ResourceGroup,
        _CSRT_RESOURCE_DESCRIPTOR_HEADER *ResourceDescriptor,
        PVOID ResourceDescriptorInfo){
  unsigned __int64 v7; 
  unsigned __int64 v8; 
  PSTR MemoryInternal; 
  UINT32 VendorId; 
  __int64 v11; 
  NTSTATUS result; 
  PSTR v13; 
  PSTR *v14; 
  PSTR *v15; 
  INT64 v16; 
  INT64 v17; 
  int v18; 
  PVOID BugCheckParameter4; 
  INT64 v20; 
  _UNICODE_STRING DestinationString; 
  __int64 v22[4]; 
  CHAR v23; 

  DestinationString = 0i64;
  if( !ResourceDescriptor )
    return -1073741811;
  if( !ResourceDescriptorInfo )
    return -1073741811;
  if( !ResourceGroup )
    return -1073741811;
  if( uINT >= (unsigned int)dword_140C49CA0 )
    return -1073741811;
  v7 = qword_140C49C98 + ((unsigned __int64)(unsigned int)uINT << 6);
  if( !*(_BYTE *)v7 )
    return -1073741811;
  v8 = v7 + 32;
  MemoryInternal = *(PSTR *)(v7 + 32);
  if( MemoryInternal == (PSTR)(v7 + 32) )
  {
LABEL_16:
    MemoryInternal = HalpMmAllocateMemoryInternal(0x28ui64, MmCached);
    if( !MemoryInternal )
      return -1073741801;
  }
  else
  {
    VendorId = ResourceGroup->VendorId;
    while( 1 )
    {
      v11 = *((_QWORD *)MemoryInternal + 3);
      if( *(_DWORD *)(v11 + 4) == VendorId
        && *(_WORD *)(v11 + 12) == ResourceGroup->DeviceId
        && *(_DWORD *)(v11 + 8) == ResourceGroup->SubvendorId
        && *(_WORD *)(v11 + 14) == ResourceGroup->SubdeviceId
        && *(_WORD *)(v11 + 16) == ResourceGroup->Revision
        && *(_WORD *)(v11 + 18) == ResourceGroup->Instance
        && *((_DWORD *)MemoryInternal + 9) == ResourceDescriptor->Uid )
      {
        break;
      }
      MemoryInternal = *(PSTR *)MemoryInternal;
      if( MemoryInternal == (PSTR)v8 )
        goto LABEL_16;
    }
    if( *((int *)MemoryInternal + 4) >= 0 )
      KeBugCheckEx(0x5Cu, (PVOID)0x300, MemoryInternal, ResourceGroup, (PVOID)ResourceDescriptor->Uid);
    v13 = *(PSTR *)MemoryInternal;
    if( *(PSTR *)(*(_QWORD *)MemoryInternal + 8i64) != MemoryInternal
      || (v14 = (PSTR *)*((_QWORD *)MemoryInternal + 1), *v14 != MemoryInternal) )
    {
LABEL_24:
      __fastfail(3u);
    }
    *v14 = v13;
    *((_QWORD *)v13 + 1) = v14;
  }
  *((_QWORD *)MemoryInternal + 3) = ResourceGroup;
  *((_WORD *)MemoryInternal + 16) = ResourceDescriptor->Type;
  *((_WORD *)MemoryInternal + 17) = ResourceDescriptor->Subtype;
  *((_DWORD *)MemoryInternal + 9) = ResourceDescriptor->Uid;
  v15 = *(PSTR **)(v8 + 8);
  if( *v15 != (PSTR)v8 )
    goto LABEL_24;
  *(_QWORD *)MemoryInternal = v8;
  *((_QWORD *)MemoryInternal + 1) = v15;
  *v15 = MemoryInternal;
  *(_QWORD *)(v8 + 8) = MemoryInternal;
  RtlInitUnicodeString(&DestinationString, L"Unknown Resource");
  if( HalpExtGetRegisteredResourceIdString(
         (INT64)MemoryInternal,
         v16,
         (INT64)v22,
         v17,
         (INT64)BugCheckParameter4,
         v20,
         *(INT64 *)&DestinationString.Length,
         (INT64)DestinationString.Buffer,
         v22[0],
         v22[1],
         v22[2],
         v22[3],
         v23) >= 0 )
    RtlInitUnicodeString(&DestinationString, (PCWSTR)v22);
  v18 = *(_DWORD *)&ResourceDescriptor->Type;
  if( v18 == 3 )
  {
    result = HalpRegisterDmaChannel((_DMA_CHANNEL_INITIALIZATION_BLOCK *)ResourceDescriptorInfo);
  }
  else if( v18 == 65539 )
  {
    result = HalpRegisterDmaController((_DMA_INITIALIZATION_BLOCK *)ResourceDescriptorInfo, &DestinationString);
  }
  else
  {
    result = -1073741822;
  }
  *((_DWORD *)MemoryInternal + 4) = result;
  return result;
}

Referenced by:

No references.