| 33 | #endif |
| 34 | |
| 35 | NTSTATUS |
| 36 | loaderCreateDevice(_Inout_ PWDFDEVICE_INIT DeviceInit) |
| 37 | /*++ |
| 38 | |
| 39 | Routine Description: |
| 40 | |
| 41 | Worker routine called to create a device and its software resources. |
| 42 | |
| 43 | Arguments: |
| 44 | |
| 45 | DeviceInit - Pointer to an opaque init structure. Memory for this |
| 46 | structure will be freed by the framework when the WdfDeviceCreate |
| 47 | succeeds. So don't access the structure after that point. |
| 48 | |
| 49 | Return Value: |
| 50 | |
| 51 | NTSTATUS |
| 52 | |
| 53 | --*/ |
| 54 | { |
| 55 | WDF_OBJECT_ATTRIBUTES deviceAttributes; |
| 56 | PDEVICE_CONTEXT deviceContext; |
| 57 | WDFDEVICE device; |
| 58 | NTSTATUS status; |
| 59 | |
| 60 | PAGED_CODE(); |
| 61 | |
| 62 | WDF_OBJECT_ATTRIBUTES_INIT_CONTEXT_TYPE(&deviceAttributes, DEVICE_CONTEXT); |
| 63 | |
| 64 | status = WdfDeviceCreate(&DeviceInit, &deviceAttributes, &device); |
| 65 | |
| 66 | if (NT_SUCCESS(status)) { |
| 67 | // |
| 68 | // Get a pointer to the device context structure that we just associated |
| 69 | // with the device object. We define this structure in the device.h |
| 70 | // header file. DeviceGetContext is an inline function generated by |
| 71 | // using the WDF_DECLARE_CONTEXT_TYPE_WITH_NAME macro in device.h. |
| 72 | // This function will do the type checking and return the device context. |
| 73 | // If you pass a wrong object handle it will return NULLPTR and assert if |
| 74 | // run under framework verifier mode. |
| 75 | // |
| 76 | deviceContext = DeviceGetContext(device); |
| 77 | |
| 78 | // |
| 79 | // Initialize the context. |
| 80 | // |
| 81 | deviceContext->PrivateDeviceData = 0; |
| 82 | |
| 83 | // |
| 84 | // Create a device interface so that applications can find and talk |
| 85 | // to us. |
| 86 | // |
| 87 | status = WdfDeviceCreateDeviceInterface( |
| 88 | device, |
| 89 | &GUID_DEVINTERFACE_LOADER, |
| 90 | NULLPTR // ReferenceString |
| 91 | ); |
| 92 |
no test coverage detected