MiCombineIdenticalPages
NTSTATUS __stdcall MiCombineIdenticalPages(
_MI_PARTITION *Partition,
PVOID StopHandle,
UINT64 CombineFlags,
INT8 PreviousMode,
UINT64 *OutputPagesCombined){
int v6;
__int64 v7;
struct _DMA_ADAPTER *v8;
struct _DMA_ADAPTER *v9;
__int64 v10;
NTSTATUS v11;
NTSTATUS v12;
_ETHREAD *CurrentThread;
INT64 v14;
unsigned int NextPageColor;
INT16 v16;
NTSTATUS v17;
NTSTATUS v19;
PVOID Object;
PVOID v21;
int v22[2];
_MI_PARTITION *v23;
_QWORD *v24;
__int64 v25[2];
__int128 v26;
__int64 result[10];
INT64 a1[4];
struct _DMA_ADAPTER *v29;
__int64 *v30;
int *v31;
int v32;
int v33;
INT64 v34[16];
__int128 v35;
__int128 v36;
_KAPC_STATE ApcState;
_QWORD *v38;
v23 = Partition;
v6 = CombineFlags;
v24 = v38;
v7 = PreviousMode;
memset((INT64)result, 0i64);
v35 = 0i64;
v36 = 0i64;
memset((INT64)a1, 0i64);
*v38 = 0i64;
v8 = 0i64;
v9 = 0i64;
memset(&ApcState, 0, sizeof(ApcState));
if( (v6 & 0xFFFFFFFC) != 0 )
return -1073741583;
v10 = -1i64;
if( (v6 & 2) != 0 )
{
if( v7 )
v10 = v7;
v7 = v10;
}
else if( v7 )
{
return -1073741811;
}
if( (dword_140CFA178 & 1) != 0 )
return -1073741637;
if( !StopHandle
|| (Object = 0i64,
v11 = ObReferenceObjectByHandle(
StopHandle,
1u,
(POBJECT_TYPE)ExEventObjectType,
(KPROCESSOR_MODE)OutputPagesCombined,
&Object,
0i64),
v9 = (struct _DMA_ADAPTER *)Object,
v12 = v11,
v11 >= 0) )
{
if( v7 )
{
v21 = 0i64;
v19 = ObReferenceObjectByHandle(
(HANDLE)v7,
0x18u,
(POBJECT_TYPE)PsProcessType,
(KPROCESSOR_MODE)OutputPagesCombined,
&v21,
0i64);
v8 = (struct _DMA_ADAPTER *)v21;
v12 = v19;
if( v19 < 0 )
{
LABEL_14:
if( v8 )
{
KiUnstackDetachProcess(&ApcState, 0i64);
HalPutDmaAdapter(v8);
}
goto LABEL_16;
}
KiStackAttachProcess((_KPROCESS *)v21, 0i64, &ApcState);
}
CurrentThread = (_ETHREAD *)KeGetCurrentThread();
v14 = (INT64)v23 + 6448;
if( (v6 & 1) == 0 || v23 == (_MI_PARTITION *)&MiSystemPartition )
{
--*((_WORD *)CurrentThread + 242);
MiCombiningInProgress((INT64 *)v14, (INT64)result, 1i64);
v22[0] = 0;
v22[1] = -1;
v25[0] = qword_140C4EAD8;
v25[1] = qword_140C4EAE0;
v30 = v25;
v31 = v22;
a1[2] = (INT64)result;
a1[3] = (INT64)&v35;
v32 = 2;
a1[0] = v14;
a1[1] = (INT64)v9;
v33 = v6;
v26 = 0i64;
MiInitializePageColorBase(*((_QWORD *)KeGetCurrentThread() + 23) + 1664i64, 0i64, (INT64)&v26);
NextPageColor = MiGetNextPageColor((INT64)&v26);
if( (unsigned int)MiCreateUltraThreadContext((INT64)v34, NextPageColor, 8i64) )
{
if( (v6 & 2) != 0 )
{
v29 = v8 + 104;
v17 = MiCombineWorkingSet((INT64)a1);
}
else
{
v29 = 0i64;
MiCombineAllPhysicalMemory((INT64)a1, v16);
}
v12 = v17;
MiDeleteUltraThreadContext((INT64)v34);
*v24 = v35;
_InterlockedIncrement((volatile signed __int32 *)(v14 + 384));
_InterlockedExchangeAdd64((volatile signed __int64 *)(v14 + 376), *((unsigned __int64 *)&v35 + 1));
_InterlockedExchangeAdd64((volatile signed __int64 *)(v14 + 360), v36);
_InterlockedExchangeAdd64((volatile signed __int64 *)(v14 + 368), *((unsigned __int64 *)&v36 + 1));
}
else
{
v12 = -1073741670;
}
MiCombiningInProgress((INT64 *)v14, (INT64)result, 0i64);
KeLeaveCriticalRegionThread((__int64)CurrentThread);
}
else
{
v12 = -1073741637;
}
goto LABEL_14;
}
LABEL_16:
if( v9 )
HalPutDmaAdapter(v9);
return v12;
}Referenced by:
MmCombineIdenticalPages
MmManagePartitionCombineMemory