windows_snapshot/operating_system/drivers.rs
1//! The Drivers subcategory groups classes that represent virtual device drivers and system drivers for base services.
2//!
3//! | Class | Description |
4//! |---------------------------------------------------|---------------------------------------------------------------------------------------|
5//! | [**Win32\_SystemDriver**](Win32_SystemDriver) | Instance class<br/> Represents the system driver for a base service.<br/> |
6
7use crate::update;
8use serde::{Deserialize, Serialize};
9use std::time::SystemTime;
10use wmi::{COMLibrary, WMIConnection, WMIDateTime};
11
12/// Represents the state of Windows Drivers
13#[derive(Deserialize, Serialize, Debug, Clone)]
14pub struct Drivers {
15 /// Sequence of Drivers based on when they were loaded in chronological order
16 pub drivers: Vec<Win32_SystemDriver>,
17 /// When was the record last updated
18 pub last_updated: SystemTime,
19}
20
21update!(Drivers, drivers);
22
23/// The `Win32_SystemDriver` WMI class represents a process on an operating system.
24///
25/// <https://learn.microsoft.com/en-us/windows/win32/cimwin32prov/win32-systemdriver>
26#[derive(Default, Deserialize, Serialize, Debug, Clone)]
27#[allow(non_snake_case)]
28#[allow(non_camel_case_types)]
29pub struct Win32_SystemDriver {
30 /// Service can be paused.
31 pub AcceptPause: Option<bool>,
32 /// Service can be stopped.
33 pub AcceptStop: Option<bool>,
34 /// Short description of the object.
35 pub Caption: Option<String>,
36 /// Name of the first concrete class to appear in the inheritance chain used in the creation of
37 /// an instance. When used with the other key properties of the class, this property allows all
38 /// instances of this class and its subclasses to be uniquely identified.
39 pub CreationClassName: Option<String>,
40 /// Description of the object.
41 pub Description: Option<String>,
42 /// This service can create or communicate with windows on the desktop.
43 pub DesktopInteract: Option<bool>,
44 /// Display name of the service. This string has a maximum length of 256 characters. The name is
45 /// case-preserved in the Service Control Manager. DisplayName comparisons are always
46 /// case-insensitive.
47 ///
48 /// Constraints: Accepts the same value as the Name property.
49 ///
50 /// Example: "Atdisk"
51 pub DisplayName: Option<String>,
52 /// Severity of the error if this service fails to start during startup. This value indicates
53 /// the action taken by the startup program if failure occurs. All errors are logged by the
54 /// computer system.
55 ///
56 /// - Ignore ("Ignore"): User is not notified.
57 /// - Normal ("Normal"): User is notified.
58 /// - Severe ("Severe"): System is restarted with the last-known-good configuration.
59 /// - Critical ("Critical"): System attempts to restart with a good configuration.
60 /// - Unknown ("Unknown"): Cause of the failure is unknown.
61 pub ErrorControl: Option<String>,
62 /// Windows error code defining any problems encountered in starting or stopping the service.
63 /// This property is set to `ERROR_SERVICE_SPECIFIC_ERROR (1066)` when the error is unique to the
64 /// service represented by this class, and information about the error is available in the
65 /// `ServiceSpecificExitCode` property. The service sets this value to `NO_ERROR` when running, and
66 /// again upon normal termination.
67 pub ExitCode: Option<u32>,
68 /// Object was installed. This property does not need a value to indicate that the object is
69 /// installed.
70 pub InstallDate: Option<WMIDateTime>,
71 /// Unique identifier for the service which provides an indication of the functionality that is
72 /// managed. This functionality is described in more detail in the object Description property.
73 pub Name: Option<String>,
74 /// Fully qualified path to the service binary file that implements the service.
75 ///
76 /// Example: "\SystemRoot\System32\drivers\afd.sys"
77 pub PathName: Option<String>,
78 /// Service-specific error code for errors that occur while the service is either starting or
79 /// stopping. The exit codes are defined by the service represented by this class. This value is
80 /// only set when the ExitCode property value is `ERROR_SERVICE_SPECIFIC_ERROR (1066)`.
81 pub ServiceSpecificExitCode: Option<u32>,
82 /// Type of service provided to calling processes.
83 ///
84 /// The values are:
85 ///
86 /// - Kernel Driver ("Kernel Driver")
87 /// - File System Driver ("File System Driver")
88 /// - Adapter ("Adapter")
89 /// - Recognizer Driver ("Recognizer Driver")
90 /// - Own Process ("Own Process")
91 /// - Share Process ("Share Process")
92 /// - Interactive Process ("Interactive Process")
93 pub ServiceType: Option<String>,
94 /// Service has been started.
95 pub Started: Option<bool>,
96 /// Start mode of the system driver.
97 ///
98 /// - Boot ("Boot"): Device driver started by the operating system loader (valid only for driver services).
99 /// - System ("System"): Device driver started by the operating system initialization process. This value is valid only for driver services.
100 /// - Auto ("Auto"): Service to be started automatically by the service control manager during system start up.
101 /// - Manual ("Manual"): Service to be started by the service control manager when a process calls the StartService method.
102 /// - Disabled ("Disabled"): Service that can no longer be started.
103 pub StartMode: Option<String>,
104 /// Account name under which the service runs. Depending on the service type, the account name
105 /// may be in the form of DomainName\Username. The service process will be logged using one of
106 /// these two forms when it runs. If the account belongs to the built-in domain, .\Username can
107 /// be specified. If NULL is specified, the service will be logged on as the LocalSystem
108 /// account. For kernel or system-level drivers, StartName contains the driver object name
109 /// (that is, \FileSystem\Rdr or \Driver\Xns) which the input and output (I/O) system uses to
110 /// load the device driver. Additionally, if NULL is specified, the driver runs with a default
111 /// object name created by the I/O system based on the service name.
112 ///
113 /// Example: "DWDOM\Admin"
114 pub StartName: Option<String>,
115 /// Current state of the base service.
116 ///
117 /// The values are:
118 ///
119 /// - Stopped ("Stopped")
120 /// - Start Pending ("Start Pending")
121 /// - Stop Pending ("Stop Pending")
122 /// - Running ("Running")
123 /// - Continue Pending ("Continue Pending")
124 /// - Pause Pending ("Pause Pending")
125 /// - Paused ("Paused")
126 /// - Unknown ("Unknown")
127 pub State: Option<String>,
128 /// Current status of the object. Various operational and nonoperational statuses can be
129 /// defined. Operational statuses include: "OK", "Degraded", and "Pred Fail" (an element, such
130 /// as a SMART-enabled hard disk drive, may be functioning properly but predicting a failure in
131 /// the near future). Nonoperational statuses include: "Error", "Starting", "Stopping", and
132 /// "Service". The latter, "Service", could apply during mirror-resilvering of a disk, reload of
133 /// a user permissions list, or other administrative work. Not all such work is online, yet the
134 /// managed element is neither "OK" nor in one of the other states.
135 ///
136 /// The values are:
137 ///
138 /// - OK ("OK")
139 /// - Error ("Error")
140 /// - Degraded ("Degraded")
141 /// - Unknown ("Unknown")
142 /// - Pred Fail ("Pred Fail")
143 /// - Starting ("Starting")
144 /// - Stopping ("Stopping")
145 /// - Service ("Service")
146 /// - Stressed ("Stressed")
147 /// - NonRecover ("NonRecover")
148 /// - No Contact ("No Contact")
149 /// - Lost Comm ("Lost Comm")
150 pub Status: Option<String>,
151 /// Type name of the system that hosts this service.
152 pub SystemCreationClassName: Option<String>,
153 /// Name of the system that hosts this service.
154 pub SystemName: Option<String>,
155 /// Unique tag value for this service in the group. A value of 0 (zero) indicates that the
156 /// service has not been assigned a tag. A tag can be used for ordering service startup within
157 /// a load order group by specifying a tag order vector in the registry located at:
158 ///
159 /// `HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\GroupOrderList.`
160 ///
161 /// Tags are only evaluated for Kernel Driver and File System Driver start-type services that
162 /// have Boot or System start modes.
163 pub TagId: Option<u32>,
164}