In the previous article, "Windows Driver Development-3" We used PNP, which is now bad for WMI.
Wmi:windows Management Interface
WMI provides pre-assembled class schemas that allow scripts or applications written in scripting language (VBS), C #, VB. NET, or C + + to monitor and configure applications, systems, or network components, and hardware in the computer.
WMI Although WDF does a lot of work for you, you also have to trigger events and instantiate callback functions yourself. It is easy to use Wmilib.sys static registration in WDM, but it is difficult to register dynamically. But in WDF, these are easy to implement. 1. Irp_mj_system_control
WDF has full control of Irp_mj_system_control.
Irp_mj_system_control: Control information generated inside the system, similar to the kernel call Devicecontrol function
Note: The minimum requirements for using the Devicecontrol system are XP.
BOOL WINAPI DeviceIoControl ( _in_ HANDLE hdevice, _in_ DWORD dwiocontrolcode, _in_ Opt_ lpvoid lpinbuffer, _in_ DWORD ninbuffersize, _out_opt_ lpvoid lpOutBuffer, _in_ DWORD noutbuffersize, _out_opt_ lpdword lpbytesreturned, _inout_opt_ lpoverlapped lpoverlapped);
2. Mode
(1) instantiation of used equipment
(2) Triggering an event when needed
(3) Statistical report
(4) Update status
(5) Delete device after logout (normal or accidental deletion)
3. ETW/Tracking
Supports kernel mode ETW/trace
Ii. WDF and WMI
WDF uses Wdfdevicecreatedeviceinterface to provide an interface for WMI.
NTSTATUS Wdfdevicecreatedeviceinterface ( [in] wdfdevice Device, [in] const GUID * Interfaceclassguid, [in, optional] pcunicode_string referencestring);
where GUID, see "Using GUIDs in Drivers"
GUID declaration (need to use header file Initguid.h):
Define_guid (GUID_DEVINTERFACE_OSRUSBFX2,//Generated using Guidgen.exe 0x573e8c73, 0XCB4, 0x4471, 0xa1, 0XBF, 0XFA , 0xb2, 0x6c, 0x31, 0xd3, 0x84);//{573e8c73-0cb4-4471-a1bf-fab26c31d384}
Windows Driver Development-4