@@ -924,8 +924,6 @@ public enum MODIFICATIONS_REVERT_METHOD {
924924 private const string CONFIGURATION_FOLDER_NAME = "FlashpointSecurePlayerConfigs" ;
925925 private const string CONFIGURATION_DOWNLOAD_NAME = "flashpointsecureplayerconfigs" ;
926926
927- public static readonly char [ ] WHITESPACE = { ' ' , '\t ' , '\n ' , '\v ' , '\" ' } ;
928-
929927 public const string OLD_CPU_SIMULATOR_PATH = "OldCPUSimulator\\ OldCPUSimulator.exe" ;
930928 public const string OLD_CPU_SIMULATOR_PARENT_PROCESS_FILE_NAME = "OLDCPUSIMULATOR.EXE" ;
931929
@@ -2530,7 +2528,7 @@ public static void HideWindow(ref ProcessStartInfo processStartInfo) {
25302528 public static void RestartApplication ( bool runAsAdministrator , Form form , ref Mutex applicationMutex , ProcessStartInfo processStartInfo = null ) {
25312529 if ( processStartInfo == null ) {
25322530 processStartInfo = new ProcessStartInfo {
2533- FileName = Application . ExecutablePath ,
2531+ FileName = GetValidArgument ( Application . ExecutablePath , true ) ,
25342532 // can't use GetCommandLineArgs() and String.Join because arguments that were in quotes will lose their quotes
25352533 // need to use Environment.CommandLine and find arguments
25362534 Arguments = GetArgumentSliceFromCommandLine ( Environment . CommandLine , 1 )
@@ -2972,33 +2970,36 @@ public static string[] GetCommandLineToArgv(string commandLine, out int argc) {
29722970 }
29732971
29742972 // http://blogs.msdn.microsoft.com/twistylittlepassagesallalike/2011/04/23/everyone-quotes-command-line-arguments-the-wrong-way/
2975- public static void GetValidArgument ( ref string argument , bool force = false ) {
2976- if ( force || argument == String . Empty || argument . IndexOfAny ( WHITESPACE ) ! = - 1 ) {
2977- int backslashes = 0 ;
2978- StringBuilder validArgument = new StringBuilder ( ) ;
2973+ public static string GetValidArgument ( string argument , bool force = false ) {
2974+ if ( ! force && argument != String . Empty && argument . IndexOfAny ( new char [ ] { ' ' , ' \t ' , ' \n ' , ' \v ' , ' \" ' } ) = = - 1 ) {
2975+ return argument ;
2976+ }
29792977
2980- for ( int i = 0 ; i < argument . Length ; i ++ ) {
2981- backslashes = 0 ;
2978+ int backslashes = 0 ;
2979+ StringBuilder validArgument = new StringBuilder ( " \" " ) ;
29822980
2983- while ( i != argument . Length && argument [ i ] == '\\ ' ) {
2984- backslashes ++ ;
2985- i ++ ;
2986- }
2981+ for ( int i = 0 ; i < argument . Length ; i ++ ) {
2982+ backslashes = 0 ;
29872983
2988- if ( i != argument . Length ) {
2989- if ( argument [ i ] == '"' ) {
2990- validArgument . Append ( '\\ ' , backslashes + backslashes + 1 ) ;
2991- } else {
2992- validArgument . Append ( '\\ ' , backslashes ) ;
2993- }
2984+ while ( i != argument . Length && argument [ i ] . ToString ( ) . Equals ( "\\ " , StringComparison . Ordinal ) ) {
2985+ backslashes ++ ;
2986+ i ++ ;
2987+ }
29942988
2995- validArgument . Append ( argument [ i ] ) ;
2989+ if ( i != argument . Length ) {
2990+ if ( argument [ i ] . ToString ( ) . Equals ( "\" " , StringComparison . Ordinal ) ) {
2991+ validArgument . Append ( '\\ ' , backslashes + backslashes + 1 ) ;
2992+ } else {
2993+ validArgument . Append ( '\\ ' , backslashes ) ;
29962994 }
2997- }
29982995
2999- validArgument . Append ( ' \\ ' , backslashes + backslashes ) ;
3000- argument = " \" " + validArgument . ToString ( ) + " \" " ;
2996+ validArgument . Append ( argument [ i ] ) ;
2997+ }
30012998 }
2999+
3000+ validArgument . Append ( '\\ ' , backslashes + backslashes ) ;
3001+ validArgument . Append ( "\" " ) ;
3002+ return validArgument . ToString ( ) ;
30023003 }
30033004
30043005 public static string GetArgumentSliceFromCommandLine ( string commandLine , int begin = 0 , int end = - 1 ) {
0 commit comments