some little fixes

This commit is contained in:
2025-04-07 16:02:32 +01:00
parent 68cf28dad8
commit c73dc4bd86
4 changed files with 34 additions and 29 deletions
+1 -1
View File
@@ -6,7 +6,7 @@ use windows::Win32::{
System::Threading::{OpenProcess, PROCESS_SUSPEND_RESUME},
};
pub const INTERVAL: Duration = Duration::from_secs(10);
pub const INTERVAL: Duration = Duration::from_secs(8);
const ENHANCED: &str = "GTA5_Enhanced.exe";
const LEGACY: &str = "GTA5.exe";
+7 -11
View File
@@ -1,8 +1,11 @@
#![allow(clippy::zombie_processes)]
use crate::util::consts::{ENHANCED, LEGACY};
use std::{path::Path, process::Command};
use std::{os::windows::process::CommandExt, path::Path, process::Command};
use sysinfo::System;
const FILTER_NAME: &str = "[GTA Tools] Block all traffic for GTA V";
const CREATE_NO_WINDOW: u32 = 0x0800_0000;
fn get_game_exe_path(sysinfo: &mut System) -> Option<&Path> {
sysinfo.refresh_all();
@@ -34,6 +37,7 @@ pub fn block_all(sysinfo: &mut System) {
"protocol=ANY",
&format!("program={exe_path}"),
])
.creation_flags(CREATE_NO_WINDOW)
.spawn()
.unwrap();
Command::new("netsh")
@@ -48,6 +52,7 @@ pub fn block_all(sysinfo: &mut System) {
"protocol=ANY",
&format!("program={exe_path}"),
])
.creation_flags(CREATE_NO_WINDOW)
.spawn()
.unwrap();
}
@@ -61,16 +66,7 @@ pub fn unblock_all() {
"rule",
&format!("name={FILTER_NAME}"),
])
.spawn()
.unwrap();
Command::new("netsh")
.args([
"advfirewall",
"firewall",
"delete",
"rule",
&format!("name={FILTER_NAME}"),
])
.creation_flags(CREATE_NO_WINDOW)
.spawn()
.unwrap();
}