From 3adf45086743d5f075e4270af7af64017eb01d63 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Gardou?= Date: Tue, 11 May 2021 17:13:14 +0200 Subject: [PATCH] [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 | 2961 +++++++++----------- 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, 1720 insertions(+), 1789 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 -#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 -#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 -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 -#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,1213 +42,7 @@ typedef struct _DETACH_DEVICE_WORK_ITEM } DETACH_DEVICE_WORK_ITEM, *PDETACH_DEVICE_WORK_ITEM; - -/* DISPATCH ROUTINES **********************************************/ - -NTSTATUS -NTAPI -FltpPreFsFilterOperation(_In_ PFS_FILTER_CALLBACK_DATA Data, - _Out_ PVOID *CompletionContext) -{ - UNREFERENCED_PARAMETER(Data); - UNREFERENCED_PARAMETER(CompletionContext); - __debugbreak(); - return STATUS_SUCCESS; -} - -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) - { - 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); -} - -NTSTATUS -NTAPI -FltpCreate(_In_ PDEVICE_OBJECT DeviceObject, - _Inout_ PIRP Irp) -{ - PFLTMGR_DEVICE_EXTENSION DeviceExtension; - - PAGED_CODE(); - - DeviceExtension = DeviceObject->DeviceExtension; - - /* Check if this is a request for us */ - if (DeviceObject == DriverData.DeviceObject) - { - FLT_ASSERT(DeviceObject->DriverObject == DriverData.DriverObject); - FLT_ASSERT(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; - } - - /* 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); - } - - 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); -} - -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 ************************************************/ - -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) - -{ - 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 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->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; -} - -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) -{ - 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 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) - { - /* Forward the call onto the device we attached to */ - return FastIoDispatch->FastIoRead(FileObject, - FileOffset, - Length, - Wait, - LockKey, - Buffer, - IoStatus, - AttachedDeviceObject); - } - - /* We failed to handle the request, send it down the slow path */ - FLT_ASSERT(FALSE); - return FALSE; -} - -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; - - 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->FastIoWrite) - { - /* Forward the call onto the device we attached to */ - return FastIoDispatch->FastIoWrite(FileObject, - FileOffset, - Length, - Wait, - LockKey, - Buffer, - IoStatus, - AttachedDeviceObject); - } - - /* 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; - - 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->FastIoQueryBasicInfo) - { - /* Forward the call onto the device we attached to */ - return FastIoDispatch->FastIoQueryBasicInfo(FileObject, - Wait, - Buffer, - IoStatus, - AttachedDeviceObject); - } - - /* We failed to handle the request, send it down the slow path */ - FLT_ASSERT(FALSE); - return FALSE; -} - -BOOLEAN -NTAPI -FltpFastIoQueryStandardInfo(_In_ PFILE_OBJECT FileObject, - _In_ BOOLEAN Wait, - _Out_ PFILE_STANDARD_INFORMATION Buffer, - _Out_ PIO_STATUS_BLOCK IoStatus, - _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) - { - /* 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->FastIoQueryStandardInfo) - { - /* 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; -} - -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) -{ - 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 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->FastIoLock) - { - /* Forward the call onto the device we attached to */ - return FastIoDispatch->FastIoLock(FileObject, - FileOffset, - Length, - ProcessId, - Key, - FailImmediately, - ExclusiveLock, - IoStatus, - AttachedDeviceObject); - } - - /* We failed to handle the request, send it down the slow path */ - FLT_ASSERT(FALSE); - return FALSE; -} - -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) -{ - 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 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->FastIoUnlockSingle) - { - /* Forward the call onto the device we attached to */ - return FastIoDispatch->FastIoUnlockSingle(FileObject, - FileOffset, - Length, - ProcessId, - Key, - IoStatus, - AttachedDeviceObject); - } - - /* We failed to handle the request, send it down the slow path */ - FLT_ASSERT(FALSE); - return FALSE; -} - -BOOLEAN -NTAPI -FltpFastIoUnlockAll(_In_ PFILE_OBJECT FileObject, - _In_ PEPROCESS ProcessId, - _Out_ PIO_STATUS_BLOCK IoStatus, - _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) - { - /* 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->FastIoUnlockAll) - { - /* Forward the call onto the device we attached to */ - return FastIoDispatch->FastIoUnlockAll(FileObject, - ProcessId, - IoStatus, - AttachedDeviceObject); - } - - /* We failed to handle the request, send it down the slow path */ - FLT_ASSERT(FALSE); - return FALSE; -} - -BOOLEAN -NTAPI -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; - 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 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->FastIoUnlockAllByKey) - { - /* Forward the call onto the device we attached to */ - return FastIoDispatch->FastIoUnlockAllByKey(FileObject, - ProcessId, - Key, - IoStatus, - AttachedDeviceObject); - } - - /* We failed to handle the request, send it down the slow path */ - FLT_ASSERT(FALSE); - return FALSE; -} - -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) -{ - 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; - } - - 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->FastIoDeviceControl) - { - /* Forward the call onto the device we attached to */ - return FastIoDispatch->FastIoDeviceControl(FileObject, - Wait, - InputBuffer, - InputBufferLength, - OutputBuffer, - OutputBufferLength, - IoControlCode, - IoStatus, - AttachedDeviceObject); - } - - /* We failed to handle the request, send it down the slow path */ - FLT_ASSERT(FALSE); - 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 -NTAPI -FltpFastIoDetachDevice(_In_ PDEVICE_OBJECT SourceDevice, - _In_ PDEVICE_OBJECT TargetDevice) -{ - PDETACH_DEVICE_WORK_ITEM DetachDeviceWorkItem; - - 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) - { - /* Initialize the work item */ - ExInitializeWorkItem(&DetachDeviceWorkItem->WorkItem, - FltpFastIoDetachDeviceWorker, - DetachDeviceWorkItem); - - /* Queue the work item and return the call */ - ExQueueWorkItem(&DetachDeviceWorkItem->WorkItem, - DelayedWorkQueue); - } - else - { - /* We failed to defer, just cleanup here */ - FltpCleanupDeviceObject(SourceDevice); - IoDetachDevice(TargetDevice); - IoDeleteDevice(SourceDevice); - } - -} - -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) -{ - 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 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->FastIoQueryNetworkOpenInfo) - { - /* Forward the call onto the device we attached to */ - return FastIoDispatch->FastIoQueryNetworkOpenInfo(FileObject, - Wait, - Buffer, - IoStatus, - AttachedDeviceObject); - } - - /* We failed to handle the request, send it down the slow path */ - FLT_ASSERT(FALSE); - return FALSE; -} - -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) -{ - 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 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->MdlRead) - { - /* Forward the call onto the device we attached to */ - return FastIoDispatch->MdlRead(FileObject, - FileOffset, - Length, - LockKey, - MdlChain, - IoStatus, - AttachedDeviceObject); - } - - /* We failed to handle the request, send it down the slow path */ - FLT_ASSERT(FALSE); - return FALSE; -} - -BOOLEAN -NTAPI -FltpFastIoMdlReadComplete(_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) - { - /* Fail the request, send it down the slow path */ - return FALSE; - } - - 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->MdlReadComplete) - { - /* 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 */ - FLT_ASSERT(FALSE); - return FALSE; -} - -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) -{ - 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 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->PrepareMdlWrite) - { - /* Forward the call onto the device we attached to */ - return FastIoDispatch->PrepareMdlWrite(FileObject, - FileOffset, - Length, - LockKey, - MdlChain, - IoStatus, - AttachedDeviceObject); - } - - /* We failed to handle the request, send it down the slow path */ - FLT_ASSERT(FALSE); - return FALSE; -} - -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; - - 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); - - /* 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; -} - -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 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; - } - - 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->FastIoReadCompressed) - { - /* Forward the call onto the device we attached to */ - return FastIoDispatch->FastIoReadCompressed(FileObject, - FileOffset, - Length, - LockKey, - Buffer, - MdlChain, - IoStatus, - CompressedDataInfo, - CompressedDataInfoLength, - AttachedDeviceObject); - } - - /* We failed to handle the request, send it down the slow path */ - FLT_ASSERT(FALSE); - return FALSE; -} - -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) - { - /* Fail the request, send it down the slow path */ - return FALSE; - } - - 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) - { - /* 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 handle the request, send it down the slow path */ - FLT_ASSERT(FALSE); - return FALSE; -} - -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) - { - return FALSE; - } - - 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) - { - /* Forward the call onto the device we attached to */ - return FastIoDispatch->MdlReadCompleteCompressed(FileObject, - MdlChain, - AttachedDeviceObject); - } - - /* We failed to handle the request, send it down the slow path */ - FLT_ASSERT(FALSE); - return FALSE; -} - -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; - - PAGED_CODE(); - - /* If it doesn't have a device extension, then it's not our device object */ - if (DeviceObject->DeviceExtension == NULL) - { - return FALSE; - } - - 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->MdlWriteCompleteCompressed) - { - /* Forward the call onto the device we attached to */ - return FastIoDispatch->MdlWriteCompleteCompressed(FileObject, - FileOffset, - MdlChain, - AttachedDeviceObject); - } - - /* We failed to handle the request, send it down the slow path */ - FLT_ASSERT(FALSE); - return FALSE; -} - -BOOLEAN -NTAPI -FltpFastIoQueryOpen(_Inout_ PIRP Irp, - _Out_ PFILE_NETWORK_OPEN_INFORMATION NetworkInformation, - _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) - { - return FALSE; - } - - 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->FastIoQueryOpen) - { - 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; - } - - /* We failed to handle the request, send it down the slow path */ - FLT_ASSERT(FALSE); - return FALSE; -} - - - -/* FUNCTIONS **********************************************/ +/* LOCAL FUNCTIONS ****************************************/ static VOID @@ -1625,6 +57,7 @@ FltpCleanupDeviceObject(_In_ PDEVICE_OBJECT DeviceObject) } } +CODE_SEG("PAGE") static NTSTATUS FltpAttachDeviceObject(_In_ PDEVICE_OBJECT SourceDevice, @@ -1657,6 +90,7 @@ FltpAttachDeviceObject(_In_ PDEVICE_OBJECT SourceDevice, return Status; } +CODE_SEG("PAGE") static BOOLEAN FltpIsAttachedToDevice(_In_ PDEVICE_OBJECT DeviceObject, @@ -1701,11 +135,12 @@ FltpIsAttachedToDevice(_In_ PDEVICE_OBJECT DeviceObject, /* Decrement the count on the last device before we update the pointer */ ObDereferenceObject(CurrentDeviceObject); CurrentDeviceObject = NextDeviceObject; - } + } return FALSE; } +CODE_SEG("PAGE") static NTSTATUS FltpEnumerateFileSystemVolumes(_In_ PDEVICE_OBJECT DeviceObject) @@ -1883,6 +318,7 @@ CleanupAndNext: return STATUS_SUCCESS; } +CODE_SEG("PAGE") static NTSTATUS FltpAttachToFileSystemDevice(_In_ PDEVICE_OBJECT DeviceObject, @@ -1983,6 +419,7 @@ Cleanup: return Status; } +CODE_SEG("PAGE") static LONG_PTR FltpDetachFromFileSystemDevice(_In_ PDEVICE_OBJECT DeviceObject) @@ -2031,7 +468,1237 @@ FltpDetachFromFileSystemDevice(_In_ PDEVICE_OBJECT DeviceObject) return ObDereferenceObject(AttachedDevice); } + +/* DISPATCH ROUTINES **********************************************/ + +NTSTATUS +NTAPI +FltpPreFsFilterOperation(_In_ PFS_FILTER_CALLBACK_DATA Data, + _Out_ PVOID *CompletionContext) +{ + UNREFERENCED_PARAMETER(Data); + UNREFERENCED_PARAMETER(CompletionContext); + __debugbreak(); + return STATUS_SUCCESS; +} + +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) + { + 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; + + /* Check if this is a request for us */ + if (DeviceObject == DriverData.DeviceObject) + { + FLT_ASSERT(DeviceObject->DriverObject == DriverData.DriverObject); + FLT_ASSERT(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; + } + + /* 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); + } + + 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 +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; + 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 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->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; +} + +CODE_SEG("PAGE") +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) +{ + 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 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) + { + /* Forward the call onto the device we attached to */ + return FastIoDispatch->FastIoRead(FileObject, + FileOffset, + Length, + Wait, + LockKey, + 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 +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; + + 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->FastIoWrite) + { + /* Forward the call onto the device we attached to */ + return FastIoDispatch->FastIoWrite(FileObject, + FileOffset, + Length, + Wait, + LockKey, + 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 +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; + + 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->FastIoQueryBasicInfo) + { + /* Forward the call onto the device we attached to */ + return FastIoDispatch->FastIoQueryBasicInfo(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 +FltpFastIoQueryStandardInfo(_In_ PFILE_OBJECT FileObject, + _In_ BOOLEAN Wait, + _Out_ PFILE_STANDARD_INFORMATION Buffer, + _Out_ PIO_STATUS_BLOCK IoStatus, + _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) + { + /* 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->FastIoQueryStandardInfo) + { + /* 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 +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; + 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 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->FastIoLock) + { + /* Forward the call onto the device we attached to */ + return FastIoDispatch->FastIoLock(FileObject, + FileOffset, + Length, + ProcessId, + Key, + FailImmediately, + ExclusiveLock, + IoStatus, + AttachedDeviceObject); + } + + /* We failed to handle the request, send it down the slow path */ + FLT_ASSERT(FALSE); + return FALSE; +} + +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) +{ + 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 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->FastIoUnlockSingle) + { + /* Forward the call onto the device we attached to */ + return FastIoDispatch->FastIoUnlockSingle(FileObject, + FileOffset, + Length, + ProcessId, + Key, + IoStatus, + AttachedDeviceObject); + } + + /* We failed to handle the request, send it down the slow path */ + FLT_ASSERT(FALSE); + return FALSE; +} + +CODE_SEG("PAGE") +BOOLEAN +NTAPI +FltpFastIoUnlockAll(_In_ PFILE_OBJECT FileObject, + _In_ PEPROCESS ProcessId, + _Out_ PIO_STATUS_BLOCK IoStatus, + _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) + { + /* 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->FastIoUnlockAll) + { + /* Forward the call onto the device we attached to */ + return FastIoDispatch->FastIoUnlockAll(FileObject, + ProcessId, + IoStatus, + AttachedDeviceObject); + } + + /* We failed to handle the request, send it down the slow path */ + FLT_ASSERT(FALSE); + 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) +{ + 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 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->FastIoUnlockAllByKey) + { + /* Forward the call onto the device we attached to */ + return FastIoDispatch->FastIoUnlockAllByKey(FileObject, + ProcessId, + Key, + IoStatus, + AttachedDeviceObject); + } + + /* We failed to handle the request, send it down the slow path */ + FLT_ASSERT(FALSE); + 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) +{ + 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; + } + + 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->FastIoDeviceControl) + { + /* Forward the call onto the device we attached to */ + return FastIoDispatch->FastIoDeviceControl(FileObject, + Wait, + InputBuffer, + InputBufferLength, + OutputBuffer, + OutputBufferLength, + IoControlCode, + IoStatus, + AttachedDeviceObject); + } + + /* We failed to handle the request, send it down the slow path */ + FLT_ASSERT(FALSE); + 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); +} + +CODE_SEG("PAGE") +VOID +NTAPI +FltpFastIoDetachDevice(_In_ PDEVICE_OBJECT SourceDevice, + _In_ PDEVICE_OBJECT TargetDevice) +{ + PDETACH_DEVICE_WORK_ITEM DetachDeviceWorkItem; + + 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) + { + /* Initialize the work item */ + ExInitializeWorkItem(&DetachDeviceWorkItem->WorkItem, + FltpFastIoDetachDeviceWorker, + DetachDeviceWorkItem); + + /* Queue the work item and return the call */ + ExQueueWorkItem(&DetachDeviceWorkItem->WorkItem, + DelayedWorkQueue); + } + else + { + /* We failed to defer, just cleanup here */ + FltpCleanupDeviceObject(SourceDevice); + IoDetachDevice(TargetDevice); + IoDeleteDevice(SourceDevice); + } + +} + +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) +{ + 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 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->FastIoQueryNetworkOpenInfo) + { + /* Forward the call onto the device we attached to */ + return FastIoDispatch->FastIoQueryNetworkOpenInfo(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 +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; + 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 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->MdlRead) + { + /* Forward the call onto the device we attached to */ + return FastIoDispatch->MdlRead(FileObject, + FileOffset, + Length, + LockKey, + MdlChain, + IoStatus, + AttachedDeviceObject); + } + + /* We failed to handle the request, send it down the slow path */ + FLT_ASSERT(FALSE); + return FALSE; +} + +CODE_SEG("PAGE") +BOOLEAN +NTAPI +FltpFastIoMdlReadComplete(_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) + { + /* Fail the request, send it down the slow path */ + return FALSE; + } + + 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->MdlReadComplete) + { + /* 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 */ + FLT_ASSERT(FALSE); + 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) +{ + 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 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->PrepareMdlWrite) + { + /* Forward the call onto the device we attached to */ + return FastIoDispatch->PrepareMdlWrite(FileObject, + FileOffset, + Length, + LockKey, + MdlChain, + IoStatus, + AttachedDeviceObject); + } + + /* We failed to handle the request, send it down the slow path */ + FLT_ASSERT(FALSE); + return FALSE; +} + +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; + + 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); + + /* 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; +} + +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 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; + } + + 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->FastIoReadCompressed) + { + /* Forward the call onto the device we attached to */ + return FastIoDispatch->FastIoReadCompressed(FileObject, + FileOffset, + Length, + LockKey, + Buffer, + MdlChain, + IoStatus, + CompressedDataInfo, + CompressedDataInfoLength, + AttachedDeviceObject); + } + + /* We failed to handle the request, send it down the slow path */ + FLT_ASSERT(FALSE); + return FALSE; +} + +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) + { + /* Fail the request, send it down the slow path */ + return FALSE; + } + + 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) + { + /* 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 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) +{ + 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 FALSE; + } + + 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) + { + /* Forward the call onto the device we attached to */ + return FastIoDispatch->MdlReadCompleteCompressed(FileObject, + MdlChain, + AttachedDeviceObject); + } + + /* We failed to handle the request, send it down the slow path */ + FLT_ASSERT(FALSE); + return FALSE; +} + +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; + + PAGED_CODE(); + + /* If it doesn't have a device extension, then it's not our device object */ + if (DeviceObject->DeviceExtension == NULL) + { + return FALSE; + } + + 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->MdlWriteCompleteCompressed) + { + /* Forward the call onto the device we attached to */ + return FastIoDispatch->MdlWriteCompleteCompressed(FileObject, + FileOffset, + MdlChain, + AttachedDeviceObject); + } + + /* We failed to handle the request, send it down the slow path */ + FLT_ASSERT(FALSE); + return FALSE; +} + +CODE_SEG("PAGE") +BOOLEAN +NTAPI +FltpFastIoQueryOpen(_Inout_ PIRP Irp, + _Out_ PFILE_NETWORK_OPEN_INFORMATION NetworkInformation, + _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) + { + return FALSE; + } + + 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->FastIoQueryOpen) + { + 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; + } + + /* 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 #include +#include + #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 #include +#include + #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 -/* 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 -#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 +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 +#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, @@ -668,6 +670,7 @@ VOID NTAPI MmFreeSwapPage(SWAPENTRY Entry); +CODE_SEG("INIT") VOID NTAPI MmInitPagingFile(VOID); @@ -827,6 +830,7 @@ MmDeleteKernelStack(PVOID Stack, /* balance.c *****************************************************************/ +CODE_SEG("INIT") VOID NTAPI MmInitializeMemoryConsumer( @@ -834,6 +838,7 @@ MmInitializeMemoryConsumer( NTSTATUS (*Trim)(ULONG Target, ULONG Priority, PULONG NrFreed) ); +CODE_SEG("INIT") VOID NTAPI MmInitializeBalancer( @@ -856,6 +861,7 @@ MmRequestPageMemoryConsumer( PPFN_NUMBER AllocatedPage ); +CODE_SEG("INIT") VOID NTAPI MiInitBalancerThread(VOID); @@ -903,6 +909,7 @@ MmDeleteRmap( PVOID Address ); +CODE_SEG("INIT") VOID NTAPI MmInitializeRmapList(VOID); @@ -1078,6 +1085,7 @@ MmIsDisabledPage( PVOID Address ); +CODE_SEG("INIT") VOID NTAPI MmInitGlobalKernelPageDirectory(VOID); @@ -1179,6 +1187,7 @@ MmCreateProcessAddressSpace( IN PULONG_PTR DirectoryTableBase ); +CODE_SEG("INIT") NTSTATUS NTAPI MmInitializeHandBuiltProcess( @@ -1186,6 +1195,7 @@ MmInitializeHandBuiltProcess( IN PULONG_PTR DirectoryTableBase ); +CODE_SEG("INIT") NTSTATUS NTAPI MmInitializeHandBuiltProcess2( @@ -1340,6 +1350,7 @@ MmProtectSectionView( PULONG OldProtect ); +CODE_SEG("INIT") NTSTATUS NTAPI MmInitSectionImplementation(VOID); @@ -1353,6 +1364,16 @@ MmNotPresentFaultSectionView( BOOLEAN Locked ); +NTSTATUS +NTAPI +MmPageOutSectionView( + PMMSUPPORT AddressSpace, + PMEMORY_AREA MemoryArea, + PVOID Address, + ULONG_PTR Entry +); + +CODE_SEG("INIT") NTSTATUS NTAPI MmCreatePhysicalMemorySection(VOID); @@ -1468,12 +1489,14 @@ _MmGetPageEntrySectionSegment(PMM_SECTION_SEGMENT Segment, /* sysldr.c ******************************************************************/ +CODE_SEG("INIT") VOID NTAPI MiReloadBootLoadedDrivers( IN PLOADER_PARAMETER_BLOCK LoaderBlock ); +CODE_SEG("INIT") BOOLEAN NTAPI MiInitializeLoadedModuleList( diff --git a/ntoskrnl/include/internal/ob.h b/ntoskrnl/include/internal/ob.h index 87a5d6901f0..8c3b82faf8a 100644 --- a/ntoskrnl/include/internal/ob.h +++ b/ntoskrnl/include/internal/ob.h @@ -164,6 +164,7 @@ typedef struct _OB_TEMP_BUFFER // // Startup and Shutdown Functions // +CODE_SEG("INIT") BOOLEAN NTAPI ObInitSystem( @@ -434,6 +435,7 @@ ObInheritDeviceMap( IN PEPROCESS Process ); +CODE_SEG("INIT") NTSTATUS NTAPI ObpCreateDosDevicesDirectory( @@ -455,6 +457,7 @@ ObpReferenceDeviceMap( // // Security descriptor cache functions // +CODE_SEG("INIT") NTSTATUS NTAPI ObpInitSdCache( diff --git a/ntoskrnl/include/internal/po.h b/ntoskrnl/include/internal/po.h index beb3f3b4112..f763a33f3ea 100644 --- a/ntoskrnl/include/internal/po.h +++ b/ntoskrnl/include/internal/po.h @@ -264,12 +264,14 @@ typedef struct _POP_SHUTDOWN_WAIT_ENTRY // // Initialization routines // +CODE_SEG("INIT") BOOLEAN NTAPI PoInitSystem( IN ULONG BootPhase ); +CODE_SEG("INIT") VOID NTAPI PoInitializePrcb( diff --git a/ntoskrnl/include/internal/ps.h b/ntoskrnl/include/internal/ps.h index b6eb06d2504..fab63a9b8d0 100644 --- a/ntoskrnl/include/internal/ps.h +++ b/ntoskrnl/include/internal/ps.h @@ -90,6 +90,7 @@ PspShutdownProcessManager( VOID ); +CODE_SEG("INIT") BOOLEAN NTAPI PsInitSystem( @@ -120,6 +121,7 @@ PspMapSystemDll( IN BOOLEAN UseLargePages ); +CODE_SEG("INIT") NTSTATUS NTAPI PsLocateSystemDll( @@ -352,6 +354,7 @@ PspRemoveProcessFromJob( IN PEJOB Job ); +CODE_SEG("INIT") VOID NTAPI PspInitializeJobStructures( @@ -415,6 +418,7 @@ PspIsProcessExiting(IN PEPROCESS Process); // // Apphelp functions // +CODE_SEG("INIT") NTSTATUS NTAPI ApphelpCacheInitialize(VOID); diff --git a/ntoskrnl/include/internal/se.h b/ntoskrnl/include/internal/se.h index 0a8561d397a..698d7067bae 100644 --- a/ntoskrnl/include/internal/se.h +++ b/ntoskrnl/include/internal/se.h @@ -256,22 +256,27 @@ SeTokenCanImpersonate( _In_ SECURITY_IMPERSONATION_LEVEL ImpersonationLevel); /* Functions */ +CODE_SEG("INIT") BOOLEAN NTAPI SeInitSystem(VOID); +CODE_SEG("INIT") VOID NTAPI SepInitPrivileges(VOID); +CODE_SEG("INIT") BOOLEAN NTAPI SepInitSecurityIDs(VOID); +CODE_SEG("INIT") BOOLEAN NTAPI SepInitDACLs(VOID); +CODE_SEG("INIT") BOOLEAN NTAPI SepInitSDs(VOID); @@ -338,17 +343,21 @@ SepCreateImpersonationTokenDacl( _Out_ PACL* Dacl ); +CODE_SEG("INIT") VOID NTAPI SepInitializeTokenImplementation(VOID); +CODE_SEG("INIT") PTOKEN NTAPI SepCreateSystemProcessToken(VOID); +CODE_SEG("INIT") PTOKEN SepCreateSystemAnonymousLogonToken(VOID); +CODE_SEG("INIT") PTOKEN SepCreateSystemAnonymousLogonTokenNoEveryone(VOID); diff --git a/ntoskrnl/include/ntoskrnl.h b/ntoskrnl/include/ntoskrnl.h index 353efeb44c3..a6ac78b4827 100644 --- a/ntoskrnl/include/ntoskrnl.h +++ b/ntoskrnl/include/ntoskrnl.h @@ -124,4 +124,8 @@ C_ASSERT(MAX_WIN32_PATH == MAX_PATH); #include "internal/probe.h" #include "resource.h" +#ifdef _MSC_VER +# pragma section("INITDATA", read,write,discard) +#endif + #endif /* _NTOSKRNL_PCH */ diff --git a/ntoskrnl/io/iomgr/driver.c b/ntoskrnl/io/iomgr/driver.c index 24f6084a892..2b6899ce884 100644 --- a/ntoskrnl/io/iomgr/driver.c +++ b/ntoskrnl/io/iomgr/driver.c @@ -752,6 +752,7 @@ IopGetDeviceObjectFromDeviceInstance(PUNICODE_STRING DeviceInstance); * Initialize a driver that is already loaded in memory. */ CODE_SEG("INIT") +static BOOLEAN IopInitializeBuiltinDriver(IN PLDR_DATA_TABLE_ENTRY BootLdrEntry) { @@ -869,7 +870,7 @@ IopInitializeBuiltinDriver(IN PLDR_DATA_TABLE_ENTRY BootLdrEntry) // for that driver, and queue AddDevice call for them. // The check is possible because HKLM/SYSTEM/CCS/Services//Enum directory // is populated upon a new device arrival based on a (critical) device database - + // Legacy drivers may add devices inside DriverEntry. // We're lazy and always assume that they are doing so BOOLEAN deviceAdded = (_Bool)(DriverObject->Flags & DRVO_LEGACY_DRIVER); @@ -936,7 +937,7 @@ IopInitializeBuiltinDriver(IN PLDR_DATA_TABLE_ENTRY BootLdrEntry) deviceAdded = TRUE; } - ExFreePool(kvInfo); + ExFreePool(kvInfo); } ZwClose(enumServiceHandle); @@ -1118,7 +1119,7 @@ IopInitializeBootDrivers(VOID) PiActionEnumRootDevices, NULL, NULL); - } + } /* Next entry */ NextEntry = NextEntry->Flink; diff --git a/ntoskrnl/io/pnpmgr/plugplay.c b/ntoskrnl/io/pnpmgr/plugplay.c index 28e243dcd79..cb7e03976ab 100644 --- a/ntoskrnl/io/pnpmgr/plugplay.c +++ b/ntoskrnl/io/pnpmgr/plugplay.c @@ -26,8 +26,7 @@ static KEVENT IopPnpNotifyEvent; /* FUNCTIONS *****************************************************************/ -CODE_SEG("INIT") -NTSTATUS +NTSTATUS CODE_SEG("INIT") IopInitPlugPlayEvents(VOID) { InitializeListHead(&IopPnpEventQueueHead); diff --git a/ntoskrnl/ke/amd64/cpu.c b/ntoskrnl/ke/amd64/cpu.c index e41f0083552..3c2b706a906 100644 --- a/ntoskrnl/ke/amd64/cpu.c +++ b/ntoskrnl/ke/amd64/cpu.c @@ -50,7 +50,6 @@ static const CHAR CmpRiseID[] = "RiseRiseRise"; /* FUNCTIONS *****************************************************************/ -CODE_SEG("INIT") VOID NTAPI KiSetProcessorType(VOID) @@ -121,7 +120,6 @@ KiGetCpuVendor(VOID) return CPU_UNKNOWN; } -CODE_SEG("INIT") ULONG NTAPI KiGetFeatureBits(VOID) @@ -211,7 +209,6 @@ KiGetFeatureBits(VOID) return FeatureBits; } -CODE_SEG("INIT") VOID NTAPI KiGetCacheInformation(VOID) diff --git a/ntoskrnl/ke/amd64/kiinit.c b/ntoskrnl/ke/amd64/kiinit.c index eb66b349fa6..9e1c23138f9 100644 --- a/ntoskrnl/ke/amd64/kiinit.c +++ b/ntoskrnl/ke/amd64/kiinit.c @@ -160,7 +160,6 @@ KiInitializePcr(IN PKIPCR Pcr, KeSetCurrentIrql(PASSIVE_LEVEL); } -CODE_SEG("INIT") VOID NTAPI KiInitializeCpu(PKIPCR Pcr) diff --git a/ntoskrnl/ke/arm/kiinit.c b/ntoskrnl/ke/arm/kiinit.c index e5396370e96..c6f4edd594c 100644 --- a/ntoskrnl/ke/arm/kiinit.c +++ b/ntoskrnl/ke/arm/kiinit.c @@ -31,7 +31,6 @@ extern PVOID KiArmVectorTable; /* FUNCTIONS ******************************************************************/ -CODE_SEG("INIT") VOID NTAPI KiInitMachineDependent(VOID) @@ -306,7 +305,6 @@ KiInitializePcr(IN ULONG ProcessorNumber, #endif } -CODE_SEG("INIT") VOID KiInitializeMachineType(VOID) { diff --git a/ntoskrnl/ke/powerpc/cpu.c b/ntoskrnl/ke/powerpc/cpu.c index c3f72573a36..571389ea995 100644 --- a/ntoskrnl/ke/powerpc/cpu.c +++ b/ntoskrnl/ke/powerpc/cpu.c @@ -57,7 +57,6 @@ RDMSR(IN ULONG Register) /* FUNCTIONS *****************************************************************/ -CODE_SEG("INIT") VOID NTAPI KiSetProcessorType(VOID) @@ -71,7 +70,6 @@ KiGetCpuVendor(VOID) return 0; } -CODE_SEG("INIT") ULONG NTAPI KiGetFeatureBits(VOID) @@ -81,7 +79,6 @@ KiGetFeatureBits(VOID) return FeatureBits; } -CODE_SEG("INIT") VOID NTAPI KiGetCacheInformation(VOID) @@ -127,7 +124,6 @@ KiSaveProcessorControlState(OUT PKPROCESSOR_STATE ProcessorState) { } -CODE_SEG("INIT") VOID NTAPI KiInitializeMachineType(VOID) @@ -141,14 +137,12 @@ KiLoadFastSyscallMachineSpecificRegisters(IN ULONG_PTR Context) return 0; } -CODE_SEG("INIT") VOID NTAPI KiRestoreFastSyscallReturnState(VOID) { } -CODE_SEG("INIT") ULONG_PTR NTAPI Ki386EnableDE(IN ULONG_PTR Context) @@ -156,7 +150,6 @@ Ki386EnableDE(IN ULONG_PTR Context) return 0; } -CODE_SEG("INIT") ULONG_PTR NTAPI Ki386EnableFxsr(IN ULONG_PTR Context) diff --git a/ntoskrnl/ke/powerpc/kiinit.c b/ntoskrnl/ke/powerpc/kiinit.c index 01f6c2aa57d..5b564092893 100644 --- a/ntoskrnl/ke/powerpc/kiinit.c +++ b/ntoskrnl/ke/powerpc/kiinit.c @@ -343,7 +343,6 @@ AppCpuInit: (PVOID)LoaderBlock); } -CODE_SEG("INIT") VOID NTAPI KiInitMachineDependent(VOID) diff --git a/ntoskrnl/mm/ARM3/miarm.h b/ntoskrnl/mm/ARM3/miarm.h index caef296e079..adb6af3fd91 100644 --- a/ntoskrnl/mm/ARM3/miarm.h +++ b/ntoskrnl/mm/ARM3/miarm.h @@ -1831,6 +1831,7 @@ MiQueryPageTableReferences(IN PVOID Address) return *RefCount; } +CODE_SEG("INIT") BOOLEAN NTAPI MmArmInitSystem( @@ -1838,34 +1839,40 @@ MmArmInitSystem( IN PLOADER_PARAMETER_BLOCK LoaderBlock ); +CODE_SEG("INIT") VOID NTAPI MiInitializeSessionSpaceLayout(VOID); +CODE_SEG("INIT") NTSTATUS NTAPI MiInitMachineDependent( IN PLOADER_PARAMETER_BLOCK LoaderBlock ); +CODE_SEG("INIT") VOID NTAPI MiComputeColorInformation( VOID ); +CODE_SEG("INIT") VOID NTAPI MiMapPfnDatabase( IN PLOADER_PARAMETER_BLOCK LoaderBlock ); +CODE_SEG("INIT") VOID NTAPI MiInitializeColorTables( VOID ); +CODE_SEG("INIT") VOID NTAPI MiInitializePfnDatabase( @@ -1884,18 +1891,21 @@ MiInitializeSessionIds( VOID ); +CODE_SEG("INIT") BOOLEAN NTAPI MiInitializeMemoryEvents( VOID ); +CODE_SEG("INIT") PFN_NUMBER NTAPI MxGetNextPage( IN PFN_NUMBER PageCount ); +CODE_SEG("INIT") PPHYSICAL_MEMORY_DESCRIPTOR NTAPI MmInitializeMemoryLimits( @@ -1942,18 +1952,21 @@ MiCheckPdeForPagedPool( IN PVOID Address ); +CODE_SEG("INIT") VOID NTAPI MiInitializeNonPagedPoolThresholds( VOID ); +CODE_SEG("INIT") VOID NTAPI MiInitializePoolEvents( VOID ); +CODE_SEG("INIT") VOID // NTAPI // InitializePool( // @@ -1962,6 +1975,7 @@ InitializePool( // ); // // FIXFIX: THIS ONE TOO +CODE_SEG("INIT") VOID NTAPI ExInitializePoolDescriptor( @@ -1978,6 +1992,7 @@ MiInitializeSessionPool( VOID ); +CODE_SEG("INIT") VOID NTAPI MiInitializeSystemPtes( @@ -2139,18 +2154,21 @@ MiLookupDataTableEntry( IN PVOID Address ); +CODE_SEG("INIT") VOID NTAPI MiInitializeDriverLargePageList( VOID ); +CODE_SEG("INIT") VOID NTAPI MiInitializeLargePageSupport( VOID ); +CODE_SEG("INIT") VOID NTAPI MiSyncCachedRanges( diff --git a/ntoskrnl/mm/amd64/init.c b/ntoskrnl/mm/amd64/init.c index add80555327..eea9cc2c1bb 100644 --- a/ntoskrnl/mm/amd64/init.c +++ b/ntoskrnl/mm/amd64/init.c @@ -439,8 +439,8 @@ MiSetupPfnForPageTable( } static -CODE_SEG("INIT") VOID +CODE_SEG("INIT") MiBuildPfnDatabaseFromPageTables(VOID) { PVOID Address = NULL; @@ -539,8 +539,8 @@ MiBuildPfnDatabaseFromPageTables(VOID) #endif } -static CODE_SEG("INIT") +static VOID MiAddDescriptorToDatabase( PFN_NUMBER BasePage, diff --git a/ntoskrnl/mm/arm/page.c b/ntoskrnl/mm/arm/page.c index d25663e8286..42a871c0a23 100644 --- a/ntoskrnl/mm/arm/page.c +++ b/ntoskrnl/mm/arm/page.c @@ -272,7 +272,6 @@ MmSetPageProtect(IN PEPROCESS Process, return; } -CODE_SEG("INIT") VOID NTAPI MmInitGlobalKernelPageDirectory(VOID) diff --git a/ntoskrnl/mm/arm/stubs.c b/ntoskrnl/mm/arm/stubs.c index eb4f6cf3510..afbfdae337a 100644 --- a/ntoskrnl/mm/arm/stubs.c +++ b/ntoskrnl/mm/arm/stubs.c @@ -639,7 +639,6 @@ MmSetPageProtect(IN PEPROCESS Process, return; } -CODE_SEG("INIT") VOID NTAPI MmInitGlobalKernelPageDirectory(VOID) diff --git a/ntoskrnl/mm/balance.c b/ntoskrnl/mm/balance.c index cb61f3559fd..93b05138df3 100644 --- a/ntoskrnl/mm/balance.c +++ b/ntoskrnl/mm/balance.c @@ -16,6 +16,7 @@ #include "ARM3/miarm.h" + /* TYPES ********************************************************************/ typedef struct _MM_ALLOCATION_REQUEST { diff --git a/ntoskrnl/mm/section.c b/ntoskrnl/mm/section.c index e273c3ac10b..005e686e771 100644 --- a/ntoskrnl/mm/section.c +++ b/ntoskrnl/mm/section.c @@ -50,6 +50,7 @@ #define NDEBUG #include #include + #include "ARM3/miarm.h" #undef MmSetPageEntrySectionSegment diff --git a/ntoskrnl/se/token.c b/ntoskrnl/se/token.c index 02664c44298..01ec724933f 100644 --- a/ntoskrnl/se/token.c +++ b/ntoskrnl/se/token.c @@ -11,6 +11,7 @@ #include #define NDEBUG #include + #include typedef struct _TOKEN_AUDIT_POLICY_INFORMATION @@ -84,7 +85,7 @@ static const INFORMATION_CLASS_INFO SeTokenInformationClass[] = { /** * @brief * Creates a lock for the token. - * + * * @param[in,out] Token * A token which lock has to be created. * @@ -151,7 +152,7 @@ SepDeleteTokenLock( * * @param[in] CountSidArray2 * SID count array from the second token. - * + * * @return * Returns TRUE if the elements match from either arrays, * FALSE otherwise. @@ -278,7 +279,7 @@ SepComparePrivilegeAndAttributesFromTokens( * - If both tokens are restricted, every SID that is restricted in either token is * also restricted in the other one. * - Every privilege present in either token is also present in the other one. - * + * * @param[in] FirstToken * The first token. * diff --git a/sdk/include/ddk/aux_klib.h b/sdk/include/ddk/aux_klib.h index edbcf06ef6b..b98cf9c1d93 100644 --- a/sdk/include/ddk/aux_klib.h +++ b/sdk/include/ddk/aux_klib.h @@ -50,11 +50,13 @@ typedef struct _KBUGCHECK_DATA { ULONG_PTR Parameter4; } KBUGCHECK_DATA, *PKBUGCHECK_DATA; +CODE_SEG("PAGE") NTSTATUS NTAPI AuxKlibInitialize(VOID); _IRQL_requires_max_(PASSIVE_LEVEL) +CODE_SEG("PAGE") NTSTATUS NTAPI AuxKlibQueryModuleInformation( @@ -71,6 +73,7 @@ AuxKlibGetImageExportDirectory( _In_ PVOID ImageBase); _IRQL_requires_max_(PASSIVE_LEVEL) +CODE_SEG("PAGE") NTSTATUS NTAPI AuxKlibEnumerateSystemFirmwareTables ( @@ -80,6 +83,7 @@ AuxKlibEnumerateSystemFirmwareTables ( _Out_opt_ PULONG ReturnLength); _IRQL_requires_max_(PASSIVE_LEVEL) +CODE_SEG("PAGE") NTSTATUS NTAPI AuxKlibGetSystemFirmwareTable ( diff --git a/sdk/include/ndk/halfuncs.h b/sdk/include/ndk/halfuncs.h index 5806c040937..6c5e480acb9 100644 --- a/sdk/include/ndk/halfuncs.h +++ b/sdk/include/ndk/halfuncs.h @@ -81,6 +81,7 @@ HalInitializeProcessor( _In_ struct _LOADER_PARAMETER_BLOCK *LoaderBlock ); +CODE_SEG("INIT") NTHALAPI BOOLEAN NTAPI @@ -176,6 +177,7 @@ HalGetInterruptSource( ); #endif +CODE_SEG("INIT") NTHALAPI VOID NTAPI diff --git a/sdk/include/xdk/iofuncs.h b/sdk/include/xdk/iofuncs.h index 04d3c63a200..534edfd66b4 100644 --- a/sdk/include/xdk/iofuncs.h +++ b/sdk/include/xdk/iofuncs.h @@ -2,6 +2,8 @@ * I/O Manager Functions * ******************************************************************************/ +#include + $if (_WDMDDK_) /* * NTSTATUS @@ -1138,6 +1140,7 @@ IoRegisterDeviceInterface( _IRQL_requires_max_(PASSIVE_LEVEL) _Must_inspect_result_ +CODE_SEG("PAGE") NTKERNELAPI NTSTATUS NTAPI @@ -1289,6 +1292,7 @@ IoStopTimer( _IRQL_requires_max_(PASSIVE_LEVEL) __drv_freesMem(Pool) +CODE_SEG("PAGE") NTKERNELAPI NTSTATUS NTAPI diff --git a/win32ss/drivers/miniport/pc98vid/ioctl.c b/win32ss/drivers/miniport/pc98vid/ioctl.c index d89a17510cd..918beb117d6 100644 --- a/win32ss/drivers/miniport/pc98vid/ioctl.c +++ b/win32ss/drivers/miniport/pc98vid/ioctl.c @@ -206,7 +206,6 @@ Pc98VidGetChildState( return NO_ERROR; } -CODE_SEG("PAGE") BOOLEAN NTAPI Pc98VidStartIO( diff --git a/win32ss/drivers/miniport/pc98vid/pc98vid.c b/win32ss/drivers/miniport/pc98vid/pc98vid.c index 485cd1a0120..8705aee35ea 100644 --- a/win32ss/drivers/miniport/pc98vid/pc98vid.c +++ b/win32ss/drivers/miniport/pc98vid/pc98vid.c @@ -193,7 +193,6 @@ Pc98VidGetVideoChildDescriptor( return ERROR_NO_MORE_DEVICES; } -CODE_SEG("INIT") ULONG NTAPI DriverEntry( diff --git a/win32ss/gdi/eng/device.h b/win32ss/gdi/eng/device.h index 9866b29507c..b74649daa73 100644 --- a/win32ss/gdi/eng/device.h +++ b/win32ss/gdi/eng/device.h @@ -39,6 +39,7 @@ EngpPopulateDeviceModeList( _Inout_ PGRAPHICS_DEVICE pGraphicsDevice, _In_ PDEVMODEW pdmDefault); +CODE_SEG("INIT") NTSTATUS NTAPI InitDeviceImpl(VOID); diff --git a/win32ss/gdi/eng/ldevobj.h b/win32ss/gdi/eng/ldevobj.h index 9b2a836056b..cd15f3cc823 100644 --- a/win32ss/gdi/eng/ldevobj.h +++ b/win32ss/gdi/eng/ldevobj.h @@ -29,6 +29,7 @@ typedef struct _LDEVOBJ } LDEVOBJ, *PLDEVOBJ; +CODE_SEG("INIT") NTSTATUS NTAPI InitLDEVImpl(VOID); @@ -50,6 +51,7 @@ NTAPI EngGetLDEV( PDEVMODEW pdm); +CODE_SEG("INIT") NTSTATUS APIENTRY DriverEntry ( diff --git a/win32ss/gdi/eng/pdevobj.h b/win32ss/gdi/eng/pdevobj.h index 5b0133385c5..4d22c270aa7 100644 --- a/win32ss/gdi/eng/pdevobj.h +++ b/win32ss/gdi/eng/pdevobj.h @@ -196,6 +196,7 @@ PDEVOBJ_vGetDeviceCaps( _In_ PPDEVOBJ ppdev, _Out_ PDEVCAPS pDevCaps); +CODE_SEG("INIT") NTSTATUS NTAPI InitPDEVImpl(VOID); diff --git a/win32ss/gdi/ntgdi/brush.h b/win32ss/gdi/ntgdi/brush.h index 523dd3541c3..99d29258041 100644 --- a/win32ss/gdi/ntgdi/brush.h +++ b/win32ss/gdi/ntgdi/brush.h @@ -131,6 +131,7 @@ struct _SURFACE; struct _PALETTE; struct _DC; +CODE_SEG("INIT") NTSTATUS NTAPI InitBrushImpl(VOID); diff --git a/win32ss/gdi/ntgdi/dc.h b/win32ss/gdi/ntgdi/dc.h index bf1b2f6e02c..76e8745b73b 100644 --- a/win32ss/gdi/ntgdi/dc.h +++ b/win32ss/gdi/ntgdi/dc.h @@ -182,7 +182,7 @@ COLORREF FASTCALL IntSetDCPenColor(HDC,COLORREF); int FASTCALL GreGetGraphicsMode(HDC); BOOL FASTCALL GreSetBrushOrg(HDC,INT,INT,LPPOINT); -NTSTATUS NTAPI InitDcImpl(VOID); +CODE_SEG("INIT") NTSTATUS NTAPI InitDcImpl(VOID); PPDEVOBJ FASTCALL IntEnumHDev(VOID); PDC NTAPI DC_AllocDcWithHandle(GDILOOBJTYPE eDcObjType); BOOL NTAPI DC_bAllocDcAttr(PDC pdc); diff --git a/win32ss/gdi/ntgdi/gdiobj.h b/win32ss/gdi/ntgdi/gdiobj.h index 0922a33d565..f7b65594187 100644 --- a/win32ss/gdi/ntgdi/gdiobj.h +++ b/win32ss/gdi/ntgdi/gdiobj.h @@ -73,6 +73,7 @@ enum _GDIOBJLAGS GDIOBJFLAG_IGNORELOCK = 0x02 }; +CODE_SEG("INIT") NTSTATUS NTAPI InitGdiHandleTable(VOID); diff --git a/win32ss/gdi/ntgdi/palette.h b/win32ss/gdi/ntgdi/palette.h index 10d1482a9b2..446b46a1e3c 100644 --- a/win32ss/gdi/ntgdi/palette.h +++ b/win32ss/gdi/ntgdi/palette.h @@ -59,6 +59,7 @@ extern PPALETTE appalSurfaceDefault[]; #define PALETTE_ShareUnlockPalette(ppal) \ GDIOBJ_vDereferenceObject(&ppal->BaseObject) +CODE_SEG("INIT") NTSTATUS NTAPI InitPaletteImpl(VOID); diff --git a/win32ss/user/ntuser/dce.h b/win32ss/user/ntuser/dce.h index 6a22ee9256f..290d17badeb 100644 --- a/win32ss/user/ntuser/dce.h +++ b/win32ss/user/ntuser/dce.h @@ -41,7 +41,7 @@ typedef struct tagDCE #define DCX_NORECOMPUTE 0x00100000 #define DCX_INDESTROY 0x00400000 -NTSTATUS NTAPI InitDCEImpl(VOID); +CODE_SEG("INIT") NTSTATUS NTAPI InitDCEImpl(VOID); PDCE FASTCALL DceAllocDCE(PWND Window, DCE_TYPE Type); HWND FASTCALL IntWindowFromDC(HDC hDc); void FASTCALL DceFreeDCE(PDCE dce, BOOLEAN Force); diff --git a/win32ss/user/ntuser/desktop.h b/win32ss/user/ntuser/desktop.h index fef1677bd67..3043af678c4 100644 --- a/win32ss/user/ntuser/desktop.h +++ b/win32ss/user/ntuser/desktop.h @@ -94,6 +94,7 @@ typedef struct _SHELL_HOOK_WINDOW HWND hWnd; } SHELL_HOOK_WINDOW, *PSHELL_HOOK_WINDOW; +CODE_SEG("INIT") NTSTATUS NTAPI InitDesktopImpl(VOID); diff --git a/win32ss/user/ntuser/input.h b/win32ss/user/ntuser/input.h index 1f574ea9345..bd185a12c04 100644 --- a/win32ss/user/ntuser/input.h +++ b/win32ss/user/ntuser/input.h @@ -59,7 +59,7 @@ extern PATTACHINFO gpai; #define LP_DO_NOT_CARE_BIT (1<<25) // For GetKeyNameText /* General */ -NTSTATUS NTAPI InitInputImpl(VOID); +CODE_SEG("INIT") NTSTATUS NTAPI InitInputImpl(VOID); VOID NTAPI RawInputThreadMain(VOID); BOOL FASTCALL IntBlockInput(PTHREADINFO W32Thread, BOOL BlockIt); NTSTATUS FASTCALL UserAttachThreadInput(PTHREADINFO,PTHREADINFO,BOOL); @@ -68,7 +68,7 @@ VOID FASTCALL DoTheScreenSaver(VOID); #define ThreadHasInputAccess(W32Thread) (TRUE) /* Keyboard */ -NTSTATUS NTAPI InitKeyboardImpl(VOID); +CODE_SEG("INIT") NTSTATUS NTAPI InitKeyboardImpl(VOID); VOID NTAPI UserInitKeyboard(HANDLE hKeyboardDevice); PKL W32kGetDefaultKeyLayout(VOID); VOID NTAPI UserProcessKeyboardInput(PKEYBOARD_INPUT_DATA pKeyInput); diff --git a/win32ss/user/ntuser/msgqueue.h b/win32ss/user/ntuser/msgqueue.h index 474ee574045..d3e3399b416 100644 --- a/win32ss/user/ntuser/msgqueue.h +++ b/win32ss/user/ntuser/msgqueue.h @@ -158,7 +158,7 @@ BOOLEAN FASTCALL MsqInitializeMessageQueue(PTHREADINFO, PUSER_MESSAGE_QUEUE); PUSER_MESSAGE_QUEUE FASTCALL MsqCreateMessageQueue(PTHREADINFO); VOID FASTCALL MsqCleanupThreadMsgs(PTHREADINFO); VOID FASTCALL MsqDestroyMessageQueue(_In_ PTHREADINFO pti); -NTSTATUS NTAPI MsqInitializeImpl(VOID); +CODE_SEG("INIT") NTSTATUS NTAPI MsqInitializeImpl(VOID); BOOLEAN FASTCALL co_MsqDispatchOneSentMessage(_In_ PTHREADINFO pti); NTSTATUS FASTCALL co_MsqWaitForNewMessages(PTHREADINFO pti, PWND WndFilter, diff --git a/win32ss/user/ntuser/ntuser.h b/win32ss/user/ntuser/ntuser.h index 2e884a6581f..379825056d1 100644 --- a/win32ss/user/ntuser/ntuser.h +++ b/win32ss/user/ntuser/ntuser.h @@ -19,7 +19,7 @@ extern ATOM gaGuiConsoleWndClass; extern ATOM AtomDDETrack; extern ATOM AtomQOS; -NTSTATUS NTAPI InitUserImpl(VOID); +CODE_SEG("INIT") NTSTATUS NTAPI InitUserImpl(VOID); VOID FASTCALL CleanupUserImpl(VOID); VOID FASTCALL UserEnterShared(VOID); VOID FASTCALL UserEnterExclusive(VOID); diff --git a/win32ss/user/ntuser/timer.h b/win32ss/user/ntuser/timer.h index 94e3627fa3f..8ca2fe8ebd0 100644 --- a/win32ss/user/ntuser/timer.h +++ b/win32ss/user/ntuser/timer.h @@ -32,7 +32,7 @@ typedef struct _TIMER extern PKTIMER MasterTimer; -NTSTATUS NTAPI InitTimerImpl(VOID); +CODE_SEG("INIT") NTSTATUS NTAPI InitTimerImpl(VOID); BOOL FASTCALL DestroyTimersForThread(PTHREADINFO pti); BOOL FASTCALL DestroyTimersForWindow(PTHREADINFO pti, PWND Window); BOOL FASTCALL IntKillTimer(PWND Window, UINT_PTR IDEvent, BOOL SystemTimer); diff --git a/win32ss/user/ntuser/winsta.h b/win32ss/user/ntuser/winsta.h index 36769473411..34720ad5093 100644 --- a/win32ss/user/ntuser/winsta.h +++ b/win32ss/user/ntuser/winsta.h @@ -73,6 +73,7 @@ extern UNICODE_STRING gustrWindowStationsDir; WINSTA_READSCREEN | \ WINSTA_WRITEATTRIBUTES +CODE_SEG("INIT") NTSTATUS NTAPI InitWindowStationImpl(VOID);