HalpReportResourceUsage
VOID __stdcall HalpReportResourceUsage(UNICODE_STRING *HalName, INTERFACE_TYPE DeviceInterfaceToUse){
INT64 v2;
unsigned int v3;
CM_RESOURCE_LIST *v4;
CM_RESOURCE_LIST *v5;
CM_RESOURCE_LIST *v6;
char *v7;
char *v8;
_DWORD *v9;
unsigned int v10;
char *v11;
unsigned __int8 v12;
ULONG_PTR v13;
unsigned int v14;
char v15;
__int128 v16;
__int16 v17;
int v18;
LONG HighPart;
_DWORD *v20;
__int64 v21;
UINT64 v22;
UINT64 v23;
int v24;
UINT64 v25;
int v26;
unsigned int v27;
_CM_PARTIAL_RESOURCE_DESCRIPTOR *v28;
unsigned int v29;
_CM_PARTIAL_RESOURCE_DESCRIPTOR *v30;
__int128 *v31;
unsigned int v32;
__int128 *v33;
char *v34;
int v35;
unsigned int v36;
ULONG LowPart;
__int64 v38;
bool v39;
int v40;
__int128 v41;
int v42;
__int128 v43;
unsigned __int8 v44;
unsigned int v45;
unsigned int v46;
char v47;
ULONG AddressSpace;
LARGE_INTEGER BusAddress;
_BYTE BusAddress_8[20];
LARGE_INTEGER sortvalue;
__int64 v52;
__int64 v53;
UINT64 ResourceListSize;
_DWORD *v55;
LARGE_INTEGER v56;
_DWORD *v57;
__int64 v58;
__int128 v59;
INT64 PoolWithTag;
CM_RESOURCE_LIST *v61;
UNICODE_STRING *HalNamea;
INT64 result;
__int64 v64;
HalNamea = HalName;
memset((INT64)&result, 0i64);
v2 = KdComPortInUse;
v3 = 0;
BusAddress.LowPart = 0;
v52 = 0i64;
sortvalue.LowPart = 0;
v53 = 0i64;
v56.QuadPart = 0i64;
AddressSpace = 0;
memset(BusAddress_8, 0, sizeof(BusAddress_8));
if( KdComPortInUse )
HalpClaimDebugResource((UINT64)&HalpKdComIoSpace, KdComPortInUse);
if( KdHvComPortInUse && KdHvComPortInUse != v2 )
HalpClaimDebugResource((UINT64)&HalpHvComIoSpace, KdHvComPortInUse);
PoolWithTag = (INT64)ExAllocatePoolWithTag(NonPagedPoolNx, 0x2000ui64, 0x206C6148ui64);
v4 = (CM_RESOURCE_LIST *)PoolWithTag;
v5 = (CM_RESOURCE_LIST *)ExAllocatePoolWithTag(NonPagedPoolNx, 0x2000ui64, 0x206C6148ui64);
v61 = v5;
v6 = v5;
if( !PoolWithTag || !v5 )
KeBugCheckEx(0xACu, 0x4000ui64, 1ui64, (ULONG_PTR)"minkernel\\hals\\lib\\misc\\usage.c", 0x18Eui64);
memset(PoolWithTag, 0i64);
memset((INT64)v6, 0i64);
*(_DWORD *)(PoolWithTag + 4) = -1;
v7 = (char *)v6 + 4;
v57 = (_DWORD *)((char *)v4 + 4);
v8 = byte_140D57D61;
v9 = (_DWORD *)((char *)v4 + 4);
v55 = (_DWORD *)((char *)v6 + 4);
v10 = 0;
v11 = HalpIDTUsageFlags;
do
{
if( (*v11 & 1) == 0 )
{
*v11 = 17;
*(_DWORD *)v8 = v10;
}
++v10;
++v11;
v8 += 5;
}
while( v10 < 0x30 );
v58 = 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((__int64)&result, &KeActiveProcessors.Count);
*(_DWORD *)BusAddress_8 = 66050;
if( (HalpIDTUsageFlags[v45] & 2) == 0 )
*(_WORD *)&BusAddress_8[2] = 0;
*(_DWORD *)&BusAddress_8[8] = *(_DWORD *)&HalpIDTUsage[5 * v45 + 1];
*(_DWORD *)&BusAddress_8[4] = *(unsigned __int16 *)&BusAddress_8[8];
*(_QWORD *)&BusAddress_8[12] = v64;
v16 = *(_OWORD *)BusAddress_8;
v17 = (unsigned __int8)HalpIDTUsage[5 * v45];
v18 = HIDWORD(v64);
HighPart = HIDWORD(v64);
v59 = *(_OWORD *)BusAddress_8;
DWORD2(v59) = v45;
v14 = ++v45;
WORD2(v59) = v17;
LABEL_19:
v20 = v55;
if( *v57 )
{
++*(_DWORD *)v4;
v21 = (__int64)(v9 + 2);
++*(_DWORD *)v6;
*v9 = 0;
*v20 = 0;
v22 = (UINT64)(v20 + 2);
v57 = v9;
v9 += 4;
ResourceListSize = (UINT64)(v20 + 2);
v20 += 4;
v58 = v21;
}
else
{
v21 = v58;
v22 = ResourceListSize;
}
++*(_DWORD *)(v21 + 4);
++*(_DWORD *)(v22 + 4);
v15 = v47;
*(_OWORD *)v9 = v16;
v9[4] = v18;
v9 += 5;
*(_OWORD *)v20 = v59;
v20[4] = HighPart;
v55 = v20 + 5;
}
if( !v13 )
break;
if( ((unsigned __int8)v15 & *(_BYTE *)(v13 + 12)) != 0 )
{
v23 = *(_QWORD *)(v13 + 16i64 * v3 + 21);
if( v23 )
{
v24 = *(_DWORD *)(v13 + 8);
if( ((v24 - 1) & 0xFFFFFFF9) == 0 && v24 != 5 )
{
v25 = *(_QWORD *)(v13 + 16i64 * v3 + 13);
*(_WORD *)&BusAddress_8[2] = 0;
v26 = RtlCmEncodeMemIoResource((_CM_PARTIAL_RESOURCE_DESCRIPTOR *)BusAddress_8, v24, v23, v25);
if( v26 < 0 )
KeBugCheckEx(0x5Cu, 0x10Fui64, v26, v13, v3);
BusAddress_8[1] = 2;
if( BusAddress_8[0] == 1 )
{
AddressSpace = 1;
*(_WORD *)&BusAddress_8[2] = BusAddress_8[0] - 1 + 17;
}
else if( BusAddress_8[0] == 3 || BusAddress_8[0] == 7 )
{
AddressSpace = 0;
if( (*(_BYTE *)(v13 + 12) & 4) != 0 )
*(_WORD *)&BusAddress_8[2] |= 1u;
}
sortvalue.HighPart = *(_DWORD *)&BusAddress_8[16];
v59 = *(_OWORD *)BusAddress_8;
HalTranslateBusAddress(0i64, 0i64, *(MEMORY_CACHING_TYPE **)&BusAddress_8[4]);
*(LARGE_INTEGER *)((char *)&v59 + 4) = v56;
if( BusAddress_8[0] == 1 && !AddressSpace )
WORD1(v59) = 0;
v16 = *(_OWORD *)BusAddress_8;
v14 = v45;
++v3;
v18 = *(_DWORD *)&BusAddress_8[16];
HighPart = sortvalue.HighPart;
goto LABEL_19;
}
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( *(_DWORD *)v4 )
{
v28 = (_CM_PARTIAL_RESOURCE_DESCRIPTOR *)((char *)v4 + 4);
while( 1 )
{
v29 = *((_DWORD *)v28 + 3);
v30 = (_CM_PARTIAL_RESOURCE_DESCRIPTOR *)((char *)v28 + 16);
v7 += 16;
sortvalue.HighPart = v29;
if( !v29 )
goto LABEL_55;
do
{
HalpGetResourceSortValue(v30, &BusAddress);
v33 = v31;
v34 = v7;
if( v32 >= v29 )
goto LABEL_53;
v35 = HIDWORD(v52);
v36 = v29;
LowPart = BusAddress.LowPart;
v38 = v36 - v32;
do
{
HalpGetResourceSortValue((_CM_PARTIAL_RESOURCE_DESCRIPTOR *)v33, &sortvalue);
if( sortvalue.LowPart >= LowPart )
{
if( sortvalue.LowPart != LowPart )
goto LABEL_51;
v39 = SHIDWORD(v53) < v35;
if( HIDWORD(v53) != v35 )
goto LABEL_50;
if( (unsigned int)v53 >= (unsigned int)v52 )
{
v39 = SHIDWORD(v53) < v35;
LABEL_50:
if( !v39 )
goto LABEL_51;
}
}
v40 = *((_DWORD *)v31 + 4);
v41 = *v31;
*v31 = *v33;
*((_DWORD *)v31 + 4) = *((_DWORD *)v33 + 4);
*v33 = v41;
*((_DWORD *)v33 + 4) = v40;
v42 = *((_DWORD *)v7 + 4);
v43 = *(_OWORD *)v7;
*(_OWORD *)v7 = *(_OWORD *)v34;
*((_DWORD *)v7 + 4) = *((_DWORD *)v34 + 4);
*(_OWORD *)v34 = v43;
*((_DWORD *)v34 + 4) = v42;
HalpGetResourceSortValue((_CM_PARTIAL_RESOURCE_DESCRIPTOR *)v31, &BusAddress);
v35 = HIDWORD(v52);
LowPart = BusAddress.LowPart;
LABEL_51:
v33 = (__int128 *)((char *)v33 + 20);
v34 += 20;
--v38;
}
while( v38 );
v29 = sortvalue.HighPart;
LABEL_53:
v30 = (_CM_PARTIAL_RESOURCE_DESCRIPTOR *)((char *)v31 + 20);
v7 += 20;
}
while( v32 + 1 < v29 );
v4 = (CM_RESOURCE_LIST *)PoolWithTag;
v27 = v46;
LABEL_55:
++v27;
v28 = v30;
v46 = v27;
if( v27 >= *(_DWORD *)v4 )
{
v6 = v61;
break;
}
}
}
IoReportHalResourceUsage(HalNamea, v4, v6, (unsigned int)ResourceListSize);
ExFreePoolWithTag(v4, 0);
ExFreePoolWithTag(v6, 0);
}Referenced by:
HalReportResourceUsage