From edf5eb22190557286ee190f421733ec579716e60 Mon Sep 17 00:00:00 2001 From: Bill Zissimopoulos Date: Thu, 7 Apr 2016 14:53:22 -0700 Subject: [PATCH] sys: disallow driver unloading based on macro FSP_UNLOAD --- src/sys/driver.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/sys/driver.c b/src/sys/driver.c index 0e2d97d9..a128a30a 100644 --- a/src/sys/driver.c +++ b/src/sys/driver.c @@ -6,15 +6,27 @@ #include +/* + * Define the following macro to include FspUnload. + * + * Note that this driver is no longer unloadable. + * See the comments in DriverEntry as to why! + */ +//#define FSP_UNLOAD + DRIVER_INITIALIZE DriverEntry; static VOID FspDriverMultiVersionInitialize(VOID); +#if defined(FSP_UNLOAD) DRIVER_UNLOAD FspUnload; +#endif #ifdef ALLOC_PRAGMA #pragma alloc_text(INIT, DriverEntry) #pragma alloc_text(INIT, FspDriverMultiVersionInitialize) +#if defined(FSP_UNLOAD) #pragma alloc_text(PAGE, FspUnload) #endif +#endif NTSTATUS DriverEntry( PDRIVER_OBJECT DriverObject, PUNICODE_STRING RegistryPath) @@ -49,7 +61,9 @@ NTSTATUS DriverEntry( ASSERT(STATUS_SUCCESS == Result); /* setup the driver object */ +#if defined(FSP_UNLOAD) DriverObject->DriverUnload = FspUnload; +#endif DriverObject->MajorFunction[IRP_MJ_CREATE] = FspCreate; DriverObject->MajorFunction[IRP_MJ_CLOSE] = FspClose; DriverObject->MajorFunction[IRP_MJ_READ] = FspRead; @@ -160,6 +174,7 @@ static VOID FspDriverMultiVersionInitialize(VOID) } } +#if defined(FSP_UNLOAD) VOID FspUnload( PDRIVER_OBJECT DriverObject) { @@ -175,6 +190,7 @@ VOID FspUnload( FSP_LEAVE_VOID("DriverName=\"%wZ\"", &DriverObject->DriverName); } +#endif PDRIVER_OBJECT FspDriverObject; PDEVICE_OBJECT FspFsctlDiskDeviceObject;