diff --git a/Sources/Launcher/.gitignore b/Sources/Launcher/.gitignore new file mode 100644 index 0000000..c84ca7a --- /dev/null +++ b/Sources/Launcher/.gitignore @@ -0,0 +1,12 @@ +# Generated by Cargo +# will have compiled files and executables +debug/ +target/ + +# These are backup files generated by rustfmt +**/*.rs.bk + +# MSVC Windows builds of rustc generate these, which store debugging information +*.pdb + +.idea diff --git a/Sources/Launcher/Cargo.lock b/Sources/Launcher/Cargo.lock new file mode 100644 index 0000000..0898041 --- /dev/null +++ b/Sources/Launcher/Cargo.lock @@ -0,0 +1,101 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "farcry_vr" +version = "1.0.0" +dependencies = [ + "windows", + "winres", +] + +[[package]] +name = "serde" +version = "1.0.183" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32ac8da02677876d532745a130fc9d8e6edfa81a269b107c5b00829b91d8eb3c" + +[[package]] +name = "toml" +version = "0.5.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f4f7f0dd8d50a853a531c426359045b1998f04219d88799810762cd4ad314234" +dependencies = [ + "serde", +] + +[[package]] +name = "windows" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e686886bc078bc1b0b600cac0147aadb815089b6e4da64016cbd754b6342700f" +dependencies = [ + "windows-targets", +] + +[[package]] +name = "windows-targets" +version = "0.48.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "27f51fb4c64f8b770a823c043c7fad036323e1c48f55287b7bbb7987b2fcdf3b" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.48.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fde1bb55ae4ce76a597a8566d82c57432bc69c039449d61572a7a353da28f68c" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.48.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1513e8d48365a78adad7322fd6b5e4c4e99d92a69db8df2d435b25b1f1f286d4" + +[[package]] +name = "windows_i686_gnu" +version = "0.48.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "60587c0265d2b842298f5858e1a5d79d146f9ee0c37be5782e92a6eb5e1d7a83" + +[[package]] +name = "windows_i686_msvc" +version = "0.48.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "224fe0e0ffff5d2ea6a29f82026c8f43870038a0ffc247aa95a52b47df381ac4" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.48.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62fc52a0f50a088de499712cbc012df7ebd94e2d6eb948435449d76a6287e7ad" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.48.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2093925509d91ea3d69bcd20238f4c2ecdb1a29d3c281d026a09705d0dd35f3d" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.48.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6ade45bc8bf02ae2aa34a9d54ba660a1a58204da34ba793c00d83ca3730b5f1" + +[[package]] +name = "winres" +version = "0.1.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b68db261ef59e9e52806f688020631e987592bd83619edccda9c47d42cde4f6c" +dependencies = [ + "toml", +] diff --git a/Sources/Launcher/Cargo.toml b/Sources/Launcher/Cargo.toml new file mode 100644 index 0000000..7afbdbc --- /dev/null +++ b/Sources/Launcher/Cargo.toml @@ -0,0 +1,19 @@ +[package] +name = "farcry_vr" +version = "1.0.0" +edition = "2021" +description = "A launcher for Far Cry VR" + +[[bin]] +name = "FarCryVR" +path = "src/main.rs" + +[dependencies.windows] +version = "0.48" +features = [ + "Win32_Foundation", + "Win32_System_LibraryLoader", +] + +[target.'cfg(windows)'.build-dependencies] +winres = "0.1" diff --git a/Sources/Launcher/src/main.rs b/Sources/Launcher/src/main.rs new file mode 100644 index 0000000..02c8446 --- /dev/null +++ b/Sources/Launcher/src/main.rs @@ -0,0 +1,37 @@ +#![windows_subsystem = "windows"] +extern crate windows; + +use std::env; +use std::path::Path; +use std::process::Command; +use windows::core::HSTRING; +use windows::Win32::System::LibraryLoader::SetDllDirectoryW; + +fn main() { + let exe_path = env::current_exe().expect("Failed to determine path"); + let install_dir = exe_path.parent().unwrap_or(Path::new(".")); + let farcry_exe_path = install_dir.join("Bin32").join("FarCry.exe"); + let mod_exe_path = install_dir.join("Mods").join("CryVR").join("Bin32"); + + let pass_on_args: Vec = env::args().skip(1).collect(); + + let args = vec![ + "-MOD:CryVR", + "-DEVMODE", + ]; + + unsafe { + SetDllDirectoryW(&HSTRING::from(mod_exe_path.as_os_str())); + } + + Command::new(farcry_exe_path) + .args(pass_on_args) + .args(&args) + .env("DXVK_ASYNC", "0") + .env("DXVK_GPLASYNCCACHE", "0") + .current_dir(install_dir.join("Bin32")) + .spawn() + .expect("Failed to launch Far Cry") + .wait() + .expect("Failed to run Far Cry"); +}