Author: pschweitzer
Date: Sun Jul 10 17:14:33 2016
New Revision: 71888
URL:
http://svn.reactos.org/svn/reactos?rev=71888&view=rev
Log:
[FASTFAT][CDFS]
Call CcMapData(), CcPinRead() inside a SEH block
This allows returning more significant error codes on failure
[NTOSKRNL]
Enable Thomas code for raising exceptions
CORE-9848
Modified:
trunk/reactos/drivers/filesystems/cdfs/dirctl.c
trunk/reactos/drivers/filesystems/cdfs/fcb.c
trunk/reactos/drivers/filesystems/fastfat/create.c
trunk/reactos/drivers/filesystems/fastfat/direntry.c
trunk/reactos/drivers/filesystems/fastfat/dirwr.c
trunk/reactos/drivers/filesystems/fastfat/fat.c
trunk/reactos/drivers/filesystems/fastfat/volume.c
trunk/reactos/ntoskrnl/cc/pin.c
Modified: trunk/reactos/drivers/filesystems/cdfs/dirctl.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filesystems/cdfs/d…
==============================================================================
--- trunk/reactos/drivers/filesystems/cdfs/dirctl.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/filesystems/cdfs/dirctl.c [iso-8859-1] Sun Jul 10 17:14:33 2016
@@ -75,14 +75,16 @@
CcUnpinData(*Context);
StreamOffset->QuadPart += BLOCKSIZE;
*CurrentOffset = ROUND_UP(*CurrentOffset, BLOCKSIZE);
- if (!CcMapData(DeviceExt->StreamFileObject,
- StreamOffset,
- BLOCKSIZE, TRUE,
- Context, Block))
+ _SEH2_TRY
+ {
+ CcMapData(DeviceExt->StreamFileObject, StreamOffset, BLOCKSIZE,
TRUE, Context, Block);
+ }
+ _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
DPRINT("CcMapData() failed\n");
- return(STATUS_UNSUCCESSFUL);
+ _SEH2_YIELD(return _SEH2_GetExceptionCode());
}
+ _SEH2_END;
*Ptr = *Block;
Record = (PDIR_RECORD)*Ptr;
}
@@ -99,14 +101,16 @@
CcUnpinData(*Context);
StreamOffset->QuadPart += BLOCKSIZE;
*CurrentOffset = ROUND_UP(*CurrentOffset, BLOCKSIZE);
- if (!CcMapData(DeviceExt->StreamFileObject,
- StreamOffset,
- BLOCKSIZE, TRUE,
- Context, Block))
+ _SEH2_TRY
+ {
+ CcMapData(DeviceExt->StreamFileObject, StreamOffset, BLOCKSIZE, TRUE,
Context, Block);
+ }
+ _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
DPRINT("CcMapData() failed\n");
- return(STATUS_UNSUCCESSFUL);
- }
+ _SEH2_YIELD(return _SEH2_GetExceptionCode());
+ }
+ _SEH2_END;
*Ptr = *Block;
Record = (PDIR_RECORD)*Ptr;
}
@@ -231,12 +235,16 @@
StreamOffset.QuadPart += ROUND_DOWN(Offset, BLOCKSIZE);
}
- if (!CcMapData(DeviceExt->StreamFileObject, &StreamOffset,
- BLOCKSIZE, TRUE, &Context, &Block))
+ _SEH2_TRY
+ {
+ CcMapData(DeviceExt->StreamFileObject, &StreamOffset, BLOCKSIZE, TRUE,
&Context, &Block);
+ }
+ _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
DPRINT("CcMapData() failed\n");
- return STATUS_UNSUCCESSFUL;
- }
+ _SEH2_YIELD(return _SEH2_GetExceptionCode());
+ }
+ _SEH2_END;
Record = (PDIR_RECORD) ((ULONG_PTR)Block + Offset % BLOCKSIZE);
if (Offset)
Modified: trunk/reactos/drivers/filesystems/cdfs/fcb.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filesystems/cdfs/f…
==============================================================================
--- trunk/reactos/drivers/filesystems/cdfs/fcb.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/filesystems/cdfs/fcb.c [iso-8859-1] Sun Jul 10 17:14:33 2016
@@ -489,16 +489,16 @@
DirSize = DirectoryFcb->Entry.DataLengthL;
StreamOffset.QuadPart = (LONGLONG)DirectoryFcb->Entry.ExtentLocationL *
(LONGLONG)BLOCKSIZE;
- if (!CcMapData(DeviceExt->StreamFileObject,
- &StreamOffset,
- BLOCKSIZE,
- TRUE,
- &Context,
- &Block))
+ _SEH2_TRY
+ {
+ CcMapData(DeviceExt->StreamFileObject, &StreamOffset, BLOCKSIZE, TRUE,
&Context, &Block);
+ }
+ _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
DPRINT("CcMapData() failed\n");
- return STATUS_UNSUCCESSFUL;
- }
+ _SEH2_YIELD(return _SEH2_GetExceptionCode());
+ }
+ _SEH2_END;
Offset = 0;
BlockOffset = 0;
@@ -575,15 +575,17 @@
Offset = ROUND_UP(Offset, BLOCKSIZE);
BlockOffset = 0;
- if (!CcMapData(DeviceExt->StreamFileObject,
- &StreamOffset,
- BLOCKSIZE, TRUE,
- &Context, &Block))
+ _SEH2_TRY
+ {
+ CcMapData(DeviceExt->StreamFileObject, &StreamOffset, BLOCKSIZE,
TRUE, &Context, &Block);
+ }
+ _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
DPRINT("CcMapData() failed\n");
RtlFreeUnicodeString(&FileToFindUpcase);
- return(STATUS_UNSUCCESSFUL);
+ _SEH2_YIELD(return _SEH2_GetExceptionCode());
}
+ _SEH2_END;
Record = (PDIR_RECORD)((ULONG_PTR)Block + BlockOffset);
}
Modified: trunk/reactos/drivers/filesystems/fastfat/create.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filesystems/fastfa…
==============================================================================
--- trunk/reactos/drivers/filesystems/fastfat/create.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/filesystems/fastfat/create.c [iso-8859-1] Sun Jul 10 17:14:33
2016
@@ -111,6 +111,7 @@
ULONG SizeDirEntry;
ULONG EntriesPerPage;
OEM_STRING StringO;
+ NTSTATUS Status = STATUS_SUCCESS;
NameU.Buffer = Vpb->VolumeLabel;
NameU.Length = 0;
@@ -134,7 +135,16 @@
ExReleaseResourceLite(&DeviceExt->DirResource);
FileOffset.QuadPart = 0;
- if (CcMapData(pFcb->FileObject, &FileOffset, SizeDirEntry, TRUE, &Context,
(PVOID*)&Entry))
+ _SEH2_TRY
+ {
+ CcMapData(pFcb->FileObject, &FileOffset, SizeDirEntry, TRUE, &Context,
(PVOID*)&Entry);
+ }
+ _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
+ {
+ Status = _SEH2_GetExceptionCode();
+ }
+ _SEH2_END;
+ if (NT_SUCCESS(Status))
{
while (TRUE)
{
@@ -164,7 +174,16 @@
{
CcUnpinData(Context);
FileOffset.u.LowPart += PAGE_SIZE;
- if (!CcMapData(pFcb->FileObject, &FileOffset, SizeDirEntry, TRUE,
&Context, (PVOID*)&Entry))
+ _SEH2_TRY
+ {
+ CcMapData(pFcb->FileObject, &FileOffset, SizeDirEntry, TRUE,
&Context, (PVOID*)&Entry);
+ }
+ _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
+ {
+ Status = _SEH2_GetExceptionCode();
+ }
+ _SEH2_END;
+ if (!NT_SUCCESS(Status))
{
Context = NULL;
break;
Modified: trunk/reactos/drivers/filesystems/fastfat/direntry.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filesystems/fastfa…
==============================================================================
--- trunk/reactos/drivers/filesystems/fastfat/direntry.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/filesystems/fastfat/direntry.c [iso-8859-1] Sun Jul 10 17:14:33
2016
@@ -70,10 +70,15 @@
CcUnpinData(Context);
}
- if (!CcMapData(Fcb->FileObject, &FileOffset, sizeof(FAT_DIR_ENTRY),
TRUE, &Context, (PVOID*)&FatDirEntry))
- {
- return TRUE;
- }
+ _SEH2_TRY
+ {
+ CcMapData(Fcb->FileObject, &FileOffset, sizeof(FAT_DIR_ENTRY),
TRUE, &Context, (PVOID*)&FatDirEntry);
+ }
+ _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
+ {
+ _SEH2_YIELD(return TRUE);
+ }
+ _SEH2_END;
FatDirEntry += Index % FAT_ENTRIES_PER_PAGE;
FileOffset.QuadPart += PAGE_SIZE;
@@ -125,10 +130,15 @@
CcUnpinData(Context);
}
- if (!CcMapData(Fcb->FileObject, &FileOffset, sizeof(FATX_DIR_ENTRY),
TRUE, &Context, (PVOID*)&FatXDirEntry))
- {
- return TRUE;
- }
+ _SEH2_TRY
+ {
+ CcMapData(Fcb->FileObject, &FileOffset, sizeof(FATX_DIR_ENTRY),
TRUE, &Context, (PVOID*)&FatXDirEntry);
+ }
+ _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
+ {
+ _SEH2_YIELD(return TRUE);
+ }
+ _SEH2_END;
FatXDirEntry += Index % FATX_ENTRIES_PER_PAGE;
FileOffset.QuadPart += PAGE_SIZE;
@@ -201,12 +211,22 @@
CcUnpinData(*pContext);
}
- if (FileOffset.u.LowPart >= pDirFcb->RFCB.FileSize.u.LowPart ||
- !CcMapData(pDirFcb->FileObject, &FileOffset, PAGE_SIZE, TRUE,
pContext, pPage))
+ if (FileOffset.u.LowPart >= pDirFcb->RFCB.FileSize.u.LowPart)
{
*pContext = NULL;
return STATUS_NO_MORE_ENTRIES;
}
+
+ _SEH2_TRY
+ {
+ CcMapData(pDirFcb->FileObject, &FileOffset, PAGE_SIZE, TRUE, pContext,
pPage);
+ }
+ _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
+ {
+ *pContext = NULL;
+ _SEH2_YIELD(return STATUS_NO_MORE_ENTRIES);
+ }
+ _SEH2_END;
}
fatDirEntry = (PFAT_DIR_ENTRY)(*pPage) + DirContext->DirIndex %
FAT_ENTRIES_PER_PAGE;
@@ -232,13 +252,23 @@
CcUnpinData(*pContext);
FileOffset.u.LowPart -= PAGE_SIZE;
- if (FileOffset.u.LowPart >= pDirFcb->RFCB.FileSize.u.LowPart ||
- !CcMapData(pDirFcb->FileObject, &FileOffset, PAGE_SIZE, TRUE,
pContext, pPage))
+ if (FileOffset.u.LowPart >= pDirFcb->RFCB.FileSize.u.LowPart)
{
*pContext = NULL;
return STATUS_NO_MORE_ENTRIES;
}
+ _SEH2_TRY
+ {
+ CcMapData(pDirFcb->FileObject, &FileOffset, PAGE_SIZE, TRUE,
pContext, pPage);
+ }
+ _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
+ {
+ *pContext = NULL;
+ _SEH2_YIELD(return STATUS_NO_MORE_ENTRIES);
+ }
+ _SEH2_END;
+
fatDirEntry = (PFAT_DIR_ENTRY)(*pPage) + DirContext->DirIndex %
FAT_ENTRIES_PER_PAGE;
longNameEntry = (slot*) fatDirEntry;
}
@@ -259,12 +289,22 @@
CcUnpinData(*pContext);
FileOffset.u.LowPart += PAGE_SIZE;
- if (FileOffset.u.LowPart >= pDirFcb->RFCB.FileSize.u.LowPart ||
- !CcMapData(pDirFcb->FileObject, &FileOffset, PAGE_SIZE, TRUE,
pContext, pPage))
+ if (FileOffset.u.LowPart >= pDirFcb->RFCB.FileSize.u.LowPart)
{
*pContext = NULL;
return STATUS_NO_MORE_ENTRIES;
}
+
+ _SEH2_TRY
+ {
+ CcMapData(pDirFcb->FileObject, &FileOffset, PAGE_SIZE, TRUE,
pContext, pPage);
+ }
+ _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
+ {
+ *pContext = NULL;
+ _SEH2_YIELD(return STATUS_NO_MORE_ENTRIES);
+ }
+ _SEH2_END;
fatDirEntry = (PFAT_DIR_ENTRY)*pPage;
longNameEntry = (slot*) *pPage;
@@ -379,12 +419,22 @@
CcUnpinData(*pContext);
FileOffset.u.LowPart += PAGE_SIZE;
- if (FileOffset.u.LowPart >= pDirFcb->RFCB.FileSize.u.LowPart ||
- !CcMapData(pDirFcb->FileObject, &FileOffset, PAGE_SIZE, TRUE,
pContext, pPage))
+ if (FileOffset.u.LowPart >= pDirFcb->RFCB.FileSize.u.LowPart)
{
*pContext = NULL;
return STATUS_NO_MORE_ENTRIES;
}
+
+ _SEH2_TRY
+ {
+ CcMapData(pDirFcb->FileObject, &FileOffset, PAGE_SIZE, TRUE,
pContext, pPage);
+ }
+ _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
+ {
+ *pContext = NULL;
+ _SEH2_YIELD(return STATUS_NO_MORE_ENTRIES);
+ }
+ _SEH2_END;
fatDirEntry = (PFAT_DIR_ENTRY)*pPage;
longNameEntry = (slot*) *pPage;
@@ -467,12 +517,22 @@
CcUnpinData(*pContext);
}
FileOffset.u.LowPart = ROUND_DOWN(DirIndex * sizeof(FATX_DIR_ENTRY), PAGE_SIZE);
- if (FileOffset.u.LowPart >= pDirFcb->RFCB.FileSize.u.LowPart ||
- !CcMapData(pDirFcb->FileObject, &FileOffset, PAGE_SIZE, TRUE,
pContext, pPage))
+ if (FileOffset.u.LowPart >= pDirFcb->RFCB.FileSize.u.LowPart)
{
*pContext = NULL;
return STATUS_NO_MORE_ENTRIES;
}
+
+ _SEH2_TRY
+ {
+ CcMapData(pDirFcb->FileObject, &FileOffset, PAGE_SIZE, TRUE, pContext,
pPage);
+ }
+ _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
+ {
+ *pContext = NULL;
+ _SEH2_YIELD(return STATUS_NO_MORE_ENTRIES);
+ }
+ _SEH2_END;
}
fatxDirEntry = (PFATX_DIR_ENTRY)(*pPage) + DirIndex % FATX_ENTRIES_PER_PAGE;
@@ -500,12 +560,23 @@
{
CcUnpinData(*pContext);
FileOffset.u.LowPart += PAGE_SIZE;
- if (FileOffset.u.LowPart >= pDirFcb->RFCB.FileSize.u.LowPart ||
- !CcMapData(pDirFcb->FileObject, &FileOffset, PAGE_SIZE, TRUE,
pContext, pPage))
+ if (FileOffset.u.LowPart >= pDirFcb->RFCB.FileSize.u.LowPart)
{
*pContext = NULL;
return STATUS_NO_MORE_ENTRIES;
}
+
+ _SEH2_TRY
+ {
+ CcMapData(pDirFcb->FileObject, &FileOffset, PAGE_SIZE, TRUE,
pContext, pPage);
+ }
+ _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
+ {
+ *pContext = NULL;
+ _SEH2_YIELD(return STATUS_NO_MORE_ENTRIES);
+ }
+ _SEH2_END;
+
fatxDirEntry = (PFATX_DIR_ENTRY)*pPage;
}
else
Modified: trunk/reactos/drivers/filesystems/fastfat/dirwr.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filesystems/fastfa…
==============================================================================
--- trunk/reactos/drivers/filesystems/fastfat/dirwr.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/filesystems/fastfat/dirwr.c [iso-8859-1] Sun Jul 10 17:14:33
2016
@@ -53,20 +53,22 @@
Offset.u.HighPart = 0;
Offset.u.LowPart = dirIndex * SizeDirEntry;
- if (CcPinRead(pFcb->parentFcb->FileObject, &Offset, SizeDirEntry,
- TRUE, &Context, (PVOID*)&PinEntry))
- {
- pFcb->Flags &= ~FCB_IS_DIRTY;
- RtlCopyMemory(PinEntry, &pFcb->entry, SizeDirEntry);
- CcSetDirtyPinnedData(Context, NULL);
- CcUnpinData(Context);
- return STATUS_SUCCESS;
- }
- else
+ _SEH2_TRY
+ {
+ CcPinRead(pFcb->parentFcb->FileObject, &Offset, SizeDirEntry, TRUE,
&Context, (PVOID*)&PinEntry);
+ }
+ _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
DPRINT1("Failed write to \'%wZ\'.\n",
&pFcb->parentFcb->PathNameU);
- return STATUS_UNSUCCESSFUL;
- }
+ _SEH2_YIELD(return _SEH2_GetExceptionCode());
+ }
+ _SEH2_END;
+
+ pFcb->Flags &= ~FCB_IS_DIRTY;
+ RtlCopyMemory(PinEntry, &pFcb->entry, SizeDirEntry);
+ CcSetDirtyPinnedData(Context, NULL);
+ CcUnpinData(Context);
+ return STATUS_SUCCESS;
}
/*
@@ -96,12 +98,16 @@
StartIndex = pFcb->startIndex;
Offset.u.HighPart = 0;
Offset.u.LowPart = (StartIndex * sizeof(FATX_DIR_ENTRY) / PAGE_SIZE) *
PAGE_SIZE;
- if (!CcPinRead(pFcb->parentFcb->FileObject, &Offset,
sizeof(FATX_DIR_ENTRY), TRUE,
- &Context, (PVOID*)&pDirEntry))
+ _SEH2_TRY
+ {
+ CcPinRead(pFcb->parentFcb->FileObject, &Offset,
sizeof(FATX_DIR_ENTRY), TRUE, &Context, (PVOID*)&pDirEntry);
+ }
+ _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
DPRINT1("CcPinRead(Offset %x:%x, Length %d) failed\n",
Offset.u.HighPart, Offset.u.LowPart, PAGE_SIZE);
- return STATUS_UNSUCCESSFUL;
- }
+ _SEH2_YIELD(return _SEH2_GetExceptionCode());
+ }
+ _SEH2_END;
pDirEntry = &pDirEntry[StartIndex % (PAGE_SIZE / sizeof(FATX_DIR_ENTRY))];
@@ -170,11 +176,16 @@
{
CcUnpinData(Context);
}
- if (!CcPinRead(pDirFcb->FileObject, &FileOffset,
DeviceExt->FatInfo.BytesPerCluster,
- TRUE, &Context, (PVOID*)&pFatEntry))
- {
- return FALSE;
- }
+ _SEH2_TRY
+ {
+ CcPinRead(pDirFcb->FileObject, &FileOffset,
DeviceExt->FatInfo.BytesPerCluster, TRUE, &Context, (PVOID*)&pFatEntry);
+ }
+ _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
+ {
+ _SEH2_YIELD(return FALSE);
+ }
+ _SEH2_END;
+
FileOffset.u.LowPart += DeviceExt->FatInfo.BytesPerCluster;
}
if (ENTRY_END(DeviceExt, pFatEntry))
@@ -226,11 +237,16 @@
/* clear the new dir cluster */
FileOffset.u.LowPart = (ULONG)(pDirFcb->RFCB.FileSize.QuadPart -
DeviceExt->FatInfo.BytesPerCluster);
- if (!CcPinRead(pDirFcb->FileObject, &FileOffset,
DeviceExt->FatInfo.BytesPerCluster,
- TRUE, &Context, (PVOID*)&pFatEntry))
- {
- return FALSE;
- }
+ _SEH2_TRY
+ {
+ CcPinRead(pDirFcb->FileObject, &FileOffset,
DeviceExt->FatInfo.BytesPerCluster, TRUE, &Context, (PVOID*)&pFatEntry);
+ }
+ _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
+ {
+ _SEH2_YIELD(return FALSE);
+ }
+ _SEH2_END;
+
if (DeviceExt->Flags & VCB_IS_FATX)
memset(pFatEntry, 0xff, DeviceExt->FatInfo.BytesPerCluster);
else
@@ -240,11 +256,16 @@
{
/* clear the entry after the last new entry */
FileOffset.u.LowPart = (*start + nbSlots) * SizeDirEntry;
- if (!CcPinRead(pDirFcb->FileObject, &FileOffset, SizeDirEntry,
- TRUE, &Context, (PVOID*)&pFatEntry))
- {
- return FALSE;
- }
+ _SEH2_TRY
+ {
+ CcPinRead(pDirFcb->FileObject, &FileOffset, SizeDirEntry, TRUE,
&Context, (PVOID*)&pFatEntry);
+ }
+ _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
+ {
+ _SEH2_YIELD(return FALSE);
+ }
+ _SEH2_END;
+
if (DeviceExt->Flags & VCB_IS_FATX)
memset(pFatEntry, 0xff, SizeDirEntry);
else
@@ -556,12 +577,17 @@
if (DirContext.StartIndex / i == DirContext.DirIndex / i)
{
/* one cluster */
- if (!CcPinRead(ParentFcb->FileObject, &FileOffset, nbSlots *
sizeof(FAT_DIR_ENTRY),
- TRUE, &Context, (PVOID*)&pFatEntry))
+ _SEH2_TRY
+ {
+ CcPinRead(ParentFcb->FileObject, &FileOffset, nbSlots *
sizeof(FAT_DIR_ENTRY), TRUE, &Context, (PVOID*)&pFatEntry);
+ }
+ _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
ExFreePoolWithTag(Buffer, TAG_VFAT);
- return STATUS_UNSUCCESSFUL;
- }
+ _SEH2_YIELD(return _SEH2_GetExceptionCode());
+ }
+ _SEH2_END;
+
if (nbSlots > 1)
{
RtlCopyMemory(pFatEntry, Buffer, (nbSlots - 1) * sizeof(FAT_DIR_ENTRY));
@@ -574,23 +600,30 @@
size = DeviceExt->FatInfo.BytesPerCluster -
(DirContext.StartIndex * sizeof(FAT_DIR_ENTRY)) %
DeviceExt->FatInfo.BytesPerCluster;
i = size / sizeof(FAT_DIR_ENTRY);
- if (!CcPinRead(ParentFcb->FileObject, &FileOffset, size, TRUE,
- &Context, (PVOID*)&pFatEntry))
+ _SEH2_TRY
+ {
+ CcPinRead(ParentFcb->FileObject, &FileOffset, size, TRUE,
&Context, (PVOID*)&pFatEntry);
+ }
+ _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
ExFreePoolWithTag(Buffer, TAG_VFAT);
- return STATUS_UNSUCCESSFUL;
- }
+ _SEH2_YIELD(return _SEH2_GetExceptionCode());
+ }
+ _SEH2_END;
RtlCopyMemory(pFatEntry, Buffer, size);
CcSetDirtyPinnedData(Context, NULL);
CcUnpinData(Context);
FileOffset.u.LowPart += size;
- if (!CcPinRead(ParentFcb->FileObject, &FileOffset,
- nbSlots * sizeof(FAT_DIR_ENTRY) - size,
- TRUE, &Context, (PVOID*)&pFatEntry))
+ _SEH2_TRY
+ {
+ CcPinRead(ParentFcb->FileObject, &FileOffset, nbSlots *
sizeof(FAT_DIR_ENTRY) - size, TRUE, &Context, (PVOID*)&pFatEntry);
+ }
+ _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
ExFreePoolWithTag(Buffer, TAG_VFAT);
- return STATUS_UNSUCCESSFUL;
- }
+ _SEH2_YIELD(return _SEH2_GetExceptionCode());
+ }
+ _SEH2_END;
if (nbSlots - 1 > i)
{
RtlCopyMemory(pFatEntry, (PVOID)(Buffer + size), (nbSlots - 1 - i) *
sizeof(FAT_DIR_ENTRY));
@@ -623,12 +656,16 @@
if (RequestedOptions & FILE_DIRECTORY_FILE)
{
FileOffset.QuadPart = 0;
- if (!CcPinRead((*Fcb)->FileObject, &FileOffset,
DeviceExt->FatInfo.BytesPerCluster, TRUE,
- &Context, (PVOID*)&pFatEntry))
+ _SEH2_TRY
+ {
+ CcPinRead((*Fcb)->FileObject, &FileOffset,
DeviceExt->FatInfo.BytesPerCluster, TRUE, &Context, (PVOID*)&pFatEntry);
+ }
+ _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
ExFreePoolWithTag(Buffer, TAG_VFAT);
- return STATUS_UNSUCCESSFUL;
- }
+ _SEH2_YIELD(return _SEH2_GetExceptionCode());
+ }
+ _SEH2_END;
/* clear the new directory cluster if not moving */
if (MoveContext == NULL)
{
@@ -746,11 +783,15 @@
/* add entry into parent directory */
FileOffset.u.HighPart = 0;
FileOffset.u.LowPart = Index * sizeof(FATX_DIR_ENTRY);
- if (!CcPinRead(ParentFcb->FileObject, &FileOffset, sizeof(FATX_DIR_ENTRY),
- TRUE, &Context, (PVOID*)&pFatXDirEntry))
- {
- return STATUS_UNSUCCESSFUL;
- }
+ _SEH2_TRY
+ {
+ CcPinRead(ParentFcb->FileObject, &FileOffset, sizeof(FATX_DIR_ENTRY),
TRUE, &Context, (PVOID*)&pFatXDirEntry);
+ }
+ _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
+ {
+ _SEH2_YIELD(return _SEH2_GetExceptionCode());
+ }
+ _SEH2_END;
RtlCopyMemory(pFatXDirEntry, &DirContext.DirEntry.FatX, sizeof(FATX_DIR_ENTRY));
CcSetDirtyPinnedData(Context, NULL);
CcUnpinData(Context);
@@ -819,11 +860,15 @@
CcUnpinData(Context);
}
Offset.u.LowPart = (i * sizeof(FAT_DIR_ENTRY) / PAGE_SIZE) * PAGE_SIZE;
- if (!CcPinRead(pFcb->parentFcb->FileObject, &Offset,
sizeof(FAT_DIR_ENTRY), TRUE,
- &Context, (PVOID*)&pDirEntry))
- {
- return STATUS_UNSUCCESSFUL;
- }
+ _SEH2_TRY
+ {
+ CcPinRead(pFcb->parentFcb->FileObject, &Offset,
sizeof(FAT_DIR_ENTRY), TRUE, &Context, (PVOID*)&pDirEntry);
+ }
+ _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
+ {
+ _SEH2_YIELD(return _SEH2_GetExceptionCode());
+ }
+ _SEH2_END;
}
pDirEntry[i % (PAGE_SIZE / sizeof(FAT_DIR_ENTRY))].Filename[0] = 0xe5;
if (i == pFcb->dirIndex)
@@ -887,12 +932,16 @@
DPRINT("delete entry: %u\n", StartIndex);
Offset.u.HighPart = 0;
Offset.u.LowPart = (StartIndex * sizeof(FATX_DIR_ENTRY) / PAGE_SIZE) * PAGE_SIZE;
- if (!CcPinRead(pFcb->parentFcb->FileObject, &Offset,
sizeof(FATX_DIR_ENTRY), TRUE,
- &Context, (PVOID*)&pDirEntry))
+ _SEH2_TRY
+ {
+ CcPinRead(pFcb->parentFcb->FileObject, &Offset, sizeof(FATX_DIR_ENTRY),
TRUE, &Context, (PVOID*)&pDirEntry);
+ }
+ _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
DPRINT1("CcPinRead(Offset %x:%x, Length %d) failed\n",
Offset.u.HighPart, Offset.u.LowPart, PAGE_SIZE);
- return STATUS_UNSUCCESSFUL;
- }
+ _SEH2_YIELD(return _SEH2_GetExceptionCode());
+ }
+ _SEH2_END;
pDirEntry = &pDirEntry[StartIndex % (PAGE_SIZE / sizeof(FATX_DIR_ENTRY))];
pDirEntry->FilenameLength = 0xe5;
CurrentCluster = vfatDirEntryGetFirstCluster(DeviceExt,
Modified: trunk/reactos/drivers/filesystems/fastfat/fat.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filesystems/fastfa…
==============================================================================
--- trunk/reactos/drivers/filesystems/fastfat/fat.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/filesystems/fastfat/fat.c [iso-8859-1] Sun Jul 10 17:14:33 2016
@@ -41,10 +41,15 @@
ChunkSize = CACHEPAGESIZE(DeviceExt);
FATOffset = CurrentCluster * sizeof(ULONG);
Offset.QuadPart = ROUND_DOWN(FATOffset, ChunkSize);
- if (!CcMapData(DeviceExt->FATFileObject, &Offset, ChunkSize, MAP_WAIT,
&Context, &BaseAddress))
- {
- return STATUS_UNSUCCESSFUL;
- }
+ _SEH2_TRY
+ {
+ CcMapData(DeviceExt->FATFileObject, &Offset, ChunkSize, MAP_WAIT,
&Context, &BaseAddress);
+ }
+ _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
+ {
+ _SEH2_YIELD(return _SEH2_GetExceptionCode());
+ }
+ _SEH2_END;
CurrentCluster = (*(PULONG)((char*)BaseAddress + (FATOffset % ChunkSize))) &
0x0fffffff;
if (CurrentCluster >= 0xffffff8 && CurrentCluster <= 0xfffffff)
@@ -81,10 +86,15 @@
ChunkSize = CACHEPAGESIZE(DeviceExt);
FATOffset = CurrentCluster * 2;
Offset.QuadPart = ROUND_DOWN(FATOffset, ChunkSize);
- if (!CcMapData(DeviceExt->FATFileObject, &Offset, ChunkSize, MAP_WAIT,
&Context, &BaseAddress))
- {
- return STATUS_UNSUCCESSFUL;
- }
+ _SEH2_TRY
+ {
+ CcMapData(DeviceExt->FATFileObject, &Offset, ChunkSize, MAP_WAIT,
&Context, &BaseAddress);
+ }
+ _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
+ {
+ _SEH2_YIELD(return _SEH2_GetExceptionCode());
+ }
+ _SEH2_END;
CurrentCluster = *((PUSHORT)((char*)BaseAddress + (FATOffset % ChunkSize)));
if (CurrentCluster >= 0xfff8 && CurrentCluster <= 0xffff)
@@ -121,10 +131,15 @@
*NextCluster = 0;
Offset.QuadPart = 0;
- if (!CcMapData(DeviceExt->FATFileObject, &Offset,
DeviceExt->FatInfo.FATSectors * DeviceExt->FatInfo.BytesPerSector, MAP_WAIT,
&Context, &BaseAddress))
- {
- return STATUS_UNSUCCESSFUL;
- }
+ _SEH2_TRY
+ {
+ CcMapData(DeviceExt->FATFileObject, &Offset,
DeviceExt->FatInfo.FATSectors * DeviceExt->FatInfo.BytesPerSector, MAP_WAIT,
&Context, &BaseAddress);
+ }
+ _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
+ {
+ _SEH2_YIELD(return _SEH2_GetExceptionCode());
+ }
+ _SEH2_END;
CBlock = (PUSHORT)((char*)BaseAddress + (CurrentCluster * 12) / 8);
if ((CurrentCluster % 2) == 0)
@@ -176,11 +191,16 @@
for (i = StartCluster; i < FatLength;)
{
Offset.QuadPart = ROUND_DOWN(i * 2, ChunkSize);
- if (!CcPinRead(DeviceExt->FATFileObject, &Offset, ChunkSize, PIN_WAIT,
&Context, &BaseAddress))
+ _SEH2_TRY
+ {
+ CcPinRead(DeviceExt->FATFileObject, &Offset, ChunkSize, PIN_WAIT,
&Context, &BaseAddress);
+ }
+ _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
DPRINT1("CcPinRead(Offset %x, Length %u) failed\n",
(ULONG)Offset.QuadPart, ChunkSize);
- return STATUS_UNSUCCESSFUL;
+ _SEH2_YIELD(return _SEH2_GetExceptionCode());
}
+ _SEH2_END;
Block = (PUSHORT)((ULONG_PTR)BaseAddress + (i * 2) % ChunkSize);
BlockEnd = (PUSHORT)((ULONG_PTR)BaseAddress + ChunkSize);
@@ -235,11 +255,16 @@
*Cluster = 0;
StartCluster = DeviceExt->LastAvailableCluster;
Offset.QuadPart = 0;
- if (!CcPinRead(DeviceExt->FATFileObject, &Offset,
DeviceExt->FatInfo.FATSectors * DeviceExt->FatInfo.BytesPerSector, PIN_WAIT,
&Context, &BaseAddress))
+ _SEH2_TRY
+ {
+ CcPinRead(DeviceExt->FATFileObject, &Offset,
DeviceExt->FatInfo.FATSectors * DeviceExt->FatInfo.BytesPerSector, PIN_WAIT,
&Context, &BaseAddress);
+ }
+ _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
DPRINT1("CcPinRead(Offset %x, Length %u) failed\n",
(ULONG)Offset.QuadPart, DeviceExt->FatInfo.FATSectors *
DeviceExt->FatInfo.BytesPerSector);
- return STATUS_UNSUCCESSFUL;
- }
+ _SEH2_YIELD(return _SEH2_GetExceptionCode());
+ }
+ _SEH2_END;
for (j = 0; j < 2; j++)
{
@@ -305,11 +330,16 @@
for (i = StartCluster; i < FatLength;)
{
Offset.QuadPart = ROUND_DOWN(i * 4, ChunkSize);
- if (!CcPinRead(DeviceExt->FATFileObject, &Offset, ChunkSize, PIN_WAIT,
&Context, &BaseAddress))
+ _SEH2_TRY
+ {
+ CcPinRead(DeviceExt->FATFileObject, &Offset, ChunkSize, PIN_WAIT,
&Context, &BaseAddress);
+ }
+ _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
DPRINT1("CcPinRead(Offset %x, Length %u) failed\n",
(ULONG)Offset.QuadPart, ChunkSize);
- return STATUS_UNSUCCESSFUL;
+ _SEH2_YIELD(return _SEH2_GetExceptionCode());
}
+ _SEH2_END;
Block = (PULONG)((ULONG_PTR)BaseAddress + (i * 4) % ChunkSize);
BlockEnd = (PULONG)((ULONG_PTR)BaseAddress + ChunkSize);
@@ -358,10 +388,15 @@
PUSHORT CBlock;
Offset.QuadPart = 0;
- if (!CcMapData(DeviceExt->FATFileObject, &Offset,
DeviceExt->FatInfo.FATSectors * DeviceExt->FatInfo.BytesPerSector, MAP_WAIT,
&Context, &BaseAddress))
- {
- return STATUS_UNSUCCESSFUL;
- }
+ _SEH2_TRY
+ {
+ CcMapData(DeviceExt->FATFileObject, &Offset,
DeviceExt->FatInfo.FATSectors * DeviceExt->FatInfo.BytesPerSector, MAP_WAIT,
&Context, &BaseAddress);
+ }
+ _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
+ {
+ _SEH2_YIELD(return _SEH2_GetExceptionCode());
+ }
+ _SEH2_END;
numberofclusters = DeviceExt->FatInfo.NumberOfClusters + 2;
@@ -413,10 +448,15 @@
for (i = 2; i < FatLength; )
{
Offset.QuadPart = ROUND_DOWN(i * 2, ChunkSize);
- if (!CcMapData(DeviceExt->FATFileObject, &Offset, ChunkSize, MAP_WAIT,
&Context, &BaseAddress))
- {
- return STATUS_UNSUCCESSFUL;
- }
+ _SEH2_TRY
+ {
+ CcMapData(DeviceExt->FATFileObject, &Offset, ChunkSize, MAP_WAIT,
&Context, &BaseAddress);
+ }
+ _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
+ {
+ _SEH2_YIELD(return _SEH2_GetExceptionCode());
+ }
+ _SEH2_END;
Block = (PUSHORT)((ULONG_PTR)BaseAddress + (i * 2) % ChunkSize);
BlockEnd = (PUSHORT)((ULONG_PTR)BaseAddress + ChunkSize);
@@ -463,11 +503,16 @@
for (i = 2; i < FatLength; )
{
Offset.QuadPart = ROUND_DOWN(i * 4, ChunkSize);
- if (!CcMapData(DeviceExt->FATFileObject, &Offset, ChunkSize, MAP_WAIT,
&Context, &BaseAddress))
+ _SEH2_TRY
+ {
+ CcMapData(DeviceExt->FATFileObject, &Offset, ChunkSize, MAP_WAIT,
&Context, &BaseAddress);
+ }
+ _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
DPRINT1("CcMapData(Offset %x, Length %u) failed\n",
(ULONG)Offset.QuadPart, ChunkSize);
- return STATUS_UNSUCCESSFUL;
- }
+ _SEH2_YIELD(return _SEH2_GetExceptionCode());
+ }
+ _SEH2_END;
Block = (PULONG)((ULONG_PTR)BaseAddress + (i * 4) % ChunkSize);
BlockEnd = (PULONG)((ULONG_PTR)BaseAddress + ChunkSize);
@@ -529,10 +574,15 @@
LARGE_INTEGER Offset;
Offset.QuadPart = 0;
- if (!CcPinRead(DeviceExt->FATFileObject, &Offset,
DeviceExt->FatInfo.FATSectors * DeviceExt->FatInfo.BytesPerSector, PIN_WAIT,
&Context, &BaseAddress))
- {
- return STATUS_UNSUCCESSFUL;
- }
+ _SEH2_TRY
+ {
+ CcPinRead(DeviceExt->FATFileObject, &Offset,
DeviceExt->FatInfo.FATSectors * DeviceExt->FatInfo.BytesPerSector, PIN_WAIT,
&Context, &BaseAddress);
+ }
+ _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
+ {
+ _SEH2_YIELD(return _SEH2_GetExceptionCode());
+ }
+ _SEH2_END;
CBlock = (PUCHAR)BaseAddress;
FATOffset = (ClusterToWrite * 12) / 8;
@@ -578,10 +628,15 @@
ChunkSize = CACHEPAGESIZE(DeviceExt);
FATOffset = ClusterToWrite * 2;
Offset.QuadPart = ROUND_DOWN(FATOffset, ChunkSize);
- if (!CcPinRead(DeviceExt->FATFileObject, &Offset, ChunkSize, PIN_WAIT,
&Context, &BaseAddress))
- {
- return STATUS_UNSUCCESSFUL;
- }
+ _SEH2_TRY
+ {
+ CcPinRead(DeviceExt->FATFileObject, &Offset, ChunkSize, PIN_WAIT,
&Context, &BaseAddress);
+ }
+ _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
+ {
+ _SEH2_YIELD(return _SEH2_GetExceptionCode());
+ }
+ _SEH2_END;
DPRINT("Writing 0x%x for offset 0x%x 0x%x\n", NewValue, FATOffset,
ClusterToWrite);
@@ -614,10 +669,15 @@
FATOffset = (ClusterToWrite * 4);
Offset.QuadPart = ROUND_DOWN(FATOffset, ChunkSize);
- if (!CcPinRead(DeviceExt->FATFileObject, &Offset, ChunkSize, PIN_WAIT,
&Context, &BaseAddress))
- {
- return STATUS_UNSUCCESSFUL;
- }
+ _SEH2_TRY
+ {
+ CcPinRead(DeviceExt->FATFileObject, &Offset, ChunkSize, PIN_WAIT,
&Context, &BaseAddress);
+ }
+ _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
+ {
+ _SEH2_YIELD(return _SEH2_GetExceptionCode());
+ }
+ _SEH2_END;
DPRINT("Writing 0x%x for offset 0x%x 0x%x\n", NewValue, FATOffset,
ClusterToWrite);
Modified: trunk/reactos/drivers/filesystems/fastfat/volume.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filesystems/fastfa…
==============================================================================
--- trunk/reactos/drivers/filesystems/fastfat/volume.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/filesystems/fastfat/volume.c [iso-8859-1] Sun Jul 10 17:14:33
2016
@@ -314,7 +314,17 @@
/* Search existing volume entry on disk */
FileOffset.QuadPart = 0;
- if (CcPinRead(pRootFcb->FileObject, &FileOffset, SizeDirEntry, TRUE,
&Context, (PVOID*)&Entry))
+ _SEH2_TRY
+ {
+ CcPinRead(pRootFcb->FileObject, &FileOffset, SizeDirEntry, TRUE,
&Context, (PVOID*)&Entry);
+ }
+ _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
+ {
+ Status = _SEH2_GetExceptionCode();
+ }
+ _SEH2_END;
+
+ if (NT_SUCCESS(Status))
{
while (TRUE)
{
@@ -339,7 +349,17 @@
{
CcUnpinData(Context);
FileOffset.u.LowPart += PAGE_SIZE;
- if (!CcPinRead(pRootFcb->FileObject, &FileOffset, SizeDirEntry,
TRUE, &Context, (PVOID*)&Entry))
+ _SEH2_TRY
+ {
+ CcPinRead(pRootFcb->FileObject, &FileOffset, SizeDirEntry,
TRUE, &Context, (PVOID*)&Entry);
+ }
+ _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
+ {
+ Status = _SEH2_GetExceptionCode();
+ }
+ _SEH2_END;
+
+ if (!NT_SUCCESS(Status))
{
Context = NULL;
break;
@@ -362,12 +382,19 @@
{
FileOffset.u.HighPart = 0;
FileOffset.u.LowPart = VolumeLabelDirIndex * SizeDirEntry;
- if (!CcPinRead(pRootFcb->FileObject, &FileOffset, SizeDirEntry,
- TRUE, &Context, (PVOID*)&Entry))
+
+ Status = STATUS_SUCCESS;
+ _SEH2_TRY
{
- Status = STATUS_UNSUCCESSFUL;
+ CcPinRead(pRootFcb->FileObject, &FileOffset, SizeDirEntry, TRUE,
&Context, (PVOID*)&Entry);
}
- else
+ _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
+ {
+ Status = _SEH2_GetExceptionCode();
+ }
+ _SEH2_END;
+
+ if (NT_SUCCESS(Status))
{
RtlCopyMemory(Entry, &VolumeLabelDirEntry, SizeDirEntry);
CcSetDirtyPinnedData(Context, NULL);
Modified: trunk/reactos/ntoskrnl/cc/pin.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/cc/pin.c?rev=7188…
==============================================================================
--- trunk/reactos/ntoskrnl/cc/pin.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/cc/pin.c [iso-8859-1] Sun Jul 10 17:14:33 2016
@@ -16,8 +16,6 @@
/* GLOBALS *******************************************************************/
-//#define RAISE_FROM_CC_MAP_DATA
-
extern NPAGED_LOOKASIDE_LIST iBcbLookasideList;
/* FUNCTIONS *****************************************************************/
@@ -64,11 +62,8 @@
{
CCTRACE(CC_API_DEBUG, "FileObject=%p FileOffset=%p Length=%lu Flags=0x%lx
-> FALSE\n",
FileObject, FileOffset, Length, Flags);
-#ifdef RAISE_FROM_CC_MAP_DATA
ExRaiseStatus(STATUS_INVALID_PARAMETER);
-#else
return FALSE;
-#endif
}
ROffset = ROUND_DOWN(ReadOffset, VACB_MAPPING_GRANULARITY);
@@ -81,11 +76,8 @@
{
CCTRACE(CC_API_DEBUG, "FileObject=%p FileOffset=%p Length=%lu Flags=0x%lx
-> FALSE\n",
FileObject, FileOffset, Length, Flags);
-#ifdef RAISE_FROM_CC_MAP_DATA
ExRaiseStatus(Status);
-#else
return FALSE;
-#endif
}
if (!Valid)
@@ -104,11 +96,8 @@
CcRosReleaseVacb(SharedCacheMap, Vacb, FALSE, FALSE, FALSE);
CCTRACE(CC_API_DEBUG, "FileObject=%p FileOffset=%p Length=%lu
Flags=0x%lx -> FALSE\n",
FileObject, FileOffset, Length, Flags);
-#ifdef RAISE_FROM_CC_MAP_DATA
ExRaiseStatus(Status);
-#else
return FALSE;
-#endif
}
}
@@ -119,11 +108,8 @@
CcRosReleaseVacb(SharedCacheMap, Vacb, TRUE, FALSE, FALSE);
CCTRACE(CC_API_DEBUG, "FileObject=%p FileOffset=%p Length=%lu Flags=0x%lx
-> FALSE\n",
FileObject, FileOffset, Length, Flags);
-#ifdef RAISE_FROM_CC_MAP_DATA
ExRaiseStatus(STATUS_INSUFFICIENT_RESOURCES);
-#else
return FALSE;
-#endif
}
RtlZeroMemory(iBcb, sizeof(*iBcb));