Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
julesontheroad authored Nov 11, 2018
1 parent ef484e4 commit 5788ad1
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 28 deletions.
37 changes: 19 additions & 18 deletions ztools/Fs/Nsp.py
Original file line number Diff line number Diff line change
Expand Up @@ -493,26 +493,27 @@ def copy_nca_meta(self,ofolder,buffer):
break
fp.close()

def copy_pfs0(self,ofolder,buffer):
def copy_pfs0_meta(self,ofolder,buffer):
for nca in self:
if type(nca) == Nca:
for f in nca:
nca.rewind()
f.rewind()
filename = str(f._path)
outfolder = str(ofolder)+'/'
filepath = os.path.join(outfolder, filename)
if not os.path.exists(outfolder):
os.makedirs(outfolder)
fp = open(filepath, 'w+b')
nca.rewind()
f.rewind()
for data in iter(lambda:f.read(int(buffer)), ""):
fp.write(data)
fp.flush()
if not data:
break
fp.close()
if str(nca.header.contentType) == 'Content.META':
for f in nca:
nca.rewind()
f.rewind()
filename = 'PFS0'
outfolder = str(ofolder)+'/'
filepath = os.path.join(outfolder, filename)
if not os.path.exists(outfolder):
os.makedirs(outfolder)
fp = open(filepath, 'w+b')
nca.rewind()
f.rewind()
for data in iter(lambda:f.read(int(buffer)), ""):
fp.write(data)
fp.flush()
if not data:
break
fp.close()

def copy_cnmt(self,ofolder,buffer):
for nca in self:
Expand Down
14 changes: 8 additions & 6 deletions ztools/Fs/Xci.py
Original file line number Diff line number Diff line change
Expand Up @@ -348,9 +348,10 @@ def cr_tr_nca(self,ofolder,buffer):
Print.info('masterKeyRev =\t' + hex(masterKeyRev))
for nca in nspF:
if type(nca) == Nca:
if nca.header.getCryptoType2() != masterKeyRev:
pass
raise IOError('Mismatched masterKeyRevs!')
if nca.header.getRightsId() != 0:
if nca.header.getCryptoType2() != masterKeyRev:
pass
raise IOError('Mismatched masterKeyRevs!')
for nca in nspF:
vfragment="false"
if type(nca) == Nca:
Expand Down Expand Up @@ -413,9 +414,10 @@ def cr_tr_nca_nd(self,ofolder,buffer):
Print.info('masterKeyRev =\t' + hex(masterKeyRev))
for nca in nspF:
if type(nca) == Nca:
if nca.header.getCryptoType2() != masterKeyRev:
pass
raise IOError('Mismatched masterKeyRevs!')
if nca.header.getRightsId() != 0:
if nca.header.getCryptoType2() != masterKeyRev:
pass
raise IOError('Mismatched masterKeyRevs!')
for nca in nspF:
vfragment="false"
if type(nca) == Nca:
Expand Down
Binary file modified ztools/Fs/__pycache__/Nsp.cpython-37.pyc
Binary file not shown.
Binary file modified ztools/Fs/__pycache__/Xci.cpython-37.pyc
Binary file not shown.
8 changes: 5 additions & 3 deletions ztools/XCI.bat
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,13 @@ FINDSTR /I ".nca" "%w_folder%\lisfiles.txt">"%w_folder%\nca_list.txt"
del "%w_folder%\lisfiles.txt"

setlocal enabledelayedexpansion
FINDSTR /R /N "^.*" "%w_folder%\nca_list.txt" | FIND /C ":">"%w_folder%\nca_number.txt"
set nca_number=
for /f "tokens=*" %%f in (%w_folder%\nca_list.txt) do (
set /a nca_number=!nca_number! + 1
)
del "%w_folder%\nca_list.txt"
set /p nca_number=<"%w_folder%\nca_number.txt"
del "%w_folder%\nca_number.txt"
::echo !nca_number!

if !nca_number! LEQ 3 goto c1dummy
if !nca_number! LEQ 2 goto c2dummy
if !nca_number! LEQ 1 goto c3dummy
Expand Down
25 changes: 24 additions & 1 deletion ztools/nut_RTR.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
parser.add_argument('--NSP_copy_cert', nargs='+', help='Extracts cert files from target nsp')
parser.add_argument('--NSP_copy_jpg', nargs='+', help='Extracts jpg files from target nsp')
parser.add_argument('--NSP_copy_cnmt', nargs='+', help='Extracts cnmt files from target nsp')
parser.add_argument('--copy_pfs0_meta', nargs='+', help='Extracts meta pfs0 from target nsp')
parser.add_argument('--NSP_copy_ncap', nargs='+', help='Extracts ncap files from target nsp')

# XCI Copy functions
Expand Down Expand Up @@ -100,7 +101,6 @@
parser.add_argument('-o', '--ofolder', nargs='+', help='Set output folder for copy instructions')
parser.add_argument('-b', '--buffer', nargs='+', help='Set buffer for copy instructions')
parser.add_argument('-ext', '--external', nargs='+', help='Set original nsp or ticket for remove nca titlerights functions')


args = parser.parse_args()

Expand Down Expand Up @@ -565,6 +565,29 @@
except BaseException as e:
Print.error('Exception: ' + str(e))

# ...................................................
# Copy pfs0 from NSP file
# ...................................................
if args.copy_pfs0_meta:
for input in args.ofolder:
try:
ofolder = input
except BaseException as e:
Print.error('Exception: ' + str(e))
for input in args.buffer:
try:
buffer = input
except BaseException as e:
Print.error('Exception: ' + str(e))
for fileName in args.copy_pfs0_meta:
try:
f = Fs.Nsp(fileName, 'r+b')
f.copy_pfs0(ofolder,buffer)
f.flush()
f.close()
except BaseException as e:
Print.error('Exception: ' + str(e))

# ...................................................
# Copy control ncap files from NSP file
# ...................................................
Expand Down

0 comments on commit 5788ad1

Please sign in to comment.