PspAllocatePartition
NTSTATUS __stdcall PspAllocatePartition(
_OBJECT_ATTRIBUTES *ObjectAttributes,
UINT64 a2,
INT8 a3,
INT64 a4,
INT8 a5,
INT64 a6,
INT64 a7){
INT64 v8;
_OBJECT_ATTRIBUTES *v9;
CHAR v10;
char v11;
NTSTATUS PartitionSystemProcess;
PVOID v13;
__int64 v15;
VOID *v16;
_QWORD *v17;
PVOID v18;
signed __int64 v19;
bool v20;
signed __int64 v21;
VOID *v22;
VOID *v23;
UINT64 ObjectBodySize;
UINT64 PagedPoolCharge;
UINT64 NonPagedPoolCharge;
PVOID Object;
UINT64 DesiredAccess;
PVOID Handle;
INT64 v30;
_KAPC_STATE ApcState;
LODWORD(DesiredAccess) = a2;
v8 = a4;
LODWORD(NonPagedPoolCharge) = 0;
v9 = ObjectAttributes;
v30 = a7;
LOBYTE(ObjectAttributes) = a3;
LODWORD(PagedPoolCharge) = 0;
LOBYTE(a4) = a3;
LODWORD(ObjectBodySize) = 128;
v10 = 0;
memset(&ApcState, 0, sizeof(ApcState));
Handle = 0i64;
v11 = 0;
Object = 0i64;
PartitionSystemProcess = ObCreateObjectEx(
(UINT64)ObjectAttributes,
PsPartitionType,
v9,
a4,
v22,
ObjectBodySize,
PagedPoolCharge,
NonPagedPoolCharge,
&Object,
0i64);
if( PartitionSystemProcess < 0 )
{
v13 = Object;
goto LABEL_9;
}
v11 = 1;
v13 = Object;
memset(Object, 0i64, 0x80u);
*((_QWORD *)v13 + 3) = 2i64;
ObfReferenceObjectWithTag(v13, 0x64726148ui64);
*((_QWORD *)v13 + 4) = 1i64;
*((_QWORD *)v13 + 12) = 0i64;
if( v8 )
{
if( _InterlockedIncrement64((volatile signed __int64 *)(v8 + 24)) <= 1 )
__fastfail(0xEu);
v13 = Object;
*((_QWORD *)Object + 7) = v8;
}
else
{
if( a5 )
goto LABEL_4;
if( _InterlockedIncrement64((volatile signed __int64 *)(PspSystemPartition + 24)) <= 1 )
__fastfail(0xEu);
v13 = Object;
*((_QWORD *)Object + 7) = PspSystemPartition;
}
if( !a5 )
{
KiStackAttachProcess(PsInitialSystemProcess, 0i64, &ApcState);
PartitionSystemProcess = PspCreatePartitionSystemProcess((PVOID *)v13 + 13, (_QWORD *)v13 + 14, v15, v16);
KiUnstackDetachProcess(&ApcState, 0i64);
if( PartitionSystemProcess < 0 )
goto LABEL_9;
PartitionSystemProcess = ExpPartitionInitialize((INT64)v13);
if( PartitionSystemProcess < 0 )
goto LABEL_9;
goto LABEL_5;
}
LABEL_4:
v10 = 1;
LABEL_5:
PartitionSystemProcess = MmCreatePartition((pHalIoWritePartitionTable **)v13, v10);
if( PartitionSystemProcess < 0 )
goto LABEL_9;
PspAddPartitionToGlobalList(v13);
if( a5 )
{
*((_DWORD *)v13 + 30) |= 1u;
*(_QWORD *)a6 = v13;
v13 = 0i64;
Object = 0i64;
LABEL_8:
PartitionSystemProcess = 0;
goto LABEL_9;
}
PartitionSystemProcess = ExpPartitionStart(*((_QWORD *)v13 + 2));
if( PartitionSystemProcess >= 0 )
{
LODWORD(v23) = 0;
v11 = 0;
PartitionSystemProcess = ObInsertObjectEx(v13, 0i64, (unsigned int)DesiredAccess, 0i64, (UINT64)v23, 0i64, &Handle);
if( PartitionSystemProcess >= 0 )
{
v17 = (_QWORD *)v30;
v18 = Handle;
*(_QWORD *)a6 = v13;
*v17 = v18;
goto LABEL_8;
}
}
LABEL_9:
if( v13 )
{
if( v11 )
HalPutDmaAdapter((PADAPTER_OBJECT)v13);
v19 = _InterlockedExchangeAdd64((volatile signed __int64 *)v13 + 4, 0xFFFFFFFFFFFFFFFFui64);
v20 = v19 <= 1;
v21 = v19 - 1;
if( v20 )
{
if( v21 )
__fastfail(0xEu);
PsDereferencePartition((INT64)Object);
}
if( PartitionSystemProcess < 0 )
PsDereferencePartition((INT64)Object);
}
return PartitionSystemProcess;
}Referenced by:
NtCreatePartition
PspInitializeSystemPartitionPhase0