https://git.reactos.org/?p=reactos.git;a=commitdiff;h=3adf45086743d5f075e42…
commit 3adf45086743d5f075e4270af7af64017eb01d63
Author: Jérôme Gardou <jerome.gardou(a)reactos.org>
AuthorDate: Tue May 11 17:13:14 2021 +0200
Commit: Jérôme Gardou <zefklop(a)users.noreply.github.com>
CommitDate: Wed May 12 11:04:29 2021 +0200
[REACTOS] Addendum to 5c7ce4475e246560d1622b8cc60dc603e3955f66 - Fix MSVC 2015 build
Put data into PAGEDATA or INITDATA sections
Keep section declaration for prototypes
CORE-17540
---
drivers/bus/pci/pci.c | 11 +-
drivers/bus/pci/pci.h | 2 +
drivers/filesystems/fastfat/fastio.c | 4 -
drivers/filesystems/fastfat/vfat.h | 2 +
drivers/filesystems/mup/dfs.c | 4 -
drivers/filesystems/mup/dfs.h | 1 +
drivers/filesystems/mup/mup.c | 26 -
drivers/filesystems/ntfs/ntfs.c | 17 +-
drivers/filesystems/ntfs/ntfs.h | 2 +
drivers/filters/fltmgr/Interface.c | 2551 ++++++++++++----------------
drivers/filters/fltmgr/fltmgr.h | 2 +
drivers/input/inport/hardware.c | 5 +-
drivers/input/inport/inport.c | 11 +-
drivers/input/inport/inport.h | 15 +
drivers/input/inport/pnp.c | 11 +-
drivers/input/inport/wmi.c | 14 +-
drivers/storage/class/disk_new/data.c | 14 +-
drivers/storage/class/disk_new/disk.h | 6 +-
drivers/storage/mountmgr/mntmgr.h | 2 +
drivers/storage/mountmgr/mountmgr.c | 5 -
drivers/storage/partmgr/partmgr.h | 3 +
hal/halx86/include/bus.h | 4 +
hal/halx86/include/hal.h | 1 +
hal/halx86/include/halacpi.h | 1 +
hal/halx86/include/halp.h | 19 +-
hal/halx86/legacy/bussupp.c | 86 +
hal/halx86/pcidata.cmake | 10 +-
ntoskrnl/cache/newcc.h | 2 +
ntoskrnl/config/cmdata.c | 13 +-
ntoskrnl/ex/sem.c | 4 +
ntoskrnl/ex/uuid.c | 1 +
ntoskrnl/ex/work.c | 4 +-
ntoskrnl/include/internal/amd64/mm.h | 1 +
ntoskrnl/include/internal/cc.h | 3 +
ntoskrnl/include/internal/cm.h | 16 +
ntoskrnl/include/internal/dbgk.h | 1 +
ntoskrnl/include/internal/ex.h | 21 +
ntoskrnl/include/internal/fsrtl.h | 3 +
ntoskrnl/include/internal/i386/ke.h | 21 +-
ntoskrnl/include/internal/inbv.h | 8 +
ntoskrnl/include/internal/io.h | 25 +
ntoskrnl/include/internal/ke.h | 9 +
ntoskrnl/include/internal/lpc.h | 1 +
ntoskrnl/include/internal/mm.h | 23 +
ntoskrnl/include/internal/ob.h | 3 +
ntoskrnl/include/internal/po.h | 2 +
ntoskrnl/include/internal/ps.h | 4 +
ntoskrnl/include/internal/se.h | 9 +
ntoskrnl/include/ntoskrnl.h | 4 +
ntoskrnl/io/iomgr/driver.c | 7 +-
ntoskrnl/io/pnpmgr/plugplay.c | 3 +-
ntoskrnl/ke/amd64/cpu.c | 3 -
ntoskrnl/ke/amd64/kiinit.c | 1 -
ntoskrnl/ke/arm/kiinit.c | 2 -
ntoskrnl/ke/powerpc/cpu.c | 7 -
ntoskrnl/ke/powerpc/kiinit.c | 1 -
ntoskrnl/mm/ARM3/miarm.h | 18 +
ntoskrnl/mm/amd64/init.c | 4 +-
ntoskrnl/mm/arm/page.c | 1 -
ntoskrnl/mm/arm/stubs.c | 1 -
ntoskrnl/mm/balance.c | 1 +
ntoskrnl/mm/section.c | 1 +
ntoskrnl/se/token.c | 7 +-
sdk/include/ddk/aux_klib.h | 4 +
sdk/include/ndk/halfuncs.h | 2 +
sdk/include/xdk/iofuncs.h | 4 +
win32ss/drivers/miniport/pc98vid/ioctl.c | 1 -
win32ss/drivers/miniport/pc98vid/pc98vid.c | 1 -
win32ss/gdi/eng/device.h | 1 +
win32ss/gdi/eng/ldevobj.h | 2 +
win32ss/gdi/eng/pdevobj.h | 1 +
win32ss/gdi/ntgdi/brush.h | 1 +
win32ss/gdi/ntgdi/dc.h | 2 +-
win32ss/gdi/ntgdi/gdiobj.h | 1 +
win32ss/gdi/ntgdi/palette.h | 1 +
win32ss/user/ntuser/dce.h | 2 +-
win32ss/user/ntuser/desktop.h | 1 +
win32ss/user/ntuser/input.h | 4 +-
win32ss/user/ntuser/msgqueue.h | 2 +-
win32ss/user/ntuser/ntuser.h | 2 +-
win32ss/user/ntuser/timer.h | 2 +-
win32ss/user/ntuser/winsta.h | 1 +
82 files changed, 1515 insertions(+), 1584 deletions(-)
diff --git a/drivers/bus/pci/pci.c b/drivers/bus/pci/pci.c
index 5395982747d..5245ccb12cf 100644
--- a/drivers/bus/pci/pci.c
+++ b/drivers/bus/pci/pci.c
@@ -26,16 +26,6 @@ static NTSTATUS NTAPI PciPowerControl(IN PDEVICE_OBJECT DeviceObject,
IN PIRP Ir
static DRIVER_DISPATCH PciPnpControl;
static NTSTATUS NTAPI PciPnpControl(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp);
-
-#ifdef ALLOC_PRAGMA
-
-// Make the initialization routines discardable, so that they
-// don't waste space
-
-#pragma alloc_text(INIT, DriverEntry)
-
-#endif /* ALLOC_PRAGMA */
-
/*** PUBLIC ******************************************************************/
PPCI_DRIVER_EXTENSION DriverExtension = NULL;
@@ -204,6 +194,7 @@ PciUnload(
UNREFERENCED_PARAMETER(DriverObject);
}
+CODE_SEG("INIT")
NTSTATUS
NTAPI
DriverEntry(
diff --git a/drivers/bus/pci/pci.h b/drivers/bus/pci/pci.h
index 3cd2204bf30..94d9ffe31c6 100644
--- a/drivers/bus/pci/pci.h
+++ b/drivers/bus/pci/pci.h
@@ -173,6 +173,8 @@ PdoPowerControl(
PDEVICE_OBJECT DeviceObject,
PIRP Irp);
+
+CODE_SEG("INIT")
NTSTATUS
NTAPI
DriverEntry(
diff --git a/drivers/filesystems/fastfat/fastio.c b/drivers/filesystems/fastfat/fastio.c
index 5f1ab235dc6..6404ab448ae 100644
--- a/drivers/filesystems/fastfat/fastio.c
+++ b/drivers/filesystems/fastfat/fastio.c
@@ -12,10 +12,6 @@
#define NDEBUG
#include <debug.h>
-#if defined(ALLOC_PRAGMA)
-#pragma alloc_text(INIT, VfatInitFastIoRoutines)
-#endif
-
static FAST_IO_CHECK_IF_POSSIBLE VfatFastIoCheckIfPossible;
static
diff --git a/drivers/filesystems/fastfat/vfat.h b/drivers/filesystems/fastfat/vfat.h
index e3e5073c411..d57497c1fa5 100644
--- a/drivers/filesystems/fastfat/vfat.h
+++ b/drivers/filesystems/fastfat/vfat.h
@@ -824,6 +824,7 @@ VfatSetExtendedAttributes(
/* fastio.c */
+CODE_SEG("INIT")
VOID
VfatInitFastIoRoutines(
PFAST_IO_DISPATCH FastIoDispatch);
@@ -1128,6 +1129,7 @@ VfatFileSystemControl(
/* iface.c */
+CODE_SEG("INIT")
NTSTATUS
NTAPI
DriverEntry(
diff --git a/drivers/filesystems/mup/dfs.c b/drivers/filesystems/mup/dfs.c
index 61b54d63dd1..9a7a5a6d696 100644
--- a/drivers/filesystems/mup/dfs.c
+++ b/drivers/filesystems/mup/dfs.c
@@ -31,10 +31,6 @@
#define NDEBUG
#include <debug.h>
-#if defined(ALLOC_PRAGMA)
-#pragma alloc_text(INIT, DfsDriverEntry)
-#endif
-
/* FUNCTIONS ****************************************************************/
NTSTATUS
diff --git a/drivers/filesystems/mup/dfs.h b/drivers/filesystems/mup/dfs.h
index e8268984ba4..0b25be953a9 100644
--- a/drivers/filesystems/mup/dfs.h
+++ b/drivers/filesystems/mup/dfs.h
@@ -51,6 +51,7 @@ DfsUnload(
PDRIVER_OBJECT DriverObject
);
+CODE_SEG("INIT")
NTSTATUS
DfsDriverEntry(
PDRIVER_OBJECT DriverObject,
diff --git a/drivers/filesystems/mup/mup.c b/drivers/filesystems/mup/mup.c
index 760bcfd5368..601d0f33896 100644
--- a/drivers/filesystems/mup/mup.c
+++ b/drivers/filesystems/mup/mup.c
@@ -32,32 +32,6 @@
#define NDEBUG
#include <debug.h>
-CODE_SEG("INIT")
-NTSTATUS
-NTAPI
-DriverEntry(
- PDRIVER_OBJECT DriverObject,
- PUNICODE_STRING RegistryPath
-);
-
-CODE_SEG("INIT")
-VOID
-MupInitializeData(
- VOID
-);
-
-CODE_SEG("INIT")
-VOID
-MupInitializeVcb(
- PMUP_VCB Vcb
-);
-
-#if defined(ALLOC_PRAGMA)
-#pragma alloc_text(INIT, DriverEntry)
-#pragma alloc_text(INIT, MupInitializeData)
-#pragma alloc_text(INIT, MupInitializeVcb)
-#endif
-
ERESOURCE MupGlobalLock;
ERESOURCE MupPrefixTableLock;
ERESOURCE MupCcbListLock;
diff --git a/drivers/filesystems/ntfs/ntfs.c b/drivers/filesystems/ntfs/ntfs.c
index 087d56ccdbd..cfa88f70a50 100644
--- a/drivers/filesystems/ntfs/ntfs.c
+++ b/drivers/filesystems/ntfs/ntfs.c
@@ -21,7 +21,7 @@
* FILE: drivers/filesystem/ntfs/ntfs.c
* PURPOSE: NTFS filesystem driver
* PROGRAMMER: Eric Kohl
- * Pierre Schweitzer
+ * Pierre Schweitzer
*/
/* INCLUDES *****************************************************************/
@@ -31,11 +31,6 @@
#define NDEBUG
#include <debug.h>
-#if defined(ALLOC_PRAGMA)
-#pragma alloc_text(INIT, DriverEntry)
-#pragma alloc_text(INIT, NtfsInitializeFunctionPointers)
-#endif
-
/* GLOBALS *****************************************************************/
PNTFS_GLOBAL_DATA NtfsGlobalData = NULL;
@@ -129,10 +124,10 @@ DriverEntry(PDRIVER_OBJECT DriverObject,
NtfsInitializeFunctionPointers(DriverObject);
/* Initialize CC functions array */
- NtfsGlobalData->CacheMgrCallbacks.AcquireForLazyWrite = NtfsAcqLazyWrite;
- NtfsGlobalData->CacheMgrCallbacks.ReleaseFromLazyWrite = NtfsRelLazyWrite;
- NtfsGlobalData->CacheMgrCallbacks.AcquireForReadAhead = NtfsAcqReadAhead;
- NtfsGlobalData->CacheMgrCallbacks.ReleaseFromReadAhead = NtfsRelReadAhead;
+ NtfsGlobalData->CacheMgrCallbacks.AcquireForLazyWrite = NtfsAcqLazyWrite;
+ NtfsGlobalData->CacheMgrCallbacks.ReleaseFromLazyWrite = NtfsRelLazyWrite;
+ NtfsGlobalData->CacheMgrCallbacks.AcquireForReadAhead = NtfsAcqReadAhead;
+ NtfsGlobalData->CacheMgrCallbacks.ReleaseFromReadAhead = NtfsRelReadAhead;
NtfsGlobalData->FastIoDispatch.SizeOfFastIoDispatch = sizeof(FAST_IO_DISPATCH);
NtfsGlobalData->FastIoDispatch.FastIoCheckIfPossible = NtfsFastIoCheckIfPossible;
@@ -164,7 +159,7 @@ DriverEntry(PDRIVER_OBJECT DriverObject,
/*
- * FUNCTION: Called within the driver entry to initialize the IRP functions array
+ * FUNCTION: Called within the driver entry to initialize the IRP functions array
* ARGUMENTS:
* DriverObject = object describing this driver
* RETURNS: Nothing
diff --git a/drivers/filesystems/ntfs/ntfs.h b/drivers/filesystems/ntfs/ntfs.h
index 9b00ca3ec15..046037edfbc 100644
--- a/drivers/filesystems/ntfs/ntfs.h
+++ b/drivers/filesystems/ntfs/ntfs.h
@@ -1276,8 +1276,10 @@ NtfsSetVolumeInformation(PNTFS_IRP_CONTEXT IrpContext);
/* ntfs.c */
+CODE_SEG("INIT")
DRIVER_INITIALIZE DriverEntry;
+CODE_SEG("INIT")
VOID
NTAPI
NtfsInitializeFunctionPointers(PDRIVER_OBJECT DriverObject);
diff --git a/drivers/filters/fltmgr/Interface.c b/drivers/filters/fltmgr/Interface.c
index b412adec1f0..1eec4521b5b 100644
--- a/drivers/filters/fltmgr/Interface.c
+++ b/drivers/filters/fltmgr/Interface.c
@@ -32,370 +32,8 @@ extern PDEVICE_OBJECT CommsDeviceObject;
extern LIST_ENTRY FilterList;
extern ERESOURCE FilterListLock;
-
-DRIVER_INITIALIZE DriverEntry;
-NTSTATUS
-NTAPI
-DriverEntry(
- _In_ PDRIVER_OBJECT DriverObject,
- _In_ PUNICODE_STRING RegistryPath
-);
-
-static
-NTSTATUS
-SetupDispatchAndCallbacksTables(
- _In_ PDRIVER_OBJECT DriverObject
-);
-
-static
-NTSTATUS
-FltpAttachDeviceObject(
- _In_ PDEVICE_OBJECT SourceDevice,
- _In_ PDEVICE_OBJECT TargetDevice,
- _Out_ PDEVICE_OBJECT *AttachedToDeviceObject
-);
-
-static
-VOID
-FltpCleanupDeviceObject(
- _In_ PDEVICE_OBJECT DeviceObject
-);
-
-static
-BOOLEAN
-FltpIsAttachedToDevice(
- _In_ PDEVICE_OBJECT DeviceObject,
- _In_opt_ PDEVICE_OBJECT *AttachedDeviceObject
-);
-
-static
-NTSTATUS
-FltpEnumerateFileSystemVolumes(
- _In_ PDEVICE_OBJECT DeviceObject
-);
-
-static
-NTSTATUS
-FltpAttachToFileSystemDevice(
- _In_ PDEVICE_OBJECT DeviceObject,
- _In_ PUNICODE_STRING DeviceName
-);
-
-static
-LONG_PTR
-FltpDetachFromFileSystemDevice(
- _In_ PDEVICE_OBJECT DeviceObject
-);
-
-DRIVER_FS_NOTIFICATION FltpFsNotification;
-VOID
-NTAPI
-FltpFsNotification(
- _In_ PDEVICE_OBJECT DeviceObject,
- _In_ BOOLEAN FsActive
-);
-
-NTSTATUS
-NTAPI
-FltpDispatch(
- _In_ PDEVICE_OBJECT DeviceObject,
- _Inout_ PIRP Irp
-);
-
-NTSTATUS
-NTAPI
-FltpCreate(
- _In_ PDEVICE_OBJECT DeviceObject,
- _Inout_ PIRP Irp
-);
-
-NTSTATUS
-NTAPI
-FltpFsControl(
- _In_ PDEVICE_OBJECT DeviceObject,
- _Inout_ PIRP Irp
-);
-
-NTSTATUS
-NTAPI
-FltpDeviceControl(
- _In_ PDEVICE_OBJECT DeviceObject,
- _Inout_ PIRP Irp
-);
-
-BOOLEAN
-NTAPI
-FltpFastIoCheckIfPossible(
- _In_ PFILE_OBJECT FileObject,
- _In_ PLARGE_INTEGER FileOffset,
- _In_ ULONG Length,
- _In_ BOOLEAN Wait,
- _In_ ULONG LockKey,
- _In_ BOOLEAN CheckForReadOperation,
- _Out_ PIO_STATUS_BLOCK IoStatus,
- _In_ PDEVICE_OBJECT DeviceObject
-);
-
-
-BOOLEAN
-NTAPI
-FltpFastIoRead(
- _In_ PFILE_OBJECT FileObject,
- _In_ PLARGE_INTEGER FileOffset,
- _In_ ULONG Length,
- _In_ BOOLEAN Wait,
- _In_ ULONG LockKey,
- _Out_ PVOID Buffer,
- _Out_ PIO_STATUS_BLOCK IoStatus,
- _In_ PDEVICE_OBJECT DeviceObject
-);
-
-BOOLEAN
-NTAPI
-FltpFastIoWrite(
- _In_ PFILE_OBJECT FileObject,
- _In_ PLARGE_INTEGER FileOffset,
- _In_ ULONG Length,
- _In_ BOOLEAN Wait,
- _In_ ULONG LockKey,
- _In_ PVOID Buffer,
- _Out_ PIO_STATUS_BLOCK IoStatus,
- _In_ PDEVICE_OBJECT DeviceObject
-);
-
-BOOLEAN
-NTAPI
-FltpFastIoQueryBasicInfo(
- _In_ PFILE_OBJECT FileObject,
- _In_ BOOLEAN Wait,
- _Out_ PFILE_BASIC_INFORMATION Buffer,
- _Out_ PIO_STATUS_BLOCK IoStatus,
- _In_ PDEVICE_OBJECT DeviceObject
-);
-
-BOOLEAN
-NTAPI
-FltpFastIoQueryStandardInfo(
- _In_ PFILE_OBJECT FileObject,
- _In_ BOOLEAN Wait,
- _Out_ PFILE_STANDARD_INFORMATION Buffer,
- _Out_ PIO_STATUS_BLOCK IoStatus,
- _In_ PDEVICE_OBJECT DeviceObject
-);
-
-BOOLEAN
-NTAPI
-FltpFastIoLock(
- _In_ PFILE_OBJECT FileObject,
- _In_ PLARGE_INTEGER FileOffset,
- _In_ PLARGE_INTEGER Length,
- _In_ PEPROCESS ProcessId,
- _In_ ULONG Key,
- _In_ BOOLEAN FailImmediately,
- _In_ BOOLEAN ExclusiveLock,
- _Out_ PIO_STATUS_BLOCK IoStatus,
- _In_ PDEVICE_OBJECT DeviceObject
-);
-
-BOOLEAN
-NTAPI
-FltpFastIoUnlockSingle(
- _In_ PFILE_OBJECT FileObject,
- _In_ PLARGE_INTEGER FileOffset,
- _In_ PLARGE_INTEGER Length,
- _In_ PEPROCESS ProcessId,
- _In_ ULONG Key,
- _Out_ PIO_STATUS_BLOCK IoStatus,
- _In_ PDEVICE_OBJECT DeviceObject
-);
-
-BOOLEAN
-NTAPI
-FltpFastIoUnlockAll(
- _In_ PFILE_OBJECT FileObject,
- _In_ PEPROCESS ProcessId,
- _Out_ PIO_STATUS_BLOCK IoStatus,
- _In_ PDEVICE_OBJECT DeviceObject
-);
-
-BOOLEAN
-NTAPI
-FltpFastIoUnlockAllByKey(
- _In_ PFILE_OBJECT FileObject,
- _In_ PVOID ProcessId,
- _In_ ULONG Key,
- _Out_ PIO_STATUS_BLOCK IoStatus,
- _In_ PDEVICE_OBJECT DeviceObject
-);
-
-BOOLEAN
-NTAPI
-FltpFastIoDeviceControl(
- _In_ PFILE_OBJECT FileObject,
- _In_ BOOLEAN Wait,
- _In_opt_ PVOID InputBuffer,
- _In_ ULONG InputBufferLength,
- _Out_opt_ PVOID OutputBuffer,
- _In_ ULONG OutputBufferLength,
- _In_ ULONG IoControlCode,
- _Out_ PIO_STATUS_BLOCK IoStatus,
- _In_ PDEVICE_OBJECT DeviceObject
-);
-
-VOID
-NTAPI
-FltpFastIoDetachDevice(
- _In_ PDEVICE_OBJECT SourceDevice,
- _In_ PDEVICE_OBJECT TargetDevice
-);
-
-BOOLEAN
-NTAPI
-FltpFastIoQueryNetworkOpenInfo(
- _In_ PFILE_OBJECT FileObject,
- _In_ BOOLEAN Wait,
- _Out_ PFILE_NETWORK_OPEN_INFORMATION Buffer,
- _Out_ PIO_STATUS_BLOCK IoStatus,
- _In_ PDEVICE_OBJECT DeviceObject
-);
-
-BOOLEAN
-NTAPI
-FltpFastIoMdlRead(
- _In_ PFILE_OBJECT FileObject,
- _In_ PLARGE_INTEGER FileOffset,
- _In_ ULONG Length,
- _In_ ULONG LockKey,
- _Out_ PMDL *MdlChain,
- _Out_ PIO_STATUS_BLOCK IoStatus,
- _In_ PDEVICE_OBJECT DeviceObject
-);
-
-BOOLEAN
-NTAPI
-FltpFastIoMdlReadComplete(
- _In_ PFILE_OBJECT FileObject,
- _In_ PMDL MdlChain,
- _In_ PDEVICE_OBJECT DeviceObject
-);
-
-BOOLEAN
-NTAPI
-FltpFastIoPrepareMdlWrite(
- _In_ PFILE_OBJECT FileObject,
- _In_ PLARGE_INTEGER FileOffset,
- _In_ ULONG Length,
- _In_ ULONG LockKey,
- _Out_ PMDL *MdlChain,
- _Out_ PIO_STATUS_BLOCK IoStatus,
- _In_ PDEVICE_OBJECT DeviceObject
-);
-
-BOOLEAN
-NTAPI
-FltpFastIoMdlWriteComplete(
- _In_ PFILE_OBJECT FileObject,
- _In_ PLARGE_INTEGER FileOffset,
- _In_ PMDL MdlChain,
- _In_ PDEVICE_OBJECT DeviceObject
-);
-
-BOOLEAN
-NTAPI
-FltpFastIoReadCompressed(
- _In_ PFILE_OBJECT FileObject,
- _In_ PLARGE_INTEGER FileOffset,
- _In_ ULONG Length,
- _In_ ULONG LockKey,
- _Out_ PVOID Buffer,
- _Out_ PMDL *MdlChain,
- _Out_ PIO_STATUS_BLOCK IoStatus,
- _Out_ PCOMPRESSED_DATA_INFO CompressedDataInfo,
- _In_ ULONG CompressedDataInfoLength,
- _In_ PDEVICE_OBJECT DeviceObject
-);
-
-BOOLEAN
-NTAPI
-FltpFastIoWriteCompressed(
- _In_ PFILE_OBJECT FileObject,
- _In_ PLARGE_INTEGER FileOffset,
- _In_ ULONG Length,
- _In_ ULONG LockKey,
- _In_ PVOID Buffer,
- _Out_ PMDL *MdlChain,
- _Out_ PIO_STATUS_BLOCK IoStatus,
- _In_ PCOMPRESSED_DATA_INFO CompressedDataInfo,
- _In_ ULONG CompressedDataInfoLength,
- _In_ PDEVICE_OBJECT DeviceObject
-);
-
-BOOLEAN
-NTAPI
-FltpFastIoMdlReadCompleteCompressed(
- _In_ PFILE_OBJECT FileObject,
- _In_ PMDL MdlChain,
- _In_ PDEVICE_OBJECT DeviceObject
-);
-
-BOOLEAN
-NTAPI
-FltpFastIoMdlWriteCompleteCompressed(
- _In_ PFILE_OBJECT FileObject,
- _In_ PLARGE_INTEGER FileOffset,
- _In_ PMDL MdlChain,
- _In_ PDEVICE_OBJECT DeviceObject
-);
-
-BOOLEAN
-NTAPI
-FltpFastIoQueryOpen(
- _Inout_ PIRP Irp,
- _Out_ PFILE_NETWORK_OPEN_INFORMATION NetworkInformation,
- _In_ PDEVICE_OBJECT DeviceObject
-);
-
-
-
-#ifdef ALLOC_PRAGMA
-#pragma alloc_text(INIT, DriverEntry)
-#pragma alloc_text(INIT, SetupDispatchAndCallbacksTables)
-#pragma alloc_text(PAGE, FltpAttachDeviceObject)
-#pragma alloc_text(PAGE, FltpIsAttachedToDevice)
-#pragma alloc_text(PAGE, FltpEnumerateFileSystemVolumes)
-#pragma alloc_text(PAGE, FltpAttachToFileSystemDevice)
-#pragma alloc_text(PAGE, FltpDetachFromFileSystemDevice)
-#pragma alloc_text(PAGE, FltpFsNotification)
-#pragma alloc_text(PAGE, FltpCreate)
-#pragma alloc_text(PAGE, FltpFsControl)
-#pragma alloc_text(PAGE, FltpDeviceControl)
-#pragma alloc_text(PAGE, FltpFastIoRead)
-#pragma alloc_text(PAGE, FltpFastIoWrite)
-#pragma alloc_text(PAGE, FltpFastIoQueryBasicInfo)
-#pragma alloc_text(PAGE, FltpFastIoQueryStandardInfo)
-#pragma alloc_text(PAGE, FltpFastIoLock)
-#pragma alloc_text(PAGE, FltpFastIoUnlockSingle)
-#pragma alloc_text(PAGE, FltpFastIoUnlockAll)
-#pragma alloc_text(PAGE, FltpFastIoUnlockAllByKey)
-#pragma alloc_text(PAGE, FltpFastIoDeviceControl)
-#pragma alloc_text(PAGE, FltpFastIoDetachDevice)
-#pragma alloc_text(PAGE, FltpFastIoQueryNetworkOpenInfo)
-#pragma alloc_text(PAGE, FltpFastIoMdlRead)
-#pragma alloc_text(PAGE, FltpFastIoMdlReadComplete)
-#pragma alloc_text(PAGE, FltpFastIoPrepareMdlWrite)
-#pragma alloc_text(PAGE, FltpFastIoMdlWriteComplete)
-#pragma alloc_text(PAGE, FltpFastIoReadCompressed)
-#pragma alloc_text(PAGE, FltpFastIoWriteCompressed)
-#pragma alloc_text(PAGE, FltpFastIoMdlReadCompleteCompressed)
-#pragma alloc_text(PAGE, FltpFastIoMdlWriteCompleteCompressed)
-#pragma alloc_text(PAGE, FltpFastIoQueryOpen)
-#endif
-
-
-
DRIVER_DATA DriverData;
-
typedef struct _DETACH_DEVICE_WORK_ITEM
{
WORK_QUEUE_ITEM WorkItem;
@@ -404,501 +42,629 @@ typedef struct _DETACH_DEVICE_WORK_ITEM
} DETACH_DEVICE_WORK_ITEM, *PDETACH_DEVICE_WORK_ITEM;
+/* LOCAL FUNCTIONS ****************************************/
-/* DISPATCH ROUTINES **********************************************/
-
-NTSTATUS
-NTAPI
-FltpPreFsFilterOperation(_In_ PFS_FILTER_CALLBACK_DATA Data,
- _Out_ PVOID *CompletionContext)
-{
- UNREFERENCED_PARAMETER(Data);
- UNREFERENCED_PARAMETER(CompletionContext);
- __debugbreak();
- return STATUS_SUCCESS;
-}
-
+static
VOID
-NTAPI
-FltpPostFsFilterOperation(_In_ PFS_FILTER_CALLBACK_DATA Data,
- _In_ NTSTATUS OperationStatus,
- _In_ PVOID CompletionContext)
+FltpCleanupDeviceObject(_In_ PDEVICE_OBJECT DeviceObject)
{
- UNREFERENCED_PARAMETER(Data);
- UNREFERENCED_PARAMETER(OperationStatus);
- UNREFERENCED_PARAMETER(CompletionContext);
- __debugbreak();
+ PFLTMGR_DEVICE_EXTENSION DeviceExtension;
+
+ DeviceExtension = DeviceObject->DeviceExtension;
+ if (DeviceExtension)
+ {
+ // cleanup device extension
+ }
}
+CODE_SEG("PAGE")
+static
NTSTATUS
-NTAPI
-FltpDispatch(_In_ PDEVICE_OBJECT DeviceObject,
- _Inout_ PIRP Irp)
+FltpAttachDeviceObject(_In_ PDEVICE_OBJECT SourceDevice,
+ _In_ PDEVICE_OBJECT TargetDevice,
+ _Out_ PDEVICE_OBJECT *AttachedToDeviceObject)
{
- PFLTMGR_DEVICE_EXTENSION DeviceExtension;
- PIO_STACK_LOCATION StackPtr;
NTSTATUS Status;
- DeviceExtension = DeviceObject->DeviceExtension;
+ PAGED_CODE();
- /* Check if this is a request for us */
- if (DeviceObject == DriverData.DeviceObject)
+ /* Before attaching, copy the flags from the device we're going to attach to */
+ if (FlagOn(SourceDevice->Flags, DO_BUFFERED_IO))
{
- FLT_ASSERT(DeviceObject->DriverObject == DriverData.DriverObject);
- FLT_ASSERT(DeviceExtension == NULL);
-
- /* Hand it off to our internal handler */
- Status = FltpDispatchHandler(DeviceObject, Irp);
- if (Status != STATUS_REPARSE)
- {
- Irp->IoStatus.Status = Status;
- Irp->IoStatus.Information = 0;
- IoCompleteRequest(Irp, 0);
- }
- return Status;
+ SetFlag(TargetDevice->Flags, DO_BUFFERED_IO);
}
-
- /* Check if this is a request for a the messaging device */
- if (DeviceObject == CommsDeviceObject)
+ if (FlagOn(SourceDevice->Flags, DO_DIRECT_IO))
{
- /* Hand off to our internal routine */
- return FltpMsgDispatch(DeviceObject, Irp);
+ SetFlag(TargetDevice->Flags, DO_DIRECT_IO);
}
-
- FLT_ASSERT(DeviceExtension &&
- DeviceExtension->AttachedToDeviceObject);
-
- StackPtr = IoGetCurrentIrpStackLocation(Irp);
- if (StackPtr->MajorFunction == IRP_MJ_SHUTDOWN)
+ if (FlagOn(SourceDevice->Flags, DO_SYSTEM_BOOT_PARTITION))
{
- // handle shutdown request
+ SetFlag(TargetDevice->Characteristics, FILE_DEVICE_SECURE_OPEN);
}
- DPRINT1("Received %X from %wZ\n", StackPtr->MajorFunction,
&DeviceExtension->DeviceName);
+ /* Attach this device to the top of the driver stack */
+ Status = IoAttachDeviceToDeviceStackSafe(SourceDevice,
+ TargetDevice,
+ AttachedToDeviceObject);
- /* Just pass the IRP down the stack */
- IoSkipCurrentIrpStackLocation(Irp);
- return IoCallDriver(DeviceExtension->AttachedToDeviceObject, Irp);
+ return Status;
}
-NTSTATUS
-NTAPI
-FltpCreate(_In_ PDEVICE_OBJECT DeviceObject,
- _Inout_ PIRP Irp)
+CODE_SEG("PAGE")
+static
+BOOLEAN
+FltpIsAttachedToDevice(_In_ PDEVICE_OBJECT DeviceObject,
+ _In_opt_ PDEVICE_OBJECT *AttachedDeviceObject)
{
- PFLTMGR_DEVICE_EXTENSION DeviceExtension;
+ PDEVICE_OBJECT CurrentDeviceObject;
+ PDEVICE_OBJECT NextDeviceObject;
PAGED_CODE();
- DeviceExtension = DeviceObject->DeviceExtension;
+ /* Initialize the return pointer */
+ if (AttachedDeviceObject) *AttachedDeviceObject = NULL;
- /* Check if this is a request for us */
- if (DeviceObject == DriverData.DeviceObject)
+ /* Start by getting the top level device in the chain */
+ CurrentDeviceObject = IoGetAttachedDeviceReference(DeviceObject);
+
+ /* Loop while there are attached devices */
+ while (CurrentDeviceObject)
{
- FLT_ASSERT(DeviceObject->DriverObject == DriverData.DriverObject);
- FLT_ASSERT(DeviceExtension == NULL);
+ /* Check if this device driver matches ours */
+ if (CurrentDeviceObject->DriverObject == DriverData.DriverObject)
+ {
+ FLT_ASSERT(CurrentDeviceObject->DeviceExtension != NULL);
- /* Someone wants a handle to the fltmgr, allow it */
- Irp->IoStatus.Status = STATUS_SUCCESS;
- Irp->IoStatus.Information = 0;
- IofCompleteRequest(Irp, 0);
- return STATUS_SUCCESS;
- }
+ /* We're attached, return the device object if the caller asked for it
*/
+ if (AttachedDeviceObject)
+ {
+ *AttachedDeviceObject = CurrentDeviceObject;
+ }
+ else
+ {
+ /* We aren't returning the reference, so decrement the count */
+ ObDereferenceObject(CurrentDeviceObject);
+ }
- /* Check if this is a request for a the new comms connection */
- if (DeviceObject == CommsDeviceObject)
- {
- /* Hand off to our internal routine */
- return FltpMsgCreate(DeviceObject, Irp);
- }
+ return TRUE;
+ }
- FLT_ASSERT(DeviceExtension &&
- DeviceExtension->AttachedToDeviceObject);
+ /* Get the next device in the chain */
+ NextDeviceObject = IoGetLowerDeviceObject(CurrentDeviceObject);
- DPRINT1("Received create from %wZ (%lu)\n",
&DeviceExtension->DeviceName, PsGetCurrentProcessId());
+ /* Decrement the count on the last device before we update the pointer */
+ ObDereferenceObject(CurrentDeviceObject);
+ CurrentDeviceObject = NextDeviceObject;
+ }
- /* Just pass the IRP down the stack */
- IoSkipCurrentIrpStackLocation(Irp);
- return IoCallDriver(DeviceExtension->AttachedToDeviceObject, Irp);
+ return FALSE;
}
+CODE_SEG("PAGE")
+static
NTSTATUS
-NTAPI
-FltpFsControl(_In_ PDEVICE_OBJECT DeviceObject,
- _Inout_ PIRP Irp)
+FltpEnumerateFileSystemVolumes(_In_ PDEVICE_OBJECT DeviceObject)
{
- PFLTMGR_DEVICE_EXTENSION DeviceExtension;
+ PFLTMGR_DEVICE_EXTENSION NewDeviceExtension;
+ PDEVICE_OBJECT BaseDeviceObject;
+ PDEVICE_OBJECT NewDeviceObject;
+ PDEVICE_OBJECT *DeviceList;
+ PDEVICE_OBJECT StorageStackDeviceObject;
+ UNICODE_STRING DeviceName;
+ ULONG NumDevices;
+ ULONG i;
+ NTSTATUS Status;
PAGED_CODE();
- /* Check if this is a request for us */
- if (DeviceObject == DriverData.DeviceObject)
+ /* Get the base device */
+ BaseDeviceObject = IoGetDeviceAttachmentBaseRef(DeviceObject);
+
+ /* get the number of device object linked to the base file system */
+ Status = IoEnumerateDeviceObjectList(BaseDeviceObject->DriverObject,
+ NULL,
+ 0,
+ &NumDevices);
+ if (Status != STATUS_BUFFER_TOO_SMALL) return Status;
+
+ /* Add a few more slots in case the size changed between calls and allocate some
memory to hold the pointers */
+ NumDevices += 4;
+ DeviceList = ExAllocatePoolWithTag(NonPagedPool,
+ (NumDevices * sizeof(PDEVICE_OBJECT)),
+ FM_TAG_DEV_OBJ_PTRS);
+ if (DeviceList == NULL) return STATUS_INSUFFICIENT_RESOURCES;
+
+ /* Now get all the device objects that this base driver has created */
+ Status = IoEnumerateDeviceObjectList(BaseDeviceObject->DriverObject,
+ DeviceList,
+ (NumDevices * sizeof(PDEVICE_OBJECT)),
+ &NumDevices);
+ if (!NT_SUCCESS(Status))
{
- /* We don't handle this request */
- Irp->IoStatus.Information = 0;
- Irp->IoStatus.Status = STATUS_INVALID_DEVICE_REQUEST;
- IofCompleteRequest(Irp, 0);
- return STATUS_INVALID_DEVICE_REQUEST;
+ ExFreePoolWithTag(DeviceList, FM_TAG_DEV_OBJ_PTRS);
+ return Status;
}
- DeviceExtension = DeviceObject->DeviceExtension;
+ /* Loop through all the devices looking for ones to attach to */
+ for (i = 0; i < NumDevices; i++)
+ {
+ RtlInitUnicodeString(&DeviceName, NULL);
+ StorageStackDeviceObject = NULL;
+ NewDeviceObject = NULL;
- FLT_ASSERT(DeviceExtension &&
- DeviceExtension->AttachedToDeviceObject);
+ /* Ignore the device we passed in, and devices of the wrong type */
+ if ((DeviceList[i] == BaseDeviceObject) ||
+ (DeviceList[i]->DeviceType != BaseDeviceObject->DeviceType))
+ {
+ goto CleanupAndNext;
+ }
- /* Just pass the IRP down the stack */
- IoSkipCurrentIrpStackLocation(Irp);
- return IoCallDriver(DeviceExtension->AttachedToDeviceObject, Irp);
-}
+ /* Ignore this device if we're already attached to it */
+ if (FltpIsAttachedToDevice(DeviceList[i], NULL) == FALSE)
+ {
+ goto CleanupAndNext;
+ }
-NTSTATUS
-NTAPI
-FltpDeviceControl(_In_ PDEVICE_OBJECT DeviceObject,
- _Inout_ PIRP Irp)
-{
- PFLTMGR_DEVICE_EXTENSION DeviceExtension;
- NTSTATUS Status;
- /* Check if the request was meant for us */
- if (DeviceObject == DriverData.DeviceObject)
- {
- Status = FltpDeviceControlHandler(DeviceObject, Irp);
- if (Status != STATUS_REPARSE)
+ /*
+ * If the device has a name, it must be a control device.
+ * This handles drivers with more then one control device (like FastFat)
+ */
+ FltpGetBaseDeviceObjectName(DeviceList[i], &DeviceName);
+ if (NT_SUCCESS(Status) && DeviceName.Length > 0)
{
- Irp->IoStatus.Status = Status;
- Irp->IoStatus.Information = 0;
- IoCompleteRequest(Irp, 0);
+ goto CleanupAndNext;
}
- return Status;
- }
+ /*
+ * Try to get the storage stack (disk) device object associated with
+ * this file system device object. Ignore the device if we don't have one
+ */
+ Status = IoGetDiskDeviceObject(DeviceList[i],
+ &StorageStackDeviceObject);
+ if (!NT_SUCCESS(Status))
+ {
+ goto CleanupAndNext;
+ }
- DeviceExtension = DeviceObject->DeviceExtension;
- FLT_ASSERT(DeviceExtension &&
- DeviceExtension->AttachedToDeviceObject);
+ /*
+ * TODO: Don't attach to shadow copy volumes,
+ * ros doesn't have any so it's not an issues yet
+ */
- /* Just pass the IRP down the stack */
- IoSkipCurrentIrpStackLocation(Irp);
- return IoCallDriver(DeviceExtension->AttachedToDeviceObject, Irp);
-}
+ /*
+ * We're far enough to be ready to attach, create a device
+ * object which we'll use to do so
+ */
+ Status = IoCreateDevice(DriverData.DriverObject,
+ sizeof(FLTMGR_DEVICE_EXTENSION),
+ NULL,
+ DeviceList[i]->DeviceType,
+ 0,
+ FALSE,
+ &NewDeviceObject);
+ if (!NT_SUCCESS(Status))
+ {
+ goto CleanupAndNext;
+ }
+ /* Get the device extension for this new object and store our disk object there
*/
+ NewDeviceExtension = NewDeviceObject->DeviceExtension;
+ NewDeviceExtension->StorageStackDeviceObject = StorageStackDeviceObject;
+ /* Lookup and store the device name for the storage stack */
+ RtlInitEmptyUnicodeString(&NewDeviceExtension->DeviceName,
+ NewDeviceExtension->DeviceNameBuffer,
+ sizeof(NewDeviceExtension->DeviceNameBuffer));
+ FltpGetObjectName(StorageStackDeviceObject,
+ &NewDeviceExtension->DeviceName);
-/* FASTIO ROUTINES ************************************************/
-BOOLEAN
-NTAPI
-FltpFastIoCheckIfPossible(_In_ PFILE_OBJECT FileObject,
- _In_ PLARGE_INTEGER FileOffset,
- _In_ ULONG Length,
- _In_ BOOLEAN Wait,
- _In_ ULONG LockKey,
- _In_ BOOLEAN CheckForReadOperation,
- _Out_ PIO_STATUS_BLOCK IoStatus,
- _In_ PDEVICE_OBJECT DeviceObject)
+ /* Grab the attach lock before we attempt to attach */
+ ExAcquireFastMutex(&DriverData.FilterAttachLock);
-{
- PFLTMGR_DEVICE_EXTENSION DeviceExtension;
- PDEVICE_OBJECT AttachedDeviceObject;
- PFAST_IO_DISPATCH FastIoDispatch;
+ /* Check again that we aren't already attached. It may have changed since our
last check */
+ if (FltpIsAttachedToDevice(DeviceList[i], NULL) == FALSE)
+ {
+ FLT_ASSERT(NewDeviceObject->DriverObject == DriverData.DriverObject);
- PAGED_CODE();
+ /* Finally, attach to the volume */
+ Status = FltpAttachDeviceObject(DeviceList[i],
+ NewDeviceObject,
+
&NewDeviceExtension->AttachedToDeviceObject);
+ if (NT_SUCCESS(Status))
+ {
+ /* Clean the initializing flag so other filters can attach to our device
object */
+ ClearFlag(NewDeviceObject->Flags, DO_DEVICE_INITIALIZING);
+ }
+ }
+ else
+ {
+ /* We're already attached. Just cleanup */
+ Status = STATUS_DEVICE_ALREADY_ATTACHED;
+ }
- /* If it doesn't have a device extension, then it's not our device object */
- if (DeviceObject->DeviceExtension == NULL)
- {
- /* Fail the call */
- IoStatus->Status = STATUS_INVALID_DEVICE_REQUEST;
- IoStatus->Information = 0;
- return TRUE;
- }
+ ExReleaseFastMutex(&DriverData.FilterAttachLock);
- DeviceExtension = DeviceObject->DeviceExtension;
- FLT_ASSERT(DeviceExtension->AttachedToDeviceObject);
+CleanupAndNext:
- /* Get the device that we attached to */
- AttachedDeviceObject = DeviceExtension->AttachedToDeviceObject;
- FastIoDispatch = AttachedDeviceObject->DriverObject->FastIoDispatch;
+ if (!NT_SUCCESS(Status))
+ {
+ if (NewDeviceObject)
+ {
+ FltpCleanupDeviceObject(NewDeviceObject);
+ IoDeleteDevice(NewDeviceObject);
+ }
+ }
+
+ if (StorageStackDeviceObject)
+ {
+ /* A ref was added for us when we attached, so we can deref ours now */
+ ObDereferenceObject(StorageStackDeviceObject);
+ }
+
+ /* Remove the ref which was added by IoEnumerateDeviceObjectList */
+ ObDereferenceObject(DeviceList[i]);
+
+ /* Free the buffer that FltpGetBaseDeviceObjectName added */
+ FltpFreeUnicodeString(&DeviceName);
- /* Make sure our FastIo table is valid */
- if (FastIoDispatch && FastIoDispatch->FastIoCheckIfPossible)
- {
- /* Forward the call onto the device we attached to */
- return FastIoDispatch->FastIoCheckIfPossible(FileObject,
- FileOffset,
- Length,
- Wait,
- LockKey,
- CheckForReadOperation,
- IoStatus,
- AttachedDeviceObject);
}
- /* We failed to handle the request, send it down the slow path */
- FLT_ASSERT(FALSE);
- return FALSE;
+ /* Free the memory we allocated for the list */
+ ExFreePoolWithTag(DeviceList, FM_TAG_DEV_OBJ_PTRS);
+
+ return STATUS_SUCCESS;
}
-BOOLEAN
-NTAPI
-FltpFastIoRead(_In_ PFILE_OBJECT FileObject,
- _In_ PLARGE_INTEGER FileOffset,
- _In_ ULONG Length,
- _In_ BOOLEAN Wait,
- _In_ ULONG LockKey,
- _Out_ PVOID Buffer,
- _Out_ PIO_STATUS_BLOCK IoStatus,
- _In_ PDEVICE_OBJECT DeviceObject)
+CODE_SEG("PAGE")
+static
+NTSTATUS
+FltpAttachToFileSystemDevice(_In_ PDEVICE_OBJECT DeviceObject,
+ _In_ PUNICODE_STRING DeviceName)
{
PFLTMGR_DEVICE_EXTENSION DeviceExtension;
- PDEVICE_OBJECT AttachedDeviceObject;
- PFAST_IO_DISPATCH FastIoDispatch;
+ PDEVICE_OBJECT NewDeviceObject;
+ WCHAR Buffer[MAX_DEVNAME_LENGTH];
+ UNICODE_STRING FileSystemDeviceName;
+ UNICODE_STRING FsRecDeviceName;
+ NTSTATUS Status;
PAGED_CODE();
- /* If it doesn't have a device extension, then it's not our device object */
- if (DeviceObject->DeviceExtension == NULL)
- {
- /* Fail the call */
- IoStatus->Status = STATUS_INVALID_DEVICE_REQUEST;
- IoStatus->Information = 0;
- return TRUE;
- }
-
- DeviceExtension = DeviceObject->DeviceExtension;
- FLT_ASSERT(DeviceExtension->AttachedToDeviceObject);
-
- /* Get the device that we attached to */
- AttachedDeviceObject = DeviceExtension->AttachedToDeviceObject;
- FastIoDispatch = AttachedDeviceObject->DriverObject->FastIoDispatch;
-
- /* Make sure our FastIo table is valid */
- if (FastIoDispatch && FastIoDispatch->FastIoRead)
+ /* Only handle device types we're interested in */
+ if (DeviceObject->DeviceType != FILE_DEVICE_DISK_FILE_SYSTEM &&
+ DeviceObject->DeviceType != FILE_DEVICE_CD_ROM_FILE_SYSTEM &&
+ DeviceObject->DeviceType != FILE_DEVICE_NETWORK_FILE_SYSTEM)
{
- /* Forward the call onto the device we attached to */
- return FastIoDispatch->FastIoRead(FileObject,
- FileOffset,
- Length,
- Wait,
- LockKey,
- Buffer,
- IoStatus,
- AttachedDeviceObject);
+ return STATUS_SUCCESS;
}
- /* We failed to handle the request, send it down the slow path */
- FLT_ASSERT(FALSE);
- return FALSE;
-}
+ /* Setup the buffer to hold the device name */
+ RtlInitEmptyUnicodeString(&FileSystemDeviceName,
+ Buffer,
+ MAX_DEVNAME_LENGTH * sizeof(WCHAR));
-BOOLEAN
-NTAPI
-FltpFastIoWrite(_In_ PFILE_OBJECT FileObject,
- _In_ PLARGE_INTEGER FileOffset,
- _In_ ULONG Length,
- _In_ BOOLEAN Wait,
- _In_ ULONG LockKey,
- _In_ PVOID Buffer,
- _Out_ PIO_STATUS_BLOCK IoStatus,
- _In_ PDEVICE_OBJECT DeviceObject)
-{
- PFLTMGR_DEVICE_EXTENSION DeviceExtension;
- PDEVICE_OBJECT AttachedDeviceObject;
- PFAST_IO_DISPATCH FastIoDispatch;
+ /* Get the the name of the file system device */
+ Status = FltpGetObjectName(DeviceObject->DriverObject,
&FileSystemDeviceName);
+ if (!NT_SUCCESS(Status)) return Status;
- PAGED_CODE();
+ DPRINT("Found device %wZ, checking if we need to attach...\n",
&FileSystemDeviceName);
- /* If it doesn't have a device extension, then it's not our device object */
- if (DeviceObject->DeviceExtension == NULL)
+ /* Build up the name of the file system recognizer device */
+ RtlInitUnicodeString(&FsRecDeviceName, L"\\FileSystem\\Fs_Rec");
+
+ /* We don't attach to recognizer devices, so bail if this is one */
+ if (RtlCompareUnicodeString(&FileSystemDeviceName, &FsRecDeviceName, TRUE) ==
0)
{
- /* Fail the call */
- IoStatus->Status = STATUS_INVALID_DEVICE_REQUEST;
- IoStatus->Information = 0;
- return TRUE;
+ return STATUS_SUCCESS;
}
- DeviceExtension = DeviceObject->DeviceExtension;
- FLT_ASSERT(DeviceExtension->AttachedToDeviceObject);
+ /* Create a device object which we can attach to this file system */
+ Status = IoCreateDevice(DriverData.DriverObject,
+ sizeof(FLTMGR_DEVICE_EXTENSION),
+ NULL,
+ DeviceObject->DeviceType,
+ 0,
+ FALSE,
+ &NewDeviceObject);
+ if (!NT_SUCCESS(Status))
+ {
+ DPRINT1("Failed to create a DO for attaching to a FS : 0x%X\n",
Status);
+ return Status;
+ }
- /* Get the device that we attached to */
- AttachedDeviceObject = DeviceExtension->AttachedToDeviceObject;
- FastIoDispatch = AttachedDeviceObject->DriverObject->FastIoDispatch;
+ /* Cast the device extension to something we understand */
+ DeviceExtension = NewDeviceObject->DeviceExtension;
- /* Make sure our FastIo table is valid */
- if (FastIoDispatch && FastIoDispatch->FastIoWrite)
+ /* Attach this device to the top of the driver stack and store the DO we attached to
in the DE */
+ Status = FltpAttachDeviceObject(NewDeviceObject,
+ DeviceObject,
+ &DeviceExtension->AttachedToDeviceObject);
+ if (NT_SUCCESS(Status))
{
- /* Forward the call onto the device we attached to */
- return FastIoDispatch->FastIoWrite(FileObject,
- FileOffset,
- Length,
- Wait,
- LockKey,
- Buffer,
- IoStatus,
- AttachedDeviceObject);
+ DPRINT("Attached to %wZ\n", &FileSystemDeviceName);
+ }
+ else
+ {
+ DPRINT1("Failed to attach to the driver stack : 0x%X\n", Status);
+ goto Cleanup;
}
- /* We failed to handle the request, send it down the slow path */
- FLT_ASSERT(FALSE);
- return FALSE;
-}
-
-BOOLEAN
-NTAPI
-FltpFastIoQueryBasicInfo(_In_ PFILE_OBJECT FileObject,
- _In_ BOOLEAN Wait,
- _Out_ PFILE_BASIC_INFORMATION Buffer,
- _Out_ PIO_STATUS_BLOCK IoStatus,
- _In_ PDEVICE_OBJECT DeviceObject)
-{
- PFLTMGR_DEVICE_EXTENSION DeviceExtension;
- PDEVICE_OBJECT AttachedDeviceObject;
- PFAST_IO_DISPATCH FastIoDispatch;
+ /* Setup the unicode string buffer and copy the device name to the device extension
*/
+ RtlInitEmptyUnicodeString(&DeviceExtension->DeviceName,
+ DeviceExtension->DeviceNameBuffer,
+ MAX_DEVNAME_LENGTH * sizeof(WCHAR));
+ RtlCopyUnicodeString(&DeviceExtension->DeviceName, DeviceName);
- PAGED_CODE();
+ /* We're done, remove the initializing flag */
+ ClearFlag(NewDeviceObject->Flags, DO_DEVICE_INITIALIZING);
- /* If it doesn't have a device extension, then it's not our device object */
- if (DeviceObject->DeviceExtension == NULL)
+ /* Look for existing mounted devices for this file system */
+ Status = FltpEnumerateFileSystemVolumes(DeviceObject);
+ if (!NT_SUCCESS(Status))
{
- /* Fail the call */
- IoStatus->Status = STATUS_INVALID_DEVICE_REQUEST;
- IoStatus->Information = 0;
- return TRUE;
+ DPRINT1("Failed to enumerate file system volumes for this file system :
0x%X\n", Status);
+ IoDetachDevice(DeviceExtension->AttachedToDeviceObject);
}
- DeviceExtension = DeviceObject->DeviceExtension;
- FLT_ASSERT(DeviceExtension->AttachedToDeviceObject);
-
- /* Get the device that we attached to */
- AttachedDeviceObject = DeviceExtension->AttachedToDeviceObject;
- FastIoDispatch = AttachedDeviceObject->DriverObject->FastIoDispatch;
+Cleanup:
- /* Make sure our FastIo table is valid */
- if (FastIoDispatch && FastIoDispatch->FastIoQueryBasicInfo)
+ if (!NT_SUCCESS(Status))
{
- /* Forward the call onto the device we attached to */
- return FastIoDispatch->FastIoQueryBasicInfo(FileObject,
- Wait,
- Buffer,
- IoStatus,
- AttachedDeviceObject);
+ IoDeleteDevice(NewDeviceObject);
}
- /* We failed to handle the request, send it down the slow path */
- FLT_ASSERT(FALSE);
- return FALSE;
+ return Status;
}
-BOOLEAN
-NTAPI
-FltpFastIoQueryStandardInfo(_In_ PFILE_OBJECT FileObject,
- _In_ BOOLEAN Wait,
- _Out_ PFILE_STANDARD_INFORMATION Buffer,
- _Out_ PIO_STATUS_BLOCK IoStatus,
- _In_ PDEVICE_OBJECT DeviceObject)
+CODE_SEG("PAGE")
+static
+LONG_PTR
+FltpDetachFromFileSystemDevice(_In_ PDEVICE_OBJECT DeviceObject)
{
+ PDEVICE_OBJECT AttachedDevice, NextDevice;
PFLTMGR_DEVICE_EXTENSION DeviceExtension;
- PDEVICE_OBJECT AttachedDeviceObject;
- PFAST_IO_DISPATCH FastIoDispatch;
+ LONG_PTR Count;
PAGED_CODE();
- /* If it doesn't have a device extension, then it's not our device object */
- if (DeviceObject->DeviceExtension == NULL)
+ /* Get the top device in the chain and increment the ref count on it */
+ AttachedDevice = IoGetAttachedDeviceReference(DeviceObject);
+
+ /* Loop all attached devices looking for our file system driver */
+ while (AttachedDevice->DriverObject != DriverData.DriverObject)
{
- /* Fail the call */
- IoStatus->Status = STATUS_INVALID_DEVICE_REQUEST;
- IoStatus->Information = 0;
- return TRUE;
- }
+ FLT_ASSERT(AttachedDevice != NULL);
- DeviceExtension = DeviceObject->DeviceExtension;
- FLT_ASSERT(DeviceExtension->AttachedToDeviceObject);
+ /* Get the next lower device object. This adds a ref on NextDevice */
+ NextDevice = IoGetLowerDeviceObject(AttachedDevice);
- /* Get the device that we attached to */
- AttachedDeviceObject = DeviceExtension->AttachedToDeviceObject;
- FastIoDispatch = AttachedDeviceObject->DriverObject->FastIoDispatch;
+ /* Remove the reference we added */
+ Count = ObDereferenceObject(AttachedDevice);
- /* Make sure our FastIo table is valid */
- if (FastIoDispatch && FastIoDispatch->FastIoQueryStandardInfo)
+ /* Bail if this is the last one */
+ if (NextDevice == NULL) return Count;
+
+ /* Try the next one */
+ AttachedDevice = NextDevice;
+ }
+
+
+ DeviceExtension = AttachedDevice->DeviceExtension;
+ if (DeviceExtension)
{
- /* Forward the call onto the device we attached to */
- return FastIoDispatch->FastIoQueryStandardInfo(FileObject,
- Wait,
- Buffer,
- IoStatus,
- AttachedDeviceObject);
+ //
+ // FIXME: Put any device extension cleanup code here
+ //
}
- /* We failed to handle the request, send it down the slow path */
- FLT_ASSERT(FALSE);
- return FALSE;
+ /* Detach the device from the chain and delete the object */
+ IoDetachDevice(DeviceObject);
+ IoDeleteDevice(AttachedDevice);
+
+ /* Remove the reference we added so the delete can complete */
+ return ObDereferenceObject(AttachedDevice);
}
-BOOLEAN
+
+/* DISPATCH ROUTINES **********************************************/
+
+NTSTATUS
NTAPI
-FltpFastIoLock(_In_ PFILE_OBJECT FileObject,
- _In_ PLARGE_INTEGER FileOffset,
- _In_ PLARGE_INTEGER Length,
- _In_ PEPROCESS ProcessId,
- _In_ ULONG Key,
- _In_ BOOLEAN FailImmediately,
- _In_ BOOLEAN ExclusiveLock,
- _Out_ PIO_STATUS_BLOCK IoStatus,
- _In_ PDEVICE_OBJECT DeviceObject)
+FltpPreFsFilterOperation(_In_ PFS_FILTER_CALLBACK_DATA Data,
+ _Out_ PVOID *CompletionContext)
{
- PFLTMGR_DEVICE_EXTENSION DeviceExtension;
- PDEVICE_OBJECT AttachedDeviceObject;
- PFAST_IO_DISPATCH FastIoDispatch;
-
- PAGED_CODE();
+ UNREFERENCED_PARAMETER(Data);
+ UNREFERENCED_PARAMETER(CompletionContext);
+ __debugbreak();
+ return STATUS_SUCCESS;
+}
- /* If it doesn't have a device extension, then it's not our device object */
- if (DeviceObject->DeviceExtension == NULL)
+VOID
+NTAPI
+FltpPostFsFilterOperation(_In_ PFS_FILTER_CALLBACK_DATA Data,
+ _In_ NTSTATUS OperationStatus,
+ _In_ PVOID CompletionContext)
+{
+ UNREFERENCED_PARAMETER(Data);
+ UNREFERENCED_PARAMETER(OperationStatus);
+ UNREFERENCED_PARAMETER(CompletionContext);
+ __debugbreak();
+}
+
+NTSTATUS
+NTAPI
+FltpDispatch(_In_ PDEVICE_OBJECT DeviceObject,
+ _Inout_ PIRP Irp)
+{
+ PFLTMGR_DEVICE_EXTENSION DeviceExtension;
+ PIO_STACK_LOCATION StackPtr;
+ NTSTATUS Status;
+
+ DeviceExtension = DeviceObject->DeviceExtension;
+
+ /* Check if this is a request for us */
+ if (DeviceObject == DriverData.DeviceObject)
{
- /* Fail the call */
- IoStatus->Status = STATUS_INVALID_DEVICE_REQUEST;
- IoStatus->Information = 0;
- return TRUE;
+ FLT_ASSERT(DeviceObject->DriverObject == DriverData.DriverObject);
+ FLT_ASSERT(DeviceExtension == NULL);
+
+ /* Hand it off to our internal handler */
+ Status = FltpDispatchHandler(DeviceObject, Irp);
+ if (Status != STATUS_REPARSE)
+ {
+ Irp->IoStatus.Status = Status;
+ Irp->IoStatus.Information = 0;
+ IoCompleteRequest(Irp, 0);
+ }
+ return Status;
+ }
+
+ /* Check if this is a request for a the messaging device */
+ if (DeviceObject == CommsDeviceObject)
+ {
+ /* Hand off to our internal routine */
+ return FltpMsgDispatch(DeviceObject, Irp);
+ }
+
+ FLT_ASSERT(DeviceExtension &&
+ DeviceExtension->AttachedToDeviceObject);
+
+ StackPtr = IoGetCurrentIrpStackLocation(Irp);
+ if (StackPtr->MajorFunction == IRP_MJ_SHUTDOWN)
+ {
+ // handle shutdown request
}
+ DPRINT1("Received %X from %wZ\n", StackPtr->MajorFunction,
&DeviceExtension->DeviceName);
+
+ /* Just pass the IRP down the stack */
+ IoSkipCurrentIrpStackLocation(Irp);
+ return IoCallDriver(DeviceExtension->AttachedToDeviceObject, Irp);
+}
+
+CODE_SEG("PAGE")
+NTSTATUS
+NTAPI
+FltpCreate(_In_ PDEVICE_OBJECT DeviceObject,
+ _Inout_ PIRP Irp)
+{
+ PFLTMGR_DEVICE_EXTENSION DeviceExtension;
+
+ PAGED_CODE();
+
DeviceExtension = DeviceObject->DeviceExtension;
- FLT_ASSERT(DeviceExtension->AttachedToDeviceObject);
- /* Get the device that we attached to */
- AttachedDeviceObject = DeviceExtension->AttachedToDeviceObject;
- FastIoDispatch = AttachedDeviceObject->DriverObject->FastIoDispatch;
+ /* Check if this is a request for us */
+ if (DeviceObject == DriverData.DeviceObject)
+ {
+ FLT_ASSERT(DeviceObject->DriverObject == DriverData.DriverObject);
+ FLT_ASSERT(DeviceExtension == NULL);
- /* Make sure our FastIo table is valid */
- if (FastIoDispatch && FastIoDispatch->FastIoLock)
+ /* Someone wants a handle to the fltmgr, allow it */
+ Irp->IoStatus.Status = STATUS_SUCCESS;
+ Irp->IoStatus.Information = 0;
+ IofCompleteRequest(Irp, 0);
+ return STATUS_SUCCESS;
+ }
+
+ /* Check if this is a request for a the new comms connection */
+ if (DeviceObject == CommsDeviceObject)
{
- /* Forward the call onto the device we attached to */
- return FastIoDispatch->FastIoLock(FileObject,
- FileOffset,
- Length,
- ProcessId,
- Key,
- FailImmediately,
- ExclusiveLock,
- IoStatus,
- AttachedDeviceObject);
+ /* Hand off to our internal routine */
+ return FltpMsgCreate(DeviceObject, Irp);
}
- /* We failed to handle the request, send it down the slow path */
- FLT_ASSERT(FALSE);
- return FALSE;
+ FLT_ASSERT(DeviceExtension &&
+ DeviceExtension->AttachedToDeviceObject);
+
+ DPRINT1("Received create from %wZ (%lu)\n",
&DeviceExtension->DeviceName, PsGetCurrentProcessId());
+
+ /* Just pass the IRP down the stack */
+ IoSkipCurrentIrpStackLocation(Irp);
+ return IoCallDriver(DeviceExtension->AttachedToDeviceObject, Irp);
+}
+
+CODE_SEG("PAGE")
+NTSTATUS
+NTAPI
+FltpFsControl(_In_ PDEVICE_OBJECT DeviceObject,
+ _Inout_ PIRP Irp)
+{
+ PFLTMGR_DEVICE_EXTENSION DeviceExtension;
+
+ PAGED_CODE();
+
+ /* Check if this is a request for us */
+ if (DeviceObject == DriverData.DeviceObject)
+ {
+ /* We don't handle this request */
+ Irp->IoStatus.Information = 0;
+ Irp->IoStatus.Status = STATUS_INVALID_DEVICE_REQUEST;
+ IofCompleteRequest(Irp, 0);
+ return STATUS_INVALID_DEVICE_REQUEST;
+ }
+
+ DeviceExtension = DeviceObject->DeviceExtension;
+
+ FLT_ASSERT(DeviceExtension &&
+ DeviceExtension->AttachedToDeviceObject);
+
+ /* Just pass the IRP down the stack */
+ IoSkipCurrentIrpStackLocation(Irp);
+ return IoCallDriver(DeviceExtension->AttachedToDeviceObject, Irp);
+}
+
+NTSTATUS
+NTAPI
+FltpDeviceControl(_In_ PDEVICE_OBJECT DeviceObject,
+ _Inout_ PIRP Irp)
+{
+ PFLTMGR_DEVICE_EXTENSION DeviceExtension;
+ NTSTATUS Status;
+
+ /* Check if the request was meant for us */
+ if (DeviceObject == DriverData.DeviceObject)
+ {
+ Status = FltpDeviceControlHandler(DeviceObject, Irp);
+ if (Status != STATUS_REPARSE)
+ {
+ Irp->IoStatus.Status = Status;
+ Irp->IoStatus.Information = 0;
+ IoCompleteRequest(Irp, 0);
+ }
+
+ return Status;
+ }
+
+ DeviceExtension = DeviceObject->DeviceExtension;
+
+ FLT_ASSERT(DeviceExtension &&
+ DeviceExtension->AttachedToDeviceObject);
+
+ /* Just pass the IRP down the stack */
+ IoSkipCurrentIrpStackLocation(Irp);
+ return IoCallDriver(DeviceExtension->AttachedToDeviceObject, Irp);
}
+
+
+/* FASTIO ROUTINES ************************************************/
+
+CODE_SEG("PAGE")
BOOLEAN
NTAPI
-FltpFastIoUnlockSingle(_In_ PFILE_OBJECT FileObject,
- _In_ PLARGE_INTEGER FileOffset,
- _In_ PLARGE_INTEGER Length,
- _In_ PEPROCESS ProcessId,
- _In_ ULONG Key,
- _Out_ PIO_STATUS_BLOCK IoStatus,
- _In_ PDEVICE_OBJECT DeviceObject)
+FltpFastIoCheckIfPossible(_In_ PFILE_OBJECT FileObject,
+ _In_ PLARGE_INTEGER FileOffset,
+ _In_ ULONG Length,
+ _In_ BOOLEAN Wait,
+ _In_ ULONG LockKey,
+ _In_ BOOLEAN CheckForReadOperation,
+ _Out_ PIO_STATUS_BLOCK IoStatus,
+ _In_ PDEVICE_OBJECT DeviceObject)
+
{
PFLTMGR_DEVICE_EXTENSION DeviceExtension;
PDEVICE_OBJECT AttachedDeviceObject;
@@ -923,16 +689,17 @@ FltpFastIoUnlockSingle(_In_ PFILE_OBJECT FileObject,
FastIoDispatch = AttachedDeviceObject->DriverObject->FastIoDispatch;
/* Make sure our FastIo table is valid */
- if (FastIoDispatch && FastIoDispatch->FastIoUnlockSingle)
+ if (FastIoDispatch && FastIoDispatch->FastIoCheckIfPossible)
{
/* Forward the call onto the device we attached to */
- return FastIoDispatch->FastIoUnlockSingle(FileObject,
- FileOffset,
- Length,
- ProcessId,
- Key,
- IoStatus,
- AttachedDeviceObject);
+ return FastIoDispatch->FastIoCheckIfPossible(FileObject,
+ FileOffset,
+ Length,
+ Wait,
+ LockKey,
+ CheckForReadOperation,
+ IoStatus,
+ AttachedDeviceObject);
}
/* We failed to handle the request, send it down the slow path */
@@ -940,13 +707,17 @@ FltpFastIoUnlockSingle(_In_ PFILE_OBJECT FileObject,
return FALSE;
}
+CODE_SEG("PAGE")
BOOLEAN
NTAPI
-FltpFastIoUnlockAll(_In_ PFILE_OBJECT FileObject,
- _In_ PEPROCESS ProcessId,
- _Out_ PIO_STATUS_BLOCK IoStatus,
- _In_ PDEVICE_OBJECT DeviceObject)
-
+FltpFastIoRead(_In_ PFILE_OBJECT FileObject,
+ _In_ PLARGE_INTEGER FileOffset,
+ _In_ ULONG Length,
+ _In_ BOOLEAN Wait,
+ _In_ ULONG LockKey,
+ _Out_ PVOID Buffer,
+ _Out_ PIO_STATUS_BLOCK IoStatus,
+ _In_ PDEVICE_OBJECT DeviceObject)
{
PFLTMGR_DEVICE_EXTENSION DeviceExtension;
PDEVICE_OBJECT AttachedDeviceObject;
@@ -971,13 +742,17 @@ FltpFastIoUnlockAll(_In_ PFILE_OBJECT FileObject,
FastIoDispatch = AttachedDeviceObject->DriverObject->FastIoDispatch;
/* Make sure our FastIo table is valid */
- if (FastIoDispatch && FastIoDispatch->FastIoUnlockAll)
+ if (FastIoDispatch && FastIoDispatch->FastIoRead)
{
/* Forward the call onto the device we attached to */
- return FastIoDispatch->FastIoUnlockAll(FileObject,
- ProcessId,
- IoStatus,
- AttachedDeviceObject);
+ return FastIoDispatch->FastIoRead(FileObject,
+ FileOffset,
+ Length,
+ Wait,
+ LockKey,
+ Buffer,
+ IoStatus,
+ AttachedDeviceObject);
}
/* We failed to handle the request, send it down the slow path */
@@ -985,13 +760,17 @@ FltpFastIoUnlockAll(_In_ PFILE_OBJECT FileObject,
return FALSE;
}
+CODE_SEG("PAGE")
BOOLEAN
NTAPI
-FltpFastIoUnlockAllByKey(_In_ PFILE_OBJECT FileObject,
- _In_ PVOID ProcessId,
- _In_ ULONG Key,
- _Out_ PIO_STATUS_BLOCK IoStatus,
- _In_ PDEVICE_OBJECT DeviceObject)
+FltpFastIoWrite(_In_ PFILE_OBJECT FileObject,
+ _In_ PLARGE_INTEGER FileOffset,
+ _In_ ULONG Length,
+ _In_ BOOLEAN Wait,
+ _In_ ULONG LockKey,
+ _In_ PVOID Buffer,
+ _Out_ PIO_STATUS_BLOCK IoStatus,
+ _In_ PDEVICE_OBJECT DeviceObject)
{
PFLTMGR_DEVICE_EXTENSION DeviceExtension;
PDEVICE_OBJECT AttachedDeviceObject;
@@ -1016,14 +795,17 @@ FltpFastIoUnlockAllByKey(_In_ PFILE_OBJECT FileObject,
FastIoDispatch = AttachedDeviceObject->DriverObject->FastIoDispatch;
/* Make sure our FastIo table is valid */
- if (FastIoDispatch && FastIoDispatch->FastIoUnlockAllByKey)
+ if (FastIoDispatch && FastIoDispatch->FastIoWrite)
{
/* Forward the call onto the device we attached to */
- return FastIoDispatch->FastIoUnlockAllByKey(FileObject,
- ProcessId,
- Key,
- IoStatus,
- AttachedDeviceObject);
+ return FastIoDispatch->FastIoWrite(FileObject,
+ FileOffset,
+ Length,
+ Wait,
+ LockKey,
+ Buffer,
+ IoStatus,
+ AttachedDeviceObject);
}
/* We failed to handle the request, send it down the slow path */
@@ -1031,17 +813,14 @@ FltpFastIoUnlockAllByKey(_In_ PFILE_OBJECT FileObject,
return FALSE;
}
+CODE_SEG("PAGE")
BOOLEAN
NTAPI
-FltpFastIoDeviceControl(_In_ PFILE_OBJECT FileObject,
- _In_ BOOLEAN Wait,
- _In_opt_ PVOID InputBuffer,
- _In_ ULONG InputBufferLength,
- _Out_opt_ PVOID OutputBuffer,
- _In_ ULONG OutputBufferLength,
- _In_ ULONG IoControlCode,
- _Out_ PIO_STATUS_BLOCK IoStatus,
- _In_ PDEVICE_OBJECT DeviceObject)
+FltpFastIoQueryBasicInfo(_In_ PFILE_OBJECT FileObject,
+ _In_ BOOLEAN Wait,
+ _Out_ PFILE_BASIC_INFORMATION Buffer,
+ _Out_ PIO_STATUS_BLOCK IoStatus,
+ _In_ PDEVICE_OBJECT DeviceObject)
{
PFLTMGR_DEVICE_EXTENSION DeviceExtension;
PDEVICE_OBJECT AttachedDeviceObject;
@@ -1052,8 +831,10 @@ FltpFastIoDeviceControl(_In_ PFILE_OBJECT FileObject,
/* If it doesn't have a device extension, then it's not our device object */
if (DeviceObject->DeviceExtension == NULL)
{
- /* Fail the request, send it down the slow path */
- return FALSE;
+ /* Fail the call */
+ IoStatus->Status = STATUS_INVALID_DEVICE_REQUEST;
+ IoStatus->Information = 0;
+ return TRUE;
}
DeviceExtension = DeviceObject->DeviceExtension;
@@ -1064,18 +845,14 @@ FltpFastIoDeviceControl(_In_ PFILE_OBJECT FileObject,
FastIoDispatch = AttachedDeviceObject->DriverObject->FastIoDispatch;
/* Make sure our FastIo table is valid */
- if (FastIoDispatch && FastIoDispatch->FastIoDeviceControl)
+ if (FastIoDispatch && FastIoDispatch->FastIoQueryBasicInfo)
{
/* Forward the call onto the device we attached to */
- return FastIoDispatch->FastIoDeviceControl(FileObject,
- Wait,
- InputBuffer,
- InputBufferLength,
- OutputBuffer,
- OutputBufferLength,
- IoControlCode,
- IoStatus,
- AttachedDeviceObject);
+ return FastIoDispatch->FastIoQueryBasicInfo(FileObject,
+ Wait,
+ Buffer,
+ IoStatus,
+ AttachedDeviceObject);
}
/* We failed to handle the request, send it down the slow path */
@@ -1083,72 +860,65 @@ FltpFastIoDeviceControl(_In_ PFILE_OBJECT FileObject,
return FALSE;
}
-VOID
-NTAPI
-FltpFastIoDetachDeviceWorker(_In_ PVOID Parameter)
-{
- PDETACH_DEVICE_WORK_ITEM DetachDeviceWorkItem = Parameter;
-
- /* Run any cleanup routines */
- FltpCleanupDeviceObject(DetachDeviceWorkItem->SourceDevice);
-
- /* Detach from the target device */
- IoDetachDevice(DetachDeviceWorkItem->TargetDevice);
-
- /* Delete the source */
- IoDeleteDevice(DetachDeviceWorkItem->SourceDevice);
-
- /* Free the pool we allocated in FltpFastIoDetachDevice */
- ExFreePoolWithTag(DetachDeviceWorkItem, 0x1234);
-}
-
-VOID
+CODE_SEG("PAGE")
+BOOLEAN
NTAPI
-FltpFastIoDetachDevice(_In_ PDEVICE_OBJECT SourceDevice,
- _In_ PDEVICE_OBJECT TargetDevice)
+FltpFastIoQueryStandardInfo(_In_ PFILE_OBJECT FileObject,
+ _In_ BOOLEAN Wait,
+ _Out_ PFILE_STANDARD_INFORMATION Buffer,
+ _Out_ PIO_STATUS_BLOCK IoStatus,
+ _In_ PDEVICE_OBJECT DeviceObject)
{
- PDETACH_DEVICE_WORK_ITEM DetachDeviceWorkItem;
+ PFLTMGR_DEVICE_EXTENSION DeviceExtension;
+ PDEVICE_OBJECT AttachedDeviceObject;
+ PFAST_IO_DISPATCH FastIoDispatch;
PAGED_CODE();
- /*
- * Detaching and deleting devices is a lot of work and takes too long
- * to be a worthwhile FastIo candidate, so we defer this call to speed
- * it up. There's no return value so we're okay to do this.
- */
-
- /* Allocate the work item and it's corresponding data */
- DetachDeviceWorkItem = ExAllocatePoolWithTag(NonPagedPool,
- sizeof(DETACH_DEVICE_WORK_ITEM),
- 0x1234);
- if (DetachDeviceWorkItem)
+ /* If it doesn't have a device extension, then it's not our device object */
+ if (DeviceObject->DeviceExtension == NULL)
{
- /* Initialize the work item */
- ExInitializeWorkItem(&DetachDeviceWorkItem->WorkItem,
- FltpFastIoDetachDeviceWorker,
- DetachDeviceWorkItem);
-
- /* Queue the work item and return the call */
- ExQueueWorkItem(&DetachDeviceWorkItem->WorkItem,
- DelayedWorkQueue);
+ /* Fail the call */
+ IoStatus->Status = STATUS_INVALID_DEVICE_REQUEST;
+ IoStatus->Information = 0;
+ return TRUE;
}
- else
+
+ DeviceExtension = DeviceObject->DeviceExtension;
+ FLT_ASSERT(DeviceExtension->AttachedToDeviceObject);
+
+ /* Get the device that we attached to */
+ AttachedDeviceObject = DeviceExtension->AttachedToDeviceObject;
+ FastIoDispatch = AttachedDeviceObject->DriverObject->FastIoDispatch;
+
+ /* Make sure our FastIo table is valid */
+ if (FastIoDispatch && FastIoDispatch->FastIoQueryStandardInfo)
{
- /* We failed to defer, just cleanup here */
- FltpCleanupDeviceObject(SourceDevice);
- IoDetachDevice(TargetDevice);
- IoDeleteDevice(SourceDevice);
+ /* Forward the call onto the device we attached to */
+ return FastIoDispatch->FastIoQueryStandardInfo(FileObject,
+ Wait,
+ Buffer,
+ IoStatus,
+ AttachedDeviceObject);
}
+ /* We failed to handle the request, send it down the slow path */
+ FLT_ASSERT(FALSE);
+ return FALSE;
}
+CODE_SEG("PAGE")
BOOLEAN
NTAPI
-FltpFastIoQueryNetworkOpenInfo(_In_ PFILE_OBJECT FileObject,
- _In_ BOOLEAN Wait,
- _Out_ PFILE_NETWORK_OPEN_INFORMATION Buffer,
- _Out_ PIO_STATUS_BLOCK IoStatus,
- _In_ PDEVICE_OBJECT DeviceObject)
+FltpFastIoLock(_In_ PFILE_OBJECT FileObject,
+ _In_ PLARGE_INTEGER FileOffset,
+ _In_ PLARGE_INTEGER Length,
+ _In_ PEPROCESS ProcessId,
+ _In_ ULONG Key,
+ _In_ BOOLEAN FailImmediately,
+ _In_ BOOLEAN ExclusiveLock,
+ _Out_ PIO_STATUS_BLOCK IoStatus,
+ _In_ PDEVICE_OBJECT DeviceObject)
{
PFLTMGR_DEVICE_EXTENSION DeviceExtension;
PDEVICE_OBJECT AttachedDeviceObject;
@@ -1173,14 +943,18 @@ FltpFastIoQueryNetworkOpenInfo(_In_ PFILE_OBJECT FileObject,
FastIoDispatch = AttachedDeviceObject->DriverObject->FastIoDispatch;
/* Make sure our FastIo table is valid */
- if (FastIoDispatch && FastIoDispatch->FastIoQueryNetworkOpenInfo)
+ if (FastIoDispatch && FastIoDispatch->FastIoLock)
{
/* Forward the call onto the device we attached to */
- return FastIoDispatch->FastIoQueryNetworkOpenInfo(FileObject,
- Wait,
- Buffer,
- IoStatus,
- AttachedDeviceObject);
+ return FastIoDispatch->FastIoLock(FileObject,
+ FileOffset,
+ Length,
+ ProcessId,
+ Key,
+ FailImmediately,
+ ExclusiveLock,
+ IoStatus,
+ AttachedDeviceObject);
}
/* We failed to handle the request, send it down the slow path */
@@ -1188,15 +962,16 @@ FltpFastIoQueryNetworkOpenInfo(_In_ PFILE_OBJECT FileObject,
return FALSE;
}
+CODE_SEG("PAGE")
BOOLEAN
NTAPI
-FltpFastIoMdlRead(_In_ PFILE_OBJECT FileObject,
- _In_ PLARGE_INTEGER FileOffset,
- _In_ ULONG Length,
- _In_ ULONG LockKey,
- _Out_ PMDL *MdlChain,
- _Out_ PIO_STATUS_BLOCK IoStatus,
- _In_ PDEVICE_OBJECT DeviceObject)
+FltpFastIoUnlockSingle(_In_ PFILE_OBJECT FileObject,
+ _In_ PLARGE_INTEGER FileOffset,
+ _In_ PLARGE_INTEGER Length,
+ _In_ PEPROCESS ProcessId,
+ _In_ ULONG Key,
+ _Out_ PIO_STATUS_BLOCK IoStatus,
+ _In_ PDEVICE_OBJECT DeviceObject)
{
PFLTMGR_DEVICE_EXTENSION DeviceExtension;
PDEVICE_OBJECT AttachedDeviceObject;
@@ -1221,16 +996,16 @@ FltpFastIoMdlRead(_In_ PFILE_OBJECT FileObject,
FastIoDispatch = AttachedDeviceObject->DriverObject->FastIoDispatch;
/* Make sure our FastIo table is valid */
- if (FastIoDispatch && FastIoDispatch->MdlRead)
+ if (FastIoDispatch && FastIoDispatch->FastIoUnlockSingle)
{
/* Forward the call onto the device we attached to */
- return FastIoDispatch->MdlRead(FileObject,
- FileOffset,
- Length,
- LockKey,
- MdlChain,
- IoStatus,
- AttachedDeviceObject);
+ return FastIoDispatch->FastIoUnlockSingle(FileObject,
+ FileOffset,
+ Length,
+ ProcessId,
+ Key,
+ IoStatus,
+ AttachedDeviceObject);
}
/* We failed to handle the request, send it down the slow path */
@@ -1238,11 +1013,13 @@ FltpFastIoMdlRead(_In_ PFILE_OBJECT FileObject,
return FALSE;
}
+CODE_SEG("PAGE")
BOOLEAN
NTAPI
-FltpFastIoMdlReadComplete(_In_ PFILE_OBJECT FileObject,
- _In_ PMDL MdlChain,
- _In_ PDEVICE_OBJECT DeviceObject)
+FltpFastIoUnlockAll(_In_ PFILE_OBJECT FileObject,
+ _In_ PEPROCESS ProcessId,
+ _Out_ PIO_STATUS_BLOCK IoStatus,
+ _In_ PDEVICE_OBJECT DeviceObject)
{
PFLTMGR_DEVICE_EXTENSION DeviceExtension;
@@ -1254,8 +1031,10 @@ FltpFastIoMdlReadComplete(_In_ PFILE_OBJECT FileObject,
/* If it doesn't have a device extension, then it's not our device object */
if (DeviceObject->DeviceExtension == NULL)
{
- /* Fail the request, send it down the slow path */
- return FALSE;
+ /* Fail the call */
+ IoStatus->Status = STATUS_INVALID_DEVICE_REQUEST;
+ IoStatus->Information = 0;
+ return TRUE;
}
DeviceExtension = DeviceObject->DeviceExtension;
@@ -1266,11 +1045,12 @@ FltpFastIoMdlReadComplete(_In_ PFILE_OBJECT FileObject,
FastIoDispatch = AttachedDeviceObject->DriverObject->FastIoDispatch;
/* Make sure our FastIo table is valid */
- if (FastIoDispatch && FastIoDispatch->MdlReadComplete)
+ if (FastIoDispatch && FastIoDispatch->FastIoUnlockAll)
{
/* Forward the call onto the device we attached to */
- return FastIoDispatch->MdlReadComplete(FileObject,
- MdlChain,
+ return FastIoDispatch->FastIoUnlockAll(FileObject,
+ ProcessId,
+ IoStatus,
AttachedDeviceObject);
}
@@ -1279,15 +1059,14 @@ FltpFastIoMdlReadComplete(_In_ PFILE_OBJECT FileObject,
return FALSE;
}
+CODE_SEG("PAGE")
BOOLEAN
NTAPI
-FltpFastIoPrepareMdlWrite(_In_ PFILE_OBJECT FileObject,
- _In_ PLARGE_INTEGER FileOffset,
- _In_ ULONG Length,
- _In_ ULONG LockKey,
- _Out_ PMDL *MdlChain,
- _Out_ PIO_STATUS_BLOCK IoStatus,
- _In_ PDEVICE_OBJECT DeviceObject)
+FltpFastIoUnlockAllByKey(_In_ PFILE_OBJECT FileObject,
+ _In_ PVOID ProcessId,
+ _In_ ULONG Key,
+ _Out_ PIO_STATUS_BLOCK IoStatus,
+ _In_ PDEVICE_OBJECT DeviceObject)
{
PFLTMGR_DEVICE_EXTENSION DeviceExtension;
PDEVICE_OBJECT AttachedDeviceObject;
@@ -1312,16 +1091,14 @@ FltpFastIoPrepareMdlWrite(_In_ PFILE_OBJECT FileObject,
FastIoDispatch = AttachedDeviceObject->DriverObject->FastIoDispatch;
/* Make sure our FastIo table is valid */
- if (FastIoDispatch && FastIoDispatch->PrepareMdlWrite)
+ if (FastIoDispatch && FastIoDispatch->FastIoUnlockAllByKey)
{
/* Forward the call onto the device we attached to */
- return FastIoDispatch->PrepareMdlWrite(FileObject,
- FileOffset,
- Length,
- LockKey,
- MdlChain,
- IoStatus,
- AttachedDeviceObject);
+ return FastIoDispatch->FastIoUnlockAllByKey(FileObject,
+ ProcessId,
+ Key,
+ IoStatus,
+ AttachedDeviceObject);
}
/* We failed to handle the request, send it down the slow path */
@@ -1329,12 +1106,18 @@ FltpFastIoPrepareMdlWrite(_In_ PFILE_OBJECT FileObject,
return FALSE;
}
+CODE_SEG("PAGE")
BOOLEAN
NTAPI
-FltpFastIoMdlWriteComplete(_In_ PFILE_OBJECT FileObject,
- _In_ PLARGE_INTEGER FileOffset,
- _In_ PMDL MdlChain,
- _In_ PDEVICE_OBJECT DeviceObject)
+FltpFastIoDeviceControl(_In_ PFILE_OBJECT FileObject,
+ _In_ BOOLEAN Wait,
+ _In_opt_ PVOID InputBuffer,
+ _In_ ULONG InputBufferLength,
+ _Out_opt_ PVOID OutputBuffer,
+ _In_ ULONG OutputBufferLength,
+ _In_ ULONG IoControlCode,
+ _Out_ PIO_STATUS_BLOCK IoStatus,
+ _In_ PDEVICE_OBJECT DeviceObject)
{
PFLTMGR_DEVICE_EXTENSION DeviceExtension;
PDEVICE_OBJECT AttachedDeviceObject;
@@ -1357,13 +1140,18 @@ FltpFastIoMdlWriteComplete(_In_ PFILE_OBJECT FileObject,
FastIoDispatch = AttachedDeviceObject->DriverObject->FastIoDispatch;
/* Make sure our FastIo table is valid */
- if (FastIoDispatch && FastIoDispatch->MdlWriteComplete)
+ if (FastIoDispatch && FastIoDispatch->FastIoDeviceControl)
{
/* Forward the call onto the device we attached to */
- return FastIoDispatch->MdlWriteComplete(FileObject,
- FileOffset,
- MdlChain,
- AttachedDeviceObject);
+ return FastIoDispatch->FastIoDeviceControl(FileObject,
+ Wait,
+ InputBuffer,
+ InputBufferLength,
+ OutputBuffer,
+ OutputBufferLength,
+ IoControlCode,
+ IoStatus,
+ AttachedDeviceObject);
}
/* We failed to handle the request, send it down the slow path */
@@ -1371,119 +1159,74 @@ FltpFastIoMdlWriteComplete(_In_ PFILE_OBJECT FileObject,
return FALSE;
}
-BOOLEAN
+VOID
NTAPI
-FltpFastIoReadCompressed(_In_ PFILE_OBJECT FileObject,
- _In_ PLARGE_INTEGER FileOffset,
- _In_ ULONG Length,
- _In_ ULONG LockKey,
- _Out_ PVOID Buffer,
- _Out_ PMDL *MdlChain,
- _Out_ PIO_STATUS_BLOCK IoStatus,
- _Out_ PCOMPRESSED_DATA_INFO CompressedDataInfo,
- _In_ ULONG CompressedDataInfoLength,
- _In_ PDEVICE_OBJECT DeviceObject)
+FltpFastIoDetachDeviceWorker(_In_ PVOID Parameter)
{
- PFLTMGR_DEVICE_EXTENSION DeviceExtension;
- PDEVICE_OBJECT AttachedDeviceObject;
- PFAST_IO_DISPATCH FastIoDispatch;
-
- PAGED_CODE();
-
- /* If it doesn't have a device extension, then it's not our device object */
- if (DeviceObject->DeviceExtension == NULL)
- {
- /* Fail the request, send it down the slow path */
- return FALSE;
- }
+ PDETACH_DEVICE_WORK_ITEM DetachDeviceWorkItem = Parameter;
- DeviceExtension = DeviceObject->DeviceExtension;
- FLT_ASSERT(DeviceExtension->AttachedToDeviceObject);
+ /* Run any cleanup routines */
+ FltpCleanupDeviceObject(DetachDeviceWorkItem->SourceDevice);
- /* Get the device that we attached to */
- AttachedDeviceObject = DeviceExtension->AttachedToDeviceObject;
- FastIoDispatch = AttachedDeviceObject->DriverObject->FastIoDispatch;
+ /* Detach from the target device */
+ IoDetachDevice(DetachDeviceWorkItem->TargetDevice);
- /* Make sure our FastIo table is valid */
- if (FastIoDispatch && FastIoDispatch->FastIoReadCompressed)
- {
- /* Forward the call onto the device we attached to */
- return FastIoDispatch->FastIoReadCompressed(FileObject,
- FileOffset,
- Length,
- LockKey,
- Buffer,
- MdlChain,
- IoStatus,
- CompressedDataInfo,
- CompressedDataInfoLength,
- AttachedDeviceObject);
- }
+ /* Delete the source */
+ IoDeleteDevice(DetachDeviceWorkItem->SourceDevice);
- /* We failed to handle the request, send it down the slow path */
- FLT_ASSERT(FALSE);
- return FALSE;
+ /* Free the pool we allocated in FltpFastIoDetachDevice */
+ ExFreePoolWithTag(DetachDeviceWorkItem, 0x1234);
}
-BOOLEAN
+CODE_SEG("PAGE")
+VOID
NTAPI
-FltpFastIoWriteCompressed(_In_ PFILE_OBJECT FileObject,
- _In_ PLARGE_INTEGER FileOffset,
- _In_ ULONG Length,
- _In_ ULONG LockKey,
- _In_ PVOID Buffer,
- _Out_ PMDL *MdlChain,
- _Out_ PIO_STATUS_BLOCK IoStatus,
- _In_ PCOMPRESSED_DATA_INFO CompressedDataInfo,
- _In_ ULONG CompressedDataInfoLength,
- _In_ PDEVICE_OBJECT DeviceObject)
+FltpFastIoDetachDevice(_In_ PDEVICE_OBJECT SourceDevice,
+ _In_ PDEVICE_OBJECT TargetDevice)
{
- PFLTMGR_DEVICE_EXTENSION DeviceExtension;
- PDEVICE_OBJECT AttachedDeviceObject;
- PFAST_IO_DISPATCH FastIoDispatch;
+ PDETACH_DEVICE_WORK_ITEM DetachDeviceWorkItem;
PAGED_CODE();
- /* If it doesn't have a device extension, then it's not our device object */
- if (DeviceObject->DeviceExtension == NULL)
- {
- /* Fail the request, send it down the slow path */
- return FALSE;
- }
-
- DeviceExtension = DeviceObject->DeviceExtension;
- FLT_ASSERT(DeviceExtension->AttachedToDeviceObject);
+ /*
+ * Detaching and deleting devices is a lot of work and takes too long
+ * to be a worthwhile FastIo candidate, so we defer this call to speed
+ * it up. There's no return value so we're okay to do this.
+ */
- /* Get the device that we attached to */
- AttachedDeviceObject = DeviceExtension->AttachedToDeviceObject;
- FastIoDispatch = AttachedDeviceObject->DriverObject->FastIoDispatch;
+ /* Allocate the work item and it's corresponding data */
+ DetachDeviceWorkItem = ExAllocatePoolWithTag(NonPagedPool,
+ sizeof(DETACH_DEVICE_WORK_ITEM),
+ 0x1234);
+ if (DetachDeviceWorkItem)
+ {
+ /* Initialize the work item */
+ ExInitializeWorkItem(&DetachDeviceWorkItem->WorkItem,
+ FltpFastIoDetachDeviceWorker,
+ DetachDeviceWorkItem);
- /* Make sure our FastIo table is valid */
- if (FastIoDispatch && FastIoDispatch->FastIoWriteCompressed)
+ /* Queue the work item and return the call */
+ ExQueueWorkItem(&DetachDeviceWorkItem->WorkItem,
+ DelayedWorkQueue);
+ }
+ else
{
- /* Forward the call onto the device we attached to */
- return FastIoDispatch->FastIoWriteCompressed(FileObject,
- FileOffset,
- Length,
- LockKey,
- Buffer,
- MdlChain,
- IoStatus,
- CompressedDataInfo,
- CompressedDataInfoLength,
- AttachedDeviceObject);
+ /* We failed to defer, just cleanup here */
+ FltpCleanupDeviceObject(SourceDevice);
+ IoDetachDevice(TargetDevice);
+ IoDeleteDevice(SourceDevice);
}
- /* We failed to handle the request, send it down the slow path */
- FLT_ASSERT(FALSE);
- return FALSE;
}
+CODE_SEG("PAGE")
BOOLEAN
NTAPI
-FltpFastIoMdlReadCompleteCompressed(_In_ PFILE_OBJECT FileObject,
- _In_ PMDL MdlChain,
- _In_ PDEVICE_OBJECT DeviceObject)
+FltpFastIoQueryNetworkOpenInfo(_In_ PFILE_OBJECT FileObject,
+ _In_ BOOLEAN Wait,
+ _Out_ PFILE_NETWORK_OPEN_INFORMATION Buffer,
+ _Out_ PIO_STATUS_BLOCK IoStatus,
+ _In_ PDEVICE_OBJECT DeviceObject)
{
PFLTMGR_DEVICE_EXTENSION DeviceExtension;
PDEVICE_OBJECT AttachedDeviceObject;
@@ -1494,7 +1237,10 @@ FltpFastIoMdlReadCompleteCompressed(_In_ PFILE_OBJECT FileObject,
/* If it doesn't have a device extension, then it's not our device object */
if (DeviceObject->DeviceExtension == NULL)
{
- return FALSE;
+ /* Fail the call */
+ IoStatus->Status = STATUS_INVALID_DEVICE_REQUEST;
+ IoStatus->Information = 0;
+ return TRUE;
}
DeviceExtension = DeviceObject->DeviceExtension;
@@ -1505,12 +1251,14 @@ FltpFastIoMdlReadCompleteCompressed(_In_ PFILE_OBJECT FileObject,
FastIoDispatch = AttachedDeviceObject->DriverObject->FastIoDispatch;
/* Make sure our FastIo table is valid */
- if (FastIoDispatch && FastIoDispatch->MdlReadCompleteCompressed)
+ if (FastIoDispatch && FastIoDispatch->FastIoQueryNetworkOpenInfo)
{
/* Forward the call onto the device we attached to */
- return FastIoDispatch->MdlReadCompleteCompressed(FileObject,
- MdlChain,
- AttachedDeviceObject);
+ return FastIoDispatch->FastIoQueryNetworkOpenInfo(FileObject,
+ Wait,
+ Buffer,
+ IoStatus,
+ AttachedDeviceObject);
}
/* We failed to handle the request, send it down the slow path */
@@ -1518,12 +1266,16 @@ FltpFastIoMdlReadCompleteCompressed(_In_ PFILE_OBJECT FileObject,
return FALSE;
}
+CODE_SEG("PAGE")
BOOLEAN
NTAPI
-FltpFastIoMdlWriteCompleteCompressed(_In_ PFILE_OBJECT FileObject,
- _In_ PLARGE_INTEGER FileOffset,
- _In_ PMDL MdlChain,
- _In_ PDEVICE_OBJECT DeviceObject)
+FltpFastIoMdlRead(_In_ PFILE_OBJECT FileObject,
+ _In_ PLARGE_INTEGER FileOffset,
+ _In_ ULONG Length,
+ _In_ ULONG LockKey,
+ _Out_ PMDL *MdlChain,
+ _Out_ PIO_STATUS_BLOCK IoStatus,
+ _In_ PDEVICE_OBJECT DeviceObject)
{
PFLTMGR_DEVICE_EXTENSION DeviceExtension;
PDEVICE_OBJECT AttachedDeviceObject;
@@ -1534,7 +1286,10 @@ FltpFastIoMdlWriteCompleteCompressed(_In_ PFILE_OBJECT FileObject,
/* If it doesn't have a device extension, then it's not our device object */
if (DeviceObject->DeviceExtension == NULL)
{
- return FALSE;
+ /* Fail the call */
+ IoStatus->Status = STATUS_INVALID_DEVICE_REQUEST;
+ IoStatus->Information = 0;
+ return TRUE;
}
DeviceExtension = DeviceObject->DeviceExtension;
@@ -1545,13 +1300,16 @@ FltpFastIoMdlWriteCompleteCompressed(_In_ PFILE_OBJECT
FileObject,
FastIoDispatch = AttachedDeviceObject->DriverObject->FastIoDispatch;
/* Make sure our FastIo table is valid */
- if (FastIoDispatch && FastIoDispatch->MdlWriteCompleteCompressed)
+ if (FastIoDispatch && FastIoDispatch->MdlRead)
{
/* Forward the call onto the device we attached to */
- return FastIoDispatch->MdlWriteCompleteCompressed(FileObject,
- FileOffset,
- MdlChain,
- AttachedDeviceObject);
+ return FastIoDispatch->MdlRead(FileObject,
+ FileOffset,
+ Length,
+ LockKey,
+ MdlChain,
+ IoStatus,
+ AttachedDeviceObject);
}
/* We failed to handle the request, send it down the slow path */
@@ -1559,22 +1317,24 @@ FltpFastIoMdlWriteCompleteCompressed(_In_ PFILE_OBJECT
FileObject,
return FALSE;
}
+CODE_SEG("PAGE")
BOOLEAN
NTAPI
-FltpFastIoQueryOpen(_Inout_ PIRP Irp,
- _Out_ PFILE_NETWORK_OPEN_INFORMATION NetworkInformation,
- _In_ PDEVICE_OBJECT DeviceObject)
+FltpFastIoMdlReadComplete(_In_ PFILE_OBJECT FileObject,
+ _In_ PMDL MdlChain,
+ _In_ PDEVICE_OBJECT DeviceObject)
+
{
PFLTMGR_DEVICE_EXTENSION DeviceExtension;
PDEVICE_OBJECT AttachedDeviceObject;
PFAST_IO_DISPATCH FastIoDispatch;
- BOOLEAN Success;
PAGED_CODE();
/* If it doesn't have a device extension, then it's not our device object */
if (DeviceObject->DeviceExtension == NULL)
{
+ /* Fail the request, send it down the slow path */
return FALSE;
}
@@ -1586,21 +1346,12 @@ FltpFastIoQueryOpen(_Inout_ PIRP Irp,
FastIoDispatch = AttachedDeviceObject->DriverObject->FastIoDispatch;
/* Make sure our FastIo table is valid */
- if (FastIoDispatch && FastIoDispatch->FastIoQueryOpen)
+ if (FastIoDispatch && FastIoDispatch->MdlReadComplete)
{
- PIO_STACK_LOCATION StackPtr = IoGetCurrentIrpStackLocation(Irp);
-
- /* Update the stack to contain the correct device for the next filter */
- StackPtr->DeviceObject = AttachedDeviceObject;
-
- /* Now forward the call */
- Success = FastIoDispatch->FastIoQueryOpen(Irp,
- NetworkInformation,
- AttachedDeviceObject);
-
- /* Restore the DeviceObject as we found it */
- StackPtr->DeviceObject = DeviceObject;
- return Success;
+ /* Forward the call onto the device we attached to */
+ return FastIoDispatch->MdlReadComplete(FileObject,
+ MdlChain,
+ AttachedDeviceObject);
}
/* We failed to handle the request, send it down the slow path */
@@ -1608,430 +1359,346 @@ FltpFastIoQueryOpen(_Inout_ PIRP Irp,
return FALSE;
}
-
-
-/* FUNCTIONS **********************************************/
-
-static
-VOID
-FltpCleanupDeviceObject(_In_ PDEVICE_OBJECT DeviceObject)
-{
- PFLTMGR_DEVICE_EXTENSION DeviceExtension;
-
- DeviceExtension = DeviceObject->DeviceExtension;
- if (DeviceExtension)
- {
- // cleanup device extension
- }
-}
-
-static
-NTSTATUS
-FltpAttachDeviceObject(_In_ PDEVICE_OBJECT SourceDevice,
- _In_ PDEVICE_OBJECT TargetDevice,
- _Out_ PDEVICE_OBJECT *AttachedToDeviceObject)
-{
- NTSTATUS Status;
-
- PAGED_CODE();
-
- /* Before attaching, copy the flags from the device we're going to attach to */
- if (FlagOn(SourceDevice->Flags, DO_BUFFERED_IO))
- {
- SetFlag(TargetDevice->Flags, DO_BUFFERED_IO);
- }
- if (FlagOn(SourceDevice->Flags, DO_DIRECT_IO))
- {
- SetFlag(TargetDevice->Flags, DO_DIRECT_IO);
- }
- if (FlagOn(SourceDevice->Flags, DO_SYSTEM_BOOT_PARTITION))
- {
- SetFlag(TargetDevice->Characteristics, FILE_DEVICE_SECURE_OPEN);
- }
-
- /* Attach this device to the top of the driver stack */
- Status = IoAttachDeviceToDeviceStackSafe(SourceDevice,
- TargetDevice,
- AttachedToDeviceObject);
-
- return Status;
-}
-
-static
+CODE_SEG("PAGE")
BOOLEAN
-FltpIsAttachedToDevice(_In_ PDEVICE_OBJECT DeviceObject,
- _In_opt_ PDEVICE_OBJECT *AttachedDeviceObject)
-{
- PDEVICE_OBJECT CurrentDeviceObject;
- PDEVICE_OBJECT NextDeviceObject;
-
- PAGED_CODE();
-
- /* Initialize the return pointer */
- if (AttachedDeviceObject) *AttachedDeviceObject = NULL;
-
- /* Start by getting the top level device in the chain */
- CurrentDeviceObject = IoGetAttachedDeviceReference(DeviceObject);
-
- /* Loop while there are attached devices */
- while (CurrentDeviceObject)
- {
- /* Check if this device driver matches ours */
- if (CurrentDeviceObject->DriverObject == DriverData.DriverObject)
- {
- FLT_ASSERT(CurrentDeviceObject->DeviceExtension != NULL);
-
- /* We're attached, return the device object if the caller asked for it
*/
- if (AttachedDeviceObject)
- {
- *AttachedDeviceObject = CurrentDeviceObject;
- }
- else
- {
- /* We aren't returning the reference, so decrement the count */
- ObDereferenceObject(CurrentDeviceObject);
- }
-
- return TRUE;
- }
-
- /* Get the next device in the chain */
- NextDeviceObject = IoGetLowerDeviceObject(CurrentDeviceObject);
-
- /* Decrement the count on the last device before we update the pointer */
- ObDereferenceObject(CurrentDeviceObject);
- CurrentDeviceObject = NextDeviceObject;
- }
-
- return FALSE;
-}
-
-static
-NTSTATUS
-FltpEnumerateFileSystemVolumes(_In_ PDEVICE_OBJECT DeviceObject)
+NTAPI
+FltpFastIoPrepareMdlWrite(_In_ PFILE_OBJECT FileObject,
+ _In_ PLARGE_INTEGER FileOffset,
+ _In_ ULONG Length,
+ _In_ ULONG LockKey,
+ _Out_ PMDL *MdlChain,
+ _Out_ PIO_STATUS_BLOCK IoStatus,
+ _In_ PDEVICE_OBJECT DeviceObject)
{
- PFLTMGR_DEVICE_EXTENSION NewDeviceExtension;
- PDEVICE_OBJECT BaseDeviceObject;
- PDEVICE_OBJECT NewDeviceObject;
- PDEVICE_OBJECT *DeviceList;
- PDEVICE_OBJECT StorageStackDeviceObject;
- UNICODE_STRING DeviceName;
- ULONG NumDevices;
- ULONG i;
- NTSTATUS Status;
+ PFLTMGR_DEVICE_EXTENSION DeviceExtension;
+ PDEVICE_OBJECT AttachedDeviceObject;
+ PFAST_IO_DISPATCH FastIoDispatch;
PAGED_CODE();
- /* Get the base device */
- BaseDeviceObject = IoGetDeviceAttachmentBaseRef(DeviceObject);
-
- /* get the number of device object linked to the base file system */
- Status = IoEnumerateDeviceObjectList(BaseDeviceObject->DriverObject,
- NULL,
- 0,
- &NumDevices);
- if (Status != STATUS_BUFFER_TOO_SMALL) return Status;
-
- /* Add a few more slots in case the size changed between calls and allocate some
memory to hold the pointers */
- NumDevices += 4;
- DeviceList = ExAllocatePoolWithTag(NonPagedPool,
- (NumDevices * sizeof(PDEVICE_OBJECT)),
- FM_TAG_DEV_OBJ_PTRS);
- if (DeviceList == NULL) return STATUS_INSUFFICIENT_RESOURCES;
-
- /* Now get all the device objects that this base driver has created */
- Status = IoEnumerateDeviceObjectList(BaseDeviceObject->DriverObject,
- DeviceList,
- (NumDevices * sizeof(PDEVICE_OBJECT)),
- &NumDevices);
- if (!NT_SUCCESS(Status))
- {
- ExFreePoolWithTag(DeviceList, FM_TAG_DEV_OBJ_PTRS);
- return Status;
- }
-
- /* Loop through all the devices looking for ones to attach to */
- for (i = 0; i < NumDevices; i++)
+ /* If it doesn't have a device extension, then it's not our device object */
+ if (DeviceObject->DeviceExtension == NULL)
{
- RtlInitUnicodeString(&DeviceName, NULL);
- StorageStackDeviceObject = NULL;
- NewDeviceObject = NULL;
-
- /* Ignore the device we passed in, and devices of the wrong type */
- if ((DeviceList[i] == BaseDeviceObject) ||
- (DeviceList[i]->DeviceType != BaseDeviceObject->DeviceType))
- {
- goto CleanupAndNext;
- }
-
- /* Ignore this device if we're already attached to it */
- if (FltpIsAttachedToDevice(DeviceList[i], NULL) == FALSE)
- {
- goto CleanupAndNext;
- }
-
-
- /*
- * If the device has a name, it must be a control device.
- * This handles drivers with more then one control device (like FastFat)
- */
- FltpGetBaseDeviceObjectName(DeviceList[i], &DeviceName);
- if (NT_SUCCESS(Status) && DeviceName.Length > 0)
- {
- goto CleanupAndNext;
- }
-
- /*
- * Try to get the storage stack (disk) device object associated with
- * this file system device object. Ignore the device if we don't have one
- */
- Status = IoGetDiskDeviceObject(DeviceList[i],
- &StorageStackDeviceObject);
- if (!NT_SUCCESS(Status))
- {
- goto CleanupAndNext;
- }
-
-
- /*
- * TODO: Don't attach to shadow copy volumes,
- * ros doesn't have any so it's not an issues yet
- */
-
- /*
- * We're far enough to be ready to attach, create a device
- * object which we'll use to do so
- */
- Status = IoCreateDevice(DriverData.DriverObject,
- sizeof(FLTMGR_DEVICE_EXTENSION),
- NULL,
- DeviceList[i]->DeviceType,
- 0,
- FALSE,
- &NewDeviceObject);
- if (!NT_SUCCESS(Status))
- {
- goto CleanupAndNext;
- }
-
- /* Get the device extension for this new object and store our disk object there
*/
- NewDeviceExtension = NewDeviceObject->DeviceExtension;
- NewDeviceExtension->StorageStackDeviceObject = StorageStackDeviceObject;
-
- /* Lookup and store the device name for the storage stack */
- RtlInitEmptyUnicodeString(&NewDeviceExtension->DeviceName,
- NewDeviceExtension->DeviceNameBuffer,
- sizeof(NewDeviceExtension->DeviceNameBuffer));
- FltpGetObjectName(StorageStackDeviceObject,
- &NewDeviceExtension->DeviceName);
-
-
- /* Grab the attach lock before we attempt to attach */
- ExAcquireFastMutex(&DriverData.FilterAttachLock);
-
- /* Check again that we aren't already attached. It may have changed since our
last check */
- if (FltpIsAttachedToDevice(DeviceList[i], NULL) == FALSE)
- {
- FLT_ASSERT(NewDeviceObject->DriverObject == DriverData.DriverObject);
-
- /* Finally, attach to the volume */
- Status = FltpAttachDeviceObject(DeviceList[i],
- NewDeviceObject,
-
&NewDeviceExtension->AttachedToDeviceObject);
- if (NT_SUCCESS(Status))
- {
- /* Clean the initializing flag so other filters can attach to our device
object */
- ClearFlag(NewDeviceObject->Flags, DO_DEVICE_INITIALIZING);
- }
- }
- else
- {
- /* We're already attached. Just cleanup */
- Status = STATUS_DEVICE_ALREADY_ATTACHED;
- }
+ /* Fail the call */
+ IoStatus->Status = STATUS_INVALID_DEVICE_REQUEST;
+ IoStatus->Information = 0;
+ return TRUE;
+ }
- ExReleaseFastMutex(&DriverData.FilterAttachLock);
+ DeviceExtension = DeviceObject->DeviceExtension;
+ FLT_ASSERT(DeviceExtension->AttachedToDeviceObject);
-CleanupAndNext:
+ /* Get the device that we attached to */
+ AttachedDeviceObject = DeviceExtension->AttachedToDeviceObject;
+ FastIoDispatch = AttachedDeviceObject->DriverObject->FastIoDispatch;
- if (!NT_SUCCESS(Status))
- {
- if (NewDeviceObject)
- {
- FltpCleanupDeviceObject(NewDeviceObject);
- IoDeleteDevice(NewDeviceObject);
- }
- }
+ /* Make sure our FastIo table is valid */
+ if (FastIoDispatch && FastIoDispatch->PrepareMdlWrite)
+ {
+ /* Forward the call onto the device we attached to */
+ return FastIoDispatch->PrepareMdlWrite(FileObject,
+ FileOffset,
+ Length,
+ LockKey,
+ MdlChain,
+ IoStatus,
+ AttachedDeviceObject);
+ }
- if (StorageStackDeviceObject)
- {
- /* A ref was added for us when we attached, so we can deref ours now */
- ObDereferenceObject(StorageStackDeviceObject);
- }
+ /* We failed to handle the request, send it down the slow path */
+ FLT_ASSERT(FALSE);
+ return FALSE;
+}
- /* Remove the ref which was added by IoEnumerateDeviceObjectList */
- ObDereferenceObject(DeviceList[i]);
+CODE_SEG("PAGE")
+BOOLEAN
+NTAPI
+FltpFastIoMdlWriteComplete(_In_ PFILE_OBJECT FileObject,
+ _In_ PLARGE_INTEGER FileOffset,
+ _In_ PMDL MdlChain,
+ _In_ PDEVICE_OBJECT DeviceObject)
+{
+ PFLTMGR_DEVICE_EXTENSION DeviceExtension;
+ PDEVICE_OBJECT AttachedDeviceObject;
+ PFAST_IO_DISPATCH FastIoDispatch;
- /* Free the buffer that FltpGetBaseDeviceObjectName added */
- FltpFreeUnicodeString(&DeviceName);
+ PAGED_CODE();
+ /* If it doesn't have a device extension, then it's not our device object */
+ if (DeviceObject->DeviceExtension == NULL)
+ {
+ /* Fail the request, send it down the slow path */
+ return FALSE;
}
- /* Free the memory we allocated for the list */
- ExFreePoolWithTag(DeviceList, FM_TAG_DEV_OBJ_PTRS);
+ DeviceExtension = DeviceObject->DeviceExtension;
+ FLT_ASSERT(DeviceExtension->AttachedToDeviceObject);
- return STATUS_SUCCESS;
+ /* Get the device that we attached to */
+ AttachedDeviceObject = DeviceExtension->AttachedToDeviceObject;
+ FastIoDispatch = AttachedDeviceObject->DriverObject->FastIoDispatch;
+
+ /* Make sure our FastIo table is valid */
+ if (FastIoDispatch && FastIoDispatch->MdlWriteComplete)
+ {
+ /* Forward the call onto the device we attached to */
+ return FastIoDispatch->MdlWriteComplete(FileObject,
+ FileOffset,
+ MdlChain,
+ AttachedDeviceObject);
+ }
+
+ /* We failed to handle the request, send it down the slow path */
+ FLT_ASSERT(FALSE);
+ return FALSE;
}
-static
-NTSTATUS
-FltpAttachToFileSystemDevice(_In_ PDEVICE_OBJECT DeviceObject,
- _In_ PUNICODE_STRING DeviceName)
+CODE_SEG("PAGE")
+BOOLEAN
+NTAPI
+FltpFastIoReadCompressed(_In_ PFILE_OBJECT FileObject,
+ _In_ PLARGE_INTEGER FileOffset,
+ _In_ ULONG Length,
+ _In_ ULONG LockKey,
+ _Out_ PVOID Buffer,
+ _Out_ PMDL *MdlChain,
+ _Out_ PIO_STATUS_BLOCK IoStatus,
+ _Out_ PCOMPRESSED_DATA_INFO CompressedDataInfo,
+ _In_ ULONG CompressedDataInfoLength,
+ _In_ PDEVICE_OBJECT DeviceObject)
{
PFLTMGR_DEVICE_EXTENSION DeviceExtension;
- PDEVICE_OBJECT NewDeviceObject;
- WCHAR Buffer[MAX_DEVNAME_LENGTH];
- UNICODE_STRING FileSystemDeviceName;
- UNICODE_STRING FsRecDeviceName;
- NTSTATUS Status;
+ PDEVICE_OBJECT AttachedDeviceObject;
+ PFAST_IO_DISPATCH FastIoDispatch;
PAGED_CODE();
- /* Only handle device types we're interested in */
- if (DeviceObject->DeviceType != FILE_DEVICE_DISK_FILE_SYSTEM &&
- DeviceObject->DeviceType != FILE_DEVICE_CD_ROM_FILE_SYSTEM &&
- DeviceObject->DeviceType != FILE_DEVICE_NETWORK_FILE_SYSTEM)
+ /* If it doesn't have a device extension, then it's not our device object */
+ if (DeviceObject->DeviceExtension == NULL)
{
- return STATUS_SUCCESS;
+ /* Fail the request, send it down the slow path */
+ return FALSE;
}
- /* Setup the buffer to hold the device name */
- RtlInitEmptyUnicodeString(&FileSystemDeviceName,
- Buffer,
- MAX_DEVNAME_LENGTH * sizeof(WCHAR));
+ DeviceExtension = DeviceObject->DeviceExtension;
+ FLT_ASSERT(DeviceExtension->AttachedToDeviceObject);
- /* Get the the name of the file system device */
- Status = FltpGetObjectName(DeviceObject->DriverObject,
&FileSystemDeviceName);
- if (!NT_SUCCESS(Status)) return Status;
+ /* Get the device that we attached to */
+ AttachedDeviceObject = DeviceExtension->AttachedToDeviceObject;
+ FastIoDispatch = AttachedDeviceObject->DriverObject->FastIoDispatch;
- DPRINT("Found device %wZ, checking if we need to attach...\n",
&FileSystemDeviceName);
+ /* Make sure our FastIo table is valid */
+ if (FastIoDispatch && FastIoDispatch->FastIoReadCompressed)
+ {
+ /* Forward the call onto the device we attached to */
+ return FastIoDispatch->FastIoReadCompressed(FileObject,
+ FileOffset,
+ Length,
+ LockKey,
+ Buffer,
+ MdlChain,
+ IoStatus,
+ CompressedDataInfo,
+ CompressedDataInfoLength,
+ AttachedDeviceObject);
+ }
- /* Build up the name of the file system recognizer device */
- RtlInitUnicodeString(&FsRecDeviceName, L"\\FileSystem\\Fs_Rec");
+ /* We failed to handle the request, send it down the slow path */
+ FLT_ASSERT(FALSE);
+ return FALSE;
+}
- /* We don't attach to recognizer devices, so bail if this is one */
- if (RtlCompareUnicodeString(&FileSystemDeviceName, &FsRecDeviceName, TRUE) ==
0)
+CODE_SEG("PAGE")
+BOOLEAN
+NTAPI
+FltpFastIoWriteCompressed(_In_ PFILE_OBJECT FileObject,
+ _In_ PLARGE_INTEGER FileOffset,
+ _In_ ULONG Length,
+ _In_ ULONG LockKey,
+ _In_ PVOID Buffer,
+ _Out_ PMDL *MdlChain,
+ _Out_ PIO_STATUS_BLOCK IoStatus,
+ _In_ PCOMPRESSED_DATA_INFO CompressedDataInfo,
+ _In_ ULONG CompressedDataInfoLength,
+ _In_ PDEVICE_OBJECT DeviceObject)
+{
+ PFLTMGR_DEVICE_EXTENSION DeviceExtension;
+ PDEVICE_OBJECT AttachedDeviceObject;
+ PFAST_IO_DISPATCH FastIoDispatch;
+
+ PAGED_CODE();
+
+ /* If it doesn't have a device extension, then it's not our device object */
+ if (DeviceObject->DeviceExtension == NULL)
{
- return STATUS_SUCCESS;
+ /* Fail the request, send it down the slow path */
+ return FALSE;
}
- /* Create a device object which we can attach to this file system */
- Status = IoCreateDevice(DriverData.DriverObject,
- sizeof(FLTMGR_DEVICE_EXTENSION),
- NULL,
- DeviceObject->DeviceType,
- 0,
- FALSE,
- &NewDeviceObject);
- if (!NT_SUCCESS(Status))
+ DeviceExtension = DeviceObject->DeviceExtension;
+ FLT_ASSERT(DeviceExtension->AttachedToDeviceObject);
+
+ /* Get the device that we attached to */
+ AttachedDeviceObject = DeviceExtension->AttachedToDeviceObject;
+ FastIoDispatch = AttachedDeviceObject->DriverObject->FastIoDispatch;
+
+ /* Make sure our FastIo table is valid */
+ if (FastIoDispatch && FastIoDispatch->FastIoWriteCompressed)
{
- DPRINT1("Failed to create a DO for attaching to a FS : 0x%X\n",
Status);
- return Status;
+ /* Forward the call onto the device we attached to */
+ return FastIoDispatch->FastIoWriteCompressed(FileObject,
+ FileOffset,
+ Length,
+ LockKey,
+ Buffer,
+ MdlChain,
+ IoStatus,
+ CompressedDataInfo,
+ CompressedDataInfoLength,
+ AttachedDeviceObject);
}
- /* Cast the device extension to something we understand */
- DeviceExtension = NewDeviceObject->DeviceExtension;
+ /* We failed to handle the request, send it down the slow path */
+ FLT_ASSERT(FALSE);
+ return FALSE;
+}
- /* Attach this device to the top of the driver stack and store the DO we attached to
in the DE */
- Status = FltpAttachDeviceObject(NewDeviceObject,
- DeviceObject,
- &DeviceExtension->AttachedToDeviceObject);
- if (NT_SUCCESS(Status))
+CODE_SEG("PAGE")
+BOOLEAN
+NTAPI
+FltpFastIoMdlReadCompleteCompressed(_In_ PFILE_OBJECT FileObject,
+ _In_ PMDL MdlChain,
+ _In_ PDEVICE_OBJECT DeviceObject)
+{
+ PFLTMGR_DEVICE_EXTENSION DeviceExtension;
+ PDEVICE_OBJECT AttachedDeviceObject;
+ PFAST_IO_DISPATCH FastIoDispatch;
+
+ PAGED_CODE();
+
+ /* If it doesn't have a device extension, then it's not our device object */
+ if (DeviceObject->DeviceExtension == NULL)
{
- DPRINT("Attached to %wZ\n", &FileSystemDeviceName);
+ return FALSE;
}
- else
+
+ DeviceExtension = DeviceObject->DeviceExtension;
+ FLT_ASSERT(DeviceExtension->AttachedToDeviceObject);
+
+ /* Get the device that we attached to */
+ AttachedDeviceObject = DeviceExtension->AttachedToDeviceObject;
+ FastIoDispatch = AttachedDeviceObject->DriverObject->FastIoDispatch;
+
+ /* Make sure our FastIo table is valid */
+ if (FastIoDispatch && FastIoDispatch->MdlReadCompleteCompressed)
{
- DPRINT1("Failed to attach to the driver stack : 0x%X\n", Status);
- goto Cleanup;
+ /* Forward the call onto the device we attached to */
+ return FastIoDispatch->MdlReadCompleteCompressed(FileObject,
+ MdlChain,
+ AttachedDeviceObject);
}
- /* Setup the unicode string buffer and copy the device name to the device extension
*/
- RtlInitEmptyUnicodeString(&DeviceExtension->DeviceName,
- DeviceExtension->DeviceNameBuffer,
- MAX_DEVNAME_LENGTH * sizeof(WCHAR));
- RtlCopyUnicodeString(&DeviceExtension->DeviceName, DeviceName);
+ /* We failed to handle the request, send it down the slow path */
+ FLT_ASSERT(FALSE);
+ return FALSE;
+}
- /* We're done, remove the initializing flag */
- ClearFlag(NewDeviceObject->Flags, DO_DEVICE_INITIALIZING);
+CODE_SEG("PAGE")
+BOOLEAN
+NTAPI
+FltpFastIoMdlWriteCompleteCompressed(_In_ PFILE_OBJECT FileObject,
+ _In_ PLARGE_INTEGER FileOffset,
+ _In_ PMDL MdlChain,
+ _In_ PDEVICE_OBJECT DeviceObject)
+{
+ PFLTMGR_DEVICE_EXTENSION DeviceExtension;
+ PDEVICE_OBJECT AttachedDeviceObject;
+ PFAST_IO_DISPATCH FastIoDispatch;
- /* Look for existing mounted devices for this file system */
- Status = FltpEnumerateFileSystemVolumes(DeviceObject);
- if (!NT_SUCCESS(Status))
+ PAGED_CODE();
+
+ /* If it doesn't have a device extension, then it's not our device object */
+ if (DeviceObject->DeviceExtension == NULL)
{
- DPRINT1("Failed to enumerate file system volumes for this file system :
0x%X\n", Status);
- IoDetachDevice(DeviceExtension->AttachedToDeviceObject);
+ return FALSE;
}
-Cleanup:
+ DeviceExtension = DeviceObject->DeviceExtension;
+ FLT_ASSERT(DeviceExtension->AttachedToDeviceObject);
- if (!NT_SUCCESS(Status))
+ /* Get the device that we attached to */
+ AttachedDeviceObject = DeviceExtension->AttachedToDeviceObject;
+ FastIoDispatch = AttachedDeviceObject->DriverObject->FastIoDispatch;
+
+ /* Make sure our FastIo table is valid */
+ if (FastIoDispatch && FastIoDispatch->MdlWriteCompleteCompressed)
{
- IoDeleteDevice(NewDeviceObject);
+ /* Forward the call onto the device we attached to */
+ return FastIoDispatch->MdlWriteCompleteCompressed(FileObject,
+ FileOffset,
+ MdlChain,
+ AttachedDeviceObject);
}
- return Status;
+ /* We failed to handle the request, send it down the slow path */
+ FLT_ASSERT(FALSE);
+ return FALSE;
}
-static
-LONG_PTR
-FltpDetachFromFileSystemDevice(_In_ PDEVICE_OBJECT DeviceObject)
+CODE_SEG("PAGE")
+BOOLEAN
+NTAPI
+FltpFastIoQueryOpen(_Inout_ PIRP Irp,
+ _Out_ PFILE_NETWORK_OPEN_INFORMATION NetworkInformation,
+ _In_ PDEVICE_OBJECT DeviceObject)
{
- PDEVICE_OBJECT AttachedDevice, NextDevice;
PFLTMGR_DEVICE_EXTENSION DeviceExtension;
- LONG_PTR Count;
+ PDEVICE_OBJECT AttachedDeviceObject;
+ PFAST_IO_DISPATCH FastIoDispatch;
+ BOOLEAN Success;
PAGED_CODE();
- /* Get the top device in the chain and increment the ref count on it */
- AttachedDevice = IoGetAttachedDeviceReference(DeviceObject);
-
- /* Loop all attached devices looking for our file system driver */
- while (AttachedDevice->DriverObject != DriverData.DriverObject)
+ /* If it doesn't have a device extension, then it's not our device object */
+ if (DeviceObject->DeviceExtension == NULL)
{
- FLT_ASSERT(AttachedDevice != NULL);
+ return FALSE;
+ }
- /* Get the next lower device object. This adds a ref on NextDevice */
- NextDevice = IoGetLowerDeviceObject(AttachedDevice);
+ DeviceExtension = DeviceObject->DeviceExtension;
+ FLT_ASSERT(DeviceExtension->AttachedToDeviceObject);
- /* Remove the reference we added */
- Count = ObDereferenceObject(AttachedDevice);
+ /* Get the device that we attached to */
+ AttachedDeviceObject = DeviceExtension->AttachedToDeviceObject;
+ FastIoDispatch = AttachedDeviceObject->DriverObject->FastIoDispatch;
- /* Bail if this is the last one */
- if (NextDevice == NULL) return Count;
+ /* Make sure our FastIo table is valid */
+ if (FastIoDispatch && FastIoDispatch->FastIoQueryOpen)
+ {
+ PIO_STACK_LOCATION StackPtr = IoGetCurrentIrpStackLocation(Irp);
- /* Try the next one */
- AttachedDevice = NextDevice;
- }
+ /* Update the stack to contain the correct device for the next filter */
+ StackPtr->DeviceObject = AttachedDeviceObject;
+ /* Now forward the call */
+ Success = FastIoDispatch->FastIoQueryOpen(Irp,
+ NetworkInformation,
+ AttachedDeviceObject);
- DeviceExtension = AttachedDevice->DeviceExtension;
- if (DeviceExtension)
- {
- //
- // FIXME: Put any device extension cleanup code here
- //
+ /* Restore the DeviceObject as we found it */
+ StackPtr->DeviceObject = DeviceObject;
+ return Success;
}
- /* Detach the device from the chain and delete the object */
- IoDetachDevice(DeviceObject);
- IoDeleteDevice(AttachedDevice);
-
- /* Remove the reference we added so the delete can complete */
- return ObDereferenceObject(AttachedDevice);
+ /* We failed to handle the request, send it down the slow path */
+ FLT_ASSERT(FALSE);
+ return FALSE;
}
+CODE_SEG("PAGE")
DRIVER_FS_NOTIFICATION FltpFsNotification;
+
+CODE_SEG("PAGE")
VOID
NTAPI
FltpFsNotification(_In_ PDEVICE_OBJECT DeviceObject,
@@ -2045,7 +1712,7 @@ FltpFsNotification(_In_ PDEVICE_OBJECT DeviceObject,
/* Set an empty string */
RtlInitUnicodeString(&DeviceName, NULL);
- /* Get the name of the lowest device object on the stack */
+ /* Get the name of the lowest device object on the stack */
Status = FltpGetBaseDeviceObjectName(DeviceObject, &DeviceName);
if (NT_SUCCESS(Status))
{
@@ -2066,7 +1733,83 @@ FltpFsNotification(_In_ PDEVICE_OBJECT DeviceObject,
}
}
-DRIVER_INITIALIZE DriverEntry;
+static
+CODE_SEG("INIT")
+NTSTATUS
+SetupDispatchAndCallbacksTables(_In_ PDRIVER_OBJECT DriverObject)
+{
+ PFAST_IO_DISPATCH FastIoDispatch;
+ FS_FILTER_CALLBACKS Callbacks;
+ ULONG i;
+
+ /* Plug all the IRPs */
+ for (i = 0; i <= IRP_MJ_MAXIMUM_FUNCTION; i++)
+ {
+ DriverObject->MajorFunction[i] = FltpDispatch;
+ }
+
+ /* Override the ones we're interested in */
+ DriverObject->MajorFunction[IRP_MJ_CREATE] = FltpCreate;
+ DriverObject->MajorFunction[IRP_MJ_CREATE_NAMED_PIPE] = FltpCreate;
+ DriverObject->MajorFunction[IRP_MJ_CREATE_MAILSLOT] = FltpCreate;
+ DriverObject->MajorFunction[IRP_MJ_FILE_SYSTEM_CONTROL] = FltpFsControl;
+ DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL] = FltpDeviceControl;
+
+ /* The FastIo dispatch table is stored in the pool along with a tag */
+ FastIoDispatch = ExAllocatePoolWithTag(NonPagedPool, sizeof(FAST_IO_DISPATCH),
FM_TAG_DISPATCH_TABLE);
+ if (FastIoDispatch == NULL) return STATUS_INSUFFICIENT_RESOURCES;
+
+ /* Fill out the FastIo table */
+ RtlZeroMemory(FastIoDispatch, sizeof(FAST_IO_DISPATCH));
+ FastIoDispatch->SizeOfFastIoDispatch = sizeof(FAST_IO_DISPATCH);
+ FastIoDispatch->FastIoCheckIfPossible = FltpFastIoCheckIfPossible;
+ FastIoDispatch->FastIoRead = FltpFastIoRead;
+ FastIoDispatch->FastIoWrite = FltpFastIoWrite;
+ FastIoDispatch->FastIoQueryBasicInfo = FltpFastIoQueryBasicInfo;
+ FastIoDispatch->FastIoQueryStandardInfo = FltpFastIoQueryStandardInfo;
+ FastIoDispatch->FastIoLock = FltpFastIoLock;
+ FastIoDispatch->FastIoUnlockSingle = FltpFastIoUnlockSingle;
+ FastIoDispatch->FastIoUnlockAll = FltpFastIoUnlockAll;
+ FastIoDispatch->FastIoUnlockAllByKey = FltpFastIoUnlockAllByKey;
+ FastIoDispatch->FastIoDeviceControl = FltpFastIoDeviceControl;
+ FastIoDispatch->FastIoDetachDevice = FltpFastIoDetachDevice;
+ FastIoDispatch->FastIoQueryNetworkOpenInfo = FltpFastIoQueryNetworkOpenInfo;
+ FastIoDispatch->MdlRead = FltpFastIoMdlRead;
+ FastIoDispatch->MdlReadComplete = FltpFastIoMdlReadComplete;
+ FastIoDispatch->PrepareMdlWrite = FltpFastIoPrepareMdlWrite;
+ FastIoDispatch->MdlWriteComplete = FltpFastIoMdlWriteComplete;
+ FastIoDispatch->FastIoReadCompressed = FltpFastIoReadCompressed;
+ FastIoDispatch->FastIoWriteCompressed = FltpFastIoWriteCompressed;
+ FastIoDispatch->MdlReadCompleteCompressed = FltpFastIoMdlReadCompleteCompressed;
+ FastIoDispatch->MdlWriteCompleteCompressed =
FltpFastIoMdlWriteCompleteCompressed;
+ FastIoDispatch->FastIoQueryOpen = FltpFastIoQueryOpen;
+
+ /* Store the FastIo table for internal and our access */
+ DriverObject->FastIoDispatch = FastIoDispatch;
+ DriverData.FastIoDispatch = FastIoDispatch;
+
+ /* Initialize the callback table */
+ Callbacks.SizeOfFsFilterCallbacks = sizeof(FS_FILTER_CALLBACKS);
+ Callbacks.PreAcquireForSectionSynchronization = FltpPreFsFilterOperation;
+ Callbacks.PostAcquireForSectionSynchronization = FltpPostFsFilterOperation;
+ Callbacks.PreReleaseForSectionSynchronization = FltpPreFsFilterOperation;
+ Callbacks.PostReleaseForSectionSynchronization = FltpPostFsFilterOperation;
+ Callbacks.PreAcquireForCcFlush = FltpPreFsFilterOperation;
+ Callbacks.PostAcquireForCcFlush = FltpPostFsFilterOperation;
+ Callbacks.PreReleaseForCcFlush = FltpPreFsFilterOperation;
+ Callbacks.PostReleaseForCcFlush = FltpPostFsFilterOperation;
+ Callbacks.PreAcquireForModifiedPageWriter = FltpPreFsFilterOperation;
+ Callbacks.PostAcquireForModifiedPageWriter = FltpPostFsFilterOperation;
+ Callbacks.PreReleaseForModifiedPageWriter = FltpPreFsFilterOperation;
+ Callbacks.PostReleaseForModifiedPageWriter = FltpPostFsFilterOperation;
+
+ /* Register our callbacks */
+ return FsRtlRegisterFileSystemFilterCallbacks(DriverObject, &Callbacks);
+}
+
+CODE_SEG("INIT") DRIVER_INITIALIZE DriverEntry;
+
+CODE_SEG("INIT")
NTSTATUS
NTAPI
DriverEntry(_In_ PDRIVER_OBJECT DriverObject,
@@ -2182,77 +1925,3 @@ Cleanup:
return Status;
}
-
-
-static
-NTSTATUS
-SetupDispatchAndCallbacksTables(_In_ PDRIVER_OBJECT DriverObject)
-{
- PFAST_IO_DISPATCH FastIoDispatch;
- FS_FILTER_CALLBACKS Callbacks;
- ULONG i;
-
- /* Plug all the IRPs */
- for (i = 0; i <= IRP_MJ_MAXIMUM_FUNCTION; i++)
- {
- DriverObject->MajorFunction[i] = FltpDispatch;
- }
-
- /* Override the ones we're interested in */
- DriverObject->MajorFunction[IRP_MJ_CREATE] = FltpCreate;
- DriverObject->MajorFunction[IRP_MJ_CREATE_NAMED_PIPE] = FltpCreate;
- DriverObject->MajorFunction[IRP_MJ_CREATE_MAILSLOT] = FltpCreate;
- DriverObject->MajorFunction[IRP_MJ_FILE_SYSTEM_CONTROL] = FltpFsControl;
- DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL] = FltpDeviceControl;
-
- /* The FastIo dispatch table is stored in the pool along with a tag */
- FastIoDispatch = ExAllocatePoolWithTag(NonPagedPool, sizeof(FAST_IO_DISPATCH),
FM_TAG_DISPATCH_TABLE);
- if (FastIoDispatch == NULL) return STATUS_INSUFFICIENT_RESOURCES;
-
- /* Fill out the FastIo table */
- RtlZeroMemory(FastIoDispatch, sizeof(FAST_IO_DISPATCH));
- FastIoDispatch->SizeOfFastIoDispatch = sizeof(FAST_IO_DISPATCH);
- FastIoDispatch->FastIoCheckIfPossible = FltpFastIoCheckIfPossible;
- FastIoDispatch->FastIoRead = FltpFastIoRead;
- FastIoDispatch->FastIoWrite = FltpFastIoWrite;
- FastIoDispatch->FastIoQueryBasicInfo = FltpFastIoQueryBasicInfo;
- FastIoDispatch->FastIoQueryStandardInfo = FltpFastIoQueryStandardInfo;
- FastIoDispatch->FastIoLock = FltpFastIoLock;
- FastIoDispatch->FastIoUnlockSingle = FltpFastIoUnlockSingle;
- FastIoDispatch->FastIoUnlockAll = FltpFastIoUnlockAll;
- FastIoDispatch->FastIoUnlockAllByKey = FltpFastIoUnlockAllByKey;
- FastIoDispatch->FastIoDeviceControl = FltpFastIoDeviceControl;
- FastIoDispatch->FastIoDetachDevice = FltpFastIoDetachDevice;
- FastIoDispatch->FastIoQueryNetworkOpenInfo = FltpFastIoQueryNetworkOpenInfo;
- FastIoDispatch->MdlRead = FltpFastIoMdlRead;
- FastIoDispatch->MdlReadComplete = FltpFastIoMdlReadComplete;
- FastIoDispatch->PrepareMdlWrite = FltpFastIoPrepareMdlWrite;
- FastIoDispatch->MdlWriteComplete = FltpFastIoMdlWriteComplete;
- FastIoDispatch->FastIoReadCompressed = FltpFastIoReadCompressed;
- FastIoDispatch->FastIoWriteCompressed = FltpFastIoWriteCompressed;
- FastIoDispatch->MdlReadCompleteCompressed = FltpFastIoMdlReadCompleteCompressed;
- FastIoDispatch->MdlWriteCompleteCompressed =
FltpFastIoMdlWriteCompleteCompressed;
- FastIoDispatch->FastIoQueryOpen = FltpFastIoQueryOpen;
-
- /* Store the FastIo table for internal and our access */
- DriverObject->FastIoDispatch = FastIoDispatch;
- DriverData.FastIoDispatch = FastIoDispatch;
-
- /* Initialize the callback table */
- Callbacks.SizeOfFsFilterCallbacks = sizeof(FS_FILTER_CALLBACKS);
- Callbacks.PreAcquireForSectionSynchronization = FltpPreFsFilterOperation;
- Callbacks.PostAcquireForSectionSynchronization = FltpPostFsFilterOperation;
- Callbacks.PreReleaseForSectionSynchronization = FltpPreFsFilterOperation;
- Callbacks.PostReleaseForSectionSynchronization = FltpPostFsFilterOperation;
- Callbacks.PreAcquireForCcFlush = FltpPreFsFilterOperation;
- Callbacks.PostAcquireForCcFlush = FltpPostFsFilterOperation;
- Callbacks.PreReleaseForCcFlush = FltpPreFsFilterOperation;
- Callbacks.PostReleaseForCcFlush = FltpPostFsFilterOperation;
- Callbacks.PreAcquireForModifiedPageWriter = FltpPreFsFilterOperation;
- Callbacks.PostAcquireForModifiedPageWriter = FltpPostFsFilterOperation;
- Callbacks.PreReleaseForModifiedPageWriter = FltpPreFsFilterOperation;
- Callbacks.PostReleaseForModifiedPageWriter = FltpPostFsFilterOperation;
-
- /* Register our callbacks */
- return FsRtlRegisterFileSystemFilterCallbacks(DriverObject, &Callbacks);
-}
diff --git a/drivers/filters/fltmgr/fltmgr.h b/drivers/filters/fltmgr/fltmgr.h
index 7008c1d0942..8f38dcbc10d 100644
--- a/drivers/filters/fltmgr/fltmgr.h
+++ b/drivers/filters/fltmgr/fltmgr.h
@@ -7,6 +7,8 @@
#include <fltkernel.h>
#include <pseh/pseh2.h>
+#include <section_attribs.h>
+
#define DRIVER_NAME L"FltMgr"
#define FLT_MAJOR_VERSION 0x0200
diff --git a/drivers/input/inport/hardware.c b/drivers/input/inport/hardware.c
index 6cc1583c860..33103f25311 100644
--- a/drivers/input/inport/hardware.c
+++ b/drivers/input/inport/hardware.c
@@ -16,10 +16,6 @@
/* GLOBALS ********************************************************************/
-#ifdef ALLOC_PRAGMA
-#pragma alloc_text(PAGE, InPortInitializeMouse)
-#endif
-
#define READ_MOUSE(DeviceExtension, Port) \
READ_PORT_UCHAR((DeviceExtension)->IoBase + (Port))
@@ -338,6 +334,7 @@ InPortIsr(
}
}
+CODE_SEG("PAGE")
VOID
NTAPI
InPortInitializeMouse(
diff --git a/drivers/input/inport/inport.c b/drivers/input/inport/inport.c
index 6ed5c71162a..745a86983e3 100644
--- a/drivers/input/inport/inport.c
+++ b/drivers/input/inport/inport.c
@@ -14,17 +14,11 @@
/* GLOBALS ********************************************************************/
-#ifdef ALLOC_PRAGMA
-#pragma alloc_text(INIT, DriverEntry)
-#pragma alloc_text(PAGE, InPortCreateClose)
-#pragma alloc_text(PAGE, InPortAddDevice)
-#pragma alloc_text(PAGE, InPortUnload)
-#endif
-
UNICODE_STRING DriverRegistryPath;
/* FUNCTIONS ******************************************************************/
+CODE_SEG("PAGE")
NTSTATUS
NTAPI
InPortCreateClose(
@@ -43,6 +37,7 @@ InPortCreateClose(
return STATUS_SUCCESS;
}
+CODE_SEG("PAGE")
NTSTATUS
NTAPI
InPortAddDevice(
@@ -161,6 +156,7 @@ Failure:
return Status;
}
+CODE_SEG("PAGE")
VOID
NTAPI
InPortUnload(
@@ -204,6 +200,7 @@ InPortPower(
return Status;
}
+CODE_SEG("INIT")
NTSTATUS
NTAPI
DriverEntry(
diff --git a/drivers/input/inport/inport.h b/drivers/input/inport/inport.h
index 2cae1cd6115..d77097713ff 100644
--- a/drivers/input/inport/inport.h
+++ b/drivers/input/inport/inport.h
@@ -13,6 +13,8 @@
#include <wmistr.h>
#include <kbdmou.h>
+#include <section_attribs.h>
+
#define INPORT_TAG 'tPnI'
typedef enum
@@ -74,14 +76,18 @@ typedef struct _INPORT_DEVICE_EXTENSION
MOUSE_ATTRIBUTES MouseAttributes;
} INPORT_DEVICE_EXTENSION, *PINPORT_DEVICE_EXTENSION;
+CODE_SEG("INIT")
DRIVER_INITIALIZE DriverEntry;
+CODE_SEG("PAGE")
DRIVER_UNLOAD InPortUnload;
+CODE_SEG("PAGE")
DRIVER_ADD_DEVICE InPortAddDevice;
_Dispatch_type_(IRP_MJ_CREATE)
_Dispatch_type_(IRP_MJ_CLOSE)
+CODE_SEG("PAGE")
DRIVER_DISPATCH_PAGED InPortCreateClose;
_Dispatch_type_(IRP_MJ_INTERNAL_DEVICE_CONTROL)
@@ -91,9 +97,11 @@ _Dispatch_type_(IRP_MJ_POWER)
DRIVER_DISPATCH_RAISED InPortPower;
_Dispatch_type_(IRP_MJ_SYSTEM_CONTROL)
+CODE_SEG("PAGE")
DRIVER_DISPATCH_PAGED InPortWmi;
_Dispatch_type_(IRP_MJ_PNP)
+CODE_SEG("PAGE")
DRIVER_DISPATCH_PAGED InPortPnp;
KSERVICE_ROUTINE InPortIsr;
@@ -104,33 +112,39 @@ KSYNCHRONIZE_ROUTINE InPortStartMouse;
KSYNCHRONIZE_ROUTINE InPortStopMouse;
+CODE_SEG("PAGE")
NTSTATUS
NTAPI
InPortStartDevice(
_In_ PDEVICE_OBJECT DeviceObject,
_Inout_ PIRP Irp);
+CODE_SEG("PAGE")
NTSTATUS
NTAPI
InPortRemoveDevice(
_In_ PDEVICE_OBJECT DeviceObject,
_Inout_ PIRP Irp);
+CODE_SEG("PAGE")
VOID
NTAPI
InPortInitializeMouse(
_In_ PINPORT_DEVICE_EXTENSION DeviceExtension);
+CODE_SEG("PAGE")
NTSTATUS
NTAPI
InPortWmiRegistration(
_Inout_ PINPORT_DEVICE_EXTENSION DeviceExtension);
+CODE_SEG("PAGE")
NTSTATUS
NTAPI
InPortWmiDeRegistration(
_Inout_ PINPORT_DEVICE_EXTENSION DeviceExtension);
+CODE_SEG("PAGE")
NTSTATUS
NTAPI
InPortQueryWmiRegInfo(
@@ -141,6 +155,7 @@ InPortQueryWmiRegInfo(
_Inout_ PUNICODE_STRING MofResourceName,
_Out_opt_ PDEVICE_OBJECT *Pdo);
+CODE_SEG("PAGE")
NTSTATUS
NTAPI
InPortQueryWmiDataBlock(
diff --git a/drivers/input/inport/pnp.c b/drivers/input/inport/pnp.c
index 82d0cd5b2c4..5484c8be375 100644
--- a/drivers/input/inport/pnp.c
+++ b/drivers/input/inport/pnp.c
@@ -12,16 +12,9 @@
#define NDEBUG
#include <debug.h>
-/* GLOBALS ********************************************************************/
-
-#ifdef ALLOC_PRAGMA
-#pragma alloc_text(PAGE, InPortPnp)
-#pragma alloc_text(PAGE, InPortStartDevice)
-#pragma alloc_text(PAGE, InPortRemoveDevice)
-#endif
-
/* FUNCTIONS ******************************************************************/
+CODE_SEG("PAGE")
NTSTATUS
NTAPI
InPortStartDevice(
@@ -178,6 +171,7 @@ Complete:
return Status;
}
+CODE_SEG("PAGE")
NTSTATUS
NTAPI
InPortRemoveDevice(
@@ -221,6 +215,7 @@ InPortRemoveDevice(
return Status;
}
+CODE_SEG("PAGE")
NTSTATUS
NTAPI
InPortPnp(
diff --git a/drivers/input/inport/wmi.c b/drivers/input/inport/wmi.c
index 957fb14db53..1f5f996b22d 100644
--- a/drivers/input/inport/wmi.c
+++ b/drivers/input/inport/wmi.c
@@ -14,14 +14,6 @@
/* GLOBALS ********************************************************************/
-#ifdef ALLOC_PRAGMA
-#pragma alloc_text(PAGE, InPortWmi)
-#pragma alloc_text(PAGE, InPortWmiRegistration)
-#pragma alloc_text(PAGE, InPortWmiDeRegistration)
-#pragma alloc_text(PAGE, InPortQueryWmiRegInfo)
-#pragma alloc_text(PAGE, InPortQueryWmiDataBlock)
-#endif
-
GUID GuidWmiPortData = POINTER_PORT_WMI_STD_DATA_GUID;
WMIGUIDREGINFO InPortWmiGuidList[] =
@@ -30,7 +22,7 @@ WMIGUIDREGINFO InPortWmiGuidList[] =
};
/* FUNCTIONS ******************************************************************/
-
+CODE_SEG("PAGE")
NTSTATUS
NTAPI
InPortQueryWmiRegInfo(
@@ -57,6 +49,7 @@ InPortQueryWmiRegInfo(
return STATUS_SUCCESS;
}
+CODE_SEG("PAGE")
NTSTATUS
NTAPI
InPortQueryWmiDataBlock(
@@ -119,6 +112,7 @@ Complete:
IO_NO_INCREMENT);
}
+CODE_SEG("PAGE")
NTSTATUS
NTAPI
InPortWmiRegistration(
@@ -140,6 +134,7 @@ InPortWmiRegistration(
WMIREG_ACTION_REGISTER);
}
+CODE_SEG("PAGE")
NTSTATUS
NTAPI
InPortWmiDeRegistration(
@@ -151,6 +146,7 @@ InPortWmiDeRegistration(
WMIREG_ACTION_DEREGISTER);
}
+CODE_SEG("PAGE")
NTSTATUS
NTAPI
InPortWmi(
diff --git a/drivers/storage/class/disk_new/data.c
b/drivers/storage/class/disk_new/data.c
index 97214055bb1..2b28148e462 100644
--- a/drivers/storage/class/disk_new/data.c
+++ b/drivers/storage/class/disk_new/data.c
@@ -22,9 +22,11 @@ Revision History:
#include "disk.h"
+#ifndef __REACTOS__
#ifdef ALLOC_DATA_PRAGMA
#pragma data_seg("PAGE")
#endif
+#endif
/*
#define HackDisableTaggedQueuing (0x01)
@@ -34,7 +36,9 @@ Revision History:
#define HackCauseNotReportableHack (0x10)
#define HackRequiresStartUnitCommand (0x20)
*/
-
+#ifdef __REACTOS__
+DATA_SEG("PAGEDATA")
+#endif
CLASSPNP_SCAN_FOR_SPECIAL_INFO DiskBadControllers[] = {
{ "COMPAQ" , "PD-1" , NULL, 0x02 },
{ "CONNER" , "CP3500" , NULL, 0x02 },
@@ -64,11 +68,17 @@ CLASSPNP_SCAN_FOR_SPECIAL_INFO DiskBadControllers[] = {
// Added MediaTypes in their own brace nesting level
// ======== ROS DIFF ========
+#ifdef __REACTOS__
+DATA_SEG("PAGECONS")
+#endif
DISK_MEDIA_TYPES_LIST const DiskMediaTypesExclude[] = {
{ "HP" , "RDX" , NULL, 0, 0, {0 ,
0 , 0 , 0 }},
{ NULL , NULL , NULL, 0, 0, {0 , 0 , 0 , 0
}}
};
+#ifdef __REACTOS__
+DATA_SEG("PAGECONS")
+#endif
DISK_MEDIA_TYPES_LIST const DiskMediaTypes[] = {
{ "COMPAQ" , "PD-1 LF-1094" , NULL, 1, 1, {PC_5_RW ,
0 , 0 , 0 }},
{ "HP" , NULL , NULL, 2, 2, {MO_5_WO , MO_5_RW, 0
, 0 }},
@@ -83,6 +93,8 @@ DISK_MEDIA_TYPES_LIST const DiskMediaTypes[] = {
{ NULL , NULL , NULL, 0, 0, {0 , 0 , 0 , 0
}}
};
+#ifndef __REACTOS__
#ifdef ALLOC_DATA_PRAGMA
#pragma data_seg()
#endif
+#endif
diff --git a/drivers/storage/class/disk_new/disk.h
b/drivers/storage/class/disk_new/disk.h
index 7954cb0eb1e..d46bafe8ca4 100644
--- a/drivers/storage/class/disk_new/disk.h
+++ b/drivers/storage/class/disk_new/disk.h
@@ -469,6 +469,10 @@ extern CLASSPNP_SCAN_FOR_SPECIAL_INFO DiskBadControllers[];
extern const DISK_MEDIA_TYPES_LIST DiskMediaTypes[];
extern const DISK_MEDIA_TYPES_LIST DiskMediaTypesExclude[];
+#if defined(__REACTOS__) && defined(_MSC_VER)
+# pragma section("PAGECONS", read)
+# pragma section("PAGEDATA", read,write)
+#endif
//
// Macros
//
@@ -477,7 +481,7 @@ extern const DISK_MEDIA_TYPES_LIST DiskMediaTypesExclude[];
// Routine prototypes.
//
-
+
DRIVER_INITIALIZE DriverEntry;
VOID
diff --git a/drivers/storage/mountmgr/mntmgr.h b/drivers/storage/mountmgr/mntmgr.h
index 11fa4bf3b6c..943568ff213 100644
--- a/drivers/storage/mountmgr/mntmgr.h
+++ b/drivers/storage/mountmgr/mntmgr.h
@@ -176,6 +176,7 @@ extern UNICODE_STRING Volume;
extern KEVENT UnloadEvent;
extern LONG Unloading;
+CODE_SEG("INIT")
DRIVER_INITIALIZE DriverEntry;
VOID
@@ -228,6 +229,7 @@ HasDriveLetter(
IN PDEVICE_INFORMATION DeviceInformation
);
+CODE_SEG("INIT")
BOOLEAN
MountmgrReadNoAutoMount(
IN PUNICODE_STRING RegistryPath
diff --git a/drivers/storage/mountmgr/mountmgr.c b/drivers/storage/mountmgr/mountmgr.c
index e733d322766..468358eb92c 100644
--- a/drivers/storage/mountmgr/mountmgr.c
+++ b/drivers/storage/mountmgr/mountmgr.c
@@ -29,11 +29,6 @@
#define NDEBUG
#include <debug.h>
-#if defined(ALLOC_PRAGMA)
-#pragma alloc_text(INIT, MountmgrReadNoAutoMount)
-#pragma alloc_text(INIT, DriverEntry)
-#endif
-
/* FIXME */
GUID MountedDevicesGuid = {0x53F5630D, 0xB6BF, 0x11D0, {0x94, 0xF2, 0x00, 0xA0, 0xC9,
0x1E, 0xFB, 0x8B}};
diff --git a/drivers/storage/partmgr/partmgr.h b/drivers/storage/partmgr/partmgr.h
index 2878942629a..5bdc30a40cf 100644
--- a/drivers/storage/partmgr/partmgr.h
+++ b/drivers/storage/partmgr/partmgr.h
@@ -100,6 +100,7 @@ typedef struct _PARTITION_EXTENSION
UNICODE_STRING DeviceName;
} PARTITION_EXTENSION, *PPARTITION_EXTENSION;
+CODE_SEG("PAGE")
NTSTATUS
PartitionCreateDevice(
_In_ PDEVICE_OBJECT FDObject,
@@ -108,11 +109,13 @@ PartitionCreateDevice(
_In_ PARTITION_STYLE PartitionStyle,
_Out_ PDEVICE_OBJECT *PDO);
+CODE_SEG("PAGE")
NTSTATUS
PartitionHandleRemove(
_In_ PPARTITION_EXTENSION PartExt,
_In_ BOOLEAN FinalRemove);
+CODE_SEG("PAGE")
NTSTATUS
PartitionHandlePnp(
_In_ PDEVICE_OBJECT DeviceObject,
diff --git a/hal/halx86/include/bus.h b/hal/halx86/include/bus.h
index cfda40f9b34..443d649fc9c 100644
--- a/hal/halx86/include/bus.h
+++ b/hal/halx86/include/bus.h
@@ -282,6 +282,7 @@ extern PCI_CONFIG_HANDLER PCIConfigHandler;
extern PCI_CONFIG_HANDLER PCIConfigHandlerType1;
extern PCI_CONFIG_HANDLER PCIConfigHandlerType2;
+CODE_SEG("INIT")
PPCI_REGISTRY_INFO_INTERNAL
NTAPI
HalpQueryPciRegistryInfo(
@@ -425,12 +426,14 @@ HalpSetCmosData(
IN ULONG Length
);
+CODE_SEG("INIT")
VOID
NTAPI
HalpInitializePciBus(
VOID
);
+CODE_SEG("INIT")
VOID
NTAPI
HalpInitializePciStubs(
@@ -470,6 +473,7 @@ HalpFindBusAddressTranslation(
IN BOOLEAN NextBus
);
+CODE_SEG("INIT")
VOID
NTAPI
HalpRegisterPciDebuggingDeviceInfo(
diff --git a/hal/halx86/include/hal.h b/hal/halx86/include/hal.h
index ec38e8c70ce..a5a9ddb755c 100644
--- a/hal/halx86/include/hal.h
+++ b/hal/halx86/include/hal.h
@@ -39,6 +39,7 @@
/* For MSVC, this is required before using DATA_SEG (used in pcidata) */
#ifdef _MSC_VER
# pragma section("INIT", read,execute,discard)
+# pragma section("INITDATA", read,discard)
#endif
/* Internal shared PCI and ACPI header */
diff --git a/hal/halx86/include/halacpi.h b/hal/halx86/include/halacpi.h
index 8f51fdf3693..e6c2728f34f 100644
--- a/hal/halx86/include/halacpi.h
+++ b/hal/halx86/include/halacpi.h
@@ -24,6 +24,7 @@ HalpAcpiGetTable(
IN ULONG Signature
);
+CODE_SEG("INIT")
NTSTATUS
NTAPI
HalpSetupAcpiPhase0(
diff --git a/hal/halx86/include/halp.h b/hal/halx86/include/halp.h
index 746230f5d91..c8fc2715798 100644
--- a/hal/halx86/include/halp.h
+++ b/hal/halx86/include/halp.h
@@ -189,6 +189,7 @@ typedef struct _HalAddressUsage
PADAPTER_OBJECT NTAPI HalpAllocateAdapterEx(ULONG NumberOfMapRegisters,BOOLEAN IsMaster,
BOOLEAN Dma32BitAddresses);
/* sysinfo.c */
+CODE_SEG("INIT")
VOID
NTAPI
HalpRegisterVector(IN UCHAR Flags,
@@ -196,6 +197,7 @@ HalpRegisterVector(IN UCHAR Flags,
IN ULONG SystemVector,
IN KIRQL Irql);
+CODE_SEG("INIT")
VOID
NTAPI
HalpEnableInterruptHandler(IN UCHAR Flags,
@@ -217,7 +219,7 @@ DECLSPEC_NORETURN VOID FASTCALL HalpDispatchInterrupt2ndEntry(IN
PKTRAP_FRAME Tr
extern BOOLEAN HalpProfilingStopped;
/* timer.c */
-VOID NTAPI HalpInitializeClock(VOID);
+CODE_SEG("INIT") VOID NTAPI HalpInitializeClock(VOID);
VOID __cdecl HalpClockInterrupt(VOID);
VOID __cdecl HalpProfileInterrupt(VOID);
@@ -235,7 +237,7 @@ HalpCalibrateStallExecution(VOID);
VOID HalpInitPciBus (VOID);
/* dma.c */
-VOID HalpInitDma (VOID);
+CODE_SEG("INIT") VOID HalpInitDma (VOID);
/* Non-generic initialization */
VOID HalpInitPhase0 (PLOADER_PARAMETER_BLOCK LoaderBlock);
@@ -254,12 +256,14 @@ HalpCheckPowerButton(
VOID
);
+CODE_SEG("INIT")
VOID
NTAPI
HalpRegisterKdSupportFunctions(
VOID
);
+CODE_SEG("INIT")
NTSTATUS
NTAPI
HalpSetupPciDeviceForDebugging(
@@ -267,6 +271,7 @@ HalpSetupPciDeviceForDebugging(
IN OUT PDEBUG_DEVICE_DESCRIPTOR PciDevice
);
+CODE_SEG("INIT")
NTSTATUS
NTAPI
HalpReleasePciDeviceForDebugging(
@@ -375,6 +380,7 @@ HaliHaltSystem(
//
// CMOS Routines
//
+CODE_SEG("INIT")
VOID
NTAPI
HalpInitializeCmos(
@@ -429,36 +435,42 @@ HalpOpenRegistryKey(
IN BOOLEAN Create
);
+CODE_SEG("INIT")
VOID
NTAPI
HalpGetNMICrashFlag(
VOID
);
+CODE_SEG("INIT")
BOOLEAN
NTAPI
HalpGetDebugPortTable(
VOID
);
+CODE_SEG("INIT")
VOID
NTAPI
HalpReportSerialNumber(
VOID
);
+CODE_SEG("INIT")
NTSTATUS
NTAPI
HalpMarkAcpiHal(
VOID
);
+CODE_SEG("INIT")
VOID
NTAPI
HalpBuildAddressMap(
VOID
);
+CODE_SEG("INIT")
VOID
NTAPI
HalpReportResourceUsage(
@@ -466,6 +478,7 @@ HalpReportResourceUsage(
IN INTERFACE_TYPE InterfaceType
);
+CODE_SEG("INIT")
ULONG
NTAPI
HalpIs16BitPortDecodeSupported(
@@ -486,6 +499,7 @@ KeUpdateSystemTime(
IN KIRQL OldIrql
);
+CODE_SEG("INIT")
VOID
NTAPI
HalpInitBusHandlers(
@@ -498,6 +512,7 @@ HaliInitPnpDriver(
VOID
);
+CODE_SEG("INIT")
VOID
NTAPI
HalpDebugPciDumpBus(
diff --git a/hal/halx86/legacy/bussupp.c b/hal/halx86/legacy/bussupp.c
index 20174bb8b73..65a9e5c8e1c 100644
--- a/hal/halx86/legacy/bussupp.c
+++ b/hal/halx86/legacy/bussupp.c
@@ -12,6 +12,92 @@
#define NDEBUG
#include <debug.h>
+CODE_SEG("INIT")
+PBUS_HANDLER
+NTAPI
+HalpAllocateAndInitPciBusHandler(
+ IN ULONG PciType,
+ IN ULONG BusNo,
+ IN BOOLEAN TestAllocation
+);
+
+CODE_SEG("INIT")
+VOID
+NTAPI
+HalpFixupPciSupportedRanges(
+ IN ULONG BusCount
+);
+
+CODE_SEG("INIT")
+NTSTATUS
+NTAPI
+HalpGetChipHacks(
+ IN USHORT VendorId,
+ IN USHORT DeviceId,
+ IN UCHAR RevisionId,
+ IN PULONG HackFlags
+);
+
+CODE_SEG("INIT")
+BOOLEAN
+NTAPI
+HalpGetPciBridgeConfig(
+ IN ULONG PciType,
+ IN PUCHAR BusCount
+);
+
+CODE_SEG("INIT")
+BOOLEAN
+NTAPI
+HalpIsBridgeDevice(
+ IN PPCI_COMMON_CONFIG PciData
+);
+
+CODE_SEG("INIT")
+BOOLEAN
+NTAPI
+HalpIsIdeDevice(
+ IN PPCI_COMMON_CONFIG PciData
+);
+
+CODE_SEG("INIT")
+BOOLEAN
+NTAPI
+HalpIsRecognizedCard(
+ IN PPCI_REGISTRY_INFO_INTERNAL PciRegistryInfo,
+ IN PPCI_COMMON_CONFIG PciData,
+ IN ULONG Flags
+);
+
+CODE_SEG("INIT")
+BOOLEAN
+NTAPI
+HalpIsValidPCIDevice(
+ IN PBUS_HANDLER BusHandler,
+ IN PCI_SLOT_NUMBER Slot
+);
+
+CODE_SEG("INIT")
+NTSTATUS
+NTAPI
+HalpMarkChipsetDecode(
+ IN BOOLEAN OverrideEnable
+);
+
+CODE_SEG("INIT")
+VOID
+NTAPI
+HalpRegisterInternalBusHandlers(
+ VOID
+);
+
+CODE_SEG("INIT")
+VOID
+NTAPI
+ShowSize(
+ IN ULONG Size
+);
+
/* GLOBALS ********************************************************************/
extern KSPIN_LOCK HalpPCIConfigLock;
diff --git a/hal/halx86/pcidata.cmake b/hal/halx86/pcidata.cmake
index de18293f589..b2034c49d2b 100644
--- a/hal/halx86/pcidata.cmake
+++ b/hal/halx86/pcidata.cmake
@@ -3,11 +3,13 @@
#
add_custom_command(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/pci_classes.c
${CMAKE_CURRENT_BINARY_DIR}/pci_classes.h
- COMMAND native-bin2c ${CMAKE_CURRENT_SOURCE_DIR}/legacy/bus/pci_classes.ids
${CMAKE_CURRENT_BINARY_DIR}/pci_classes.c ${CMAKE_CURRENT_BINARY_DIR}/pci_classes.h BINSTR
ClassTable DATA_SEG\(\"INIT\"\) ${CMAKE_CURRENT_SOURCE_DIR}/include/hal.h
- DEPENDS native-bin2c ${CMAKE_CURRENT_SOURCE_DIR}/legacy/bus/pci_classes.ids
VERBATIM)
+ COMMAND native-bin2c ${CMAKE_CURRENT_SOURCE_DIR}/legacy/bus/pci_classes.ids
${CMAKE_CURRENT_BINARY_DIR}/pci_classes.c ${CMAKE_CURRENT_BINARY_DIR}/pci_classes.h BINSTR
ClassTable "DATA_SEG\(\"INITDATA\"\)"
${CMAKE_CURRENT_SOURCE_DIR}/include/hal.h
+ DEPENDS native-bin2c ${CMAKE_CURRENT_SOURCE_DIR}/legacy/bus/pci_classes.ids
+ VERBATIM)
add_custom_command(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/pci_vendors.c
${CMAKE_CURRENT_BINARY_DIR}/pci_vendors.h
- COMMAND native-bin2c ${CMAKE_CURRENT_SOURCE_DIR}/legacy/bus/pci_vendors.ids
${CMAKE_CURRENT_BINARY_DIR}/pci_vendors.c ${CMAKE_CURRENT_BINARY_DIR}/pci_vendors.h BINSTR
VendorTable DATA_SEG\(\"INIT\"\) ${CMAKE_CURRENT_SOURCE_DIR}/include/hal.h
- DEPENDS native-bin2c ${CMAKE_CURRENT_SOURCE_DIR}/legacy/bus/pci_vendors.ids
VERBATIM)
+ COMMAND native-bin2c ${CMAKE_CURRENT_SOURCE_DIR}/legacy/bus/pci_vendors.ids
${CMAKE_CURRENT_BINARY_DIR}/pci_vendors.c ${CMAKE_CURRENT_BINARY_DIR}/pci_vendors.h BINSTR
VendorTable "DATA_SEG\(\"INITDATA\"\)"
${CMAKE_CURRENT_SOURCE_DIR}/include/hal.h
+ DEPENDS native-bin2c ${CMAKE_CURRENT_SOURCE_DIR}/legacy/bus/pci_vendors.ids
+ VERBATIM)
#####################################
diff --git a/ntoskrnl/cache/newcc.h b/ntoskrnl/cache/newcc.h
index 801bdc08bb8..d71779f42ff 100644
--- a/ntoskrnl/cache/newcc.h
+++ b/ntoskrnl/cache/newcc.h
@@ -38,6 +38,7 @@ typedef struct _NOCC_CACHE_MAP
ULONG ReadAheadGranularity;
} NOCC_CACHE_MAP, *PNOCC_CACHE_MAP;
+CODE_SEG("INIT")
VOID
NTAPI
CcPfInitializePrefetcher(VOID);
@@ -53,6 +54,7 @@ CcMdlWriteComplete2(IN PFILE_OBJECT FileObject,
IN PLARGE_INTEGER FileOffset,
IN PMDL MdlChain);
+CODE_SEG("INIT")
VOID
NTAPI
CcInitView(VOID);
diff --git a/ntoskrnl/config/cmdata.c b/ntoskrnl/config/cmdata.c
index 95fafb225c6..28ac7041793 100644
--- a/ntoskrnl/config/cmdata.c
+++ b/ntoskrnl/config/cmdata.c
@@ -65,12 +65,7 @@ ULONG CmpTypeCount[MaximumType + 1];
HANDLE CmpRegistryRootHandle;
-// for MSVC, this is required before using DATA_SEG
-#ifdef _MSC_VER
-# pragma section("INIT", read,execute,discard)
-#endif
-
-DATA_SEG("INIT") UNICODE_STRING CmClassName[MaximumClass + 1] =
+DATA_SEG("INITDATA") UNICODE_STRING CmClassName[MaximumClass + 1] =
{
RTL_CONSTANT_STRING(L"System"),
RTL_CONSTANT_STRING(L"Processor"),
@@ -82,7 +77,7 @@ DATA_SEG("INIT") UNICODE_STRING CmClassName[MaximumClass + 1]
=
RTL_CONSTANT_STRING(L"Undefined")
};
-DATA_SEG("INIT") UNICODE_STRING CmTypeName[MaximumType + 1] =
+DATA_SEG("INITDATA") UNICODE_STRING CmTypeName[MaximumType + 1] =
{
RTL_CONSTANT_STRING(L"System"),
RTL_CONSTANT_STRING(L"CentralProcessor"),
@@ -128,7 +123,7 @@ DATA_SEG("INIT") UNICODE_STRING CmTypeName[MaximumType + 1]
=
RTL_CONSTANT_STRING(L"Undefined")
};
-DATA_SEG("INIT") CMP_MF_TYPE CmpMultifunctionTypes[] =
+DATA_SEG("INITDATA") CMP_MF_TYPE CmpMultifunctionTypes[] =
{
{"ISA", Isa, 0},
{"MCA", MicroChannel, 0},
@@ -141,7 +136,7 @@ DATA_SEG("INIT") CMP_MF_TYPE CmpMultifunctionTypes[] =
{NULL, Internal, 0}
};
-DATA_SEG("INIT") CM_SYSTEM_CONTROL_VECTOR CmControlVector[] =
+DATA_SEG("INITDATA") CM_SYSTEM_CONTROL_VECTOR CmControlVector[] =
{
{
L"Session Manager",
diff --git a/ntoskrnl/ex/sem.c b/ntoskrnl/ex/sem.c
index ddd79761ac0..8a1810d5db7 100644
--- a/ntoskrnl/ex/sem.c
+++ b/ntoskrnl/ex/sem.c
@@ -13,6 +13,10 @@
#define NDEBUG
#include <debug.h>
+#if defined (ALLOC_PRAGMA)
+#pragma alloc_text(INIT, ExpInitializeSemaphoreImplementation)
+#endif
+
/* GLOBALS ******************************************************************/
POBJECT_TYPE ExSemaphoreObjectType;
diff --git a/ntoskrnl/ex/uuid.c b/ntoskrnl/ex/uuid.c
index 07530161d29..4df98a37d4a 100644
--- a/ntoskrnl/ex/uuid.c
+++ b/ntoskrnl/ex/uuid.c
@@ -29,6 +29,7 @@
/* 10000 in 100-ns model = 0.1 microsecond */
#define TIME_FRAME 10000
+
/* GLOBALS ****************************************************************/
FAST_MUTEX ExpUuidLock;
diff --git a/ntoskrnl/ex/work.c b/ntoskrnl/ex/work.c
index 03ab0c4bfdf..a10a4878b42 100644
--- a/ntoskrnl/ex/work.c
+++ b/ntoskrnl/ex/work.c
@@ -609,7 +609,7 @@ ExpSetSwappingKernelApc(IN PKAPC Apc,
PKEVENT Event = (PKEVENT)*SystemArgument1;
/* Make sure it's an active worker */
- if (PsGetCurrentThread()->ActiveExWorker)
+ if (PsGetCurrentThread()->ActiveExWorker)
{
/* Read the setting from the context flag */
AllowSwap = (PBOOLEAN)NormalContext;
@@ -670,7 +670,7 @@ ExSwapinWorkerThreads(IN BOOLEAN AllowSwap)
KeClearEvent(&Event);
}
}
-
+
/* Next thread */
Next:
Thread = PsGetNextProcessThread(Process, Thread);
diff --git a/ntoskrnl/include/internal/amd64/mm.h b/ntoskrnl/include/internal/amd64/mm.h
index e62df71cfe0..bdb0066a8d4 100644
--- a/ntoskrnl/include/internal/amd64/mm.h
+++ b/ntoskrnl/include/internal/amd64/mm.h
@@ -295,6 +295,7 @@ MI_IS_MAPPED_PTE(PMMPTE PointerPte)
(PointerPte->u.Hard.PageFrameNumber != 0));
}
+CODE_SEG("INIT")
FORCEINLINE
BOOLEAN
MiIsPdeForAddressValid(PVOID Address)
diff --git a/ntoskrnl/include/internal/cc.h b/ntoskrnl/include/internal/cc.h
index 52a7b19f0a6..1986e888f9e 100644
--- a/ntoskrnl/include/internal/cc.h
+++ b/ntoskrnl/include/internal/cc.h
@@ -287,6 +287,7 @@ extern LAZY_WRITER LazyWriter;
#define NODE_TYPE_PRIVATE_MAP 0x02FE
#define NODE_TYPE_SHARED_MAP 0x02FF
+CODE_SEG("INIT")
VOID
NTAPI
CcPfInitializePrefetcher(
@@ -327,6 +328,7 @@ CcRosEnsureVacbResident(
_In_ ULONG Length
);
+CODE_SEG("INIT")
VOID
NTAPI
CcInitView(VOID);
@@ -335,6 +337,7 @@ VOID
NTAPI
CcShutdownLazyWriter(VOID);
+CODE_SEG("INIT")
BOOLEAN
CcInitializeCacheManager(VOID);
diff --git a/ntoskrnl/include/internal/cm.h b/ntoskrnl/include/internal/cm.h
index 62d31b38544..a251ab1bead 100644
--- a/ntoskrnl/include/internal/cm.h
+++ b/ntoskrnl/include/internal/cm.h
@@ -695,6 +695,7 @@ CmpFlushNotify(
IN BOOLEAN LockHeld
);
+CODE_SEG("INIT")
VOID
NTAPI
CmpInitCallback(
@@ -704,24 +705,28 @@ CmpInitCallback(
//
// KCB Cache/Delay Routines
//
+CODE_SEG("INIT")
VOID
NTAPI
CmpInitializeCache(
VOID
);
+CODE_SEG("INIT")
VOID
NTAPI
CmpInitCmPrivateDelayAlloc(
VOID
);
+CODE_SEG("INIT")
VOID
NTAPI
CmpInitCmPrivateAlloc(
VOID
);
+CODE_SEG("INIT")
VOID
NTAPI
CmpInitDelayDerefKCBEngine(
@@ -964,6 +969,7 @@ VOID
NTAPI
CmpRemoveFromDelayedClose(IN PCM_KEY_CONTROL_BLOCK Kcb);
+CODE_SEG("INIT")
VOID
NTAPI
CmpInitializeDelayedCloseTable(
@@ -1162,6 +1168,7 @@ CmpCreateLinkNode(
//
// Boot Routines
//
+CODE_SEG("INIT")
HCELL_INDEX
NTAPI
CmpFindControlSet(
@@ -1171,6 +1178,7 @@ CmpFindControlSet(
OUT PBOOLEAN AutoSelect
);
+CODE_SEG("INIT")
VOID
NTAPI
CmGetSystemControlValues(
@@ -1187,6 +1195,7 @@ CmpSaveBootControlSet(
//
// Hardware Configuration Routines
//
+CODE_SEG("INIT")
NTSTATUS
NTAPI
CmpInitializeRegistryNode(
@@ -1204,6 +1213,7 @@ CmpInitializeMachineDependentConfiguration(
IN PLOADER_PARAMETER_BLOCK LoaderBlock
);
+CODE_SEG("INIT")
NTSTATUS
NTAPI
CmpInitializeHardwareConfiguration(
@@ -1408,6 +1418,7 @@ CmSaveMergedKeys(
//
// Startup and Shutdown
//
+CODE_SEG("INIT")
BOOLEAN
NTAPI
CmInitSystem1(
@@ -1435,12 +1446,14 @@ CmpSetVersionData(
//
// Driver List Routines
//
+CODE_SEG("INIT")
PUNICODE_STRING*
NTAPI
CmGetSystemDriverList(
VOID
);
+CODE_SEG("INIT")
BOOLEAN
NTAPI
CmpFindDrivers(
@@ -1451,6 +1464,7 @@ CmpFindDrivers(
IN PLIST_ENTRY DriverListHead
);
+CODE_SEG("INIT")
BOOLEAN
NTAPI
CmpSortDriverList(
@@ -1459,12 +1473,14 @@ CmpSortDriverList(
IN PLIST_ENTRY DriverListHead
);
+CODE_SEG("INIT")
BOOLEAN
NTAPI
CmpResolveDriverDependencies(
IN PLIST_ENTRY DriverListHead
);
+CODE_SEG("INIT")
BOOLEAN
NTAPI
CmpIsSafe(
diff --git a/ntoskrnl/include/internal/dbgk.h b/ntoskrnl/include/internal/dbgk.h
index 96cbb1f309b..1fef45aba50 100644
--- a/ntoskrnl/include/internal/dbgk.h
+++ b/ntoskrnl/include/internal/dbgk.h
@@ -46,6 +46,7 @@
#define DBGKTRACE(x, fmt, ...) DPRINT(fmt, ##__VA_ARGS__)
#endif
+CODE_SEG("INIT")
VOID
NTAPI
DbgkInitialize(
diff --git a/ntoskrnl/include/internal/ex.h b/ntoskrnl/include/internal/ex.h
index 4a0e94d7da4..2b8b0026794 100644
--- a/ntoskrnl/include/internal/ex.h
+++ b/ntoskrnl/include/internal/ex.h
@@ -190,6 +190,7 @@ C_ASSERT(RTL_FIELD_SIZE(UUID_CACHED_VALUES_STRUCT, GuidInit) ==
RTL_FIELD_SIZE(U
/* INITIALIZATION FUNCTIONS *************************************************/
+CODE_SEG("INIT")
BOOLEAN
NTAPI
ExpWin32kInit(VOID);
@@ -204,6 +205,7 @@ Phase1Initialization(
IN PVOID Context
);
+CODE_SEG("INIT")
VOID
NTAPI
ExpInitializePushLocks(VOID);
@@ -214,6 +216,7 @@ ExRefreshTimeZoneInformation(
IN PLARGE_INTEGER SystemBootTime
);
+CODE_SEG("INIT")
VOID
NTAPI
ExpInitializeWorkerThreads(VOID);
@@ -222,10 +225,12 @@ VOID
NTAPI
ExSwapinWorkerThreads(IN BOOLEAN AllowSwap);
+CODE_SEG("INIT")
VOID
NTAPI
ExpInitLookasideLists(VOID);
+CODE_SEG("INIT")
VOID
NTAPI
ExInitializeSystemLookasideList(
@@ -237,18 +242,22 @@ ExInitializeSystemLookasideList(
IN PLIST_ENTRY ListHead
);
+CODE_SEG("INIT")
BOOLEAN
NTAPI
ExpInitializeCallbacks(VOID);
+CODE_SEG("INIT")
BOOLEAN
NTAPI
ExpUuidInitialization(VOID);
+CODE_SEG("INIT")
BOOLEAN
NTAPI
ExLuidInitialization(VOID);
+CODE_SEG("INIT")
VOID
NTAPI
ExpInitializeExecutive(
@@ -260,38 +269,47 @@ VOID
NTAPI
ExShutdownSystem(VOID);
+CODE_SEG("INIT")
BOOLEAN
NTAPI
ExpInitializeEventImplementation(VOID);
+CODE_SEG("INIT")
BOOLEAN
NTAPI
ExpInitializeKeyedEventImplementation(VOID);
+CODE_SEG("INIT")
BOOLEAN
NTAPI
ExpInitializeEventPairImplementation(VOID);
+CODE_SEG("INIT")
BOOLEAN
NTAPI
ExpInitializeSemaphoreImplementation(VOID);
+CODE_SEG("INIT")
BOOLEAN
NTAPI
ExpInitializeMutantImplementation(VOID);
+CODE_SEG("INIT")
BOOLEAN
NTAPI
ExpInitializeTimerImplementation(VOID);
+CODE_SEG("INIT")
BOOLEAN
NTAPI
ExpInitializeProfileImplementation(VOID);
+CODE_SEG("INIT")
VOID
NTAPI
ExpResourceInitialization(VOID);
+CODE_SEG("INIT")
VOID
NTAPI
ExInitPoolLookasidePointers(VOID);
@@ -431,6 +449,7 @@ typedef BOOLEAN
ULONG_PTR Context
);
+CODE_SEG("INIT")
VOID
NTAPI
ExpInitializeHandleTables(
@@ -1486,12 +1505,14 @@ ExTimerRundown(
VOID
);
+CODE_SEG("INIT")
VOID
NTAPI
HeadlessInit(
IN PLOADER_PARAMETER_BLOCK LoaderBlock
);
+CODE_SEG("INIT")
VOID
NTAPI
XIPInit(
diff --git a/ntoskrnl/include/internal/fsrtl.h b/ntoskrnl/include/internal/fsrtl.h
index 228bb7a1cf8..5e106c38c1b 100644
--- a/ntoskrnl/include/internal/fsrtl.h
+++ b/ntoskrnl/include/internal/fsrtl.h
@@ -108,12 +108,14 @@ typedef struct _INT_MAPPING
//
// Initialization Routines
//
+CODE_SEG("INIT")
VOID
NTAPI
FsRtlInitializeLargeMcbs(
VOID
);
+CODE_SEG("INIT")
VOID
NTAPI
FsRtlInitializeTunnels(
@@ -129,6 +131,7 @@ FsRtlPTeardownPerFileObjectContexts(
IN PFILE_OBJECT FileObject
);
+CODE_SEG("INIT")
BOOLEAN
NTAPI
FsRtlInitSystem(
diff --git a/ntoskrnl/include/internal/i386/ke.h b/ntoskrnl/include/internal/i386/ke.h
index 71e302b4dde..95242fdbfa0 100644
--- a/ntoskrnl/include/internal/i386/ke.h
+++ b/ntoskrnl/include/internal/i386/ke.h
@@ -381,6 +381,7 @@ KiSetTebBase(PKPCR Pcr, PNT_TIB TebAddress)
Ke386SetGdtEntryBase(&Pcr->GDT[KGDT_R3_TEB / sizeof(KGDTENTRY)], TebAddress);
}
+CODE_SEG("INIT")
VOID
FASTCALL
Ki386InitializeTss(
@@ -389,30 +390,36 @@ Ki386InitializeTss(
IN PKGDTENTRY Gdt
);
+CODE_SEG("INIT")
VOID
NTAPI
KiSetCR0Bits(VOID);
+CODE_SEG("INIT")
VOID
NTAPI
KiGetCacheInformation(VOID);
+CODE_SEG("INIT")
BOOLEAN
NTAPI
KiIsNpxPresent(
VOID
);
+CODE_SEG("INIT")
BOOLEAN
NTAPI
KiIsNpxErrataPresent(
VOID
);
+CODE_SEG("INIT")
VOID
NTAPI
KiSetProcessorType(VOID);
+CODE_SEG("INIT")
ULONG
NTAPI
KiGetFeatureBits(VOID);
@@ -447,18 +454,21 @@ Ki386SetupAndExitToV86Mode(
OUT PTEB VdmTeb
);
+CODE_SEG("INIT")
VOID
NTAPI
KeI386VdmInitialize(
VOID
);
+CODE_SEG("INIT")
ULONG_PTR
NTAPI
Ki386EnableGlobalPage(
IN ULONG_PTR Context
);
+CODE_SEG("INIT")
ULONG_PTR
NTAPI
Ki386EnableTargetLargePage(
@@ -486,48 +496,56 @@ Ki386EnableCurrentLargePage(
IN ULONG Cr3
);
+CODE_SEG("INIT")
VOID
NTAPI
KiI386PentiumLockErrataFixup(
VOID
);
+CODE_SEG("INIT")
VOID
NTAPI
KiInitializePAT(
VOID
);
+CODE_SEG("INIT")
VOID
NTAPI
KiInitializeMTRR(
IN BOOLEAN FinalCpu
);
+CODE_SEG("INIT")
VOID
NTAPI
KiAmdK6InitializeMTRR(
VOID
);
+CODE_SEG("INIT")
VOID
NTAPI
KiRestoreFastSyscallReturnState(
VOID
);
+CODE_SEG("INIT")
ULONG_PTR
NTAPI
Ki386EnableDE(
IN ULONG_PTR Context
);
+CODE_SEG("INIT")
ULONG_PTR
NTAPI
Ki386EnableFxsr(
IN ULONG_PTR Context
);
+CODE_SEG("INIT")
ULONG_PTR
NTAPI
Ki386EnableXMMIExceptions(
@@ -791,12 +809,13 @@ KiCheckForApcDelivery(IN PKTRAP_FRAME TrapFrame)
//
// Switches from boot loader to initial kernel stack
//
+CODE_SEG("INIT")
FORCEINLINE
DECLSPEC_NORETURN
VOID
KiSwitchToBootStack(IN ULONG_PTR InitialStack)
{
- DECLSPEC_NORETURN VOID NTAPI KiSystemStartupBootStack(VOID);
+ CODE_SEG("INIT") DECLSPEC_NORETURN VOID NTAPI
KiSystemStartupBootStack(VOID);
/* We have to switch to a new stack before continuing kernel initialization */
#ifdef __GNUC__
diff --git a/ntoskrnl/include/internal/inbv.h b/ntoskrnl/include/internal/inbv.h
index 204a2aa8023..3dbc8d9896d 100644
--- a/ntoskrnl/include/internal/inbv.h
+++ b/ntoskrnl/include/internal/inbv.h
@@ -6,6 +6,7 @@
//
// Driver Initialization
//
+CODE_SEG("INIT")
BOOLEAN
NTAPI
InbvDriverInitialize(
@@ -32,12 +33,14 @@ InbvBitBlt(
//
// Progress-Bar Functions
//
+CODE_SEG("INIT")
VOID
NTAPI
InbvIndicateProgress(
VOID
);
+CODE_SEG("INIT")
VOID
NTAPI
InbvSetProgressBarSubset(
@@ -45,6 +48,7 @@ InbvSetProgressBarSubset(
_In_ ULONG Ceiling
);
+CODE_SEG("INIT")
VOID
NTAPI
InbvUpdateProgressBar(
@@ -54,24 +58,28 @@ InbvUpdateProgressBar(
//
// Boot Splash-Screen Functions
//
+CODE_SEG("INIT")
VOID
NTAPI
InbvRotBarInit(
VOID
);
+CODE_SEG("INIT")
VOID
NTAPI
DisplayBootBitmap(
IN BOOLEAN TextMode
);
+CODE_SEG("INIT")
VOID
NTAPI
DisplayFilter(
IN PCHAR *String
);
+CODE_SEG("INIT")
VOID
NTAPI
FinalizeBootLogo(
diff --git a/ntoskrnl/include/internal/io.h b/ntoskrnl/include/internal/io.h
index 12f9ebea0bc..095d63bbefc 100644
--- a/ntoskrnl/include/internal/io.h
+++ b/ntoskrnl/include/internal/io.h
@@ -571,6 +571,15 @@ IopDetectResourceConflict(
//
NTSTATUS
NTAPI
+PipCallDriverAddDevice(
+ IN PDEVICE_NODE DeviceNode,
+ IN BOOLEAN LoadDriver,
+ IN PDRIVER_OBJECT DriverObject
+);
+
+CODE_SEG("INIT")
+NTSTATUS
+NTAPI
IopInitializePlugPlayServices(
VOID
);
@@ -662,6 +671,7 @@ IoDestroyDriverList(
VOID
);
+CODE_SEG("INIT")
NTSTATUS
IopInitPlugPlayEvents(VOID);
@@ -713,12 +723,14 @@ IopCreateDeviceKeyPath(
//
// PnP Routines
//
+CODE_SEG("INIT")
NTSTATUS
NTAPI
IopUpdateRootKey(
VOID
);
+CODE_SEG("INIT")
NTSTATUS
NTAPI
PiInitCacheGroupInformation(
@@ -761,12 +773,14 @@ PiSetDevNodeText(
//
// Initialization Routines
//
+CODE_SEG("INIT")
NTSTATUS
NTAPI
IopCreateArcNames(
IN PLOADER_PARAMETER_BLOCK LoaderBlock
);
+CODE_SEG("INIT")
NTSTATUS
NTAPI
IopReassignSystemRoot(
@@ -774,6 +788,7 @@ IopReassignSystemRoot(
OUT PANSI_STRING NtBootPath
);
+CODE_SEG("INIT")
BOOLEAN
NTAPI
IoInitSystem(
@@ -794,6 +809,7 @@ IoInitializeCrashDump(
IN HANDLE PageFileHandle
);
+CODE_SEG("INIT")
VOID
PiInitializeNotifications(
VOID);
@@ -958,11 +974,13 @@ IopShutdownBaseFileSystems(
//
// Boot logging support
//
+CODE_SEG("INIT")
VOID
IopInitBootLog(
IN BOOLEAN StartBootLog
);
+CODE_SEG("INIT")
VOID
IopStartBootLog(
VOID
@@ -1034,6 +1052,7 @@ RawFsIsRawFileSystemDeviceObject(
IN PDEVICE_OBJECT DeviceObject
);
+CODE_SEG("INIT")
NTSTATUS
NTAPI
RawFsDriverEntry(
@@ -1066,12 +1085,14 @@ PnpRootRegisterDevice(
//
// Driver Routines
//
+CODE_SEG("INIT")
VOID
FASTCALL
IopInitializeBootDrivers(
VOID
);
+CODE_SEG("INIT")
VOID
FASTCALL
IopInitializeSystemDrivers(
@@ -1305,6 +1326,7 @@ IoSetIoCompletion(
//
// Ramdisk Routines
//
+CODE_SEG("INIT")
NTSTATUS
NTAPI
IopStartRamdisk(
@@ -1346,16 +1368,19 @@ PiPerformSyncDeviceAction(
//
// PnP notifications
//
+CODE_SEG("PAGE")
VOID
PiNotifyDeviceInterfaceChange(
_In_ LPCGUID Event,
_In_ LPCGUID InterfaceClassGuid,
_In_ PUNICODE_STRING SymbolicLinkName);
+CODE_SEG("PAGE")
VOID
PiNotifyHardwareProfileChange(
_In_ LPCGUID Event);
+CODE_SEG("PAGE")
VOID
PiNotifyTargetDeviceChange(
_In_ LPCGUID Event,
diff --git a/ntoskrnl/include/internal/ke.h b/ntoskrnl/include/internal/ke.h
index 884db0413c0..e5551a5527b 100644
--- a/ntoskrnl/include/internal/ke.h
+++ b/ntoskrnl/include/internal/ke.h
@@ -728,10 +728,12 @@ KeQueryValuesProcess(IN PKPROCESS Process,
/* INITIALIZATION FUNCTIONS *************************************************/
+CODE_SEG("INIT")
BOOLEAN
NTAPI
KeInitSystem(VOID);
+CODE_SEG("INIT")
VOID
NTAPI
KeInitExceptions(VOID);
@@ -740,11 +742,13 @@ VOID
NTAPI
KeInitInterrupts(VOID);
+CODE_SEG("INIT")
VOID
NTAPI
KiInitializeBugCheck(VOID);
DECLSPEC_NORETURN
+CODE_SEG("INIT")
VOID
NTAPI
KiSystemStartup(
@@ -905,6 +909,7 @@ KiChainedDispatch(
IN PKINTERRUPT Interrupt
);
+CODE_SEG("INIT")
VOID
NTAPI
KiInitializeMachineType(
@@ -922,6 +927,7 @@ KiSetupStackAndInitializeKernel(
IN PLOADER_PARAMETER_BLOCK LoaderBlock
);
+CODE_SEG("INIT")
VOID
NTAPI
KiInitSpinLocks(
@@ -929,6 +935,7 @@ KiInitSpinLocks(
IN CCHAR Number
);
+CODE_SEG("INIT")
LARGE_INTEGER
NTAPI
KiComputeReciprocal(
@@ -936,6 +943,7 @@ KiComputeReciprocal(
OUT PUCHAR Shift
);
+CODE_SEG("INIT")
VOID
NTAPI
KiInitSystem(
@@ -964,6 +972,7 @@ KiCallbackReturn(
IN NTSTATUS Status
);
+CODE_SEG("INIT")
VOID
NTAPI
KiInitMachineDependent(VOID);
diff --git a/ntoskrnl/include/internal/lpc.h b/ntoskrnl/include/internal/lpc.h
index e862a4f2476..f8d8640c1c6 100644
--- a/ntoskrnl/include/internal/lpc.h
+++ b/ntoskrnl/include/internal/lpc.h
@@ -137,6 +137,7 @@ LpcExitThread(
//
// Initialization functions
//
+CODE_SEG("INIT")
BOOLEAN
NTAPI
LpcInitSystem(
diff --git a/ntoskrnl/include/internal/mm.h b/ntoskrnl/include/internal/mm.h
index 2f101c97956..7b284a01335 100644
--- a/ntoskrnl/include/internal/mm.h
+++ b/ntoskrnl/include/internal/mm.h
@@ -602,6 +602,7 @@ MiCheckAllProcessMemoryAreas(VOID);
/* npool.c *******************************************************************/
+CODE_SEG("INIT")
VOID
NTAPI
MiInitializeNonPagedPool(VOID);
@@ -652,6 +653,7 @@ MmInit1(
VOID
);
+CODE_SEG("INIT")
BOOLEAN
NTAPI
MmInitSystem(IN ULONG Phase,
... 982 lines suppressed ...