diff --git a/src/Dmf_BusFilter.c b/src/Dmf_BusFilter.c index 7113733..76075c7 100644 --- a/src/Dmf_BusFilter.c +++ b/src/Dmf_BusFilter.c @@ -171,7 +171,6 @@ typedef struct _BUS_RELATIONS_WORK_CONTEXT // Forward declarations // -#pragma code_seg("PAGE") _IRQL_requires_max_(PASSIVE_LEVEL) static void @@ -179,7 +178,6 @@ DMF_BusFilter_Relations_RemoveDevice( _In_ PDEVICE_OBJECT DeviceObject, _In_ PIRP RemoveIrp ); -#pragma code_seg() _IRQL_requires_max_(PASSIVE_LEVEL) static @@ -189,14 +187,12 @@ DMF_BusFilter_Relations_AddDevice( _In_ PDEVICE_OBJECT PhysicalDeviceObject ); -#pragma code_seg("PAGE") _IRQL_requires_max_(PASSIVE_LEVEL) static VOID BusFilter_TeardownChildDevices( _In_ WDFDEVICE Device ); -#pragma code_seg() EVT_WDF_OBJECT_CONTEXT_CLEANUP DMF_BusFilter_EvtBusDeviceContextCleanup; @@ -205,7 +201,9 @@ EVT_WDF_OBJECT_CONTEXT_CLEANUP DMF_BusFilter_EvtBusDeviceContextCleanup; /////////////////////////////////////////////////////////////////////////////////////////////////////// // -#pragma code_seg("PAGE") +// NOTE: Not in the PAGE segment because it acquires ChildListLock (raising IRQL +// to DISPATCH_LEVEL), making pageable memory unsafe while the lock is held. +// _IRQL_requires_max_(PASSIVE_LEVEL) static void @@ -251,8 +249,6 @@ Return Value: FuncEntry(DMF_TRACE); - PAGED_CODE(); - // Step 1: release the remove lock (matching the IoAcquireRemoveLock in // DispatchHandler) AND wait for all other in-flight holders to drain. // After this call, no concurrent dispatcher can be accessing the extension @@ -285,7 +281,6 @@ Return Value: FuncExitNoReturn(DMF_TRACE); } -#pragma code_seg() /////////////////////////////////////////////////////////////////////////////////////////////////////// // Child PnP dispatch @@ -748,7 +743,9 @@ Exit: // DEVICE_RELATIONS returned by the lower bus driver. Must be called at PASSIVE_LEVEL // because DMF_BusFilter_Relations_AddDevice requires it. // -#pragma code_seg("PAGE") +// NOTE: Not in the PAGE segment because it acquires ChildListLock (raising IRQL +// to DISPATCH_LEVEL), making pageable memory unsafe while the lock is held. +// _IRQL_requires_max_(PASSIVE_LEVEL) static void @@ -761,8 +758,6 @@ DMF_BusFilter_ProcessBusRelations( WDM_CHILD_DEVICE_EXTENSION* childExtension = NULL; PARENT_BUS_DEVICE_CONTEXT* parentContext = DMF_BusFilter_GetParentContext(Device); - PAGED_CODE(); - if (parentContext == NULL) { return; @@ -808,7 +803,6 @@ DMF_BusFilter_ProcessBusRelations( } } } -#pragma code_seg() // Work item routine: runs at PASSIVE_LEVEL when the completion routine fires at // DISPATCH_LEVEL and cannot call IoCreateDevice / IoAttachDeviceToDeviceStackSafe @@ -1638,7 +1632,9 @@ Return Value: return NULL; } -#pragma code_seg("PAGE") +// NOTE: Not in the PAGE segment because it acquires ChildListLock (raising IRQL +// to DISPATCH_LEVEL), making pageable memory unsafe while the lock is held. +// _IRQL_requires_max_(PASSIVE_LEVEL) static VOID @@ -1682,8 +1678,6 @@ Return Value: FuncEntry(DMF_TRACE); - PAGED_CODE(); - if (parentContext == NULL || context == NULL) { goto Exit; @@ -1777,7 +1771,6 @@ Exit: FuncExitNoReturn(DMF_TRACE); } -#pragma code_seg() #pragma code_seg("PAGE") _Use_decl_annotations_