Skip to content

Commit

Permalink
Merge pull request #404 from Zagrios/bugfix/bs-crash-when-steam-run-a…
Browse files Browse the repository at this point in the history
…s-admin

[bugfix] Start BS as Admin when Steam is running as admin but BSM is not
  • Loading branch information
Zagrios authored Jan 20, 2024
2 parents 444db56 + 4c8617a commit d2c1d81
Show file tree
Hide file tree
Showing 15 changed files with 725 additions and 21 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,6 @@ npm-debug.log.*
*.css.d.ts
*.sass.d.ts
*.scss.d.ts

# externals
externals/bs-admin-start/target/*
Binary file added assets/scripts/start_beat_saber_admin.exe
Binary file not shown.
2 changes: 2 additions & 0 deletions externals/bs-admin-start/.cargo/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[target.x86_64-pc-windows-msvc]
rustflags = ["-C", "target-feature=+crt-static"]
83 changes: 83 additions & 0 deletions externals/bs-admin-start/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 18 additions & 0 deletions externals/bs-admin-start/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[package]
name = "start_beat_saber_admin"
version = "0.1.0"
edition = "2021"
build = "build.rs"

[build-dependencies]
winres = "0.1.12"

[profile.release]
codegen-units = 1
lto = true
opt-level = "z"

[package.metadata.winres]
FileDescription = "Start Beat Saber as Admin"
LegalCopyright = "Copyright © 2024 Zagrios"
CompanyName = "Zagrios"
20 changes: 20 additions & 0 deletions externals/bs-admin-start/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
extern crate winres;

fn main() {
if cfg!(target_os = "windows") {
let mut res = winres::WindowsResource::new();
res.set_manifest(r#"
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
<security>
<requestedPrivileges>
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
</requestedPrivileges>
</security>
</trustInfo>
</assembly>
"#);
res.set_icon("./icon.ico");
res.compile().unwrap();
}
}
Binary file added externals/bs-admin-start/icon.ico
Binary file not shown.
17 changes: 17 additions & 0 deletions externals/bs-admin-start/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@

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

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());

for arg in args.iter().skip(1) {
command.arg(arg);
}

command.env("SteamAppId", "620980");

let _ = command.spawn();
}
Loading

0 comments on commit d2c1d81

Please sign in to comment.