MiCreateSectionCommon
NTSTATUS __fastcall MiCreateSectionCommon(
UINT64 a1,
UINT64 a2,
OBJECT_ATTRIBUTES *a3,
UINT64 *a4,
LARGE_INTEGER *InputMaximumSize,
UINT64 a6,
PVOID FileHandle,
PVOID Address,
ULONGLONG ullMultiplicand){
struct _DMA_ADAPTER *ProcessToken;
int v10;
BOOL v11;
CHAR PreviousMode;
NTSTATUS result;
INT64 v14;
int v15;
NTSTATUS v16;
NTSTATUS v17;
PADAPTER_OBJECT v18;
_CONTROL_AREA *v19;
__int64 v20;
_FILE_OBJECT *v21;
int v22;
UINT64 SectionPageProtection;
UINT64 AllocationAttributes;
UINT64 SessionId;
INT64 v26;
UINT64 Flags;
PADAPTER_OBJECT DmaAdapter;
PVOID Handle;
INT64 v30[10];
_QWORD *v31;
unsigned int DesiredAccess;
UINT8 a6a;
DesiredAccess = a2;
v31 = (_QWORD *)a1;
ProcessToken = 0i64;
DmaAdapter = 0i64;
Handle = 0i64;
*(_OWORD *)v30 = 0i64;
Flags = 0i64;
v10 = a6;
if( (a6 & 0x3000000) == 50331648 )
return -1073741580;
v11 = (a6 & 0x2100000) != 0 && (a6 & 0x1100000) != 17825792;
if( (a6 & 0x2083FFFF) != 0 || (a6 & 0xF100000) == 0 )
return -1073741580;
if( (a6 & 0x3100000) != 0 )
{
v22 = -872153088;
if( (a6 & 0x2100000) == 0 )
v22 = -867958784;
if( (v22 & (unsigned int)a6) != 0 )
return -1073741580;
}
if( (a6 & 0xC000000) == 201326592 || (a6 & 0x80080000) == -2146959360 )
return -1073741580;
if( ((unsigned __int16)InputMaximumSize & 0x701) != 0 )
return -1073741755;
PreviousMode = *((_BYTE *)KeGetCurrentThread() + 562);
if( !PreviousMode )
{
if( a4 )
Flags = *a4;
goto LABEL_18;
}
if( v11 )
return -1073741580;
if( a1 >= 0x7FFFFFFF0000i64 )
a1 = 0x7FFFFFFF0000i64;
*(_QWORD *)a1 = *(_QWORD *)a1;
if( a4 )
{
if( ((unsigned __int8)a4 & 3) != 0 )
ExRaiseDatatypeMisalignment();
Flags = *a4;
}
LABEL_18:
result = MiCaptureSectionCreateExtendedParameters(Address, (unsigned int)ullMultiplicand);
if( result >= 0 )
{
v14 = *((_QWORD *)KeGetCurrentThread() + 23);
if( PreviousMode == 1 )
{
a6a = *(_BYTE *)(v14 + 2169);
ProcessToken = (struct _DMA_ADAPTER *)PsReferencePrimaryToken((PEPROCESS)v14);
}
else
{
a6a = 0;
}
v15 = MmGetSessionIdEx(v14);
while( 1 )
{
LODWORD(SessionId) = v15;
LODWORD(AllocationAttributes) = 0;
LODWORD(SectionPageProtection) = v10;
MiCreateSection(
(VOID **)&DmaAdapter,
a3,
Flags,
(_LARGE_INTEGER *)(unsigned int)InputMaximumSize,
SectionPageProtection,
AllocationAttributes,
ProcessToken,
a6a,
FileHandle,
0i64,
PreviousMode,
SessionId,
(INT64)v30,
v26,
Flags,
(INT64)DmaAdapter,
(INT64)Handle,
v30[0],
v30[1],
v30[2],
v30[3],
v30[4],
v30[5],
v30[6]);
v17 = v16;
if( v16 != -1073741740 )
break;
KeDelayExecutionThread(0, 0, (PLARGE_INTEGER)MiHalfSecond);
}
if( ProcessToken )
HalPutDmaAdapter(ProcessToken);
if( v17 < 0 )
{
return v17;
}
else
{
v18 = DmaAdapter;
v19 = MiSectionControlArea((_SECTION *)DmaAdapter);
v20 = (__int64)v19;
if( v19 && *((_QWORD *)v19 + 8) )
{
v21 = MiReferenceControlAreaFile(v19);
CcZeroEndOfLastPage(v21);
MiDereferenceControlAreaFile(v20, (unsigned __int64)v21);
}
LODWORD(SectionPageProtection) = 0;
result = ObInsertObjectEx(v18, 0i64, DesiredAccess, 0i64, SectionPageProtection, 0i64, &Handle);
if( result >= 0 )
*v31 = Handle;
}
}
return result;
}Referenced by:
NtCreateSection
NtCreateSectionEx