Author: pschweitzer
Date: Sun Dec 14 12:24:18 2014
New Revision: 65638
URL:
http://svn.reactos.org/svn/reactos?rev=65638&view=rev
Log:
[NTFS]
- Implement NtfsGetUserBuffer() that will (attempt to) return the user output buffer for
METHOD_NEITHER IOCTL.
- Implement parameters checking GetVolumeBitmap()
CORE-8725
Modified:
trunk/reactos/drivers/filesystems/ntfs/CMakeLists.txt
trunk/reactos/drivers/filesystems/ntfs/fsctl.c
trunk/reactos/drivers/filesystems/ntfs/misc.c
trunk/reactos/drivers/filesystems/ntfs/ntfs.h
Modified: trunk/reactos/drivers/filesystems/ntfs/CMakeLists.txt
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filesystems/ntfs/C…
==============================================================================
--- trunk/reactos/drivers/filesystems/ntfs/CMakeLists.txt [iso-8859-1] (original)
+++ trunk/reactos/drivers/filesystems/ntfs/CMakeLists.txt [iso-8859-1] Sun Dec 14 12:24:18
2014
@@ -20,6 +20,7 @@
add_library(ntfs SHARED ${SOURCE} ntfs.rc)
set_module_type(ntfs kernelmodedriver)
+target_link_libraries(ntfs ${PSEH_LIB})
add_importlibs(ntfs ntoskrnl hal)
add_pch(ntfs ntfs.h SOURCE)
add_cd_file(TARGET ntfs DESTINATION reactos/system32/drivers NO_CAB FOR all)
Modified: trunk/reactos/drivers/filesystems/ntfs/fsctl.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filesystems/ntfs/f…
==============================================================================
--- trunk/reactos/drivers/filesystems/ntfs/fsctl.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/filesystems/ntfs/fsctl.c [iso-8859-1] Sun Dec 14 12:24:18 2014
@@ -661,7 +661,57 @@
GetVolumeBitmap(PDEVICE_EXTENSION DeviceExt,
PIRP Irp)
{
+ NTSTATUS Status = STATUS_SUCCESS;
+ PIO_STACK_LOCATION Stack;
+ PVOLUME_BITMAP_BUFFER BitmapBuffer;
+
DPRINT1("GetVolumeBitmap(%p, %p)\n", DeviceExt, Irp);
+
+ Stack = IoGetCurrentIrpStackLocation(Irp);
+
+ if (Stack->Parameters.FileSystemControl.InputBufferLength <
sizeof(STARTING_LCN_INPUT_BUFFER))
+ {
+ DPRINT1("Invalid input! %d\n",
Stack->Parameters.FileSystemControl.InputBufferLength);
+ return STATUS_INVALID_PARAMETER;
+ }
+
+ if (Stack->Parameters.FileSystemControl.OutputBufferLength <
sizeof(VOLUME_BITMAP_BUFFER))
+ {
+ DPRINT1("Invalid output! %d\n",
Stack->Parameters.FileSystemControl.OutputBufferLength);
+ return STATUS_BUFFER_TOO_SMALL;
+ }
+
+ BitmapBuffer = NtfsGetUserBuffer(Irp);
+ if (Irp->RequestorMode == UserMode)
+ {
+ _SEH2_TRY
+ {
+ ProbeForRead(Stack->Parameters.FileSystemControl.Type3InputBuffer,
+ Stack->Parameters.FileSystemControl.InputBufferLength,
+ sizeof(CHAR));
+ ProbeForWrite(BitmapBuffer,
Stack->Parameters.FileSystemControl.OutputBufferLength,
+ sizeof(CHAR));
+ }
+ _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
+ {
+ Status = _SEH2_GetExceptionCode();
+ }
+ _SEH2_END;
+ }
+ else
+ {
+ if (Stack->Parameters.FileSystemControl.Type3InputBuffer == NULL ||
+ BitmapBuffer == NULL)
+ {
+ Status = STATUS_INVALID_PARAMETER;
+ }
+ }
+
+ if (!NT_SUCCESS(Status))
+ {
+ DPRINT1("Invalid buffer! %p %p\n",
Stack->Parameters.FileSystemControl.Type3InputBuffer, BitmapBuffer);
+ return Status;
+ }
UNIMPLEMENTED;
return STATUS_NOT_IMPLEMENTED;
Modified: trunk/reactos/drivers/filesystems/ntfs/misc.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filesystems/ntfs/m…
==============================================================================
--- trunk/reactos/drivers/filesystems/ntfs/misc.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/filesystems/ntfs/misc.c [iso-8859-1] Sun Dec 14 12:24:18 2014
@@ -112,4 +112,17 @@
*FileAttributes = FILE_ATTRIBUTE_NORMAL;
}
+PVOID
+NtfsGetUserBuffer(PIRP Irp)
+{
+ if (Irp->MdlAddress != NULL)
+ {
+ return MmGetSystemAddressForMdlSafe(Irp->MdlAddress, HighPagePriority);
+ }
+ else
+ {
+ return Irp->UserBuffer;
+ }
+}
+
/* EOF */
Modified: trunk/reactos/drivers/filesystems/ntfs/ntfs.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filesystems/ntfs/n…
==============================================================================
--- trunk/reactos/drivers/filesystems/ntfs/ntfs.h [iso-8859-1] (original)
+++ trunk/reactos/drivers/filesystems/ntfs/ntfs.h [iso-8859-1] Sun Dec 14 12:24:18 2014
@@ -2,6 +2,7 @@
#define NTFS_H
#include <ntifs.h>
+#include <pseh/pseh2.h>
#define CACHEPAGESIZE(pDeviceExt) \
((pDeviceExt)->NtfsInfo.UCHARsPerCluster > PAGE_SIZE ? \
@@ -729,6 +730,9 @@
NtfsAllocateIrpContext(PDEVICE_OBJECT DeviceObject,
PIRP Irp);
+PVOID
+NtfsGetUserBuffer(PIRP Irp);
+
#if 0
BOOLEAN
wstrcmpjoki(PWSTR s1, PWSTR s2);