[NTOSKRNL:CC] Fixed Probing code

This commit is contained in:
Dibyamartanda Samanta 2024-05-24 18:05:45 +02:00
parent 2300440e3d
commit 5a5ebcae89

View File

@ -302,6 +302,8 @@ CcPrepareMdlWrite(IN PFILE_OBJECT FileObject,
ULONG ZeroOpsFlags = {0};
PVACB Vacb = nullptr;
BOOL MapFlag = false;
PKTHREAD currentThread = nullptr;
UCHAR SavedState ={0};
if ((FileObject->Flags & 0x10) == 0)
{
if (IoIsFileOriginRemote(FileObject) && !CcCanIWriteStream(FileObject, Length, 0, 0))
@ -352,14 +354,13 @@ CcPrepareMdlWrite(IN PFILE_OBJECT FileObject,
Mdl = IoAllocateMdl(VirtualAddress, ReceivedLength, FALSE, FALSE, NULL);
if (!Mdl)
RtlRaiseStatus(STATUS_INSUFFICIENT_RESOURCES );
/*Save the current state of the UserIdealProcessor field & Then Performe Probing and locking of pages*/
PKTHREAD currentThread = KeGetCurrentThread();
PULONG userIdealProcessorByte = (PULONG)((ULONG_PTR)currentThread + userIdealProcessorOffset);
ULONG savedState = *(userIdealProcessorByte + 1) + 2;
*(userIdealProcessorByte + 1) = 1;
MmProbeAndLockPages(mdl, KernelMode, IoWriteAccess);
/*Restore the saved state of the UserIdealProcessor field*/
*(userIdealProcessorByte + 1) = savedState - 2;
currentThread = KeGetCurrentThread();
SavedState = currentThread->UserIdealProcessor + 2;
currentThread->UserIdealProcessor = 1;
MmProbeAndLockPages(Mdl, KernelMode, IoWriteAccess);
currentThread->UserIdealProcessor = SavedState - 2;
SavedState
/* Update the Read Aheas Stats*/
KeAcquireInStackQueuedSpinLock(&SharedCacheMap->BcbSpinLock, &LockHandle);
if ( ReadAhead_Length.QuadPart > SharedCacheMap->ValidDataGoal.QuadPart )