HalpAllocateDomainCommonBufferInternal
NTSTATUS __stdcall HalpAllocateDomainCommonBufferInternal(
INT64 BugCheckParameter3,
_LARGE_INTEGER *a2,
_LARGE_INTEGER *a3,
UINT64 a4,
INT8 a5,
INT64 a6,
UINT64 PreferredNode,
INT64 a8,
INT64 a9){
VOID *v9;
INT64 v10;
unsigned int v11;
int v15;
__int64 v16;
LONGLONG QuadPart;
unsigned __int64 v18;
int v19;
__int64 v20;
INT64 v21;
VOID *ContiguousNodeMemory;
UINT64 v23;
INT64 v24;
UINT64 v25;
int v26;
VOID **PoolWithTag;
UINT64 v28;
unsigned __int64 v29;
UINT64 v30;
BOOL v31;
UINT64 v32;
unsigned int v34;
UINT64 Protect;
UINT64 v36;
char v37;
INT64 v38;
PVOID P;
INT64 v40;
__int64 v41[2];
P = 0i64;
v9 = 0i64;
v10 = 0i64;
v37 = 0;
v38 = 0i64;
v11 = a4;
v15 = HalpDmaReferenceDomainObject(BugCheckParameter3, (UINT64)a2, (INT64 *)a3, a4);
if( v15 < 0 )
return v15;
v16 = *(_QWORD *)(BugCheckParameter3 + 72);
if( v16 )
*(_BYTE *)(v16 + 516) = 1;
QuadPart = 0i64;
if( a2 )
QuadPart = a2->QuadPart;
v18 = *(_QWORD *)(BugCheckParameter3 + 16);
if( a3 && v18 > a3->QuadPart )
v18 = a3->QuadPart;
if( a6 )
{
if( *(_DWORD *)a6 == 1 )
{
v19 = 4;
goto LABEL_10;
}
if( *(_DWORD *)a6 )
{
v15 = -1073741811;
goto LABEL_54;
}
}
else
{
v19 = 4;
if( *(_BYTE *)(BugCheckParameter3 + 32) )
goto LABEL_10;
}
v19 = 516;
LABEL_10:
v20 = *(_QWORD *)(BugCheckParameter3 + 24);
if( (a5 & 1) != 0 )
{
v34 = 1;
v11 = (v11 + 0x1FFFFF) & 0xFFE00000;
do
{
if( 1i64 << v34 >= (unsigned __int64)v11 )
break;
++v34;
}
while( v34 < 0x3F );
v20 = 1i64 << v34;
}
LODWORD(v36) = PreferredNode;
LODWORD(Protect) = v19;
v21 = v11;
ContiguousNodeMemory = MmAllocateContiguousNodeMemory(
v11,
(_LARGE_INTEGER)QuadPart,
(_LARGE_INTEGER)v18,
(_LARGE_INTEGER)v20,
Protect,
v36);
v9 = ContiguousNodeMemory;
if( ContiguousNodeMemory )
{
LODWORD(v23) = MmGetPhysicalAddress((UINT64)ContiguousNodeMemory);
v25 = v23;
v26 = *(_DWORD *)(BugCheckParameter3 + 64);
if( v26 == 2 )
{
v41[0] = QuadPart;
v40 = v18;
v15 = HalpDomainLaAllocate(
BugCheckParameter3,
(PDUMPWRITER_FILL_HEADERS *)v21,
v24,
(UINT64 *)v41,
(INT64)&v40,
(INT64)&v38);
if( v15 < 0 )
goto LABEL_54;
v10 = v38;
v37 = 1;
v15 = HalpIommuDomainMapLogicalRange(*(_QWORD *)(BugCheckParameter3 + 40), 3i64, v25, v21, v38);
if( v15 < 0 )
{
LABEL_53:
HalpDomainLaDelete(BugCheckParameter3, v10);
goto LABEL_54;
}
}
else
{
if( v26 == 3 )
{
v15 = HalpIommuDomainMapLogicalRange(*(_QWORD *)(BugCheckParameter3 + 40), 3i64, v25, v21, v25);
if( v15 < 0 )
goto LABEL_54;
}
v38 = v25;
v10 = v25;
}
PoolWithTag = ExAllocatePoolWithTag(0x200ui64, 0x28ui64, 543973704i64);
P = PoolWithTag;
v28 = (UINT64)PoolWithTag;
if( !PoolWithTag )
{
v15 = -1073741670;
goto LABEL_52;
}
PoolWithTag[3] = v9;
PoolWithTag[4] = (VOID *)BugCheckParameter3;
v29 = (unsigned __int8)KeAcquireSpinLockRaiseToDpc((UINT64 *)(BugCheckParameter3 + 96));
v30 = *(_QWORD *)(BugCheckParameter3 + 80);
if( (*(_BYTE *)(BugCheckParameter3 + 88) & 1) != 0 && v30 )
v30 ^= BugCheckParameter3 + 80;
v31 = 0;
if( v30 )
{
while( 1 )
{
if( *(_QWORD *)(v30 + 24) > (unsigned __int64)v9 )
{
v32 = *(_QWORD *)v30;
if( (*(_BYTE *)(BugCheckParameter3 + 88) & 1) != 0 )
{
if( !v32 )
break;
v32 ^= v30;
}
if( !v32 )
break;
}
else
{
v32 = *(_QWORD *)(v30 + 8);
if( (*(_BYTE *)(BugCheckParameter3 + 88) & 1) != 0 )
{
if( !v32 )
goto LABEL_25;
v32 ^= v30;
}
if( !v32 )
{
LABEL_25:
v31 = 1;
break;
}
}
v30 = v32;
}
}
RtlRbInsertNodeEx((UINT64 *)(BugCheckParameter3 + 80), v30, v31, v28);
KxReleaseSpinLock((UINT64 *)(BugCheckParameter3 + 96));
__writecr8(v29);
*(_QWORD *)a8 = v10;
*(_QWORD *)a9 = v9;
}
else
{
v15 = -1073741670;
}
if( v15 >= 0 )
return v15;
LABEL_52:
if( v37 )
goto LABEL_53;
LABEL_54:
HalpDmaDereferenceDomainObject((PVOID)BugCheckParameter3);
if( v9 )
MmFreeContiguousMemory(v9);
if( P )
ExFreePoolWithTag(P, 0);
return v15;
}Referenced by:
HalAllocateCommonBufferExV3
HalAllocateCommonBufferWithBounds
HalAllocateDomainCommonBuffer