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;
WCHAR v17;
int v18;
struct _UNICODE_STRING DestinationString;
WCHAR SourceString[80];
DestinationString = 0i64;
if( !ResourceDescriptor )
return -1073741811;
if( !ResourceDescriptorInfo )
return -1073741811;
if( !ResourceGroup )
return -1073741811;
if( (unsigned int)uINT >= HalpExtHandleCount )
return -1073741811;
v7 = HalpExtHandleArray + ((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, 0x300ui64, (ULONG_PTR)MemoryInternal, (ULONG_PTR)ResourceGroup, 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", (WCHAR)ResourceDescriptor);
if( HalpExtGetRegisteredResourceIdString((INT64)MemoryInternal, v16, SourceString) >= 0 )
RtlInitUnicodeString(&DestinationString, SourceString, v17);
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.