diff options
| author | J M Rossy <[email protected]> | 2015-07-29 15:40:09 -0700 |
|---|---|---|
| committer | J M Rossy <[email protected]> | 2015-07-29 16:34:40 -0700 |
| commit | 5d61a4a79a1e96dc5d9af1e5e712c84507307544 (patch) | |
| tree | 49ed270893578cd18758b74ffcca16dc7ab948d6 /network/trans/WFPSampler/sys/NotifyFunctions_AdvancedCallouts.cpp | |
| parent | 5d41613e26e147d2300c786bb2b34cb4b4067a25 (diff) | |
Samples update for public Windows 10 release
Fix #2 Enabling WPP Recorder in Sensors Samples causes errors
Fix #4 Add back fixed KMDOD sample
Add new BarcodeScanner sample in pos folder
Add new MagneticStripeReader sample in pos folder
Add new SynpaticsTouch sample in input folder
Add new Power Engine Plugin sample in pofx folder
Add new DeviceMft sample in avstream folder
Add new AvsCamera sample in root
Add new SimBatt sample in root
Add other pre-existing samples not yet released for Win10
Diffstat (limited to 'network/trans/WFPSampler/sys/NotifyFunctions_AdvancedCallouts.cpp')
| -rw-r--r-- | network/trans/WFPSampler/sys/NotifyFunctions_AdvancedCallouts.cpp | 223 |
1 files changed, 223 insertions, 0 deletions
diff --git a/network/trans/WFPSampler/sys/NotifyFunctions_AdvancedCallouts.cpp b/network/trans/WFPSampler/sys/NotifyFunctions_AdvancedCallouts.cpp new file mode 100644 index 00000000..18c93824 --- /dev/null +++ b/network/trans/WFPSampler/sys/NotifyFunctions_AdvancedCallouts.cpp @@ -0,0 +1,223 @@ +//////////////////////////////////////////////////////////////////////////////////////////////////// +// +// Copyright (c) 2012 Microsoft Corporation. All Rights Reserved. +// +// Module Name: +// NotifyFunctions_AdvancedCallouts.cpp +// +// Abstract: +// This module contains WFP Notify functions for the simpler callouts. +// +// Naming Convention: +// +// <Module><Scenario> +// +// i.e. +// +// NotifyAdvancedNotification +// +// <Module> +// Notify - Function is an FWPS_CALLOUT_NOTIFY_FN +// <Scenario> +// AdvancedNotification - Function demonstates use of the simple notifications +// +// Author: +// Dusty Harper (DHarper) +// +// Revision History: +// +// [ Month ][Day] [Year] - [Revision]-[ Comments ] +// December 13, 2013 - 1.1 - Creation +// +//////////////////////////////////////////////////////////////////////////////////////////////////// + +#include "Framework_WFPSamplerCalloutDriver.h" /// . +#include "NotifyFunctions_AdvancedCallouts.tmh" /// $(OBJ_PATH)\$(O)\ + +/** + @private_function="PrvAdvancedNotificationWorkItemRoutine" + + Purpose: Traces the appropriate notification event. <br> + <br> + Notes: <br> + <br> + MSDN_Ref: <br> +*/ +_IRQL_requires_(PASSIVE_LEVEL) +_IRQL_requires_same_ +_Function_class_(IO_WORKITEM_ROUTINE) +VOID PrvAdvancedNotificationWorkItemRoutine(_In_ PDEVICE_OBJECT pDeviceObject, + _Inout_opt_ PVOID pContext) +{ +#if DBG + + DbgPrintEx(DPFLTR_IHVNETWORK_ID, + DPFLTR_INFO_LEVEL, + " ---> PrvAdvancedNotificationWorkItemRoutine()\n"); + +#endif /// DBG + + UNREFERENCED_PARAMETER(pDeviceObject); + + NT_ASSERT(pContext); + NT_ASSERT(((WORKITEM_DATA*)pContext)->pNotifyData); + + + WORKITEM_DATA* pWorkItemData = (WORKITEM_DATA*)pContext; + + if(pWorkItemData) + { + NTSTATUS status = STATUS_SUCCESS; + FWPM_CALLOUT* pCallout = 0; + PWSTR pCalloutName = L""; + + status = FwpmCalloutGetById(g_EngineHandle, + pWorkItemData->pNotifyData->calloutID, + &pCallout); + if(status != STATUS_SUCCESS) + { + if(status != STATUS_FWP_CALLOUT_NOT_FOUND) + DbgPrintEx(DPFLTR_IHVNETWORK_ID, + DPFLTR_ERROR_LEVEL, + " !!!! [FilterID: %#I64x][CalloutID: %#x] PrvAdvancedNotificationWorkItemRoutine : FwpmCalloutGetById() [status: %#x]\n", + pWorkItemData->pNotifyData->filterID, + pWorkItemData->pNotifyData->calloutID, + status); + } + else + pCalloutName = pCallout->displayData.name; + + switch(pWorkItemData->pNotifyData->notificationType) + { + case FWPS_CALLOUT_NOTIFY_ADD_FILTER: + { + DbgPrintEx(DPFLTR_IHVNETWORK_ID, + DPFLTR_INFO_LEVEL, + " -- [FilterID: %#I64x][CalloutID: %#x] A filter referencing %S callout was added\n", + pWorkItemData->pNotifyData->filterID, + pWorkItemData->pNotifyData->calloutID, + pCalloutName ? pCalloutName : L""); + break; + } + case FWPS_CALLOUT_NOTIFY_DELETE_FILTER: + { + DbgPrintEx(DPFLTR_IHVNETWORK_ID, + DPFLTR_INFO_LEVEL, + " -- [FilterID: %#I64x][CalloutID: %#x] A filter referencing %S callout was deleted\n", + pWorkItemData->pNotifyData->filterID, + pWorkItemData->pNotifyData->calloutID, + pCalloutName ? pCalloutName : L""); + + break; + } + case FWPS_CALLOUT_NOTIFY_ADD_FILTER_POST_COMMIT: + { + DbgPrintEx(DPFLTR_IHVNETWORK_ID, + DPFLTR_INFO_LEVEL, + " -- [FilterID: %#I64x][CalloutID: %#x] A filter referencing %S callout was committed\n", + pWorkItemData->pNotifyData->filterID, + pWorkItemData->pNotifyData->calloutID, + pCalloutName ? pCalloutName : L""); + break; + } + default: + { + DbgPrintEx(DPFLTR_IHVNETWORK_ID, + DPFLTR_INFO_LEVEL, + " -- [FilterID: %#I64x][CalloutID: %#x] Invalid Notification Type. Please Contact [email protected]\n", + pWorkItemData->pNotifyData->filterID, + pWorkItemData->pNotifyData->calloutID); + + break; + } + } + + FwpmFreeMemory((VOID**)&pCallout); + + HLPR_DELETE(pWorkItemData->pNotifyData, + WFPSAMPLER_CALLOUT_DRIVER_TAG); + + KrnlHlprWorkItemDataDestroy(&pWorkItemData); + } + +#if DBG + + DbgPrintEx(DPFLTR_IHVNETWORK_ID, + DPFLTR_INFO_LEVEL, + " <--- PrvAdvancedNotificationWorkItemRoutine()\n"); + +#endif /// DBG + + return; +} + +/** + @notify_function="NotifyAdvancedNotification" + + Purpose: Traces the notification event. <br> + <br> + Notes: <br> + <br> + MSDN_Ref: HTTP://MSDN.Microsoft.com/En-US/Library/FF568803.aspx <br> + HTTP://MSDN.Microsoft.com/En-US/Library/FF568804.aspx <br> +*/ +_IRQL_requires_min_(PASSIVE_LEVEL) +_IRQL_requires_max_(DISPATCH_LEVEL) +_IRQL_requires_same_ +_Success_(return == STATUS_SUCCESS) +NTSTATUS NTAPI NotifyAdvancedNotification(_In_ FWPS_CALLOUT_NOTIFY_TYPE notificationType, + _In_ const GUID* pFilterKey, + _Inout_ FWPS_FILTER* pFilter) +{ + NT_ASSERT(pFilter); + + DbgPrintEx(DPFLTR_IHVNETWORK_ID, + DPFLTR_INFO_LEVEL, + " ---> NotifyAdvancedNotification() [FilterID: %#I64x][CalloutID: %#x]\n", + pFilter->filterId, + pFilter->action.calloutId); + + NTSTATUS status = STATUS_SUCCESS; + NOTIFY_DATA* pNotifyData = 0; + +#pragma warning(push) +#pragma warning(disable: 6014) /// pNotifyData is expected to be cleaned up by caller using PrvAdvancedNotificationWorkItemRoutine + + HLPR_NEW(pNotifyData, + NOTIFY_DATA, + WFPSAMPLER_CALLOUT_DRIVER_TAG); + HLPR_BAIL_ON_ALLOC_FAILURE(pNotifyData, + status); + +#pragma warning(pop) + + pNotifyData->notificationType = notificationType; + pNotifyData->calloutID = pFilter ? pFilter->action.calloutId : 0; + pNotifyData->filterID = pFilter ? pFilter->filterId : 0; + pNotifyData->pFilterKey = pFilterKey; + + status = KrnlHlprWorkItemQueue(g_pWDMDevice, + PrvAdvancedNotificationWorkItemRoutine, + pNotifyData); + + HLPR_BAIL_LABEL: + + if(status != STATUS_SUCCESS) + { + DbgPrintEx(DPFLTR_IHVNETWORK_ID, + DPFLTR_ERROR_LEVEL, + " !!!! NotifyAdvancedNotification() [status: %#x]\n", + status); + + HLPR_DELETE(pNotifyData, + WFPSAMPLER_CALLOUT_DRIVER_TAG); + } + + DbgPrintEx(DPFLTR_IHVNETWORK_ID, + DPFLTR_INFO_LEVEL, + " <--- NotifyAdvancedNotification() [FilterID: %#I64x][CalloutID: %#x]\n", + pFilter->filterId, + pFilter->action.calloutId); + + return status; +} |
