A simple little driver include wdk h include
- Slides: 44
A simple little driver
#include <wdk. h> #include <wdf. h> DRIVER_INITIALIZE Driver. Entry; EVT_WDF_DRIVER_DEVICE_ADD On. Device. Add; NTSTATUS Driver. Entry(PDRIVER_OBJECT Driver. Object, PUNICODE_STRING Registry. Path) { WDF_DRIVER_CONFIG config; WDF_DRIVER_CONFIG_INIT(&config, On. Device. Add); return Wdf. Driver. Create(Driver. Object, Registry. Path, WDF_NO_OBJECT_ATTRIBUTES, &config, WDF_NO_HANDLE); } NTSTATUS On. Device. Add(WDFDRIVER Driver, PWDFDEVICE_INIT Device. Init) { return Wdf. Device. Create(&Device. Init, WDF_NO_OBJECT_ATTRIBUTES, WDF_NO_HANDLE); }
#include <wdk. h> #include <wdf. h> DRIVER_INITIALIZE Driver. Entry; EVT_WDF_DRIVER_DEVICE_ADD On. Device. Add; NTSTATUS Driver. Entry(PDRIVER_OBJECT Driver. Object, PUNICODE_STRING Registry. Path) { WDF_DRIVER_CONFIG config; WDF_DRIVER_CONFIG_INIT(&config, On. Device. Add); return Wdf. Driver. Create(Driver. Object, Registry. Path, WDF_NO_OBJECT_ATTRIBUTES, &config, WDF_NO_HANDLE); } NTSTATUS On. Device. Add(WDFDRIVER Driver, PWDFDEVICE_INIT Device. Init) { return Wdf. Device. Create(&Device. Init, WDF_NO_OBJECT_ATTRIBUTES, WDF_NO_HANDLE); }
#include <wdk. h> #include <wdf. h> DRIVER_INITIALIZE Driver. Entry; EVT_WDF_DRIVER_DEVICE_ADD On. Device. Add; NTSTATUS Driver. Entry(PDRIVER_OBJECT Driver. Object, PUNICODE_STRING Registry. Path) { WDF_DRIVER_CONFIG config; WDF_DRIVER_CONFIG_INIT(&config, On. Device. Add); return Wdf. Driver. Create(Driver. Object, Registry. Path, WDF_NO_OBJECT_ATTRIBUTES, &config, WDF_NO_HANDLE); } NTSTATUS On. Device. Add(WDFDRIVER Driver, PWDFDEVICE_INIT Device. Init) { return Wdf. Device. Create(&Device. Init, WDF_NO_OBJECT_ATTRIBUTES, WDF_NO_HANDLE); }
#include <wdk. h> #include <wdf. h> DRIVER_INITIALIZE Driver. Entry; EVT_WDF_DRIVER_DEVICE_ADD On. Device. Add; NTSTATUS Driver. Entry(PDRIVER_OBJECT Driver. Object, PUNICODE_STRING Registry. Path) { WDF_DRIVER_CONFIG config; WDF_DRIVER_CONFIG_INIT(&config, On. Device. Add); return Wdf. Driver. Create(Driver. Object, Registry. Path, WDF_NO_OBJECT_ATTRIBUTES, &config, WDF_NO_HANDLE); } NTSTATUS On. Device. Add(WDFDRIVER Driver, PWDFDEVICE_INIT Device. Init) { return Wdf. Device. Create(&Device. Init, WDF_NO_OBJECT_ATTRIBUTES, WDF_NO_HANDLE); }
#include <wdk. h> #include <wdf. h> DRIVER_INITIALIZE Driver. Entry; EVT_WDF_DRIVER_DEVICE_ADD On. Device. Add; NTSTATUS Driver. Entry(PDRIVER_OBJECT Driver. Object, PUNICODE_STRING Registry. Path) { WDF_DRIVER_CONFIG config; WDF_DRIVER_CONFIG_INIT(&config, On. Device. Add); return Wdf. Driver. Create(Driver. Object, Registry. Path, WDF_NO_OBJECT_ATTRIBUTES, &config, WDF_NO_HANDLE); } NTSTATUS On. Device. Add(WDFDRIVER Driver, PWDFDEVICE_INIT Device. Init) { return Wdf. Device. Create(&Device. Init, WDF_NO_OBJECT_ATTRIBUTES, WDF_NO_HANDLE); }
#include <wdk. h> #include <wdf. h> DRIVER_INITIALIZE Driver. Entry; EVT_WDF_DRIVER_DEVICE_ADD On. Device. Add; NTSTATUS Driver. Entry(PDRIVER_OBJECT Driver. Object, PUNICODE_STRING Registry. Path) { WDF_DRIVER_CONFIG config; WDF_DRIVER_CONFIG_INIT(&config, On. Device. Add); return Wdf. Driver. Create(Driver. Object, Registry. Path, WDF_NO_OBJECT_ATTRIBUTES, &config, WDF_NO_HANDLE); } NTSTATUS On. Device. Add(WDFDRIVER Driver, PWDFDEVICE_INIT Device. Init) { return Wdf. Device. Create(&Device. Init, WDF_NO_OBJECT_ATTRIBUTES, WDF_NO_HANDLE); }
#include <wdk. h> #include <wdf. h> DRIVER_INITIALIZE Driver. Entry; EVT_WDF_DRIVER_DEVICE_ADD On. Device. Add; NTSTATUS Driver. Entry(PDRIVER_OBJECT Driver. Object, PUNICODE_STRING Registry. Path) { WDF_DRIVER_CONFIG config; WDF_DRIVER_CONFIG_INIT(&config, On. Device. Add); return Wdf. Driver. Create(Driver. Object, Registry. Path, WDF_NO_OBJECT_ATTRIBUTES, &config, WDF_NO_HANDLE); } NTSTATUS On. Device. Add(WDFDRIVER Driver, PWDFDEVICE_INIT Device. Init) { return Wdf. Device. Create(&Device. Init, WDF_NO_OBJECT_ATTRIBUTES, WDF_NO_HANDLE); }
Storing Driver Specific Data
struct Device. Context { MYDEVICE_STATE Current. State; . . . }; WDF_DECLARE_CONTEXT_TYPE_WITH_NAME(Device. Context, Get. Device. Context); NTSTATUS On. Device. Add(. . . ) { WDFDEVICE device; Device. Context* context; WDF_OBJECT_ATTRIBUTES attributes; WDF_OBJECT_ATTRIBUTES_INIT_CONTEXT_TYPE(&attributes, Device. Context); attributes. Evt. Destroy. Callback = On. Device. Destroy; Wdf. Device. Create(&Device. Init, &attributes, &device); if (failure) {return status; } device. Context = Get. Device. Context(device); device. Context->Current. State = My. Device. State. Uninitialized; . . . }
NTSTATUS On. Device. Add(. . . ) { Wdf. Usb. Target. Create(device, WDF_NO_OBJECT_ATTRIBUTES, &device. Context->Usb. Io. Target); if (failure) return status; WDF_OBJECT_ATTRIBUTES attributes; WDF_OBJECT_ATTRIBUTES_INIT_CONTEXT_TYPE(&attributes, Request. Context); attributes. Parent. Object = device. Context->Usb. Io. Target; Wdf. Request. Create(&attributes, device. Context->Usb. Io. Target, &device. Context->Usb. Request); if (failure) return status; Initialize. Request. Context(device. Context->Usb. Request); if (failure) return status; . . . }
Handling I/O
NTSTATUS On. Device. Add(…, PWDFDEVICE_INIT Device. Init) {. . . // After creating the device… WDF_IO_QUEUE_CONFIG queue. Config; WDF_IO_QUEUE_CONFIG_INIT_DEFAULT_QUEUE( &queue. Config, Wdf. Io. Queue. Dispatch. Sequential ); queue. Config. Evt. Io. Device. Control = On. Device. Control; Wdf. Io. Queue. Create(device, &queue. Config, WDF_NO_OBJECT_ATTRIBUTES, WDF_NO_OBJECT); … }
VOID On. Device. Control(WDFQUEUE Queue, WDFREQUEST Request, size_t Input. Cb, size_t Output. Cb, ULONG Io. Control. Code) { if (Io. Control. Code != IOCTL_MYDRIVER_DO_SOMETHING) { goto error; } Wdf. Request. Retrieve. Input. Buffer(Request, sizeof(DO_SOMETHING_INPUT), &input, NULL); if (failure) goto error; // Validate input structure if (failure) goto error; // Start request running. if (failure) goto error; return; Error: Wdf. Request. Complete(Request, status); return;
Power Management
NTSTATUS On. Device. Add(. . . ) { … WDF_PNPPOWER_EVENT_CALLBACKS power. Cb; WDF_PNPPOWER_EVENT_CALLBACKS_INIT(&power. Cb); power. Cb. Evt. Device. D 0 Entry = On. D 0 Entry; power. Cb. Evt. Device. D 0 Exit = On. D 0 Exit; Wdf. Device. Init. Set. Pnp. Power. Event. Callbacks(Device. Init, &power. Cb); // create the device. . . WDF_DEVICE_POWER_POLICY_IDLE_SETTINGS idle. Settings; WDF_DEVICE_POWER_POLICY_IDLE_SETTINGS_INIT( &idle. Settings, Idle. Usb. Selective. Suspend ); idle. Settings. Idle. Timeout = 500; // milliseconds Wdf. Device. Assign. S 0 Idle. Settings(device, &idle. Settings); if (failure) return status; }
Summary
Developing Drivers with Windows Driver Foundation Kernel-Mode Driver Framework Design Guide User-Mode Driver Framework Design Guide Choosing a driver model What’s New in Windows Driver Frameworks for Windows 8 wdfinfo@microsoft. com Mine WDF
http: //forums. dev. windows. com http: //bldw. in/Session. Feedback
- Wdk demo
- #include stdio.h #include conio.h #include stdlib.h
- 1 little 2 little 3 little indian
- 1 little 2 little 3 little indian
- Umdf reflector
- #include string.h
- #include iostream using namespace std
- #include iostream #include cmath
- Include
- # include iostream
- Cppinclude
- Namespace string
- Two little feet
- Quantifier of fresh air
- Make the mighty ocean
- Litle a
- Mouse mouse where is your house
- Use of few a few the few
- Fill in a little or a few
- Complete the sentences use these words
- Have present simple
- Simple past simple present simple future
- Past simple future
- Without information
- Future simple in the past
- Present simple present continuous past simple exercises
- Future tense of like
- Forma afirmativa
- Present simple present continuous 4 класс
- Churchill taxi story
- Drivers ed module 10 topic 1
- Module 7 topic 4 drivers ed
- Module 11 topic 1 insuring a vehicle
- Module 8 topic 1
- Utah driver's manual
- User-mode driver framework
- Gsa drive thru