Skip to content

Commit

Permalink
[chore] add checks and args whitelist for launching BS as admin
Browse files Browse the repository at this point in the history
  • Loading branch information
Zagrios committed Jan 25, 2024
1 parent 263061e commit 4fc5a87
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 3 deletions.
Binary file modified assets/scripts/start_beat_saber_admin.exe
Binary file not shown.
36 changes: 33 additions & 3 deletions externals/bs-admin-start/src/main.rs
@@ -1,13 +1,43 @@

use std::{process::Command, path::Path};

const EXECUTABLE_NAME: &str = "Beat Saber.exe";
const AUTORIZED_ARGS: [&str; 8] = [
"fpfc",
"-vrmode",
"oculus",
"--verbose",
"--no-yeet",
"--disable-autoupdate",
"--combine-logs",
"editor"
];

fn main() {
let args: Vec<String> = std::env::args().collect();

let mut command = Command::new(args.get(1).unwrap());
command.current_dir(Path::new(args.get(1).unwrap()).parent().unwrap());
let executable_path = Path::new(&args[1]);

if executable_path.file_name().unwrap() != EXECUTABLE_NAME {
eprintln!("Executable path is not Beat Saber.exe.");
return;
}

if !executable_path.exists() || !executable_path.is_file() {
eprintln!("Executable path is not valid.");
return;
}

let mut command = Command::new(executable_path);

if let Some(parent_dir) = executable_path.parent() {
command.current_dir(parent_dir);
}

for arg in args.iter().skip(1) {
for arg in args.iter().skip(2) {
if !AUTORIZED_ARGS.contains(&arg.as_str()) {
continue;
}
command.arg(arg);
}

Expand Down

0 comments on commit 4fc5a87

Please sign in to comment.