summaryrefslogtreecommitdiff
path: root/nfc/NfcCxSample/windows-drivertemplate-nfc/Driver.cpp
blob: c07eabe8b84007e87e5a8802651587abc93a3753 (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
#include <windows.h>
#include <wdf.h>

#include "Device.h"

extern "C" DRIVER_INITIALIZE DriverEntry;

// [Required]
// The entry point for the driver.
//
// In general, almost nothing should be done during driver initialization. Instead, almost all resources should
// be associated with a specific device.
//
// https://docs.microsoft.com/windows-hardware/drivers/wdf/driverentry-for-kmdf-drivers
extern "C" NTSTATUS DriverEntry(
    _In_ PDRIVER_OBJECT DriverObject,
    _In_ PUNICODE_STRING RegistryPath
    )
{
    NTSTATUS status;

    // Specify `DeviceContext::AddDevice` as the `EvtDriverDeviceAdd` callback function
    // for the driver.
    WDF_DRIVER_CONFIG driverConfig;
    WDF_DRIVER_CONFIG_INIT(&driverConfig, DeviceContext::AddDevice);

    // Initialize WDF.
    status = WdfDriverCreate(
        DriverObject,
        RegistryPath,
        WDF_NO_OBJECT_ATTRIBUTES,
        &driverConfig,
        WDF_NO_HANDLE
        );
    if (!NT_SUCCESS(status))
    {
        return status;
    }

    return STATUS_SUCCESS;
}