HalpReportResourceUsage
VOID __stdcall HalpReportResourceUsage(_UNICODE_STRING *HalName, _INTERFACE_TYPE DeviceInterfaceToUse){
__int64 v2;
unsigned int v3;
_CM_RESOURCE_LIST *v4;
VOID **v5;
_CM_RESOURCE_LIST *v6;
_CM_FULL_RESOURCE_DESCRIPTOR *List;
char *v8;
_CM_FULL_RESOURCE_DESCRIPTOR *v9;
unsigned int v10;
char *v11;
unsigned __int8 v12;
_QWORD *v13;
unsigned int v14;
char v15;
__int128 v16;
__int16 v17;
int v18;
LONG HighPart;
_CM_FULL_RESOURCE_DESCRIPTOR *v20;
__int64 p_PartialResourceList;
UINT64 v22;
UINT64 v23;
int v24;
UINT64 v25;
NTSTATUS v26;
unsigned int v27;
_CM_PARTIAL_RESOURCE_DESCRIPTOR *v28;
unsigned int Length;
_CM_PARTIAL_RESOURCE_DESCRIPTOR *v30;
__int64 v31;
unsigned int v32;
__int64 v33;
_CM_FULL_RESOURCE_DESCRIPTOR *v34;
int v35;
unsigned int v36;
ULONG v37;
__int64 v38;
bool v39;
int v40;
_CM_PARTIAL_RESOURCE_DESCRIPTOR v41;
int v42;
__int128 v43;
unsigned __int8 v44;
unsigned int v45;
unsigned int v46;
char v47;
_LARGE_INTEGER TranslatedAddress;
_BYTE Descriptor[20];
_LARGE_INTEGER sortvalue;
__int64 v51;
__int64 v52;
UINT64 ResourceListSize;
_CM_FULL_RESOURCE_DESCRIPTOR *p_u;
__int64 v55;
_CM_FULL_RESOURCE_DESCRIPTOR *v56;
__int64 v57;
__int128 v58;
VOID **PoolWithTag;
VOID **v60;
_UNICODE_STRING *HalNamea;
_KAFFINITY_EX Dest;
HalNamea = HalName;
memset(&Dest, 0i64, sizeof(Dest));
v2 = *(&stru_140CF2E80 + 927);
v3 = 0;
v51 = 0i64;
sortvalue.anonymous_0.LowPart = 0;
v52 = 0i64;
v55 = 0i64;
TranslatedAddress.QuadPart = 0i64;
memset(Descriptor, 0, sizeof(Descriptor));
if( *(&stru_140CF2E80 + 927) )
HalpClaimDebugResource((UINT64)&HalpKdComIoSpace, *(&stru_140CF2E80 + 927));
if( *(&stru_140CF2E80 + 931) && *(&stru_140CF2E80 + 931) != v2 )
HalpClaimDebugResource((UINT64)&HalpHvComIoSpace, *(&stru_140CF2E80 + 931));
PoolWithTag = ExAllocatePoolWithTag(0x200ui64, 0x2000ui64, 543973704i64);
v4 = (_CM_RESOURCE_LIST *)PoolWithTag;
v5 = ExAllocatePoolWithTag(0x200ui64, 0x2000ui64, 543973704i64);
v60 = v5;
v6 = (_CM_RESOURCE_LIST *)v5;
if( !PoolWithTag || !v5 )
KeBugCheckEx(0xACu, (PVOID)0x4000, (PVOID)1, "minkernel\\hals\\lib\\misc\\usage.c", (PVOID)0x18E);
memset(PoolWithTag, 0i64, 0x2000u);
memset(v6, 0i64, 0x2000u);
*((_DWORD *)PoolWithTag + 1) = -1;
List = v6->List;
v56 = v4->List;
v8 = byte_140D57D61;
v9 = v4->List;
p_u = v6->List;
v10 = 0;
v11 = HalpIDTUsageFlags;
do
{
if( (*v11 & 1) == 0 )
{
*v11 = 17;
*(_DWORD *)v8 = v10;
}
++v10;
++v11;
v8 += 5;
}
while( v10 < 0x30 );
v57 = 0i64;
v12 = 0;
ResourceListSize = 0i64;
v44 = 0;
while( 2 )
{
v13 = HalpAddressUsageList;
v14 = 0;
v15 = v12 != 0 ? 16 : 32;
v47 = v15;
LABEL_12:
v45 = v14;
while( 1 )
{
while( v14 <= 0xFF )
{
if( ((unsigned __int8)v15 & (unsigned __int8)HalpIDTUsageFlags[v14]) == 0 )
{
++v14;
goto LABEL_12;
}
KeCopyAffinityEx(&Dest, &KeActiveProcessors);
*(_WORD *)Descriptor = 514;
*(_WORD *)&Descriptor[2] = (HalpIDTUsageFlags[v45] & 2) != 0;
*(_DWORD *)&Descriptor[8] = *(_DWORD *)&HalpIDTUsage[5 * v45 + 1];
*(_DWORD *)&Descriptor[4] = *(unsigned __int16 *)&Descriptor[8];
*(_QWORD *)&Descriptor[12] = Dest.Bitmap[0];
v16 = *(_OWORD *)Descriptor;
v17 = (unsigned __int8)HalpIDTUsage[5 * v45];
v18 = HIDWORD(Dest.Bitmap[0]);
HighPart = HIDWORD(Dest.Bitmap[0]);
v58 = *(_OWORD *)Descriptor;
DWORD2(v58) = v45;
v14 = ++v45;
WORD2(v58) = v17;
LABEL_17:
v20 = p_u;
if( v56->InterfaceType )
{
++v4->Count;
p_PartialResourceList = (__int64)&v9->PartialResourceList;
++v6->Count;
v9->InterfaceType = Internal;
v20->InterfaceType = Internal;
v22 = (UINT64)&v20->PartialResourceList;
v56 = v9;
v9 = (_CM_FULL_RESOURCE_DESCRIPTOR *)((char *)v9 + 16);
ResourceListSize = (UINT64)&v20->PartialResourceList;
v20 = (_CM_FULL_RESOURCE_DESCRIPTOR *)((char *)v20 + 16);
v57 = p_PartialResourceList;
}
else
{
p_PartialResourceList = v57;
v22 = ResourceListSize;
}
++*(_DWORD *)(p_PartialResourceList + 4);
++*(_DWORD *)(v22 + 4);
v15 = v47;
*(_OWORD *)&v9->InterfaceType = v16;
*(_DWORD *)&v9->PartialResourceList.PartialDescriptors[0].Type = v18;
v9 = (_CM_FULL_RESOURCE_DESCRIPTOR *)((char *)v9 + 20);
*(_OWORD *)&v20->InterfaceType = v58;
*(_DWORD *)&v20->PartialResourceList.PartialDescriptors[0].Type = HighPart;
p_u = (_CM_FULL_RESOURCE_DESCRIPTOR *)&v20->PartialResourceList.PartialDescriptors[0].u;
}
if( !v13 )
break;
if( ((unsigned __int8)v15 & *((_BYTE *)v13 + 12)) != 0 )
{
v23 = *(_QWORD *)((char *)&v13[2 * v3 + 2] + 5);
if( v23 )
{
v24 = *((_DWORD *)v13 + 2);
if( ((v24 - 1) & 0xFFFFFFF9) == 0 && v24 != 5 )
{
v25 = *(_QWORD *)((char *)&v13[2 * v3 + 1] + 5);
*(_WORD *)&Descriptor[2] = 0;
v26 = RtlCmEncodeMemIoResource((_CM_PARTIAL_RESOURCE_DESCRIPTOR *)Descriptor, v24, v23, v25);
if( v26 < 0 )
KeBugCheckEx(0x5Cu, (PVOID)0x10F, (PVOID)v26, v13, (PVOID)v3);
Descriptor[1] = 2;
if( Descriptor[0] == 1 )
{
TranslatedAddress.anonymous_0.LowPart = 1;
*(_WORD *)&Descriptor[2] = Descriptor[0] - 1 + 17;
}
else if( Descriptor[0] == 3 || Descriptor[0] == 7 )
{
TranslatedAddress.anonymous_0.LowPart = 0;
if( (*((_BYTE *)v13 + 12) & 4) != 0 )
*(_WORD *)&Descriptor[2] |= 1u;
}
sortvalue.anonymous_0.HighPart = *(_DWORD *)&Descriptor[16];
v58 = *(_OWORD *)Descriptor;
HalTranslateBusAddress(Internal, 0, *(PHYSICAL_ADDRESS *)&Descriptor[4], &TranslatedAddress);
*(_QWORD *)((char *)&v58 + 4) = v55;
if( Descriptor[0] == 1 && !TranslatedAddress.anonymous_0.LowPart )
WORD1(v58) = 0;
v16 = *(_OWORD *)Descriptor;
v14 = v45;
++v3;
v18 = *(_DWORD *)&Descriptor[16];
HighPart = sortvalue.anonymous_0.HighPart;
goto LABEL_17;
}
v14 = v45;
}
v13 = (_QWORD *)*v13;
v3 = 0;
}
else
{
v13 = (_QWORD *)*v13;
v3 = 0;
}
}
v12 = v44 + 1;
v44 = v12;
if( v12 < 2u )
{
v3 = 0;
continue;
}
break;
}
v46 = 0;
ResourceListSize = (unsigned int)((_DWORD)v9 - (_DWORD)v4);
v27 = 0;
if( v4->Count )
{
v28 = (_CM_PARTIAL_RESOURCE_DESCRIPTOR *)v4->List;
while( 1 )
{
Length = v28->u.Length;
v30 = v28 + 1;
List = (_CM_FULL_RESOURCE_DESCRIPTOR *)((char *)List + 16);
sortvalue.anonymous_0.HighPart = Length;
if( !Length )
goto LABEL_53;
do
{
HalpGetResourceSortValue(v30, (_LARGE_INTEGER *)((char *)&TranslatedAddress.QuadPart + 4));
v33 = v31;
v34 = List;
if( v32 >= Length )
goto LABEL_51;
v35 = HIDWORD(v51);
v36 = Length;
v37 = TranslatedAddress.anonymous_0.HighPart;
v38 = v36 - v32;
do
{
HalpGetResourceSortValue((_CM_PARTIAL_RESOURCE_DESCRIPTOR *)v33, &sortvalue);
if( sortvalue.anonymous_0.LowPart >= v37 )
{
if( sortvalue.anonymous_0.LowPart != v37 )
goto LABEL_49;
v39 = SHIDWORD(v52) < v35;
if( HIDWORD(v52) != v35 )
goto LABEL_48;
if( (unsigned int)v52 >= (unsigned int)v51 )
{
v39 = SHIDWORD(v52) < v35;
LABEL_48:
if( !v39 )
goto LABEL_49;
}
}
v40 = *(_DWORD *)(v31 + 16);
v41 = *(_CM_PARTIAL_RESOURCE_DESCRIPTOR *)v31;
*(_OWORD *)v31 = *(_OWORD *)v33;
*(_DWORD *)(v31 + 16) = *(_DWORD *)(v33 + 16);
*(_CM_PARTIAL_RESOURCE_DESCRIPTOR *)v33 = v41;
*(_DWORD *)(v33 + 16) = v40;
v42 = *(_DWORD *)&List->PartialResourceList.PartialDescriptors[0].Type;
v43 = *(_OWORD *)&List->InterfaceType;
*(_OWORD *)&List->InterfaceType = *(_OWORD *)&v34->InterfaceType;
*(_DWORD *)&List->PartialResourceList.PartialDescriptors[0].Type = *(_DWORD *)&v34->PartialResourceList.PartialDescriptors[0].Type;
*(_OWORD *)&v34->InterfaceType = v43;
*(_DWORD *)&v34->PartialResourceList.PartialDescriptors[0].Type = v42;
HalpGetResourceSortValue(
(_CM_PARTIAL_RESOURCE_DESCRIPTOR *)v31,
(_LARGE_INTEGER *)((char *)&TranslatedAddress.QuadPart + 4));
v35 = HIDWORD(v51);
v37 = TranslatedAddress.anonymous_0.HighPart;
LABEL_49:
v33 += 20i64;
v34 = (_CM_FULL_RESOURCE_DESCRIPTOR *)((char *)v34 + 20);
--v38;
}
while( v38 );
Length = sortvalue.anonymous_0.HighPart;
LABEL_51:
v30 = (_CM_PARTIAL_RESOURCE_DESCRIPTOR *)(v31 + 20);
List = (_CM_FULL_RESOURCE_DESCRIPTOR *)((char *)List + 20);
}
while( v32 + 1 < Length );
v4 = (_CM_RESOURCE_LIST *)PoolWithTag;
v27 = v46;
LABEL_53:
++v27;
v28 = v30;
v46 = v27;
if( v27 >= v4->Count )
{
v6 = (_CM_RESOURCE_LIST *)v60;
break;
}
}
}
IoReportHalResourceUsage(HalNamea, v4, v6, (unsigned int)ResourceListSize);
ExFreePoolWithTag(v4, 0);
ExFreePoolWithTag(v6, 0);
}Referenced by:
HalReportResourceUsage