/*++ Copyright (c) Microsoft Corporation. All rights reserved. Module Name: driver.cpp Abstract: This file contains the driver entry points and callbacks. Environment: Windows User-Mode Driver Framework --*/ #include "precomp.h" #include "Trace.h" #include "Defaults.h" #include "Driver.h" #include "Device.h" #include "Driver.tmh" extern "C" NTSTATUS DriverEntry( _In_ PDRIVER_OBJECT DriverObject, _In_ PUNICODE_STRING RegistryPath ) { NTSTATUS status = STATUS_SUCCESS; // Initialize WPP Tracing WPP_INIT_TRACING(DriverObject, RegistryPath); TraceEvents(TRACE_LEVEL_INFORMATION, TRACE_DRIVER, "%!FUNC! Entry"); // Register a cleanup callback so that we can call WPP_CLEANUP when // the framework driver object is deleted during driver unload. WDF_OBJECT_ATTRIBUTES attributes; WDF_OBJECT_ATTRIBUTES_INIT(&attributes); attributes.EvtCleanupCallback = GnssUmdfEvtDriverContextCleanup; WDF_DRIVER_CONFIG config; WDF_DRIVER_CONFIG_INIT(&config, CDevice::OnDeviceAdd); config.EvtDriverUnload = OnDriverUnload; status = WdfDriverCreate(DriverObject, RegistryPath, &attributes, &config, WDF_NO_HANDLE); if (!NT_SUCCESS(status)) { TraceEvents(TRACE_LEVEL_ERROR, TRACE_DRIVER, "WdfDriverCreate failed %!STATUS!", status); WPP_CLEANUP(DriverObject); return status; } TraceEvents(TRACE_LEVEL_INFORMATION, TRACE_DRIVER, "%!FUNC! Exit"); return status; } void GnssUmdfEvtDriverContextCleanup( _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); TraceEvents(TRACE_LEVEL_INFORMATION, TRACE_DRIVER, "%!FUNC! Entry"); // Stop WPP Tracing WPP_CLEANUP(WdfDriverWdmGetDriverObject((WDFDRIVER)DriverObject)); } void OnDriverUnload( _In_ WDFDRIVER /* Driver */ ) { WPP_CLEANUP(Driver); }