** WIP ** [NTFS] Investigate why OpenHandleCount underflows to negative values...

This commit is contained in:
Hermès Bélusca-Maïto 2024-02-22 20:32:05 +01:00
parent 945e2bda94
commit 66edbfa4f4
No known key found for this signature in database
GPG key ID: 3B2539C65E7B93D0
4 changed files with 16 additions and 1 deletions

View file

@ -52,8 +52,12 @@ NtfsCleanupFile(PDEVICE_EXTENSION DeviceExt,
if (!Fcb) if (!Fcb)
return STATUS_SUCCESS; return STATUS_SUCCESS;
DPRINT1("DeviceExt->OpenHandleCount = 0x%lx\n", DeviceExt->OpenHandleCount);
DPRINT1("Fcb->OpenHandleCount = 0x%lx\n", Fcb->OpenHandleCount);
if (Fcb->Flags & FCB_IS_VOLUME) if (Fcb->Flags & FCB_IS_VOLUME)
{ {
ASSERT(Fcb->OpenHandleCount > 0);
Fcb->OpenHandleCount--; Fcb->OpenHandleCount--;
if (Fcb->OpenHandleCount != 0) if (Fcb->OpenHandleCount != 0)
@ -68,6 +72,7 @@ NtfsCleanupFile(PDEVICE_EXTENSION DeviceExt,
return STATUS_PENDING; return STATUS_PENDING;
} }
ASSERT(Fcb->OpenHandleCount > 0);
Fcb->OpenHandleCount--; Fcb->OpenHandleCount--;
CcUninitializeCacheMap(FileObject, &Fcb->RFCB.FileSize, NULL); CcUninitializeCacheMap(FileObject, &Fcb->RFCB.FileSize, NULL);

View file

@ -59,12 +59,17 @@ NtfsCloseFile(PDEVICE_EXTENSION DeviceExt,
FileObject->FsContext2 = NULL; FileObject->FsContext2 = NULL;
FileObject->FsContext = NULL; FileObject->FsContext = NULL;
FileObject->SectionObjectPointer = NULL; FileObject->SectionObjectPointer = NULL;
DPRINT1("DeviceExt->OpenHandleCount = 0x%lx\n", DeviceExt->OpenHandleCount);
DPRINT1("Fcb->OpenHandleCount = 0x%lx\n", Fcb->OpenHandleCount);
ASSERT(DeviceExt->OpenHandleCount > 0);
DeviceExt->OpenHandleCount--; DeviceExt->OpenHandleCount--;
if (FileObject->FileName.Buffer) if (FileObject->FileName.Buffer)
{ {
// This a FO, that was created outside from FSD. // This a FO, that was created outside from FSD.
// Some FO's are created with IoCreateStreamFileObject() insid from FSD. // Some FO's are created with IoCreateStreamFileObject() inside from FSD.
// This FO's don't have a FileName. // This FO's don't have a FileName.
NtfsReleaseFCB(DeviceExt, Fcb); NtfsReleaseFCB(DeviceExt, Fcb);
} }

View file

@ -606,6 +606,9 @@ NtfsCreateFile(PDEVICE_OBJECT DeviceObject,
{ {
Fcb->OpenHandleCount++; Fcb->OpenHandleCount++;
DeviceExt->OpenHandleCount++; DeviceExt->OpenHandleCount++;
DPRINT1("DeviceExt->OpenHandleCount = 0x%lx\n", DeviceExt->OpenHandleCount);
DPRINT1("Fcb->OpenHandleCount = 0x%lx\n", Fcb->OpenHandleCount);
} }
/* /*

View file

@ -876,6 +876,8 @@ LockOrUnlockVolume(PDEVICE_EXTENSION DeviceExt,
} }
/* Deny locking if we're not alone */ /* Deny locking if we're not alone */
DPRINT1("DeviceExt->OpenHandleCount = 0x%lx\n", DeviceExt->OpenHandleCount);
DPRINT1("Fcb->OpenHandleCount = 0x%lx\n", Fcb->OpenHandleCount);
if (Lock && DeviceExt->OpenHandleCount != 1) if (Lock && DeviceExt->OpenHandleCount != 1)
{ {
return STATUS_ACCESS_DENIED; return STATUS_ACCESS_DENIED;