sys: disallow driver unloading based on macro FSP_UNLOAD

This commit is contained in:
Bill Zissimopoulos 2016-04-07 14:53:22 -07:00
parent 785c4ba29d
commit edf5eb2219

View File

@ -6,15 +6,27 @@
#include <sys/driver.h> #include <sys/driver.h>
/*
* 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; DRIVER_INITIALIZE DriverEntry;
static VOID FspDriverMultiVersionInitialize(VOID); static VOID FspDriverMultiVersionInitialize(VOID);
#if defined(FSP_UNLOAD)
DRIVER_UNLOAD FspUnload; DRIVER_UNLOAD FspUnload;
#endif
#ifdef ALLOC_PRAGMA #ifdef ALLOC_PRAGMA
#pragma alloc_text(INIT, DriverEntry) #pragma alloc_text(INIT, DriverEntry)
#pragma alloc_text(INIT, FspDriverMultiVersionInitialize) #pragma alloc_text(INIT, FspDriverMultiVersionInitialize)
#if defined(FSP_UNLOAD)
#pragma alloc_text(PAGE, FspUnload) #pragma alloc_text(PAGE, FspUnload)
#endif #endif
#endif
NTSTATUS DriverEntry( NTSTATUS DriverEntry(
PDRIVER_OBJECT DriverObject, PUNICODE_STRING RegistryPath) PDRIVER_OBJECT DriverObject, PUNICODE_STRING RegistryPath)
@ -49,7 +61,9 @@ NTSTATUS DriverEntry(
ASSERT(STATUS_SUCCESS == Result); ASSERT(STATUS_SUCCESS == Result);
/* setup the driver object */ /* setup the driver object */
#if defined(FSP_UNLOAD)
DriverObject->DriverUnload = FspUnload; DriverObject->DriverUnload = FspUnload;
#endif
DriverObject->MajorFunction[IRP_MJ_CREATE] = FspCreate; DriverObject->MajorFunction[IRP_MJ_CREATE] = FspCreate;
DriverObject->MajorFunction[IRP_MJ_CLOSE] = FspClose; DriverObject->MajorFunction[IRP_MJ_CLOSE] = FspClose;
DriverObject->MajorFunction[IRP_MJ_READ] = FspRead; DriverObject->MajorFunction[IRP_MJ_READ] = FspRead;
@ -160,6 +174,7 @@ static VOID FspDriverMultiVersionInitialize(VOID)
} }
} }
#if defined(FSP_UNLOAD)
VOID FspUnload( VOID FspUnload(
PDRIVER_OBJECT DriverObject) PDRIVER_OBJECT DriverObject)
{ {
@ -175,6 +190,7 @@ VOID FspUnload(
FSP_LEAVE_VOID("DriverName=\"%wZ\"", FSP_LEAVE_VOID("DriverName=\"%wZ\"",
&DriverObject->DriverName); &DriverObject->DriverName);
} }
#endif
PDRIVER_OBJECT FspDriverObject; PDRIVER_OBJECT FspDriverObject;
PDEVICE_OBJECT FspFsctlDiskDeviceObject; PDEVICE_OBJECT FspFsctlDiskDeviceObject;