Windows 10
A Microsoft operating system that runs on personal computers and tablets.
9,484 questions
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
NTSTATUS
DriverEntry(
__in PDRIVER_OBJECT DriverObject,
__in PUNICODE_STRING RegistryPath
)
{
WDF_DRIVER_CONFIG config;
NTSTATUS status;
WDF_OBJECT_ATTRIBUTES attributes;
WDFDRIVER driver;
DTRACE("DriverEntry Called");
//
// 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 = RcardDrvEvtCleanup;
attributes.EvtDestroyCallback = RcardDrvEvtDestroyCallback;
WDF_DRIVER_CONFIG_INIT(&config,
RcardDrvEvtDeviceAdd
);
status = WdfDriverCreate(DriverObject,
RegistryPath,
&attributes,
&config,
&driver
);
if (!NT_SUCCESS(status)) {
DERROR("Failed in DriverEntry %x\n", status);
return status;
}
//WdfObjectReference(DriverObject);
DTRACE("Driver Create Success DriverEntry %x\n", status);
return status;
}
NTSTATUS
RcardDrvEvtDeviceAdd(
__in WDFDRIVER Driver,
__inout PWDFDEVICE_INIT DeviceInit
)
/*++
Routine Description:
EvtDeviceAdd is called by the framework in response to AddDevice
call from the PnP manager. We create and initialize a device object to
represent a new instance of the device.
Arguments:
Driver - Handle to a framework driver object created in DriverEntry
DeviceInit - PoINTer to a framework-allocated WDFDEVICE_INIT structure.
Return Value:
NTSTATUS
--*/
{
NTSTATUS status = STATUS_SUCCESS;
WDF_PNPPOWER_EVENT_CALLBACKS pnpPowerCallbacks;
WDF_OBJECT_ATTRIBUTES attributes;
WDFDEVICE device;
PRPP_DEVICE_CONTEXT devContext = NULL;
UNICODE_STRING symbolicLinkName;
USHORT symbolicLinkNameBuf[256] = { 0 };
WDF_IO_QUEUE_CONFIG queueConfig;
WDFQUEUE queue;
UNREFERENCED_PARAMETER(Driver);
PAGED_CODE();
DTRACE(" Device Add called \n");
//
// Zero out the PnpPowerCallbacks structure.
//
WDF_PNPPOWER_EVENT_CALLBACKS_INIT(&pnpPowerCallbacks);
//
// Set Callbacks for any of the functions we are INTerested in.
// If no callback is set, Framework will take the default action
// by itself.
//
pnpPowerCallbacks.EvtDevicePrepareHardware = RcardEvtDevicePrepareHardware;
pnpPowerCallbacks.EvtDeviceReleaseHardware = RcardEvtDeviceReleaseHardware;
//
// These two callbacks set up and tear down hardware state that must be
// done every time the device moves in and out of the D0-working state.
//
pnpPowerCallbacks.EvtDeviceD0Entry = RcardEvtDeviceD0Entry;
pnpPowerCallbacks.EvtDeviceD0Exit = RcardEvtDeviceD0Exit;
// Register the PnP Callbacks..
WdfDeviceInitSetPnpPowerEventCallbacks(DeviceInit, &pnpPowerCallbacks);
// Initialize Fdo Attributes.
WDF_OBJECT_ATTRIBUTES_INIT_CONTEXT_TYPE(&attributes, RCARD_DEVICE_CONTEXT);
WdfDeviceInitSetIoType(DeviceInit, WdfDeviceIoDirect);
...