Add all my files

This commit is contained in:
mrdude2478 2020-12-27 04:23:00 +00:00
commit 4d4dfd633e
132 changed files with 35395 additions and 0 deletions

69
LICENSE Normal file
View File

@ -0,0 +1,69 @@
Microsoft Public License (Ms-PL)
This license governs use of the accompanying software. If you use the
software, you accept this license. If you do not accept the license,
do not use the software.
1. Definitions
The terms "reproduce," "reproduction," "derivative works," and
"distribution" have the same meaning here as under U.S. copyright
law.
A "contribution" is the original software, or any additions or
changes to the software.
A "contributor" is any person that distributes its contribution
under this license.
"Licensed patents" are a contributor's patent claims that read
directly on its contribution.
2. Grant of Rights
(A) Copyright Grant- Subject to the terms of this license,
including the license conditions and limitations in section 3,
each contributor grants you a non-exclusive, worldwide,
royalty-free copyright license to reproduce its contribution,
prepare derivative works of its contribution, and distribute its
contribution or any derivative works that you create.
(B) Patent Grant- Subject to the terms of this license, including
the license conditions and limitations in section 3, each
contributor grants you a non-exclusive, worldwide, royalty-free
license under its licensed patents to make, have made, use, sell,
offer for sale, import, and/or otherwise dispose of its
contribution in the software or derivative works of the
contribution in the software.
3. Conditions and Limitations
(A) No Trademark License- This license does not grant you rights
to use any contributors' name, logo, or trademarks.
(B) If you bring a patent claim against any contributor over
patents that you claim are infringed by the software, your patent
license from such contributor to the software ends automatically.
(C) If you distribute any portion of the software, you must retain
all copyright, patent, trademark, and attribution notices that are
present in the software.
(D) If you distribute any portion of the software in source code
form, you may do so only under this license by including a
complete copy of this license with your distribution. If you
distribute any portion of the software in compiled or object code
form, you may only do so under a license that complies with this
license.
(E) You may not distribute, copy, use, or link any portion of this
code to any other code that requires distribution of source code.
(F) The software is licensed "as-is." You bear the risk of using
it. The contributors give no express warranties, guarantees, or
conditions. You may have additional consumer rights under your
local laws which this license cannot change. To the extent
permitted under your local laws, the contributors exclude the
implied warranties of merchantability, fitness for a particular
purpose and non-infringement.

228
Makefile Normal file
View File

@ -0,0 +1,228 @@
#---------------------------------------------------------------------------------
.SUFFIXES:
#---------------------------------------------------------------------------------
ifeq ($(strip $(DEVKITPRO)),)
$(error "Please set DEVKITPRO in your environment. export DEVKITPRO=<path to>/devkitpro")
endif
TOPDIR ?= $(CURDIR)
include $(DEVKITPRO)/libnx/switch_rules
#---------------------------------------------------------------------------------
# TARGET is the name of the output
# BUILD is the directory where object files & intermediate files will be placed
# SOURCES is a list of directories containing source code
# DATA is a list of directories containing data files
# INCLUDES is a list of directories containing header files
# ROMFS is the directory containing data to be added to RomFS, relative to the Makefile (Optional)
#
# NO_ICON: if set to anything, do not use icon.
# NO_NACP: if set to anything, no .nacp file is generated.
# APP_TITLE is the name of the app stored in the .nacp file (Optional)
# APP_AUTHOR is the author of the app stored in the .nacp file (Optional)
# APP_VERSION is the version of the app stored in the .nacp file (Optional)
# APP_TITLEID is the titleID of the app stored in the .nacp file (Optional)
# ICON is the filename of the icon (.jpg), relative to the project folder.
# If not set, it attempts to use one of the following (in this order):
# - <Project name>.jpg
# - icon.jpg
# - <libnx folder>/default_icon.jpg
#
# CONFIG_JSON is the filename of the NPDM config file (.json), relative to the project folder.
# If not set, it attempts to use one of the following (in this order):
# - <Project name>.json
# - config.json
# If a JSON file is provided or autodetected, an ExeFS PFS0 (.nsp) is built instead
# of a homebrew executable (.nro). This is intended to be used for sysmodules.
# NACP building is skipped as well.
#---------------------------------------------------------------------------------
TARGET := $(notdir $(CURDIR))
BUILD := build
SOURCES := source source/ui source/data source/install source/nx source/nx/ipc source/util
DATA := data
INCLUDES := include include/ui include/data include/install include/nx include/nx/ipc include/util include/Plutonium/Plutonium/Output-switch/include
APP_TITLE := TinWoo Installer
APP_AUTHOR := MrDude
APP_VERSION := 1.0.1
ROMFS := romfs
APP_ICON := icon.jpg
#---------------------------------------------------------------------------------
# options for code generation
#---------------------------------------------------------------------------------
ARCH := -march=armv8-a+crc+crypto -mtune=cortex-a57 -mtp=soft -fPIE
CFLAGS := -g -Wall -O2 -ffunction-sections \
$(ARCH) $(DEFINES)
CFLAGS += $(INCLUDE) -D__SWITCH__ -Wno-deprecated -Wall #-D__DEBUG__ -DNXLINK_DEBUG
CXXFLAGS := $(CFLAGS) -fno-rtti -std=gnu++17 -Wall
ASFLAGS := -g $(ARCH)
LDFLAGS = -specs=$(DEVKITPRO)/libnx/switch.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map)
LIBS := -lcurl -lz -lssh2 -lusbhsfs -lntfs-3g -llwext4 -lmbedtls -lmbedcrypto -lmbedx509 -lminizip -lnx -lstdc++fs -lzzip -lpu -lfreetype -lSDL2_mixer -lopusfile -lopus -lmodplug -lmpg123 -lvorbisidec -lSDL2 -lc -logg -lSDL2_ttf -lSDL2_gfx -lSDL2_image -lwebp -lpng -ljpeg `sdl2-config --libs` `freetype-config --libs` -lzstd
#---------------------------------------------------------------------------------
# list of directories containing libraries, this must be the top level containing
# include and lib
#---------------------------------------------------------------------------------
LIBDIRS := $(PORTLIBS) $(LIBNX) $(CURDIR)/include/Plutonium/Plutonium/Output
#---------------------------------------------------------------------------------
# no real need to edit anything past this point unless you need to add additional
# rules for different file extensions
#---------------------------------------------------------------------------------
ifneq ($(BUILD),$(notdir $(CURDIR)))
#---------------------------------------------------------------------------------
export OUTPUT := $(CURDIR)/$(TARGET)
export TOPDIR := $(CURDIR)
export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \
$(foreach dir,$(DATA),$(CURDIR)/$(dir))
export DEPSDIR := $(CURDIR)/$(BUILD)
CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))
#---------------------------------------------------------------------------------
# use CXX for linking C++ projects, CC for standard C
#---------------------------------------------------------------------------------
ifeq ($(strip $(CPPFILES)),)
#---------------------------------------------------------------------------------
export LD := $(CC)
#---------------------------------------------------------------------------------
else
#---------------------------------------------------------------------------------
export LD := $(CXX)
#---------------------------------------------------------------------------------
endif
#---------------------------------------------------------------------------------
export OFILES_BIN := $(addsuffix .o,$(BINFILES))
export OFILES_SRC := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o)
export OFILES := $(OFILES_BIN) $(OFILES_SRC)
export HFILES_BIN := $(addsuffix .h,$(subst .,_,$(BINFILES)))
export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \
$(foreach dir,$(LIBDIRS),-I$(dir)/include) \
-I$(CURDIR)/$(BUILD)
export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib)
ifeq ($(strip $(CONFIG_JSON)),)
jsons := $(wildcard *.json)
ifneq (,$(findstring $(TARGET).json,$(jsons)))
export APP_JSON := $(TOPDIR)/$(TARGET).json
else
ifneq (,$(findstring config.json,$(jsons)))
export APP_JSON := $(TOPDIR)/config.json
endif
endif
else
export APP_JSON := $(TOPDIR)/$(CONFIG_JSON)
endif
ifeq ($(strip $(ICON)),)
icons := $(wildcard *.jpg)
ifneq (,$(findstring icon.jpg,$(icons)))
export APP_ICON := $(TOPDIR)/icon.jpg
endif
else
export APP_ICON := $(TOPDIR)/$(ICON)
endif
ifeq ($(strip $(NO_ICON)),)
export NROFLAGS += --icon=$(APP_ICON)
endif
ifeq ($(strip $(NO_NACP)),)
export NROFLAGS += --nacp=$(CURDIR)/$(TARGET).nacp
endif
ifneq ($(APP_TITLEID),)
export NACPFLAGS += --titleid=$(APP_TITLEID)
endif
ifneq ($(ROMFS),)
export NROFLAGS += --romfsdir=$(CURDIR)/$(ROMFS)
endif
$(info $$NROFLAGS is [${NROFLAGS}])
.PHONY: $(BUILD) clean all
#---------------------------------------------------------------------------------
all: $(BUILD)
$(BUILD):
@[ -d $@ ] || mkdir -p $@
# $(MAKE) --no-print-directory -C include/Plutonium -f Makefile lib
@$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile
#---------------------------------------------------------------------------------
clean:
@echo clean ...
ifeq ($(strip $(APP_JSON)),)
# @$(MAKE) --no-print-directory -C include/Plutonium/Plutonium -f Makefile clean
@rm -fr $(BUILD) $(TARGET).nro $(TARGET).nacp $(TARGET).elf
else
# @$(MAKE) --no-print-directory -C include/Plutonium/Plutonium -f Makefile clean
@rm -fr $(BUILD) $(TARGET).nsp $(TARGET).nso $(TARGET).npdm $(TARGET).elf
endif
#---------------------------------------------------------------------------------
else
.PHONY: all
DEPENDS := $(OFILES:.o=.d)
#---------------------------------------------------------------------------------
# main targets
#---------------------------------------------------------------------------------
ifeq ($(strip $(APP_JSON)),)
all : $(OUTPUT).nro
ifeq ($(strip $(NO_NACP)),)
$(OUTPUT).nro : $(OUTPUT).elf $(OUTPUT).nacp
else
$(OUTPUT).nro : $(OUTPUT).elf
endif
else
all : $(OUTPUT).nsp
$(OUTPUT).nsp : $(OUTPUT).nso $(OUTPUT).npdm
$(OUTPUT).nso : $(OUTPUT).elf
endif
$(OUTPUT).elf : $(OFILES)
$(OFILES_SRC) : $(HFILES_BIN)
#---------------------------------------------------------------------------------
# you need a rule like this for each extension you use as binary data
#---------------------------------------------------------------------------------
%.bin.o %_bin.h : %.bin
#---------------------------------------------------------------------------------
@echo $(notdir $<)
@$(bin2o)
-include $(DEPENDS)
#---------------------------------------------------------------------------------------
endif
#---------------------------------------------------------------------------------------

21
README.md Normal file
View File

@ -0,0 +1,21 @@
# Tinleaf
A No-Bullshit-No-Bullshit NSP, NSZ, XCI, and XCZ Installer for Nintendo Switch
![Tinleaf Installer Main Menu](tinleaf.jpg)
## Features
- Installs NSP/NSZ/XCI/XCZ files and split NSP/XCI files from your SD card
- Installs NSP/NSZ/XCI/XCZ files over LAN or USB from tools such as [NS-USBloader](https://github.com/developersu/ns-usbloader)
- Installs NSP/NSZ/XCI/XCZ files over the internet by URL or Google Drive
- Verifies NCAs by header signature before they're installed
- Installs and manages the latest signature patches quickly and easily
- Works on SX OS and Atmosphere
## Thanks to
- Adubbz
- Goffrier
- Blawar
- Xortroll
## Prominently Modified
This code was prominently modified by blawar on 2020-03-12

19
Tinfoil.LICENSE Normal file
View File

@ -0,0 +1,19 @@
Copyright (c) 2017-2018 Adubbz
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

674
awoo.LICENSE Normal file
View File

@ -0,0 +1,674 @@
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The GNU General Public License is a free, copyleft license for
software and other kinds of works.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
the GNU General Public License is intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users. We, the Free Software Foundation, use the
GNU General Public License for most of our software; it applies also to
any other work released this way by its authors. You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
To protect your rights, we need to prevent others from denying you
these rights or asking you to surrender the rights. Therefore, you have
certain responsibilities if you distribute copies of the software, or if
you modify it: responsibilities to respect the freedom of others.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received. You must make sure that they, too, receive
or can get the source code. And you must show them these terms so they
know their rights.
Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.
For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software. For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.
Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the manufacturer
can do so. This is fundamentally incompatible with the aim of
protecting users' freedom to change the software. The systematic
pattern of such abuse occurs in the area of products for individuals to
use, which is precisely where it is most unacceptable. Therefore, we
have designed this version of the GPL to prohibit the practice for those
products. If such problems arise substantially in other domains, we
stand ready to extend this provision to those domains in future versions
of the GPL, as needed to protect the freedom of users.
Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish to
avoid the special danger that patents applied to a free program could
make it effectively proprietary. To prevent this, the GPL assures that
patents cannot be used to render the program non-free.
The precise terms and conditions for copying, distribution and
modification follow.
TERMS AND CONDITIONS
0. Definitions.
"This License" refers to version 3 of the GNU General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy. The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based
on the Program.
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
1. Source Code.
The "source code" for a work means the preferred form of the work
for making modifications to it. "Object code" means any non-source
form of a work.
A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.
The Corresponding Source for a work in source code form is that
same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
b) The work must carry prominent notices stating that it is
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".
c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:
a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
Source of the work are being offered to the general public at no
charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or
e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or
run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
13. Use with the GNU Affero General Public License.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the
Program specifies that a certain numbered version of the GNU General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU General Public License, you may choose any version ever published
by the Free Software Foundation.
If the Program specifies that a proxy can decide which future
versions of the GNU General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:
<program> Copyright (C) <year> <name of author>
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, your program's commands
might be different; for a GUI interface, you would use an "about box".
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
<https://www.gnu.org/licenses/>.
The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
<https://www.gnu.org/licenses/why-not-lgpl.html>.

BIN
icon.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 63 KiB

28
include/HDInstall.hpp Normal file
View File

@ -0,0 +1,28 @@
/*
Copyright (c) 2017-2018 Adubbz
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#pragma once
#include <filesystem>
#include <vector>
namespace nspInstStuff_B {
void installNspFromFile(std::vector<std::filesystem::path> ourNspList, int whereToInstall);
}

View File

@ -0,0 +1,89 @@
/*
Copyright (c) 2017-2018 Adubbz
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#pragma once
#include <atomic>
#include <switch/types.h>
#include <memory>
#include "nx/ncm.hpp"
#include "nx/nca_writer.h"
namespace tin::data
{
static const size_t BUFFER_SEGMENT_DATA_SIZE = 0x800000; // Approximately 8MB
extern int NUM_BUFFER_SEGMENTS;
struct BufferSegment
{
std::atomic_bool isFinalized = false;
u64 writeOffset = 0;
u8 data[BUFFER_SEGMENT_DATA_SIZE] = {0};
};
// Receives data in a circular buffer split into 8MB segments
class BufferedPlaceholderWriter
{
private:
size_t m_totalDataSize = 0;
size_t m_sizeBuffered = 0;
size_t m_sizeWrittenToPlaceholder = 0;
// The current segment to which further data will be appended
u64 m_currentFreeSegment = 0;
BufferSegment* m_currentFreeSegmentPtr = NULL;
// The current segment that will be written to the placeholder
u64 m_currentSegmentToWrite = 0;
BufferSegment* m_currentSegmentToWritePtr = NULL;
std::unique_ptr<BufferSegment[]> m_bufferSegments;
std::shared_ptr<nx::ncm::ContentStorage> m_contentStorage;
NcmContentId m_ncaId;
NcaWriter m_writer;
public:
BufferedPlaceholderWriter(std::shared_ptr<nx::ncm::ContentStorage>& contentStorage, NcmContentId ncaId, size_t totalDataSize);
void AppendData(void* source, size_t length);
bool CanAppendData(size_t length);
void WriteSegmentToPlaceholder();
bool CanWriteSegmentToPlaceholder();
// Determine the number of segments required to fit data of this size
u32 CalcNumSegmentsRequired(size_t size);
// Check if there are enough free segments to fit data of this size
bool IsSizeAvailable(size_t size);
bool IsBufferDataComplete();
bool IsPlaceholderComplete();
size_t GetTotalDataSize();
size_t GetSizeBuffered();
size_t GetSizeWrittenToPlaceholder();
void DebugPrintBuffers();
};
}

View File

@ -0,0 +1,72 @@
/*
Copyright (c) 2017-2018 Adubbz
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#pragma once
#include <switch/types.h>
#include <cstring>
#include <vector>
namespace tin::data
{
class ByteBuffer
{
private:
std::vector<u8> m_buffer;
public:
ByteBuffer(size_t reserveSize=0);
size_t GetSize();
u8* GetData(); // TODO: Remove this, it shouldn't be needed
void Resize(size_t size);
void DebugPrintContents();
template <typename T>
T Read(u64 offset)
{
if (offset + sizeof(T) <= m_buffer.size())
return *((T*)&m_buffer.data()[offset]);
T def;
memset(&def, 0, sizeof(T));
return def;
}
template <typename T>
void Write(T data, u64 offset)
{
size_t requiredSize = offset + sizeof(T);
if (requiredSize > m_buffer.size())
m_buffer.resize(requiredSize, 0);
memcpy(m_buffer.data() + offset, &data, sizeof(T));
}
template <typename T>
void Append(T data)
{
this->Write(data, this->GetSize());
}
};
}

View File

@ -0,0 +1,51 @@
/*
Copyright (c) 2017-2018 Adubbz
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#pragma once
#include <switch/types.h>
#include "data/byte_buffer.hpp"
namespace tin::data
{
class ByteStream
{
protected:
u64 m_offset = 0;
public:
virtual void ReadBytes(void* dest, size_t length) = 0;
};
// NOTE: This isn't generally useful, it's mainly for things like libpng
// which rely on streams
class BufferedByteStream : public ByteStream
{
private:
ByteBuffer m_byteBuffer;
public:
BufferedByteStream(ByteBuffer buffer);
void ReadBytes(void* dest, size_t length) override;
};
}

57
include/install/hfs0.hpp Normal file
View File

@ -0,0 +1,57 @@
#pragma once
#include <switch/types.h>
#define MAGIC_HFS0 0x30534648
namespace tin::install
{
struct HFS0FileEntry
{
u64 dataOffset;
u64 fileSize;
u32 stringTableOffset;
u32 hashedSize;
u64 padding;
unsigned char hash[0x20];
} PACKED;
static_assert(sizeof(HFS0FileEntry) == 0x40, "HFS0FileEntry must be 0x18");
struct HFS0BaseHeader
{
u32 magic;
u32 numFiles;
u32 stringTableSize;
u32 reserved;
} PACKED;
static_assert(sizeof(HFS0BaseHeader) == 0x10, "HFS0BaseHeader must be 0x10");
NX_INLINE const HFS0FileEntry *hfs0GetFileEntry(const HFS0BaseHeader *header, u32 i)
{
if (i >= header->numFiles)
return NULL;
return (const HFS0FileEntry*)(header + 0x1 + i * 0x4);
}
NX_INLINE const char *hfs0GetStringTable(const HFS0BaseHeader *header)
{
return (const char*)(header + 0x1 + header->numFiles * 0x4);
}
NX_INLINE u64 hfs0GetHeaderSize(const HFS0BaseHeader *header)
{
return 0x1 + header->numFiles * 0x4 + header->stringTableSize;
}
NX_INLINE const char *hfs0GetFileName(const HFS0BaseHeader *header, u32 i)
{
return hfs0GetStringTable(header) + hfs0GetFileEntry(header, i)->stringTableOffset;
}
NX_INLINE const char *hfs0GetFileName(const HFS0BaseHeader *header, const HFS0FileEntry *entry)
{
return hfs0GetStringTable(header) + entry->stringTableOffset;
}
}

View File

@ -0,0 +1,40 @@
/*
Copyright (c) 2017-2018 Adubbz
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#pragma once
#include "install/nsp.hpp"
#include <memory>
namespace tin::install::nsp
{
class HTTPNSP : public NSP
{
public:
tin::network::HTTPDownload m_download;
HTTPNSP(std::string url);
virtual void StreamToPlaceholder(std::shared_ptr<nx::ncm::ContentStorage>& contentStorage, NcmContentId placeholderId) override;
virtual void BufferData(void* buf, off_t offset, size_t size) override;
};
}

View File

@ -0,0 +1,41 @@
/*
Copyright (c) 2017-2018 Adubbz
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#pragma once
#include "install/xci.hpp"
#include "util/network_util.hpp"
#include <memory>
namespace tin::install::xci
{
class HTTPXCI : public XCI
{
public:
tin::network::HTTPDownload m_download;
HTTPXCI(std::string url);
virtual void StreamToPlaceholder(std::shared_ptr<nx::ncm::ContentStorage>& contentStorage, NcmContentId placeholderId) override;
virtual void BufferData(void* buf, off_t offset, size_t size) override;
};
}

View File

@ -0,0 +1,69 @@
/*
Copyright (c) 2017-2018 Adubbz
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#pragma once
extern "C"
{
#include <switch/services/fs.h>
}
#include <memory>
#include <tuple>
#include <vector>
#include "install/simple_filesystem.hpp"
#include "data/byte_buffer.hpp"
#include "nx/content_meta.hpp"
#include "nx/ipc/tin_ipc.h"
namespace tin::install
{
class Install
{
protected:
const NcmStorageId m_destStorageId;
bool m_ignoreReqFirmVersion = false;
bool m_declinedValidation = false;
std::vector<nx::ncm::ContentMeta> m_contentMeta;
Install(NcmStorageId destStorageId, bool ignoreReqFirmVersion);
virtual std::vector<std::tuple<nx::ncm::ContentMeta, NcmContentInfo>> ReadCNMT() = 0;
virtual void InstallContentMetaRecords(tin::data::ByteBuffer& installContentMetaBuf, int i);
virtual void InstallApplicationRecord(int i);
virtual void InstallTicketCert() = 0;
virtual void InstallNCA(const NcmContentId &ncaId) = 0;
public:
virtual ~Install();
virtual void Prepare();
virtual void Begin();
virtual u64 GetTitleId(int i = 0);
virtual NcmContentMetaType GetContentMetaType(int i = 0);
};
}

View File

@ -0,0 +1,45 @@
/*
Copyright (c) 2017-2018 Adubbz
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#pragma once
#include <switch.h>
#include <string>
#include "install/install.hpp"
#include "install/nsp.hpp"
namespace tin::install::nsp
{
class NSPInstall : public Install
{
private:
const std::shared_ptr<NSP> m_NSP;
protected:
std::vector<std::tuple<nx::ncm::ContentMeta, NcmContentInfo>> ReadCNMT() override;
void InstallNCA(const NcmContentId& ncaId) override;
void InstallTicketCert() override;
public:
NSPInstall(NcmStorageId destStorageId, bool ignoreReqFirmVersion, const std::shared_ptr<NSP>& remoteNSP);
};
}

View File

@ -0,0 +1,47 @@
/*
Copyright (c) 2017-2018 Adubbz
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#pragma once
#include <switch.h>
#include "install/install.hpp"
#include "install/xci.hpp"
#include "nx/content_meta.hpp"
#include "nx/ipc/tin_ipc.h"
namespace tin::install::xci
{
class XCIInstallTask : public Install
{
private:
const std::shared_ptr<tin::install::xci::XCI> m_xci;
protected:
std::vector<std::tuple<nx::ncm::ContentMeta, NcmContentInfo>> ReadCNMT() override;
void InstallNCA(const NcmContentId& ncaId) override;
void InstallTicketCert() override;
public:
XCIInstallTask(NcmStorageId destStorageId, bool ignoreReqFirmVersion, const std::shared_ptr<XCI>& xci);
};
};

77
include/install/nca.hpp Normal file
View File

@ -0,0 +1,77 @@
#pragma once
#include <switch.h>
#define NCA_HEADER_SIZE 0x4000
#define MAGIC_NCA3 0x3341434E /* "NCA3" */
namespace tin::install
{
struct NcaFsHeader
{
u8 _0x0;
u8 _0x1;
u8 partition_type;
u8 fs_type;
u8 crypt_type;
u8 _0x5[0x3];
u8 superblock_data[0x138];
/*union {
pfs0_superblock_t pfs0_superblock;
romfs_superblock_t romfs_superblock;
//nca0_romfs_superblock_t nca0_romfs_superblock;
bktr_superblock_t bktr_superblock;
};*/
union {
u64 section_ctr;
struct {
u32 section_ctr_low;
u32 section_ctr_high;
};
};
u8 _0x148[0xB8]; /* Padding. */
} PACKED;
static_assert(sizeof(NcaFsHeader) == 0x200, "NcaFsHeader must be 0x200");
struct NcaSectionEntry
{
u32 media_start_offset;
u32 media_end_offset;
u8 _0x8[0x8]; /* Padding. */
} PACKED;
static_assert(sizeof(NcaSectionEntry) == 0x10, "NcaSectionEntry must be 0x10");
struct NcaHeader
{
u8 fixed_key_sig[0x100]; /* RSA-PSS signature over header with fixed key. */
u8 npdm_key_sig[0x100]; /* RSA-PSS signature over header with key in NPDM. */
u32 magic;
u8 distribution; /* System vs gamecard. */
u8 content_type;
u8 m_cryptoType; /* Which keyblob (field 1) */
u8 m_kaekIndex; /* Which kaek index? */
u64 nca_size; /* Entire archive size. */
u64 m_titleId;
u8 _0x218[0x4]; /* Padding. */
union {
uint32_t sdk_version; /* What SDK was this built with? */
struct {
u8 sdk_revision;
u8 sdk_micro;
u8 sdk_minor;
u8 sdk_major;
};
};
u8 m_cryptoType2; /* Which keyblob (field 2) */
u8 _0x221[0xF]; /* Padding. */
u64 m_rightsId[2]; /* Rights ID (for titlekey crypto). */
NcaSectionEntry section_entries[4]; /* Section entry metadata. */
u8 section_hashes[4 * 0x20]; /* SHA-256 hashes for each section header. */
u8 m_keys[4 * 0x10]; /* Encrypted key area. */
u8 _0x340[0xC0]; /* Padding. */
NcaFsHeader fs_headers[4]; /* FS section headers. */
} PACKED;
static_assert(sizeof(NcaHeader) == 0xc00, "NcaHeader must be 0xc00");
}

57
include/install/nsp.hpp Normal file
View File

@ -0,0 +1,57 @@
/*
Copyright (c) 2017-2018 Adubbz
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#pragma once
#include <functional>
#include <vector>
#include <switch/types.h>
#include "install/pfs0.hpp"
#include "nx/ncm.hpp"
#include "util/network_util.hpp"
namespace tin::install::nsp
{
class NSP
{
protected:
std::vector<u8> m_headerBytes;
NSP();
public:
virtual void StreamToPlaceholder(std::shared_ptr<nx::ncm::ContentStorage>& contentStorage, NcmContentId placeholderId) = 0;
virtual void BufferData(void* buf, off_t offset, size_t size) = 0;
virtual void RetrieveHeader();
virtual const PFS0BaseHeader* GetBaseHeader();
virtual u64 GetDataOffset();
virtual const PFS0FileEntry* GetFileEntry(unsigned int index);
virtual const PFS0FileEntry* GetFileEntryByName(std::string name);
virtual const PFS0FileEntry* GetFileEntryByNcaId(const NcmContentId& ncaId);
virtual std::vector<const PFS0FileEntry*> GetFileEntriesByExtension(std::string extension);
virtual const char* GetFileEntryName(const PFS0FileEntry* fileEntry);
};
}

48
include/install/pfs0.hpp Normal file
View File

@ -0,0 +1,48 @@
/*
Copyright (c) 2017-2018 Adubbz
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#pragma once
#include <switch/types.h>
namespace tin::install
{
struct PFS0FileEntry
{
u64 dataOffset;
u64 fileSize;
u32 stringTableOffset;
u32 padding;
} PACKED;
static_assert(sizeof(PFS0FileEntry) == 0x18, "PFS0FileEntry must be 0x18");
struct PFS0BaseHeader
{
u32 magic;
u32 numFiles;
u32 stringTableSize;
u32 reserved;
} PACKED;
static_assert(sizeof(PFS0BaseHeader) == 0x10, "PFS0BaseHeader must be 0x10");
}

View File

@ -0,0 +1,40 @@
/*
Copyright (c) 2017-2018 Adubbz
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#pragma once
#include "install/nsp.hpp"
namespace tin::install::nsp
{
class SDMCNSP : public NSP
{
public:
SDMCNSP(std::string path);
~SDMCNSP();
virtual void StreamToPlaceholder(std::shared_ptr<nx::ncm::ContentStorage>& contentStorage, NcmContentId ncaId) override;
virtual void BufferData(void* buf, off_t offset, size_t size) override;
private:
FILE* m_nspFile;
};
}

View File

@ -0,0 +1,40 @@
/*
Copyright (c) 2017-2018 Adubbz
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#pragma once
#include "install/xci.hpp"
namespace tin::install::xci
{
class SDMCXCI : public XCI
{
public:
SDMCXCI(std::string path);
~SDMCXCI();
virtual void StreamToPlaceholder(std::shared_ptr<nx::ncm::ContentStorage>& contentStorage, NcmContentId ncaId) override;
virtual void BufferData(void* buf, off_t offset, size_t size) override;
private:
FILE* m_xciFile;
};
}

View File

@ -0,0 +1,46 @@
/*
Copyright (c) 2017-2018 Adubbz
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#pragma once
#include <functional>
#include "nx/fs.hpp"
namespace tin::install::nsp
{
class SimpleFileSystem final
{
private:
nx::fs::IFileSystem* m_fileSystem;
public:
const std::string m_rootPath;
const std::string m_absoluteRootPath;
SimpleFileSystem(nx::fs::IFileSystem& fileSystem, std::string rootPath, std::string absoluteRootPath);
~SimpleFileSystem();
nx::fs::IFile OpenFile(std::string path);
bool HasFile(std::string path);
std::string GetFileNameFromExtension(std::string path, std::string extension);
};
}

View File

@ -0,0 +1,41 @@
/*
Copyright (c) 2017-2018 Adubbz
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#pragma once
#include <string>
#include "install/nsp.hpp"
namespace tin::install::nsp
{
class USBNSP : public NSP
{
private:
std::string m_nspName;
public:
USBNSP(std::string nspName);
virtual void StreamToPlaceholder(std::shared_ptr<nx::ncm::ContentStorage>& contentStorage, NcmContentId placeholderId) override;
virtual void BufferData(void* buf, off_t offset, size_t size) override;
};
}

View File

@ -0,0 +1,41 @@
/*
Copyright (c) 2017-2018 Adubbz
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#pragma once
#include <string>
#include "install/xci.hpp"
namespace tin::install::xci
{
class USBXCI : public XCI
{
private:
std::string m_xciName;
public:
USBXCI(std::string xciName);
virtual void StreamToPlaceholder(std::shared_ptr<nx::ncm::ContentStorage>& contentStorage, NcmContentId placeholderId) override;
virtual void BufferData(void* buf, off_t offset, size_t size) override;
};
}

58
include/install/xci.hpp Normal file
View File

@ -0,0 +1,58 @@
/*
Copyright (c) 2017-2018 Adubbz
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#pragma once
#include <functional>
#include <vector>
#include <switch/types.h>
#include "install/hfs0.hpp"
#include "nx/ncm.hpp"
#include <memory>
namespace tin::install::xci
{
class XCI
{
protected:
u64 m_secureHeaderOffset;
std::vector<u8> m_secureHeaderBytes;
XCI();
public:
virtual void StreamToPlaceholder(std::shared_ptr<nx::ncm::ContentStorage>& contentStorage, NcmContentId placeholderId) = 0;
virtual void BufferData(void* buf, off_t offset, size_t size) = 0;
virtual void RetrieveHeader();
virtual const HFS0BaseHeader* GetSecureHeader();
virtual u64 GetDataOffset();
virtual const HFS0FileEntry* GetFileEntry(unsigned int index);
virtual const HFS0FileEntry* GetFileEntryByName(std::string name);
virtual const HFS0FileEntry* GetFileEntryByNcaId(const NcmContentId& ncaId);
virtual std::vector<const HFS0FileEntry*> GetFileEntriesByExtension(std::string extension);
virtual const char* GetFileEntryName(const HFS0FileEntry* fileEntry);
};
}

27
include/netInstall.hpp Normal file
View File

@ -0,0 +1,27 @@
/*
Copyright (c) 2017-2018 Adubbz
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#include <vector>
namespace netInstStuff {
void installTitleNet(std::vector<std::string> ourUrlList, int ourStorage, std::vector<std::string> urlListAltNames, std::string ourSource);
std::vector<std::string> OnSelected();
}

View File

@ -0,0 +1,73 @@
/*
Copyright (c) 2017-2018 Adubbz
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#pragma once
#include <switch/services/ncm.h>
#include <switch/types.h>
#include <vector>
#include "data/byte_buffer.hpp"
namespace nx::ncm
{
struct PackagedContentInfo
{
u8 hash[0x20];
NcmContentInfo content_info;
} PACKED;
struct PackagedContentMetaHeader
{
u64 title_id;
u32 version;
u8 type;
u8 _0xd;
u16 extended_header_size;
u16 content_count;
u16 content_meta_count;
u8 attributes;
u8 storage_id;
u8 install_type;
bool comitted;
u32 required_system_version;
u32 _0x1c;
};
static_assert(sizeof(PackagedContentMetaHeader) == 0x20, "PackagedContentMetaHeader must be 0x20!");
class ContentMeta final
{
private:
tin::data::ByteBuffer m_bytes;
public:
ContentMeta();
ContentMeta(u8* data, size_t size);
PackagedContentMetaHeader GetPackagedContentMetaHeader();
NcmContentMetaKey GetContentMetaKey();
std::vector<NcmContentInfo> GetContentInfos();
void GetInstallContentMeta(tin::data::ByteBuffer& installContentMetaBuffer, NcmContentInfo& cnmtContentInfo, bool ignoreReqFirmVersion);
};
}

99
include/nx/fs.hpp Normal file
View File

@ -0,0 +1,99 @@
/*
Copyright (c) 2017-2018 Adubbz
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#pragma once
#include <string>
extern "C"
{
#include <switch/types.h>
#include <switch/services/fs.h>
}
#include "nx/ipc/tin_ipc.h"
namespace nx::fs
{
class IFileSystem;
class IFile
{
friend IFileSystem;
private:
FsFile m_file;
IFile(FsFile& file);
public:
// Don't allow copying, or garbage may be closed by the destructor
IFile& operator=(const IFile&) = delete;
IFile(const IFile&) = delete;
~IFile();
void Read(u64 offset, void* buf, size_t size);
s64 GetSize();
};
class IDirectory
{
friend IFileSystem;
private:
FsDir m_dir;
IDirectory(FsDir& dir);
public:
// Don't allow copying, or garbage may be closed by the destructor
IDirectory& operator=(const IDirectory&) = delete;
IDirectory(const IDirectory&) = delete;
~IDirectory();
void Read(s64 inval, FsDirectoryEntry* buf, size_t numEntries);
u64 GetEntryCount();
};
class IFileSystem
{
private:
FsFileSystem m_fileSystem;
public:
// Don't allow copying, or garbage may be closed by the destructor
IFileSystem& operator=(const IFileSystem&) = delete;
IFileSystem(const IFileSystem&) = delete;
IFileSystem();
~IFileSystem();
Result OpenSdFileSystem();
void OpenFileSystemWithId(std::string path, FsFileSystemType fileSystemType, u64 titleId);
void CloseFileSystem();
IFile OpenFile(std::string path);
IDirectory OpenDirectory(std::string path, int flags);
};
}

42
include/nx/ipc/es.h Normal file
View File

@ -0,0 +1,42 @@
/*
Copyright (c) 2017-2018 Adubbz
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#pragma once
#include <switch/services/ncm.h>
typedef struct {
u8 c[0x10];
} RightsId;
Result esInitialize();
void esExit();
Service* esGetServiceSession();
Result esImportTicket(void const *tikBuf, size_t tikSize, void const *certBuf, size_t certSize); //1
Result esDeleteTicket(const RightsId *rightsIdBuf, size_t bufSize); //3
Result esGetTitleKey(const RightsId *rightsId, u8 *outBuf, size_t bufSize); //8
Result esCountCommonTicket(u32 *numTickets); //9
Result esCountPersonalizedTicket(u32 *numTickets); // 10
Result esListCommonTicket(u32 *numRightsIdsWritten, RightsId *outBuf, size_t bufSize);
Result esListPersonalizedTicket(u32 *numRightsIdsWritten, RightsId *outBuf, size_t bufSize);
Result esGetCommonTicketData(u64 *unkOut, void *outBuf1, size_t bufSize1, const RightsId* rightsId);

53
include/nx/ipc/ns_ext.h Normal file
View File

@ -0,0 +1,53 @@
/*
Copyright (c) 2017-2018 Adubbz
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#pragma once
#include <switch/services/ns.h>
#include <switch/services/ncm.h>
typedef struct {
u64 titleID;
u64 unk;
u64 size;
} PACKED ApplicationRecord;
typedef struct {
NcmContentMetaKey metaRecord;
u64 storageId;
} PACKED ContentStorageRecord;
Result nsextInitialize(void);
void nsextExit(void);
Result nsPushApplicationRecord(u64 title_id, u8 last_modified_event, ContentStorageRecord *content_records_buf, size_t buf_size);
Result nsListApplicationRecordContentMeta(u64 offset, u64 titleID, void *out_buf, size_t out_buf_size, u32 *entries_read_out);
Result nsDeleteApplicationRecord(u64 titleID);
Result nsLaunchApplication(u64 titleID);
Result nsPushLaunchVersion(u64 titleID, u32 version);
Result nsDisableApplicationAutoUpdate(u64 titleID);
Result nsGetContentMetaStorage(const NcmContentMetaKey *record, u8 *out);
Result nsBeginInstallApplication(u64 tid, u32 unk, u8 storageId);
Result nsInvalidateAllApplicationControlCache(void);
Result nsInvalidateApplicationControlCache(u64 tid);
Result nsCheckApplicationLaunchRights(u64 tid);
Result nsGetApplicationContentPath(u64 titleId, u8 type, char *outBuf, size_t bufSize);

34
include/nx/ipc/tin_ipc.h Normal file
View File

@ -0,0 +1,34 @@
/*
Copyright (c) 2017-2018 Adubbz
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#pragma once
#ifdef __cplusplus
extern "C" {
#endif
#include "nx/ipc/es.h"
#include "nx/ipc/ns_ext.h"
#ifdef __cplusplus
}
#endif

62
include/nx/nca_writer.h Normal file
View File

@ -0,0 +1,62 @@
/*
Copyright (c) 2017-2018 Adubbz
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#pragma once
#include <switch.h>
#include <vector>
#include "nx/ncm.hpp"
#include <memory>
#include "install/nca.hpp"
class NcaBodyWriter
{
public:
NcaBodyWriter(const NcmContentId& ncaId, u64 offset, std::shared_ptr<nx::ncm::ContentStorage>& contentStorage);
virtual ~NcaBodyWriter();
virtual u64 write(const u8* ptr, u64 sz);
bool isOpen() const;
protected:
std::shared_ptr<nx::ncm::ContentStorage> m_contentStorage;
NcmContentId m_ncaId;
u64 m_offset;
};
class NcaWriter
{
public:
NcaWriter(const NcmContentId& ncaId, std::shared_ptr<nx::ncm::ContentStorage>& contentStorage);
virtual ~NcaWriter();
bool isOpen() const;
bool close();
u64 write(const u8* ptr, u64 sz);
void flushHeader();
protected:
NcmContentId m_ncaId;
std::shared_ptr<nx::ncm::ContentStorage> m_contentStorage;
std::vector<u8> m_buffer;
std::shared_ptr<NcaBodyWriter> m_writer;
};

58
include/nx/ncm.hpp Normal file
View File

@ -0,0 +1,58 @@
/*
Copyright (c) 2017-2018 Adubbz
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#pragma once
#include <string>
extern "C"
{
#include <switch/services/fs.h>
#include <switch/services/ncm.h>
}
#include "nx/ipc/tin_ipc.h"
namespace nx::ncm
{
class ContentStorage final
{
private:
NcmContentStorage m_contentStorage;
public:
// Don't allow copying, or garbage may be closed by the destructor
ContentStorage& operator=(const ContentStorage&) = delete;
ContentStorage(const ContentStorage&) = delete;
ContentStorage(NcmStorageId storageId);
~ContentStorage();
void CreatePlaceholder(const NcmContentId &placeholderId, const NcmPlaceHolderId &registeredId, size_t size);
void DeletePlaceholder(const NcmPlaceHolderId &placeholderId);
void WritePlaceholder(const NcmPlaceHolderId &placeholderId, u64 offset, void *buffer, size_t bufSize);
void Register(const NcmPlaceHolderId &placeholderId, const NcmContentId &registeredId);
void Delete(const NcmContentId &registeredId);
bool Has(const NcmContentId &registeredId);
std::string GetPath(const NcmContentId &registeredId);
};
}

81
include/nx/usbhdd.h Normal file
View File

@ -0,0 +1,81 @@
#pragma once
/*
Microsoft Public License (Ms-PL)
This license governs use of the accompanying software. If you use the
software, you accept this license. If you do not accept the license,
do not use the software.
1. Definitions
The terms "reproduce," "reproduction," "derivative works," and
"distribution" have the same meaning here as under U.S. copyright
law.
A "contribution" is the original software, or any additions or
changes to the software.
A "contributor" is any person that distributes its contribution
under this license.
"Licensed patents" are a contributor's patent claims that read
directly on its contribution.
2. Grant of Rights
(A) Copyright Grant- Subject to the terms of this license,
including the license conditions and limitations in section 3,
each contributor grants you a non-exclusive, worldwide,
royalty-free copyright license to reproduce its contribution,
prepare derivative works of its contribution, and distribute its
contribution or any derivative works that you create.
(B) Patent Grant- Subject to the terms of this license, including
the license conditions and limitations in section 3, each
contributor grants you a non-exclusive, worldwide, royalty-free
license under its licensed patents to make, have made, use, sell,
offer for sale, import, and/or otherwise dispose of its
contribution in the software or derivative works of the
contribution in the software.
3. Conditions and Limitations
(A) No Trademark License- This license does not grant you rights
to use any contributors' name, logo, or trademarks.
(B) If you bring a patent claim against any contributor over
patents that you claim are infringed by the software, your patent
license from such contributor to the software ends automatically.
(C) If you distribute any portion of the software, you must retain
all copyright, patent, trademark, and attribution notices that are
present in the software.
(D) If you distribute any portion of the software in source code
form, you may do so only under this license by including a
complete copy of this license with your distribution. If you
distribute any portion of the software in compiled or object code
form, you may only do so under a license that complies with this
license.
(E) You may not distribute, copy, use, or link any portion of this
code to any other code that requires distribution of source code.
(F) The software is licensed "as-is." You bear the risk of using
it. The contributors give no express warranties, guarantees, or
conditions. You may have additional consumer rights under your
local laws which this license cannot change. To the extent
permitted under your local laws, the contributors exclude the
implied warranties of merchantability, fitness for a particular
purpose and non-infringement.
*/
namespace nx::hdd
{
const char* rootPath(u32 index = 0);
u32 count();
bool init();
bool exit();
}

28
include/sdInstall.hpp Normal file
View File

@ -0,0 +1,28 @@
/*
Copyright (c) 2017-2018 Adubbz
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#pragma once
#include <filesystem>
#include <vector>
namespace nspInstStuff {
void installNspFromFile(std::vector<std::filesystem::path> ourNspList, int whereToInstall);
}

3
include/sigInstall.hpp Normal file
View File

@ -0,0 +1,3 @@
namespace sig {
void installSigPatches ();
}

31
include/ui/HDInstPage.hpp Normal file
View File

@ -0,0 +1,31 @@
#pragma once
#include <filesystem>
#include <pu/Plutonium>
using namespace pu::ui::elm;
namespace inst::ui {
class HDInstPage : public pu::ui::Layout
{
public:
HDInstPage();
PU_SMART_CTOR(HDInstPage)
pu::ui::elm::Menu::Ref menu;
void startInstall();
void onInput(u64 Down, u64 Up, u64 Held, pu::ui::Touch Pos);
TextBlock::Ref pageInfoText;
void drawMenuItems(bool clearItems, std::filesystem::path ourPath);
private:
std::vector<std::filesystem::path> ourDirectories;
std::vector<std::filesystem::path> ourFiles;
std::vector<std::filesystem::path> selectedTitles;
std::filesystem::path currentDir;
TextBlock::Ref butText;
Rectangle::Ref topRect;
Rectangle::Ref infoRect;
Rectangle::Ref botRect;
Image::Ref titleImage;
TextBlock::Ref appVersionText;
void followDirectory();
void selectNsp(int selectedIndex);
};
}

View File

@ -0,0 +1,25 @@
#pragma once
#include <pu/Plutonium>
#include "ui/mainPage.hpp"
#include "ui/netInstPage.hpp"
#include "ui/sdInstPage.hpp"
#include "ui/HDInstPage.hpp"
#include "ui/usbInstPage.hpp"
#include "ui/instPage.hpp"
#include "ui/optionsPage.hpp"
namespace inst::ui {
class MainApplication : public pu::ui::Application {
public:
using Application::Application;
PU_SMART_CTOR(MainApplication)
void OnLoad() override;
MainPage::Ref mainPage;
netInstPage::Ref netinstPage;
sdInstPage::Ref sdinstPage;
HDInstPage::Ref HDinstPage;
usbInstPage::Ref usbinstPage;
instPage::Ref instpage;
optionsPage::Ref optionspage;
};
}

27
include/ui/instPage.hpp Normal file
View File

@ -0,0 +1,27 @@
#pragma once
#include <pu/Plutonium>
using namespace pu::ui::elm;
namespace inst::ui {
class instPage : public pu::ui::Layout
{
public:
instPage();
PU_SMART_CTOR(instPage)
void onInput(u64 Down, u64 Up, u64 Held, pu::ui::Touch Pos);
TextBlock::Ref pageInfoText;
TextBlock::Ref installInfoText;
Image::Ref awooImage;
pu::ui::elm::ProgressBar::Ref installBar;
static void setTopInstInfoText(std::string ourText);
static void setInstInfoText(std::string ourText);
static void setInstBarPerc(double ourPercent);
static void loadMainMenu();
static void loadInstallScreen();
private:
Rectangle::Ref infoRect;
Rectangle::Ref topRect;
Image::Ref titleImage;
TextBlock::Ref appVersionText;
};
}

37
include/ui/mainPage.hpp Normal file
View File

@ -0,0 +1,37 @@
#pragma once
#include <pu/Plutonium>
using namespace pu::ui::elm;
namespace inst::ui {
class MainPage : public pu::ui::Layout
{
public:
MainPage();
PU_SMART_CTOR(MainPage)
void installMenuItem_Click();
void netInstallMenuItem_Click();
void usbInstallMenuItem_Click();
void sigPatchesMenuItem_Click();
void settingsMenuItem_Click();
void exitMenuItem_Click();
void onInput(u64 Down, u64 Up, u64 Held, pu::ui::Touch Pos);
Image::Ref awooImage;
private:
bool appletFinished;
bool updateFinished;
TextBlock::Ref butText;
Rectangle::Ref topRect;
Rectangle::Ref botRect;
Image::Ref titleImage;
TextBlock::Ref appVersionText;
pu::ui::elm::Menu::Ref optionMenu;
pu::ui::elm::MenuItem::Ref installMenuItem;
pu::ui::elm::MenuItem::Ref netInstallMenuItem;
pu::ui::elm::MenuItem::Ref usbInstallMenuItem;
pu::ui::elm::MenuItem::Ref sigPatchesMenuItem;
pu::ui::elm::MenuItem::Ref settingsMenuItem;
pu::ui::elm::MenuItem::Ref exitMenuItem;
Image::Ref eggImage;
};
}

View File

@ -0,0 +1,30 @@
#pragma once
#include <pu/Plutonium>
using namespace pu::ui::elm;
namespace inst::ui {
class netInstPage : public pu::ui::Layout
{
public:
netInstPage();
PU_SMART_CTOR(netInstPage)
void startInstall(bool urlMode);
void startNetwork();
void onInput(u64 Down, u64 Up, u64 Held, pu::ui::Touch Pos);
TextBlock::Ref pageInfoText;
private:
std::vector<std::string> ourUrls;
std::vector<std::string> selectedUrls;
std::vector<std::string> alternativeNames;
TextBlock::Ref butText;
Rectangle::Ref topRect;
Rectangle::Ref infoRect;
Rectangle::Ref botRect;
Image::Ref titleImage;
TextBlock::Ref appVersionText;
pu::ui::elm::Menu::Ref menu;
Image::Ref infoImage;
void drawMenuItems(bool clearItems);
void selectTitle(int selectedIndex);
};
}

View File

@ -0,0 +1,26 @@
#pragma once
#include <pu/Plutonium>
using namespace pu::ui::elm;
namespace inst::ui {
class optionsPage : public pu::ui::Layout
{
public:
optionsPage();
PU_SMART_CTOR(optionsPage)
void onInput(u64 Down, u64 Up, u64 Held, pu::ui::Touch Pos);
static void askToUpdate(std::vector<std::string> updateInfo);
private:
TextBlock::Ref butText;
Rectangle::Ref topRect;
Rectangle::Ref infoRect;
Rectangle::Ref botRect;
Image::Ref titleImage;
TextBlock::Ref appVersionText;
TextBlock::Ref pageInfoText;
pu::ui::elm::Menu::Ref menu;
void setMenuText();
std::string getMenuOptionIcon(bool ourBool);
std::string getMenuLanguage(int ourLangCode);
};
}

31
include/ui/sdInstPage.hpp Normal file
View File

@ -0,0 +1,31 @@
#pragma once
#include <filesystem>
#include <pu/Plutonium>
using namespace pu::ui::elm;
namespace inst::ui {
class sdInstPage : public pu::ui::Layout
{
public:
sdInstPage();
PU_SMART_CTOR(sdInstPage)
pu::ui::elm::Menu::Ref menu;
void startInstall();
void onInput(u64 Down, u64 Up, u64 Held, pu::ui::Touch Pos);
TextBlock::Ref pageInfoText;
void drawMenuItems(bool clearItems, std::filesystem::path ourPath);
private:
std::vector<std::filesystem::path> ourDirectories;
std::vector<std::filesystem::path> ourFiles;
std::vector<std::filesystem::path> selectedTitles;
std::filesystem::path currentDir;
TextBlock::Ref butText;
Rectangle::Ref topRect;
Rectangle::Ref infoRect;
Rectangle::Ref botRect;
Image::Ref titleImage;
TextBlock::Ref appVersionText;
void followDirectory();
void selectNsp(int selectedIndex);
};
}

View File

@ -0,0 +1,31 @@
#pragma once
#include <pu/Plutonium>
using namespace pu::ui::elm;
namespace inst::ui {
class usbInstPage : public pu::ui::Layout
{
public:
usbInstPage();
PU_SMART_CTOR(usbInstPage)
void startInstall();
void startUsb();
void onInput(u64 Down, u64 Up, u64 Held, pu::ui::Touch Pos);
TextBlock::Ref pageInfoText;
private:
std::vector<std::string> ourTitles;
std::vector<std::string> selectedTitles;
std::string lastUrl;
std::string lastFileID;
TextBlock::Ref butText;
Rectangle::Ref topRect;
Rectangle::Ref infoRect;
Rectangle::Ref botRect;
Image::Ref titleImage;
TextBlock::Ref appVersionText;
pu::ui::elm::Menu::Ref menu;
Image::Ref infoImage;
void drawMenuItems(bool clearItems);
void selectTitle(int selectedIndex);
};
}

8
include/usbInstall.hpp Normal file
View File

@ -0,0 +1,8 @@
#pragma once
#include <vector>
#include <string>
namespace usbInstStuff {
std::vector<std::string> OnSelected();
void installTitleUsb(std::vector<std::string> ourNspList, int ourStorage);
}

25
include/util/config.hpp Normal file
View File

@ -0,0 +1,25 @@
#pragma once
#include <vector>
namespace inst::config {
static const std::string appDir = "sdmc:/switch/tinwoo";
static const std::string configPath = appDir + "/config.json";
static const std::string appVersion = "1.0.1";
extern std::string gAuthKey;
extern std::string sigPatchesUrl;
extern std::vector<std::string> updateInfo;
extern int languageSetting;
extern bool ignoreReqVers;
extern bool validateNCAs;
extern bool overClock;
extern bool deletePrompt;
extern bool autoUpdate;
extern bool usbAck;
extern bool gayMode;
extern bool useSound;
void setConfig();
void parseConfig();
}

154
include/util/crypto.hpp Normal file
View File

@ -0,0 +1,154 @@
#pragma once
#include <stddef.h>
#include <switch.h>
namespace Crypto
{
#define RSA_2048_BYTES 0x100
#define RSA_2048_BITS (RSA_2048_BYTES*8)
static const unsigned char NCAHeaderSignature[0x100] = { /* Fixed RSA key used to validate NCA signature 0. */
0xBF, 0xBE, 0x40, 0x6C, 0xF4, 0xA7, 0x80, 0xE9, 0xF0, 0x7D, 0x0C, 0x99, 0x61, 0x1D, 0x77, 0x2F,
0x96, 0xBC, 0x4B, 0x9E, 0x58, 0x38, 0x1B, 0x03, 0xAB, 0xB1, 0x75, 0x49, 0x9F, 0x2B, 0x4D, 0x58,
0x34, 0xB0, 0x05, 0xA3, 0x75, 0x22, 0xBE, 0x1A, 0x3F, 0x03, 0x73, 0xAC, 0x70, 0x68, 0xD1, 0x16,
0xB9, 0x04, 0x46, 0x5E, 0xB7, 0x07, 0x91, 0x2F, 0x07, 0x8B, 0x26, 0xDE, 0xF6, 0x00, 0x07, 0xB2,
0xB4, 0x51, 0xF8, 0x0D, 0x0A, 0x5E, 0x58, 0xAD, 0xEB, 0xBC, 0x9A, 0xD6, 0x49, 0xB9, 0x64, 0xEF,
0xA7, 0x82, 0xB5, 0xCF, 0x6D, 0x70, 0x13, 0xB0, 0x0F, 0x85, 0xF6, 0xA9, 0x08, 0xAA, 0x4D, 0x67,
0x66, 0x87, 0xFA, 0x89, 0xFF, 0x75, 0x90, 0x18, 0x1E, 0x6B, 0x3D, 0xE9, 0x8A, 0x68, 0xC9, 0x26,
0x04, 0xD9, 0x80, 0xCE, 0x3F, 0x5E, 0x92, 0xCE, 0x01, 0xFF, 0x06, 0x3B, 0xF2, 0xC1, 0xA9, 0x0C,
0xCE, 0x02, 0x6F, 0x16, 0xBC, 0x92, 0x42, 0x0A, 0x41, 0x64, 0xCD, 0x52, 0xB6, 0x34, 0x4D, 0xAE,
0xC0, 0x2E, 0xDE, 0xA4, 0xDF, 0x27, 0x68, 0x3C, 0xC1, 0xA0, 0x60, 0xAD, 0x43, 0xF3, 0xFC, 0x86,
0xC1, 0x3E, 0x6C, 0x46, 0xF7, 0x7C, 0x29, 0x9F, 0xFA, 0xFD, 0xF0, 0xE3, 0xCE, 0x64, 0xE7, 0x35,
0xF2, 0xF6, 0x56, 0x56, 0x6F, 0x6D, 0xF1, 0xE2, 0x42, 0xB0, 0x83, 0x40, 0xA5, 0xC3, 0x20, 0x2B,
0xCC, 0x9A, 0xAE, 0xCA, 0xED, 0x4D, 0x70, 0x30, 0xA8, 0x70, 0x1C, 0x70, 0xFD, 0x13, 0x63, 0x29,
0x02, 0x79, 0xEA, 0xD2, 0xA7, 0xAF, 0x35, 0x28, 0x32, 0x1C, 0x7B, 0xE6, 0x2F, 0x1A, 0xAA, 0x40,
0x7E, 0x32, 0x8C, 0x27, 0x42, 0xFE, 0x82, 0x78, 0xEC, 0x0D, 0xEB, 0xE6, 0x83, 0x4B, 0x6D, 0x81,
0x04, 0x40, 0x1A, 0x9E, 0x9A, 0x67, 0xF6, 0x72, 0x29, 0xFA, 0x04, 0xF0, 0x9D, 0xE4, 0xF4, 0x03
};
class Keys
{
public:
Keys()
{
u8 kek[0x10] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
splCryptoGenerateAesKek(headerKekSource, 0, 0, kek);
splCryptoGenerateAesKey(kek, headerKeySource, headerKey);
splCryptoGenerateAesKey(kek, headerKeySource + 0x10, headerKey + 0x10);
}
u8 headerKekSource[0x10] = { 0x1F, 0x12, 0x91, 0x3A, 0x4A, 0xCB, 0xF0, 0x0D, 0x4C, 0xDE, 0x3A, 0xF6, 0xD5, 0x23, 0x88, 0x2A };
u8 headerKeySource[0x20] = { 0x5A, 0x3E, 0xD8, 0x4F, 0xDE, 0xC0, 0xD8, 0x26, 0x31, 0xF7, 0xE2, 0x5D, 0x19, 0x7B, 0xF5, 0xD0, 0x1C, 0x9B, 0x7B, 0xFA, 0xF6, 0x28, 0x18, 0x3D, 0x71, 0xF6, 0x4D, 0x73, 0xF1, 0x50, 0xB9, 0xD2 };
u8 headerKey[0x20] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
};
void calculateMGF1andXOR(unsigned char* data, size_t data_size, const void* source, size_t source_size);
bool rsa2048PssVerify(const void *data, size_t len, const unsigned char *signature, const unsigned char *modulus);
template<class T>
T swapEndian(T s)
{
T result;
u8* dest = (u8*)&result;
u8* src = (u8*)&s;
for (unsigned int i = 0; i < sizeof(s); i++)
{
dest[i] = src[sizeof(s) - i - 1];
}
return result;
}
class AesCtr
{
public:
AesCtr() : m_high(0), m_low(0)
{
}
AesCtr(u64 iv) : m_high(swapEndian(iv)), m_low(0)
{
}
u64& high() { return m_high; }
u64& low() { return m_low; }
private:
u64 m_high;
u64 m_low;
};
class Aes128Ctr
{
public:
Aes128Ctr(const u8* key, const AesCtr& iv)
{
counter = iv;
aes128CtrContextCreate(&ctx, key, &iv);
seek(0);
}
virtual ~Aes128Ctr()
{
}
void seek(u64 offset)
{
counter.low() = swapEndian(offset >> 4);
aes128CtrContextResetCtr(&ctx, &counter);
}
void encrypt(void *dst, const void *src, size_t l)
{
aes128CtrCrypt(&ctx, dst, src, l);
}
void decrypt(void *dst, const void *src, size_t l)
{
encrypt(dst, src, l);
}
protected:
AesCtr counter;
Aes128CtrContext ctx;
};
class AesXtr
{
public:
AesXtr(const u8* key, bool is_encryptor)
{
aes128XtsContextCreate(&ctx, key, key + 0x10, is_encryptor);
}
virtual ~AesXtr()
{
}
void encrypt(void *dst, const void *src, size_t l, size_t sector, size_t sector_size)
{
for (size_t i = 0; i < l; i += sector_size)
{
aes128XtsContextResetSector(&ctx, sector++, true);
aes128XtsEncrypt(&ctx, dst, src, sector_size);
dst = (u8*)dst + sector_size;
src = (const u8*)src + sector_size;
}
}
void decrypt(void *dst, const void *src, size_t l, size_t sector, size_t sector_size)
{
for (size_t i = 0; i < l; i += sector_size)
{
aes128XtsContextResetSector(&ctx, sector++, true);
aes128XtsDecrypt(&ctx, dst, src, sector_size);
dst = (u8*)dst + sector_size;
src = (const u8*)src + sector_size;
}
}
protected:
Aes128XtsContext ctx;
};
}

7
include/util/curl.hpp Normal file
View File

@ -0,0 +1,7 @@
#pragma once
#include <string>
namespace inst::curl {
bool downloadFile(const std::string ourUrl, const char *pagefilename, long timeout = 5000, bool writeProgress = false);
std::string downloadToBuffer (const std::string ourUrl, int firstRange = -1, int secondRange = -1, long timeout = 5000);
}

36
include/util/debug.h Normal file
View File

@ -0,0 +1,36 @@
/*
Copyright (c) 2017-2018 Adubbz
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#pragma once
#ifdef __cplusplus
extern "C" {
#endif
#include <stdio.h>
#include <switch/types.h>
void printBytes(u8 *bytes, size_t size, bool includeHeader);
#ifdef __cplusplus
}
#endif

39
include/util/error.hpp Normal file
View File

@ -0,0 +1,39 @@
/*
Copyright (c) 2017-2018 Adubbz
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#pragma once
#include <cstring>
#include <stdexcept>
#include <stdio.h>
#include "util/debug.h"
#define ASSERT_OK(rc_out, desc) if (R_FAILED(rc_out)) { char msg[256] = {0}; snprintf(msg, 256-1, "%s:%u: %s. Error code: 0x%08x\n", __func__, __LINE__, desc, rc_out); throw std::runtime_error(msg); }
#define THROW_FORMAT(format, ...) { char error_prefix[512] = {0}; snprintf(error_prefix, 256-1, "%s:%u: ", __func__, __LINE__);\
char formatted_msg[256] = {0}; snprintf(formatted_msg, 256-1, format, ##__VA_ARGS__);\
strncat(error_prefix, formatted_msg, 512-1); throw std::runtime_error(error_prefix); }
#ifdef NXLINK_DEBUG
#define LOG_DEBUG(format, ...) { printf("%s:%u: ", __func__, __LINE__); printf(format, ##__VA_ARGS__); }
#else
#define LOG_DEBUG(format, ...) ;
#endif

View File

@ -0,0 +1,36 @@
/*
Copyright (c) 2017-2018 Adubbz
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#pragma once
#include <string>
#include <tuple>
#include <vector>
#include "nx/content_meta.hpp"
namespace tin::util
{
NcmContentInfo CreateNSPCNMTContentRecord(const std::string& nspPath);
nx::ncm::ContentMeta GetContentMetaFromNCA(const std::string& ncaPath);
std::vector<std::string> GetNSPList();
}

22875
include/util/json.hpp Normal file

File diff suppressed because it is too large Load Diff

28
include/util/lang.hpp Normal file
View File

@ -0,0 +1,28 @@
#pragma once
#include <string>
#include <sstream>
#include <fstream>
#include "json.hpp"
using json = nlohmann::json;
namespace Language {
void Load();
std::string LanguageEntry(std::string key);
std::string GetRandomMsg();
inline json GetRelativeJson(json j, std::string key) {
std::istringstream ss(key);
std::string token;
while (std::getline(ss, token, '.') && j != nullptr) {
j = j[token];
}
return j;
}
}
inline std::string operator ""_lang (const char* key, size_t size) {
return Language::LanguageEntry(std::string(key, size));
}

View File

@ -0,0 +1,83 @@
/*
Copyright (c) 2017-2018 Adubbz
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#pragma once
#include <switch/types.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <sys/errno.h>
#include <fcntl.h>
#include <unistd.h>
#include <functional>
#include <map>
#include <memory>
#include <string>
#include <vector>
#ifdef __cplusplus
extern "C" {
#endif
#ifdef __cplusplus
}
#endif
namespace tin::network
{
class HTTPHeader
{
private:
std::string m_url;
std::map<std::string, std::string> m_values;
static size_t ParseHTMLHeader(char* bytes, size_t size, size_t numItems, void* userData);
public:
HTTPHeader(std::string url);
void PerformRequest();
bool HasValue(std::string key);
std::string GetValue(std::string key);
};
class HTTPDownload
{
private:
std::string m_url;
HTTPHeader m_header;
bool m_rangesSupported = false;
static size_t ParseHTMLData(char* bytes, size_t size, size_t numItems, void* userData);
public:
HTTPDownload(std::string url);
void BufferDataRange(void* buffer, size_t offset, size_t size, std::function<void (size_t sizeRead)> progressFunc);
int StreamDataRange(size_t offset, size_t size, std::function<size_t (u8* bytes, size_t size)> streamFunc);
};
size_t WaitReceiveNetworkData(int sockfd, void* buf, size_t len);
size_t WaitSendNetworkData(int sockfd, void* buf, size_t len);
}

View File

@ -0,0 +1,41 @@
/*
Copyright (c) 2017-2018 Adubbz
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#pragma once
#include <switch/types.h>
#include <string>
#include "nx/content_meta.hpp"
#include "nx/ipc/tin_ipc.h"
namespace tin::util
{
u64 GetRightsIdTid(RightsId rightsId);
u64 GetRightsIdKeyGen(RightsId rightsId);
std::string GetNcaIdString(const NcmContentId& ncaId);
NcmContentId GetNcaIdFromString(std::string ncaIdStr);
u64 GetBaseTitleId(u64 titleId, NcmContentMetaType contentMetaType);
std::string GetBaseTitleName(u64 baseTitleId);
std::string GetTitleName(u64 titleId, NcmContentMetaType contentMetaType);
}

3
include/util/unzip.hpp Normal file
View File

@ -0,0 +1,3 @@
namespace inst::zip {
bool extractFile(const std::string filename, const std::string destination);
}

View File

@ -0,0 +1,47 @@
/**
* @file usb_comms.h
* @brief USB comms.
* @author yellows8
* @author plutoo
* @copyright libnx Authors
*/
#ifdef __cplusplus
extern "C" {
#endif
#pragma once
#include "switch/types.h"
typedef struct {
u8 bInterfaceClass;
u8 bInterfaceSubClass;
u8 bInterfaceProtocol;
} tinleaf_UsbCommsInterfaceInfo;
/// Initializes usbComms with the default number of interfaces (1)
Result tinleaf_usbCommsInitialize(void);
/// Initializes usbComms with a specific number of interfaces.
Result tinleaf_usbCommsInitializeEx(u32 num_interfaces, const tinleaf_UsbCommsInterfaceInfo *infos);
/// Exits usbComms.
void tinleaf_usbCommsExit(void);
/// Sets whether to throw a fatal error in usbComms{Read/Write}* on failure, or just return the transferred size. By default (false) the latter is used.
void tinleaf_usbCommsSetErrorHandling(bool flag);
/// Read data with the default interface.
size_t tinleaf_usbCommsRead(void* buffer, size_t size, u64 timeout);
/// Write data with the default interface.
size_t tinleaf_usbCommsWrite(const void* buffer, size_t size, u64 timeout);
/// Same as usbCommsRead except with the specified interface.
size_t tinleaf_usbCommsReadEx(void* buffer, size_t size, u32 interface, u64 timeout);
/// Same as usbCommsWrite except with the specified interface.
size_t tinleaf_usbCommsWriteEx(const void* buffer, size_t size, u32 interface, u64 timeout);
#ifdef __cplusplus
}
#endif

59
include/util/usb_util.hpp Normal file
View File

@ -0,0 +1,59 @@
/*
Copyright (c) 2017-2018 Adubbz
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#pragma once
#include <switch.h>
#include <string>
namespace tin::util
{
enum USBCmdType : u8
{
REQUEST = 0,
RESPONSE = 1
};
struct USBCmdHeader
{
u32 magic;
USBCmdType type;
u8 padding[0x3] = {0};
u32 cmdId;
u64 dataSize;
u8 reserved[0xC] = {0};
} PACKED;
static_assert(sizeof(USBCmdHeader) == 0x20, "USBCmdHeader must be 0x20!");
class USBCmdManager
{
public:
static void SendCmdHeader(u32 cmdId, size_t dataSize);
static void SendExitCmd();
static USBCmdHeader SendFileRangeCmd(std::string nspName, u64 offset, u64 size);
};
size_t USBRead(void* out, size_t len, u64 timeout = 5000000000);
size_t USBWrite(const void* in, size_t len, u64 timeout = 5000000000);
}

24
include/util/util.hpp Normal file
View File

@ -0,0 +1,24 @@
#pragma once
#include <filesystem>
namespace inst::util {
void initApp ();
void deinitApp ();
void initInstallServices();
void deinitInstallServices();
bool ignoreCaseCompare(const std::string &a, const std::string &b);
std::vector<std::filesystem::path> getDirectoryFiles(const std::string & dir, const std::vector<std::string> & extensions);
std::vector<std::filesystem::path> getDirsAtPath(const std::string & dir);
bool removeDirectory(std::string dir);
bool copyFile(std::string inFile, std::string outFile);
std::string formatUrlString(std::string ourString);
std::string shortenString(std::string ourString, int ourLength, bool isFile);
std::string readTextFromFile(std::string ourFile);
std::string softwareKeyboard(std::string guideText, std::string initialText, int LenMax);
std::string getDriveFileName(std::string fileId);
std::vector<uint32_t> setClockSpeed(int deviceToClock, uint32_t clockSpeed);
std::string getIPAddress();
int getUsbState();
void playAudio(std::string audioPath);
std::vector<std::string> checkForAppUpdate();
}

6
libusbhsfs.LICENSE Normal file
View File

@ -0,0 +1,6 @@
Copyright (c) 2020, DarkMatterCore <pabloacurielz@gmail.com>.
Copyright (c) 2020, XorTroll.
Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

BIN
romfs/audio/ameizing.mp3 Normal file

Binary file not shown.

BIN
romfs/audio/bark.wav Normal file

Binary file not shown.

BIN
romfs/images/Background.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 843 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 611 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 537 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

BIN
romfs/images/logo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 68 KiB

218
romfs/lang/de.json Normal file
View File

@ -0,0 +1,218 @@
{
"main":{
"menu": {
"sd": "Von SD-Karte installieren",
"net": "Über LAN oder Internet installieren",
"usb": "Über USB installieren",
"hdd": "Install over USB HDD",
"sig": "Verwalte Signatur-Patches",
"set": "Einstellungen",
"exit": "Beenden"
},
"theme": {
"title": "Use Theme",
"desc": "Press OK to quit Tinwoo or Cancel to continue.\n\nThemes will activate the next time you start Tinwoo."
},
"hdd": {
"title": "USB HDD",
"notfound": "USB HDD is not connected."
},
"net": {
"title": "Netzwerk Verbindung nicht verfügbar",
"desc": "Überprüfe ob der Flugzeug-Modus deaktiviert ist und ob du mit einem lokalen Netzwerk verbunden bist"
},
"usb": {
"warn": {
"title": "Warnung!",
"desc": "USB-Installationen funktionieren möglicherweise mit manchen Geräten und\nKonfigurationen nicht. Falls du Probleme mit USB-Installationen hast,\nreiß dir nicht die Haare aus! Wir empfehlen NS-USBloader für USB-Installationen\noder stattdessen LAN/Internet Installationen,\nam besten über einen Ethernet-Adapter verbunden.\n\nWir haben dich gewarnt...",
"opt1": "Warnt mich nicht nochmal"
},
"error": {
"title": "Keine USB-Verbindung erkannt",
"desc": "Verbinde dich für USB-Installationen mit einem kompatiblen Gerät"
}
},
"applet": {
"title": "Applet-Modus wird nicht unterstützt",
"desc": "Es kann zu Problemen bei der Verwendung des TinWoo Installer im Applet-Modus kommen.\nWenn du Probleme hast, starte den TinWoo Installer über einen installierten Titel (halte R gedrückt, während du ein Spiel startest)!"
},
"buttons": "\ue0e0 Auswählen \ue0e1 Beenden"
},
"inst": {
"net": {
"help": {
"title": "Hilfe",
"desc": "Dateien können von anderen Geräten aus mit Tools wie NS-USBloader im\nTinfoil-Modus installiert werden. Um Dateien an deine Switch zu senden, öffne\neins dieser Programme auf deinem PC oder mobilen Gerät. Gebe die IP-Adresse\ndeiner Switches ein (auf dem Bildschirm aufgelistet), wähle die Dateien\naus und lade sie dann auf die Konsole hoch! Wenn die von dir verwendete\nSoftware dir nicht erlaubt, bestimmte Dateitypen auszuwählen.\nVersuche die Dateiendung in etwas umzubenennen, dass sie akzeptiert. Der TinWoo Installer\nprüft keine Dateiendungen bei Netzinstallationen!\n\nFalls das nicht klappt, kopiere einfach deine Dateien auf die SD-Karte\nund versuche die Option \"Von SD-Karte installieren\" im Hauptmenü!"
},
"src": {
"title": "Von wo aus willst du installieren?",
"opt0": "URL",
"opt1": "Google Drive"
},
"url": {
"hint": "Gebe eine URL zu einer Datei ein",
"invalid": "Die eingegebene URL ist ungültig",
"source_string": " per URL"
},
"gdrive": {
"hint": "Gebe die ID einer öffentlichen Google Drive Datei ein",
"alt_name": "Google Drive Datei",
"source_string": " von Google Drive"
},
"top_info": "Wähle Dateien zur Installation vom Server aus und drücke dann \ue0b3 !",
"top_info1": "Warte auf eine Verbindung... Die IP Adresse deiner Switch ist: ",
"failed": "Ferninstallation fehlgeschlagen!",
"transfer_interput": "Bei der Dateiübertragung ist ein Fehler aufgetreten.",
"source_string": " über das lokale Netzwerk",
"buttons": "\ue0e3 Installation über das Internet \ue0e2 Hilfe \ue0e1 Abbrechen",
"buttons1": "\ue0e0 Datei auswählen \ue0e3 Alle auswählen \ue0ef Datei(en) installieren \ue0e1 Abbrechen"
},
"sd": {
"help": {
"title": "Hilfe",
"desc": "Kopiere NSP, NSZ, XCI oder XCZ Dateien auf deine SD Karte,\nsuche nach ihnen und wähle die zu installierenden Titel aus und drücke dann \ue0b3."
},
"top_info": "Wähle Dateien zur Installation vom Server aus und drücke dann \ue0b3!",
"source_string": " von der SD Karte",
"delete_info": " installiert! Soll es von der SD-Karte gelöscht werden?",
"delete_info_multi": " Dateien erfolgreich installiert! Sollen diese von der SD-Karte gelöscht werden?",
"delete_desc": "Die originalen Dateien werden nach der Installation nicht mehr benötigt",
"buttons": "\ue0e0 Datei auswählen \ue0e3 Alle auswählen \ue0ef Datei(en) installieren \ue0e1 Abbrechen"
},
"hd": {
"help": {
"title": "Help",
"desc": "Copy your NSP, NSZ, XCI, or XCZ files to your hard drive, browse to and\nselect the ones you want to install, then press the Plus button."
},
"top_info": "Select the files you want to install, then press the Plus button!",
"source_string": " from hard drive",
"delete_info": " installed\nDelete it from the hard drive?",
"delete_info_multi": " files installed successfully!\nDelete them from the hard drive?",
"delete_desc": "The original files aren't needed anymore after they've been installed",
"buttons": "\ue0e0 Select File \ue0e3 Select All \ue0ef Install File(s) \ue0e2 Help \ue0e1 Cancel"
},
"usb": {
"help": {
"title": "Hilfe",
"desc": "Dateien können mit Tools, wie NS-USBloader im Tinfoil-Modus\nvon anderen Geräten aus installiert werden.\nUm Dateien an deine Switch zu senden, öffne\neins dieser Programme auf deinem PC oder mobilen Gerät, wähle die Dateien\naus und lade sie dann auf die Konsole hoch!\n\nLeider erfordern USB-Installationen auf einigen Plattformen ein spezielles\nSetup und können manchmal ziemlich fehlerhaft sein. Falls das nicht klappt,\nversuche es mit LAN/Internet Installation oder kopiere deine Dateien auf\ndeine SD-Karte und versuche die Option \"Von SD-Karte installieren\" im Hauptmenü!"
},
"top_info": "USB verbunden! Warte auf die Dateiliste...",
"top_info2": "Wähle Dateien zur Installation aus und drücke dann \ue0b3 !",
"error": "USB Übertragung ist zeitlich abgelaufen oder fehlgeschlagen",
"source_string": " über USB",
"buttons": "\ue0e2 (Halten) Hilfe \ue0e1 (Halte) Abbrechen",
"buttons2": "\ue0e0 Datei auswählen \ue0e3 Alle auswählen \ue0ef Datei(en) installieren \ue0e1 Abbrechen"
},
"target": {
"desc0": "Wo soll ",
"desc1": " installiert werden?",
"desc00": "Wo sollen die ",
"desc01": " Dateien installiert werden?",
"opt0": "SD Karte",
"opt1": "Interner Speicher"
},
"info_page": {
"top_info0": "Installiere ",
"preparing": "Bereite Installation vor...",
"failed": "Installation fehlgeschlagen ",
"failed_desc": "Teilweise installierte Inhalte können in den Einstellungen entfernt werden.",
"complete": "Installation abgeschlossen",
"desc0": " Dateien erfolgreich installiert!",
"desc1": " installiert!",
"downloading": "Lädt ",
"at": " herunter von "
},
"nca_verify": {
"title": "Ungültige NCA-Signatur erkannt!",
"desc": "Unsachgemäß signierte Software sollte nur von vertrauenswürdigen Quellen\ninstalliert werden. Dateien von gepackten Spiele Modulen und DLC-Freischaltung enthalten,\nwerden immer diese Warnung anzeigen. Sie können diese Prüfung in den Einstellungen des TinWoo Installer deaktivieren.\nSind Sie sicher, dass Sie die Installation fortsetzen möchten?",
"opt1": "Ja, ich verstehe die Risiken",
"error": "Die gewünschte NCA ist nicht richtig signiert: "
},
"finished": [
"Genieße deine \"legalen Sicherheitskopien\"!",
"Ich bin mir sicher nachdem du das Spiel probiert hast wirst du Spaß dabei haben das Spiel tatsächlich zu kaufen!",
"Du hast das Spiel sicher gekauft? Nintendo sagt danke für deinen Kauf!",
"DRM zu umgehen ist toll, stimmt es?",
"Du hast wahrscheinlich sechs Bäume gerettet. Dadurch dass du das Spiel nicht gekauft hast!\nAll das Plastik geht irgendwo hin!",
"Nintendo Ninjas wurden zu deinem Standort gesendet.",
"Und wir mussten dir nicht mal politische Ideologien in den Rachen stopfen!"
]
},
"sig": {
"install": "Installieren",
"uninstall": "Deinstallieren",
"update": "Aktualisieren",
"version_text": "Du hast die aktuellen Patches für die HOS Version installiert ",
"title0": "Installiere Signatur Patches?",
"desc0": "Signatur Patches werden benötigt, um offizielle Software zu installieren und zu spielen.",
"backup_failed": "Konnte die hekate patches.ini nicht finden! Trotzdem installieren?",
"backup_failed_desc": "Falls du hekate nicht nutzt, kannst du diese Warnung ignorieren.",
"download_failed": "Konnte die Signatur Patches nicht herunterladen",
"download_failed_desc": "Eventuell hast du eine ungültige Quelle in den Einstellung\nvom TinWoo Installer eingestellt oder der Host ist derzeitig offline.",
"version_text2": "Deine Signatur Patches wurden aktualisiert, für deine HOS Version ",
"install_complete": "Installation abgeschlossen!",
"complete_desc": "Starte die Konsole neu um die Änderung zu übernehmen",
"restart": "Neustarten",
"later": "Mach ich später",
"extract_failed": "Konnte die Dateien nicht extrahieren!",
"restore_failed": "Konnte die originale hekate patches.ini nicht wiederherstellen! Deinstallation fortsetzen?",
"uninstall_complete": "Deinstallation vollständig",
"remove_failed": "Konnte die Signatur Patches nicht entfernen",
"remove_failed_desc": "Dateien müssen möglicherweise umbenannt oder entfernt werden",
"generic_error": "Installation der Signatur Patches fehlgeschlagen!"
},
"options": {
"menu_items": {
"ignore_firm": "Ignoriere minimale Firmware Version des Titels",
"nca_verify": "Verifiziere NCA Signatur vor der Installation",
"boost_mode": "Aktiviere \"Boost-Modus\" während der Installation",
"ask_delete": "Frage ob installierte Titel gelöscht werden sollen",
"auto_update": "Suche automatisch nach Updates für TinWoo Installer",
"gay_option": "Thema verwenden",
"useSound": "Use sound notifications during installs",
"sig_url": "Signatur Patches URL: ",
"language": "Sprache: ",
"check_update": "Suche nach Updates für TinWoo Installer",
"credits": "Anerkennung"
},
"nca_warn": {
"title": "Warnung!",
"desc": "Einige installierbare Dateien können bösartige Inhalte enthalten! Deaktiviere\ndiese Funktion nur, wenn du absolut sicher bist, dass die zu installierende\nSoftware vertrauenswürdig ist! Willst du die NCA-Signaturprüfung immer noch deaktivieren?",
"opt1": "Ja, ich möchte mein Gerät bricken"
},
"sig_hint": "Gebe eine URL an, um Signatur Patches zu beziehen",
"update": {
"title": "Neue Version verfügbar",
"desc0": "TinWoo Installer ",
"desc1": " ist jetzt verfügbar! Bereit zu aktualisieren?",
"opt0": "Aktualisieren",
"top_info": "Aktualisierung zu TinWoo Installer ",
"bot_info": "Beziehe TinWoo Installer ",
"bot_info2": "Extrahiere TinWoo Installer ",
"complete": "Aktualisierung vollständig!",
"failed": "Aktualisierung fehlgeschlagen!",
"end_desc": "Die Software wird nun beendet.",
"title_check_fail": "Keine Aktualisierungen gefunden",
"desc_check_fail": "Du bist auf der aktuellsten Version des TinWoo Installer!"
},
"credits": {
"title": "Vielen Dank an die folgenden Leute!",
"desc": "TinWoo - MrDude\nTinleaf - BlaWar\nAwoo Installer - Huntereb\nHard Drive Support - DarkMatterCore\n\n\nhttps://github.com/Huntereb/Awoo-Installer\nhttps://github.com/blawar/tinleaf\nhttps://github.com/DarkMatterCore/libusbhsfs\n\nThanks for testing - LyuboA"
},
"language": {
"title": "Wähle TinWoo Installer Sprache",
"desc": "Die Software wird danach beendet. Drücke B um den Vorgang abzubrechen.",
"system_language": "System"
},
"title": "Ändere TinWoo Installer Einstellungen!",
"buttons": "\ue0e0 Auswählen/Ändern \ue0e1 Abbrechen "
},
"common": {
"ok": "OK",
"cancel": "Abbrechen",
"close": "Schließen",
"yes": "Ja",
"no": "Nein",
"cancel_desc": "Drücke \ue0e1 zum Abbrechen "
}
}

218
romfs/lang/en.json Normal file
View File

@ -0,0 +1,218 @@
{
"main":{
"menu": {
"sd": "Install from SD card",
"net": "Install over LAN or internet",
"usb": "Install over USB",
"hdd": "Install over USB HDD",
"sig": "Manage signature patches",
"set": "Settings",
"exit": "Exit"
},
"theme": {
"title": "Use Theme",
"desc": "Press OK to quit Tinwoo or Cancel to continue.\n\nThemes will activate the next time you start Tinwoo."
},
"hdd": {
"title": "USB HDD",
"notfound": "USB HDD is not connected."
},
"net": {
"title": "Network connection not available",
"desc": "Check that airplane mode is disabled and you're connected to a local network."
},
"usb": {
"warn": {
"title": "Warning!",
"desc": "USB installations may not \"just werk\" on some devices and setups.\nIf you experience issues with USB installations, please don't pull your\nhair out! It's advised to use NS-USBloader for USB installations, or\nLAN/Internet installations instead for remote installation, especially\nwhen paired with an ethernet adapter!\n\nYou have been warned...",
"opt1": "Don't tell me again"
},
"error": {
"title": "No USB connection detected",
"desc": "Plug in to a compatible device to install over USB"
}
},
"applet": {
"title": "Applet Mode not supported",
"desc": "You may experience issues using TinWoo Installer in Applet Mode. If you do\nhave problems, please switch to running TinWoo Installer over an installed\ntitle (hold R while starting a game)!"
},
"buttons": "\ue0e0 Select \ue0e1 Exit"
},
"inst": {
"net": {
"help": {
"title": "Help",
"desc": "Files can be installed remotely from your other devices using tools such\nas NS-USBloader in Tinfoil mode. To send files to your Switch, open one\nof these pieces of software on your PC or mobile device, input your\nSwitch's IP address (listed on-screen), select your files, then upload\nto your console! If the software you're using won't let you select\nspecific file types, try renaming the extension to something it accepts.\nTinWoo Installer doesn't care about file extensions during net installations!\n\nIf you can't figure it out, just copy your files to your SD card and try\nthe \"Install from SD Card\" option on the main menu!"
},
"src": {
"title": "Where do you want to install from?",
"opt0": "URL",
"opt1": "Google Drive"
},
"url": {
"hint": "Enter the Internet address of a file",
"invalid": "The URL specified is invalid!",
"source_string": " from URL"
},
"gdrive": {
"hint": "Enter the file ID of a public Google Drive file",
"alt_name": "Google Drive File",
"source_string": " from Google Drive"
},
"top_info": "Select what files you want to install from the server, then press the Plus button!",
"top_info1": "Waiting for a connection... Your Switch's IP Address is: ",
"failed": "Failed to perform remote install!",
"transfer_interput": "An error occured during data transfer. Check your network connection.",
"source_string": " over local network",
"buttons": "\ue0e3 Install Over Internet \ue0e2 Help \ue0e1 Cancel",
"buttons1": "\ue0e0 Select File \ue0e3 Select All \ue0ef Install File(s) \ue0e1 Cancel"
},
"sd": {
"help": {
"title": "Help",
"desc": "Copy your NSP, NSZ, XCI, or XCZ files to your SD card, browse to and\nselect the ones you want to install, then press the Plus button."
},
"top_info": "Select what files you want to install, then press the Plus button!",
"source_string": " from SD card",
"delete_info": " installed! Delete it from the SD card?",
"delete_info_multi": " files installed successfully! Delete them from the SD card?",
"delete_desc": "The original files aren't needed anymore after they've been installed",
"buttons": "\ue0e0 Select File \ue0e3 Select All \ue0ef Install File(s) \ue0e2 Help \ue0e1 Cancel"
},
"hd": {
"help": {
"title": "Help",
"desc": "Copy your NSP, NSZ, XCI, or XCZ files to your hard drive, browse to and\nselect the ones you want to install, then press the Plus button."
},
"top_info": "Select the files you want to install, then press the Plus button!",
"source_string": " from hard drive",
"delete_info": " installed\nDelete it from the hard drive?",
"delete_info_multi": " files installed successfully!\nDelete them from the hard drive?",
"delete_desc": "The original files aren't needed anymore after they've been installed",
"buttons": "\ue0e0 Select File \ue0e3 Select All \ue0ef Install File(s) \ue0e2 Help \ue0e1 Cancel"
},
"usb": {
"help": {
"title": "Help",
"desc": "Files can be installed over USB from other devices using tools such as\nNS-USBloader in Tinfoil mode. To send files to your Switch, open one of\nthese pieces of software on your PC, select your files, then upload to\nyour console!\n\nUnfortunately USB installations require a specific setup on some\nplatforms, and can be rather buggy at times. If you can't figure it out,\ngive LAN/internet installs a try, or copy your files to your SD card and\ntry the \"Install from SD Card\" option on the main menu!"
},
"top_info": "USB connection successful! Waiting for list of files to be sent...",
"top_info2": "Select what files you want to install over USB, then press the Plus button!",
"error": "USB transfer timed out or failed",
"source_string": " over USB",
"buttons": "\ue0e2 (Hold) Help \ue0e1 (Hold) Cancel",
"buttons2": "\ue0e0 Select File \ue0e3 Select All \ue0ef Install File(s) \ue0e1 Cancel"
},
"target": {
"desc0": "Where should ",
"desc1": " be installed to?",
"desc00": "Where should the selected ",
"desc01": " files be installed to?",
"opt0": "SD Card",
"opt1": "Internal Storage"
},
"info_page": {
"top_info0": "Installing ",
"preparing": "Preparing installation...",
"failed": "Failed to install ",
"failed_desc": "Partially installed contents can be removed from the System Settings applet.",
"complete": "Install complete",
"desc0": " files installed successfully!",
"desc1": " installed!",
"downloading": "Downloading ",
"at": " at "
},
"nca_verify": {
"title": "Invalid NCA signature detected!",
"desc": "Improperly signed software should only be installed from trustworthy\nsources. Files containing cartridge repacks and DLC unlockers will always\nshow this warning. You can disable this check in TinWoo Installer's settings.\n\nAre you sure you want to continue the installation?",
"opt1": "Yes, I understand the risks",
"error": "The requested NCA is not properly signed: "
},
"finished": [
"Enjoy your \"legal backups\"!",
"I'm sure after you give the game a try you'll have tons of fun actually buying it!",
"You buy gamu right? Nintendo-san thanka-you for your purchase!",
"Bypassing DRM is great, isn't it?",
"You probably saved like six trees by not buying the game! All that plastic goes somewhere!",
"Nintendo ninjas have been dispatched to your current location.",
"And we didn't even have to shove a political ideology down your throat to get here!"
]
},
"sig": {
"install": "Install",
"uninstall": "Uninstall",
"update": "Update",
"version_text": "You currently have signature patches installed for up to HOS version ",
"title0": "Install signature patches?",
"desc0": "Signature patches are required for installing and playing official software.",
"backup_failed": "Could not back up Hekate patches.ini! Install anyway?",
"backup_failed_desc": "If you don't use Hekate you can ignore this warning.",
"download_failed": "Could not download signature patches",
"download_failed_desc": "You may have supplied an invalid source in TinWoo Installer's settings,\nor the host may just be down right now.",
"version_text2": "Your signature patches have been updated for up to HOS version ",
"install_complete": "Install complete!",
"complete_desc": "Restart your console to apply",
"restart": "Restart",
"later": "I'll do it later",
"extract_failed": "Could not extract files!",
"restore_failed": "Unable to restore original Hekate patches.ini! Continue uninstalling?",
"uninstall_complete": "Uninstall complete",
"remove_failed": "Unable to remove signature patches",
"remove_failed_desc": "Files may have been renamed or deleted",
"generic_error": "Failed to install signature patches!"
},
"options": {
"menu_items": {
"ignore_firm": "Ignore minimum firmware version required by titles",
"nca_verify": "Verify NCA signatures before installation",
"boost_mode": "Enable \"boost mode\" during installations",
"ask_delete": "Ask to delete original files after installation",
"auto_update": "Check for updates to TinWoo Installer automatically",
"gay_option": "Use Theme",
"useSound": "Use sound notifications during installs",
"sig_url": "Signature patches source URL: ",
"language": "Language: ",
"check_update": "Check for updates to TinWoo Installer",
"credits": "Credits"
},
"nca_warn": {
"title": "Warning!",
"desc": "Some installable files may contain malicious contents! Only disable this\nfeature if you are absolutely certain the software you will be installing\nis trustworthy!\n\nDo you still want to disable NCA signature verification?",
"opt1": "Yes, I want a brick"
},
"sig_hint": "Enter the URL to obtain Signature Patches from",
"update": {
"title": "Update available",
"desc0": "TinWoo Installer ",
"desc1": " is available now! Ready to update?",
"opt0": "Update",
"top_info": "Updating to TinWoo Installer ",
"bot_info": "Downloading TinWoo Installer ",
"bot_info2": "Extracting TinWoo Installer ",
"complete": "Update complete!",
"failed": "Update failed!",
"end_desc": "The software will now be closed.",
"title_check_fail": "No updates found",
"desc_check_fail": "You are on the latest version of TinWoo Installer!"
},
"credits": {
"title": "Thanks to the following!",
"desc": "TinWoo - MrDude\nTinleaf - BlaWar\nAwoo Installer - Huntereb\nHard Drive Support - DarkMatterCore\n\n\nhttps://github.com/Huntereb/Awoo-Installer\nhttps://github.com/blawar/tinleaf\nhttps://github.com/DarkMatterCore/libusbhsfs\n\nThanks for testing - LyuboA"
},
"language": {
"title": "Select TinWoo Installer's language",
"desc": "The software will be closed after changing languages. Press B to cancel.",
"system_language": "System"
},
"title": "Change TinWoo Installer's settings!",
"buttons": "\ue0e0 Select/Change \ue0e1 Cancel"
},
"common": {
"ok": "OK",
"cancel": "Cancel",
"close": "Close",
"yes": "Yes",
"no": "No",
"cancel_desc": "Press B to cancel"
}
}

218
romfs/lang/fr.json Normal file
View File

@ -0,0 +1,218 @@
{
"main":{
"menu": {
"sd": "Installer à partir de la carte SD",
"net": "Installer à partir d'un LAN ou d'internet",
"usb": "Installer à partir d'un périphèrique USB",
"hdd": "Install over USB HDD",
"sig": "Gérer les patchs de signatures",
"set": " Paramètres",
"exit": " Quitter"
},
"theme": {
"title": "Use Theme",
"desc": "Press OK to quit Tinwoo or Cancel to continue.\n\nThemes will activate the next time you start Tinwoo."
},
"hdd": {
"title": "USB HDD",
"notfound": "USB HDD is not connected."
},
"net": {
"title": "Connection au réseau impossible",
"desc": "Vérifiez que le mode avion est désactivé et que vous êtes connecté à un réseau local."
},
"usb": {
"warn": {
"title": "Avertissement!",
"desc": "L'installation USB peut ne \"pas fonctionner\" sur certains appareils et certaines configurations.\nSi vous rencontrez des problèmes avec l'installation USB, ne vous arrachez pas\nles cheveux ! Il est conseillé d'utiliser NS-USBloader pour l'installation USB. Pour installer à distance, préfèrez les modes \nLAN/Internet, en particulier \nsi vous utilisez un adaptateur ethernet!\n\nVous avez été prévenu...",
"opt1": "Ne plus m'avertir"
},
"error": {
"title": "Aucune connection USB détéctée",
"desc": "Brancher un appareil compatible pour installer via le port USB"
}
},
"applet": {
"title": "Le mode Applet n'est pas compatible",
"desc": "Vous pouvez rencontrer des problèmes en utilisant TinWoo Installer en mode Applet. Si vous \navez des problèmes, veuillez lancer TinWoo en mode 'non-Applet'\n (Maintenez R pendant le démarrage d'un jeu)!"
},
"buttons": "\ue0e0 Select \ue0e1 Quitter"
},
"inst": {
"net": {
"help": {
"title": "Aide",
"desc": "Les fichiers peuvent être installés à distance depuis vos autres périphériques à l'aide d'outils\ntels que NS-USBloader en mode Tinfoil. Pour envoyer des fichiers à votre Switch, ouvrez l'un\nde ces logiciels sur votre PC ou votre appareil mobile, entrez\nl'adresse IP de votre Switch (indiquée à l'écran), sélectionnez vos fichiers, puis téléchargez-les\nsur votre console ! Si le logiciel que vous utilisez ne vous permet pas de sélectionner des types de fichiers\nspécifiques, essayez de modifier l'extension en quelque chose qu'il accepte.\nTinWoo Installer ne se soucie pas des extensions de fichiers lors des installations via le net !\n\nSi vous n'arrivez pas à comprendre, copiez simplement vos fichiers sur votre carte SD et essayez\nl'option \"Installer à partir de la carte SD\" depuis le menu principal!"
},
"src": {
"title": "D'où voulez-vous installer ?",
"opt0": "URL",
"opt1": "Google Drive"
},
"url": {
"hint": "Entrez l'URL d'un fichier",
"invalid": "L'URL spécifiée n'est pas valide !",
"source_string": " à partir d'un URL"
},
"gdrive": {
"hint": "Saisissez l'ID d'un fichier Google Drive public",
"alt_name": "Fichier Google Drive",
"source_string": " à partir de Google Drive"
},
"top_info": "Sélectionnez les fichiers que vous voulez installer à partir du serveur, puis appuyez sur le bouton Plus !",
"top_info1": "En attente d'une connexion... L'adresse IP de votre switch est : ",
"failed": "Echec de l'installation à distance !",
"transfer_interput": "Une erreur s'est produite pendant le transfert des données. Vérifiez votre connexion réseau.",
"source_string": " à partir d'un réeseau local",
"buttons": "\ue0e3 Installer via Internet \ue0e2 Aide \ue0e1 Annuler",
"buttons1": "\ue0e0 Sélectionnez un fichier \ue0e3 Tout sélectionner \ue0ef Installer un/des fichier(s) \ue0e1 Annuler"
},
"sd": {
"help": {
"title": "Aide",
"desc": "Copiez vos fichiers NSP, NSZ, XCI ou XCZ sur votre carte SD, recherchez et\nsélectionnez ceux que vous voulez installer, puis appuyez sur le bouton Plus."
},
"top_info": "Sélectionnez les fichiers que vous voulez installer, puis appuyez sur le bouton Plus !",
"source_string": " à partir de la carte SD",
"delete_info": " Installation réussie! Supprimer de la carte SD?",
"delete_info_multi": " fichiers installés avec succès ! Les supprimer de la carte SD ?",
"delete_desc": "Les fichiers originaux ne sont plus nécessaires une fois qu'ils ont été installés.",
"buttons": "\ue0e0 Sélectionnez un fichier \ue0e3 Tout sélectionner \ue0ef Installer un/des fichier(s) \ue0e2 Aide \ue0e1 Annuler"
},
"hd": {
"help": {
"title": "Help",
"desc": "Copy your NSP, NSZ, XCI, or XCZ files to your hard drive, browse to and\nselect the ones you want to install, then press the Plus button."
},
"top_info": "Select the files you want to install, then press the Plus button!",
"source_string": " from hard drive",
"delete_info": " installed\nDelete it from the hard drive?",
"delete_info_multi": " files installed successfully!\nDelete them from the hard drive?",
"delete_desc": "The original files aren't needed anymore after they've been installed",
"buttons": "\ue0e0 Select File \ue0e3 Select All \ue0ef Install File(s) \ue0e2 Help \ue0e1 Cancel"
},
"usb": {
"help": {
"title": "Aide",
"desc": "Les fichiers peuvent être installés à partir du port USB depuis vos autres périphériques à l'aide d'outils\ntels que NS-USBloader en mode Tinfoil. Pour envoyer des fichiers à votre Switch, ouvrez un\nde ces logiciels sur votre PC, sélectionnez vos fichiers, puis téléchargez-les\nsur votre console !\n\nMalheureusement, les installations USB nécessitent une configuration spécifique sur certaines\nplates-formes, et peuvent parfois être assez buggées. Si vous n'arrivez pas à comprendre,\nessayez les installations LAN/internet, ou copiez vos fichiers sur votre carte SD et\nessayezl'option \"Installer à partir de la carte SD\" depuis le menu principal!"
},
"top_info": "Connexion USB réussie ! En attente de l'envoi de la liste des fichiers...",
"top_info2": "Sélectionnez les fichiers que vous voulez installer par USB, puis appuyez sur le bouton Plus !",
"error": "Le transfert USB a été interrompu ou a échoué",
"source_string": " à partir d'un périphèrique USB",
"buttons": "\ue0e2 (Maintenir) Aide \ue0e1 (Maintenir) Annuler",
"buttons2": "\ue0e0 Sélectionnez un fichier \ue0e3 Tout sélectionner \ue0ef Installer un/des fichier(s) \ue0e1 Annuler"
},
"target": {
"desc0": "Où ",
"desc1": " doit-il être installé?",
"desc00": "Où les fichier sélectionnés",
"desc01": " doivent-ils aller ?",
"opt0": "Carte SD",
"opt1": "Stockage Interne"
},
"info_page": {
"top_info0": "Installation ",
"preparing": "Préparation de l'installation...",
"failed": "Installation échouée ",
"failed_desc": "Le contenu partiellement installé peut être supprimé depuis les paramètres systèmes de l'applet.",
"complete": "Installation complète",
"desc0": " fichiers installés avec succès !",
"desc1": " installé !",
"downloading": "Téléchargement ",
"at": " à "
},
"nca_verify": {
"title": "Signature NCA invalide détectée!",
"desc": "Les logiciels incorrectement signés ne doivent être installés qu'à partir de\nsources dignes de confiance. Les fichiers contenant des repacks de cartouches et des DLC\nafficheront toujours cet avertissement. Vous pouvez désactiver cette vérification dans les paramètres de TinWoo Installer.\n\nEtes-vous sûr de vouloir continuer l'installation ?",
"opt1": "Oui, je comprends les risques",
"error": "Le NCA demandé n'est pas correctement signé: "
},
"finished": [
"Profitez bien de vos \"backups légaux\"!",
"Je suis sûr qu'après avoir essayé le jeu, vous prendrez beaucoup de plaisir à l'acheter !",
"Vous achetez vos jeux ? Nintendo-san vous remercie de votre achat!",
"Contourner les DRM, c'est génial, non ?",
"Vous avez probablement sauvé genre six arbres en n'achetant pas le jeu ! Tout ce plastique va bien quelque part !",
"Des ninjas Nintendo ont été envoyés à votre emplacement actuel.",
"Et nous n'avons même pas eu à vous enfoncer une idéologie politique dans le crâne pour en arriver là !"
]
},
"sig": {
"install": "Installer",
"uninstall": "Désinstaller",
"update": "Mettre à jour",
"version_text": "Vous avez actuellement des patches de signature installés pour la version HOS ",
"title0": "Installer les patchs de signature ?",
"desc0": "Les patchs de signature sont nécessaires pour installer et utiliser les logiciels officiels.",
"backup_failed": "Impossible de sauvegarder le fichier Patches.ini d'Hekate ! Installer quand même ?",
"backup_failed_desc": "Si vous n'utilisez pas Hekate, vous pouvez ignorer cet avertissement.",
"download_failed": "Impossible de télécharger les patchs de signature",
"download_failed_desc": "Vous avez peut-être fourni une source invalide dans les paramètres de l'installateur TinWoo,\nou l'hôte est peut-être juste en panne en ce moment.",
"version_text2": "Vos patchs de signature ont été mis à jour pour la version d'HOS ",
"install_complete": "Installation complète !",
"complete_desc": "Redémarrez votre console pour appliquer",
"restart": "Redémarrer",
"later": "Je le ferai plus tard.",
"extract_failed": "Impossible d'extraire les fichiers !",
"restore_failed": "Impossible de restaurer le fichier original patches.ini d'Hekate ! Continuer à désinstaller ?",
"uninstall_complete": "Désinstallation complète",
"remove_failed": "Impossible de supprimer les patchs de signature",
"remove_failed_desc": "Les fichiers ont peut-être été renommés ou supprimés",
"generic_error": "Echec de l'installation des patchs de signature !"
},
"options": {
"menu_items": {
"ignore_firm": "Ignorez la version minimale de firmware requise par les jeux",
"nca_verify": "Vérifier les signatures des NCA avant l'installation",
"boost_mode": "Activer le \"boost mode\" pendant l'installation",
"ask_delete": "Demande de suppression des fichiers originaux après l'installation",
"auto_update": "Vérifier les mises à jour de l'installateur TinWoo automatiquement",
"gay_option": "Utiliser le thème",
"useSound": "Use sound notifications during installs",
"sig_url": "Patchs de signatures URL: ",
"language": "Langage: ",
"check_update": "Vérifiez les mises à jour de l'installateur TinWoo",
"credits": "Crédits"
},
"nca_warn": {
"title": "Avertissement!",
"desc": "Certains fichiers installables peuvent contenir des contenus malveillants ! Ne désactivez cette fonction\nque si vous êtes absolument certain que le logiciel que vous allez installer est\ndigne de confiance !\n\nVoulez-vous toujours désactiver la vérification de la signature des NCA ?",
"opt1": "Oui, je veux brick ma Switch"
},
"sig_hint": "Entrez l'URL pour obtenir les patches de signature",
"update": {
"title": "Mise à jour disponible",
"desc0": "TinWoo Installer ",
"desc1": " est disponible dès maintenant ! Prêt à mettre à jour ?",
"opt0": "Mise à jour",
"top_info": "Mise à jour de l'installateur TinWoo ",
"bot_info": "Téléchargement de l'installateur TinWoo ",
"bot_info2": "Extraction de l'installateur TinWoo ",
"complete": "Mise à jour complète !",
"failed": "La mise à jour a échoué !",
"end_desc": "Le logiciel sera maintenant fermé.",
"title_check_fail": "Aucune mise à jour trouvée",
"desc_check_fail": "Vous êtes sur la dernière version de TinWoo Installer !"
},
"credits": {
"title": "Merci aux personnes suivantes !",
"desc": "TinWoo - MrDude\nTinleaf - BlaWar\nAwoo Installer - Huntereb\nHard Drive Support - DarkMatterCore\n\n\nhttps://github.com/Huntereb/Awoo-Installer\nhttps://github.com/blawar/tinleaf\nhttps://github.com/DarkMatterCore/libusbhsfs\n\nThanks for testing - LyuboA"
},
"language": {
"title": "Sélectionnez la langue de TinWoo Installer",
"desc": "Le logiciel sera fermé après avoir changé de langue. Appuyez sur B pour annuler.",
"system_language": "Système"
},
"title": "Modifiez les paramètres de TinWoo Installler !",
"buttons": "\ue0e0 Sélectionner/Modifier \ue0e1 Annuler"
},
"common": {
"ok": "OK",
"cancel": "Annuler",
"close": "Fermer",
"yes": "Oui",
"no": "Non",
"cancel_desc": "Appuyez sur B pour annuler"
}
}

218
romfs/lang/it.json Normal file
View File

@ -0,0 +1,218 @@
{
"main":{
"menu": {
"sd": "Installa dalla SD",
"net": "Installa via LAN o da internet",
"usb": "Installa via USB",
"hdd": "Install over USB HDD",
"sig": "Gestisci le SigPatches",
"set": "Impostazioni",
"exit": "Esci"
},
"theme": {
"title": "Use Theme",
"desc": "Press OK to quit Tinwoo or Cancel to continue.\n\nThemes will activate the next time you start Tinwoo."
},
"hdd": {
"title": "USB HDD",
"notfound": "USB HDD is not connected."
},
"net": {
"title": "Connessione alla rete non disponibile",
"desc": "Controlla che la modalità aereo sia disattivata e che tu sia connesso ad una rete."
},
"usb": {
"warn": {
"title": "Attenzione!",
"desc": "L'installazione USB potrebbe non funzionare su alcuni dispositivi e in alcune configurazioni.\nSe stai incontrando dei problemi con l'installazione USB, non disperare!\nÈ consigliato usare NS-USBloader per le installazioni via USB, mentre\nLAN/Internet per le installazioni remote, specie\nquando si utilizza un adattatore ethernet!\n\nSei stato avvertito...",
"opt1": "Non dirmelo di nuovo!"
},
"error": {
"title": "Nessuna connessione USB rilevata",
"desc": "Collega a un dispositivo compatibile per installare via USB"
}
},
"applet": {
"title": "Applet Mode non è supportata",
"desc": "Puoi incontrare problemi utilizzando TinWoo Installer in Applet Mode. Se\nriscontri problemi, ti prego di utilizzare TinWoo Installer avviandolo attraverso un gioco\ngià installato (tieni premuto R mentre avvii un gioco)!"
},
"buttons": "\ue0e0 Seleziona \ue0e1 Esci"
},
"inst": {
"net": {
"help": {
"title": "Aiuto",
"desc": "I file possono essere installati via remoto da altri dispositivi utilizzando programmi come\nNS-USBloader in modialità \"Tinfoil\". Per inviare file, apri uno\ndi questi software sul tuo PC o sul tuo smartphone, inserisci\nl'indirizzo IP (mostrato sullo schermo), seleziona i file e poi inviali alla\nconsole! Se il software che usi non ti permette di selezionare file\nspecifici, prova a cambiare l'estensione del file in qualcosa che venga accettato dal software.\nTinWoo Installer non legge l'estensione del file durante l'installazione via internet!\n\nSe proprio non riesci, copia i file nella SD e seleziona\nl'opzione \"Installa dalla SD\" dal menù principale!"
},
"src": {
"title": "Da dove vuoi installare?",
"opt0": "URL",
"opt1": "Google Drive"
},
"url": {
"hint": "Inserisci l'URL del file",
"invalid": "L'URL specificato non è valido!",
"source_string": " da URL"
},
"gdrive": {
"hint": "Inserisci l'ID di un file pubblico di Google Drive",
"alt_name": "File Google Drive",
"source_string": " da Google Drive"
},
"top_info": "Seleziona quali file vuoi installare dal server, poi premi il tasto Più!",
"top_info1": "Aspettando una connnessione... L'indirizzo IP è: ",
"failed": "Impossibile eseguire l'installazione remota!",
"transfer_interput": "Si è verificato un errore durante il trasferimento dei dati. Controlla la tua connessione.",
"source_string": " via rete locale",
"buttons": "\ue0e3 Installa via internet \ue0e2 Aiuto \ue0e1 Annulla",
"buttons1": "\ue0e0 Seleziona File \ue0e3 Seleziona tutto \ue0ef Installa i File \ue0e1 Annulla"
},
"sd": {
"help": {
"title": "Aiuto",
"desc": "Copia i tuoi file NSP, NSZ, XCI, o XCZ nella SD, cercali e\nseleziona quelli che vuoi installare, poi premi Il tasto Più."
},
"top_info": "Seleziona quali file vuoi installare, poi premi Il tasto Più!",
"source_string": " dalla SD",
"delete_info": " installato! Cancellarlo dalla SD?",
"delete_info_multi": " file installati correttamente! Cancellarli dalla SD?",
"delete_desc": "I file originali non sono più necessari dopo averli installati",
"buttons": "\ue0e0 Seleziona File \ue0e3 Seleziona tutto \ue0ef Installa i File \ue0e2 Aiuto \ue0e1 Annulla"
},
"hd": {
"help": {
"title": "Help",
"desc": "Copy your NSP, NSZ, XCI, or XCZ files to your hard drive, browse to and\nselect the ones you want to install, then press the Plus button."
},
"top_info": "Select the files you want to install, then press the Plus button!",
"source_string": " from hard drive",
"delete_info": " installed\nDelete it from the hard drive?",
"delete_info_multi": " files installed successfully!\nDelete them from the hard drive?",
"delete_desc": "The original files aren't needed anymore after they've been installed",
"buttons": "\ue0e0 Select File \ue0e3 Select All \ue0ef Install File(s) \ue0e2 Help \ue0e1 Cancel"
},
"usb": {
"help": {
"title": "Aiuto",
"desc": "I file possono essere installati via USB da altri dispositivi utilizzando programmi come\nNS-USBloader in modalità \"Tinfoil\". Per inviare i file, apri uno di\nquesti software sul tuo PC, seleziona i file, poi mandali\nalla console!\n\nSfortunatamente l'installazione via USB richiede configurazioni specifiche in certe\npiattaforme, che possono non funzionare correttamente alle volte. Se proprio non riesci,\ndai una possibilità all'installazione via LAN/internet, o copia i file nella SD e\nseleziona l'opzione \"Installa dalla SD\" nel menù principale!"
},
"top_info": "Connessione USB avvenuta correttamete! Aspetto che la lista dei file venga inviata...",
"top_info2": "Seleziona quali file vuoi installare via USB, poi premi il tasto Più!",
"error": "Trasferimento USB scaduto o fallito",
"source_string": " via USB",
"buttons": "\ue0e2 (Tieni premuto) Aiuto \ue0e1 (Tieni premuto) Annulla",
"buttons2": "\ue0e0 Seleziona File \ue0e3 Seleziona tutto \ue0ef Installa i File \ue0e1 Annulla"
},
"target": {
"desc0": "Dove dovrebbe ",
"desc1": " essere installato?",
"desc00": "Dove dovrebbero essere ",
"desc01": " instalalti i file selezionati?",
"opt0": "SD",
"opt1": "Memoria interna"
},
"info_page": {
"top_info0": "Sto installando ",
"preparing": "Preparando l'installazione...",
"failed": "Installazione fallita ",
"failed_desc": "I contenuti parzialmente installati possono essere rimossi dalle Impostazioni di sistema.",
"complete": "Installazione completa",
"desc0": " file installati correttamente!",
"desc1": " installato!",
"downloading": "Sto scaricando ",
"at": " in "
},
"nca_verify": {
"title": "Rilevata firma NCA non valida!",
"desc": "Software firmati impropriamente dovrebbero essere installati solo da fonti\nsicure. I file che contengono repack di cartucce e DLC mostreranno sempre\nquesto avviso. Puoi disabilitarlo dalle impostazioni di TinWoo Installer.\n\nSei sicuro di voler continuare l'installazione?",
"opt1": "Sì, comprendo il rischio",
"error": "Il file NCA seguente non è firmato correttamente: "
},
"finished": [
"Goditi i tuoi \"backup legali\"!",
"Sono sicuro che dopo che lo proverai, ti divertirai tantissimo a comprarlo!",
"Hai comprato il giochino, vero? Nintendo-san ti linglazia pel il tuo acquisto!",
"Bypassare il DRM è fantastico, vero?",
"Probabilmente hai salvato sei alberi non comprando il gioco! Tutta quella plastica va da qualche parte!",
"I ninja di Nintendo sono stati mandati alla tua attuale posizione.",
"E non abbiamo nemmeno dovuto farti mandare giù un'ideologia politica per farti arrivare qui!"
]
},
"sig": {
"install": "Installa",
"uninstall": "Disinstalla",
"update": "Aggiorna",
"version_text": "Le SigPatches sono già installate per la versione corrente di HOS ",
"title0": "Installare le SigPatches?",
"desc0": "Le SigPatches sono necessarie per installare e per giocare ai software ufficiali.",
"backup_failed": "Non è stato possibile effettuare il backup del file \"patches.ini\" di Hekate! Installare comunque?",
"backup_failed_desc": "Se non usi Hekate puoi ignorare questo avviso.",
"download_failed": "Non è stato possibile scaricare le SigPatches",
"download_failed_desc": "Puoi aver utilizzato una fonte non valida nelle impostazioni di TinWoo Installer,\no la fonte potrebbe non essere raggiungibile al momento.",
"version_text2": "Le SigPatches sono state aggiornate per la versione corrente di HOS ",
"install_complete": "Installazione completata!",
"complete_desc": "Riavvia la console per applicare i cambiamenti",
"restart": "Riavvia",
"later": "Lo farò dopo",
"extract_failed": "Non è stato possibile estrarre i file!",
"restore_failed": "Impossibile ripristinare il file \"patches.ini\" originale! Continuare a disinstallare?",
"uninstall_complete": "Disinstallazione completa",
"remove_failed": "Impossibile rimuovere le SigPatches",
"remove_failed_desc": "I file potrebbero essere stati rinominati o cancellati",
"generic_error": "Impossibile installare le SigPatches!"
},
"options": {
"menu_items": {
"ignore_firm": "Ignora la versione minima del firmware richiesta dai titoli",
"nca_verify": "Verifica le firme NCA prima dell'installazione",
"boost_mode": "Abilita la \"boost mode\" durante le installazioni",
"ask_delete": "Chiedi di cancellare i file originale dopo l'installazione",
"auto_update": "Controlla aggiornamenti di TinWoo Installer automaticamente",
"gay_option": "Usa tema",
"useSound": "Use sound notifications during installs",
"sig_url": "Fonte URL SigPatches: ",
"language": "Lingua: ",
"check_update": "Controlla aggiornamenti di TinWoo Installer ora",
"credits": "Crediti"
},
"nca_warn": {
"title": "Attenzione!",
"desc": "Alcuni file potrebbero avere contenuti malevoli! Disabilita questa\nopzione solo se sei assolutamente certi che i file che si stanno installando\nsono sicuri!\n\nVuoi ancora disabilitare la verifica della firma NCA?",
"opt1": "Sì, sono sicuro!"
},
"sig_hint": "Inserisci l'URL da cui ottenere le SigPatches",
"update": {
"title": "Aggiornamento disponibile",
"desc0": "TinWoo Installer ",
"desc1": " è disponibile adesso! Pronto per aggiornare?",
"opt0": "Aggiorna",
"top_info": "Aggiornamento ad TinWoo Installer ",
"bot_info": "Sto scaricando TinWoo Installer ",
"bot_info2": "Sto estraendo TinWoo Installer ",
"complete": "Aggiornamento completato!",
"failed": "Aggiornamento fallito!",
"end_desc": "Il software verrà chiuso.",
"title_check_fail": "Nessun aggiornamento disponibile",
"desc_check_fail": "Stai usando l'ultima versione di TinWoo Installer!"
},
"credits": {
"title": "Un ringraziamento alle seguenti persone!",
"desc": "TinWoo - MrDude\nTinleaf - BlaWar\nAwoo Installer - Huntereb\nHard Drive Support - DarkMatterCore\n\n\nhttps://github.com/Huntereb/Awoo-Installer\nhttps://github.com/blawar/tinleaf\nhttps://github.com/DarkMatterCore/libusbhsfs\n\nThanks for testing - LyuboA"
},
"language": {
"title": "Seleziona la lingua di TinWoo Installer",
"desc": "Il software verrà chiuso dopo aver cambiato la lingua. Premi B per annullare.",
"system_language": "Sistema"
},
"title": "Cambia le impostazioni di TinWoo Installer!",
"buttons": "\ue0e0 Seleziona/Cambia \ue0e1 Annulla"
},
"common": {
"ok": "OK",
"cancel": "Annulla",
"close": "Chiudi",
"yes": "Sì",
"no": "No",
"cancel_desc": "Premi B per annullare"
}
}

218
romfs/lang/jp.json Normal file
View File

@ -0,0 +1,218 @@
{
"main":{
"menu": {
"sd": "SDカードからインストール",
"net": "LANまたはインターネット経由でインストール",
"usb": "USB経由でインストール",
"hdd": "Install over USB HDD",
"sig": "署名パッチを管理する",
"set": "設定",
"exit": "終了"
},
"theme": {
"title": "Use Theme",
"desc": "Press OK to quit Tinwoo or Cancel to continue.\n\nThemes will activate the next time you start Tinwoo."
},
"hdd": {
"title": "USB HDD",
"notfound": "USB HDD is not connected."
},
"net": {
"title": "ネットワーク接続は利用できません",
"desc": "機内モードが無効になっていて、ローカルネットワークに接続していることを確認してください。"
},
"usb": {
"warn": {
"title": "警告!",
"desc": "USBのインストールは、一部のデバイスおよびセットアップでは動作しない場合があります。\nUSBのインストールで問題が発生した場合は、ケーブルを抜かないでください。 \nUSBインストールにはNS-USBloaderを、リモートインストールには代わりにLAN /インターネットインストールに使用することをお勧めします。\n特に、イーサネットアダプターと組み合わせた場合は警告されています...",
"opt1": "次回から表示しない"
},
"error": {
"title": "USB接続が検出されません",
"desc": "互換性のあるデバイスに接続してUSB経由でインストールする"
}
},
"applet": {
"title": "アプレットモードはサポートされていません",
"desc": "アプレットモードでTinWooを使用すると問題が発生する場合があります。\n問題が発生した場合は、インストール済みのタイトルでTinWooを実行するように切り替えてください\n(ゲームの開始中にRを押したままにしてください)!"
},
"buttons": "\ue0e0 選択 \ue0e1 終了"
},
"inst": {
"net": {
"help": {
"title": "ヘルプ",
"desc": "TinfoilモードのNS-USBloaderなどのツールを使用して、他のデバイスからファイルをリモートでインストールできます。\nスイッチにファイルを送信するには、PCまたはモバイルデバイスでこれらのソフトウェアのいずれかを開き、\nスイッチのIPアドレス画面に表示を入力し、ファイルを選択して、コンソールにアップロードします\n使用しているソフトウェアで特定のファイルタイプを選択できない場合は、\n拡張子の名前を受け入れ可能なものに変更してください。\nTinWooはネット経由のインストール中にファイル拡張子を気にしません\n\n分からない場合は、ファイルをSDカードにコピーして\nメインメニューの[SDカードからインストール]オプションを試してください。"
},
"src": {
"title": "どこからインストールしますか?",
"opt0": "URL",
"opt1": "Googleドライブ"
},
"url": {
"hint": "ファイルのインターネットアドレスを入力してください",
"invalid": "指定されたURLは無効です",
"source_string": " URLから"
},
"gdrive": {
"hint": "Googleドライブの公開ファイルのファイルIDを入力してください",
"alt_name": "Googleドライブファイル",
"source_string": " Googleドライブから"
},
"top_info": "サーバーからインストールするファイルを選択し、+ボタンを押してください!",
"top_info1": "接続を待機しています...スイッチのIPアドレスは次のとおりです。: ",
"failed": "リモートインストールを実行できませんでした!",
"transfer_interput": "データ転送中にエラーが発生しました。ネットワーク接続を確認してください。",
"source_string": " ローカルネットワーク経由",
"buttons": "\ue0e3 インターネット経由でインストールする \ue0e2 ヘルプ \ue0e1 キャンセル",
"buttons1": "\ue0e0 ファイルを選択 \ue0e3 すべて選択 \ue0ef ファイルをインストール \ue0e1 キャンセル"
},
"sd": {
"help": {
"title": "ヘルプ",
"desc": "NSP、NSZ、XCI、またはXCZファイルをSDカードにコピーし、\nインストールするファイルを参照して選択し、ボタンを押します。"
},
"top_info": "インストールするファイルを選択し、+ボタンを押してください!",
"source_string": " SDカードから",
"delete_info": " インストール完了! SDカードから削除しますか",
"delete_info_multi": " ファイルが正常にインストールされました! SDカードから削除しますか",
"delete_desc": "元のファイルはインストール後に不要になりました",
"buttons": "\ue0e0 ファイルを選択 \ue0e3 すべて選択 \ue0ef ファイルをインストール \ue0e2 ヘルプ \ue0e1 キャンセル"
},
"hd": {
"help": {
"title": "Help",
"desc": "Copy your NSP, NSZ, XCI, or XCZ files to your hard drive, browse to and\nselect the ones you want to install, then press the Plus button."
},
"top_info": "Select the files you want to install, then press the Plus button!",
"source_string": " from hard drive",
"delete_info": " installed\nDelete it from the hard drive?",
"delete_info_multi": " files installed successfully!\nDelete them from the hard drive?",
"delete_desc": "The original files aren't needed anymore after they've been installed",
"buttons": "\ue0e0 Select File \ue0e3 Select All \ue0ef Install File(s) \ue0e2 Help \ue0e1 Cancel"
},
"usb": {
"help": {
"title": "ヘルプ",
"desc": "TinfoilモードのNS-USBloaderなどのツールを使用して、\n他のデバイスからUSB経由でファイルをインストールできます。 スイッチにファイルを送信するには、PCでこれらのソフトウェアのいずれかを開き、\nファイルを選択して、コンソールにアップロードします\n\n残念ながら、一部のプラットフォームではUSBのインストールに特定のセットアップが必要であり、\nかなりバグが多い場合があります。わからない場合は、\nLAN /インターネットインストールを試してみるか、ファイルをSDカードにコピーして、\nメインメニューの[SDカードからインストール]オプションを試してください!"
},
"top_info": "USB接続に成功しましたファイルのリストが送信されるのを待っています...",
"top_info2": "USB経由でインストールするファイルを選択し、ボタンを押します",
"error": "USB転送がタイムアウトまたは失敗した",
"source_string": " USB経由",
"buttons": "\ue0e2 (押す) ヘルプ \ue0e1 (押す) キャンセル",
"buttons2": "\ue0e0 ファイルを選択 \ue0e3 すべて選択 \ue0ef ファイルをインストール \ue0e1 キャンセル"
},
"target": {
"desc0": "どこに ",
"desc1": " をインストールしますか?",
"desc00": "選択すべき場所 ",
"desc01": " ファイルをインストールしますか?",
"opt0": "SDカード",
"opt1": "内部ストレージ"
},
"info_page": {
"top_info0": "インストール中 ",
"preparing": "インストールの準備...",
"failed": "インストールに失敗しました ",
"failed_desc": "部分的にインストールされたコンテンツは、システム設定アプレットから削除できます。",
"complete": "インストール完了",
"desc0": " ファイルが正常にインストールされました!",
"desc1": " インストール完了!",
"downloading": "ダウンロード中 ",
"at": " に "
},
"nca_verify": {
"title": "無効なNCA署名が検出されました!",
"desc": "不適切に署名されたソフトウェアは、信頼できるソースからのみインストールする必要があります。\nカートリッジの再梱包とDLCロック解除を含むファイルには、常にこの警告が表示されます。\nTinWooの設定でこのチェックを無効にできます。\n\nインストールを続行してもよろしいですか",
"opt1": "はい、リスクを理解しています",
"error": "要求されたNCAは適切に署名されていません: "
},
"finished": [
"バックアップをお楽しみください!",
"そのゲームは自分で購入したものですか?",
"任天堂ありがとう!",
"DRMのバイパスは素晴らしいでしょ?",
"ダウンロード版を購入することで自然環境保護に協力しましょう!",
"任天堂の諜報員があなたの現在の場所に派遣されました。",
"ここに到達するために政治的なイデオロギーを喉に押し込む必要さえありませんでした!"
]
},
"sig": {
"install": "インストール",
"uninstall": "アンインストール",
"update": "アップデート",
"version_text": "現在、HOSバージョンまでの署名パッチがインストールされています ",
"title0": "署名パッチをインストールしますか?",
"desc0": "公式のソフトウェアをインストールして再生するには、署名パッチが必要です。",
"backup_failed": "Hekate patch.iniをバックアップできませんでしたそれでもインストールしますか?",
"backup_failed_desc": "Hekateを使用しない場合、この警告は無視できます。",
"download_failed": "署名パッチをダウンロードできませんでした",
"download_failed_desc": "TinWooの設定で無効なソースを指定したか、\nホストが現在ダウンしている可能性があります。",
"version_text2": "署名パッチがHOSバージョンまで更新されました ",
"install_complete": "インストール完了!",
"complete_desc": "本体を再起動して適用します",
"restart": "再起動",
"later": "後でやります",
"extract_failed": "ファイルを抽出できませんでした!",
"restore_failed": "元のHekate patch.iniを復元できませんアンインストールを続行しますか",
"uninstall_complete": "アンインストール完了",
"remove_failed": "署名パッチを削除できません",
"remove_failed_desc": "ファイルの名前が変更または削除された可能性があります",
"generic_error": "署名パッチのインストールに失敗しました!"
},
"options": {
"menu_items": {
"ignore_firm": "タイトルに必要な最小ファームウェアバージョンを無視する",
"nca_verify": "インストール前にNCA署名を検証する",
"boost_mode": "インストール中に「ブーストモード」を有効にする",
"ask_delete": "インストール後に元のファイルを削除する",
"auto_update": "TinWooのアップデートを自動的に確認する",
"gay_option": "テーマを使用する",
"useSound": "Use sound notifications during installs",
"sig_url": "署名パッチのソースURL: ",
"language": "言語: ",
"check_update": "TinWoo Installerのアップデートを確認",
"credits": "クレジット"
},
"nca_warn": {
"title": "警告!",
"desc": "一部のインストール可能なファイルには悪意のあるコンテンツが含まれている場合があります!\nこの機能は、インストールするソフトウェアが信頼できると確信している場合にのみ無効にしてください!\n\nそれでもNCA署名検証を無効にしますか?",
"opt1": "はい、故障しても大丈夫です"
},
"sig_hint": "署名パッチを取得するURLを入力します",
"update": {
"title": "更新可能",
"desc0": "TinWoo Installer ",
"desc1": " 現在入手可能です!更新する準備ができましたか?",
"opt0": "アップデート",
"top_info": "TinWoo Installerを更新 ",
"bot_info": "TinWoo Installerをダウンロード中 ",
"bot_info2": "TinWoo Installerを展開中 ",
"complete": "更新完了!",
"failed": "更新失敗!",
"end_desc": "これでソフト​​ウェアが閉じられます。",
"title_check_fail": "更新が見つかりません",
"desc_check_fail": "既にTinWoo Installerの最新バージョンを使用しています!"
},
"credits": {
"title": "以下の方々に感謝します!",
"desc": "TinWoo - MrDude\nTinleaf - BlaWar\nAwoo Installer - Huntereb\nHard Drive Support - DarkMatterCore\n\n\nhttps://github.com/Huntereb/Awoo-Installer\nhttps://github.com/blawar/tinleaf\nhttps://github.com/DarkMatterCore/libusbhsfs\n\nThanks for testing - LyuboA"
},
"language": {
"title": "TinWoo Installerの言語を選択",
"desc": "言語を変更した後、ソフトウェアは閉じられます。 Bを押してキャンセルします。",
"system_language": "システムのデフォルト"
},
"title": "TinWoo Installerの設定を変更する",
"buttons": "\ue0e0 選択/変更 \ue0e1 キャンセル"
},
"common": {
"ok": "OK",
"cancel": "キャンセル",
"close": "閉じる",
"yes": "はい",
"no": "いいえ",
"cancel_desc": "Bを押してキャンセル"
}
}

218
romfs/lang/ru.json Normal file
View File

@ -0,0 +1,218 @@
{
"main":{
"menu": {
"sd": "Установка из SD-карты",
"net": "Установка по сети",
"usb": "Установка через USB",
"hdd": "Install over USB HDD",
"sig": "Управление sig-patches",
"set": "Настройки",
"exit": "Выход"
},
"theme": {
"title": "Use Theme",
"desc": "Press OK to quit Tinwoo or Cancel to continue.\n\nThemes will activate the next time you start Tinwoo."
},
"hdd": {
"title": "USB HDD",
"notfound": "USB HDD is not connected."
},
"net": {
"title": "Сетевое подключение недоступно",
"desc": "Удостоверьтесь что авиарежим отключён и вы подключены к локальной сети."
},
"usb": {
"warn": {
"title": "Внимание!",
"desc": "Иногда на некоторых устройствах установка через USB не может \"просто работать\".\nЕсли с этим у вас возникли трудности не спешите рвать на себе волосы!\nРекомендуется использовать NS-USBloader для установки через USB или же установки\nпо сети, особенно если у вас есть проводной адаптер!\n\nВы предупреждены...",
"opt1": "Не показывать снова"
},
"error": {
"title": "Нет USB подключения",
"desc": "Для установки через USB подключитесь к совместимому устройству"
}
},
"applet": {
"title": "Applet Mode не поддерживается",
"desc": "В TinWoo Installer могут возникать проблемы когда и если он запущен в режиме апплета.\nЕсли у вас есть трудности, пожалуйста запустите приложение через установленную игру\n(зажмите R при запуске)!"
},
"buttons": "\ue0e0 Выбрать \ue0e1 Выход"
},
"inst": {
"net": {
"help": {
"title": "Помощь",
"desc": "Файлы могут быть установленны удалённо из другого вашего устройства используя такие утилиты как\nNS-USBloader в режиме Tinfoil. Чтобы передать файлы на Switch откройте одно из этих замечательных\nприложений на вашем ПК или мобильном устройстве, введите IP адрес вашего Switch (отображается на экране),\nвыберите файлы и затем загрузите их в вашу консоль! Если приложение которое вы используете не позволяет\nвыбрать определённый формат файла, попробуйте изменить его расширение.\nTinWoo Installer не чувствителен\nк расширениям файла при установке по сети!\n\nЕсли вы ничего не поняли, просто скопируйте файлы на SD-карту и выберите в главном меню опцию\n\"Установка из SD-карты\"!"
},
"src": {
"title": "Откуда будем устанавливать?",
"opt0": "URL",
"opt1": "Google Drive"
},
"url": {
"hint": "Укажите ссылку на файл",
"invalid": "Указан неверный URL!",
"source_string": " из URL"
},
"gdrive": {
"hint": "Введите ID файла из общедоступного Google Drive",
"alt_name": "Файл Google Drive",
"source_string": " из Google Drive"
},
"top_info": "Выберите какие файлы вы хотите установить из сервера и нажмите \"+\"!",
"top_info1": "Ожидание подключения... IP-адрес вашего Switch: ",
"failed": "Не удалось выполнить установку из удалённого источника!",
"transfer_interput": "Во время передачи возникла ошибка. Проверьте ваши настройки сети.",
"source_string": " по локальной сети",
"buttons": "\ue0e3 Установка через интернет \ue0e2 Помощь \ue0e1 Отмена",
"buttons1": "\ue0e0 Выбрать файл \ue0e3 Выбрать всё \ue0ef Установить файл(ы) \ue0e1 Отмена"
},
"sd": {
"help": {
"title": "Помощь",
"desc": "Скопируйте ваши NSP, NSZ, XCI или XCZ файлы на SD-карту, перейдите в неё и \nвыберите то, что хотите установить. Затем нажмите на \"+\"."
},
"top_info": "Выберите файлы, которые вы хотите установить и нажмите \"+\"!",
"source_string": " из SD-карты",
"delete_info": " установлен! Удалить файл с SD-карты?",
"delete_info_multi": " файлы успешно установлены! Удалить их из SD-карты?",
"delete_desc": "После того, как файлы установлены, они больше не требуются.",
"buttons": "\ue0e0 Выбрать файл \ue0e3 Выбрать всё \ue0ef Установить файл(ы) \ue0e2 Помощь \ue0e1 Отмена "
},
"hd": {
"help": {
"title": "Help",
"desc": "Copy your NSP, NSZ, XCI, or XCZ files to your hard drive, browse to and\nselect the ones you want to install, then press the Plus button."
},
"top_info": "Select the files you want to install, then press the Plus button!",
"source_string": " from hard drive",
"delete_info": " installed\nDelete it from the hard drive?",
"delete_info_multi": " files installed successfully!\nDelete them from the hard drive?",
"delete_desc": "The original files aren't needed anymore after they've been installed",
"buttons": "\ue0e0 Select File \ue0e3 Select All \ue0ef Install File(s) \ue0e2 Help \ue0e1 Cancel"
},
"usb": {
"help": {
"title": "Помощь",
"desc": "Файлы могут быть установленны удалённо из другого вашего устройства используя такие утилиты как\nNS-USBloader в режиме Tinfoil. Чтобы передать файлы на Switch откройте одно из этих замечательных\nприложений на вашем ПК или мобильном устройстве, выберите файлы и затем загрузите их в вашу консоль!\n\nК сожалению, установка через USB требует специальных настроек на некоторых платформах и может\nпериодически глючить. Если вы ничего не поняли, попробуйте использовать установку по сети или же просто\nскопируйте файлы на SD-карту и выберите в главном меню опцию \"Установка из SD-карты\"!"
},
"top_info": "USB подключено! Ожидаем передачи списка файлов для установки...",
"top_info2": "Выберите какие файлы вы хотите установить через USB и нажмите \"+\"!",
"error": "Передача через USB провалилась из-за ошибки или превышения времини ожидания",
"source_string": " через USB",
"buttons": "\ue0e2 (Удерж.) Помощь \ue0e1 (Удерж.) Отмена",
"buttons2": "\ue0e0 Выбрать файл \ue0e3 Выбрать всё \ue0ef Установить файл(ы) \ue0e1 Отмена"
},
"target": {
"desc0": "Куда следует установить ",
"desc1": " ?",
"desc00": "Куда следует установить ",
"desc01": " эти файлы?",
"opt0": "SD-карта",
"opt1": "Внутренняя память"
},
"info_page": {
"top_info0": "Установка ",
"preparing": "Подготовка к установке...",
"failed": "Не удалось установить ",
"failed_desc": "Частично установленный контент может быть удалён через \"Настройки системы\".",
"complete": "Установка завершена",
"desc0": " файлы успешно установлены!",
"desc1": " установлен!",
"downloading": "Загружаем ",
"at": " в "
},
"nca_verify": {
"title": "Обнаружена неверная NCA подпись!",
"desc": "Неверно подписанное программное обеспечение должно устанавливаться исключительно из проверенных источников!\nФайлы содержащие перепакованные картриджи и разблокировщики DLC будут всегда приводить к показу этого\nпредупреждения. Вы можете отключить эту проверку в настройках TinWoo Installer\n Вы уверены что хотите продолжить установку?",
"opt1": "Да, я понимаю все риски",
"error": "Запрашиваемый NCA неверно подписан: "
},
"finished": [
"Наслаждайтесь вашими \"легальными копиями\"!",
"Уверен, оценив игру вы получите массу удовольствия когда действительно её купите!",
"Семпай ведь купил игру, правда? Nintendo-сан благодарит вас за покупку!",
"Обходить DRM это круто! Не так ли?",
"Возможно вы сохранили порядка шести деревьев просто не купив эту игру! И весь пластик куда-то делся!",
"Ниндзи из Nintendo успешно выяснили ваше текущее местоположение.",
"Чтобы сделать всё верно нам даже не потребовалось промывать вам мозги политическими заявлениями!"
]
},
"sig": {
"install": "Установить",
"uninstall": "Удалить",
"update": "Обновить",
"version_text": "У вас уже установлены signature patches соответствующие HOS версии ",
"title0": "Установить signature patches?",
"desc0": "Signature patches требуются для установки и запуска официальных приложений.",
"backup_failed": "Не удалось сделать копию Hekate patches.ini! Всё равно установить?",
"backup_failed_desc": "Игнорируйте это предупреждение если вы не исользуете Hekate.",
"download_failed": "Не удалось загрузить signature patches",
"download_failed_desc": "Возможно вы указали неправильный источник в настройках TinWoo Installer,\nили же сервер просто недоступен.",
"version_text2": "Ваши signature patches были обновлены до HOS версии ",
"install_complete": "Установка завершена!",
"complete_desc": "Презапустите вашу консоль чтобы изменения вступили в силу",
"restart": "Перезапустить",
"later": "Я сделаю это позже",
"extract_failed": "Невозможно извлечь файлы!",
"restore_failed": "Невозможно восстановить исходную версию Hekate patches.ini! Продолжить удаление?",
"uninstall_complete": "Удаление завершено",
"remove_failed": "Невозможно удалить signature patches",
"remove_failed_desc": "Вероятно файлы были перемещены или удалены",
"generic_error": "Не удалось установить signature patches!"
},
"options": {
"menu_items": {
"ignore_firm": "Игнорировать требования игр о минимальной версии прошивки",
"nca_verify": "Проверять подписи NCA перед установкой",
"boost_mode": "Включить \"boost-режим\" во время установки",
"ask_delete": "Спрашивать разрешения удалить исходные файлы после установки",
"auto_update": "Автоматически проверять наличие обновлений",
"gay_option": "Использовать тему",
"useSound": "Use sound notifications during installs",
"sig_url": "URL для скачивания Signature patches: ",
"language": "Язык: ",
"check_update": "Проверить наличие обновлений TinWoo Installer",
"credits": "Благодарности"
},
"nca_warn": {
"title": "Внимание!",
"desc": "Некоторые устанавливаемые приложения могут содержать вредоносный код!\nОтключайте эту опцию только если вы совершенно точно уверены в качестве\nустанавливаемых приложений и доверяете их источникам!\n\n\nВсё ещё хотите отключить проверку проверку NCA подписей?",
"opt1": "Да, я хочу получить кирпич"
},
"sig_hint": "Введите URL откуда следует брать Signature Patches",
"update": {
"title": "Доступно обновление",
"desc0": "TinWoo Installer ",
"desc1": " уже доступен! Готовы обновиться?",
"opt0": "Обновление",
"top_info": "Обновление TinWoo Installer ",
"bot_info": "Загрузка TinWoo Installer ",
"bot_info2": "Извлечение TinWoo Installer ",
"complete": "Обновление завершено!",
"failed": "Обновление провалилось!",
"end_desc": "Сейчас приложение будет закрыто.",
"title_check_fail": "Обновлений нет",
"desc_check_fail": "Вы уже используете последнюю версию TinWoo Installer!"
},
"credits": {
"title": "Выражаем благодарность следующим людям:",
"desc": "TinWoo - MrDude\nTinleaf - BlaWar\nAwoo Installer - Huntereb\nHard Drive Support - DarkMatterCore\n\n\nhttps://github.com/Huntereb/Awoo-Installer\nhttps://github.com/blawar/tinleaf\nhttps://github.com/DarkMatterCore/libusbhsfs\n\nThanks for testing - LyuboA"
},
"language": {
"title": "Выбор языка",
"desc": "После изменения языка приложение будет закрыто. Нажмите B для отмены.",
"system_language": "Системный"
},
"title": "Меняйте настройки TinWoo Installer!",
"buttons": "\ue0e0 Выбрать/Изменить \ue0e1 Отмена"
},
"common": {
"ok": "OK",
"cancel": "Отмена",
"close": "Закрыть",
"yes": "Да",
"no": "Нет",
"cancel_desc": "Нажмите B для отмены"
}
}

168
source/HDInstall.cpp Normal file
View File

@ -0,0 +1,168 @@
/*
Copyright (c) 2017-2018 Adubbz
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#include <cstring>
#include <string>
#include <sstream>
#include <filesystem>
#include <ctime>
#include <thread>
#include <memory>
#include "HDInstall.hpp"
#include "install/install_nsp.hpp"
#include "install/install_xci.hpp"
#include "install/sdmc_xci.hpp"
#include "install/sdmc_nsp.hpp"
#include "nx/fs.hpp"
#include "util/file_util.hpp"
#include "util/title_util.hpp"
#include "util/error.hpp"
#include "util/config.hpp"
#include "util/util.hpp"
#include "util/lang.hpp"
#include "ui/MainApplication.hpp"
#include "ui/instPage.hpp"
namespace inst::ui {
extern MainApplication *mainApp;
}
namespace nspInstStuff_B {
void installNspFromFile(std::vector<std::filesystem::path> ourTitleList, int whereToInstall)
{
inst::util::initInstallServices();
inst::ui::instPage::loadInstallScreen();
bool nspInstalled = true;
NcmStorageId m_destStorageId = NcmStorageId_SdCard;
if (whereToInstall) m_destStorageId = NcmStorageId_BuiltInUser;
unsigned int titleItr;
std::vector<int> previousClockValues;
if (inst::config::overClock) {
previousClockValues.push_back(inst::util::setClockSpeed(0, 1785000000)[0]);
previousClockValues.push_back(inst::util::setClockSpeed(1, 76800000)[0]);
previousClockValues.push_back(inst::util::setClockSpeed(2, 1600000000)[0]);
}
try
{
for (titleItr = 0; titleItr < ourTitleList.size(); titleItr++) {
inst::ui::instPage::setTopInstInfoText("inst.info_page.top_info0"_lang + inst::util::shortenString(ourTitleList[titleItr].filename().string(), 40, true) + "inst.hd.source_string"_lang);
std::unique_ptr<tin::install::Install> installTask;
if (ourTitleList[titleItr].extension() == ".xci" || ourTitleList[titleItr].extension() == ".xcz") {
auto sdmcXCI = std::make_shared<tin::install::xci::SDMCXCI>(ourTitleList[titleItr]);
installTask = std::make_unique<tin::install::xci::XCIInstallTask>(m_destStorageId, inst::config::ignoreReqVers, sdmcXCI);
} else {
auto sdmcNSP = std::make_shared<tin::install::nsp::SDMCNSP>(ourTitleList[titleItr]);
installTask = std::make_unique<tin::install::nsp::NSPInstall>(m_destStorageId, inst::config::ignoreReqVers, sdmcNSP);
}
LOG_DEBUG("%s\n", "Preparing installation");
inst::ui::instPage::setInstInfoText("inst.info_page.preparing"_lang);
inst::ui::instPage::setInstBarPerc(0);
installTask->Prepare();
installTask->Begin();
}
}
catch (std::exception& e)
{
LOG_DEBUG("Failed to install");
LOG_DEBUG("%s", e.what());
fprintf(stdout, "%s", e.what());
inst::ui::instPage::setInstInfoText("inst.info_page.failed"_lang + inst::util::shortenString(ourTitleList[titleItr].filename().string(), 42, true));
inst::ui::instPage::setInstBarPerc(0);
std::string audioPath = "";
if (std::filesystem::exists(inst::config::appDir + "/sounds/OHNO.WAV")) {
audioPath = (inst::config::appDir + "/sounds/OHNO.WAV");
}
else {
audioPath = "romfs:/audio/bark.wav";
}
std::thread audioThread(inst::util::playAudio,audioPath);
inst::ui::mainApp->CreateShowDialog("inst.info_page.failed"_lang + inst::util::shortenString(ourTitleList[titleItr].filename().string(), 42, true) + "!", "inst.info_page.failed_desc"_lang + "\n\n" + (std::string)e.what(), {"common.ok"_lang}, true);
audioThread.join();
nspInstalled = false;
}
if (previousClockValues.size() > 0) {
inst::util::setClockSpeed(0, previousClockValues[0]);
inst::util::setClockSpeed(1, previousClockValues[1]);
inst::util::setClockSpeed(2, previousClockValues[2]);
}
if(nspInstalled) {
inst::ui::instPage::setInstInfoText("inst.info_page.complete"_lang);
inst::ui::instPage::setInstBarPerc(100);
std::string audioPath = "";
if (inst::config::useSound) {
if (std::filesystem::exists(inst::config::appDir + "/sounds/YIPPEE.WAV")) {
audioPath = (inst::config::appDir + "/sounds/YIPPEE.WAV");
}
else {
audioPath = "romfs:/audio/ameizing.mp3";
}
std::thread audioThread(inst::util::playAudio,audioPath);
if (ourTitleList.size() > 1) {
if (inst::config::deletePrompt) {
if(inst::ui::mainApp->CreateShowDialog(std::to_string(ourTitleList.size()) + "inst.hd.delete_info_multi"_lang, "inst.hd.delete_desc"_lang, {"common.no"_lang,"common.yes"_lang}, false) == 1) {
for (long unsigned int i = 0; i < ourTitleList.size(); i++) {
if (std::filesystem::exists(ourTitleList[i])) std::filesystem::remove(ourTitleList[i]);
}
}
} else inst::ui::mainApp->CreateShowDialog(std::to_string(ourTitleList.size()) + "inst.info_page.desc0"_lang, Language::GetRandomMsg(), {"common.ok"_lang}, true);
} else {
if (inst::config::deletePrompt) {
if(inst::ui::mainApp->CreateShowDialog(inst::util::shortenString(ourTitleList[0].filename().string(), 32, true) + "inst.hd.delete_info"_lang, "inst.hd.delete_desc"_lang, {"common.no"_lang,"common.yes"_lang}, false) == 1) if (std::filesystem::exists(ourTitleList[0])) std::filesystem::remove(ourTitleList[0]);
} else inst::ui::mainApp->CreateShowDialog(inst::util::shortenString(ourTitleList[0].filename().string(), 42, true) + "inst.info_page.desc1"_lang, Language::GetRandomMsg(), {"common.ok"_lang}, true);
}
audioThread.join();
}
else{
if (ourTitleList.size() > 1) {
if (inst::config::deletePrompt) {
if(inst::ui::mainApp->CreateShowDialog(std::to_string(ourTitleList.size()) + "inst.hd.delete_info_multi"_lang, "inst.hd.delete_desc"_lang, {"common.no"_lang,"common.yes"_lang}, false) == 1) {
for (long unsigned int i = 0; i < ourTitleList.size(); i++) {
if (std::filesystem::exists(ourTitleList[i])) std::filesystem::remove(ourTitleList[i]);
}
}
} else inst::ui::mainApp->CreateShowDialog(std::to_string(ourTitleList.size()) + "inst.info_page.desc0"_lang, Language::GetRandomMsg(), {"common.ok"_lang}, true);
} else {
if (inst::config::deletePrompt) {
if(inst::ui::mainApp->CreateShowDialog(inst::util::shortenString(ourTitleList[0].filename().string(), 32, true) + "inst.hd.delete_info"_lang, "inst.hd.delete_desc"_lang, {"common.no"_lang,"common.yes"_lang}, false) == 1) if (std::filesystem::exists(ourTitleList[0])) std::filesystem::remove(ourTitleList[0]);
} else inst::ui::mainApp->CreateShowDialog(inst::util::shortenString(ourTitleList[0].filename().string(), 42, true) + "inst.info_page.desc1"_lang, Language::GetRandomMsg(), {"common.ok"_lang}, true);
}
}
}
LOG_DEBUG("Done");
inst::ui::instPage::loadMainMenu();
inst::util::deinitInstallServices();
return;
}
}

View File

@ -0,0 +1,212 @@
/*
Copyright (c) 2017-2018 Adubbz
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#include "data/buffered_placeholder_writer.hpp"
#include <climits>
#include <math.h>
#include <algorithm>
#include <exception>
#include "util/error.hpp"
#include "util/debug.h"
namespace tin::data
{
int NUM_BUFFER_SEGMENTS;
BufferedPlaceholderWriter::BufferedPlaceholderWriter(std::shared_ptr<nx::ncm::ContentStorage>& contentStorage, NcmContentId ncaId, size_t totalDataSize) :
m_totalDataSize(totalDataSize), m_contentStorage(contentStorage), m_ncaId(ncaId), m_writer(ncaId, contentStorage)
{
// Though currently the number of segments is fixed, we want them allocated on the heap, not the stack
m_bufferSegments = std::make_unique<BufferSegment[]>(NUM_BUFFER_SEGMENTS);
if (m_bufferSegments == nullptr)
THROW_FORMAT("Failed to allocated buffer segments!\n");
m_currentFreeSegmentPtr = &m_bufferSegments[m_currentFreeSegment];
m_currentSegmentToWritePtr = &m_bufferSegments[m_currentSegmentToWrite];
}
void BufferedPlaceholderWriter::AppendData(void* source, size_t length)
{
if (m_sizeBuffered + length > m_totalDataSize)
THROW_FORMAT("Cannot append data as it would exceed the expected total.\n");
size_t dataSizeRemaining = length;
u64 sourceOffset = 0;
while (dataSizeRemaining > 0)
{
size_t bufferSegmentSizeRemaining = BUFFER_SEGMENT_DATA_SIZE - m_currentFreeSegmentPtr->writeOffset;
if (m_currentFreeSegmentPtr->isFinalized)
THROW_FORMAT("Current buffer segment is already finalized!\n");
if (dataSizeRemaining < bufferSegmentSizeRemaining)
{
memcpy(m_currentFreeSegmentPtr->data + m_currentFreeSegmentPtr->writeOffset, (u8*)source + sourceOffset, dataSizeRemaining);
sourceOffset += dataSizeRemaining;
m_currentFreeSegmentPtr->writeOffset += dataSizeRemaining;
dataSizeRemaining = 0;
}
else
{
memcpy(m_currentFreeSegmentPtr->data + m_currentFreeSegmentPtr->writeOffset, (u8*)source + sourceOffset, bufferSegmentSizeRemaining);
dataSizeRemaining -= bufferSegmentSizeRemaining;
sourceOffset += bufferSegmentSizeRemaining;
m_currentFreeSegmentPtr->writeOffset += bufferSegmentSizeRemaining;
m_currentFreeSegmentPtr->isFinalized = true;
m_currentFreeSegment = (m_currentFreeSegment + 1) % NUM_BUFFER_SEGMENTS;
m_currentFreeSegmentPtr = &m_bufferSegments[m_currentFreeSegment];
}
}
m_sizeBuffered += length;
if (m_sizeBuffered == m_totalDataSize)
{
m_currentFreeSegmentPtr->isFinalized = true;
}
}
bool BufferedPlaceholderWriter::CanAppendData(size_t length)
{
if (m_sizeBuffered + length > m_totalDataSize)
return false;
if (!this->IsSizeAvailable(length))
return false;
return true;
}
void BufferedPlaceholderWriter::WriteSegmentToPlaceholder()
{
if (m_sizeWrittenToPlaceholder >= m_totalDataSize)
THROW_FORMAT("Cannot write segment as end of data has already been reached!\n");
if (!m_currentSegmentToWritePtr->isFinalized)
THROW_FORMAT("Cannot write segment as it hasn't been finalized!\n");
// NOTE: The final segment will have leftover data from previous writes, however
// this will be accounted for by this size
size_t sizeToWriteToPlaceholder = std::min(m_totalDataSize - m_sizeWrittenToPlaceholder, BUFFER_SEGMENT_DATA_SIZE);
m_writer.write(m_currentSegmentToWritePtr->data, sizeToWriteToPlaceholder);
m_currentSegmentToWritePtr->isFinalized = false;
m_currentSegmentToWritePtr->writeOffset = 0;
m_currentSegmentToWrite = (m_currentSegmentToWrite + 1) % NUM_BUFFER_SEGMENTS;
m_currentSegmentToWritePtr = &m_bufferSegments[m_currentSegmentToWrite];
m_sizeWrittenToPlaceholder += sizeToWriteToPlaceholder;
}
bool BufferedPlaceholderWriter::CanWriteSegmentToPlaceholder()
{
if (m_sizeWrittenToPlaceholder >= m_totalDataSize)
return false;
if (!m_currentSegmentToWritePtr->isFinalized)
return false;
return true;
}
u32 BufferedPlaceholderWriter::CalcNumSegmentsRequired(size_t size)
{
if (m_currentFreeSegmentPtr->isFinalized)
return INT_MAX;
size_t bufferSegmentSizeRemaining = BUFFER_SEGMENT_DATA_SIZE - m_currentFreeSegmentPtr->writeOffset;
if (size <= bufferSegmentSizeRemaining) return 1;
else
{
double numSegmentsReq = 1 + (double)(size - bufferSegmentSizeRemaining) / (double)BUFFER_SEGMENT_DATA_SIZE;
return ceil(numSegmentsReq);
}
}
bool BufferedPlaceholderWriter::IsSizeAvailable(size_t size)
{
u32 numSegmentsRequired = this->CalcNumSegmentsRequired(size);
if ((int)numSegmentsRequired > NUM_BUFFER_SEGMENTS)
return false;
for (unsigned int i = 0; i < numSegmentsRequired; i++)
{
unsigned int segmentIndex = m_currentFreeSegment + i;
BufferSegment* bufferSegment = &m_bufferSegments[segmentIndex % NUM_BUFFER_SEGMENTS];
if (bufferSegment->isFinalized)
return false;
if (i != 0 && bufferSegment->writeOffset != 0)
THROW_FORMAT("Unexpected non-zero write offset at segment %u (%lu)\n", segmentIndex, bufferSegment->writeOffset);
}
return true;
}
bool BufferedPlaceholderWriter::IsBufferDataComplete()
{
if (m_sizeBuffered > m_totalDataSize)
THROW_FORMAT("Size buffered cannot exceed total data size!\n");
return m_sizeBuffered == m_totalDataSize;
}
bool BufferedPlaceholderWriter::IsPlaceholderComplete()
{
if (m_sizeWrittenToPlaceholder > m_totalDataSize)
THROW_FORMAT("Size written to placeholder cannot exceed total data size!\n");
return m_sizeWrittenToPlaceholder == m_totalDataSize;
}
size_t BufferedPlaceholderWriter::GetTotalDataSize()
{
return m_totalDataSize;
}
size_t BufferedPlaceholderWriter::GetSizeBuffered()
{
return m_sizeBuffered;
}
size_t BufferedPlaceholderWriter::GetSizeWrittenToPlaceholder()
{
return m_sizeWrittenToPlaceholder;
}
void BufferedPlaceholderWriter::DebugPrintBuffers()
{
LOG_DEBUG("BufferedPlaceholderWriter Buffers: \n");
for (int i = 0; i < NUM_BUFFER_SEGMENTS; i++)
{
LOG_DEBUG("Buffer %u:\n", i);
printBytes(m_bufferSegments[i].data, BUFFER_SEGMENT_DATA_SIZE, true);
}
}
}

View File

@ -0,0 +1,55 @@
/*
Copyright (c) 2017-2018 Adubbz
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#include "data/byte_buffer.hpp"
#include "util/error.hpp"
#include "util/debug.h"
namespace tin::data
{
ByteBuffer::ByteBuffer(size_t reserveSize)
{
m_buffer.resize(reserveSize);
}
size_t ByteBuffer::GetSize()
{
return m_buffer.size();
}
u8* ByteBuffer::GetData()
{
return m_buffer.data();
}
void ByteBuffer::Resize(size_t size)
{
m_buffer.resize(size, 0);
}
void ByteBuffer::DebugPrintContents()
{
LOG_DEBUG("Buffer Size: 0x%lx\n", this->GetSize());
printBytes(this->GetData(), this->GetSize(), true);
}
}

View File

@ -0,0 +1,41 @@
/*
Copyright (c) 2017-2018 Adubbz
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#include "data/byte_stream.hpp"
namespace tin::data
{
BufferedByteStream::BufferedByteStream(ByteBuffer buffer) :
m_byteBuffer(buffer)
{
}
void BufferedByteStream::ReadBytes(void* dest, size_t length)
{
if (m_offset + length > m_byteBuffer.GetSize())
return;
memcpy(dest, m_byteBuffer.GetData() + m_offset, length);
m_offset += length;
}
}

154
source/install/http_nsp.cpp Normal file
View File

@ -0,0 +1,154 @@
/*
Copyright (c) 2017-2018 Adubbz
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#include "install/http_nsp.hpp"
#include <switch.h>
#include <threads.h>
#include "data/buffered_placeholder_writer.hpp"
#include "util/title_util.hpp"
#include "util/error.hpp"
#include "util/debug.h"
#include "util/util.hpp"
#include "util/lang.hpp"
#include "ui/instPage.hpp"
namespace tin::install::nsp
{
bool stopThreadsHttpNsp;
HTTPNSP::HTTPNSP(std::string url) :
m_download(url)
{
}
struct StreamFuncArgs
{
tin::network::HTTPDownload* download;
tin::data::BufferedPlaceholderWriter* bufferedPlaceholderWriter;
u64 pfs0Offset;
u64 ncaSize;
};
int CurlStreamFunc(void* in)
{
StreamFuncArgs* args = reinterpret_cast<StreamFuncArgs*>(in);
auto streamFunc = [&](u8* streamBuf, size_t streamBufSize) -> size_t
{
while (true)
{
if (args->bufferedPlaceholderWriter->CanAppendData(streamBufSize))
break;
}
args->bufferedPlaceholderWriter->AppendData(streamBuf, streamBufSize);
return streamBufSize;
};
if (args->download->StreamDataRange(args->pfs0Offset, args->ncaSize, streamFunc) == 1) stopThreadsHttpNsp = true;
return 0;
}
int PlaceholderWriteFunc(void* in)
{
StreamFuncArgs* args = reinterpret_cast<StreamFuncArgs*>(in);
while (!args->bufferedPlaceholderWriter->IsPlaceholderComplete() && !stopThreadsHttpNsp)
{
if (args->bufferedPlaceholderWriter->CanWriteSegmentToPlaceholder())
args->bufferedPlaceholderWriter->WriteSegmentToPlaceholder();
}
return 0;
}
void HTTPNSP::StreamToPlaceholder(std::shared_ptr<nx::ncm::ContentStorage>& contentStorage, NcmContentId placeholderId)
{
const PFS0FileEntry* fileEntry = this->GetFileEntryByNcaId(placeholderId);
std::string ncaFileName = this->GetFileEntryName(fileEntry);
LOG_DEBUG("Retrieving %s\n", ncaFileName.c_str());
size_t ncaSize = fileEntry->fileSize;
tin::data::BufferedPlaceholderWriter bufferedPlaceholderWriter(contentStorage, placeholderId, ncaSize);
StreamFuncArgs args;
args.download = &m_download;
args.bufferedPlaceholderWriter = &bufferedPlaceholderWriter;
args.pfs0Offset = this->GetDataOffset() + fileEntry->dataOffset;
args.ncaSize = ncaSize;
thrd_t curlThread;
thrd_t writeThread;
stopThreadsHttpNsp = false;
thrd_create(&curlThread, CurlStreamFunc, &args);
thrd_create(&writeThread, PlaceholderWriteFunc, &args);
u64 freq = armGetSystemTickFreq();
u64 startTime = armGetSystemTick();
size_t startSizeBuffered = 0;
double speed = 0.0;
inst::ui::instPage::setInstBarPerc(0);
while (!bufferedPlaceholderWriter.IsBufferDataComplete() && !stopThreadsHttpNsp)
{
u64 newTime = armGetSystemTick();
if (newTime - startTime >= freq * 0.5)
{
size_t newSizeBuffered = bufferedPlaceholderWriter.GetSizeBuffered();
double mbBuffered = (newSizeBuffered / 1000000.0) - (startSizeBuffered / 1000000.0);
double duration = ((double)(newTime - startTime) / (double)freq);
speed = mbBuffered / duration;
startTime = newTime;
startSizeBuffered = newSizeBuffered;
int downloadProgress = (int)(((double)bufferedPlaceholderWriter.GetSizeBuffered() / (double)bufferedPlaceholderWriter.GetTotalDataSize()) * 100.0);
inst::ui::instPage::setInstInfoText("inst.info_page.downloading"_lang + inst::util::formatUrlString(ncaFileName) + "inst.info_page.at"_lang + std::to_string(speed).substr(0, std::to_string(speed).size()-4) + "MB/s");
inst::ui::instPage::setInstBarPerc((double)downloadProgress);
}
}
inst::ui::instPage::setInstBarPerc(100);
inst::ui::instPage::setInstInfoText("inst.info_page.top_info0"_lang + ncaFileName + "...");
inst::ui::instPage::setInstBarPerc(0);
while (!bufferedPlaceholderWriter.IsPlaceholderComplete() && !stopThreadsHttpNsp)
{
int installProgress = (int)(((double)bufferedPlaceholderWriter.GetSizeWrittenToPlaceholder() / (double)bufferedPlaceholderWriter.GetTotalDataSize()) * 100.0);
inst::ui::instPage::setInstBarPerc((double)installProgress);
}
inst::ui::instPage::setInstBarPerc(100);
thrd_join(curlThread, NULL);
thrd_join(writeThread, NULL);
if (stopThreadsHttpNsp) THROW_FORMAT(("inst.net.transfer_interput"_lang).c_str());
}
void HTTPNSP::BufferData(void* buf, off_t offset, size_t size)
{
m_download.BufferDataRange(buf, offset, size, nullptr);
}
}

162
source/install/http_xci.cpp Normal file
View File

@ -0,0 +1,162 @@
/*
Copyright (c) 2017-2018 Adubbz
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#include "install/http_xci.hpp"
#include <threads.h>
#include "data/buffered_placeholder_writer.hpp"
#include "util/error.hpp"
#include "util/util.hpp"
#include "util/lang.hpp"
#include "ui/instPage.hpp"
namespace tin::install::xci
{
bool stopThreadsHttpXci;
HTTPXCI::HTTPXCI(std::string url) :
m_download(url)
{
}
struct StreamFuncArgs
{
tin::network::HTTPDownload* download;
tin::data::BufferedPlaceholderWriter* bufferedPlaceholderWriter;
u64 pfs0Offset;
u64 ncaSize;
};
int CurlStreamFunc(void* in)
{
StreamFuncArgs* args = reinterpret_cast<StreamFuncArgs*>(in);
auto streamFunc = [&](u8* streamBuf, size_t streamBufSize) -> size_t
{
while (true)
{
if (args->bufferedPlaceholderWriter->CanAppendData(streamBufSize))
break;
}
args->bufferedPlaceholderWriter->AppendData(streamBuf, streamBufSize);
return streamBufSize;
};
if (args->download->StreamDataRange(args->pfs0Offset, args->ncaSize, streamFunc) == 1) stopThreadsHttpXci = true;
return 0;
}
int PlaceholderWriteFunc(void* in)
{
StreamFuncArgs* args = reinterpret_cast<StreamFuncArgs*>(in);
while (!args->bufferedPlaceholderWriter->IsPlaceholderComplete() && !stopThreadsHttpXci)
{
if (args->bufferedPlaceholderWriter->CanWriteSegmentToPlaceholder())
args->bufferedPlaceholderWriter->WriteSegmentToPlaceholder();
}
return 0;
}
void HTTPXCI::StreamToPlaceholder(std::shared_ptr<nx::ncm::ContentStorage>& contentStorage, NcmContentId ncaId)
{
const HFS0FileEntry* fileEntry = this->GetFileEntryByNcaId(ncaId);
std::string ncaFileName = this->GetFileEntryName(fileEntry);
LOG_DEBUG("Retrieving %s\n", ncaFileName.c_str());
size_t ncaSize = fileEntry->fileSize;
tin::data::BufferedPlaceholderWriter bufferedPlaceholderWriter(contentStorage, ncaId, ncaSize);
StreamFuncArgs args;
args.download = &m_download;
args.bufferedPlaceholderWriter = &bufferedPlaceholderWriter;
args.pfs0Offset = this->GetDataOffset() + fileEntry->dataOffset;
args.ncaSize = ncaSize;
thrd_t curlThread;
thrd_t writeThread;
stopThreadsHttpXci = false;
thrd_create(&curlThread, CurlStreamFunc, &args);
thrd_create(&writeThread, PlaceholderWriteFunc, &args);
u64 freq = armGetSystemTickFreq();
u64 startTime = armGetSystemTick();
size_t startSizeBuffered = 0;
double speed = 0.0;
inst::ui::instPage::setInstBarPerc(0);
while (!bufferedPlaceholderWriter.IsBufferDataComplete() && !stopThreadsHttpXci)
{
u64 newTime = armGetSystemTick();
if (newTime - startTime >= freq * 0.5)
{
size_t newSizeBuffered = bufferedPlaceholderWriter.GetSizeBuffered();
double mbBuffered = (newSizeBuffered / 1000000.0) - (startSizeBuffered / 1000000.0);
double duration = ((double)(newTime - startTime) / (double)freq);
speed = mbBuffered / duration;
startTime = newTime;
startSizeBuffered = newSizeBuffered;
int downloadProgress = (int)(((double)bufferedPlaceholderWriter.GetSizeBuffered() / (double)bufferedPlaceholderWriter.GetTotalDataSize()) * 100.0);
#ifdef NXLINK_DEBUG
u64 totalSizeMB = bufferedPlaceholderWriter.GetTotalDataSize() / 1000000;
u64 downloadSizeMB = bufferedPlaceholderWriter.GetSizeBuffered() / 1000000;
LOG_DEBUG("> Download Progress: %lu/%lu MB (%i%s) (%.2f MB/s)\r", downloadSizeMB, totalSizeMB, downloadProgress, "%", speed);
#endif
inst::ui::instPage::setInstInfoText("inst.info_page.downloading"_lang + inst::util::formatUrlString(ncaFileName) + "inst.info_page.at"_lang + std::to_string(speed).substr(0, std::to_string(speed).size()-4) + "MB/s");
inst::ui::instPage::setInstBarPerc((double)downloadProgress);
}
}
inst::ui::instPage::setInstBarPerc(100);
#ifdef NXLINK_DEBUG
u64 totalSizeMB = bufferedPlaceholderWriter.GetTotalDataSize() / 1000000;
#endif
inst::ui::instPage::setInstInfoText("inst.info_page.top_info0"_lang + ncaFileName + "...");
inst::ui::instPage::setInstBarPerc(0);
while (!bufferedPlaceholderWriter.IsPlaceholderComplete() && !stopThreadsHttpXci)
{
int installProgress = (int)(((double)bufferedPlaceholderWriter.GetSizeWrittenToPlaceholder() / (double)bufferedPlaceholderWriter.GetTotalDataSize()) * 100.0);
#ifdef NXLINK_DEBUG
u64 installSizeMB = bufferedPlaceholderWriter.GetSizeWrittenToPlaceholder() / 1000000;
LOG_DEBUG("> Install Progress: %lu/%lu MB (%i%s)\r", installSizeMB, totalSizeMB, installProgress, "%");
#endif
inst::ui::instPage::setInstBarPerc((double)installProgress);
}
inst::ui::instPage::setInstBarPerc(100);
thrd_join(curlThread, NULL);
thrd_join(writeThread, NULL);
if (stopThreadsHttpXci) THROW_FORMAT(("inst.net.transfer_interput"_lang).c_str());
}
void HTTPXCI::BufferData(void* buf, off_t offset, size_t size)
{
m_download.BufferDataRange(buf, offset, size, nullptr);
}
}

192
source/install/install.cpp Normal file
View File

@ -0,0 +1,192 @@
/*
Copyright (c) 2017-2018 Adubbz
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#include "install/install.hpp"
#include <switch.h>
#include <cstring>
#include <memory>
#include "util/error.hpp"
#include "nx/ncm.hpp"
#include "util/title_util.hpp"
// TODO: Check NCA files are present
// TODO: Check tik/cert is present
namespace tin::install
{
Install::Install(NcmStorageId destStorageId, bool ignoreReqFirmVersion) :
m_destStorageId(destStorageId), m_ignoreReqFirmVersion(ignoreReqFirmVersion), m_contentMeta()
{
appletSetMediaPlaybackState(true);
}
Install::~Install()
{
appletSetMediaPlaybackState(false);
}
// TODO: Implement RAII on NcmContentMetaDatabase
void Install::InstallContentMetaRecords(tin::data::ByteBuffer& installContentMetaBuf, int i)
{
NcmContentMetaDatabase contentMetaDatabase;
NcmContentMetaKey contentMetaKey = m_contentMeta[i].GetContentMetaKey();
try
{
ASSERT_OK(ncmOpenContentMetaDatabase(&contentMetaDatabase, m_destStorageId), "Failed to open content meta database");
ASSERT_OK(ncmContentMetaDatabaseSet(&contentMetaDatabase, &contentMetaKey, (NcmContentMetaHeader*)installContentMetaBuf.GetData(), installContentMetaBuf.GetSize()), "Failed to set content records");
ASSERT_OK(ncmContentMetaDatabaseCommit(&contentMetaDatabase), "Failed to commit content records");
}
catch (std::runtime_error& e)
{
serviceClose(&contentMetaDatabase.s);
THROW_FORMAT(e.what());
}
serviceClose(&contentMetaDatabase.s);
}
void Install::InstallApplicationRecord(int i)
{
Result rc = 0;
std::vector<ContentStorageRecord> storageRecords;
u64 baseTitleId = tin::util::GetBaseTitleId(this->GetTitleId(i), this->GetContentMetaType(i));
s32 contentMetaCount = 0;
LOG_DEBUG("Base title Id: 0x%lx", baseTitleId);
// TODO: Make custom error with result code field
// 0x410: The record doesn't already exist
if (R_FAILED(rc = nsCountApplicationContentMeta(baseTitleId, &contentMetaCount)) && rc != 0x410)
{
THROW_FORMAT("Failed to count application content meta");
}
rc = 0;
LOG_DEBUG("Content meta count: %u\n", contentMetaCount);
// Obtain any existing app record content meta and append it to our vector
if (contentMetaCount > 0)
{
storageRecords.resize(contentMetaCount);
size_t contentStorageBufSize = contentMetaCount * sizeof(ContentStorageRecord);
auto contentStorageBuf = std::make_unique<ContentStorageRecord[]>(contentMetaCount);
u32 entriesRead;
ASSERT_OK(nsListApplicationRecordContentMeta(0, baseTitleId, contentStorageBuf.get(), contentStorageBufSize, &entriesRead), "Failed to list application record content meta");
if ((s32)entriesRead != contentMetaCount)
{
THROW_FORMAT("Mismatch between entries read and content meta count");
}
memcpy(storageRecords.data(), contentStorageBuf.get(), contentStorageBufSize);
}
// Add our new content meta
ContentStorageRecord storageRecord;
storageRecord.metaRecord = m_contentMeta[i].GetContentMetaKey();
storageRecord.storageId = m_destStorageId;
storageRecords.push_back(storageRecord);
// Replace the existing application records with our own
try
{
nsDeleteApplicationRecord(baseTitleId);
}
catch (...) {}
LOG_DEBUG("Pushing application record...\n");
ASSERT_OK(nsPushApplicationRecord(baseTitleId, 0x3, storageRecords.data(), storageRecords.size() * sizeof(ContentStorageRecord)), "Failed to push application record");
}
// Validate and obtain all data needed for install
void Install::Prepare()
{
tin::data::ByteBuffer cnmtBuf;
std::vector<std::tuple<nx::ncm::ContentMeta, NcmContentInfo>> tupelList = this->ReadCNMT();
for (size_t i = 0; i < tupelList.size(); i++) {
std::tuple<nx::ncm::ContentMeta, NcmContentInfo> cnmtTuple = tupelList[i];
m_contentMeta.push_back(std::get<0>(cnmtTuple));
NcmContentInfo cnmtContentRecord = std::get<1>(cnmtTuple);
nx::ncm::ContentStorage contentStorage(m_destStorageId);
if (!contentStorage.Has(cnmtContentRecord.content_id))
{
LOG_DEBUG("Installing CNMT NCA...\n");
this->InstallNCA(cnmtContentRecord.content_id);
}
else
{
LOG_DEBUG("CNMT NCA already installed. Proceeding...\n");
}
// Parse data and create install content meta
if (m_ignoreReqFirmVersion)
LOG_DEBUG("WARNING: Required system firmware version is being IGNORED!\n");
tin::data::ByteBuffer installContentMetaBuf;
m_contentMeta[i].GetInstallContentMeta(installContentMetaBuf, cnmtContentRecord, m_ignoreReqFirmVersion);
this->InstallContentMetaRecords(installContentMetaBuf, i);
this->InstallApplicationRecord(i);
}
}
void Install::Begin()
{
LOG_DEBUG("Installing ticket and cert...\n");
try
{
this->InstallTicketCert();
}
catch (std::runtime_error& e)
{
LOG_DEBUG("WARNING: Ticket installation failed! This may not be an issue, depending on your use case.\nProceed with caution!\n");
}
for (nx::ncm::ContentMeta contentMeta: m_contentMeta) {
LOG_DEBUG("Installing NCAs...\n");
for (auto& record : contentMeta.GetContentInfos())
{
LOG_DEBUG("Installing from %s\n", tin::util::GetNcaIdString(record.content_id).c_str());
this->InstallNCA(record.content_id);
}
}
}
u64 Install::GetTitleId(int i)
{
return m_contentMeta[i].GetContentMetaKey().id;
}
NcmContentMetaType Install::GetContentMetaType(int i)
{
return static_cast<NcmContentMetaType>(m_contentMeta[i].GetContentMetaKey().type);
}
}

View File

@ -0,0 +1,182 @@
/*
Copyright (c) 2017-2018 Adubbz
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#include "install/install_nsp.hpp"
#include <machine/endian.h>
#include <thread>
#include "install/nca.hpp"
#include "nx/fs.hpp"
#include "nx/ncm.hpp"
#include "util/config.hpp"
#include "util/crypto.hpp"
#include "util/file_util.hpp"
#include "util/title_util.hpp"
#include "util/debug.h"
#include "util/error.hpp"
#include "util/util.hpp"
#include "util/lang.hpp"
#include "ui/MainApplication.hpp"
namespace inst::ui {
extern MainApplication *mainApp;
}
namespace tin::install::nsp
{
NSPInstall::NSPInstall(NcmStorageId destStorageId, bool ignoreReqFirmVersion, const std::shared_ptr<NSP>& remoteNSP) :
Install(destStorageId, ignoreReqFirmVersion), m_NSP(remoteNSP)
{
m_NSP->RetrieveHeader();
}
std::vector<std::tuple<nx::ncm::ContentMeta, NcmContentInfo>> NSPInstall::ReadCNMT()
{
std::vector<std::tuple<nx::ncm::ContentMeta, NcmContentInfo>> CNMTList;
for (const PFS0FileEntry* fileEntry : m_NSP->GetFileEntriesByExtension("cnmt.nca")) {
std::string cnmtNcaName(m_NSP->GetFileEntryName(fileEntry));
NcmContentId cnmtContentId = tin::util::GetNcaIdFromString(cnmtNcaName);
size_t cnmtNcaSize = fileEntry->fileSize;
nx::ncm::ContentStorage contentStorage(m_destStorageId);
LOG_DEBUG("CNMT Name: %s\n", cnmtNcaName.c_str());
// We install the cnmt nca early to read from it later
this->InstallNCA(cnmtContentId);
std::string cnmtNCAFullPath = contentStorage.GetPath(cnmtContentId);
NcmContentInfo cnmtContentInfo;
cnmtContentInfo.content_id = cnmtContentId;
*(u64*)&cnmtContentInfo.size = cnmtNcaSize & 0xFFFFFFFFFFFF;
cnmtContentInfo.content_type = NcmContentType_Meta;
CNMTList.push_back( { tin::util::GetContentMetaFromNCA(cnmtNCAFullPath), cnmtContentInfo } );
}
return CNMTList;
}
void NSPInstall::InstallNCA(const NcmContentId& ncaId)
{
const PFS0FileEntry* fileEntry = m_NSP->GetFileEntryByNcaId(ncaId);
std::string ncaFileName = m_NSP->GetFileEntryName(fileEntry);
#ifdef NXLINK_DEBUG
size_t ncaSize = fileEntry->fileSize;
LOG_DEBUG("Installing %s to storage Id %u\n", ncaFileName.c_str(), m_destStorageId);
#endif
std::shared_ptr<nx::ncm::ContentStorage> contentStorage(new nx::ncm::ContentStorage(m_destStorageId));
// Attempt to delete any leftover placeholders
try {
contentStorage->DeletePlaceholder(*(NcmPlaceHolderId*)&ncaId);
}
catch (...) {}
// Attempt to delete leftover ncas
try {
contentStorage->Delete(ncaId);
}
catch (...) {}
LOG_DEBUG("Size: 0x%lx\n", ncaSize);
if (inst::config::validateNCAs && !m_declinedValidation)
{
tin::install::NcaHeader* header = new NcaHeader;
m_NSP->BufferData(header, m_NSP->GetDataOffset() + fileEntry->dataOffset, sizeof(tin::install::NcaHeader));
Crypto::AesXtr crypto(Crypto::Keys().headerKey, false);
crypto.decrypt(header, header, sizeof(tin::install::NcaHeader), 0, 0x200);
if (header->magic != MAGIC_NCA3)
THROW_FORMAT("Invalid NCA magic");
if (!Crypto::rsa2048PssVerify(&header->magic, 0x200, header->fixed_key_sig, Crypto::NCAHeaderSignature))
{
std::thread audioThread(inst::util::playAudio,"romfs:/audio/bark.wav");
int rc = inst::ui::mainApp->CreateShowDialog("inst.nca_verify.title"_lang, "inst.nca_verify.desc"_lang, {"common.cancel"_lang, "inst.nca_verify.opt1"_lang}, false);
audioThread.join();
if (rc != 1)
THROW_FORMAT(("inst.nca_verify.error"_lang + tin::util::GetNcaIdString(ncaId)).c_str());
m_declinedValidation = true;
}
delete header;
}
m_NSP->StreamToPlaceholder(contentStorage, ncaId);
LOG_DEBUG("Registering placeholder...\n");
try
{
contentStorage->Register(*(NcmPlaceHolderId*)&ncaId, ncaId);
}
catch (...)
{
LOG_DEBUG(("Failed to register " + ncaFileName + ". It may already exist.\n").c_str());
}
try
{
contentStorage->DeletePlaceholder(*(NcmPlaceHolderId*)&ncaId);
}
catch (...) {}
}
void NSPInstall::InstallTicketCert()
{
// Read the tik files and put it into a buffer
std::vector<const PFS0FileEntry*> tikFileEntries = m_NSP->GetFileEntriesByExtension("tik");
std::vector<const PFS0FileEntry*> certFileEntries = m_NSP->GetFileEntriesByExtension("cert");
for (size_t i = 0; i < tikFileEntries.size(); i++)
{
if (tikFileEntries[i] == nullptr) {
LOG_DEBUG("Remote tik file is missing.\n");
THROW_FORMAT("Remote tik file is not present!");
}
u64 tikSize = tikFileEntries[i]->fileSize;
auto tikBuf = std::make_unique<u8[]>(tikSize);
LOG_DEBUG("> Reading tik\n");
m_NSP->BufferData(tikBuf.get(), m_NSP->GetDataOffset() + tikFileEntries[i]->dataOffset, tikSize);
if (certFileEntries[i] == nullptr)
{
LOG_DEBUG("Remote cert file is missing.\n");
THROW_FORMAT("Remote cert file is not present!");
}
u64 certSize = certFileEntries[i]->fileSize;
auto certBuf = std::make_unique<u8[]>(certSize);
LOG_DEBUG("> Reading cert\n");
m_NSP->BufferData(certBuf.get(), m_NSP->GetDataOffset() + certFileEntries[i]->dataOffset, certSize);
// Finally, let's actually import the ticket
ASSERT_OK(esImportTicket(tikBuf.get(), tikSize, certBuf.get(), certSize), "Failed to import ticket");
}
}
}

View File

@ -0,0 +1,181 @@
/*
Copyright (c) 2017-2018 Adubbz
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#include <thread>
#include "install/install_xci.hpp"
#include "util/file_util.hpp"
#include "util/title_util.hpp"
#include "util/debug.h"
#include "util/error.hpp"
#include "util/config.hpp"
#include "util/crypto.hpp"
#include "util/util.hpp"
#include "util/lang.hpp"
#include "install/nca.hpp"
#include "ui/MainApplication.hpp"
namespace inst::ui {
extern MainApplication *mainApp;
}
namespace tin::install::xci
{
XCIInstallTask::XCIInstallTask(NcmStorageId destStorageId, bool ignoreReqFirmVersion, const std::shared_ptr<XCI>& xci) :
Install(destStorageId, ignoreReqFirmVersion), m_xci(xci)
{
m_xci->RetrieveHeader();
}
std::vector<std::tuple<nx::ncm::ContentMeta, NcmContentInfo>> XCIInstallTask::ReadCNMT()
{
std::vector<std::tuple<nx::ncm::ContentMeta, NcmContentInfo>> CNMTList;
for (const HFS0FileEntry* fileEntry : m_xci->GetFileEntriesByExtension("cnmt.nca")) {
std::string cnmtNcaName(m_xci->GetFileEntryName(fileEntry));
NcmContentId cnmtContentId = tin::util::GetNcaIdFromString(cnmtNcaName);
size_t cnmtNcaSize = fileEntry->fileSize;
nx::ncm::ContentStorage contentStorage(m_destStorageId);
LOG_DEBUG("CNMT Name: %s\n", cnmtNcaName.c_str());
// We install the cnmt nca early to read from it later
this->InstallNCA(cnmtContentId);
std::string cnmtNCAFullPath = contentStorage.GetPath(cnmtContentId);
NcmContentInfo cnmtContentInfo;
cnmtContentInfo.content_id = cnmtContentId;
*(u64*)&cnmtContentInfo.size = cnmtNcaSize & 0xFFFFFFFFFFFF;
cnmtContentInfo.content_type = NcmContentType_Meta;
CNMTList.push_back( { tin::util::GetContentMetaFromNCA(cnmtNCAFullPath), cnmtContentInfo } );
}
return CNMTList;
}
void XCIInstallTask::InstallNCA(const NcmContentId& ncaId)
{
const HFS0FileEntry* fileEntry = m_xci->GetFileEntryByNcaId(ncaId);
std::string ncaFileName = m_xci->GetFileEntryName(fileEntry);
#ifdef NXLINK_DEBUG
size_t ncaSize = fileEntry->fileSize;
LOG_DEBUG("Installing %s to storage Id %u\n", ncaFileName.c_str(), m_destStorageId);
#endif
std::shared_ptr<nx::ncm::ContentStorage> contentStorage(new nx::ncm::ContentStorage(m_destStorageId));
// Attempt to delete any leftover placeholders
try {
contentStorage->DeletePlaceholder(*(NcmPlaceHolderId*)&ncaId);
}
catch (...) {}
// Attempt to delete leftover ncas
try {
contentStorage->Delete(ncaId);
}
catch (...) {}
LOG_DEBUG("Size: 0x%lx\n", ncaSize);
if (inst::config::validateNCAs && !m_declinedValidation)
{
tin::install::NcaHeader* header = new NcaHeader;
m_xci->BufferData(header, m_xci->GetDataOffset() + fileEntry->dataOffset, sizeof(tin::install::NcaHeader));
Crypto::AesXtr crypto(Crypto::Keys().headerKey, false);
crypto.decrypt(header, header, sizeof(tin::install::NcaHeader), 0, 0x200);
if (header->magic != MAGIC_NCA3)
THROW_FORMAT("Invalid NCA magic");
if (!Crypto::rsa2048PssVerify(&header->magic, 0x200, header->fixed_key_sig, Crypto::NCAHeaderSignature))
{
std::thread audioThread(inst::util::playAudio,"romfs:/audio/bark.wav");
int rc = inst::ui::mainApp->CreateShowDialog("inst.nca_verify.title"_lang, "inst.nca_verify.desc"_lang, {"common.cancel"_lang, "inst.nca_verify.opt1"_lang}, false);
audioThread.join();
if (rc != 1)
THROW_FORMAT(("inst.nca_verify.error"_lang + tin::util::GetNcaIdString(ncaId)).c_str());
m_declinedValidation = true;
}
delete header;
}
m_xci->StreamToPlaceholder(contentStorage, ncaId);
// Clean up the line for whatever comes next
LOG_DEBUG(" \r");
LOG_DEBUG("Registering placeholder...\n");
try
{
contentStorage->Register(*(NcmPlaceHolderId*)&ncaId, ncaId);
}
catch (...)
{
LOG_DEBUG(("Failed to register " + ncaFileName + ". It may already exist.\n").c_str());
}
try
{
contentStorage->DeletePlaceholder(*(NcmPlaceHolderId*)&ncaId);
}
catch (...) {}
}
void XCIInstallTask::InstallTicketCert()
{
// Read the tik files and put it into a buffer
std::vector<const HFS0FileEntry*> tikFileEntries = m_xci->GetFileEntriesByExtension("tik");
std::vector<const HFS0FileEntry*> certFileEntries = m_xci->GetFileEntriesByExtension("cert");
for (size_t i = 0; i < tikFileEntries.size(); i++)
{
if (tikFileEntries[i] == nullptr)
{
LOG_DEBUG("Remote tik file is missing.\n");
THROW_FORMAT("Remote tik file is not present!");
}
u64 tikSize = tikFileEntries[i]->fileSize;
auto tikBuf = std::make_unique<u8[]>(tikSize);
LOG_DEBUG("> Reading tik\n");
m_xci->BufferData(tikBuf.get(), m_xci->GetDataOffset() + tikFileEntries[i]->dataOffset, tikSize);
if (certFileEntries[i] == nullptr)
{
LOG_DEBUG("Remote cert file is missing.\n");
THROW_FORMAT("Remote cert file is not present!");
}
u64 certSize = certFileEntries[i]->fileSize;
auto certBuf = std::make_unique<u8[]>(certSize);
LOG_DEBUG("> Reading cert\n");
m_xci->BufferData(certBuf.get(), m_xci->GetDataOffset() + certFileEntries[i]->dataOffset, certSize);
// Finally, let's actually import the ticket
ASSERT_OK(esImportTicket(tikBuf.get(), tikSize, certBuf.get(), certSize), "Failed to import ticket");
}
}
}

143
source/install/nsp.cpp Normal file
View File

@ -0,0 +1,143 @@
/*
Copyright (c) 2017-2018 Adubbz
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#include "install/nsp.hpp"
#include <threads.h>
#include "data/buffered_placeholder_writer.hpp"
#include "util/title_util.hpp"
#include "util/error.hpp"
#include "util/debug.h"
namespace tin::install::nsp
{
NSP::NSP() {}
// TODO: Do verification: PFS0 magic, sizes not zero
void NSP::RetrieveHeader()
{
LOG_DEBUG("Retrieving remote NSP header...\n");
// Retrieve the base header
m_headerBytes.resize(sizeof(PFS0BaseHeader), 0);
this->BufferData(m_headerBytes.data(), 0x0, sizeof(PFS0BaseHeader));
LOG_DEBUG("Base header: \n");
printBytes(m_headerBytes.data(), sizeof(PFS0BaseHeader), true);
// Retrieve the full header
size_t remainingHeaderSize = this->GetBaseHeader()->numFiles * sizeof(PFS0FileEntry) + this->GetBaseHeader()->stringTableSize;
m_headerBytes.resize(sizeof(PFS0BaseHeader) + remainingHeaderSize, 0);
this->BufferData(m_headerBytes.data() + sizeof(PFS0BaseHeader), sizeof(PFS0BaseHeader), remainingHeaderSize);
LOG_DEBUG("Full header: \n");
printBytes(m_headerBytes.data(), m_headerBytes.size(), true);
}
const PFS0FileEntry* NSP::GetFileEntry(unsigned int index)
{
if (index >= this->GetBaseHeader()->numFiles)
THROW_FORMAT("File entry index is out of bounds\n")
size_t fileEntryOffset = sizeof(PFS0BaseHeader) + index * sizeof(PFS0FileEntry);
if (m_headerBytes.size() < fileEntryOffset + sizeof(PFS0FileEntry))
THROW_FORMAT("Header bytes is too small to get file entry!");
return reinterpret_cast<PFS0FileEntry*>(m_headerBytes.data() + fileEntryOffset);
}
std::vector<const PFS0FileEntry*> NSP::GetFileEntriesByExtension(std::string extension)
{
std::vector<const PFS0FileEntry*> entryList;
for (unsigned int i = 0; i < this->GetBaseHeader()->numFiles; i++)
{
const PFS0FileEntry* fileEntry = this->GetFileEntry(i);
std::string name(this->GetFileEntryName(fileEntry));
auto foundExtension = name.substr(name.find(".") + 1);
if (foundExtension == extension)
entryList.push_back(fileEntry);
}
return entryList;
}
const PFS0FileEntry* NSP::GetFileEntryByName(std::string name)
{
for (unsigned int i = 0; i < this->GetBaseHeader()->numFiles; i++)
{
const PFS0FileEntry* fileEntry = this->GetFileEntry(i);
std::string foundName(this->GetFileEntryName(fileEntry));
if (foundName == name)
return fileEntry;
}
return nullptr;
}
const PFS0FileEntry* NSP::GetFileEntryByNcaId(const NcmContentId& ncaId)
{
const PFS0FileEntry* fileEntry = nullptr;
std::string ncaIdStr = tin::util::GetNcaIdString(ncaId);
if ((fileEntry = this->GetFileEntryByName(ncaIdStr + ".nca")) == nullptr)
{
if ((fileEntry = this->GetFileEntryByName(ncaIdStr + ".cnmt.nca")) == nullptr)
{
if ((fileEntry = this->GetFileEntryByName(ncaIdStr + ".ncz")) == nullptr)
{
if ((fileEntry = this->GetFileEntryByName(ncaIdStr + ".cnmt.ncz")) == nullptr)
{
return nullptr;
}
}
}
}
return fileEntry;
}
const char* NSP::GetFileEntryName(const PFS0FileEntry* fileEntry)
{
u64 stringTableStart = sizeof(PFS0BaseHeader) + this->GetBaseHeader()->numFiles * sizeof(PFS0FileEntry);
return reinterpret_cast<const char*>(m_headerBytes.data() + stringTableStart + fileEntry->stringTableOffset);
}
const PFS0BaseHeader* NSP::GetBaseHeader()
{
if (m_headerBytes.empty())
THROW_FORMAT("Cannot retrieve header as header bytes are empty. Have you retrieved it yet?\n");
return reinterpret_cast<PFS0BaseHeader*>(m_headerBytes.data());
}
u64 NSP::GetDataOffset()
{
if (m_headerBytes.empty())
THROW_FORMAT("Cannot get data offset as header is empty. Have you retrieved it yet?\n");
return m_headerBytes.size();
}
}

View File

@ -0,0 +1,74 @@
#include "install/sdmc_nsp.hpp"
#include "error.hpp"
#include "debug.h"
#include "nx/nca_writer.h"
#include "ui/instPage.hpp"
#include "util/lang.hpp"
namespace tin::install::nsp
{
SDMCNSP::SDMCNSP(std::string path)
{
m_nspFile = fopen((path).c_str(), "rb");
if (!m_nspFile)
THROW_FORMAT("can't open file at %s\n", path.c_str());
}
SDMCNSP::~SDMCNSP()
{
fclose(m_nspFile);
}
void SDMCNSP::StreamToPlaceholder(std::shared_ptr<nx::ncm::ContentStorage>& contentStorage, NcmContentId ncaId)
{
const PFS0FileEntry* fileEntry = this->GetFileEntryByNcaId(ncaId);
std::string ncaFileName = this->GetFileEntryName(fileEntry);
LOG_DEBUG("Retrieving %s\n", ncaFileName.c_str());
size_t ncaSize = fileEntry->fileSize;
NcaWriter writer(ncaId, contentStorage);
float progress;
u64 fileStart = GetDataOffset() + fileEntry->dataOffset;
u64 fileOff = 0;
size_t readSize = 0x400000; // 4MB buff
auto readBuffer = std::make_unique<u8[]>(readSize);
try
{
inst::ui::instPage::setInstInfoText("inst.info_page.top_info0"_lang + ncaFileName + "...");
inst::ui::instPage::setInstBarPerc(0);
while (fileOff < ncaSize)
{
progress = (float) fileOff / (float) ncaSize;
if (fileOff % (0x400000 * 3) == 0) {
LOG_DEBUG("> Progress: %lu/%lu MB (%d%s)\r", (fileOff / 1000000), (ncaSize / 1000000), (int)(progress * 100.0), "%");
inst::ui::instPage::setInstBarPerc((double)(progress * 100.0));
}
if (fileOff + readSize >= ncaSize) readSize = ncaSize - fileOff;
this->BufferData(readBuffer.get(), fileOff + fileStart, readSize);
writer.write(readBuffer.get(), readSize);
fileOff += readSize;
}
inst::ui::instPage::setInstBarPerc(100);
}
catch (std::exception& e)
{
LOG_DEBUG("something went wrong: %s\n", e.what());
}
writer.close();
}
void SDMCNSP::BufferData(void* buf, off_t offset, size_t size)
{
fseeko(m_nspFile, offset, SEEK_SET);
fread(buf, 1, size, m_nspFile);
}
}

View File

@ -0,0 +1,74 @@
#include "install/sdmc_xci.hpp"
#include "error.hpp"
#include "debug.h"
#include "nx/nca_writer.h"
#include "ui/instPage.hpp"
#include "util/lang.hpp"
namespace tin::install::xci
{
SDMCXCI::SDMCXCI(std::string path)
{
m_xciFile = fopen((path).c_str(), "rb");
if (!m_xciFile)
THROW_FORMAT("can't open file at %s\n", path.c_str());
}
SDMCXCI::~SDMCXCI()
{
fclose(m_xciFile);
}
void SDMCXCI::StreamToPlaceholder(std::shared_ptr<nx::ncm::ContentStorage>& contentStorage, NcmContentId ncaId)
{
const HFS0FileEntry* fileEntry = this->GetFileEntryByNcaId(ncaId);
std::string ncaFileName = this->GetFileEntryName(fileEntry);
LOG_DEBUG("Retrieving %s\n", ncaFileName.c_str());
size_t ncaSize = fileEntry->fileSize;
NcaWriter writer(ncaId, contentStorage);
float progress;
u64 fileStart = GetDataOffset() + fileEntry->dataOffset;
u64 fileOff = 0;
size_t readSize = 0x400000; // 4MB buff
auto readBuffer = std::make_unique<u8[]>(readSize);
try
{
inst::ui::instPage::setInstInfoText("inst.info_page.top_info0"_lang + ncaFileName + "...");
inst::ui::instPage::setInstBarPerc(0);
while (fileOff < ncaSize)
{
progress = (float) fileOff / (float) ncaSize;
if (fileOff % (0x400000 * 3) == 0) {
LOG_DEBUG("> Progress: %lu/%lu MB (%d%s)\r", (fileOff / 1000000), (ncaSize / 1000000), (int)(progress * 100.0), "%");
inst::ui::instPage::setInstBarPerc((double)(progress * 100.0));
}
if (fileOff + readSize >= ncaSize) readSize = ncaSize - fileOff;
this->BufferData(readBuffer.get(), fileOff + fileStart, readSize);
writer.write(readBuffer.get(), readSize);
fileOff += readSize;
}
inst::ui::instPage::setInstBarPerc(100);
}
catch (std::exception& e)
{
LOG_DEBUG("something went wrong: %s\n", e.what());
}
writer.close();
}
void SDMCXCI::BufferData(void* buf, off_t offset, size_t size)
{
fseeko(m_xciFile, offset, SEEK_SET);
fread(buf, 1, size, m_xciFile);
}
}

View File

@ -0,0 +1,89 @@
/*
Copyright (c) 2017-2018 Adubbz
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#include "install/simple_filesystem.hpp"
#include <exception>
#include <memory>
#include "nx/fs.hpp"
#include "util/error.hpp"
namespace tin::install::nsp
{
SimpleFileSystem::SimpleFileSystem(nx::fs::IFileSystem& fileSystem, std::string rootPath, std::string absoluteRootPath) :
m_fileSystem(&fileSystem) , m_rootPath(rootPath), m_absoluteRootPath(absoluteRootPath)
{}
SimpleFileSystem::~SimpleFileSystem() {}
nx::fs::IFile SimpleFileSystem::OpenFile(std::string path)
{
return m_fileSystem->OpenFile(m_rootPath + path);
}
bool SimpleFileSystem::HasFile(std::string path)
{
try
{
LOG_DEBUG(("Attempting to find file at " + m_rootPath + path + "\n").c_str());
m_fileSystem->OpenFile(m_rootPath + path);
return true;
}
catch (std::exception& e) {}
return false;
}
std::string SimpleFileSystem::GetFileNameFromExtension(std::string path, std::string extension)
{
nx::fs::IDirectory dir = m_fileSystem->OpenDirectory(m_rootPath + path, FsDirOpenMode_ReadFiles | FsDirOpenMode_ReadDirs);
u64 entryCount = dir.GetEntryCount();
auto dirEntries = std::make_unique<FsDirectoryEntry[]>(entryCount);
dir.Read(0, dirEntries.get(), entryCount);
for (unsigned int i = 0; i < entryCount; i++)
{
FsDirectoryEntry dirEntry = dirEntries[i];
std::string dirEntryName = dirEntry.name;
if (dirEntry.type == FsDirEntryType_Dir)
{
auto subdirPath = path + dirEntryName + "/";
auto subdirFound = this->GetFileNameFromExtension(subdirPath, extension);
if (subdirFound != "")
return subdirFound;
continue;
}
else if (dirEntry.type == FsDirEntryType_File)
{
auto foundExtension = dirEntryName.substr(dirEntryName.find(".") + 1);
if (foundExtension == extension)
return dirEntryName;
}
}
return "";
}
}

193
source/install/usb_nsp.cpp Normal file
View File

@ -0,0 +1,193 @@
/*
Copyright (c) 2017-2018 Adubbz
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#include "install/usb_nsp.hpp"
#include <switch.h>
#include <algorithm>
#include <malloc.h>
#include <threads.h>
#include "data/byte_buffer.hpp"
#include "data/buffered_placeholder_writer.hpp"
#include "util/usb_util.hpp"
#include "util/error.hpp"
#include "util/debug.h"
#include "util/util.hpp"
#include "util/usb_comms_tinleaf.h"
#include "util/lang.hpp"
#include "ui/instPage.hpp"
namespace tin::install::nsp
{
bool stopThreadsUsbNsp;
std::string errorMessageUsbNsp;
USBNSP::USBNSP(std::string nspName) :
m_nspName(nspName)
{
}
struct USBFuncArgs
{
std::string nspName;
tin::data::BufferedPlaceholderWriter* bufferedPlaceholderWriter;
u64 pfs0Offset;
u64 ncaSize;
};
int USBThreadFunc(void* in)
{
USBFuncArgs* args = reinterpret_cast<USBFuncArgs*>(in);
tin::util::USBCmdHeader header = tin::util::USBCmdManager::SendFileRangeCmd(args->nspName, args->pfs0Offset, args->ncaSize);
u8* buf = (u8*)memalign(0x1000, 0x800000);
u64 sizeRemaining = header.dataSize;
size_t tmpSizeRead = 0;
try
{
while (sizeRemaining && !stopThreadsUsbNsp)
{
tmpSizeRead = tinleaf_usbCommsRead(buf, std::min(sizeRemaining, (u64)0x800000), 5000000000);
if (tmpSizeRead == 0) THROW_FORMAT(("inst.usb.error"_lang).c_str());
sizeRemaining -= tmpSizeRead;
while (true)
{
if (args->bufferedPlaceholderWriter->CanAppendData(tmpSizeRead))
break;
}
args->bufferedPlaceholderWriter->AppendData(buf, tmpSizeRead);
}
}
catch (std::exception& e)
{
stopThreadsUsbNsp = true;
errorMessageUsbNsp = e.what();
}
free(buf);
return 0;
}
int USBPlaceholderWriteFunc(void* in)
{
USBFuncArgs* args = reinterpret_cast<USBFuncArgs*>(in);
while (!args->bufferedPlaceholderWriter->IsPlaceholderComplete() && !stopThreadsUsbNsp)
{
if (args->bufferedPlaceholderWriter->CanWriteSegmentToPlaceholder())
args->bufferedPlaceholderWriter->WriteSegmentToPlaceholder();
}
return 0;
}
void USBNSP::StreamToPlaceholder(std::shared_ptr<nx::ncm::ContentStorage>& contentStorage, NcmContentId placeholderId)
{
const PFS0FileEntry* fileEntry = this->GetFileEntryByNcaId(placeholderId);
std::string ncaFileName = this->GetFileEntryName(fileEntry);
LOG_DEBUG("Retrieving %s\n", ncaFileName.c_str());
size_t ncaSize = fileEntry->fileSize;
tin::data::BufferedPlaceholderWriter bufferedPlaceholderWriter(contentStorage, placeholderId, ncaSize);
USBFuncArgs args;
args.nspName = m_nspName;
args.bufferedPlaceholderWriter = &bufferedPlaceholderWriter;
args.pfs0Offset = this->GetDataOffset() + fileEntry->dataOffset;
args.ncaSize = ncaSize;
thrd_t usbThread;
thrd_t writeThread;
stopThreadsUsbNsp = false;
thrd_create(&usbThread, USBThreadFunc, &args);
thrd_create(&writeThread, USBPlaceholderWriteFunc, &args);
u64 freq = armGetSystemTickFreq();
u64 startTime = armGetSystemTick();
size_t startSizeBuffered = 0;
double speed = 0.0;
inst::ui::instPage::setInstBarPerc(0);
while (!bufferedPlaceholderWriter.IsBufferDataComplete() && !stopThreadsUsbNsp)
{
u64 newTime = armGetSystemTick();
if (newTime - startTime >= freq)
{
size_t newSizeBuffered = bufferedPlaceholderWriter.GetSizeBuffered();
double mbBuffered = (newSizeBuffered / 1000000.0) - (startSizeBuffered / 1000000.0);
double duration = ((double)(newTime - startTime) / (double)freq);
speed = mbBuffered / duration;
startTime = newTime;
startSizeBuffered = newSizeBuffered;
int downloadProgress = (int)(((double)bufferedPlaceholderWriter.GetSizeBuffered() / (double)bufferedPlaceholderWriter.GetTotalDataSize()) * 100.0);
#ifdef NXLINK_DEBUG
u64 totalSizeMB = bufferedPlaceholderWriter.GetTotalDataSize() / 1000000;
u64 downloadSizeMB = bufferedPlaceholderWriter.GetSizeBuffered() / 1000000;
LOG_DEBUG("> Download Progress: %lu/%lu MB (%i%s) (%.2f MB/s)\r", downloadSizeMB, totalSizeMB, downloadProgress, "%", speed);
#endif
inst::ui::instPage::setInstInfoText("inst.info_page.downloading"_lang + inst::util::formatUrlString(ncaFileName) + "inst.info_page.at"_lang + std::to_string(speed).substr(0, std::to_string(speed).size()-4) + "MB/s");
inst::ui::instPage::setInstBarPerc((double)downloadProgress);
}
}
inst::ui::instPage::setInstBarPerc(100);
#ifdef NXLINK_DEBUG
u64 totalSizeMB = bufferedPlaceholderWriter.GetTotalDataSize() / 1000000;
#endif
inst::ui::instPage::setInstInfoText("inst.info_page.top_info0"_lang + ncaFileName + "...");
inst::ui::instPage::setInstBarPerc(0);
while (!bufferedPlaceholderWriter.IsPlaceholderComplete() && !stopThreadsUsbNsp)
{
int installProgress = (int)(((double)bufferedPlaceholderWriter.GetSizeWrittenToPlaceholder() / (double)bufferedPlaceholderWriter.GetTotalDataSize()) * 100.0);
#ifdef NXLINK_DEBUG
u64 installSizeMB = bufferedPlaceholderWriter.GetSizeWrittenToPlaceholder() / 1000000;
LOG_DEBUG("> Install Progress: %lu/%lu MB (%i%s)\r", installSizeMB, totalSizeMB, installProgress, "%");
#endif
inst::ui::instPage::setInstBarPerc((double)installProgress);
}
inst::ui::instPage::setInstBarPerc(100);
thrd_join(usbThread, NULL);
thrd_join(writeThread, NULL);
if (stopThreadsUsbNsp) throw std::runtime_error(errorMessageUsbNsp.c_str());
}
void USBNSP::BufferData(void* buf, off_t offset, size_t size)
{
LOG_DEBUG("buffering 0x%lx-0x%lx\n", offset, offset + size);
tin::util::USBCmdHeader header = tin::util::USBCmdManager::SendFileRangeCmd(m_nspName, offset, size);
u8* tempBuffer = (u8*)memalign(0x1000, header.dataSize);
if (tin::util::USBRead(tempBuffer, header.dataSize) == 0) THROW_FORMAT(("inst.usb.error"_lang).c_str());
memcpy(buf, tempBuffer, header.dataSize);
free(tempBuffer);
}
}

192
source/install/usb_xci.cpp Normal file
View File

@ -0,0 +1,192 @@
/*
Copyright (c) 2017-2018 Adubbz
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#include "install/usb_xci.hpp"
#include <switch.h>
#include <algorithm>
#include <malloc.h>
#include <threads.h>
#include "data/byte_buffer.hpp"
#include "data/buffered_placeholder_writer.hpp"
#include "util/usb_util.hpp"
#include "util/error.hpp"
#include "util/debug.h"
#include "util/util.hpp"
#include "util/usb_comms_tinleaf.h"
#include "util/lang.hpp"
#include "ui/instPage.hpp"
namespace tin::install::xci
{
bool stopThreadsUsbXci;
std::string errorMessageUsbXci;
USBXCI::USBXCI(std::string xciName) :
m_xciName(xciName)
{
}
struct USBFuncArgs
{
std::string xciName;
tin::data::BufferedPlaceholderWriter* bufferedPlaceholderWriter;
u64 hfs0Offset;
u64 ncaSize;
};
int USBThreadFunc(void* in)
{
USBFuncArgs* args = reinterpret_cast<USBFuncArgs*>(in);
tin::util::USBCmdHeader header = tin::util::USBCmdManager::SendFileRangeCmd(args->xciName, args->hfs0Offset, args->ncaSize);
u8* buf = (u8*)memalign(0x1000, 0x800000);
u64 sizeRemaining = header.dataSize;
size_t tmpSizeRead = 0;
try
{
while (sizeRemaining && !stopThreadsUsbXci)
{
tmpSizeRead = tinleaf_usbCommsRead(buf, std::min(sizeRemaining, (u64)0x800000), 5000000000);
if (tmpSizeRead == 0) THROW_FORMAT(("inst.usb.error"_lang).c_str());
sizeRemaining -= tmpSizeRead;
while (true)
{
if (args->bufferedPlaceholderWriter->CanAppendData(tmpSizeRead))
break;
}
args->bufferedPlaceholderWriter->AppendData(buf, tmpSizeRead);
}
}
catch (std::exception& e)
{
stopThreadsUsbXci = true;
errorMessageUsbXci = e.what();
}
free(buf);
return 0;
}
int USBPlaceholderWriteFunc(void* in)
{
USBFuncArgs* args = reinterpret_cast<USBFuncArgs*>(in);
while (!args->bufferedPlaceholderWriter->IsPlaceholderComplete() && !stopThreadsUsbXci)
{
if (args->bufferedPlaceholderWriter->CanWriteSegmentToPlaceholder())
args->bufferedPlaceholderWriter->WriteSegmentToPlaceholder();
}
return 0;
}
void USBXCI::StreamToPlaceholder(std::shared_ptr<nx::ncm::ContentStorage>& contentStorage, NcmContentId placeholderId)
{
const HFS0FileEntry* fileEntry = this->GetFileEntryByNcaId(placeholderId);
std::string ncaFileName = this->GetFileEntryName(fileEntry);
LOG_DEBUG("Retrieving %s\n", ncaFileName.c_str());
size_t ncaSize = fileEntry->fileSize;
tin::data::BufferedPlaceholderWriter bufferedPlaceholderWriter(contentStorage, placeholderId, ncaSize);
USBFuncArgs args;
args.xciName = m_xciName;
args.bufferedPlaceholderWriter = &bufferedPlaceholderWriter;
args.hfs0Offset = this->GetDataOffset() + fileEntry->dataOffset;
args.ncaSize = ncaSize;
thrd_t usbThread;
thrd_t writeThread;
stopThreadsUsbXci = false;
thrd_create(&usbThread, USBThreadFunc, &args);
thrd_create(&writeThread, USBPlaceholderWriteFunc, &args);
u64 freq = armGetSystemTickFreq();
u64 startTime = armGetSystemTick();
size_t startSizeBuffered = 0;
double speed = 0.0;
inst::ui::instPage::setInstBarPerc(0);
while (!bufferedPlaceholderWriter.IsBufferDataComplete() && !stopThreadsUsbXci)
{
u64 newTime = armGetSystemTick();
if (newTime - startTime >= freq)
{
size_t newSizeBuffered = bufferedPlaceholderWriter.GetSizeBuffered();
double mbBuffered = (newSizeBuffered / 1000000.0) - (startSizeBuffered / 1000000.0);
double duration = ((double)(newTime - startTime) / (double)freq);
speed = mbBuffered / duration;
startTime = newTime;
startSizeBuffered = newSizeBuffered;
int downloadProgress = (int)(((double)bufferedPlaceholderWriter.GetSizeBuffered() / (double)bufferedPlaceholderWriter.GetTotalDataSize()) * 100.0);
#ifdef NXLINK_DEBUG
u64 totalSizeMB = bufferedPlaceholderWriter.GetTotalDataSize() / 1000000;
u64 downloadSizeMB = bufferedPlaceholderWriter.GetSizeBuffered() / 1000000;
LOG_DEBUG("> Download Progress: %lu/%lu MB (%i%s) (%.2f MB/s)\r", downloadSizeMB, totalSizeMB, downloadProgress, "%", speed);
#endif
inst::ui::instPage::setInstInfoText("inst.info_page.downloading"_lang + inst::util::formatUrlString(ncaFileName) + "inst.info_page.at"_lang + std::to_string(speed).substr(0, std::to_string(speed).size()-4) + "MB/s");
inst::ui::instPage::setInstBarPerc((double)downloadProgress);
}
}
inst::ui::instPage::setInstBarPerc(100);
#ifdef NXLINK_DEBUG
u64 totalSizeMB = bufferedPlaceholderWriter.GetTotalDataSize() / 1000000;
#endif
inst::ui::instPage::setInstInfoText("inst.info_page.top_info0"_lang + ncaFileName + "...");
inst::ui::instPage::setInstBarPerc(0);
while (!bufferedPlaceholderWriter.IsPlaceholderComplete() && !stopThreadsUsbXci)
{
int installProgress = (int)(((double)bufferedPlaceholderWriter.GetSizeWrittenToPlaceholder() / (double)bufferedPlaceholderWriter.GetTotalDataSize()) * 100.0);
#ifdef NXLINK_DEBUG
u64 installSizeMB = bufferedPlaceholderWriter.GetSizeWrittenToPlaceholder() / 1000000;
LOG_DEBUG("> Install Progress: %lu/%lu MB (%i%s)\r", installSizeMB, totalSizeMB, installProgress, "%");
#endif
inst::ui::instPage::setInstBarPerc((double)installProgress);
}
inst::ui::instPage::setInstBarPerc(100);
thrd_join(usbThread, NULL);
thrd_join(writeThread, NULL);
if (stopThreadsUsbXci) throw std::runtime_error(errorMessageUsbXci.c_str());
}
void USBXCI::BufferData(void* buf, off_t offset, size_t size)
{
LOG_DEBUG("buffering 0x%lx-0x%lx\n", offset, offset + size);
tin::util::USBCmdHeader header = tin::util::USBCmdManager::SendFileRangeCmd(m_xciName, offset, size);
u8* tempBuffer = (u8*)memalign(0x1000, header.dataSize);
if (tin::util::USBRead(tempBuffer, header.dataSize) == 0) THROW_FORMAT(("inst.usb.error"_lang).c_str());
memcpy(buf, tempBuffer, header.dataSize);
free(tempBuffer);
}
}

174
source/install/xci.cpp Normal file
View File

@ -0,0 +1,174 @@
/*
Copyright (c) 2017-2018 Adubbz
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#include "install/xci.hpp"
#include "util/title_util.hpp"
#include "error.hpp"
#include "debug.h"
namespace tin::install::xci
{
XCI::XCI()
{
}
void XCI::RetrieveHeader()
{
LOG_DEBUG("Retrieving HFS0 header...\n");
// Retrieve hfs0 offset
u64 hfs0Offset = 0xf000;
// Retrieve main hfs0 header
std::vector<u8> m_headerBytes;
m_headerBytes.resize(sizeof(HFS0BaseHeader), 0);
this->BufferData(m_headerBytes.data(), hfs0Offset, sizeof(HFS0BaseHeader));
LOG_DEBUG("Base header: \n");
printBytes(m_headerBytes.data(), sizeof(HFS0BaseHeader), true);
// Retrieve full header
HFS0BaseHeader *header = reinterpret_cast<HFS0BaseHeader*>(m_headerBytes.data());
if (header->magic != MAGIC_HFS0)
THROW_FORMAT("hfs0 magic doesn't match at 0x%lx\n", hfs0Offset);
size_t remainingHeaderSize = header->numFiles * sizeof(HFS0FileEntry) + header->stringTableSize;
m_headerBytes.resize(sizeof(HFS0BaseHeader) + remainingHeaderSize, 0);
this->BufferData(m_headerBytes.data() + sizeof(HFS0BaseHeader), hfs0Offset + sizeof(HFS0BaseHeader), remainingHeaderSize);
LOG_DEBUG("Base header: \n");
printBytes(m_headerBytes.data(), sizeof(HFS0BaseHeader) + remainingHeaderSize, true);
// Find Secure partition
header = reinterpret_cast<HFS0BaseHeader*>(m_headerBytes.data());
for (unsigned int i = 0; i < header->numFiles; i++)
{
const HFS0FileEntry *entry = hfs0GetFileEntry(header, i);
std::string entryName(hfs0GetFileName(header, entry));
if (entryName != "secure")
continue;
m_secureHeaderOffset = hfs0Offset + remainingHeaderSize + 0x10 + entry->dataOffset;
m_secureHeaderBytes.resize(sizeof(HFS0BaseHeader), 0);
this->BufferData(m_secureHeaderBytes.data(), m_secureHeaderOffset, sizeof(HFS0BaseHeader));
LOG_DEBUG("Secure header: \n");
printBytes(m_secureHeaderBytes.data(), sizeof(HFS0BaseHeader), true);
if (this->GetSecureHeader()->magic != MAGIC_HFS0)
THROW_FORMAT("hfs0 magic doesn't match at 0x%lx\n", m_secureHeaderOffset);
// Retrieve full header
remainingHeaderSize = this->GetSecureHeader()->numFiles * sizeof(HFS0FileEntry) + this->GetSecureHeader()->stringTableSize;
m_secureHeaderBytes.resize(sizeof(HFS0BaseHeader) + remainingHeaderSize, 0);
this->BufferData(m_secureHeaderBytes.data() + sizeof(HFS0BaseHeader), m_secureHeaderOffset + sizeof(HFS0BaseHeader), remainingHeaderSize);
LOG_DEBUG("Base header: \n");
printBytes(m_secureHeaderBytes.data(), sizeof(HFS0BaseHeader) + remainingHeaderSize, true);
return;
}
THROW_FORMAT("couldn't optain secure hfs0 header\n");
}
const HFS0BaseHeader* XCI::GetSecureHeader()
{
if (m_secureHeaderBytes.empty())
THROW_FORMAT("Cannot retrieve header as header bytes are empty. Have you retrieved it yet?\n");
return reinterpret_cast<HFS0BaseHeader*>(m_secureHeaderBytes.data());
}
u64 XCI::GetDataOffset()
{
if (m_secureHeaderBytes.empty())
THROW_FORMAT("Cannot get data offset as header is empty. Have you retrieved it yet?\n");
return m_secureHeaderOffset + m_secureHeaderBytes.size();
}
const HFS0FileEntry* XCI::GetFileEntry(unsigned int index)
{
if (index >= this->GetSecureHeader()->numFiles)
THROW_FORMAT("File entry index is out of bounds\n")
return hfs0GetFileEntry(this->GetSecureHeader(), index);
}
const HFS0FileEntry* XCI::GetFileEntryByName(std::string name)
{
for (unsigned int i = 0; i < this->GetSecureHeader()->numFiles; i++)
{
const HFS0FileEntry* fileEntry = this->GetFileEntry(i);
std::string foundName(this->GetFileEntryName(fileEntry));
if (foundName == name)
return fileEntry;
}
return nullptr;
}
const HFS0FileEntry* XCI::GetFileEntryByNcaId(const NcmContentId& ncaId)
{
const HFS0FileEntry* fileEntry = nullptr;
std::string ncaIdStr = tin::util::GetNcaIdString(ncaId);
if ((fileEntry = this->GetFileEntryByName(ncaIdStr + ".nca")) == nullptr)
{
if ((fileEntry = this->GetFileEntryByName(ncaIdStr + ".cnmt.nca")) == nullptr)
{
if ((fileEntry = this->GetFileEntryByName(ncaIdStr + ".ncz")) == nullptr)
{
if ((fileEntry = this->GetFileEntryByName(ncaIdStr + ".cnmt.ncz")) == nullptr)
{
return nullptr;
}
}
}
}
return fileEntry;
}
std::vector<const HFS0FileEntry*> XCI::GetFileEntriesByExtension(std::string extension)
{
std::vector<const HFS0FileEntry*> entryList;
for (unsigned int i = 0; i < this->GetSecureHeader()->numFiles; i++)
{
const HFS0FileEntry* fileEntry = this->GetFileEntry(i);
std::string name(this->GetFileEntryName(fileEntry));
auto foundExtension = name.substr(name.find(".") + 1);
if (foundExtension == extension)
entryList.push_back(fileEntry);
}
return entryList;
}
const char* XCI::GetFileEntryName(const HFS0FileEntry* fileEntry)
{
return hfs0GetFileName(this->GetSecureHeader(), fileEntry);
}
}

26
source/main.cpp Normal file
View File

@ -0,0 +1,26 @@
#include <thread>
#include "switch.h"
#include "util/error.hpp"
#include "ui/MainApplication.hpp"
#include "util/util.hpp"
#include "util/config.hpp"
using namespace pu::ui::render;
int main(int argc, char* argv[])
{
inst::util::initApp();
try {
auto renderer = Renderer::New(SDL_INIT_TIMER | SDL_INIT_VIDEO | SDL_INIT_EVENTS | SDL_INIT_JOYSTICK | SDL_INIT_HAPTIC | SDL_INIT_GAMECONTROLLER,
RendererInitOptions::RendererNoSound, RendererHardwareFlags);
auto main = inst::ui::MainApplication::New(renderer);
std::thread updateThread;
if (inst::config::autoUpdate && inst::util::getIPAddress() != "1.0.0.127") updateThread = std::thread(inst::util::checkForAppUpdate);
main->Prepare();
main->ShowWithFadeIn();
updateThread.join();
} catch (std::exception& e) {
LOG_DEBUG("An error occurred:\n%s", e.what());
}
inst::util::deinitApp();
return 0;
}

Some files were not shown because too many files have changed in this diff Show More