Ejemplo n.º 1
0
VOID PowerStateCallback(_In_ VOID* pCallbackContext,
                        _In_ VOID* pPowerStateEvent,
                        _In_ VOID* pEventSpecifics)
{
#if DBG
   
   DbgPrintEx(DPFLTR_IHVNETWORK_ID,
              DPFLTR_INFO_LEVEL,
              " ---> PowerStateCallback()\n");

#endif /// DBG
   
   UNREFERENCED_PARAMETER(pCallbackContext);

   if(pPowerStateEvent == (VOID*)PO_CB_SYSTEM_STATE_LOCK)
   {
      NTSTATUS status = STATUS_SUCCESS;

      if(pEventSpecifics)
      {
         /// entering the ON state (S0), so return operation to normal
         if(g_calloutsRegistered == FALSE)
         {
            status = KrnlHlprExposedCalloutsRegister();
            HLPR_BAIL_ON_FAILURE(status);

            g_calloutsRegistered = TRUE;
         }
      }
      else
      {
         /// leaving the ON state (S0) to sleep (S1/S2/S3) or hibernate (S4)
         /// Unregister the callouts so no more injection will take place.  By default, the filters 
         /// invoking the callouts will return block.
         if(g_calloutsRegistered == TRUE)
         {
            status = KrnlHlprExposedCalloutsUnregister();
            HLPR_BAIL_ON_FAILURE(status);

            g_calloutsRegistered = FALSE;
         }
      }
   }

   HLPR_BAIL_LABEL:

#if DBG
   
   DbgPrintEx(DPFLTR_IHVNETWORK_ID,
              DPFLTR_INFO_LEVEL,
              " <--- PowerStateCallback()\n");

#endif /// DBG
   
   return;
}
Ejemplo n.º 2
0
VOID EventCleanupDeviceObject(_In_ WDFOBJECT deviceObject)
{
#if DBG
   
   DbgPrintEx(DPFLTR_IHVNETWORK_ID,
              DPFLTR_INFO_LEVEL,
              " ---> EventCleanupDeviceObject()\n");

#endif /// DBG
   
   UNREFERENCED_PARAMETER(deviceObject);

   KrnlHlprExposedCalloutsUnregister();

   if(g_WFPSamplerDeviceData.pOutboundInjectionHandles)
      KrnlHlprInjectionHandleDataDestroy(&(g_WFPSamplerDeviceData.pOutboundInjectionHandles));

   if(g_WFPSamplerDeviceData.pInboundInjectionHandles)
      KrnlHlprInjectionHandleDataDestroy(&(g_WFPSamplerDeviceData.pInboundInjectionHandles));

   if(g_WFPSamplerDeviceData.pIPv6OutboundInjectionHandles)
      KrnlHlprInjectionHandleDataDestroy(&(g_WFPSamplerDeviceData.pIPv6OutboundInjectionHandles));

   if(g_WFPSamplerDeviceData.pIPv6InboundInjectionHandles)
      KrnlHlprInjectionHandleDataDestroy(&(g_WFPSamplerDeviceData.pIPv6InboundInjectionHandles));

   if(g_WFPSamplerDeviceData.pIPv4OutboundInjectionHandles)
      KrnlHlprInjectionHandleDataDestroy(&(g_WFPSamplerDeviceData.pIPv4OutboundInjectionHandles));

   if(g_WFPSamplerDeviceData.pIPv4InboundInjectionHandles)
      KrnlHlprInjectionHandleDataDestroy(&(g_WFPSamplerDeviceData.pIPv4InboundInjectionHandles));

   if(g_WFPSamplerDeviceData.pEngineHandle)
      KrnlHlprFwpmSessionDestroyEngineHandle(&(g_WFPSamplerDeviceData.pEngineHandle));

   FwpmBfeStateUnsubscribeChanges(g_bfeSubscriptionHandle);

   UnregisterPowerStateChangeCallback(&g_deviceExtension);

   if(g_pNDISPoolData)
      KrnlHlprNDISPoolDataDestroy(&g_pNDISPoolData);

#if DBG
   
   DbgPrintEx(DPFLTR_IHVNETWORK_ID,
              DPFLTR_INFO_LEVEL,
              " <--- EventCleanupDeviceObject()\n");

#endif /// DBG
   
   return;
}