windows_snapshot/
state.rs

1//! Stores the main state of Windows machine
2
3use crate::operating_system::{
4    desktop, drivers, file_system, processes, registry, services, users, event_log, memory_and_pagefiles, scheduler_jobs, product_activation, software_license_provider, shares, multimedia_audio_visual, storage
5};
6use serde::{Deserialize, Serialize};
7use tokio::join;
8
9/// Our main struct
10///
11/// Holds the state/snapshot of Windows
12#[derive(Default, Deserialize, Serialize, Debug, Clone)]
13pub struct Windows {
14    /// State of Windows Processes
15    pub processes: processes::Processes,
16    /// State of Windows Threads
17    pub threads: processes::Threads,
18    /// State of Windows Drivers
19    pub drivers: drivers::Drivers,
20    /// State of Windows Registry
21    pub registry: registry::Registry,
22    /// State of Windows Services
23    pub services: services::Services,
24    /// State of Windows Desktops
25    pub desktops: desktop::Desktops,
26    /// State of Windows Environments
27    pub environment: desktop::Environments,
28    /// State of Windows TimeZones
29    pub timezones: desktop::TimeZones,
30    /// State of Windows User Accounts
31    pub user_accounts: users::UserAccounts,
32    /* This fails for now as a string is returned on object
33    /// Relation of user account and desktop settings that are specific to it
34    pub user_desktops: desktop::UserDesktops,
35    */
36    /* Abstract class, don't need it
37    /// State of Windows user accounts and group accounts
38    pub accounts: users::Accounts,
39    */
40    /// State of Windows Groups
41    pub groups: users::Groups,
42    /// State of Windows Logon Sessions
43    pub logon_sessions: users::LogonSessions,
44    /// State of Windows Network Logins
45    pub network_login_profiles: users::NetworkLoginProfiles,
46    /// State of Windows System Accounts
47    pub system_accounts: users::SystemAccounts,
48    /// State of windows Directory
49    pub directories: file_system::Directories,
50    /// State of windows Directory Specifications
51    pub directories_specifications: file_system::DirectorySpecifications,
52    /// State of windows Directory Disk Partitions
53    pub disk_partition: file_system::DiskPartitions,
54    /// State of windows Logical Disks
55    pub logical_disks: file_system::LogicalDisks,
56    /// State of windows Mapped Logical Disks
57    pub mapped_logical_disks: file_system::MappedLogicalDisks,
58    /// State of windows Quota Settings
59    pub quota_settings: file_system::QuotaSettings,
60    /// State of windows Shortcut Files
61    pub shortcut_files: file_system::ShortcutFiles,
62    /// State of windows Volumes
63    pub volumes: file_system::Volumes,
64    /// State of windows NTEventLogFiles
65    pub nt_event_log_files: event_log::NTEventlogFiles,
66    /// State of windows NTLogEvents
67    pub nt_log_events: event_log::NTLogEvents,
68    /// State of windows PageFiles
69    pub pagefiles: memory_and_pagefiles::PageFiles,
70    /// State of windows PageFileSettings
71    pub pagefile_settings: memory_and_pagefiles::PageFileSettings,
72    /// State of windows PageFileUsages
73    pub pagefile_usages: memory_and_pagefiles::PageFileUsages,
74    /// State of windows ScheduledJobs
75    pub scheduled_jobs: scheduler_jobs::ScheduledJobs,
76    /// State of windows LocalTimes
77    pub local_times: scheduler_jobs::LocalTimes,
78    /// State of windows UTCTimes
79    pub utc_times: scheduler_jobs::UTCTimes,
80    /// State of windows Proxys
81    pub proxys: product_activation::Proxys,
82    /// State of windows WindowsProductActivations
83    pub windows_product_activations: product_activation::WindowsProductActivations,
84    /// State of windows SoftwareLicensingProducts
85    pub software_licensing_products: software_license_provider::SoftwareLicensingProducts,
86    /// State of windows SoftwareLicensingServices
87    pub software_licensing_services: software_license_provider::SoftwareLicensingServices,
88    /// State of windows SoftwareLicensingTokenActivationLicenses
89    pub software_licensing_token_activation_licenses: software_license_provider::SoftwareLicensingTokenActivationLicenses,
90    /// State of windows ServerConnections
91    pub server_connections: shares::ServerConnections,
92    /// State of windows ServerSessions
93    pub server_sessions: shares::ServerSessions,
94    /// State of windows Shares
95    pub shares: shares::Shares,
96    /// State of Windows CodecFiles
97    pub codec_files: multimedia_audio_visual::CodecFiles,
98    /// State of Windows ShadowCopys
99    pub shadow_copys: storage::ShadowCopys,
100    /// State of Windows ShadowContexts
101    pub shadow_contexts: storage::ShadowContexts,
102    /// State of Windows ShadowProviders
103    pub shadow_providers: storage::ShadowProviders,
104}
105
106impl Windows {
107    /// Synchronously update all the fields
108    pub fn update(&mut self) {
109        self.processes.update();
110        self.threads.update();
111        self.drivers.update();
112        self.registry.update();
113        self.services.update();
114        self.desktops.update();
115        self.environment.update();
116        self.timezones.update();
117        self.user_accounts.update();
118        // self.user_desktops.update();
119        // self.accounts.update();
120        self.groups.update();
121        self.logon_sessions.update();
122        self.network_login_profiles.update();
123        self.system_accounts.update();
124        self.directories.update();
125        self.directories_specifications.update();
126        self.disk_partition.update();
127        self.logical_disks.update();
128        self.mapped_logical_disks.update();
129        self.quota_settings.update();
130        self.shortcut_files.update();
131        self.volumes.update();
132        self.nt_event_log_files.update();
133        self.nt_log_events.update();
134        self.pagefiles.update();
135        self.pagefile_settings.update();
136        self.pagefile_usages.update();
137        self.scheduled_jobs.update();
138        self.local_times.update();
139        self.utc_times.update();
140        self.software_licensing_products.update();
141        self.software_licensing_services.update();
142        self.software_licensing_token_activation_licenses.update();
143        self.server_connections.update();
144        self.server_sessions.update();
145        self.shares.update();
146        self.codec_files.update();
147        self.shadow_copys.update();
148        self.shadow_contexts.update();
149        self.shadow_providers.update();
150    }
151
152    /// Asynchronously update all the fields
153    pub async fn async_update(&mut self) {
154        join!(
155            self.threads.async_update(),
156            self.processes.async_update(),
157            self.drivers.async_update(),
158            self.registry.async_update(),
159            self.services.async_update(),
160            self.desktops.async_update(),
161            self.environment.async_update(),
162            self.timezones.async_update(),
163            self.user_accounts.async_update(),
164            // self.user_desktops.async_update(),
165            // self.accounts.async_update(),
166            self.groups.async_update(),
167            self.logon_sessions.async_update(),
168            self.network_login_profiles.async_update(),
169            self.system_accounts.async_update(),
170            self.directories.async_update(),
171            self.directories_specifications.async_update(),
172            self.disk_partition.async_update(),
173            self.logical_disks.async_update(),
174            self.mapped_logical_disks.async_update(),
175            self.quota_settings.async_update(),
176            self.shortcut_files.async_update(),
177            self.volumes.async_update(),
178            self.nt_event_log_files.async_update(),
179            self.nt_log_events.async_update(),
180            self.pagefiles.async_update(),
181            self.pagefile_settings.async_update(),
182            self.pagefile_usages.async_update(),
183            self.scheduled_jobs.async_update(),
184            self.local_times.async_update(),
185            self.utc_times.async_update(),
186            self.software_licensing_products.async_update(),
187            self.software_licensing_services.async_update(),
188            self.software_licensing_token_activation_licenses.async_update(),
189            self.server_connections.async_update(),
190            self.server_sessions.async_update(),
191            self.shares.async_update(),
192            self.codec_files.async_update(),
193            self.shadow_copys.async_update(),
194            self.shadow_contexts.async_update(),
195            self.shadow_providers.async_update(),
196        );
197    }
198}