@@ -3,7 +3,9 @@ use dll_syringe::{process::OwnedProcess, Syringe};
33#[ cfg( target_os = "windows" ) ]
44use log:: info;
55#[ cfg( target_os = "windows" ) ]
6- use std:: process:: Command ;
6+ use std:: path:: PathBuf ;
7+ #[ cfg( target_os = "windows" ) ]
8+ use std:: process:: { Command , Stdio } ;
79
810#[ cfg( target_os = "windows" ) ]
911use crate :: { constants:: * , errors:: * } ;
@@ -34,13 +36,25 @@ pub async fn run_samp(
3436 custom_game_exe : & str ,
3537) -> Result < ( ) > {
3638 // Prepare the command to spawn the executable
37- let mut target_game_exe = GTA_SA_EXECUTABLE . to_string ( ) ;
38- if custom_game_exe. len ( ) > 0 {
39- target_game_exe = custom_game_exe. to_string ( ) ;
40- }
41- let mut cmd = Command :: new ( format ! ( "{}/{}" , executable_dir, target_game_exe) ) ;
39+ let target_game_exe = if custom_game_exe. len ( ) > 0 {
40+ custom_game_exe. to_string ( )
41+ } else {
42+ GTA_SA_EXECUTABLE . to_string ( )
43+ } ;
44+
45+ let exe_path = PathBuf :: from ( executable_dir) . join ( & target_game_exe) ;
46+
47+ let exe_path = exe_path. canonicalize ( ) . map_err ( |e| {
48+ LauncherError :: Process ( format ! ( "Invalid executable path {:?}: {}" , exe_path, e) )
49+ } ) ?;
50+
51+ let mut cmd = Command :: new ( & exe_path) ;
4252
4353 let mut ready_for_exec = cmd
54+ . stdin ( Stdio :: null ( ) )
55+ . stdout ( Stdio :: null ( ) )
56+ . stderr ( Stdio :: null ( ) )
57+ . current_dir ( executable_dir)
4458 . arg ( "-c" )
4559 . arg ( "-n" )
4660 . arg ( name)
@@ -58,7 +72,12 @@ pub async fn run_samp(
5872 match process {
5973 Ok ( p) => {
6074 inject_dll ( p. id ( ) , dll_path, 0 , false ) ?;
61- inject_dll ( p. id ( ) , omp_file, 0 , false )
75+ info ! ( "[run_samp] omp_file.is_empty(): {}" , omp_file. is_empty( ) ) ;
76+ if !omp_file. is_empty ( ) {
77+ inject_dll ( p. id ( ) , omp_file, 0 , false )
78+ } else {
79+ Ok ( ( ) )
80+ }
6281 }
6382 Err ( e) => {
6483 info ! ( "[injector.rs] Process creation failed: {}" , e) ;
0 commit comments