summaryrefslogtreecommitdiff
path: root/nfc/Simulator/Src/Driver.cpp
blob: 5082e3b4b2acdf040414256abf1755cd93cf63f3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
/*++
 
Copyright (C) Microsoft Corporation, All Rights Reserved.

Module Name:

    Driver.cpp

Abstract:

    This module contains the implementation of the UMDF driver callback object.

Environment:

   Windows User-Mode Driver Framework (WUDF)

--*/

#include "Internal.h"
#include "Driver.tmh"

DECLARE_TRACING_TLS;

NTSTATUS
DriverEntry(
    _In_ PDRIVER_OBJECT DriverObject,
    _In_ PUNICODE_STRING RegistryPath
    )
{
    NTSTATUS Status = STATUS_SUCCESS;
    WDF_DRIVER_CONFIG Config;

    WPP_INIT_TRACING(DriverObject, RegistryPath);
    TracingTlsInitialize();

    FunctionEntry("...");

    WDF_DRIVER_CONFIG_INIT(&Config, CDevice::OnDeviceAdd);
    Config.EvtDriverUnload = OnDriverUnload;

    Status = WdfDriverCreate(
                    DriverObject,
                    RegistryPath,
                    WDF_NO_OBJECT_ATTRIBUTES,
                    &Config,
                    WDF_NO_HANDLE);

    if (!NT_SUCCESS(Status)) {
        TraceInfo("WdfDriverCreate failed with Status %!STATUS!", Status);
        goto Exit;
    }
    
Exit:
    if (!NT_SUCCESS(Status)) {
        TracingTlsFree();
        WPP_CLEANUP(DriverObject);
    }
    FunctionReturn(Status, "Status = %!STATUS!", Status);
}

VOID
OnDriverUnload(
    _In_ WDFDRIVER Driver
    )
{
    UNREFERENCED_PARAMETER(Driver);

    TracingTlsFree();
    WPP_CLEANUP(WdfDriverWdmGetDriverObject(Driver));
}