mirror of
https://github.com/ihaveamac/custom-install.git
synced 2026-01-21 22:15:59 +00:00
Compare commits
32 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d12684d8bf | ||
|
|
54ae8a504c | ||
|
|
d97e11e4ec | ||
|
|
c3448c388e | ||
|
|
4d7be0812e | ||
|
|
8c60eecec5 | ||
|
|
653569093d | ||
|
|
adccac9ee7 | ||
|
|
8629cbee8e | ||
|
|
740844e57a | ||
|
|
d847043045 | ||
|
|
217a508bf3 | ||
|
|
42ec2d760a | ||
|
|
938d8fd6aa | ||
|
|
ac0be9d61d | ||
|
|
d231e9c043 | ||
|
|
9c3c4ce5f9 | ||
|
|
6a324b9388 | ||
|
|
647e56cf05 | ||
|
|
643e4e4976 | ||
|
|
09ed0093df | ||
|
|
9b7346c919 | ||
|
|
38f5e2b0e6 | ||
|
|
f48e177604 | ||
|
|
4ca2c59b5a | ||
|
|
7a68b23365 | ||
|
|
1dec5175ea | ||
|
|
4d223ed931 | ||
|
|
46a0d985a7 | ||
|
|
37112682a0 | ||
|
|
9c777adf26 | ||
|
|
b3eae08f27 |
3
.gitignore
vendored
3
.gitignore
vendored
@@ -18,3 +18,6 @@ venv/
|
|||||||
=======
|
=======
|
||||||
|
|
||||||
*.pyc
|
*.pyc
|
||||||
|
/build/
|
||||||
|
/dist/
|
||||||
|
/custom-install-finalize.3dsx
|
||||||
|
|||||||
161
ci-gui.py
161
ci-gui.py
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
from os import environ, scandir
|
from os import environ, scandir
|
||||||
from os.path import abspath, basename, dirname, join, isfile
|
from os.path import abspath, basename, dirname, join, isfile
|
||||||
from sys import exc_info, platform
|
import sys
|
||||||
from threading import Thread, Lock
|
from threading import Thread, Lock
|
||||||
from time import strftime
|
from time import strftime
|
||||||
from traceback import format_exception
|
from traceback import format_exception
|
||||||
@@ -16,20 +16,28 @@ import tkinter.filedialog as fd
|
|||||||
import tkinter.messagebox as mb
|
import tkinter.messagebox as mb
|
||||||
from typing import TYPE_CHECKING
|
from typing import TYPE_CHECKING
|
||||||
|
|
||||||
|
from pyctr.crypto import MissingSeedError, CryptoEngine, load_seeddb
|
||||||
from pyctr.crypto.engine import b9_paths
|
from pyctr.crypto.engine import b9_paths
|
||||||
from pyctr.util import config_dirs
|
from pyctr.util import config_dirs
|
||||||
from pyctr.type.cdn import CDNError
|
from pyctr.type.cdn import CDNError
|
||||||
from pyctr.type.cia import CIAError
|
from pyctr.type.cia import CIAError
|
||||||
from pyctr.type.tmd import TitleMetadataError
|
from pyctr.type.tmd import TitleMetadataError
|
||||||
|
|
||||||
from custominstall import CustomInstall, CI_VERSION, load_cifinish, InvalidCIFinishError
|
from custominstall import CustomInstall, CI_VERSION, load_cifinish, InvalidCIFinishError, InstallStatus
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from typing import Dict, List
|
from os import PathLike
|
||||||
|
from typing import Dict, List, Union
|
||||||
|
|
||||||
is_windows = platform == 'win32'
|
frozen = getattr(sys, 'frozen', None)
|
||||||
|
is_windows = sys.platform == 'win32'
|
||||||
taskbar = None
|
taskbar = None
|
||||||
if is_windows:
|
if is_windows:
|
||||||
|
if frozen:
|
||||||
|
# attempt to fix loading tcl/tk when running from a path with non-latin characters
|
||||||
|
tkinter_path = dirname(tk.__file__)
|
||||||
|
tcl_path = join(tkinter_path, 'tcl8.6')
|
||||||
|
environ['TCL_LIBRARY'] = 'lib/tkinter/tcl8.6'
|
||||||
try:
|
try:
|
||||||
import comtypes.client as cc
|
import comtypes.client as cc
|
||||||
|
|
||||||
@@ -37,7 +45,7 @@ if is_windows:
|
|||||||
|
|
||||||
taskbar = cc.CreateObject('{56FDF344-FD6D-11D0-958A-006097C9A090}', interface=tbl.ITaskbarList3)
|
taskbar = cc.CreateObject('{56FDF344-FD6D-11D0-958A-006097C9A090}', interface=tbl.ITaskbarList3)
|
||||||
taskbar.HrInit()
|
taskbar.HrInit()
|
||||||
except ModuleNotFoundError:
|
except (ModuleNotFoundError, UnicodeEncodeError, AttributeError):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
file_parent = dirname(abspath(__file__))
|
file_parent = dirname(abspath(__file__))
|
||||||
@@ -70,6 +78,18 @@ default_b9_path = find_first_file(b9_paths)
|
|||||||
default_seeddb_path = find_first_file(seeddb_paths)
|
default_seeddb_path = find_first_file(seeddb_paths)
|
||||||
default_movable_sed_path = find_first_file([join(file_parent, 'movable.sed')])
|
default_movable_sed_path = find_first_file([join(file_parent, 'movable.sed')])
|
||||||
|
|
||||||
|
if default_seeddb_path:
|
||||||
|
load_seeddb(default_seeddb_path)
|
||||||
|
|
||||||
|
statuses = {
|
||||||
|
InstallStatus.Waiting: 'Waiting',
|
||||||
|
InstallStatus.Starting: 'Starting',
|
||||||
|
InstallStatus.Writing: 'Writing',
|
||||||
|
InstallStatus.Finishing: 'Finishing',
|
||||||
|
InstallStatus.Done: 'Done',
|
||||||
|
InstallStatus.Failed: 'Failed',
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
class ConsoleFrame(ttk.Frame):
|
class ConsoleFrame(ttk.Frame):
|
||||||
def __init__(self, parent: tk.BaseWidget = None, starting_lines: 'List[str]' = None):
|
def __init__(self, parent: tk.BaseWidget = None, starting_lines: 'List[str]' = None):
|
||||||
@@ -176,7 +196,8 @@ class TitleReadFailResults(tk.Toplevel):
|
|||||||
|
|
||||||
|
|
||||||
class InstallResults(tk.Toplevel):
|
class InstallResults(tk.Toplevel):
|
||||||
def __init__(self, parent: tk.Tk = None, *, install_state: 'Dict[str, List[str]]', copied_3dsx: bool):
|
def __init__(self, parent: tk.Tk = None, *, install_state: 'Dict[str, List[str]]', copied_3dsx: bool,
|
||||||
|
application_count: int):
|
||||||
super().__init__(parent)
|
super().__init__(parent)
|
||||||
self.parent = parent
|
self.parent = parent
|
||||||
|
|
||||||
@@ -209,6 +230,11 @@ class InstallResults(tk.Toplevel):
|
|||||||
if install_state['installed'] and copied_3dsx:
|
if install_state['installed'] and copied_3dsx:
|
||||||
message += '\n\ncustom-install-finalize has been copied to the SD card.'
|
message += '\n\ncustom-install-finalize has been copied to the SD card.'
|
||||||
|
|
||||||
|
if application_count >= 300:
|
||||||
|
message += (f'\n\nWarning: {application_count} installed applications were detected.\n'
|
||||||
|
f'The HOME Menu will only show 300 icons.\n'
|
||||||
|
f'Some applications (not updates or DLC) will need to be deleted.')
|
||||||
|
|
||||||
message_label = ttk.Label(outer_container, text=message)
|
message_label = ttk.Label(outer_container, text=message)
|
||||||
message_label.grid(row=0, column=0, sticky=tk.NSEW, padx=10, pady=10)
|
message_label.grid(row=0, column=0, sticky=tk.NSEW, padx=10, pady=10)
|
||||||
|
|
||||||
@@ -235,6 +261,7 @@ class InstallResults(tk.Toplevel):
|
|||||||
|
|
||||||
class CustomInstallGUI(ttk.Frame):
|
class CustomInstallGUI(ttk.Frame):
|
||||||
console = None
|
console = None
|
||||||
|
b9_loaded = False
|
||||||
|
|
||||||
def __init__(self, parent: tk.Tk = None):
|
def __init__(self, parent: tk.Tk = None):
|
||||||
super().__init__(parent)
|
super().__init__(parent)
|
||||||
@@ -285,12 +312,14 @@ class CustomInstallGUI(ttk.Frame):
|
|||||||
sd_selected.delete('1.0', tk.END)
|
sd_selected.delete('1.0', tk.END)
|
||||||
sd_selected.insert(tk.END, f)
|
sd_selected.insert(tk.END, f)
|
||||||
|
|
||||||
sd_msed_path = find_first_file([join(f, 'gm9', 'out', 'movable.sed'), join(f, 'movable.sed')])
|
for filename in ['boot9.bin', 'seeddb.bin', 'movable.sed']:
|
||||||
if sd_msed_path:
|
path = auto_input_filename(self, f, filename)
|
||||||
self.log('Found movable.sed on SD card at ' + sd_msed_path)
|
if filename == 'boot9.bin':
|
||||||
box = self.file_picker_textboxes['movable.sed']
|
self.check_b9_loaded()
|
||||||
box.delete('1.0', tk.END)
|
self.enable_buttons()
|
||||||
box.insert(tk.END, sd_msed_path)
|
if filename == 'seeddb.bin':
|
||||||
|
load_seeddb(path)
|
||||||
|
|
||||||
|
|
||||||
sd_type_label = ttk.Label(file_pickers, text='SD root')
|
sd_type_label = ttk.Label(file_pickers, text='SD root')
|
||||||
sd_type_label.grid(row=0, column=0)
|
sd_type_label.grid(row=0, column=0)
|
||||||
@@ -303,14 +332,25 @@ class CustomInstallGUI(ttk.Frame):
|
|||||||
|
|
||||||
self.file_picker_textboxes['sd'] = sd_selected
|
self.file_picker_textboxes['sd'] = sd_selected
|
||||||
|
|
||||||
|
def auto_input_filename(self, f, filename):
|
||||||
|
sd_msed_path = find_first_file([join(f, 'gm9', 'out', filename), join(f, filename)])
|
||||||
|
if sd_msed_path:
|
||||||
|
self.log('Found ' + filename + ' on SD card at ' + sd_msed_path)
|
||||||
|
if filename.endswith('bin'):
|
||||||
|
filename = filename.split('.')[0]
|
||||||
|
box = self.file_picker_textboxes[filename]
|
||||||
|
box.delete('1.0', tk.END)
|
||||||
|
box.insert(tk.END, sd_msed_path)
|
||||||
|
return sd_msed_path
|
||||||
# This feels so wrong.
|
# This feels so wrong.
|
||||||
def create_required_file_picker(type_name, types, default, row):
|
def create_required_file_picker(type_name, types, default, row, callback=lambda filename: None):
|
||||||
def internal_callback():
|
def internal_callback():
|
||||||
f = fd.askopenfilename(parent=parent, title='Select ' + type_name, filetypes=types,
|
f = fd.askopenfilename(parent=parent, title='Select ' + type_name, filetypes=types,
|
||||||
initialdir=file_parent)
|
initialdir=file_parent)
|
||||||
if f:
|
if f:
|
||||||
selected.delete('1.0', tk.END)
|
selected.delete('1.0', tk.END)
|
||||||
selected.insert(tk.END, f)
|
selected.insert(tk.END, f)
|
||||||
|
callback(f)
|
||||||
|
|
||||||
type_label = ttk.Label(file_pickers, text=type_name)
|
type_label = ttk.Label(file_pickers, text=type_name)
|
||||||
type_label.grid(row=row, column=0)
|
type_label.grid(row=row, column=0)
|
||||||
@@ -325,8 +365,15 @@ class CustomInstallGUI(ttk.Frame):
|
|||||||
|
|
||||||
self.file_picker_textboxes[type_name] = selected
|
self.file_picker_textboxes[type_name] = selected
|
||||||
|
|
||||||
create_required_file_picker('boot9', [('boot9 file', '*.bin')], default_b9_path, 1)
|
def b9_callback(path: 'Union[PathLike, bytes, str]'):
|
||||||
create_required_file_picker('seeddb', [('seeddb file', '*.bin')], default_seeddb_path, 2)
|
self.check_b9_loaded()
|
||||||
|
self.enable_buttons()
|
||||||
|
|
||||||
|
def seeddb_callback(path: 'Union[PathLike, bytes, str]'):
|
||||||
|
load_seeddb(path)
|
||||||
|
|
||||||
|
create_required_file_picker('boot9', [('boot9 file', '*.bin')], default_b9_path, 1, b9_callback)
|
||||||
|
create_required_file_picker('seeddb', [('seeddb file', '*.bin')], default_seeddb_path, 2, seeddb_callback)
|
||||||
create_required_file_picker('movable.sed', [('movable.sed file', '*.sed')], default_movable_sed_path, 3)
|
create_required_file_picker('movable.sed', [('movable.sed file', '*.sed')], default_movable_sed_path, 3)
|
||||||
|
|
||||||
# ---------------------------------------------------------------- #
|
# ---------------------------------------------------------------- #
|
||||||
@@ -404,14 +451,16 @@ class CustomInstallGUI(ttk.Frame):
|
|||||||
|
|
||||||
self.treeview = ttk.Treeview(treeview_frame, yscrollcommand=treeview_scrollbar.set)
|
self.treeview = ttk.Treeview(treeview_frame, yscrollcommand=treeview_scrollbar.set)
|
||||||
self.treeview.grid(row=0, column=0, sticky=tk.NSEW)
|
self.treeview.grid(row=0, column=0, sticky=tk.NSEW)
|
||||||
self.treeview.configure(columns=('filepath', 'titleid', 'titlename'), show='headings')
|
self.treeview.configure(columns=('filepath', 'titleid', 'titlename', 'status'), show='headings')
|
||||||
|
|
||||||
self.treeview.column('filepath', width=200, anchor=tk.W)
|
self.treeview.column('filepath', width=200, anchor=tk.W)
|
||||||
self.treeview.heading('filepath', text='File path')
|
self.treeview.heading('filepath', text='File path')
|
||||||
self.treeview.column('titleid', width=50, anchor=tk.W)
|
self.treeview.column('titleid', width=70, anchor=tk.W)
|
||||||
self.treeview.heading('titleid', text='Title ID')
|
self.treeview.heading('titleid', text='Title ID')
|
||||||
self.treeview.column('titlename', width=150, anchor=tk.W)
|
self.treeview.column('titlename', width=150, anchor=tk.W)
|
||||||
self.treeview.heading('titlename', text='Title name')
|
self.treeview.heading('titlename', text='Title name')
|
||||||
|
self.treeview.column('status', width=20, anchor=tk.W)
|
||||||
|
self.treeview.heading('status', text='Status')
|
||||||
|
|
||||||
treeview_scrollbar.configure(command=self.treeview.yview)
|
treeview_scrollbar.configure(command=self.treeview.yview)
|
||||||
|
|
||||||
@@ -449,12 +498,18 @@ class CustomInstallGUI(ttk.Frame):
|
|||||||
self.log(f'custom-install {CI_VERSION} - https://github.com/ihaveamac/custom-install', status=False)
|
self.log(f'custom-install {CI_VERSION} - https://github.com/ihaveamac/custom-install', status=False)
|
||||||
|
|
||||||
if is_windows and not taskbar:
|
if is_windows and not taskbar:
|
||||||
self.log('Note: comtypes module not found.')
|
self.log('Note: Could not load taskbar lib.')
|
||||||
self.log('Note: Progress will not be shown in the Windows taskbar.')
|
self.log('Note: Progress will not be shown in the Windows taskbar.')
|
||||||
|
|
||||||
self.log('Ready.')
|
self.log('Ready.')
|
||||||
|
|
||||||
self.disable_during_install = (add_cias, add_dirs, remove_selected, start, *self.file_picker_textboxes.values())
|
self.require_boot9 = (add_cias, add_cdn, add_dirs, remove_selected, start)
|
||||||
|
|
||||||
|
self.disable_buttons()
|
||||||
|
self.check_b9_loaded()
|
||||||
|
self.enable_buttons()
|
||||||
|
if not self.b9_loaded:
|
||||||
|
self.log('Note: boot9 was not auto-detected. Please choose it before adding any titles.')
|
||||||
|
|
||||||
def sort_treeview(self):
|
def sort_treeview(self):
|
||||||
l = [(self.treeview.set(k, 'titlename'), k) for k in self.treeview.get_children()]
|
l = [(self.treeview.set(k, 'titlename'), k) for k in self.treeview.get_children()]
|
||||||
@@ -464,7 +519,23 @@ class CustomInstallGUI(ttk.Frame):
|
|||||||
for idx, pair in enumerate(l):
|
for idx, pair in enumerate(l):
|
||||||
self.treeview.move(pair[1], '', idx)
|
self.treeview.move(pair[1], '', idx)
|
||||||
|
|
||||||
|
def check_b9_loaded(self):
|
||||||
|
if not self.b9_loaded:
|
||||||
|
boot9 = self.file_picker_textboxes['boot9'].get('1.0', tk.END).strip()
|
||||||
|
try:
|
||||||
|
tmp_crypto = CryptoEngine(boot9=boot9)
|
||||||
|
self.b9_loaded = tmp_crypto.b9_keys_set
|
||||||
|
except:
|
||||||
|
return False
|
||||||
|
return self.b9_loaded
|
||||||
|
|
||||||
|
def update_status(self, path: 'Union[PathLike, bytes, str]', status: InstallStatus):
|
||||||
|
self.treeview.set(path, 'status', statuses[status])
|
||||||
|
|
||||||
def add_cia(self, path):
|
def add_cia(self, path):
|
||||||
|
if not self.check_b9_loaded():
|
||||||
|
# this shouldn't happen
|
||||||
|
return False, 'Please choose boot9 first'
|
||||||
path = abspath(path)
|
path = abspath(path)
|
||||||
if path in self.readers:
|
if path in self.readers:
|
||||||
return False, 'File already in list'
|
return False, 'File already in list'
|
||||||
@@ -472,6 +543,8 @@ class CustomInstallGUI(ttk.Frame):
|
|||||||
reader = CustomInstall.get_reader(path)
|
reader = CustomInstall.get_reader(path)
|
||||||
except (CIAError, CDNError, TitleMetadataError):
|
except (CIAError, CDNError, TitleMetadataError):
|
||||||
return False, 'Failed to read as a CIA or CDN title, probably corrupt'
|
return False, 'Failed to read as a CIA or CDN title, probably corrupt'
|
||||||
|
except MissingSeedError:
|
||||||
|
return False, 'Latest seeddb.bin is required, check the README for details'
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
return False, f'Exception occurred: {type(e).__name__}: {e}'
|
return False, f'Exception occurred: {type(e).__name__}: {e}'
|
||||||
|
|
||||||
@@ -481,7 +554,8 @@ class CustomInstallGUI(ttk.Frame):
|
|||||||
title_name = reader.contents[0].exefs.icon.get_app_title().short_desc
|
title_name = reader.contents[0].exefs.icon.get_app_title().short_desc
|
||||||
except:
|
except:
|
||||||
title_name = '(No title)'
|
title_name = '(No title)'
|
||||||
self.treeview.insert('', tk.END, text=path, iid=path, values=(path, reader.tmd.title_id, title_name))
|
self.treeview.insert('', tk.END, text=path, iid=path,
|
||||||
|
values=(path, reader.tmd.title_id, title_name, statuses[InstallStatus.Waiting]))
|
||||||
self.readers[path] = reader
|
self.readers[path] = reader
|
||||||
return True, ''
|
return True, ''
|
||||||
|
|
||||||
@@ -532,25 +606,26 @@ class CustomInstallGUI(ttk.Frame):
|
|||||||
mb.showinfo('Info', message, parent=self.parent)
|
mb.showinfo('Info', message, parent=self.parent)
|
||||||
|
|
||||||
def disable_buttons(self):
|
def disable_buttons(self):
|
||||||
for b in self.disable_during_install:
|
for b in self.require_boot9:
|
||||||
|
b.config(state=tk.DISABLED)
|
||||||
|
for b in self.file_picker_textboxes.values():
|
||||||
b.config(state=tk.DISABLED)
|
b.config(state=tk.DISABLED)
|
||||||
|
|
||||||
def enable_buttons(self):
|
def enable_buttons(self):
|
||||||
for b in self.disable_during_install:
|
if self.b9_loaded:
|
||||||
|
for b in self.require_boot9:
|
||||||
|
b.config(state=tk.NORMAL)
|
||||||
|
for b in self.file_picker_textboxes.values():
|
||||||
b.config(state=tk.NORMAL)
|
b.config(state=tk.NORMAL)
|
||||||
|
|
||||||
def start_install(self):
|
def start_install(self):
|
||||||
sd_root = self.file_picker_textboxes['sd'].get('1.0', tk.END).strip()
|
sd_root = self.file_picker_textboxes['sd'].get('1.0', tk.END).strip()
|
||||||
boot9 = self.file_picker_textboxes['boot9'].get('1.0', tk.END).strip()
|
|
||||||
seeddb = self.file_picker_textboxes['seeddb'].get('1.0', tk.END).strip()
|
seeddb = self.file_picker_textboxes['seeddb'].get('1.0', tk.END).strip()
|
||||||
movable_sed = self.file_picker_textboxes['movable.sed'].get('1.0', tk.END).strip()
|
movable_sed = self.file_picker_textboxes['movable.sed'].get('1.0', tk.END).strip()
|
||||||
|
|
||||||
if not sd_root:
|
if not sd_root:
|
||||||
self.show_error('SD root is not specified.')
|
self.show_error('SD root is not specified.')
|
||||||
return
|
return
|
||||||
if not boot9:
|
|
||||||
self.show_error('boot9 is not specified.')
|
|
||||||
return
|
|
||||||
if not movable_sed:
|
if not movable_sed:
|
||||||
self.show_error('movable.sed is not specified.')
|
self.show_error('movable.sed is not specified.')
|
||||||
return
|
return
|
||||||
@@ -560,29 +635,37 @@ class CustomInstallGUI(ttk.Frame):
|
|||||||
'Continue?'):
|
'Continue?'):
|
||||||
return
|
return
|
||||||
|
|
||||||
self.disable_buttons()
|
|
||||||
|
|
||||||
if not len(self.readers):
|
if not len(self.readers):
|
||||||
self.show_error('There are no titles added to install.')
|
self.show_error('There are no titles added to install.')
|
||||||
return
|
return
|
||||||
|
|
||||||
self.log('Starting install...')
|
for path in self.readers.keys():
|
||||||
|
self.update_status(path, InstallStatus.Waiting)
|
||||||
|
self.disable_buttons()
|
||||||
|
|
||||||
if taskbar:
|
if taskbar:
|
||||||
taskbar.SetProgressState(self.hwnd, tbl.TBPF_NORMAL)
|
taskbar.SetProgressState(self.hwnd, tbl.TBPF_NORMAL)
|
||||||
|
|
||||||
installer = CustomInstall(boot9=boot9,
|
installer = CustomInstall(movable=movable_sed,
|
||||||
seeddb=seeddb,
|
|
||||||
movable=movable_sed,
|
|
||||||
sd=sd_root,
|
sd=sd_root,
|
||||||
skip_contents=self.skip_contents_var.get() == 1,
|
skip_contents=self.skip_contents_var.get() == 1,
|
||||||
overwrite_saves=self.overwrite_saves_var.get() == 1)
|
overwrite_saves=self.overwrite_saves_var.get() == 1)
|
||||||
|
|
||||||
|
if not installer.check_for_id0():
|
||||||
|
self.show_error(f'id0 {installer.crypto.id0.hex()} was not found inside "Nintendo 3DS" on the SD card.\n'
|
||||||
|
f'\n'
|
||||||
|
f'Before using custom-install, you should use this SD card on the appropriate console.\n'
|
||||||
|
f'\n'
|
||||||
|
f'Otherwise, make sure the correct movable.sed is being used.')
|
||||||
|
return
|
||||||
|
|
||||||
|
self.log('Starting install...')
|
||||||
|
|
||||||
# use the treeview which has been sorted alphabetically
|
# use the treeview which has been sorted alphabetically
|
||||||
#installer.readers = self.readers.values()
|
|
||||||
readers_final = []
|
readers_final = []
|
||||||
for k in self.treeview.get_children():
|
for k in self.treeview.get_children():
|
||||||
readers_final.append(self.readers[self.treeview.set(k, 'filepath')])
|
filepath = self.treeview.set(k, 'filepath')
|
||||||
|
readers_final.append((self.readers[filepath], filepath))
|
||||||
|
|
||||||
installer.readers = readers_final
|
installer.readers = readers_final
|
||||||
|
|
||||||
@@ -618,6 +701,7 @@ class CustomInstallGUI(ttk.Frame):
|
|||||||
installer.event.update_percentage += ci_update_percentage
|
installer.event.update_percentage += ci_update_percentage
|
||||||
installer.event.on_error += ci_on_error
|
installer.event.on_error += ci_on_error
|
||||||
installer.event.on_cia_start += ci_on_cia_start
|
installer.event.on_cia_start += ci_on_cia_start
|
||||||
|
installer.event.update_status += self.update_status
|
||||||
|
|
||||||
if self.skip_contents_var.get() != 1:
|
if self.skip_contents_var.get() != 1:
|
||||||
total_size, free_space = installer.check_size()
|
total_size, free_space = installer.check_size()
|
||||||
@@ -630,16 +714,19 @@ class CustomInstallGUI(ttk.Frame):
|
|||||||
|
|
||||||
def install():
|
def install():
|
||||||
try:
|
try:
|
||||||
result, copied_3dsx = installer.start()
|
result, copied_3dsx, application_count = installer.start()
|
||||||
if result:
|
if result:
|
||||||
result_window = InstallResults(self.parent, install_state=result, copied_3dsx=copied_3dsx)
|
result_window = InstallResults(self.parent,
|
||||||
|
install_state=result,
|
||||||
|
copied_3dsx=copied_3dsx,
|
||||||
|
application_count=application_count)
|
||||||
result_window.focus()
|
result_window.focus()
|
||||||
elif result is None:
|
elif result is None:
|
||||||
self.show_error("An error occurred when trying to run save3ds_fuse.\n"
|
self.show_error("An error occurred when trying to run save3ds_fuse.\n"
|
||||||
"Either title.db doesn't exist, or save3ds_fuse couldn't be run.")
|
"Either title.db doesn't exist, or save3ds_fuse couldn't be run.")
|
||||||
self.open_console()
|
self.open_console()
|
||||||
except:
|
except:
|
||||||
installer.event.on_error(exc_info())
|
installer.event.on_error(sys.exc_info())
|
||||||
finally:
|
finally:
|
||||||
self.enable_buttons()
|
self.enable_buttons()
|
||||||
|
|
||||||
|
|||||||
109
custominstall.py
109
custominstall.py
@@ -5,11 +5,13 @@
|
|||||||
# You can find the full license text in LICENSE.md in the root of this project.
|
# You can find the full license text in LICENSE.md in the root of this project.
|
||||||
|
|
||||||
from argparse import ArgumentParser
|
from argparse import ArgumentParser
|
||||||
|
from enum import Enum
|
||||||
|
from glob import glob
|
||||||
|
import gzip
|
||||||
from os import makedirs, rename, scandir
|
from os import makedirs, rename, scandir
|
||||||
from os.path import dirname, join, isdir, isfile
|
from os.path import dirname, join, isdir, isfile
|
||||||
from random import randint
|
from random import randint
|
||||||
from hashlib import sha256
|
from hashlib import sha256
|
||||||
from locale import getpreferredencoding
|
|
||||||
from pprint import pformat
|
from pprint import pformat
|
||||||
from shutil import copyfile, copy2, rmtree
|
from shutil import copyfile, copy2, rmtree
|
||||||
import sys
|
import sys
|
||||||
@@ -21,7 +23,7 @@ import subprocess
|
|||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from os import PathLike
|
from os import PathLike
|
||||||
from typing import List, Union
|
from typing import List, Union, Tuple
|
||||||
|
|
||||||
from events import Events
|
from events import Events
|
||||||
|
|
||||||
@@ -42,7 +44,7 @@ if is_windows:
|
|||||||
else:
|
else:
|
||||||
from os import statvfs
|
from os import statvfs
|
||||||
|
|
||||||
CI_VERSION = '2.1b1'
|
CI_VERSION = '2.1'
|
||||||
|
|
||||||
# used to run the save3ds_fuse binary next to the script
|
# used to run the save3ds_fuse binary next to the script
|
||||||
frozen = getattr(sys, 'frozen', False)
|
frozen = getattr(sys, 'frozen', False)
|
||||||
@@ -74,6 +76,15 @@ class InvalidCIFinishError(Exception):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class InstallStatus(Enum):
|
||||||
|
Waiting = 0
|
||||||
|
Starting = 1
|
||||||
|
Writing = 2
|
||||||
|
Finishing = 3
|
||||||
|
Done = 4
|
||||||
|
Failed = 5
|
||||||
|
|
||||||
|
|
||||||
def get_free_space(path: 'Union[PathLike, bytes, str]'):
|
def get_free_space(path: 'Union[PathLike, bytes, str]'):
|
||||||
if is_windows:
|
if is_windows:
|
||||||
lpSectorsPerCluster = c_ulonglong(0)
|
lpSectorsPerCluster = c_ulonglong(0)
|
||||||
@@ -191,15 +202,15 @@ def get_install_size(title: 'Union[CIAReader, CDNReader]'):
|
|||||||
|
|
||||||
|
|
||||||
class CustomInstall:
|
class CustomInstall:
|
||||||
def __init__(self, boot9, seeddb, movable, sd, cifinish_out=None,
|
def __init__(self, *, movable, sd, cifinish_out=None, overwrite_saves=False, skip_contents=False,
|
||||||
overwrite_saves=False, skip_contents=False):
|
boot9=None, seeddb=None):
|
||||||
self.event = Events()
|
self.event = Events()
|
||||||
self.log_lines = [] # Stores all info messages for user to view
|
self.log_lines = [] # Stores all info messages for user to view
|
||||||
|
|
||||||
self.crypto = CryptoEngine(boot9=boot9)
|
self.crypto = CryptoEngine(boot9=boot9)
|
||||||
self.crypto.setup_sd_key_from_file(movable)
|
self.crypto.setup_sd_key_from_file(movable)
|
||||||
self.seeddb = seeddb
|
self.seeddb = seeddb
|
||||||
self.readers: 'List[Union[CDNReader, CIAReader]]' = []
|
self.readers: 'List[Tuple[Union[CDNReader, CIAReader], Union[PathLike, bytes, str]]]' = []
|
||||||
self.sd = sd
|
self.sd = sd
|
||||||
self.skip_contents = skip_contents
|
self.skip_contents = skip_contents
|
||||||
self.overwrite_saves = overwrite_saves
|
self.overwrite_saves = overwrite_saves
|
||||||
@@ -249,17 +260,21 @@ class CustomInstall:
|
|||||||
if reader.tmd.title_id.startswith('00048'): # DSiWare
|
if reader.tmd.title_id.startswith('00048'): # DSiWare
|
||||||
self.log(f'Skipping {reader.tmd.title_id} - DSiWare is not supported')
|
self.log(f'Skipping {reader.tmd.title_id} - DSiWare is not supported')
|
||||||
continue
|
continue
|
||||||
readers.append(reader)
|
readers.append((reader, path))
|
||||||
self.readers = readers
|
self.readers = readers
|
||||||
|
|
||||||
def check_size(self):
|
def check_size(self):
|
||||||
total_size = 0
|
total_size = 0
|
||||||
for r in self.readers:
|
for r, _ in self.readers:
|
||||||
total_size += get_install_size(r)
|
total_size += get_install_size(r)
|
||||||
|
|
||||||
free_space = get_free_space(self.sd)
|
free_space = get_free_space(self.sd)
|
||||||
return total_size, free_space
|
return total_size, free_space
|
||||||
|
|
||||||
|
def check_for_id0(self):
|
||||||
|
sd_path = join(self.sd, 'Nintendo 3DS', self.crypto.id0.hex())
|
||||||
|
return isdir(sd_path)
|
||||||
|
|
||||||
def start(self):
|
def start(self):
|
||||||
if frozen:
|
if frozen:
|
||||||
save3ds_fuse_path = join(script_dir, 'bin', 'save3ds_fuse')
|
save3ds_fuse_path = join(script_dir, 'bin', 'save3ds_fuse')
|
||||||
@@ -269,7 +284,7 @@ class CustomInstall:
|
|||||||
save3ds_fuse_path += '.exe'
|
save3ds_fuse_path += '.exe'
|
||||||
if not isfile(save3ds_fuse_path):
|
if not isfile(save3ds_fuse_path):
|
||||||
self.log("Couldn't find " + save3ds_fuse_path, 2)
|
self.log("Couldn't find " + save3ds_fuse_path, 2)
|
||||||
return None, False
|
return None, False, 0
|
||||||
|
|
||||||
crypto = self.crypto
|
crypto = self.crypto
|
||||||
# TODO: Move a lot of these into their own methods
|
# TODO: Move a lot of these into their own methods
|
||||||
@@ -280,6 +295,8 @@ class CustomInstall:
|
|||||||
f'please remove extra directories')
|
f'please remove extra directories')
|
||||||
elif len(id1s) == 0:
|
elif len(id1s) == 0:
|
||||||
raise SDPathError(f'Could not find a suitable id1 directory for id0 {crypto.id0.hex()}')
|
raise SDPathError(f'Could not find a suitable id1 directory for id0 {crypto.id0.hex()}')
|
||||||
|
id1 = id1s[0]
|
||||||
|
sd_path = join(sd_path, id1)
|
||||||
|
|
||||||
if self.cifinish_out:
|
if self.cifinish_out:
|
||||||
cifinish_path = self.cifinish_out
|
cifinish_path = self.cifinish_out
|
||||||
@@ -294,7 +311,41 @@ class CustomInstall:
|
|||||||
f'This could mean an issue with the SD card or the filesystem. Please check it for errors.\n'
|
f'This could mean an issue with the SD card or the filesystem. Please check it for errors.\n'
|
||||||
f'It is also possible, though less likely, to be an issue with custom-install.\n'
|
f'It is also possible, though less likely, to be an issue with custom-install.\n'
|
||||||
f'Exiting now to prevent possible issues. If you want to try again, delete cifinish.bin from the SD card and re-run custom-install.')
|
f'Exiting now to prevent possible issues. If you want to try again, delete cifinish.bin from the SD card and re-run custom-install.')
|
||||||
return None, False
|
return None, False, 0
|
||||||
|
|
||||||
|
db_path = join(sd_path, 'dbs')
|
||||||
|
titledb_path = join(db_path, 'title.db')
|
||||||
|
importdb_path = join(db_path, 'import.db')
|
||||||
|
if not isfile(titledb_path):
|
||||||
|
makedirs(db_path, exist_ok=True)
|
||||||
|
with gzip.open(join(script_dir, 'title.db.gz')) as f:
|
||||||
|
tdb = f.read()
|
||||||
|
|
||||||
|
self.log(f'Creating title.db...')
|
||||||
|
with open(titledb_path, 'wb') as o:
|
||||||
|
with self.crypto.create_ctr_io(Keyslot.SD, o, self.crypto.sd_path_to_iv('/dbs/title.db')) as e:
|
||||||
|
e.write(tdb)
|
||||||
|
|
||||||
|
cmac = crypto.create_cmac_object(Keyslot.CMACSDNAND)
|
||||||
|
cmac_data = [b'CTR-9DB0', 0x2.to_bytes(4, 'little'), tdb[0x100:0x200]]
|
||||||
|
cmac.update(sha256(b''.join(cmac_data)).digest())
|
||||||
|
|
||||||
|
e.seek(0)
|
||||||
|
e.write(cmac.digest())
|
||||||
|
|
||||||
|
self.log(f'Creating import.db...')
|
||||||
|
with open(importdb_path, 'wb') as o:
|
||||||
|
with self.crypto.create_ctr_io(Keyslot.SD, o, self.crypto.sd_path_to_iv('/dbs/import.db')) as e:
|
||||||
|
e.write(tdb)
|
||||||
|
|
||||||
|
cmac = crypto.create_cmac_object(Keyslot.CMACSDNAND)
|
||||||
|
cmac_data = [b'CTR-9DB0', 0x3.to_bytes(4, 'little'), tdb[0x100:0x200]]
|
||||||
|
cmac.update(sha256(b''.join(cmac_data)).digest())
|
||||||
|
|
||||||
|
e.seek(0)
|
||||||
|
e.write(cmac.digest())
|
||||||
|
|
||||||
|
del tdb
|
||||||
|
|
||||||
with TemporaryDirectory(suffix='-custom-install') as tempdir:
|
with TemporaryDirectory(suffix='-custom-install') as tempdir:
|
||||||
# set up the common arguments for the two times we call save3ds_fuse
|
# set up the common arguments for the two times we call save3ds_fuse
|
||||||
@@ -317,7 +368,7 @@ class CustomInstall:
|
|||||||
out = subprocess.run(save3ds_fuse_common_args + ['-x'],
|
out = subprocess.run(save3ds_fuse_common_args + ['-x'],
|
||||||
stdout=subprocess.PIPE,
|
stdout=subprocess.PIPE,
|
||||||
stderr=subprocess.STDOUT,
|
stderr=subprocess.STDOUT,
|
||||||
encoding=getpreferredencoding(),
|
encoding='utf-8',
|
||||||
**extra_kwargs)
|
**extra_kwargs)
|
||||||
if out.returncode:
|
if out.returncode:
|
||||||
for l in out.stdout.split('\n'):
|
for l in out.stdout.split('\n'):
|
||||||
@@ -325,18 +376,19 @@ class CustomInstall:
|
|||||||
self.log('Command line:')
|
self.log('Command line:')
|
||||||
for l in pformat(out.args).split('\n'):
|
for l in pformat(out.args).split('\n'):
|
||||||
self.log(l)
|
self.log(l)
|
||||||
return None, False
|
return None, False, 0
|
||||||
|
|
||||||
sd_path = join(sd_path, id1s[0])
|
|
||||||
|
|
||||||
|
if self.seeddb:
|
||||||
load_seeddb(self.seeddb)
|
load_seeddb(self.seeddb)
|
||||||
|
|
||||||
install_state = {'installed': [], 'failed': []}
|
install_state = {'installed': [], 'failed': []}
|
||||||
|
|
||||||
# Now loop through all provided cia files
|
# Now loop through all provided cia files
|
||||||
for idx, cia in enumerate(self.readers):
|
for idx, info in enumerate(self.readers):
|
||||||
|
cia, path = info
|
||||||
|
|
||||||
self.event.on_cia_start(idx)
|
self.event.on_cia_start(idx)
|
||||||
|
self.event.update_status(path, InstallStatus.Starting)
|
||||||
|
|
||||||
temp_title_root = join(self.sd, f'ci-install-temp-{cia.tmd.title_id}-{randint(0, 0xFFFFFFFF):08x}')
|
temp_title_root = join(self.sd, f'ci-install-temp-{cia.tmd.title_id}-{randint(0, 0xFFFFFFFF):08x}')
|
||||||
makedirs(temp_title_root, exist_ok=True)
|
makedirs(temp_title_root, exist_ok=True)
|
||||||
@@ -383,6 +435,7 @@ class CustomInstall:
|
|||||||
temp_content_root = join(temp_title_root, 'content')
|
temp_content_root = join(temp_title_root, 'content')
|
||||||
|
|
||||||
if not self.skip_contents:
|
if not self.skip_contents:
|
||||||
|
self.event.update_status(path, InstallStatus.Writing)
|
||||||
makedirs(join(temp_content_root, 'cmd'), exist_ok=True)
|
makedirs(join(temp_content_root, 'cmd'), exist_ok=True)
|
||||||
if cia.tmd.save_size:
|
if cia.tmd.save_size:
|
||||||
makedirs(join(temp_title_root, 'data'), exist_ok=True)
|
makedirs(join(temp_title_root, 'data'), exist_ok=True)
|
||||||
@@ -423,6 +476,7 @@ class CustomInstall:
|
|||||||
install_state['failed'].append(display_title)
|
install_state['failed'].append(display_title)
|
||||||
rename(temp_title_root, temp_title_root + '-corrupted')
|
rename(temp_title_root, temp_title_root + '-corrupted')
|
||||||
do_continue = True
|
do_continue = True
|
||||||
|
self.event.update_status(path, InstallStatus.Failed)
|
||||||
break
|
break
|
||||||
|
|
||||||
if do_continue:
|
if do_continue:
|
||||||
@@ -534,6 +588,7 @@ class CustomInstall:
|
|||||||
b'\0' * 0x2c
|
b'\0' * 0x2c
|
||||||
]
|
]
|
||||||
|
|
||||||
|
self.event.update_status(path, InstallStatus.Finishing)
|
||||||
if isdir(title_root):
|
if isdir(title_root):
|
||||||
self.log(f'Removing original install at {title_root}...')
|
self.log(f'Removing original install at {title_root}...')
|
||||||
rmtree(title_root)
|
rmtree(title_root)
|
||||||
@@ -554,7 +609,7 @@ class CustomInstall:
|
|||||||
out = subprocess.run(save3ds_fuse_common_args + ['-i'],
|
out = subprocess.run(save3ds_fuse_common_args + ['-i'],
|
||||||
stdout=subprocess.PIPE,
|
stdout=subprocess.PIPE,
|
||||||
stderr=subprocess.STDOUT,
|
stderr=subprocess.STDOUT,
|
||||||
encoding=getpreferredencoding(),
|
encoding='utf-8',
|
||||||
**extra_kwargs)
|
**extra_kwargs)
|
||||||
if out.returncode:
|
if out.returncode:
|
||||||
for l in out.stdout.split('\n'):
|
for l in out.stdout.split('\n'):
|
||||||
@@ -563,11 +618,19 @@ class CustomInstall:
|
|||||||
for l in pformat(out.args).split('\n'):
|
for l in pformat(out.args).split('\n'):
|
||||||
self.log(l)
|
self.log(l)
|
||||||
install_state['failed'].append(display_title)
|
install_state['failed'].append(display_title)
|
||||||
|
self.event.update_status(path, InstallStatus.Failed)
|
||||||
|
else:
|
||||||
install_state['installed'].append(display_title)
|
install_state['installed'].append(display_title)
|
||||||
|
self.event.update_status(path, InstallStatus.Done)
|
||||||
|
|
||||||
copied = False
|
copied = False
|
||||||
|
# launchable applications, not DLC or update data
|
||||||
|
application_count = len(glob(join(tempdir, '00040000*')))
|
||||||
if install_state['installed']:
|
if install_state['installed']:
|
||||||
|
if application_count >= 300:
|
||||||
|
self.log(f'{application_count} installed applications were detected.', 1)
|
||||||
|
self.log('The HOME Menu will only show 300 icons.', 1)
|
||||||
|
self.log('Some applications (not updates or DLC) will need to be deleted.', 1)
|
||||||
finalize_3dsx_orig_path = join(script_dir, 'custom-install-finalize.3dsx')
|
finalize_3dsx_orig_path = join(script_dir, 'custom-install-finalize.3dsx')
|
||||||
hb_dir = join(self.sd, '3ds')
|
hb_dir = join(self.sd, '3ds')
|
||||||
finalize_3dsx_path = join(hb_dir, 'custom-install-finalize.3dsx')
|
finalize_3dsx_path = join(hb_dir, 'custom-install-finalize.3dsx')
|
||||||
@@ -583,7 +646,7 @@ class CustomInstall:
|
|||||||
if copied:
|
if copied:
|
||||||
self.log('custom-install-finalize has been copied to the SD card.')
|
self.log('custom-install-finalize has been copied to the SD card.')
|
||||||
|
|
||||||
return install_state, copied
|
return install_state, copied, application_count
|
||||||
|
|
||||||
def get_sd_path(self):
|
def get_sd_path(self):
|
||||||
sd_path = join(self.sd, 'Nintendo 3DS', self.crypto.id0.hex())
|
sd_path = join(self.sd, 'Nintendo 3DS', self.crypto.id0.hex())
|
||||||
@@ -664,6 +727,10 @@ if __name__ == "__main__":
|
|||||||
installer.event.update_percentage += percent_handle
|
installer.event.update_percentage += percent_handle
|
||||||
installer.event.on_error += error
|
installer.event.on_error += error
|
||||||
|
|
||||||
|
if not installer.check_for_id0():
|
||||||
|
installer.event.on_error(f'Could not find id0 directory {installer.crypto.id0.hex()} '
|
||||||
|
f'inside Nintendo 3DS directory.')
|
||||||
|
|
||||||
installer.prepare_titles(args.cia)
|
installer.prepare_titles(args.cia)
|
||||||
|
|
||||||
if not args.skip_contents:
|
if not args.skip_contents:
|
||||||
@@ -674,7 +741,11 @@ if __name__ == "__main__":
|
|||||||
f'Free space: {free_space / (1024 * 1024):0.2f} MiB')
|
f'Free space: {free_space / (1024 * 1024):0.2f} MiB')
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
result, copied_3dsx = installer.start()
|
result, copied_3dsx, application_count = installer.start()
|
||||||
if result is False:
|
if result is False:
|
||||||
# save3ds_fuse failed
|
# save3ds_fuse failed
|
||||||
installer.log('NOTE: Once save3ds_fuse is fixed, run the same command again with --skip-contents')
|
installer.log('NOTE: Once save3ds_fuse is fixed, run the same command again with --skip-contents')
|
||||||
|
if application_count >= 300:
|
||||||
|
installer.log(f'\n\nWarning: {application_count} installed applications were detected.\n'
|
||||||
|
f'The HOME Menu will only show 300 icons.\n'
|
||||||
|
f'Some applications (not updates or DLC) will need to be deleted.')
|
||||||
|
|||||||
@@ -197,31 +197,99 @@ fail:
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Result check_title_exist(u64 title_id, u64 *ticket_ids, u32 ticket_ids_length, u64 *title_ids, u32 title_ids_length)
|
||||||
|
{
|
||||||
|
Result ret = -2;
|
||||||
|
|
||||||
|
for (u32 i = 0; i < ticket_ids_length; i++)
|
||||||
|
{
|
||||||
|
if (ticket_ids[i] == title_id)
|
||||||
|
{
|
||||||
|
ret++;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (u32 i = 0; i < title_ids_length; i++)
|
||||||
|
{
|
||||||
|
if (title_ids[i] == title_id)
|
||||||
|
{
|
||||||
|
ret++;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
void finalize_install(void)
|
void finalize_install(void)
|
||||||
{
|
{
|
||||||
Result res;
|
Result res;
|
||||||
Handle ticketHandle;
|
Handle ticketHandle;
|
||||||
struct ticket_dumb ticket_buf;
|
struct ticket_dumb ticket_buf;
|
||||||
struct finish_db_entry_final *entries;
|
struct finish_db_entry_final *entries = NULL;
|
||||||
int title_count;
|
int title_count;
|
||||||
|
|
||||||
title_count = load_cifinish(CIFINISH_PATH, &entries);
|
u32 titles_read;
|
||||||
if (title_count == -1)
|
u32 tickets_read;
|
||||||
|
|
||||||
|
res = AM_GetTitleCount(MEDIATYPE_SD, &titles_read);
|
||||||
|
|
||||||
|
if (R_FAILED(res))
|
||||||
{
|
{
|
||||||
free(entries);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (title_count == 0)
|
|
||||||
|
res = AM_GetTicketCount(&tickets_read);
|
||||||
|
|
||||||
|
if (R_FAILED(res))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
u64 *installed_ticket_ids = malloc(sizeof(u64) * tickets_read );
|
||||||
|
u64 *installed_title_ids = malloc(sizeof(u64) * titles_read );
|
||||||
|
|
||||||
|
res = AM_GetTitleList(&titles_read, MEDIATYPE_SD, titles_read, installed_title_ids);
|
||||||
|
|
||||||
|
if (R_FAILED(res))
|
||||||
|
{
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
res = AM_GetTicketList(&tickets_read, tickets_read, 0, installed_ticket_ids);
|
||||||
|
|
||||||
|
if (R_FAILED(res))
|
||||||
|
{
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
title_count = load_cifinish(CIFINISH_PATH, &entries);
|
||||||
|
|
||||||
|
if (title_count == -1)
|
||||||
|
{
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
|
else if (title_count == 0)
|
||||||
{
|
{
|
||||||
printf("No titles to finalize.\n");
|
printf("No titles to finalize.\n");
|
||||||
free(entries);
|
goto exit;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
memcpy(&ticket_buf, basetik_bin, basetik_bin_size);
|
memcpy(&ticket_buf, basetik_bin, basetik_bin_size);
|
||||||
|
|
||||||
|
Result exist_res = 0;
|
||||||
|
|
||||||
for (int i = 0; i < title_count; ++i)
|
for (int i = 0; i < title_count; ++i)
|
||||||
{
|
{
|
||||||
|
exist_res = check_title_exist(entries[i].title_id, installed_ticket_ids, tickets_read, installed_title_ids, titles_read);
|
||||||
|
|
||||||
|
if (R_SUCCEEDED(exist_res))
|
||||||
|
{
|
||||||
|
printf("No need to finalize %016llx, skipping...\n", entries[i].title_id);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
printf("Finalizing %016llx...\n", entries[i].title_id);
|
printf("Finalizing %016llx...\n", entries[i].title_id);
|
||||||
|
|
||||||
ticket_buf.title_id_be = __builtin_bswap64(entries[i].title_id);
|
ticket_buf.title_id_be = __builtin_bswap64(entries[i].title_id);
|
||||||
@@ -231,8 +299,7 @@ void finalize_install(void)
|
|||||||
{
|
{
|
||||||
printf("Failed to begin ticket install: %08lx\n", res);
|
printf("Failed to begin ticket install: %08lx\n", res);
|
||||||
AM_InstallTicketAbort(ticketHandle);
|
AM_InstallTicketAbort(ticketHandle);
|
||||||
free(entries);
|
goto exit;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
res = FSFILE_Write(ticketHandle, NULL, 0, &ticket_buf, sizeof(struct ticket_dumb), 0);
|
res = FSFILE_Write(ticketHandle, NULL, 0, &ticket_buf, sizeof(struct ticket_dumb), 0);
|
||||||
@@ -240,8 +307,7 @@ void finalize_install(void)
|
|||||||
{
|
{
|
||||||
printf("Failed to write ticket: %08lx\n", res);
|
printf("Failed to write ticket: %08lx\n", res);
|
||||||
AM_InstallTicketAbort(ticketHandle);
|
AM_InstallTicketAbort(ticketHandle);
|
||||||
free(entries);
|
goto exit;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
res = AM_InstallTicketFinish(ticketHandle);
|
res = AM_InstallTicketFinish(ticketHandle);
|
||||||
@@ -249,8 +315,7 @@ void finalize_install(void)
|
|||||||
{
|
{
|
||||||
printf("Failed to finish ticket install: %08lx\n", res);
|
printf("Failed to finish ticket install: %08lx\n", res);
|
||||||
AM_InstallTicketAbort(ticketHandle);
|
AM_InstallTicketAbort(ticketHandle);
|
||||||
free(entries);
|
goto exit;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (entries[i].has_seed)
|
if (entries[i].has_seed)
|
||||||
@@ -267,7 +332,12 @@ void finalize_install(void)
|
|||||||
printf("Deleting %s...\n", CIFINISH_PATH);
|
printf("Deleting %s...\n", CIFINISH_PATH);
|
||||||
unlink(CIFINISH_PATH);
|
unlink(CIFINISH_PATH);
|
||||||
|
|
||||||
|
exit:
|
||||||
|
|
||||||
free(entries);
|
free(entries);
|
||||||
|
free(installed_ticket_ids);
|
||||||
|
free(installed_title_ids);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char* argv[])
|
int main(int argc, char* argv[])
|
||||||
@@ -276,7 +346,7 @@ int main(int argc, char* argv[])
|
|||||||
gfxInitDefault();
|
gfxInitDefault();
|
||||||
consoleInit(GFX_TOP, NULL);
|
consoleInit(GFX_TOP, NULL);
|
||||||
|
|
||||||
printf("custom-install-finalize v1.5\n");
|
printf("custom-install-finalize v1.6\n");
|
||||||
|
|
||||||
finalize_install();
|
finalize_install();
|
||||||
// print this at the end in case it gets pushed off the screen
|
// print this at the end in case it gets pushed off the screen
|
||||||
|
|||||||
@@ -1,11 +1,13 @@
|
|||||||
mkdir build
|
mkdir build
|
||||||
mkdir dist
|
mkdir dist
|
||||||
cxfreeze ci-gui.py --target-dir=build\custom-install-standalone --base-name=Win32GUI
|
python setup-cxfreeze.py build_exe --build-exe=build\custom-install-standalone
|
||||||
mkdir build\custom-install-standalone\bin
|
mkdir build\custom-install-standalone\bin
|
||||||
copy TaskbarLib.tlb build\custom-install-standalone
|
copy TaskbarLib.tlb build\custom-install-standalone
|
||||||
copy bin\win32\save3ds_fuse.exe build\custom-install-standalone\bin
|
copy bin\win32\save3ds_fuse.exe build\custom-install-standalone\bin
|
||||||
copy bin\README build\custom-install-standalone\bin
|
copy bin\README build\custom-install-standalone\bin
|
||||||
copy custom-install-finalize.3dsx build\custom-install-standalone
|
copy custom-install-finalize.3dsx build\custom-install-standalone
|
||||||
|
copy title.db.gz build\custom-install-standalone
|
||||||
copy extras\windows-quickstart.txt build\custom-install-standalone
|
copy extras\windows-quickstart.txt build\custom-install-standalone
|
||||||
|
copy extras\run_with_cmd.bat build\custom-install-standalone
|
||||||
copy LICENSE.md build\custom-install-standalone
|
copy LICENSE.md build\custom-install-standalone
|
||||||
python -m zipfile -c dist\custom-install-standalone.zip build\custom-install-standalone
|
python -m zipfile -c dist\custom-install-standalone.zip build\custom-install-standalone
|
||||||
|
|||||||
@@ -1,2 +1,2 @@
|
|||||||
-r requirements.txt
|
-r requirements.txt
|
||||||
comtypes==1.1.7
|
comtypes==1.1.10
|
||||||
|
|||||||
@@ -1,2 +1,2 @@
|
|||||||
events==0.4
|
events==0.4
|
||||||
pyctr==0.4.5
|
pyctr>=0.4,<0.6
|
||||||
|
|||||||
19
setup-cxfreeze.py
Normal file
19
setup-cxfreeze.py
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
import sys
|
||||||
|
from cx_Freeze import setup, Executable
|
||||||
|
|
||||||
|
if sys.platform == 'win32':
|
||||||
|
executables = [
|
||||||
|
Executable('ci-gui.py', target_name='ci-gui-console'),
|
||||||
|
Executable('ci-gui.py', target_name='ci-gui', base='Win32GUI'),
|
||||||
|
]
|
||||||
|
else:
|
||||||
|
executables = [
|
||||||
|
Executable('ci-gui.py', target_name='ci-gui'),
|
||||||
|
]
|
||||||
|
|
||||||
|
setup(
|
||||||
|
name = "ci-gui",
|
||||||
|
version = "2.1b4",
|
||||||
|
description = "Installs a title directly to an SD card for the Nintendo 3DS",
|
||||||
|
executables = executables
|
||||||
|
)
|
||||||
BIN
title.db.gz
Normal file
BIN
title.db.gz
Normal file
Binary file not shown.
Reference in New Issue
Block a user