VOID NonPnpEvtDriverContextCleanup( IN WDFOBJECT Driver ) /*++ Routine Description: Called when the driver object is deleted during driver unload. You can free all the resources created in DriverEntry that are not automatically freed by the framework. Arguments: Driver - Handle to a framework driver object created in DriverEntry Return Value: NTSTATUS --*/ { TraceEvents(TRACE_LEVEL_VERBOSE, DBG_INIT, "Entered NonPnpEvtDriverContextCleanup\n"); PAGED_CODE(); // // No need to free the controldevice object explicitly because it will // be deleted when the Driver object is deleted due to the default parent // child relationship between Driver and ControlDevice. // WPP_CLEANUP( WdfDriverWdmGetDriverObject( (WDFDRIVER)Driver ) ); }
VOID OsrFxEvtDriverContextCleanup( __in WDFDRIVER Driver ) /*++ Routine Description: Free resources allocated in DriverEntry that are automatically cleaned up framework. Arguments: Driver - handle to a WDF Driver object. Return Value: VOID. --*/ { PAGED_CODE (); UNREFERENCED_PARAMETER(Driver); TraceEvents(TRACE_LEVEL_INFORMATION, DBG_INIT, "--> OsrFxEvtDriverContextCleanup\n"); WPP_CLEANUP( WdfDriverWdmGetDriverObject( Driver )); }
VOID DriverUnload( IN PDRIVER_OBJECT driverObject ) /*++ Routine Description: Called to indicate that we are being unloaded and to cause an orderly shutdown Arguments: driverObject Our driver Return Value: None --*/ { UNREFERENCED_PARAMETER(driverObject); MonitorCoUninitialize(); MonitorNfUninitialize(); IoDeleteDevice(monitorDeviceObject); IoDeleteSymbolicLink(&monitorSymbolicLink); DoTraceMessage(TRACE_SHUTDOWN, "MsnMonitor Driver Shutting Down"); WPP_CLEANUP(driverObject); }
NTSTATUS DriverEntry(IN PDRIVER_OBJECT DriverObject, IN PUNICODE_STRING RegistryPath) { NTSTATUS status; WDF_DRIVER_CONFIG config; WDF_OBJECT_ATTRIBUTES attributes; // Initialize the WPP tracing. WPP_INIT_TRACING(DriverObject, RegistryPath); Trace(TRACE_LEVEL_VERBOSE, "[%s] -->", __FUNCTION__); // Register a cleanup callback so that we can call WPP_CLEANUP when // the framework driver object is deleted during driver unload. WDF_OBJECT_ATTRIBUTES_INIT(&attributes); attributes.EvtCleanupCallback = VioCryptDriverContextCleanup; WDF_DRIVER_CONFIG_INIT(&config, VioCryptDeviceAdd); status = WdfDriverCreate(DriverObject, RegistryPath, &attributes, &config, WDF_NO_HANDLE); if (!NT_SUCCESS(status)) { Trace(TRACE_LEVEL_ERROR, "[%s] WdfDriverCreate failed: status %X", __FUNCTION__, status); WPP_CLEANUP(DriverObject); } Trace(TRACE_LEVEL_VERBOSE, "[%s] -->", __FUNCTION__); return status; }
VOID EvtDriverContextCleanup( IN WDFOBJECT Driver ) { WPP_CLEANUP(WdfDriverWdmGetDriverObject((WDFDRIVER)Driver )); }
_Use_decl_annotations_ VOID PlxEvtDriverContextCleanup( WDFOBJECT Driver ) /*++ Routine Description: Free all the resources allocated in DriverEntry. Arguments: Driver - handle to a WDF Driver object. Return Value: VOID. --*/ { PAGED_CODE (); TraceEvents(TRACE_LEVEL_INFORMATION, DBG_INIT, "PlxEvtDriverContextCleanup: enter"); WPP_CLEANUP( WdfDriverWdmGetDriverObject( Driver ) ); }
BOOL WINAPI DllMain( HINSTANCE ModuleHandle, DWORD Reason, PVOID Reserved ) { UNREFERENCED_PARAMETER(ModuleHandle); UNREFERENCED_PARAMETER(Reserved); if (DLL_PROCESS_ATTACH == Reason) { #ifndef WPP_MACRO_USE_KM_VERSION_FOR_UM WPP_INIT_TRACING(NFCCX_TRACING_ID); #endif EventRegisterMicrosoft_Windows_NFC_ClassExtension(); TraceLoggingRegister(g_hNfcCxProvider); } else if (DLL_PROCESS_DETACH == Reason) { #ifndef WPP_MACRO_USE_KM_VERSION_FOR_UM WPP_CLEANUP(); #endif EventUnregisterMicrosoft_Windows_NFC_ClassExtension(); TraceLoggingUnregister(g_hNfcCxProvider); } return TRUE; }
VOID OsrFxEvtDriverContextCleanup( WDFOBJECT Driver ) /*++ Routine Description: Free resources allocated in DriverEntry that are automatically cleaned up framework. Arguments: Driver - handle to a WDF Driver object. Return Value: VOID. --*/ { PAGED_CODE (); TraceEvents(TRACE_LEVEL_INFORMATION, DBG_INIT, "--> OsrFxEvtDriverContextCleanup\n"); WPP_CLEANUP( WdfDriverWdmGetDriverObject( (WDFDRIVER)Driver )); UNREFERENCED_PARAMETER(Driver); // For the case when WPP is not being used. EventUnregisterOSRUSBFX2(); }
NTSTATUS DriverEntry(IN PDRIVER_OBJECT DriverObject, IN PUNICODE_STRING RegistryPath) { NTSTATUS status; WDF_DRIVER_CONFIG config; WDF_OBJECT_ATTRIBUTES attributes; // Initialize WPP tracing. WPP_INIT_TRACING(DriverObject, RegistryPath); TraceEvents(TRACE_LEVEL_VERBOSE, DBG_INIT, "--> %!FUNC!"); // Register a cleanup callback so that we can call WPP_CLEANUP when // the framework driver object is deleted during driver unload. WDF_OBJECT_ATTRIBUTES_INIT(&attributes); attributes.EvtCleanupCallback = PVPanicEvtDriverContextCleanup; WDF_DRIVER_CONFIG_INIT(&config, PVPanicEvtDeviceAdd); status = WdfDriverCreate(DriverObject, RegistryPath, &attributes, &config, WDF_NO_HANDLE); if (!NT_SUCCESS(status)) { TraceEvents(TRACE_LEVEL_ERROR, DBG_INIT, "WdfDriverCreate failed: %!STATUS!", status); WPP_CLEANUP(DriverObject); } else { TraceEvents(TRACE_LEVEL_VERBOSE, DBG_INIT, "<-- %!FUNC!"); } return status; }
VOID NfcCxEvtDriverUnload( _In_ WDFDRIVER Driver ) /*++ Routine Description: Driver Unload routine. While the implementation of this function doesn't actually do anything, it is required to tell WDF that our driver is unloadable. Arguments: DriverObject - pointer to the driver object Return Value: None --*/ { UNREFERENCED_PARAMETER(Driver); TRACE_FUNCTION_ENTRY(LEVEL_VERBOSE); TRACE_FUNCTION_EXIT(LEVEL_VERBOSE); #ifdef WPP_MACRO_USE_KM_VERSION_FOR_UM WPP_CLEANUP(WdfDriverWdmGetDriverObject(Driver)); #endif }
VOID SerialEvtDriverContextCleanup( IN WDFDRIVER Driver ) /*++ Routine Description: Free all the resources allocated in DriverEntry. Arguments: Driver - handle to a WDF Driver object. Return Value: VOID. --*/ { UNREFERENCED_PARAMETER(Driver); PAGED_CODE (); SerialDbgPrintEx(TRACE_LEVEL_INFORMATION, DBG_INIT, "--> SerialEvtDriverContextCleanup\n"); // // Stop WPP Tracing // WPP_CLEANUP( WdfDriverWdmGetDriverObject(Driver) ); SerialDbgPrintEx(TRACE_LEVEL_INFORMATION, DBG_INIT, "<-- SerialEvtDriverContextCleanup\n"); }
VOID SmplDeviceEvtDriverContextCleanup( _In_ WDFOBJECT DriverObject ) /*++ Routine Description: Free all the resources allocated in DriverEntry. Arguments: DriverObject - handle to a WDF Driver object. Return Value: VOID. --*/ { UNREFERENCED_PARAMETER(DriverObject); PAGED_CODE (); TraceEvents(TRACE_LEVEL_INFORMATION, TRACE_DRIVER, "%!FUNC! Entry"); // // Stop WPP Tracing // WPP_CLEANUP( WdfDriverWdmGetDriverObject(DriverObject) ); }
///////////////////////////////////////////////////////////////////////// // // DllMain // // This is the main DLL Entry Point. // // Parameters: // hInstance - Handle to the DLL module // dwReason - Indicates why the DLL entry point is being called // lpReserved - Additional information based on dwReason // // Return Values: // TRUE = initialization succeeds // FALSE = initialization fails // ///////////////////////////////////////////////////////////////////////// extern "C" BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved) { (lpReserved); switch (dwReason) { case DLL_PROCESS_ATTACH: // Initialize tracing WPP_INIT_TRACING(MYDRIVER_TRACING_ID); DisableThreadLibraryCalls(hInstance); break; case DLL_PROCESS_DETACH: // Cleanup tracing. WPP_CLEANUP(); _AtlModule.Term(); break; default: break; } // Call the ATL module class so it can initialize return _AtlModule.DllMain(dwReason, lpReserved); }
//Installable driver initialization entry point. This entry point is called directly by the I/O system. // NTSTATUS DriverEntry (_In_ PDRIVER_OBJECT pDriverObject, _In_ PUNICODE_STRING pszRegistryPath) { NTSTATUS status = STATUS_SUCCESS; WDF_DRIVER_CONFIG config; WDF_OBJECT_ATTRIBUTES attributes; // Initialize WPP Tracing WPP_INIT_TRACING(pDriverObject, pszRegistryPath); TraceInfo(DBG_INIT, "(%!FUNC!) Enter -Sample Built %s %s\n", __DATE__, __TIME__); WDF_DRIVER_CONFIG_INIT(&config, HidFx2EvtDeviceAdd); // Register a cleanup callback so that we can call WPP_CLEANUP when the framework driver object is deleted during driver unload. WDF_OBJECT_ATTRIBUTES_INIT(&attributes); attributes.EvtCleanupCallback = HidFx2EvtDriverContextCleanup; // Create a framework driver object to represent our driver. status = WdfDriverCreate(pDriverObject, pszRegistryPath, &attributes, // Driver Attributes &config, // Driver Config Info WDF_NO_HANDLE ); if (!NT_SUCCESS(status)) { TraceErr(DBG_INIT, "(%!FUNC!)WdfDriverCreate failed with status %!STATUS!\n", status); WPP_CLEANUP(pDriverObject); } TraceVerbose(DBG_INIT, "(%!FUNC!) Exit\n"); return status; }
VOID HidFx2EvtDriverContextCleanup( IN WDFOBJECT Object ) /*++ Routine Description: Free resources allocated in DriverEntry that are not automatically cleaned up framework. Arguments: Driver - handle to a WDF Driver object. Return Value: VOID. --*/ { PAGED_CODE (); TraceEvents(TRACE_LEVEL_INFORMATION, DBG_INIT, "Exit HidFx2EvtDriverContextCleanup\n"); WPP_CLEANUP(WdfDriverWdmGetDriverObject((WDFDRIVER) Object)); }
NTSTATUS DriverEntry(IN PDRIVER_OBJECT DriverObject, IN PUNICODE_STRING RegistryPath) { NTSTATUS status = STATUS_SUCCESS; WDF_DRIVER_CONFIG config; WDF_OBJECT_ATTRIBUTES attributes; WPP_INIT_TRACING(DriverObject, RegistryPath); TraceEvents(TRACE_LEVEL_INFORMATION, DBG_INIT, "Virtio-Serial driver started...built on %s %s\n", __DATE__, __TIME__); WDF_DRIVER_CONFIG_INIT(&config,VIOSerialEvtDeviceAdd); config.DriverPoolTag = VIOSERIAL_DRIVER_MEMORY_TAG; WDF_OBJECT_ATTRIBUTES_INIT(&attributes); attributes.EvtCleanupCallback = VIOSerialEvtDriverContextCleanup; status = WdfDriverCreate(DriverObject, RegistryPath, &attributes, &config, WDF_NO_HANDLE); if (!NT_SUCCESS(status)) { TraceEvents(TRACE_LEVEL_ERROR, DBG_INIT, "WdfDriverCreate failed - 0x%x\n", status); WPP_CLEANUP(DriverObject); return status; } TraceEvents(TRACE_LEVEL_INFORMATION, DBG_PNP, "<-- %s\n", __FUNCTION__); return status; }
//Free resources allocated in DriverEntry that are not automatically cleaned up framework. // void HidFx2EvtDriverContextCleanup(_In_ WDFOBJECT hDriver) { PAGED_CODE (); TraceVerbose(DBG_INIT, "(%!FUNC!) Enter/Exit\n"); WPP_CLEANUP(WdfDriverWdmGetDriverObject(hDriver)); }
VOID SingleCompEvtDriverCleanup( _In_ WDFOBJECT Driver ) { UNREFERENCED_PARAMETER(Driver); WPP_CLEANUP(); }
_Use_decl_annotations_ VOID OnDriverUnload ( WDFDRIVER WdfDriver ) { PAGED_CODE(); DRIVER_OBJECT* driverObjectPtr = WdfDriverWdmGetDriverObject(WdfDriver); WPP_CLEANUP(driverObjectPtr); }
VOID SingleCompEvtDriverCleanup( _In_ WDFOBJECT Driver ) { PAGED_CODE(); WPP_CLEANUP(WdfDriverWdmGetDriverObject((WDFDRIVER) Driver)); }
NTSTATUS DriverEntry(IN PDRIVER_OBJECT DriverObject, IN PUNICODE_STRING RegistryPath) { NTSTATUS status = STATUS_SUCCESS; WDF_DRIVER_CONFIG config; WDF_OBJECT_ATTRIBUTES attributes; WDFDRIVER Driver; PDRIVER_CONTEXT Context; #if (NTDDI_VERSION > NTDDI_WIN7) ExInitializeDriverRuntime(DrvRtPoolNxOptIn); #endif WPP_INIT_TRACING(DriverObject, RegistryPath); TraceEvents(TRACE_LEVEL_INFORMATION, DBG_INIT, "Virtio-Serial driver started...built on %s %s\n", __DATE__, __TIME__); WDF_DRIVER_CONFIG_INIT(&config,VIOSerialEvtDeviceAdd); config.DriverPoolTag = VIOSERIAL_DRIVER_MEMORY_TAG; WDF_OBJECT_ATTRIBUTES_INIT_CONTEXT_TYPE(&attributes, DRIVER_CONTEXT); attributes.EvtCleanupCallback = VIOSerialEvtDriverContextCleanup; status = WdfDriverCreate(DriverObject, RegistryPath, &attributes, &config, &Driver); if (!NT_SUCCESS(status)) { TraceEvents(TRACE_LEVEL_ERROR, DBG_INIT, "WdfDriverCreate failed - 0x%x\n", status); WPP_CLEANUP(DriverObject); return status; } Context = GetDriverContext(Driver); // create a lookaside list used for allocating WRITE_BUFFER_ENTRY // structures by all devices status = WdfLookasideListCreate(WDF_NO_OBJECT_ATTRIBUTES, sizeof(WRITE_BUFFER_ENTRY), NonPagedPool, WDF_NO_OBJECT_ATTRIBUTES, VIOSERIAL_DRIVER_MEMORY_TAG, &Context->WriteBufferLookaside); if (!NT_SUCCESS(status)) { TraceEvents(TRACE_LEVEL_ERROR, DBG_INIT, "WdfLookasideListCreate failed - 0x%x\n", status); return status; } TraceEvents(TRACE_LEVEL_INFORMATION, DBG_PNP, "<-- %s\n", __FUNCTION__); return status; }
VOID TracedrvDriverUnload( IN PDRIVER_OBJECT DriverObject ) /*++ Routine Description: Free all the resources allocated in DriverEntry. Arguments: DriverObject - pointer to a driver object. Return Value: VOID. --*/ { PDEVICE_OBJECT pDevObj; UNICODE_STRING linkName; PAGED_CODE(); KdPrint(("TraceDrv: Unloading \n")); // // Get pointer to Device object // pDevObj = DriverObject->DeviceObject; // // Cleanup using DeviceObject on Win2K. Make sure // this is same deviceobject that used for initializing. // On XP the Parameter is ignored WPP_CLEANUP(pDevObj); // // Form the Win32 symbolic link name. // RtlInitUnicodeString( &linkName, TRACEDRV_WIN32_DEVICE_NAME ); // // Remove symbolic link from Object // namespace... // IoDeleteSymbolicLink( &linkName ); // // Unload the callbacks from the kernel to this driver // IoDeleteDevice( pDevObj ); }
int __cdecl _tmain(int argc, TCHAR** argv) { WPP_INIT_TRACING(_T("ndasportcmd")); int ret = Run(argc, argv); WPP_CLEANUP(); return ret; }
VOID VIOInputEvtDriverContextCleanup( IN WDFOBJECT Driver) { PAGED_CODE(); TraceEvents(TRACE_LEVEL_INFORMATION, DBG_PNP, "<--> %s\n", __FUNCTION__); WPP_CLEANUP(WdfDriverWdmGetDriverObject((WDFDRIVER)Driver)); }
VOID VioCryptDriverContextCleanup(IN WDFOBJECT DriverObject) { UNREFERENCED_PARAMETER(DriverObject); Trace(TRACE_LEVEL_VERBOSE, "[%s]", __FUNCTION__); PAGED_CODE(); // Stop the WPP tracing. WPP_CLEANUP(WdfDriverWdmGetDriverObject(DriverObject)); }
VOID PVPanicEvtDriverContextCleanup(IN WDFOBJECT DriverObject) { UNREFERENCED_PARAMETER(DriverObject); TraceEvents(TRACE_LEVEL_VERBOSE, DBG_INIT, "<-> %!FUNC!"); PAGED_CODE(); // Stop WPP tracing. WPP_CLEANUP(WdfDriverWdmGetDriverObject(DriverObject)); }
BOOL WINAPI DllMain( HINSTANCE ModuleHandle, DWORD Reason, PVOID Reserved ) /*++ Routine Description: This is the entry point and exit point for the I/O trace driver. This does very little as the I/O trace driver has minimal global data. This method initializes tracing. Arguments: ModuleHandle - the DLL handle for this module. Reason - the reason this entry point was called. Reserved - unused Return Value: TRUE --*/ { UNREFERENCED_PARAMETER( ModuleHandle ); if (DLL_PROCESS_ATTACH == Reason) { // // Initialize tracing. // WPP_INIT_TRACING(MYDRIVER_TRACING_ID); } else if (DLL_PROCESS_DETACH == Reason) { // // Cleanup tracing. // WPP_CLEANUP(); } return _AtlModule.DllMain(Reason, Reserved); ; }
BOOL WINAPI DllMain( HINSTANCE ModuleHandle, DWORD Reason, PVOID /* Reserved */ ) /*++ Routine Description: This is the entry point and exit point for the I/O trace driver. This does very little as the I/O trace driver has minimal global data. This method initializes tracing, and saves the module handle away in a global variable so that it can be referenced should the COM registration code (Dll[Un]RegisterServer) be called. Arguments: ModuleHandle - the DLL handle for this module. Reason - the reason this entry point was called. Reserved - unused Return Value: TRUE --*/ { UNREFERENCED_PARAMETER(ModuleHandle); if (DLL_PROCESS_ATTACH == Reason) { // // Initialize tracing. // WPP_INIT_TRACING(MYDRIVER_TRACING_ID); } else if (DLL_PROCESS_DETACH == Reason) { // // Cleanup tracing. // WPP_CLEANUP(); } return TRUE; }
void ParaNdis_DebugCleanup(PDRIVER_OBJECT pDriverObject) { #ifdef OVERRIDE_DEBUG_BREAK if (sizeof(PVOID) == sizeof(ULONG) && pDbgBreakPoint) { DPrintf(0, ("Restoring original BP handler at %p", pDbgBreakPoint)); RtlCopyMemory(pDbgBreakPoint, DbgBreakPointChunk, sizeof(DbgBreakPointChunk)); } #endif BugCheckDeregisterCallback(&CallbackRecord); WPP_CLEANUP(pDriverObject); }
NTSTATUS DriverEntry(IN PDRIVER_OBJECT DriverObject,IN PUNICODE_STRING RegistryPath) { NTSTATUS status; WDF_DRIVER_CONFIG config; WDF_OBJECT_ATTRIBUTES attributes; #if defined(_DEBUG) || defined(DBG) // if (TRUE == KdRefreshDebuggerNotPresent()) // return STATUS_UNSUCCESSFUL;// For the time being, don't load the driver if no debugger is attached // DbgBreakPoint(); if (FALSE == KdRefreshDebuggerNotPresent()) DbgBreakPoint(); #endif // Initialize WPP Tracing WPP_INIT_TRACING( DriverObject, RegistryPath ); WPP_FLAG_LEVEL_ENABLED(MYDRIVER_ALL_INFO, TRACE_LEVEL_VERBOSE); TraceEvents(TRACE_LEVEL_INFORMATION, TRACE_DRIVER, "UsbCfgCtrl>> DriverEntry " __DATE__ " " __TIME__ "\r\n"); // Register a cleanup callback so that we can call WPP_CLEANUP when the framework driver object is deleted during driver unload. WDF_OBJECT_ATTRIBUTES_INIT(&attributes); attributes.EvtCleanupCallback = [](IN WDFOBJECT DriverObject) { TraceEvents(TRACE_LEVEL_INFORMATION, TRACE_DRIVER, "%!FUNC! Entry"); // Stop WPP Tracing WPP_CLEANUP(WdfDriverWdmGetDriverObject((WDFDRIVER)DriverObject)); }; WDF_DRIVER_CONFIG_INIT(&config, UsbCfgDevice::CreateDevice);// UsbCfgCtrlEvtDeviceAdd); status = WdfDriverCreate(DriverObject, RegistryPath, &attributes, &config, WDF_NO_HANDLE); if (NT_FAILED(status)) { TraceEvents(TRACE_LEVEL_ERROR, TRACE_DRIVER, "WdfDriverCreate failed %!STATUS!\r\n", status); WPP_CLEANUP(DriverObject); return status; } TraceEvents(TRACE_LEVEL_INFORMATION, TRACE_DRIVER, "%!FUNC! Exit\r\n"); return status; }