MiUnlockMdlWritePages
VOID __stdcall MiUnlockMdlWritePages(UINT64 *Page, UINT64 *LastPage, IO_STATUS_BLOCK *IoStatus){
UINT64 *v4;
unsigned int v5;
_MMPFN *PfnDb;
char *v7;
unsigned __int8 CurrentIrql;
UINT64 v9;
__int64 v10;
INT64 v11;
struct _KPRCB *CurrentPrcb;
IO_STATUS_BLOCK *v13;
unsigned __int64 v14;
__int64 Information_high;
bool v16;
signed __int32 v17;
unsigned __int64 v18;
unsigned __int64 v19;
unsigned __int64 v20;
struct _KLOCK_QUEUE_HANDLE LockHandle;
UINT64 SpinCount;
if( Page < LastPage )
{
v4 = Page;
v5 = (unsigned int)IoStatus->Status >> 31;
PfnDb = MmGetPfnDb();
do
{
v7 = (char *)PfnDb + 48 * *v4;
CurrentIrql = KeGetCurrentIrql();
__writecr8(2ui64);
LODWORD(SpinCount) = 0;
while( _interlockedbittestandset64((volatile signed __int32 *)v7 + 6, 0x3Fui64) )
{
do
KeYieldProcessorEx(&SpinCount);
while( *((__int64 *)v7 + 3) < 0 );
}
v9 = 1i64;
v10 = (*((_QWORD *)v7 + 5) >> 39) & 0x3FFi64;
memset(&LockHandle, 0, sizeof(LockHandle));
v11 = *(_QWORD *)(qword_140C4E388 + 8 * v10);
if( !*(_QWORD *)(v11 + 6264)
|| (KeAcquireInStackQueuedSpinLock((UINT64 *)(v11 + 6248), &LockHandle),
v9 = MiRestockOverCommit(v11, 1ui64),
KeReleaseInStackQueuedSpinLockFromDpcLevel(&LockHandle),
__writecr8(LockHandle.OldIrql),
v9) )
{
if( (ULONG_PTR *)v11 == &MiSystemPartition
&& (CurrentPrcb = KeGetCurrentPrcb(),
_m_prefetchw((char *)CurrentPrcb + 33560),
IoStatus = (IO_STATUS_BLOCK *)*((unsigned int *)CurrentPrcb + 8390),
(unsigned __int64)IoStatus + v9 <= 0x100) )
{
while( 1 )
{
v13 = (IO_STATUS_BLOCK *)_InterlockedCompareExchange(
(volatile signed __int32 *)CurrentPrcb + 8390,
(_DWORD)IoStatus + v9,
(signed __int32)IoStatus);
if( v13 == IoStatus )
break;
IoStatus = v13;
if( (unsigned __int64)v13 + v9 > 0x100 )
goto LABEL_14;
}
}
else
{
LABEL_14:
v18 = _InterlockedExchangeAdd64((volatile signed __int64 *)(v11 + 7464), -(__int64)v9);
v19 = *(_QWORD *)(v11 + 6240);
if( v18 >= v19 && v18 - v9 < v19 || (v20 = *(_QWORD *)(v11 + 6232), v18 >= v20) && v18 - v9 < v20 )
MiSyncCommitSignals((_MI_PARTITION *)v11, 0i64);
}
}
v14 = 1i64;
if( (ULONG_PTR *)v11 != &MiSystemPartition )
goto LABEL_22;
IoStatus = (IO_STATUS_BLOCK *)KeGetCurrentPrcb();
Information_high = SHIDWORD(IoStatus[2097].Information);
if( (_DWORD)Information_high == -1 )
goto LABEL_22;
if( (unsigned __int64)(Information_high + 1) <= 0x100 )
{
do
{
v17 = _InterlockedCompareExchange(
(volatile signed __int32 *)&IoStatus[2097].Information + 1,
Information_high + 1,
Information_high);
v16 = (_DWORD)Information_high == v17;
LODWORD(Information_high) = v17;
if( v16 )
goto LABEL_12;
}
while( v17 != -1 && (unsigned __int64)(v17 + 1i64) <= 0x100 );
}
if( (int)Information_high > 192
&& (_DWORD)Information_high != -1
&& (_DWORD)Information_high == _InterlockedCompareExchange(
(volatile signed __int32 *)&IoStatus[2097].Information + 1,
192,
Information_high) )
{
v14 = (int)Information_high - 192 + 1i64;
}
if( v14 )
LABEL_22:
_InterlockedExchangeAdd64((volatile signed __int64 *)(v11 + 7168), v14);
LABEL_12:
MiWriteCompletePfn((_MMPFN *)v7, v5, (UINT8 *)IoStatus);
_InterlockedAnd64((volatile signed __int64 *)v7 + 3, 0x7FFFFFFFFFFFFFFFui64);
__writecr8(CurrentIrql);
++v4;
PfnDb = MmGetPfnDb();
}
while( v4 < LastPage );
}
}Referenced by:
MiFlushComplete
MiUnlockFlushMdl