Skip to content

Commit 1b77583

Browse files
committed
enhance: check os version on startup
1 parent 006fa13 commit 1b77583

File tree

3 files changed

+28
-1
lines changed

3 files changed

+28
-1
lines changed

Cargo.lock

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ windows = { version = "0.61", features = [
2323
# enable SeDebugPrivilege for SYSTEM processes
2424
"Win32_Security",
2525
] }
26+
windows-version = "0.1.4"
2627

2728
[build-dependencies]
2829
windows_exe_info = "0.5.2"

src/main.rs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use std::ffi::OsString;
33

44
use ahash::AHashSet;
55
use rustystar::privilege::try_enable_se_debug_privilege;
6-
use spdlog::{Level, LevelFilter, debug, info, warn};
6+
use spdlog::{Level, LevelFilter, debug, error, info, warn};
77
use win32_ecoqos::process::toggle_efficiency_mode;
88

99
use rustystar::bypass::should_bypass;
@@ -22,6 +22,21 @@ async fn main() -> Result<(), Box<dyn Error + Send + Sync>> {
2222
},
2323
));
2424

25+
let os_version = windows_version::OsVersion::current().build;
26+
match () {
27+
_ if os_version < 21359 => {
28+
error!("EcoQoS is not supported on your system, found {os_version} < 21359");
29+
return Ok(());
30+
}
31+
_ if os_version < 22621 => {
32+
warn!("EcoQoS needs Windows 11 22H2 or newer to be most effective");
33+
}
34+
_ => {
35+
info!("Congratulations! Your system will make best result");
36+
}
37+
}
38+
39+
info!("initializing whitelist...");
2540
let _ = WHITELIST.set(AHashSet::from_iter(
2641
[
2742
// ourself
@@ -66,6 +81,7 @@ async fn main() -> Result<(), Box<dyn Error + Send + Sync>> {
6681
.map(OsString::from),
6782
));
6883

84+
info!("registering Ctrl-C handler...");
6985
ctrlc::set_handler(|| {
7086
info!("received ctrl-c, recovering...");
7187
_ = toggle_all(None);

0 commit comments

Comments
 (0)