9
9
using System . IO ;
10
10
using System . Media ;
11
11
using System . Text ;
12
- using System . Threading . Tasks ;
12
+ using System . Threading ;
13
13
using System . Windows . Forms ;
14
14
15
15
namespace CHOVY
@@ -156,20 +156,10 @@ private void FREEDOM_Click(object sender, EventArgs e)
156
156
string TitleID = GetTitleID ( ISOPath . Text ) ;
157
157
158
158
string TmpDir = Path . Combine ( Application . StartupPath , "_tmp" ) ;
159
- string GameWorkDir = Path . Combine ( TmpDir , "ux0_pspemu_temp_game_PSP_GAME_" + TitleID ) ;
160
- // string GameWorkDir = Path.Combine(TmpDir, TitleID);
161
- string LicenseWorkDir = Path . Combine ( TmpDir , "ux0_pspemu_temp_game_PSP_LICENSE" ) ;
159
+ string GameWorkDir = Path . Combine ( TmpDir , TitleID ) ;
162
160
string EbootFile = Path . Combine ( GameWorkDir , "EBOOT.PBP" ) ;
163
161
string EbootSignature = Path . Combine ( GameWorkDir , "__sce_ebootpbp" ) ;
164
- string GamePathFile = Path . Combine ( GameWorkDir , "VITA_PATH.TXT" ) ;
165
- string LicensePathFile = Path . Combine ( LicenseWorkDir , "VITA_PATH.TXT" ) ;
166
162
167
-
168
- try
169
- {
170
- Directory . Delete ( TmpDir , true ) ;
171
- }
172
- catch ( Exception ) { } ;
173
163
Directory . CreateDirectory ( TmpDir ) ;
174
164
Directory . CreateDirectory ( GameWorkDir ) ;
175
165
@@ -188,15 +178,20 @@ private void FREEDOM_Click(object sender, EventArgs e)
188
178
string Aid = BitConverter . ToString ( RifAid ) . Replace ( "-" , "" ) . ToLower ( ) ;
189
179
string BackupWorkDir = Path . Combine ( CmaDir , "PGAME" , Aid , TitleID ) ;
190
180
191
- TotalProgress . Style = ProgressBarStyle . Continuous ;
192
- Status . Text = "Overthrowing The PSPEMU Monarchy 00 %" ;
181
+ TotalProgress . Maximum = 100 ;
182
+ Status . Text = "Overthrowing The PSPEMU Monarchy 0 %" ;
193
183
194
184
string BootupImage = "" ;
195
185
if ( isMini ( ISOPath . Text ) )
196
186
{
197
187
BootupImage = Path . Combine ( Application . StartupPath , "_tmp" , "minis.png" ) ;
198
188
Resources . MINIS . Save ( BootupImage ) ;
199
189
}
190
+ else
191
+ {
192
+ BootupImage = Path . Combine ( Application . StartupPath , "_tmp" , "chovy.png" ) ;
193
+ Resources . ChovyLogo . Save ( BootupImage ) ;
194
+ }
200
195
201
196
Process signnp = pbp . GenPbpFromIso ( ISOPath . Text , EbootFile , ContentID , Versionkey . Text , CompressPBP . Checked , BootupImage ) ;
202
197
while ( ! signnp . HasExited )
@@ -207,33 +202,29 @@ private void FREEDOM_Click(object sender, EventArgs e)
207
202
Progress = Progress . Remove ( 0 , 19 ) ;
208
203
int ProgressInt = int . Parse ( Progress . Substring ( 0 , 3 ) ) ;
209
204
TotalProgress . Value = ProgressInt ;
210
- Status . Text = "Overthrowing The PSPEMU Monarchy " + Progress ;
205
+ Status . Text = "Overthrowing The PSPEMU Monarchy " + ProgressInt . ToString ( ) + "%" ;
211
206
}
212
207
Application . DoEvents ( ) ;
213
208
}
214
- TotalProgress . Value = 100 ;
209
+ TotalProgress . Value = 0 ;
215
210
216
- if ( isMini ( ISOPath . Text ) )
211
+ Status . Text = "Signing the Declaration of Independance 0%" ;
212
+ UInt64 IntAid = BitConverter . ToUInt64 ( RifAid , 0x00 ) ;
213
+ Thread thrd = new Thread ( ( ) =>
217
214
{
218
- try
215
+
216
+ int ChovyGenRes = pbp . gen__sce_ebootpbp ( EbootFile , IntAid , EbootSignature ) ;
217
+ if ( ! File . Exists ( EbootSignature ) || ChovyGenRes != 0 )
219
218
{
220
- File . Delete ( BootupImage ) ;
219
+ MessageBox . Show ( "CHOVY-GEN Failed! Please check CHOVY.DLL exists\n and that the Microsoft Visual C++ 2015 Redistributable Update 3 RC is installed" ) ;
220
+ enable ( ) ;
221
+ return ;
221
222
}
222
- catch ( Exception ) { } ;
223
-
224
- }
225
-
226
- // File.WriteAllText(GamePathFile, "ux0:pspemu/temp/game/PSP/GAME/" + TitleID + "\x00");
227
-
228
- //TotalProgress.Style = ProgressBarStyle.Marquee;
229
- Status . Text = "Signing the Declaration of Independance 0%" ;
230
- UInt64 IntAid = BitConverter . ToUInt64 ( RifAid , 0x00 ) ;
231
- int ChovyGenRes = pbp . gen__sce_ebootpbp ( EbootFile , IntAid , EbootSignature ) ;
232
- if ( ! File . Exists ( EbootSignature ) || ChovyGenRes != 0 )
233
- {
234
- MessageBox . Show ( "CHOVY-GEN Failed! Please check CHOVY.DLL exists\n and that the Microsoft Visual C++ 2015 Redistributable Update 3 RC is installed" ) ;
235
- enable ( ) ;
236
- return ;
223
+ } ) ;
224
+ thrd . Start ( ) ;
225
+ while ( thrd . IsAlive )
226
+ {
227
+ Application . DoEvents ( ) ;
237
228
}
238
229
239
230
/*
@@ -242,8 +233,7 @@ private void FREEDOM_Click(object sender, EventArgs e)
242
233
243
234
// Pacakge GAME
244
235
245
-
246
- //string BackupGameDir = Path.Combine(BackupWorkDir, "game");
236
+ byte [ ] CmaKey = CmaKeys . GenerateKey ( RifAid ) ;
247
237
248
238
string [ ] entrys = Directory . GetFileSystemEntries ( GameWorkDir , "*" , SearchOption . AllDirectories ) ;
249
239
long noEntrys = entrys . LongLength ;
@@ -255,20 +245,19 @@ private void FREEDOM_Click(object sender, EventArgs e)
255
245
}
256
246
TotalProgress . Maximum = noBlocks ;
257
247
258
- byte [ ] CmaKey = CmaKeys . GenerateKey ( RifAid ) ;
259
248
260
249
string BackupDir = Path . Combine ( BackupWorkDir , "game" ) ;
261
250
Directory . CreateDirectory ( BackupDir ) ;
262
- FileStream psvimg = File . OpenWrite ( Path . Combine ( BackupDir , "game.psvimg" ) ) ;
263
- psvimg . SetLength ( 0 ) ;
264
-
265
- PSVIMGBuilder builder = new PSVIMGBuilder ( psvimg , CmaKey ) ;
266
-
267
-
251
+ string psvimgFilepath = Path . Combine ( BackupDir , "game.psvimg" ) ;
252
+ FileStream gamePsvimg = File . OpenWrite ( psvimgFilepath ) ;
253
+ gamePsvimg . SetLength ( 0 ) ;
254
+ PSVIMGBuilder builder = new PSVIMGBuilder ( gamePsvimg , CmaKey ) ;
268
255
269
256
foreach ( string entry in entrys )
270
257
{
271
258
string relativePath = entry . Remove ( 0 , GameWorkDir . Length ) ;
259
+ relativePath = relativePath . Replace ( '\\ ' , '/' ) ;
260
+
272
261
bool isDir = File . GetAttributes ( entry ) . HasFlag ( FileAttributes . Directory ) ;
273
262
274
263
if ( isDir )
@@ -295,54 +284,29 @@ private void FREEDOM_Click(object sender, EventArgs e)
295
284
}
296
285
297
286
long ContentSize = builder . Finish ( ) ;
287
+ gamePsvimg = File . OpenRead ( psvimgFilepath ) ;
288
+ FileStream gamePsvmd = File . OpenWrite ( Path . Combine ( BackupDir , "game.psvmd" ) ) ;
289
+ PSVMDBuilder . CreatePsvmd ( gamePsvmd , gamePsvimg , ContentSize , "game" , CmaKey ) ;
290
+ gamePsvmd . Close ( ) ;
291
+ gamePsvimg . Close ( ) ;
298
292
299
- psvimg = File . OpenRead ( Path . Combine ( BackupDir , "game.psvimg" ) ) ;
300
- FileStream psvmd = File . OpenWrite ( Path . Combine ( BackupDir , "game.psvmd" ) ) ;
301
- PSVMDBuilder . CreatePsvmd ( psvmd , psvimg , ContentSize , "game" , CmaKey ) ;
302
- psvmd . Close ( ) ;
303
-
304
- // Directory.CreateDirectory(BackupGameDir);
305
-
306
- //Process psvimg_create = psvimgtools.PSVIMG_CREATE(Aid, "game" ,TmpDir, Path.Combine(BackupWorkDir,"game"));
307
- /* while(!psvimg_create.HasExited)
308
- {
309
- Application.DoEvents();
310
- }
311
- if (psvimg_create.ExitCode != 0)
312
- {
313
- MessageBox.Show("PSVIMG-CREATE.EXE FAILED!\nArguments:\n" + psvimg_create.StartInfo.Arguments + "\nStdOut:\n" + psvimg_create.StandardOutput.ReadToEnd() + "\nStdErr:\n" + psvimg_create.StandardError.ReadToEnd());
314
- enable();
315
- return;
316
- }
317
- */
318
293
// Package LICENSE
319
- try
320
- {
321
- Directory . Delete ( TmpDir , true ) ;
322
- }
323
- catch ( Exception ) { } ;
324
- Directory . CreateDirectory ( TmpDir ) ;
325
- Directory . CreateDirectory ( LicenseWorkDir ) ;
326
- File . Copy ( RifPath . Text , Path . Combine ( LicenseWorkDir , ContentID + ".rif" ) , true ) ;
327
- File . WriteAllText ( LicensePathFile , "ux0:pspemu/temp/game/PSP/LICENSE\x00 " ) ;
328
- /*Directory.CreateDirectory(BackupGameDir);
329
- Process psvimg_create = psvimgtools.PSVIMG_CREATE(Aid, "license", TmpDir, Path.Combine(BackupWorkDir, "license"));
330
- while (!psvimg_create.HasExited)
331
- {
332
- Application.DoEvents();
333
- }
334
- if(psvimg_create.ExitCode != 0)
335
- {
336
- MessageBox.Show("PSVIMG-CREATE.EXE FAILED!\nArguments:\n" + psvimg_create.StartInfo.Arguments + "\nStdOut:\n" + psvimg_create.StandardOutput.ReadToEnd() + "\nStdErr:\n" + psvimg_create.StandardError.ReadToEnd());
337
- enable();
338
- return;
339
- }*/
340
294
341
- try
342
- {
343
- Directory . Delete ( TmpDir , true ) ;
344
- }
345
- catch ( Exception ) { } ;
295
+ BackupDir = Path . Combine ( BackupWorkDir , "license" ) ;
296
+ psvimgFilepath = Path . Combine ( BackupDir , "license.psvimg" ) ;
297
+
298
+ Directory . CreateDirectory ( BackupDir ) ;
299
+ FileStream licensePsvimg = File . OpenWrite ( psvimgFilepath ) ;
300
+ licensePsvimg . SetLength ( 0 ) ;
301
+ builder = new PSVIMGBuilder ( licensePsvimg , CmaKey ) ;
302
+ builder . AddFile ( RifPath . Text , "ux0:pspemu/temp/game/PSP/LICENSE" , "/" + ContentID + ".rif" ) ;
303
+ ContentSize = builder . Finish ( ) ;
304
+
305
+ licensePsvimg = File . OpenRead ( psvimgFilepath ) ;
306
+ FileStream licensePsvmd = File . OpenWrite ( Path . Combine ( BackupDir , "license.psvmd" ) ) ;
307
+ PSVMDBuilder . CreatePsvmd ( licensePsvmd , licensePsvimg , ContentSize , "license" , CmaKey ) ;
308
+ licensePsvmd . Close ( ) ;
309
+ licensePsvimg . Close ( ) ;
346
310
347
311
// Write PARAM.SFO & ICON0.PNG
348
312
string SceSysWorkDir = Path . Combine ( BackupWorkDir , "sce_sys" ) ;
@@ -355,9 +319,14 @@ private void FREEDOM_Click(object sender, EventArgs e)
355
319
356
320
Status . Text = "YOU HAVE MADE A SOCIAL CONTRACT WITH FREEDOM!" ;
357
321
TotalProgress . Value = 0 ;
358
- TotalProgress . Style = ProgressBarStyle . Continuous ;
359
-
360
- if ( ! MutedAudio )
322
+
323
+ try
324
+ {
325
+ Directory . Delete ( TmpDir , true ) ;
326
+ }
327
+ catch ( Exception ) { } ;
328
+
329
+ if ( ! MutedAudio )
361
330
{
362
331
Stream str = Resources . Murica ;
363
332
SoundPlayer snd = new SoundPlayer ( str ) ;
0 commit comments