[NTOSKRNL:CC] Bug Fix
This commit is contained in:
parent
5a5ebcae89
commit
785ff4b644
@ -10,39 +10,51 @@
|
|||||||
#include <ntoskrnl.hpp>
|
#include <ntoskrnl.hpp>
|
||||||
|
|
||||||
|
|
||||||
BOOL
|
BOOLEAN NTAPI IsGoToNextMap(IN PSHARED_CACHE_MAP SharedMap, IN ULONG TargetPages)
|
||||||
NTAPI
|
|
||||||
IsGoToNextMap(IN PSHARED_CACHE_MAP SharedMap, IN ULONG TargetPages)
|
|
||||||
{
|
{
|
||||||
BOOLEAN Skip = FALSE;
|
BOOLEAN Skip = FALSE;
|
||||||
|
|
||||||
if (SharedMap->Flags & (0x20 | 0x800))
|
// If the map is marked for teardown or modified without writing, return TRUE
|
||||||
|
if (SharedMap->Flags & (SHARE_FL_WAITING_TEARDOWN | SHARE_FL_MODIFIED_NO_WRITE)) {
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
if ((SharedMap->OpenCount || SharedMap->DirtyPages) && SharedMap->FileSize.QuadPart)
|
// Determine if we should skip based on open count and dirty pages
|
||||||
{
|
if ((SharedMap->OpenCount || SharedMap->DirtyPages) && SharedMap->FileSize.QuadPart != 0) {
|
||||||
Skip = TRUE;
|
Skip = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!SharedMap->DirtyPages && Skip)
|
// Skip if no dirty pages but `Skip` is `TRUE`
|
||||||
|
if (!SharedMap->DirtyPages && Skip) {
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
if (SharedMap->Flags & SHARE_FL_WAITING_TEARDOWN)
|
// If the map is waiting for teardown, return FALSE
|
||||||
|
if (SharedMap->Flags & SHARE_FL_WAITING_TEARDOWN) {
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
if (!TargetPages && Skip)
|
// Skip if no target pages and `Skip` is `TRUE`
|
||||||
|
if (TargetPages == 0 && Skip) {
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Increment the lazy write pass count
|
||||||
SharedMap->LazyWritePassCount++;
|
SharedMap->LazyWritePassCount++;
|
||||||
|
|
||||||
if ((SharedMap->LazyWritePassCount & 0xF) && (SharedMap->Flags & SHARE_FL_MODIFIED_NO_WRITE) &&
|
// Skip based on lazy write pass count and other conditions
|
||||||
CcCapturedSystemSize != MmSmallSystem && SharedMap->DirtyPages < 0x40 && Skip)
|
if ((SharedMap->LazyWritePassCount & 0xF) &&
|
||||||
|
(SharedMap->Flags & SHARE_FL_MODIFIED_NO_WRITE) &&
|
||||||
|
CcCapturedSystemSize != MmSmallSystem &&
|
||||||
|
SharedMap->DirtyPages < 0x40 && Skip)
|
||||||
{
|
{
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((SharedMap->FileObject->Flags & 0x8000) && SharedMap->OpenCount &&
|
// Skip if file object is marked for direct I/O and other conditions
|
||||||
CcCanIWrite(SharedMap->FileObject, 0x40000, 0, 0xFF) && Skip)
|
if ((SharedMap->FileObject->Flags & FO_DIRECT_IO) &&
|
||||||
|
SharedMap->OpenCount != 0 &&
|
||||||
|
CcCanIWrite(SharedMap->FileObject, 0x40000, FALSE, 0xFF) && Skip)
|
||||||
{
|
{
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user