4
4
using LibChovy ;
5
5
using LibChovy . VersionKey ;
6
6
using System . Text ;
7
+ using Vita . ContentManager ;
8
+ using PspCrypto ;
7
9
8
10
namespace ChovySign_CLI
9
11
{
10
12
internal class Program
11
13
{
12
14
private static ArgumentParsingMode mode = ArgumentParsingMode . ARG ;
13
15
private static List < string > parameters = new List < string > ( ) ;
14
- private static string [ ] discs ;
16
+ private static string [ ] discs = new string [ ] { } ;
15
17
private static bool pspCompress = false ;
16
- private static bool devKit = false ;
17
18
private static string ? popsDiscName ;
18
- private static string ? popsIcon0File ;
19
- private static string ? popsPic0File ;
19
+ private static byte [ ] ? popsIcon0File ;
20
+ private static byte [ ] ? popsPic0File ;
20
21
private static PbpMode ? pbpMode = null ;
21
22
private static NpDrmRif ? rifFile = null ;
22
23
private static NpDrmInfo ? drmInfo = null ;
23
24
25
+ // cma
26
+ private static bool devKit = false ;
27
+ private static bool packagePsvImg = true ;
28
+ private static string ? outputFolder = null ;
29
+
30
+ // --vkey-gen
24
31
private static byte [ ] ? actDat = null ;
25
32
private static byte [ ] ? idps = null ;
26
33
private static string ? rifFolder = null ;
34
+
35
+ // --pops-eboot-sign
36
+ private static byte [ ] ? ebootElf = null ;
37
+ private static byte [ ] ? configBin = null ;
38
+
27
39
enum PbpMode
28
40
{
29
41
PSP = 0 ,
@@ -33,15 +45,23 @@ enum PbpMode
33
45
}
34
46
enum ArgumentParsingMode
35
47
{
36
- ARG = 0 ,
37
- POPS_DISC = 1 ,
38
- PSP_UMD = 2 ,
39
- VERSIONKEY = 3 ,
40
- VERSIONKEY_EXTRACT = 4 ,
41
- VERSIONKEY_GENERATOR = 5 ,
42
- POPS_INFO = 6 ,
43
- KEYS_TXT_GEN = 7 ,
44
- RIF = 8
48
+ ARG ,
49
+ POPS_DISC ,
50
+ PSP_UMD ,
51
+
52
+ VERSIONKEY ,
53
+ VERSIONKEY_EXTRACT ,
54
+ VERSIONKEY_GENERATOR ,
55
+
56
+ CMA_DEVKIT ,
57
+ CMA_OUTPUT_FOLDER ,
58
+ CMA_PACKAGE_PSVIMG ,
59
+
60
+ POPS_INFO ,
61
+ POPS_EBOOT ,
62
+
63
+ KEYS_TXT_GEN ,
64
+ RIF
45
65
}
46
66
public static int Error ( string errorMsg , int ret )
47
67
{
@@ -102,13 +122,13 @@ private static int complete()
102
122
switch ( mode )
103
123
{
104
124
case ArgumentParsingMode . POPS_DISC :
105
- if ( parameters . Count > 5 ) return Error ( "--pops: no more than 5 disc images allowed in a single game (sony's rules, not mine)" , 5 ) ;
106
- if ( parameters . Count < 1 ) return Error ( "--pops: at least 1 disc image file is required." , 5 ) ;
125
+ if ( parameters . Count > 5 ) return Error ( "--pops: no more than 5 disc images allowed in a single game (sony's rules, not mine)" , 4 ) ;
126
+ if ( parameters . Count < 1 ) return Error ( "--pops: at least 1 disc image file is required." , 4 ) ;
107
127
discs = parameters . ToArray ( ) ;
108
128
break ;
109
129
case ArgumentParsingMode . PSP_UMD :
110
- if ( parameters . Count < 1 ) return Error ( "--psp: a path to a disc image is required" , 5 ) ;
111
- if ( parameters . Count > 2 ) return Error ( "--psp: no more than 2 arguments. (" + parameters . Count + " given)" , 5 ) ;
130
+ if ( parameters . Count < 1 ) return Error ( "--psp: a path to a disc image is required" , 4 ) ;
131
+ if ( parameters . Count > 2 ) return Error ( "--psp: no more than 2 arguments. (" + parameters . Count + " given)" , 4 ) ;
112
132
discs = new string [ 1 ] ;
113
133
discs [ 0 ] = parameters [ 0 ] ;
114
134
@@ -134,17 +154,34 @@ private static int complete()
134
154
if ( parameters . Count < 2 ) return Error ( "--pops-info takes at least 1 arguments (" + parameters . Count + " given)" , 4 ) ;
135
155
if ( parameters . Count > 3 ) return Error ( "--pops-info takes no more than 3 arguments(" + parameters . Count + " given)" , 4 ) ;
136
156
popsDiscName = parameters [ 0 ] ;
137
- if ( parameters . Count > 1 )
138
- popsIcon0File = parameters [ 1 ] ;
139
- if ( parameters . Count > 2 )
140
- popsPic0File = parameters [ 2 ] ;
157
+ if ( parameters . Count > 1 && File . Exists ( parameters [ 1 ] ) )
158
+ popsIcon0File = File . ReadAllBytes ( parameters [ 1 ] ) ;
159
+ if ( parameters . Count > 2 && File . Exists ( parameters [ 2 ] ) )
160
+ popsPic0File = File . ReadAllBytes ( parameters [ 2 ] ) ;
141
161
break ;
142
162
case ArgumentParsingMode . KEYS_TXT_GEN :
143
163
if ( parameters . Count != 3 ) return Error ( "--keys-txt-gen takes 3 arguments, (" + parameters . Count + " given)" , 4 ) ;
144
164
actDat = File . ReadAllBytes ( parameters [ 0 ] ) ;
145
165
idps = StringToByteArray ( parameters [ 1 ] ) ;
146
166
rifFolder = parameters [ 2 ] ;
147
167
break ;
168
+ case ArgumentParsingMode . POPS_EBOOT :
169
+ if ( parameters . Count < 1 ) return Error ( "--pops-eboot-sign expects at most 1 arguments" , 4 ) ;
170
+ if ( ! File . Exists ( parameters [ 0 ] ) ) return Error ( "--pops-eboot-sign: file not found" , 4 ) ;
171
+ ebootElf = File . ReadAllBytes ( parameters [ 0 ] ) ;
172
+
173
+ if ( parameters . Count >= 2 && File . Exists ( parameters [ 1 ] ) )
174
+ configBin = File . ReadAllBytes ( parameters [ 1 ] ) ;
175
+ else
176
+ configBin = GameBuilder . Resources . DATAPSPSDCFG ;
177
+
178
+ break ;
179
+ case ArgumentParsingMode . CMA_OUTPUT_FOLDER :
180
+ if ( parameters . Count < 1 ) return Error ( "--output-folder expects 1 output" , 4 ) ;
181
+ if ( ! Directory . Exists ( parameters [ 0 ] ) ) return Error ( "--output-folder: directory not found" , 4 ) ;
182
+
183
+ SettingsReader . BackupsFolder = parameters [ 0 ] ;
184
+ break ;
148
185
case ArgumentParsingMode . RIF :
149
186
if ( parameters . Count != 1 ) return Error ( "--rif expects only 1 argument," , 4 ) ;
150
187
rifFile = new NpDrmRif ( File . ReadAllBytes ( parameters [ 0 ] ) ) ;
@@ -163,12 +200,20 @@ public static int Main(string[] args)
163
200
Console . WriteLine ( "Chovy-Sign v2 (CLI)" ) ;
164
201
Console . WriteLine ( "--pops [disc1.cue] [disc2.cue] [disc3.cue] ... (up to 5)" ) ;
165
202
Console . WriteLine ( "--pops-info [game title] [icon0.png] (optional) [pic1.png] (optional)" ) ;
203
+ Console . WriteLine ( "--pops-eboot [eboot.elf] [config.bin] (optional)" ) ;
204
+
166
205
Console . WriteLine ( "--psp [umd.iso] [compress; true/false] (optional)" ) ;
206
+
167
207
Console . WriteLine ( "--rif [GAME.RIF]" ) ;
208
+
168
209
Console . WriteLine ( "--devkit (Use 000000000000 account id)" ) ;
210
+ Console . WriteLine ( "--no-psvimg (Disable creating a .psvimg file)" ) ;
211
+ Console . WriteLine ( "--output-folder [output_folder]" ) ;
212
+
169
213
Console . WriteLine ( "--vkey [versionkey] [contentid] [key_index]" ) ;
170
214
Console . WriteLine ( "--vkey-extract [eboot.pbp]" ) ;
171
215
Console . WriteLine ( "--vkey-gen [act.dat] [license.rif] [console_id] [key_index]" ) ;
216
+
172
217
Console . WriteLine ( "--keys-txt-gen [act.dat] [console_id] [psp_license_folder]" ) ;
173
218
}
174
219
@@ -236,6 +281,17 @@ public static int Main(string[] args)
236
281
return Error ( "rif is already set" , 3 ) ;
237
282
238
283
break ;
284
+ case "--pops-eboot" :
285
+ mode = ArgumentParsingMode . POPS_EBOOT ;
286
+ break ;
287
+ case "--output-folder" :
288
+ mode = ArgumentParsingMode . CMA_OUTPUT_FOLDER ;
289
+ break ;
290
+
291
+ case "--no-psvimg" :
292
+ packagePsvImg = false ;
293
+ break ;
294
+
239
295
case "--devkit" :
240
296
devKit = true ;
241
297
break ;
@@ -248,6 +304,7 @@ public static int Main(string[] args)
248
304
case ArgumentParsingMode . VERSIONKEY_EXTRACT :
249
305
case ArgumentParsingMode . PSP_UMD :
250
306
case ArgumentParsingMode . POPS_DISC :
307
+ case ArgumentParsingMode . POPS_EBOOT :
251
308
case ArgumentParsingMode . POPS_INFO :
252
309
case ArgumentParsingMode . RIF :
253
310
default :
@@ -267,14 +324,14 @@ public static int Main(string[] args)
267
324
if ( pbpMode is null ) return Error ( "no pbp mode was set, exiting" , 7 ) ;
268
325
269
326
if ( pbpMode == PbpMode . PSP && drmInfo . KeyIndex != 2 )
270
- return Error ( "KeyType is " + drmInfo . KeyIndex + ", but PBP mode is PSP, you cant do that .. please use a type 1 versionkey." , 8 ) ;
327
+ return Error ( "KeyType is " + drmInfo . KeyIndex + ", but PBP mode is PSP, you cant do that .. please use a type 2 versionkey." , 8 ) ;
271
328
272
329
if ( pbpMode == PbpMode . POPS && drmInfo . KeyIndex != 1 )
273
330
return Error ( "KeyType is " + drmInfo . KeyIndex + ", but PBP mode is POPS, you cant do that .. please use a type 1 versionkey." , 8 ) ;
274
331
275
332
if ( rifFile is null )
276
333
return Error ( "Rif is not set, use --rif to specify base game RIF" , 8 ) ;
277
- //if (pbpMode == PbpMode.POPS && (popsDiscName is null || popsIcon0File is null)) return Error("pbp mode is POPS, but you have not specified a disc title or icon file using --pops-info.", 9);
334
+
278
335
ChovySign csign = new ChovySign ( ) ;
279
336
csign . RegisterCallback ( onProgress ) ;
280
337
if ( pbpMode == PbpMode . POPS )
@@ -287,18 +344,26 @@ public static int Main(string[] args)
287
344
if ( popsDiscName is not null )
288
345
popsParameters . Name = popsDiscName ;
289
346
290
- if ( File . Exists ( popsIcon0File ) )
291
- popsParameters . Icon0 = File . ReadAllBytes ( popsIcon0File ) ;
347
+ if ( popsIcon0File is not null )
348
+ popsParameters . Icon0 = popsIcon0File ;
349
+
292
350
351
+ popsParameters . CreatePsvImg = packagePsvImg ;
293
352
popsParameters . Account . Devkit = devKit ;
294
353
354
+ // Allow for custom eboot.elf and configs
355
+ popsParameters . ConfigBinOverride = configBin ;
356
+ popsParameters . EbootElfOverride = ebootElf ;
357
+
295
358
csign . Go ( popsParameters ) ;
296
359
297
360
}
298
361
else if ( pbpMode == PbpMode . PSP )
299
362
{
300
363
PspParameters pspParameters = new PspParameters ( drmInfo , rifFile ) ;
301
364
pspParameters . Account . Devkit = devKit ;
365
+ pspParameters . CreatePsvImg = packagePsvImg ;
366
+
302
367
pspParameters . Compress = pspCompress ;
303
368
pspParameters . Umd = new UmdInfo ( discs . First ( ) ) ;
304
369
0 commit comments