Skip to content

Commit 0af19e0

Browse files
committed
add dnasload user header
a
1 parent 0f8bb69 commit 0af19e0

File tree

3 files changed

+37
-16
lines changed

3 files changed

+37
-16
lines changed

src/kelf.cpp

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -366,18 +366,22 @@ int Kelf::SaveKelf(const std::string &filename, int headerid)
366366
static uint8_t *USER_HEADER;
367367

368368
switch (headerid) {
369-
case 0:
369+
case HEADER::FMCB:
370370
USER_HEADER = USER_HEADER_FMCB;
371371
break;
372372

373-
case 1:
373+
case HEADER::FHDB:
374374
USER_HEADER = USER_HEADER_FHDB;
375375
break;
376376

377-
case 2:
377+
case HEADER::MBR:
378378
USER_HEADER = USER_HEADER_MBR;
379379
break;
380380

381+
case HEADER::DNASLOAD:
382+
USER_HEADER = USER_HEADER_DNASLOAD;
383+
break;
384+
381385
default:
382386
USER_HEADER = USER_HEADER_FHDB;
383387
break;
@@ -451,15 +455,19 @@ int Kelf::LoadContent(const std::string &filename, int headerid)
451455
// TODO: encrypted Kbit hold some useful data
452456
static uint8_t *USER_Kbit;
453457
switch (headerid) {
454-
case 0:
458+
case HEADER::FMCB:
459+
case HEADER::DNASLOAD:
455460
USER_Kbit = USER_Kbit_FMCB;
456461
break;
457-
case 1:
462+
463+
case HEADER::FHDB:
458464
USER_Kbit = USER_Kbit_FHDB;
459465
break;
460-
case 2:
466+
467+
case HEADER::MBR:
461468
USER_Kbit = USER_Kbit_MBR;
462469
break;
470+
463471
default:
464472
USER_Kbit = USER_Kbit_FHDB;
465473
break;

src/kelf.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,18 @@
3030
#define SYSTEM_TYPE_PS2 0 // same for COH (arcade)
3131
#define SYSTEM_TYPE_PSX 1
3232

33+
enum HEADER {
34+
INVALID = -1,
35+
FMCB = 0,
36+
FHDB,
37+
MBR,
38+
DNASLOAD,
39+
};
40+
3341
static uint8_t USER_HEADER_FMCB[16] = {0x01, 0x00, 0x00, 0x01, 0x00, 0x03, 0x00, 0x4A, 0x00, 0x01, 0x02, 0x19, 0x00, 0x00, 0x00, 0x56};
3442
static uint8_t USER_HEADER_FHDB[16] = {0x01, 0x00, 0x00, 0x04, 0x00, 0x02, 0x00, 0x4A, 0x00, 0x08, 0x01, 0x00, 0x00, 0x00, 0x00, 0x1B};
3543
static uint8_t USER_HEADER_MBR[16] = {0x01, 0x00, 0x00, 0x04, 0x00, 0x02, 0x01, 0x57, 0x07, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2A};
44+
static uint8_t USER_HEADER_DNASLOAD[16] = {0x01, 0x00, 0x00, 0x04, 0x00, 0x06, 0x00, 0x4A, 0x00, 0x0E, 0x01, 0x00, 0x00, 0x00, 0x00, 0x02};
3645

3746
static uint8_t USER_HEADER_NAMCO_SECURITY_DONGLE_BOOTFILE[16] = {0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00};
3847

src/kelftool.cpp

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -93,15 +93,18 @@ int encrypt(int argc, char **argv)
9393
}
9494

9595
if (strcmp("fmcb", argv[1]) == 0)
96-
headerid = 0;
96+
headerid = HEADER::FMCB;
9797

9898
if (strcmp("fhdb", argv[1]) == 0)
99-
headerid = 1;
99+
headerid = HEADER::FHDB;
100100

101101
if (strcmp("mbr", argv[1]) == 0)
102-
headerid = 2;
102+
headerid = HEADER::MBR;
103103

104-
if (headerid == -1) {
104+
if (strcmp("dnasload", argv[1]) == 0)
105+
headerid = HEADER::DNASLOAD;
106+
107+
if (headerid == HEADER::INVALID) {
105108

106109
printf("Invalid header: %s\n", argv[1]);
107110
return -1;
@@ -141,12 +144,13 @@ int main(int argc, char **argv)
141144
printf("Available submodules:\n");
142145
printf("\tdecrypt - decrypt and check signature of kelf files\n");
143146
printf("\tencrypt <headerid> - encrypt and sign kelf files <headerid>: fmcb, fhdb, mbr\n");
144-
printf("\t\tfmcb - for retail PS2 memory cards\n");
145-
printf("\t\tfhdb - for retail PS2 HDD (HDD OSD / BB Navigator)\n");
146-
printf("\t\tmbr - for retail PS2 HDD (mbr injection).\n");
147-
printf("\t\t Note: for mbr elf should load from 0x100000 and should be without headers:\n");
148-
printf("\t\t readelf -h <input_elf> should show 0x100000 or 0x100008\n");
149-
printf("\t\t $(EE_OBJCOPY) -O binary -v <input_elf> <headerless_elf>\n");
147+
printf("\t\tfmcb - for retail PS2 memory cards\n");
148+
printf("\t\tdnasload - for retail PS2 memory cardsfor retail PS2 memory cards (PSX Whitelist)\n");
149+
printf("\t\tfhdb - for retail PS2 HDD (HDD OSD / BB Navigator)\n");
150+
printf("\t\tmbr - for retail PS2 HDD (mbr injection).\n");
151+
printf("\t\t Note: for mbr elf should load from 0x100000 and should be without headers:\n");
152+
printf("\t\t readelf -h <input_elf> should show 0x100000 or 0x100008\n");
153+
printf("\t\t $(EE_OBJCOPY) -O binary -v <input_elf> <headerless_elf>\n");
150154
return -1;
151155
}
152156

0 commit comments

Comments
 (0)