HalpDmaAllocateMappingResources
NTSTATUS __stdcall HalpDmaAllocateMappingResources(){
unsigned int v0;
UINT64 v1;
unsigned int v2;
__int64 v3;
_HALP_ALLOC_CONTEXT *v4;
_HALP_ALLOC_CONTEXT *v5;
UINT8 *v6;
UINT8 *v7;
UINT8 *v8;
UINT8 **v9;
UINT8 *v10;
UINT64 v11;
_HALP_ALLOC_CONTEXT *v12;
unsigned int v13;
__int64 v14;
_HALP_ALLOC_CONTEXT *v15;
char *v16;
__int64 v17;
UINT8 *v19;
__int64 v20;
__int64 v21;
PVOID *v22;
_HALP_ALLOC_CONTEXT *v23;
_HALP_ALLOC_CONTEXT *v24;
int ReservedMappingArray;
_HALP_ALLOC_CONTEXT *v26;
KeQueryMaximumProcessorCountEx(0xFFFFu);
v1 = 8i64 * v0;
v2 = v0;
v3 = v0;
qword_140C53C60 = HalpMmAllocCtxAlloc(v4, v1);
if( !qword_140C53C60 )
return -1073741670;
v6 = HalpMmAllocCtxAlloc(v5, 4144 * v3);
v8 = v6;
if( !v6 )
{
v19 = (UINT8 *)qword_140C53C60;
LABEL_14:
HalpMmAllocCtxFree((_HALP_ALLOC_CONTEXT *)v7, v19);
return -1073741670;
}
if( v2 )
{
v9 = (UINT8 **)qword_140C53C60;
v7 = v6 + 32;
do
{
*(_QWORD *)v7 = 0i64;
v10 = v7 - 32;
*((_DWORD *)v7 + 3) = 0;
*(_QWORD *)v10 = 0i64;
*((_DWORD *)v7 - 6) = 131128;
*((_DWORD *)v7 + 2) = 4096;
v7 += 4144;
*v9++ = v10;
--v3;
}
while( v3 );
}
qword_140CF2310 = 0i64;
v11 = 4i64;
if( v2 <= 4 )
{
qword_140C53C68 = HalpMmAllocCtxAlloc((_HALP_ALLOC_CONTEXT *)v7, v1);
if( qword_140C53C68 )
{
v13 = 0;
if( !v2 )
{
LABEL_12:
byte_140C53C58 = 1;
return 0;
}
v14 = 0i64;
while( 1 )
{
HalpDmaAllocateReservedMapping();
v16 = (char *)qword_140C53C68;
*(_QWORD *)((char *)qword_140C53C68 + v14) = v17;
if( !v17 )
break;
++v13;
v14 += 8i64;
if( v13 >= v2 )
goto LABEL_12;
}
if( v13 )
{
v20 = 0i64;
v21 = v13;
do
{
v22 = *(PVOID **)&v16[v20];
MmFreeMappingAddress(v22[2], 0x206C6148u);
HalpMmAllocCtxFree(v23, v22);
v16 = (char *)qword_140C53C68;
v20 += 8i64;
--v21;
}
while( v21 );
}
HalpMmAllocCtxFree(v15, v16);
v11 = v2;
goto LABEL_21;
}
HalpMmAllocCtxFree(v12, qword_140C53C60);
v19 = v8;
goto LABEL_14;
}
LABEL_21:
ReservedMappingArray = HalpDmaAllocateReservedMappingArray(v2, v11);
if( ReservedMappingArray < 0 )
{
HalpMmAllocCtxFree(v24, qword_140C53C60);
HalpMmAllocCtxFree(v26, v8);
}
return ReservedMappingArray;
}Referenced by:
HalpDmaInit