adapt codebase to own, new system info impl
This commit is contained in:
Generated
+5
-91
@@ -837,8 +837,7 @@ dependencies = [
|
|||||||
"serde_json",
|
"serde_json",
|
||||||
"static_vcruntime",
|
"static_vcruntime",
|
||||||
"strum",
|
"strum",
|
||||||
"sysinfo",
|
"windows",
|
||||||
"windows 0.62.0",
|
|
||||||
"winreg",
|
"winreg",
|
||||||
"winresource",
|
"winresource",
|
||||||
]
|
]
|
||||||
@@ -1263,15 +1262,6 @@ version = "0.2.0"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "2bf50223579dc7cdcfb3bfcacf7069ff68243f8c363f62ffa99cf000a6b9c451"
|
checksum = "2bf50223579dc7cdcfb3bfcacf7069ff68243f8c363f62ffa99cf000a6b9c451"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "ntapi"
|
|
||||||
version = "0.4.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "e8a3895c6391c39d7fe7ebc444a87eb2991b2a0bc718fdabd071eec617fc68e4"
|
|
||||||
dependencies = [
|
|
||||||
"winapi",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "num-traits"
|
name = "num-traits"
|
||||||
version = "0.2.19"
|
version = "0.2.19"
|
||||||
@@ -1471,16 +1461,6 @@ dependencies = [
|
|||||||
"objc2-core-foundation",
|
"objc2-core-foundation",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "objc2-io-kit"
|
|
||||||
version = "0.3.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "71c1c64d6120e51cd86033f67176b1cb66780c2efe34dec55176f77befd93c0a"
|
|
||||||
dependencies = [
|
|
||||||
"libc",
|
|
||||||
"objc2-core-foundation",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "objc2-io-surface"
|
name = "objc2-io-surface"
|
||||||
version = "0.3.1"
|
version = "0.3.1"
|
||||||
@@ -2130,20 +2110,6 @@ dependencies = [
|
|||||||
"syn",
|
"syn",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "sysinfo"
|
|
||||||
version = "0.37.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "07cec4dc2d2e357ca1e610cfb07de2fa7a10fc3e9fe89f72545f3d244ea87753"
|
|
||||||
dependencies = [
|
|
||||||
"libc",
|
|
||||||
"memchr",
|
|
||||||
"ntapi",
|
|
||||||
"objc2-core-foundation",
|
|
||||||
"objc2-io-kit",
|
|
||||||
"windows 0.61.3",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "thiserror"
|
name = "thiserror"
|
||||||
version = "1.0.69"
|
version = "1.0.69"
|
||||||
@@ -2595,39 +2561,17 @@ version = "0.4.0"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
|
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "windows"
|
|
||||||
version = "0.61.3"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "9babd3a767a4c1aef6900409f85f5d53ce2544ccdfaa86dad48c91782c6d6893"
|
|
||||||
dependencies = [
|
|
||||||
"windows-collections 0.2.0",
|
|
||||||
"windows-core 0.61.2",
|
|
||||||
"windows-future 0.2.1",
|
|
||||||
"windows-link 0.1.3",
|
|
||||||
"windows-numerics 0.2.0",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "windows"
|
name = "windows"
|
||||||
version = "0.62.0"
|
version = "0.62.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "9579d0e6970fd5250aa29aba5994052385ff55cf7b28a059e484bb79ea842e42"
|
checksum = "9579d0e6970fd5250aa29aba5994052385ff55cf7b28a059e484bb79ea842e42"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"windows-collections 0.3.0",
|
"windows-collections",
|
||||||
"windows-core 0.62.0",
|
"windows-core 0.62.0",
|
||||||
"windows-future 0.3.0",
|
"windows-future",
|
||||||
"windows-link 0.2.0",
|
"windows-link 0.2.0",
|
||||||
"windows-numerics 0.3.0",
|
"windows-numerics",
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "windows-collections"
|
|
||||||
version = "0.2.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "3beeceb5e5cfd9eb1d76b381630e82c4241ccd0d27f1a39ed41b2760b255c5e8"
|
|
||||||
dependencies = [
|
|
||||||
"windows-core 0.61.2",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -2665,17 +2609,6 @@ dependencies = [
|
|||||||
"windows-strings 0.5.0",
|
"windows-strings 0.5.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "windows-future"
|
|
||||||
version = "0.2.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "fc6a41e98427b19fe4b73c550f060b59fa592d7d686537eebf9385621bfbad8e"
|
|
||||||
dependencies = [
|
|
||||||
"windows-core 0.61.2",
|
|
||||||
"windows-link 0.1.3",
|
|
||||||
"windows-threading 0.1.0",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "windows-future"
|
name = "windows-future"
|
||||||
version = "0.3.0"
|
version = "0.3.0"
|
||||||
@@ -2684,7 +2617,7 @@ checksum = "b2194dee901458cb79e1148a4e9aac2b164cc95fa431891e7b296ff0b2f1d8a6"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"windows-core 0.62.0",
|
"windows-core 0.62.0",
|
||||||
"windows-link 0.2.0",
|
"windows-link 0.2.0",
|
||||||
"windows-threading 0.2.0",
|
"windows-threading",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -2721,16 +2654,6 @@ version = "0.2.0"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "45e46c0661abb7180e7b9c281db115305d49ca1709ab8242adf09666d2173c65"
|
checksum = "45e46c0661abb7180e7b9c281db115305d49ca1709ab8242adf09666d2173c65"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "windows-numerics"
|
|
||||||
version = "0.2.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "9150af68066c4c5c07ddc0ce30421554771e528bde427614c61038bc2c92c2b1"
|
|
||||||
dependencies = [
|
|
||||||
"windows-core 0.61.2",
|
|
||||||
"windows-link 0.1.3",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "windows-numerics"
|
name = "windows-numerics"
|
||||||
version = "0.3.0"
|
version = "0.3.0"
|
||||||
@@ -2861,15 +2784,6 @@ dependencies = [
|
|||||||
"windows_x86_64_msvc 0.53.0",
|
"windows_x86_64_msvc 0.53.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "windows-threading"
|
|
||||||
version = "0.1.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "b66463ad2e0ea3bbf808b7f1d371311c80e115c0b71d60efc142cafbcfb057a6"
|
|
||||||
dependencies = [
|
|
||||||
"windows-link 0.1.3",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "windows-threading"
|
name = "windows-threading"
|
||||||
version = "0.2.0"
|
version = "0.2.0"
|
||||||
|
|||||||
@@ -21,7 +21,6 @@ open = "5.3.2"
|
|||||||
serde = { version = "1.0.219", features = ["derive"] }
|
serde = { version = "1.0.219", features = ["derive"] }
|
||||||
serde_json = "1.0.143"
|
serde_json = "1.0.143"
|
||||||
strum = { version = "0.27.2", features = ["derive"] }
|
strum = { version = "0.27.2", features = ["derive"] }
|
||||||
sysinfo = "0.37.0"
|
|
||||||
windows = { version = "0.62.0", features = [
|
windows = { version = "0.62.0", features = [
|
||||||
"Win32_NetworkManagement_WindowsFirewall",
|
"Win32_NetworkManagement_WindowsFirewall",
|
||||||
"Win32_Security",
|
"Win32_Security",
|
||||||
|
|||||||
@@ -2,9 +2,9 @@ use crate::util::{
|
|||||||
consts::game::{EXE_ENHANCED, EXE_LEGACY},
|
consts::game::{EXE_ENHANCED, EXE_LEGACY},
|
||||||
countdown::Countdown,
|
countdown::Countdown,
|
||||||
log,
|
log,
|
||||||
|
system_info::SystemInfo,
|
||||||
};
|
};
|
||||||
use std::time::{Duration, Instant};
|
use std::time::{Duration, Instant};
|
||||||
use sysinfo::System;
|
|
||||||
use windows::Win32::{
|
use windows::Win32::{
|
||||||
Foundation::{CloseHandle, HANDLE, NTSTATUS},
|
Foundation::{CloseHandle, HANDLE, NTSTATUS},
|
||||||
System::Threading::{OpenProcess, PROCESS_SUSPEND_RESUME},
|
System::Threading::{OpenProcess, PROCESS_SUSPEND_RESUME},
|
||||||
@@ -49,21 +49,21 @@ unsafe extern "system" {
|
|||||||
unsafe fn NtResumeProcess(ProcessHandle: HANDLE) -> NTSTATUS;
|
unsafe fn NtResumeProcess(ProcessHandle: HANDLE) -> NTSTATUS;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_gta_pid(sysinfo: &mut System) -> Option<u32> {
|
fn get_gta_pid(system_info: &mut SystemInfo) -> Option<u32> {
|
||||||
sysinfo.refresh_all();
|
system_info.refresh();
|
||||||
if let Some((pid, _)) = sysinfo
|
if let Some(p) = system_info
|
||||||
.processes()
|
.processes()
|
||||||
.iter()
|
.iter()
|
||||||
.find(|(_, p)| p.name() == EXE_ENHANCED || p.name() == EXE_LEGACY)
|
.find(|p| p.name() == EXE_ENHANCED || p.name() == EXE_LEGACY)
|
||||||
{
|
{
|
||||||
return Some(pid.as_u32());
|
return Some(p.pid());
|
||||||
} else {
|
} else {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn activate(game_handle: &mut HANDLE, sysinfo: &mut System) -> Result<(), ()> {
|
pub fn activate(game_handle: &mut HANDLE, system_info: &mut SystemInfo) -> Result<(), ()> {
|
||||||
let Some(pid) = get_gta_pid(sysinfo) else {
|
let Some(pid) = get_gta_pid(system_info) else {
|
||||||
return Err(());
|
return Err(());
|
||||||
};
|
};
|
||||||
unsafe {
|
unsafe {
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
use crate::util::{
|
use crate::util::{
|
||||||
consts::game::{EXE_ENHANCED, EXE_LEGACY},
|
consts::game::{EXE_ENHANCED, EXE_LEGACY},
|
||||||
log,
|
log,
|
||||||
|
system_info::SystemInfo,
|
||||||
};
|
};
|
||||||
use std::time::{Duration, Instant};
|
use std::time::{Duration, Instant};
|
||||||
use sysinfo::System;
|
|
||||||
|
|
||||||
const INTERVAL: Duration = Duration::from_secs(3);
|
const INTERVAL: Duration = Duration::from_secs(3);
|
||||||
|
|
||||||
@@ -27,7 +27,7 @@ impl Default for ForceClose {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl ForceClose {
|
impl ForceClose {
|
||||||
pub fn prompt(&mut self, force_close_button_clicked: bool, sysinfo: &mut System) {
|
pub fn prompt(&mut self, force_close_button_clicked: bool, system_info: &mut SystemInfo) {
|
||||||
if force_close_button_clicked && !self.counting {
|
if force_close_button_clicked && !self.counting {
|
||||||
self.button_text = "Are you sure?".to_owned();
|
self.button_text = "Are you sure?".to_owned();
|
||||||
self.timer = Instant::now();
|
self.timer = Instant::now();
|
||||||
@@ -37,7 +37,7 @@ impl ForceClose {
|
|||||||
if self.counting && self.timer.elapsed() >= INTERVAL {
|
if self.counting && self.timer.elapsed() >= INTERVAL {
|
||||||
self.reset();
|
self.reset();
|
||||||
} else if force_close_button_clicked && !self.current_frame {
|
} else if force_close_button_clicked && !self.current_frame {
|
||||||
activate(sysinfo);
|
activate(system_info);
|
||||||
self.reset();
|
self.reset();
|
||||||
}
|
}
|
||||||
self.finish_current_frame();
|
self.finish_current_frame();
|
||||||
@@ -54,13 +54,13 @@ impl ForceClose {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn activate(sysinfo: &mut System) {
|
fn activate(system_info: &mut SystemInfo) {
|
||||||
sysinfo.refresh_all();
|
system_info.refresh();
|
||||||
sysinfo
|
system_info
|
||||||
.processes()
|
.processes()
|
||||||
.iter()
|
.iter()
|
||||||
.filter(|(_, p)| p.name() == EXE_ENHANCED || p.name() == EXE_LEGACY)
|
.filter(|p| p.name() == EXE_ENHANCED || p.name() == EXE_LEGACY)
|
||||||
.for_each(|(_, p)| {
|
.for_each(|p| {
|
||||||
if p.kill() == false {
|
if p.kill() == false {
|
||||||
log::log(
|
log::log(
|
||||||
log::LogLevel::Error,
|
log::LogLevel::Error,
|
||||||
@@ -68,5 +68,5 @@ fn activate(sysinfo: &mut System) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
sysinfo.refresh_all();
|
system_info.refresh();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,12 @@
|
|||||||
use crate::util::consts::game::{EXE_ENHANCED, EXE_LEGACY};
|
use crate::util::{
|
||||||
|
consts::game::{EXE_ENHANCED, EXE_LEGACY},
|
||||||
|
system_info::SystemInfo,
|
||||||
|
};
|
||||||
use std::{
|
use std::{
|
||||||
path::Path,
|
path::Path,
|
||||||
time::{Duration, Instant},
|
time::{Duration, Instant},
|
||||||
};
|
};
|
||||||
use strum::{Display, EnumIter};
|
use strum::{Display, EnumIter};
|
||||||
use sysinfo::System;
|
|
||||||
use windows::{
|
use windows::{
|
||||||
Win32::{
|
Win32::{
|
||||||
NetworkManagement::WindowsFirewall::{
|
NetworkManagement::WindowsFirewall::{
|
||||||
@@ -71,8 +73,8 @@ impl Drop for GameNetworking {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl GameNetworking {
|
impl GameNetworking {
|
||||||
pub fn block_all(&mut self, sysinfo: &mut System) {
|
pub fn block_all(&mut self, system_info: &mut SystemInfo) {
|
||||||
let Some(exe_path) = get_game_exe_path(sysinfo) else {
|
let Some(exe_path) = get_game_exe_path(system_info) else {
|
||||||
self.blocked_status = BlockedStatus::Failed;
|
self.blocked_status = BlockedStatus::Failed;
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
@@ -133,12 +135,12 @@ impl GameNetworking {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_game_exe_path(sysinfo: &mut System) -> Option<&Path> {
|
fn get_game_exe_path(system_info: &mut SystemInfo) -> Option<&Path> {
|
||||||
sysinfo.refresh_all();
|
system_info.refresh();
|
||||||
if let Some((_, process)) = sysinfo
|
if let Some(process) = system_info
|
||||||
.processes()
|
.processes()
|
||||||
.iter()
|
.iter()
|
||||||
.find(|(_, p)| p.name() == EXE_ENHANCED || p.name() == EXE_LEGACY)
|
.find(|p| p.name() == EXE_ENHANCED || p.name() == EXE_LEGACY)
|
||||||
{
|
{
|
||||||
process.exe()
|
process.exe()
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
+10
-5
@@ -1,7 +1,9 @@
|
|||||||
use crate::{
|
use crate::{
|
||||||
features,
|
features,
|
||||||
gui::{colours, settings::Settings, tools, ui_ext::UiExt},
|
gui::{colours, settings::Settings, tools, ui_ext::UiExt},
|
||||||
util::{consts::game::WINDOW_TITLE, persistent_state::PersistentState, win},
|
util::{
|
||||||
|
consts::game::WINDOW_TITLE, persistent_state::PersistentState, system_info::SystemInfo, win,
|
||||||
|
},
|
||||||
};
|
};
|
||||||
use eframe::egui;
|
use eframe::egui;
|
||||||
use std::time::{Duration, Instant};
|
use std::time::{Duration, Instant};
|
||||||
@@ -39,7 +41,7 @@ pub struct App {
|
|||||||
pub settings: Settings,
|
pub settings: Settings,
|
||||||
stage: Stage,
|
stage: Stage,
|
||||||
pub flags: Flags,
|
pub flags: Flags,
|
||||||
pub sysinfo: sysinfo::System,
|
pub system_info: SystemInfo,
|
||||||
game_handle: windows::Win32::Foundation::HANDLE,
|
game_handle: windows::Win32::Foundation::HANDLE,
|
||||||
pub anti_afk: features::anti_afk::AntiAfk,
|
pub anti_afk: features::anti_afk::AntiAfk,
|
||||||
empty_session: features::empty_session::EmptySession,
|
empty_session: features::empty_session::EmptySession,
|
||||||
@@ -108,7 +110,7 @@ impl App {
|
|||||||
egui::Button::new(&self.force_close.button_text),
|
egui::Button::new(&self.force_close.button_text),
|
||||||
);
|
);
|
||||||
self.force_close
|
self.force_close
|
||||||
.prompt(force_close_button.clicked(), &mut self.sysinfo);
|
.prompt(force_close_button.clicked(), &mut self.system_info);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn show_session_section(&mut self, _ctx: &egui::Context, ui: &mut egui::Ui) {
|
fn show_session_section(&mut self, _ctx: &egui::Context, ui: &mut egui::Ui) {
|
||||||
@@ -116,7 +118,10 @@ impl App {
|
|||||||
ui.add_enabled_ui(!self.empty_session.disabled, |ui| {
|
ui.add_enabled_ui(!self.empty_session.disabled, |ui| {
|
||||||
ui.horizontal(|ui| {
|
ui.horizontal(|ui| {
|
||||||
if ui.button("Empty current session").clicked() {
|
if ui.button("Empty current session").clicked() {
|
||||||
if features::empty_session::activate(&mut self.game_handle, &mut self.sysinfo)
|
if features::empty_session::activate(
|
||||||
|
&mut self.game_handle,
|
||||||
|
&mut self.system_info,
|
||||||
|
)
|
||||||
.is_ok()
|
.is_ok()
|
||||||
{
|
{
|
||||||
self.empty_session.interval = Instant::now();
|
self.empty_session.interval = Instant::now();
|
||||||
@@ -169,7 +174,7 @@ impl App {
|
|||||||
.add_sized([button_width, 18.0], egui::Button::new("Block"))
|
.add_sized([button_width, 18.0], egui::Button::new("Block"))
|
||||||
.clicked()
|
.clicked()
|
||||||
{
|
{
|
||||||
self.game_networking.block_all(&mut self.sysinfo);
|
self.game_networking.block_all(&mut self.system_info);
|
||||||
}
|
}
|
||||||
if ui
|
if ui
|
||||||
.add_sized([button_width, 18.0], egui::Button::new("Unblock"))
|
.add_sized([button_width, 18.0], egui::Button::new("Unblock"))
|
||||||
|
|||||||
+6
-9
@@ -48,19 +48,16 @@ impl App {
|
|||||||
));
|
));
|
||||||
ui.label(format!("can activate: {}", self.anti_afk.can_activate()));
|
ui.label(format!("can activate: {}", self.anti_afk.can_activate()));
|
||||||
});
|
});
|
||||||
ui.collapsing("sysinfo", |ui| {
|
ui.collapsing("system info", |ui| {
|
||||||
if ui.button("refresh all").clicked() {
|
if ui.button("refresh").clicked() {
|
||||||
self.sysinfo.refresh_all();
|
self.system_info.refresh();
|
||||||
}
|
}
|
||||||
let pid = self
|
let pid = self
|
||||||
.sysinfo
|
.system_info
|
||||||
.processes()
|
.processes()
|
||||||
.iter()
|
.iter()
|
||||||
.find(|(_, p)| p.name() == EXE_ENHANCED || p.name() == EXE_LEGACY)
|
.find(|p| p.name() == EXE_ENHANCED || p.name() == EXE_LEGACY)
|
||||||
.map_or_else(
|
.map_or_else(|| "no pid found!".to_owned(), |p| p.pid().to_string());
|
||||||
|| "no pid found!".to_owned(),
|
|
||||||
|(pid, _)| pid.as_u32().to_string(),
|
|
||||||
);
|
|
||||||
ui.label(format!("gta pid: {pid}"));
|
ui.label(format!("gta pid: {pid}"));
|
||||||
});
|
});
|
||||||
ui.collapsing("app state", |ui| ui.label(format!("{self:#?}")));
|
ui.collapsing("app state", |ui| ui.label(format!("{self:#?}")));
|
||||||
|
|||||||
+2
-2
@@ -21,8 +21,8 @@ fn app_creator(
|
|||||||
if !app.flags.elevated && app.settings.start_elevated {
|
if !app.flags.elevated && app.settings.start_elevated {
|
||||||
win::elevate(win::ElevationExitMethod::Forced);
|
win::elevate(win::ElevationExitMethod::Forced);
|
||||||
}
|
}
|
||||||
// refresh sysinfo because it initializes with nothing
|
// refresh system info because it initializes with nothing
|
||||||
app.sysinfo.refresh_all();
|
app.system_info.refresh();
|
||||||
// enable image loading support in egui
|
// enable image loading support in egui
|
||||||
egui_extras::install_image_loaders(&cc.egui_ctx);
|
egui_extras::install_image_loaders(&cc.egui_ctx);
|
||||||
// set our initial theme, from earlier loaded settings. we set the egui theme
|
// set our initial theme, from earlier loaded settings. we set the egui theme
|
||||||
|
|||||||
+9
-15
@@ -18,26 +18,26 @@ use windows::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
struct Process {
|
pub struct Process {
|
||||||
pid: u32,
|
pid: u32,
|
||||||
name: String,
|
name: String,
|
||||||
exe: Option<PathBuf>,
|
exe: Option<PathBuf>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Process {
|
impl Process {
|
||||||
fn pid(&self) -> u32 {
|
pub fn pid(&self) -> u32 {
|
||||||
self.pid
|
self.pid
|
||||||
}
|
}
|
||||||
|
|
||||||
fn name(&self) -> &str {
|
pub fn name(&self) -> &str {
|
||||||
&self.name
|
&self.name
|
||||||
}
|
}
|
||||||
|
|
||||||
fn exe(&self) -> Option<&Path> {
|
pub fn exe(&self) -> Option<&Path> {
|
||||||
self.exe.as_deref()
|
self.exe.as_deref()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn kill(&self) -> bool {
|
pub fn kill(&self) -> bool {
|
||||||
let mut taskkill = Command::new("taskkill.exe");
|
let mut taskkill = Command::new("taskkill.exe");
|
||||||
taskkill.creation_flags(CREATE_NO_WINDOW.0);
|
taskkill.creation_flags(CREATE_NO_WINDOW.0);
|
||||||
taskkill.arg("/F").arg("/PID").arg(&self.pid.to_string());
|
taskkill.arg("/F").arg("/PID").arg(&self.pid.to_string());
|
||||||
@@ -48,20 +48,14 @@ impl Process {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug, Default)]
|
||||||
struct SystemInfo {
|
pub struct SystemInfo {
|
||||||
processes: Vec<Process>,
|
processes: Vec<Process>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl SystemInfo {
|
impl SystemInfo {
|
||||||
fn new() -> Self {
|
|
||||||
Self {
|
|
||||||
processes: Vec::new(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: unfuck this retarded function
|
// TODO: unfuck this retarded function
|
||||||
fn refresh(&mut self) {
|
pub fn refresh(&mut self) {
|
||||||
let mut processes = Vec::new();
|
let mut processes = Vec::new();
|
||||||
let snapshot_handle = unsafe { CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0).unwrap() };
|
let snapshot_handle = unsafe { CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0).unwrap() };
|
||||||
let mut process_entry = PROCESSENTRY32::default();
|
let mut process_entry = PROCESSENTRY32::default();
|
||||||
@@ -136,7 +130,7 @@ impl SystemInfo {
|
|||||||
self.processes = processes;
|
self.processes = processes;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn processes(&self) -> &[Process] {
|
pub fn processes(&self) -> &[Process] {
|
||||||
&self.processes
|
&self.processes
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user