MiInvalidatePageFileBitmapsCache
VOID __stdcall MiInvalidatePageFileBitmapsCache(
_MMPAGING_FILE *PagingFile,
UINT64 StartIndex,
UINT64 Length,
_MI_PAGEFILE_BITMAPS_CACHE_ENTRY *CacheEntry){
BOOL v5;
int v6;
unsigned int StartingIndex;
unsigned int v9;
_MI_PAGEFILE_BITMAPS_CACHE_ENTRY *v10;
_RTL_BALANCED_NODE *p_BitmapsCacheFreeList;
_RTL_BALANCED_NODE *v12;
_RTL_RB_TREE *v13;
unsigned __int64 v14;
int v15;
unsigned int v16;
_RTL_BALANCED_NODE *v17;
unsigned int v18;
unsigned int v19;
int v20;
unsigned int v21;
unsigned int v22;
_LIST_ENTRY *v23;
_LIST_ENTRY *Flink;
_LIST_ENTRY *v25;
_RTL_RB_TREE *p_BitmapsCacheLengthTree;
UINT64 Root;
BOOL v28;
UINT64 v29;
_RTL_RB_TREE *p_BitmapsCacheLocationTree;
UINT64 v31;
UINT64 v32;
unsigned int MaximumRunLengthInBitmaps;
v5 = 0;
v6 = Length;
if( CacheEntry )
{
LABEL_2:
StartingIndex = CacheEntry->StartingIndex;
if( StartingIndex == (_DWORD)StartIndex
|| (v18 = StartIndex + v6, v19 = StartingIndex + CacheEntry->Length, (_DWORD)StartIndex + v6 == v19) )
{
v9 = CacheEntry->Length - v6;
CacheEntry->Length = v9;
if( StartingIndex == (_DWORD)StartIndex )
CacheEntry->StartingIndex = StartingIndex + v6;
v10 = CacheEntry;
if( !v9 )
{
RtlRbRemoveNode((UINT64 *)&PagingFile->BitmapsCacheLengthTree, (UINT64)CacheEntry);
RtlRbRemoveNode((UINT64 *)&PagingFile->BitmapsCacheLocationTree, (UINT64)&CacheEntry->LocationTreeNode);
p_BitmapsCacheFreeList = (_RTL_BALANCED_NODE *)&PagingFile->BitmapsCacheFreeList;
v12 = p_BitmapsCacheFreeList->Children[1];
if( v12->Children[0] == p_BitmapsCacheFreeList )
{
CacheEntry->LengthTreeNode.Children[0] = p_BitmapsCacheFreeList;
CacheEntry->LengthTreeNode.Children[1] = v12;
v12->Children[0] = &CacheEntry->LengthTreeNode;
p_BitmapsCacheFreeList->Children[1] = &CacheEntry->LengthTreeNode;
return;
}
goto LABEL_72;
}
}
else
{
v20 = v19 - StartIndex;
v21 = StartIndex - StartingIndex;
v22 = v20 - v6;
v23 = &PagingFile->BitmapsCacheFreeList;
Flink = PagingFile->BitmapsCacheFreeList.Flink;
if( Flink != &PagingFile->BitmapsCacheFreeList )
{
if( Flink->Blink == v23 )
{
v25 = Flink->Flink;
if( Flink->Flink->Blink == Flink )
{
v23->Flink = v25;
v25->Blink = v23;
HIDWORD(Flink[3].Flink) = v22;
LODWORD(Flink[3].Flink) = v18;
CacheEntry->Length = v21;
MiBitmapsCachedEntryLengthChanged(PagingFile, CacheEntry, 0i64);
p_BitmapsCacheLengthTree = &PagingFile->BitmapsCacheLengthTree;
Root = (UINT64)PagingFile->BitmapsCacheLengthTree.Root;
if( (PagingFile->BitmapsCacheLengthTree._bf_0 & 1) != 0 )
{
if( Root )
Root ^= (unsigned __int64)p_BitmapsCacheLengthTree;
else
Root = 0i64;
}
v28 = 0;
if( Root )
{
while( 1 )
{
if( Flink[3].Flink < (_LIST_ENTRY *)*(_QWORD *)(Root + 48) )
{
v29 = *(_QWORD *)Root;
if( (PagingFile->BitmapsCacheLengthTree._bf_0 & 1) != 0 )
{
if( !v29 )
goto LABEL_61;
v29 ^= Root;
}
if( !v29 )
{
LABEL_61:
v28 = 0;
break;
}
}
else
{
v29 = *(_QWORD *)(Root + 8);
if( (PagingFile->BitmapsCacheLengthTree._bf_0 & 1) != 0 )
{
if( !v29 )
goto LABEL_60;
v29 ^= Root;
}
if( !v29 )
{
LABEL_60:
v28 = 1;
break;
}
}
Root = v29;
}
}
RtlRbInsertNodeEx((UINT64 *)p_BitmapsCacheLengthTree, Root, v28, (UINT64)Flink);
p_BitmapsCacheLocationTree = &PagingFile->BitmapsCacheLocationTree;
v31 = (UINT64)PagingFile->BitmapsCacheLocationTree.Root;
if( (PagingFile->BitmapsCacheLocationTree._bf_0 & 1) != 0 )
{
if( v31 )
v31 ^= (unsigned __int64)p_BitmapsCacheLocationTree;
else
v31 = 0i64;
}
if( v31 )
{
while( 1 )
{
if( LODWORD(Flink[3].Flink) < *(_DWORD *)(v31 + 24) )
{
v32 = *(_QWORD *)v31;
if( (PagingFile->BitmapsCacheLocationTree._bf_0 & 1) != 0 )
{
if( !v32 )
break;
v32 ^= v31;
}
if( !v32 )
break;
}
else
{
v32 = *(_QWORD *)(v31 + 8);
if( (PagingFile->BitmapsCacheLocationTree._bf_0 & 1) != 0 )
{
if( !v32 )
goto LABEL_56;
v32 ^= v31;
}
if( !v32 )
{
LABEL_56:
v5 = 1;
break;
}
}
v31 = v32;
}
}
RtlRbInsertNodeEx((UINT64 *)p_BitmapsCacheLocationTree, v31, v5, (UINT64)&Flink[1].Blink);
return;
}
}
LABEL_72:
__fastfail(3u);
}
if( v21 <= v22 )
{
CacheEntry->StartingIndex = v18;
CacheEntry->Length = v22;
MaximumRunLengthInBitmaps = PagingFile->MaximumRunLengthInBitmaps;
if( MaximumRunLengthInBitmaps <= v21 )
MaximumRunLengthInBitmaps = v21;
}
else
{
CacheEntry->Length = v21;
MaximumRunLengthInBitmaps = PagingFile->MaximumRunLengthInBitmaps;
if( MaximumRunLengthInBitmaps <= v22 )
MaximumRunLengthInBitmaps = v22;
}
PagingFile->MaximumRunLengthInBitmaps = MaximumRunLengthInBitmaps;
v10 = CacheEntry;
}
MiBitmapsCachedEntryLengthChanged(PagingFile, v10, 0i64);
return;
}
v13 = &PagingFile->BitmapsCacheLocationTree;
v14 = (unsigned __int64)v13->Root;
if( (v13->_bf_0 & 1) != 0 )
{
if( v14 )
v14 ^= (unsigned __int64)v13;
else
v14 = 0i64;
}
v15 = v13->_bf_0 & 1;
while( v14 )
{
v16 = *(_DWORD *)(v14 + 24);
if( (int)StartIndex + v6 > v16 )
{
if( (unsigned int)StartIndex < *(_DWORD *)(v14 + 28) + v16 )
{
CacheEntry = (_MI_PAGEFILE_BITMAPS_CACHE_ENTRY *)(v14 - 24);
goto LABEL_2;
}
v17 = *(_RTL_BALANCED_NODE **)(v14 + 8);
}
else
{
v17 = *(_RTL_BALANCED_NODE **)v14;
}
if( v15 && v17 )
v14 ^= (unsigned __int64)v17;
else
v14 = (unsigned __int64)v17;
}
}Referenced by:
MiAttemptPageFileReductionApc
MiFindFreePageFileSpace
MiGatherPagefilePages