diff --git a/src/kelf.cpp b/src/kelf.cpp
index ce5f152..92a50c5 100644
--- a/src/kelf.cpp
+++ b/src/kelf.cpp
@@ -155,20 +155,32 @@ int Kelf::LoadKelf(std::string filename)
return 0;
}
-int Kelf::SaveKelf(std::string filename)
+int Kelf::SaveKelf(std::string filename,int headerid)
{
FILE* f = fopen(filename.c_str(), "wb");
KELFHeader header;
- static uint8_t PSX_USER[] = { 0x01, 0x03, 0x00, 0x04, 0x00, 0x02, 0x00, 0x4A, 0x00, 0x07, 0x01, 0x00, 0x00, 0x00, 0x01, 0x78 };
+
+ static uint8_t *PSX_USER;
+
+ static uint8_t USER_HEADER_FMCB[]={ 0x01, 0x00, 0x00, 0x01, 0x00, 0x03, 0x00, 0x4A, 0x00, 0x01, 0x02, 0x19, 0x00, 0x00, 0x00, 0x56 };
+
+ static uint8_t USER_HEADER_FHDB[]={ 0x01, 0x00, 0x00, 0x04, 0x00, 0x02, 0x00, 0x4A, 0x00, 0x08, 0x01, 0x00, 0x00, 0x00, 0x00, 0x1B };
+
+
+ if(headerid==0)
+ PSX_USER = USER_HEADER_FMCB;
+ else
+ PSX_USER = USER_HEADER_FHDB;
+
memcpy(header.UserDefined, PSX_USER, 16);
header.ContentSize = Content.size();
header.HeaderSize = sizeof(KELFHeader) + 8 + 16 + 16 + 8 + 16 + 16 + 8 + 8; // header + header signature + kbit + kc + bittable + bittable signature + root signature
- header.SystemType = SYSTEM_TYPE_PSX;
+ header.SystemType = SYSTEM_TYPE_PS2;
header.ApplicationType = 1; // 1 = xosdmain, 5 = dvdplayer kirx 7 = dvdplayer kelf
header.Flags = 0x22C;
header.BitCount = 0;
- header.MGZones = 1; // Japan
+ header.MGZones = 0xFF; // ??
std::string HeaderSignature = GetHeaderSignature(header);
std::string BitTableSignature = GetBitTableSignature();
diff --git a/src/kelf.h b/src/kelf.h
index fc4bf62..0c024d4 100644
--- a/src/kelf.h
+++ b/src/kelf.h
@@ -73,7 +73,7 @@ class Kelf
Kelf(KeyStore& _ks) : ks(_ks) { }
int LoadKelf(std::string filename);
- int SaveKelf(std::string filename);
+ int SaveKelf(std::string filename,int header);
int LoadContent(std::string filename);
int SaveContent(std::string filename);
@@ -87,4 +87,4 @@ class Kelf
int VerifyContentSignature();
};
-#endif
\ No newline at end of file
+#endif
diff --git a/src/kelftool.cpp b/src/kelftool.cpp
index c952e8a..6893d64 100644
--- a/src/kelftool.cpp
+++ b/src/kelftool.cpp
@@ -31,7 +31,7 @@ std::string getKeyStorePath()
int decrypt(int argc, char** argv)
{
- if (argc < 2)
+ if (argc < 3)
{
printf("%s decrypt