CcPerformReadAhead
VOID __stdcall CcPerformReadAhead(_WORK_QUEUE_ENTRY *WorkQueueEntry, _FILE_OBJECT *FileObject){
_FILE_OBJECT *v2;
__int64 v3;
unsigned __int8 v4;
_LARGE_INTEGER v5;
unsigned int v6;
__int64 PrivateCacheMap;
_BOOL8 v8;
VOID *v9;
signed __int64 v10;
unsigned int v11;
unsigned int v12;
_WORK_QUEUE_ENTRY *v13;
int v14;
_ETHREAD *v15;
unsigned int PagePriorityThread;
unsigned __int64 *v17;
__int64 v18;
VOID *v19;
_SHARED_CACHE_MAP *v20;
UINT64 v21;
UINT8 v22;
UINT64 v23;
unsigned int v24;
UINT64 PagePriority;
int v26;
int v27;
int v28;
_KLOCK_QUEUE_HANDLE LockHandle;
_BOOL4 v31;
int v32;
unsigned int v33;
unsigned int v34;
UINT64 Length;
_LARGE_INTEGER SectionOffset;
_SINGLE_LIST_ENTRY *OpaqueWaitBlock;
unsigned __int64 *Partition;
__int64 v39;
_SHARED_CACHE_MAP *SharedCacheMap;
unsigned int v41;
__int64 FaultedData[2];
unsigned int v43;
_FILE_OBJECT *FileObjecta;
__int64 v45;
__int64 v46;
_LARGE_INTEGER FileOffset;
_FILE_OBJECT *v48;
_WORK_QUEUE_ENTRY *v49;
_ETHREAD *v50;
_ETHREAD *CurrentThread;
_QWORD v52[2];
_QWORD v53[2];
_QWORD v54[2];
unsigned int v55;
int v56;
__int64 v57;
_QWORD v58[2];
unsigned int v59;
int v60;
__int64 v61;
v2 = FileObject;
FileObjecta = FileObject;
v49 = WorkQueueEntry;
v48 = FileObject;
SharedCacheMap = 0i64;
SectionOffset.QuadPart = 0i64;
FileOffset.QuadPart = 0i64;
LODWORD(Length) = 0;
v24 = 0;
v45 = 0i64;
v46 = 0i64;
v31 = 0;
PagePriority = 0i64;
v27 = 0;
v28 = 0;
OpaqueWaitBlock = 0i64;
v32 = 0;
v33 = 0;
Partition = 0i64;
memset(&LockHandle, 0, sizeof(LockHandle));
CurrentThread = (_ETHREAD *)KeGetCurrentThread();
CurrentThread->CacheManagerCount = 0;
SharedCacheMap = (_SHARED_CACHE_MAP *)FileObject->SectionObjectPointer->SharedCacheMap;
v45 = *((_QWORD *)SharedCacheMap + 26);
v46 = *((_QWORD *)SharedCacheMap + 27);
Partition = (unsigned __int64 *)CcGetPartition(SharedCacheMap);
LOBYTE(v3) = 1;
v4 = (*(__int64(__fastcall **)(__int64, __int64))(v45 + 16))(v46, v3);
v26 = v4;
if( v4 )
{
while( 1 )
{
OpaqueWaitBlock = 0i64;
v5 = SectionOffset;
v6 = v24;
while( 1 )
{
KeAcquireInStackQueuedSpinLock(Partition + 16, &LockHandle);
PrivateCacheMap = (__int64)v2->PrivateCacheMap;
v39 = PrivateCacheMap;
if( PrivateCacheMap )
{
KxAcquireSpinLock((UINT64 *)(PrivateCacheMap + 80));
v6 = *(_DWORD *)(PrivateCacheMap + 52);
v8 = v6 == 0;
v31 = v6 == 0;
v5 = *(_LARGE_INTEGER *)(PrivateCacheMap + 56);
SectionOffset = v5;
if( v6 > 0x800000 )
v6 = 0x800000;
v24 = v6;
*(_DWORD *)(PrivateCacheMap + 52) = 0;
if( !v8 )
*(_QWORD *)(PrivateCacheMap + 64) = v5.QuadPart + v6;
if( (*(_DWORD *)PrivateCacheMap & 0x200000) != 0 )
{
v32 = 1;
v33 = *(_DWORD *)(PrivateCacheMap + 88);
}
KxReleaseSpinLock((UINT64 *)(PrivateCacheMap + 80));
LODWORD(PagePriority) = (*(_DWORD *)PrivateCacheMap >> 18) & 7;
}
KeReleaseInStackQueuedSpinLockFromDpcLevel(&LockHandle);
__writecr8(LockHandle.OldIrql);
if( !PrivateCacheMap || v31 )
break;
v10 = *((_QWORD *)SharedCacheMap + 1);
if( v5.QuadPart < v10 )
{
v28 = 1;
if( v5.QuadPart + v6 >= v10 )
{
v6 = v10 - v5.anonymous_0.LowPart;
v27 = 1;
}
v6 = (v6 + 4095) & 0xFFFFF000;
v24 = v6;
v11 = v6;
v41 = v6;
FileOffset = v5;
LODWORD(Length) = v6;
if( v32 )
{
if( !v33 )
KeBugCheckEx(0x34u, (PVOID)0xA2E, (PVOID)0xFFFFFFFFC0000420i64, 0i64, 0i64);
v12 = v6;
if( v6 > v33 )
v12 = v33;
v34 = v12;
}
else
{
v12 = v6;
v34 = v6;
}
v13 = WorkQueueEntry;
if( (xmmword_140CFB490 & 0x20000) != 0 )
{
v54[1] = v5.QuadPart;
v55 = v6;
v54[0] = WorkQueueEntry;
v56 = PagePriority;
v57 = 0i64;
v52[0] = v54;
v52[1] = 32i64;
EtwTraceKernelEvent((__int64)v52, 1u, 0x80020000, 0x1603u, 0x401902u);
}
while( v11 )
{
if( v12 > v11 )
v12 = v11;
v34 = v12;
if( (xmmword_140CFB490 & 0x20000) != 0 )
{
v61 = 0i64;
v58[1] = v5.QuadPart;
v59 = v12;
v58[0] = v13;
v60 = PagePriority;
v53[0] = v58;
v53[1] = 32i64;
EtwTraceKernelEvent((__int64)v53, 1u, 0x80020000, 0x160Bu, 0x401902u);
}
v23 = *((_QWORD *)WorkQueueEntry + 3);
MmPrefetchForCacheManager(FileObjecta, v5, v9, v12);
HIDWORD(PagePriority) |= v14;
v11 -= v12;
v41 = v11;
v5.QuadPart += v12;
SectionOffset = v5;
v13 = WorkQueueEntry;
}
v2 = FileObjecta;
}
}
if( !OpaqueWaitBlock )
break;
v15 = (_ETHREAD *)KeGetCurrentThread();
v50 = v15;
PagePriorityThread = PsGetPagePriorityThread(v15);
v43 = PagePriorityThread;
LODWORD(FaultedData[0]) = 0;
MmWaitForCacheManagerPrefetch(OpaqueWaitBlock);
PsSetPagePriorityThread(v15, (unsigned int)PagePriority);
LODWORD(v23) = PagePriority;
CcMapAndCopyFromCache(
v2,
FileOffset,
(unsigned int)Length,
1u,
0i64,
(UINT64 *)FaultedData,
v23,
*((VOID **)WorkQueueEntry + 3));
PsSetPagePriorityThread(v15, PagePriorityThread);
}
}
__addgsdword(0x8164u, KeGetCurrentThread()[1].Timer.DueTime.HighPart);
if( v26 )
(*(void(__fastcall **)(__int64))(v45 + 24))(v46);
v17 = Partition;
KeAcquireInStackQueuedSpinLock(Partition + 16, &LockHandle);
v18 = (__int64)v2->PrivateCacheMap;
v39 = v18;
if( v18 )
{
KxAcquireSpinLock((UINT64 *)(v18 + 80));
*(_DWORD *)v18 &= ~0x10000u;
if( v27 && (v2->Flags & 0x20) != 0 )
*(_QWORD *)(v18 + 64) = 0i64;
if( !HIDWORD(PagePriority) && v28 )
*(_DWORD *)v18 &= ~0x20000u;
KxReleaseSpinLock((UINT64 *)(v18 + 80));
}
KeReleaseInStackQueuedSpinLockFromDpcLevel(&LockHandle);
__writecr8(LockHandle.OldIrql);
ObfDereferenceObjectWithTag(v2, 0x746C6644ui64);
v19 = (VOID *)*((_QWORD *)WorkQueueEntry + 3);
if( v19 )
IoDiskIoAttributionDereference(v19);
KeAcquireInStackQueuedSpinLock(v17 + 16, &LockHandle);
v20 = SharedCacheMap;
CcDecrementOpenCount(SharedCacheMap, v21, v22);
*((_DWORD *)v20 + 38) &= ~0x4000u;
KeReleaseInStackQueuedSpinLockFromDpcLevel(&LockHandle);
__writecr8(LockHandle.OldIrql);
}Referenced by:
CcWorkerThread