MSDN Documentation

Windows Drivers | WMI

Introduction to Windows Management Instrumentation (WMI)

Windows Management Instrumentation (WMI) is an infrastructure for managing devices and applications on Microsoft Windows-based operating systems. It provides a standardized way to access management information and perform management operations. WMI is built on top of the Component Object Model (COM) and uses a SQL-like query language called the WMI Query Language (WQL) for retrieving information.

What is WMI?

WMI is a core component of the Windows operating system that allows administrators and applications to:

WMI is designed to be extensible, allowing third-party applications and hardware vendors to expose their management information and control capabilities through WMI.

Key Concepts

WMI Providers

WMI providers are COM objects that expose management data to WMI. They act as a bridge between WMI and the underlying managed resources (e.g., operating system components, hardware, applications). Common providers include:

WMI Consumers

WMI consumers are applications or scripts that use WMI to query management information or perform management tasks. Examples include:

WMI Schema (Namespaces and Classes)

WMI organizes management data into a hierarchical structure of namespaces, similar to file system directories. Within each namespace, WMI defines classes that represent managed objects. Each class has properties (attributes) and methods (operations). For example, the Win32_Process class represents a running process and has properties like ProcessId and Name, and methods like Terminate().

You can explore the WMI schema using tools like the WMI Explorer or PowerShell.

Using WMI in Driver Development

For Windows driver developers, WMI provides a powerful mechanism to expose driver-specific information and allow the operating system and user-mode applications to manage driver behavior. By implementing WMI data blocks in your driver, you can:

Instrumenting your driver for WMI involves defining WMI classes using MOF (Managed Object Format) files and implementing the necessary callback routines in your driver to handle WMI requests.

// Example of a WMI query using VBScript
Set objWMIService = GetObject("winmgmts:\\.\root\cimv2")
Set colProcesses = objWMIService.ExecQuery("SELECT * FROM Win32_Process WHERE Name = 'notepad.exe'")

For Each objProcess in colProcesses
    Wscript.Echo "Process Name: " & objProcess.Name & ", Process ID: " & objProcess.ProcessId
Next

Getting Started

To begin working with WMI in driver development, you should familiarize yourself with:

Refer to the subsequent sections for detailed information on WMI providers, classes, instrumentation, and security.

Next Steps

Continue to the WMI Architecture section to understand the fundamental building blocks of WMI.