mirror of
https://github.com/shijimasoft/cia-unix.git
synced 2025-06-19 06:45:41 -04:00
Merge pull request #24 from R-YaTian/contentId
append content id to ncch filename
This commit is contained in:
commit
01fe17a1cd
@ -292,7 +292,7 @@ def parseCIA(fh):
|
|||||||
fh.seek(contentOffs + nextContentOffs)
|
fh.seek(contentOffs + nextContentOffs)
|
||||||
ciaHandle = ciaReader(fh, cEnc, titkey, cIdx, contentOffs + nextContentOffs)
|
ciaHandle = ciaReader(fh, cEnc, titkey, cIdx, contentOffs + nextContentOffs)
|
||||||
nextContentOffs = nextContentOffs + align(cSize, 64)
|
nextContentOffs = nextContentOffs + align(cSize, 64)
|
||||||
parseNCCH(ciaHandle, cSize, 0, cIdx, tid, 0, 0)
|
parseNCCH(ciaHandle, cSize, 0, cIdx, cId, tid, 0, 0)
|
||||||
|
|
||||||
|
|
||||||
def parseNCSD(fh):
|
def parseNCSD(fh):
|
||||||
@ -307,13 +307,14 @@ def parseNCSD(fh):
|
|||||||
header.offset_sizeTable[i].size * mediaUnitSize,
|
header.offset_sizeTable[i].size * mediaUnitSize,
|
||||||
header.offset_sizeTable[i].offset * mediaUnitSize,
|
header.offset_sizeTable[i].offset * mediaUnitSize,
|
||||||
i,
|
i,
|
||||||
|
i,
|
||||||
reverseCtypeArray(header.titleId),
|
reverseCtypeArray(header.titleId),
|
||||||
0,
|
0,
|
||||||
1,
|
1,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def parseNCCH(fh, fsize, offs=0, idx=0, titleId="", standAlone=1, fromNcsd=0):
|
def parseNCCH(fh, fsize, offs=0, idx=0, contentId=0, titleId="", standAlone=1, fromNcsd=0):
|
||||||
tab = '\t' if not standAlone else " "
|
tab = '\t' if not standAlone else " "
|
||||||
if not standAlone and fromNcsd:
|
if not standAlone and fromNcsd:
|
||||||
print(f" Parsing {ncsdPartitions[idx]} NCCH")
|
print(f" Parsing {ncsdPartitions[idx]} NCCH")
|
||||||
@ -331,6 +332,7 @@ def parseNCCH(fh, fsize, offs=0, idx=0, titleId="", standAlone=1, fromNcsd=0):
|
|||||||
print((tab + "KeyY: %032X" % ncchKeyY))
|
print((tab + "KeyY: %032X" % ncchKeyY))
|
||||||
print(tab + f"Title ID: {reverseCtypeArray(header.titleId)}")
|
print(tab + f"Title ID: {reverseCtypeArray(header.titleId)}")
|
||||||
print(tab + f"Format version: {header.formatVersion}")
|
print(tab + f"Format version: {header.formatVersion}")
|
||||||
|
print(tab + f"Content Id: %08X" % contentId)
|
||||||
usesExtraCrypto = bytearray(header.flags)[3]
|
usesExtraCrypto = bytearray(header.flags)[3]
|
||||||
if usesExtraCrypto:
|
if usesExtraCrypto:
|
||||||
print((tab + "Uses Extra NCCH crypto, keyslot 0x%X" % {1: 37, 10: 24, 11: 27}[usesExtraCrypto]))
|
print((tab + "Uses Extra NCCH crypto, keyslot 0x%X" % {1: 37, 10: 24, 11: 27}[usesExtraCrypto]))
|
||||||
@ -349,7 +351,7 @@ def parseNCCH(fh, fsize, offs=0, idx=0, titleId="", standAlone=1, fromNcsd=0):
|
|||||||
print((tab + "Uses 9.6 NCCH Seed crypto with KeyY: %032X" % keyY))
|
print((tab + "Uses 9.6 NCCH Seed crypto with KeyY: %032X" % keyY))
|
||||||
print("")
|
print("")
|
||||||
base = os.path.splitext(os.path.basename(fh.name))[0]
|
base = os.path.splitext(os.path.basename(fh.name))[0]
|
||||||
base += f".{(idx if fromNcsd == 0 else ncsdPartitions[idx])}.ncch"
|
base += f".{(idx if fromNcsd == 0 else ncsdPartitions[idx])}.%08X.ncch" % contentId
|
||||||
base = os.path.join(os.path.dirname(os.path.realpath(sys.argv[0])), base)
|
base = os.path.join(os.path.dirname(os.path.realpath(sys.argv[0])), base)
|
||||||
with open(base, "wb") as (f):
|
with open(base, "wb") as (f):
|
||||||
tmp = tmp[:399] + chr(tmp[399] & 2 | 4).encode() + tmp[400:]
|
tmp = tmp[:399] + chr(tmp[399] & 2 | 4).encode() + tmp[400:]
|
||||||
|
Loading…
Reference in New Issue
Block a user