@@ -45,11 +45,12 @@ public static class Program
4545 private const string ConfigFileName = "SharpLoader.ini" ;
4646 private static readonly string MyPath = Process . GetCurrentProcess ( ) . MainModule . FileName ;
4747 private static readonly string MyDirectory = Path . GetDirectoryName ( MyPath ) ;
48- private static readonly string ConfigPath = Path . Combine ( MyDirectory , ConfigFileName ) ;
49-
48+
5049 public static int Seed = - 1 ;
5150 public static string Hash ;
5251
52+ private static string _configPath = Path . Combine ( MyDirectory , ConfigFileName ) ;
53+
5354 private static MainForm _form ;
5455 private static List < string > _dragDropPaths ;
5556 private static bool _outToConsole ;
@@ -94,7 +95,19 @@ public static void Main(string[] args)
9495
9596 ZipFile . ExtractToDirectory ( args [ i ] , tempDir ) ;
9697
97- _dragDropPaths . AddRange ( ScanDir ( tempDir ) ) ;
98+ var unzipFiles = ScanDir ( tempDir ) ;
99+
100+ foreach ( var unzipFile in unzipFiles )
101+ {
102+ if ( unzipFile . EndsWith ( ConfigFileName ) )
103+ {
104+ _configPath = unzipFile ;
105+ }
106+ else
107+ {
108+ _dragDropPaths . Add ( unzipFile ) ;
109+ }
110+ }
98111 }
99112 // Normal
100113 else
@@ -130,6 +143,19 @@ public static void Main(string[] args)
130143 }
131144 }
132145
146+ // Data file not found
147+ if ( ! File . Exists ( _configPath ) )
148+ {
149+ WinApi . WritePrivateProfileString ( "SharpLoader" , "References" , "" , _configPath ) ;
150+ WinApi . WritePrivateProfileString ( "SharpLoader" , "Directory" , "" , _configPath ) ;
151+ WinApi . WritePrivateProfileString ( "SharpLoader" , "Sources" , "" , _configPath ) ;
152+ WinApi . WritePrivateProfileString ( "SharpLoader" , "Output" , "SharpLoader" , _configPath ) ;
153+ WinApi . WritePrivateProfileString ( "SharpLoader" , "Arguments" , "/platform:anycpu32bitpreferred" , _configPath ) ;
154+ WinApi . WritePrivateProfileString ( "SharpLoader" , "AutoRun" , "false" , _configPath ) ;
155+
156+ Environment . Exit ( 1 ) ;
157+ }
158+
133159 // Generate random seed
134160 if ( Seed == - 1 )
135161 {
@@ -175,21 +201,11 @@ public static int Compile()
175201 Out ( "" ) ;
176202
177203 // Data file not found
178- if ( ! File . Exists ( ConfigFileName ) )
204+ if ( ! File . Exists ( _configPath ) )
179205 {
180206 Console . ForegroundColor = ConsoleColor . Red ;
181207 Out ( $ "-=: Config file not found ({ ConfigFileName } )") ;
182208
183- WinApi . WritePrivateProfileString ( "SharpLoader" , "References" , "" , ConfigPath ) ;
184- WinApi . WritePrivateProfileString ( "SharpLoader" , "Directory" , "" , ConfigPath ) ;
185- WinApi . WritePrivateProfileString ( "SharpLoader" , "Sources" , "" , ConfigPath ) ;
186- WinApi . WritePrivateProfileString ( "SharpLoader" , "Output" , "SharpLoader" , ConfigPath ) ;
187- WinApi . WritePrivateProfileString ( "SharpLoader" , "Arguments" , "/platform:anycpu32bitpreferred" , ConfigPath ) ;
188- WinApi . WritePrivateProfileString ( "SharpLoader" , "AutoRun" , "false" , ConfigPath ) ;
189-
190- Console . ForegroundColor = ConsoleColor . Red ;
191- Out ( $ "-=: Default config file generated") ;
192-
193209 return 1 ;
194210 }
195211
@@ -203,12 +219,12 @@ public static int Compile()
203219 var compilerArgumentsReadSb = new StringBuilder ( ReadBufferSize ) ;
204220 var autoRunReadSb = new StringBuilder ( ReadBufferSize ) ;
205221
206- WinApi . GetPrivateProfileString ( "SharpLoader" , "References" , string . Empty , userReferencesReadSb , ReadBufferSize , ConfigPath ) ;
207- WinApi . GetPrivateProfileString ( "SharpLoader" , "Directory" , string . Empty , baseDirectoryReadSb , ReadBufferSize , ConfigPath ) ;
208- WinApi . GetPrivateProfileString ( "SharpLoader" , "Sources" , string . Empty , sourceFilesReadSb , ReadBufferSize , ConfigPath ) ;
209- WinApi . GetPrivateProfileString ( "SharpLoader" , "Output" , string . Empty , outputNameReadSb , ReadBufferSize , ConfigPath ) ;
210- WinApi . GetPrivateProfileString ( "SharpLoader" , "Arguments" , string . Empty , compilerArgumentsReadSb , ReadBufferSize , ConfigPath ) ;
211- WinApi . GetPrivateProfileString ( "SharpLoader" , "AutoRun" , string . Empty , autoRunReadSb , ReadBufferSize , ConfigPath ) ;
222+ WinApi . GetPrivateProfileString ( "SharpLoader" , "References" , string . Empty , userReferencesReadSb , ReadBufferSize , _configPath ) ;
223+ WinApi . GetPrivateProfileString ( "SharpLoader" , "Directory" , string . Empty , baseDirectoryReadSb , ReadBufferSize , _configPath ) ;
224+ WinApi . GetPrivateProfileString ( "SharpLoader" , "Sources" , string . Empty , sourceFilesReadSb , ReadBufferSize , _configPath ) ;
225+ WinApi . GetPrivateProfileString ( "SharpLoader" , "Output" , string . Empty , outputNameReadSb , ReadBufferSize , _configPath ) ;
226+ WinApi . GetPrivateProfileString ( "SharpLoader" , "Arguments" , string . Empty , compilerArgumentsReadSb , ReadBufferSize , _configPath ) ;
227+ WinApi . GetPrivateProfileString ( "SharpLoader" , "AutoRun" , string . Empty , autoRunReadSb , ReadBufferSize , _configPath ) ;
212228
213229 var userReferences = userReferencesReadSb . ToString ( ) . Split ( new [ ] { ';' } , StringSplitOptions . RemoveEmptyEntries ) ;
214230 var baseDirectory = baseDirectoryReadSb . ToString ( ) ;
0 commit comments