Compare commits

...

13 Commits

Author SHA1 Message Date
Maschell
d3e801fffd Update github actions 2024-05-06 13:56:59 +02:00
Maschell
7b5f682918 Rename to Payload-Loader Installer update icon (thanks @Adinaton) 2024-05-06 13:56:59 +02:00
Maschell
86196c6bb1 Use ubuntu-22.04 for CI 2022-09-05 12:51:24 +02:00
Maschell
df5990044c Add LICENSE 2022-09-05 12:51:24 +02:00
Maschell
d9f6b0a237 Format the code via clang-format 2022-07-24 08:56:28 -07:00
Maschell
0c8f5afbb1 Update README 2021-12-31 17:51:00 +01:00
Maschell
c8d2fd8fcf Update the README 2021-12-26 15:20:43 +01:00
Maschell
c17d114864 Fix coldboot installation on non-aroma systems 2021-12-26 15:03:56 +01:00
Maschell
c7afdf6aa1 Fix credits 2021-12-26 15:03:30 +01:00
Maschell
202f5374aa Rename it PayloadLoader Installer 2021-12-26 15:03:22 +01:00
Maschell
678d63cabb Update submodule 2021-12-26 15:01:46 +01:00
Maschell
f972091f50 Formatting 2021-10-17 15:28:14 +02:00
Maschell
80110c3f4c Fix input when no gamepad is connected. 2021-10-17 15:26:25 +02:00
41 changed files with 1664 additions and 828 deletions

67
.clang-format Normal file
View File

@ -0,0 +1,67 @@
# Generated from CLion C/C++ Code Style settings
BasedOnStyle: LLVM
AccessModifierOffset: -4
AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: Consecutive
AlignConsecutiveMacros: AcrossEmptyLinesAndComments
AlignOperands: Align
AllowAllArgumentsOnNextLine: false
AllowAllConstructorInitializersOnNextLine: false
AllowAllParametersOfDeclarationOnNextLine: false
AllowShortBlocksOnASingleLine: Always
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: All
AllowShortIfStatementsOnASingleLine: Always
AllowShortLambdasOnASingleLine: All
AllowShortLoopsOnASingleLine: true
AlwaysBreakAfterReturnType: None
AlwaysBreakTemplateDeclarations: Yes
BreakBeforeBraces: Custom
BraceWrapping:
AfterCaseLabel: false
AfterClass: false
AfterControlStatement: Never
AfterEnum: false
AfterFunction: false
AfterNamespace: false
AfterUnion: false
BeforeCatch: false
BeforeElse: false
IndentBraces: false
SplitEmptyFunction: false
SplitEmptyRecord: true
BreakBeforeBinaryOperators: None
BreakBeforeTernaryOperators: true
BreakConstructorInitializers: BeforeColon
BreakInheritanceList: BeforeColon
ColumnLimit: 0
CompactNamespaces: false
ContinuationIndentWidth: 8
IndentCaseLabels: true
IndentPPDirectives: None
IndentWidth: 4
KeepEmptyLinesAtTheStartOfBlocks: true
MaxEmptyLinesToKeep: 2
NamespaceIndentation: All
ObjCSpaceAfterProperty: false
ObjCSpaceBeforeProtocolList: true
PointerAlignment: Right
ReflowComments: false
SpaceAfterCStyleCast: true
SpaceAfterLogicalNot: false
SpaceAfterTemplateKeyword: false
SpaceBeforeAssignmentOperators: true
SpaceBeforeCpp11BracedList: false
SpaceBeforeCtorInitializerColon: true
SpaceBeforeInheritanceColon: true
SpaceBeforeParens: ControlStatements
SpaceBeforeRangeBasedForLoopColon: true
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 1
SpacesInAngles: false
SpacesInCStyleCastParentheses: false
SpacesInContainerLiterals: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
TabWidth: 4
UseTab: Never

View File

@ -6,11 +6,18 @@ on:
- main
jobs:
build-binary:
runs-on: ubuntu-18.04
clang-format:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: clang-format
run: |
docker run --rm -v ${PWD}:/src wiiuenv/clang-format:13.0.0-2 -r ./source
build-binary:
runs-on: ubuntu-22.04
needs: clang-format
steps:
- uses: actions/checkout@v4
- name: Checkout submodules using a PAT
run: |
git config --file .gitmodules --get-regexp url | while read url; do
@ -28,7 +35,7 @@ jobs:
path: "*.wuhb"
deploy-binary:
needs: build-binary
runs-on: ubuntu-18.04
runs-on: ubuntu-22.04
steps:
- name: Get environment variables
id: get_repository_name
@ -63,4 +70,4 @@ jobs:
upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
asset_path: ./${{ env.REPOSITORY_NAME }}_${{ env.DATETIME }}.zip
asset_name: ${{ env.REPOSITORY_NAME }}_${{ env.DATETIME }}.zip
asset_content_type: application/unknown
asset_content_type: application/zip

View File

@ -3,10 +3,36 @@ name: CI-PR
on: [pull_request]
jobs:
build-binary:
runs-on: ubuntu-18.04
clang-format:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: clang-format
run: |
docker run --rm -v ${PWD}:/src wiiuenv/clang-format:13.0.0-2 -r ./source
check-build-with-logging:
runs-on: ubuntu-22.04
needs: clang-format
steps:
- uses: actions/checkout@v4
- name: Checkout submodules using a PAT
run: |
git config --file .gitmodules --get-regexp url | while read url; do
git config --file=.gitmodules $(echo "$url" | sed -E "s/git@github.com:|https:\/\/github.com\//https:\/\/${{ secrets.CI_PAT }}:${{ secrets.CI_PAT }}@github.com\//")
done
git submodule sync
git submodule update --init --recursive
- name: build binary with logging
run: |
docker build . -t builder
docker run --rm -v ${PWD}:/project builder make DEBUG=VERBOSE
docker run --rm -v ${PWD}:/project builder make clean
docker run --rm -v ${PWD}:/project builder make DEBUG=1
build-binary:
runs-on: ubuntu-22.04
needs: clang-format
steps:
- uses: actions/checkout@v4
- name: Checkout submodules using a PAT
run: |
git config --file .gitmodules --get-regexp url | while read url; do

View File

@ -1,6 +1,6 @@
FROM wiiuenv/devkitppc:20210917
FROM wiiuenv/devkitppc:20210920
COPY --from=wiiuenv/libiosuhax:20210109 /artifacts $DEVKITPRO
COPY --from=wiiuenv/libiosuhax:20211008 /artifacts $DEVKITPRO
COPY --from=wiiuenv/devkitarm:20210917 $DEVKITPRO/devkitARM $DEVKITPRO/devkitARM
ENV DEVKITARM=/opt/devkitpro/devkitARM

674
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. <http://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 <http://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:
{project} Copyright (C) {year} {fullname}
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
<http://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
<http://www.gnu.org/philosophy/why-not-lgpl.html>.

View File

@ -13,9 +13,9 @@ TOPDIR ?= $(CURDIR)
# APP_SHORTNAME sets the short name of the application
# APP_AUTHOR sets the author of the application
#-------------------------------------------------------------------------------
APP_NAME := Aroma Installer
APP_SHORTNAME := Aroma Installer
APP_AUTHOR := Maschell, rw, GaryOderNichts
APP_NAME := Payload-Loader Installer
APP_SHORTNAME := Payload-Loader Installer
APP_AUTHOR := Maschell, rw-r-r-0644, GaryOderNichts
include $(DEVKITPRO)/wut/share/wut_rules
@ -30,17 +30,15 @@ include $(DEVKITPRO)/wut/share/wut_rules
# TV_SPLASH is the image displayed during bootup on the TV, leave blank to use default rule
# DRC_SPLASH is the image displayed during bootup on the DRC, leave blank to use default rule
#-------------------------------------------------------------------------------
TARGET := AromaInstaller
TARGET := PayloadLoaderInstaller
BUILD := build
SOURCES := source \
source/common \
source/utils \
source/fs
source/fs \
source/input
INCLUDES := include source
CONTENT := meta
ICON := meta/icon.jpg
TV_SPLASH := meta/icon.jpg
DRC_SPLASH := meta/icon.jpg
ICON := meta/icon.png
#-------------------------------------------------------------------------------
# options for code generation

View File

@ -1,4 +1,27 @@
# AromaInstaller
# Payload-Loader Installer
A (hopefully) userfriendly and safe installer to inject a ["payload.elf-loader"](https://github.com/wiiu-env/PayloadFromRPX) into the Health and Safety application via [FailST](https://maschell.github.io/homebrew/2020/12/02/failst.html).
To be able to do a coldboot setup you need launch this installer via the Health & Safety injection itself.
**Use the installer to uninstall the Payload-Loader, even a factory won't remove it**
**There is always the risk of bricking the console, only proceed with installing if you understand this risk**
# Features
- Inject [PayloadFromRPX](https://github.com/wiiu-env/PayloadFromRPX) into the Health & Safety application.
- Change the boot-title of the console to Health & Safety to coldboot into PayloadFromRPX.
- Various (hash)-checks to make sure the installation will be successful.
- Restore the original Health & Safety Application.
## Usage
Load the Installer with the [PayloadLoaderInstallerEnvironment](https://github.com/wiiu-env/PayloadLoaderInstallerEnvironment) or [homebrew_on_menu_plugin](https://github.com/wiiu-env/homebrew_on_menu_plugin).
- Coldbooting into the Payload-Loader can only be activated if you launch the installer from an environment that has been loaded by the Payload-Loader. This ensures the Payload-Loader is actually working properly before coldbooting into it.
- **Launching the Payload-Loader Installer from the browser won't let change the boot title to Payload-Loader.**
- The PayloadFromRPX can only be updated when coldbooting into the Wii U Menu.
- Coldbooting can only be activated when the installer recognizes the PayloadFromRPX.
- The installer is only designed to work with a unmodifed system. **If your have modified the Health & Safety Application or system.xml in the past the installer may fail**
## Building using the Dockerfile
@ -6,11 +29,16 @@ It's possible to use a docker image for building. This way you don't need anythi
```
# Build docker image (only needed once)
docker build . -t aromainstaller-builder
docker build . -t payloadloaderinstaller-builder
# make
docker run -it --rm -v ${PWD}:/project aromainstaller-builder make
docker run -it --rm -v ${PWD}:/project payloadloaderinstaller-builder make
# make clean
docker run -it --rm -v ${PWD}:/project aromainstaller-builder make clean
```
docker run -it --rm -v ${PWD}:/project payloadloaderinstaller-builder make clean
```
# Credits
- Maschell (FailST, Installer, PayloadFromRPX)
- rw-r-r-0644 (Installer)
- GaryOderNichts (Installer)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 57 KiB

BIN
meta/icon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

@ -1 +1 @@
Subproject commit 235642bab3466ff9c9785a1813aff89b2182c12d
Subproject commit 2602aa4b56aeab0dac3149806a0f242ae56ba555

View File

@ -1,10 +1,10 @@
#include "ApplicationState.h"
#include "WiiUScreen.h"
#include "ScreenUtils.h"
#include "StringTools.h"
#include "../build/safe_payload.h"
#include <sysapp/launch.h>
#include "utils/ScreenUtils.h"
#include "utils/StringTools.h"
#include "utils/WiiUScreen.h"
#include <iosuhax.h>
#include <sysapp/launch.h>
extern "C" void OSShutdown();
@ -21,7 +21,7 @@ void ApplicationState::changeState(eGameState newState) {
menu.addText();
menu.addOption("Press A to return to the Wii U Menu.", STATE_EXIT_SYSMENU);
} else if (this->state == STATE_WELCOME_SCREEN) {
menu.addText("Welcome to the Aroma Installer!");
menu.addText("Welcome to the Payload-Loader Installer!");
menu.addText("Do you want to check if an installation is possible?");
menu.addText();
menu.addOption("Check", STATE_GET_APP_INFORMATION);
@ -33,13 +33,13 @@ void ApplicationState::changeState(eGameState newState) {
} else if (this->state == STATE_CHECK_COLDBOOT_STATUS) {
menu.addText("Check if coldboot can be enabled.");
} else if (this->state == STATE_CHECK_REMOVAL_POSSIBLE) {
menu.addText("Check if Aroma can be removed.");
menu.addText("Check if Payload-Loader can be removed.");
} else if (this->state == STATE_APP_INCOMPATIBLE) {
menu.addText("Sorry, Aroma cannot be safely installed to:");
menu.addText("Sorry, Payload-Loader cannot be safely installed to:");
menu.addText(std::string(appInfo->appName));
menu.addText();
menu.addText("Additional informations:");
auto showCheckResult = [&] (const std::string &name, bool canPatch, bool patched) {
auto showCheckResult = [&](const std::string &name, bool canPatch, bool patched) {
if (patched) {
menu.addText("[ X ] " + name + " is already patched!");
} else if (canPatch) {
@ -59,7 +59,7 @@ void ApplicationState::changeState(eGameState newState) {
menu.addText();
menu.addOption("Exit", STATE_EXIT_SYSMENU);
} else if (this->state == STATE_MAIN_MENU) {
menu.addText("Aroma " + std::string(this->alreadyInstalledAndUpdated ? "is" : "can be") + " installed to:");
menu.addText("Payload-Loader " + std::string(this->alreadyInstalledAndUpdated ? "is" : "can be") + " installed to:");
menu.addText(std::string(appInfo->appName));
menu.addText();
menu.addOption("Install / Update", STATE_INSTALL_CONFIRM_DIALOG);
@ -75,13 +75,13 @@ void ApplicationState::changeState(eGameState newState) {
menu.addOption("Back", STATE_MAIN_MENU);
} else {
if (this->coldbootTitleId == this->appInfo->titleId) {
menu.addText("Before you can install/update Aroma you need to change");
menu.addText("Before you can install/update Payload-Loader you need to change");
menu.addText("the coldboot title back to Wii U Menu");
menu.addText();
menu.addOption("Back", STATE_MAIN_MENU);
} else {
menu.addText("Are you REALLY sure you want to install Aroma?");
menu.addText("Are you REALLY sure you want to install Payload-Loader?");
menu.addText("Installing could permanently damage your console");
menu.addText();
menu.addText("After the installation the following app will turn into");
@ -104,17 +104,17 @@ void ApplicationState::changeState(eGameState newState) {
} else if (this->state == STATE_INSTALL_RPX) {
menu.addText("... install safe.rpx");
} else if (this->state == STATE_INSTALL_SUCCESS) {
menu.addText("Aroma was successfully installed");
menu.addText("Payload-Loader was successfully installed");
menu.addText();
menu.addOption("Press A to shutdown the console", STATE_EXIT_SHUTDOWN);
} else if (this->state == STATE_REMOVE_CONFIRM_DIALOG) {
if (this->systemXMLAlreadyPatched) {
menu.addText("Before you can remove Aroma you need to switch");
menu.addText("Before you can remove Payload-Loader you need to switch");
menu.addText("the system boot title back to the Wii U Menu");
menu.addText();
menu.addOption("Back", STATE_MAIN_MENU);
} else {
menu.addText("Are you REALLY sure you want to remove Aroma?");
menu.addText("Are you REALLY sure you want to remove Payload-Loader?");
menu.addText();
menu.addOption("Back", STATE_MAIN_MENU);
menu.addOption("Remove", STATE_REMOVE_STARTED);
@ -123,17 +123,16 @@ void ApplicationState::changeState(eGameState newState) {
menu.addText("Removing...");
} else if (this->state == STATE_REMOVE_COLDBOOT) {
menu.addText("... remove system.xml coldboot patches");
} else if (this->state == STATE_REMOVE_AROMA) {
menu.addText("... remove Aroma application patches");
} else if (this->state == STATE_REMOVE_PAYLOAD_LOADER) {
menu.addText("... remove Payload-Loader application patches");
} else if (this->state == STATE_REMOVE_SUCCESS) {
menu.addText("Aroma was successfully removed");
menu.addText("Payload-Loader was successfully removed");
menu.addText();
menu.addOption("Press A to shutdown the console", STATE_EXIT_SHUTDOWN);
} else if (this->state == STATE_BOOT_MENU) {
menu.addText("System is currently booting into: ");
std::string titleId = StringTools::strfmt("%ll016X", this->coldbootTitleId);
std::string titleName = this->coldbootTitle ?
std::string(this->coldbootTitle->name) : "Unknown title";
std::string titleId = StringTools::strfmt("%ll016X", this->coldbootTitleId);
std::string titleName = this->coldbootTitle ? std::string(this->coldbootTitle->name) : "Unknown title";
menu.addText(titleId + " (" + titleName + ")");
menu.addText();
if (this->systemXMLRestorePossible && this->systemXMLAlreadyPatched) {
@ -143,20 +142,19 @@ void ApplicationState::changeState(eGameState newState) {
menu.addOption("Switch back to Wii U Menu", STATE_BOOT_SWITCH_SYSMENU);
} else if (this->systemXMLPatchAllowed) {
menu.addOption("Switch to Aroma", STATE_BOOT_SWITCH_AROMA);
menu.addOption("Switch to Payload-Loader", STATE_BOOT_SWITCH_PAYLOAD_LOADER);
} else if (this->systemXMLPatchAllowedButNoRPXCheck) {
menu.addText("Your RPX is not as expected. You probably");
menu.addText("need to update or re-install Aroma first.");
menu.addText("need to update or re-install Payload-Loader first.");
menu.addText();
menu.addOption("Back", STATE_MAIN_MENU);
} else if (this->systemXMLPatchPossible) {
menu.addText("To change the system boot title to Aroma, you need to");
menu.addText("launch this installer from an already running Aroma");
menu.addText("To change the system boot title to Payload-Loader, you need to");
menu.addText("launch this installer from an already running Payload-Loader");
menu.addText("instance, in order to verify that the installation");
menu.addText("is working properly.");
menu.addText();
menu.addText("After installing Aroma, reboot the console, open the");
menu.addText("Health & Safety app and relaunch the Aroma installer.");
menu.addText("After installing Payload-Loader, reboot the console, open the");
menu.addText("Health & Safety app and relaunch the Payload-Loader installer.");
menu.addText();
} else {
menu.addText("Sorry, your system.xml file has not yet been tested");
@ -164,7 +162,7 @@ void ApplicationState::changeState(eGameState newState) {
menu.addText();
}
menu.addOption("Back", STATE_MAIN_MENU);
} else if (this->state == STATE_BOOT_SWITCH_AROMA) {
} else if (this->state == STATE_BOOT_SWITCH_PAYLOAD_LOADER) {
menu.addText("Changing system.xml to boot " + std::string(this->appInfo->appName) + " ...");
} else if (this->state == STATE_BOOT_SWITCH_SYSMENU) {
menu.addText("Changing system.xml to boot System Menu ...");
@ -210,8 +208,7 @@ void ApplicationState::update(Input *input) {
changeState(STATE_INSTALL_FST);
}
} else if (this->state == STATE_INSTALL_FST) {
auto result = (this->fstAlreadyPatched) ? InstallerService::SUCCESS :
InstallerService::patchFST(this->appInfo->path, this->appInfo->fstHash);
auto result = (this->fstAlreadyPatched) ? InstallerService::SUCCESS : InstallerService::patchFST(this->appInfo->path, this->appInfo->fstHash);
if (result != InstallerService::SUCCESS) {
this->installerError = result;
setError(ERROR_INSTALLER_ERROR);
@ -219,8 +216,7 @@ void ApplicationState::update(Input *input) {
changeState(STATE_INSTALL_COS);
}
} else if (this->state == STATE_INSTALL_COS) {
auto result = (this->cosAlreadyPatched) ? InstallerService::SUCCESS :
InstallerService::patchCOS(this->appInfo->path, this->appInfo->cosHash);
auto result = (this->cosAlreadyPatched) ? InstallerService::SUCCESS : InstallerService::patchCOS(this->appInfo->path, this->appInfo->cosHash);
if (result != InstallerService::SUCCESS) {
this->installerError = result;
setError(ERROR_INSTALLER_ERROR);
@ -243,7 +239,7 @@ void ApplicationState::update(Input *input) {
// changeState(STATE_REMOVE_COLDBOOT);
setError(ERROR_INSTALLER_ERROR);
} else {
changeState(STATE_REMOVE_AROMA);
changeState(STATE_REMOVE_PAYLOAD_LOADER);
}
} else if (this->state == STATE_REMOVE_COLDBOOT) {
auto result = InstallerService::setBootTitle(*this->systemMenuTitleId);
@ -251,9 +247,9 @@ void ApplicationState::update(Input *input) {
this->installerError = result;
setError(ERROR_INSTALLER_ERROR);
} else {
changeState(STATE_REMOVE_AROMA);
changeState(STATE_REMOVE_PAYLOAD_LOADER);
}
} else if (this->state == STATE_REMOVE_AROMA) {
} else if (this->state == STATE_REMOVE_PAYLOAD_LOADER) {
auto result = InstallerService::restoreAppFiles(this->appInfo->path);
if (result != InstallerService::SUCCESS) {
this->installerError = result;
@ -270,7 +266,7 @@ void ApplicationState::update(Input *input) {
} else {
changeState(STATE_BOOT_SWITCH_SUCCESS);
}
} else if (this->state == STATE_BOOT_SWITCH_AROMA) {
} else if (this->state == STATE_BOOT_SWITCH_PAYLOAD_LOADER) {
OSEnableHomeButtonMenu(false);
auto result = InstallerService::setBootTitle(this->appInfo->titleId);
if (result != InstallerService::SUCCESS) {
@ -290,8 +286,8 @@ void ApplicationState::update(Input *input) {
ApplicationState::ApplicationState() {
menu.setOptionsCallback([this](auto &&newState) { changeState(std::forward<decltype(newState)>(newState)); });
menu.setHeader("Aroma Installer");
menu.setFooter("By Maschell");
menu.setHeader("Payload-Loader Installer");
menu.setFooter("By Maschell, rw-r-r-0644, GaryOderNichts");
changeState(STATE_WELCOME_SCREEN);
DEBUG_FUNCTION_LINE("State has changed to \"STATE_WELCOME_SCREEN\"");
@ -303,7 +299,7 @@ void ApplicationState::checkPatchPossible() {
this->fstAlreadyPatched = (InstallerService::checkFSTAlreadyValid(this->appInfo->path, this->appInfo->fstHash) == InstallerService::SUCCESS);
this->rpxAlreadyPatched = (InstallerService::checkRPXAlreadyValid(this->appInfo->path, RPX_HASH) == InstallerService::SUCCESS);
this->cosAlreadyPatched = (InstallerService::checkCOSAlreadyValid(this->appInfo->path, this->appInfo->cosHash) == InstallerService::SUCCESS);
this->tmdValid = (InstallerService::checkTMDValid(this->appInfo->path, this->appInfo->tmdHash, this->appInfo->tmdWithCertHash) == InstallerService::SUCCESS);
this->tmdValid = (InstallerService::checkTMDValid(this->appInfo->path, this->appInfo->tmdHash, this->appInfo->tmdWithCertHash) == InstallerService::SUCCESS);
InstallerService::eResults result;
@ -316,7 +312,7 @@ void ApplicationState::checkPatchPossible() {
DEBUG_FUNCTION_LINE("ERROR: %s", InstallerService::ErrorMessage(result).c_str());
}
this->installPossible = this->fstPatchPossible && this->cosPatchPossible && this->tmdValid;
this->installPossible = this->fstPatchPossible && this->cosPatchPossible && this->tmdValid;
this->alreadyInstalledAndUpdated = this->fstAlreadyPatched && this->cosAlreadyPatched && this->tmdValid && this->rpxAlreadyPatched;
changeState(STATE_CHECK_COLDBOOT_STATUS);
@ -366,7 +362,7 @@ void ApplicationState::checkColdbootStatus() {
this->systemXMLAlreadyPatched = (this->coldbootTitleId == this->appInfo->titleId);
}
this->systemXMLPatchAllowed = this->systemXMLPatchPossible && this->alreadyInstalledAndUpdated && InstallerService::isColdBootAllowed();
this->systemXMLPatchAllowed = this->systemXMLPatchPossible && this->alreadyInstalledAndUpdated && InstallerService::isColdBootAllowed();
this->systemXMLPatchAllowedButNoRPXCheck = this->systemXMLPatchPossible && this->fstAlreadyPatched && this->cosAlreadyPatched && this->tmdValid && InstallerService::isColdBootAllowed();
changeState(STATE_CHECK_REMOVAL_POSSIBLE);

View File

@ -1,15 +1,14 @@
#pragma once
#include <string>
#include <optional>
#include "common/common.h"
#include "InstallerService.h"
#include "Input.h"
#include "Menu.h"
#include "common/common.h"
#include <input/Input.h>
#include <optional>
#include <string>
class ApplicationState {
public:
enum eErrorState {
ERROR_NONE,
ERROR_IOSUHAX_FAILED,
@ -38,11 +37,11 @@ public:
STATE_REMOVE_CONFIRM_DIALOG,
STATE_REMOVE_STARTED,
STATE_REMOVE_COLDBOOT,
STATE_REMOVE_AROMA,
STATE_REMOVE_PAYLOAD_LOADER,
STATE_REMOVE_SUCCESS,
STATE_BOOT_MENU,
STATE_BOOT_SWITCH_SYSMENU,
STATE_BOOT_SWITCH_AROMA,
STATE_BOOT_SWITCH_PAYLOAD_LOADER,
STATE_BOOT_SWITCH_SUCCESS,
STATE_EXIT_SYSMENU,
STATE_EXIT_SHUTDOWN,
@ -80,23 +79,23 @@ private:
bool fstPatchPossible = false;
bool cosPatchPossible = false;
bool removalPossible = false;
bool installPossible = false;
bool removalPossible = false;
bool installPossible = false;
bool alreadyInstalledAndUpdated = false;
bool systemXMLPatchPossible = false;
bool systemXMLPatchAllowed = false;
bool systemXMLPatchPossible = false;
bool systemXMLPatchAllowed = false;
bool systemXMLPatchAllowedButNoRPXCheck = false;
bool systemXMLAlreadyPatched = false;
bool systemXMLRestorePossible = false;
bool systemXMLAlreadyPatched = false;
bool systemXMLRestorePossible = false;
eGameState state = STATE_WELCOME_SCREEN;
eErrorState error = ERROR_NONE;
eGameState state = STATE_WELCOME_SCREEN;
eErrorState error = ERROR_NONE;
uint64_t coldbootTitleId = 0;
_gList_t *coldbootTitle = nullptr;
_gList_t *coldbootTitle = nullptr;
std::optional<uint64_t> systemMenuTitleId;
bool fstAlreadyPatched = false;
bool rpxAlreadyPatched = false;
bool cosAlreadyPatched = false;
bool tmdValid = false;
bool tmdValid = false;
};

View File

@ -1,66 +0,0 @@
#pragma once
#include <cstring>
#include <cstdint>
class Input {
public:
//!Constructor
Input() = default;
//!Destructor
virtual ~Input() = default;
void combine(const Input& b) {
data.buttons_d |= b.data.buttons_d;
data.buttons_h |= b.data.buttons_h;
data.buttons_r |= b.data.buttons_r;
}
enum eButtons {
BUTTON_NONE = 0x0000,
VPAD_TOUCH = 0x80000000,
BUTTON_Z = 0x20000,
BUTTON_C = 0x10000,
BUTTON_A = 0x8000,
BUTTON_B = 0x4000,
BUTTON_X = 0x2000,
BUTTON_Y = 0x1000,
BUTTON_1 = BUTTON_Y,
BUTTON_2 = BUTTON_X,
BUTTON_LEFT = 0x0800,
BUTTON_RIGHT = 0x0400,
BUTTON_UP = 0x0200,
BUTTON_DOWN = 0x0100,
BUTTON_ZL = 0x0080,
BUTTON_ZR = 0x0040,
BUTTON_L = 0x0020,
BUTTON_R = 0x0010,
BUTTON_PLUS = 0x0008,
BUTTON_MINUS = 0x0004,
BUTTON_HOME = 0x0002,
BUTTON_SYNC = 0x0001,
STICK_R_LEFT = 0x04000000,
STICK_R_RIGHT = 0x02000000,
STICK_R_UP = 0x01000000,
STICK_R_DOWN = 0x00800000,
STICK_L_LEFT = 0x40000000,
STICK_L_RIGHT = 0x20000000,
STICK_L_UP = 0x10000000,
STICK_L_DOWN = 0x08000000
};
typedef struct {
uint32_t buttons_h;
uint32_t buttons_d;
uint32_t buttons_r;
bool validPointer;
bool touched;
float pointerAngle;
int32_t x;
int32_t y;
} PadData;
PadData data{};
PadData lastData{};
};

View File

@ -1,19 +1,19 @@
#include "common/common.h"
#include "utils/logger.h"
#include "WiiUScreen.h"
#include "StringTools.h"
#include "fs/FSUtils.h"
#include "common/fst_structs.h"
#include "InstallerService.h"
#include "utils/utils.h"
#include "common/common.h"
#include "common/fst_structs.h"
#include "fs/FSUtils.h"
#include "utils/StringTools.h"
#include "utils/WiiUScreen.h"
#include "utils/logger.h"
#include "utils/pugixml.hpp"
#include "utils/utils.h"
#include <coreinit/mcp.h>
#include <string>
#include <memory>
#include <cstdlib>
#include <malloc.h>
#include <sstream>
#include <iosuhax.h>
#include <malloc.h>
#include <memory>
#include <sstream>
#include <string>
InstallerService::eResults InstallerService::checkCOS(const std::string &path, char *hash) {
std::string cosFilePath = path + "/code/cos.xml";
@ -37,7 +37,7 @@ InstallerService::eResults InstallerService::checkCOS(const std::string &path, c
DEBUG_FUNCTION_LINE("Success! cos.xml is compatible");
return SUCCESS;
} else {
DEBUG_FUNCTION_LINE("Hash mismatch! cos.xml is NOT compatible. Expected hash: %s actual hash: %s",hash, newHash.c_str());
DEBUG_FUNCTION_LINE("Hash mismatch! cos.xml is NOT compatible. Expected hash: %s actual hash: %s", hash, newHash.c_str());
}
return COS_XML_HASH_MISMATCH;
@ -100,7 +100,7 @@ InstallerService::eResults InstallerService::checkSystemXML(const std::string &p
InstallerService::eResults InstallerService::checkFST(const std::string &path, const char *fstHash) {
std::string fstFilePath = path + "/code/title.fst";
uint8_t *fstData = nullptr;
uint8_t *fstData = nullptr;
uint32_t fstDataSize = 0;
DEBUG_FUNCTION_LINE("Trying to load FST from %s", fstFilePath.c_str());
@ -137,7 +137,7 @@ bool InstallerService::patchCOSXMLData(pugi::xml_document *doc) {
appEntry.child("codegen_core").first_child().set_value("80000001");
appEntry.child("max_size").first_child().set_value("40000000");
appEntry.child("max_codesize").first_child().set_value("00800000");
for (pugi::xml_node permission: appEntry.child("permissions").children()) {
for (pugi::xml_node permission : appEntry.child("permissions").children()) {
auto mask = permission.child("mask");
mask.first_child().set_value("FFFFFFFFFFFFFFFF");
}
@ -145,7 +145,7 @@ bool InstallerService::patchCOSXMLData(pugi::xml_document *doc) {
}
std::optional<appInformation> InstallerService::getInstalledAppInformation() {
auto mcpHandle = (int32_t) MCP_Open();
auto mcpHandle = (int32_t) MCP_Open();
auto titleCount = (uint32_t) MCP_TitleCount(mcpHandle);
auto *titleList = (MCPTitleListType *) memalign(32, sizeof(MCPTitleListType) * titleCount);
@ -188,7 +188,7 @@ std::optional<appInformation> InstallerService::getInstalledAppInformation() {
}
std::optional<uint64_t> InstallerService::getSystemMenuTitleId() {
auto mcpHandle = (int32_t) MCP_Open();
auto mcpHandle = (int32_t) MCP_Open();
auto titleCount = (uint32_t) 1;
auto *titleList = (MCPTitleListType *) memalign(32, sizeof(MCPTitleListType) * titleCount);
@ -203,8 +203,7 @@ std::optional<uint64_t> InstallerService::getSystemMenuTitleId() {
if ((titleList->titleId != 0x0005001010040000L) &&
(titleList->titleId != 0x0005001010040100L) &&
(titleList->titleId != 0x0005001010040200L))
{
(titleList->titleId != 0x0005001010040200L)) {
DEBUG_FUNCTION_LINE("Unrecognized System Menu title");
return {};
}
@ -242,7 +241,7 @@ InstallerService::eResults InstallerService::patchFSTData(uint8_t *fstData, uint
DEBUG_FUNCTION_LINE("Section %d can be used as a base", usableSectionIndex);
}
auto *rootEntry = (FSTNodeEntry *) (fstData + sizeof(FSTHeader) + numberOfSections * sizeof(FSTSectionEntry));
auto *rootEntry = (FSTNodeEntry *) (fstData + sizeof(FSTHeader) + numberOfSections * sizeof(FSTSectionEntry));
auto numberOfNodeEntries = rootEntry->directory.lastEntryNumber;
char *stringTableOffset = (char *) ((uint32_t) rootEntry + (sizeof(FSTNodeEntry) * numberOfNodeEntries));
@ -344,14 +343,13 @@ std::string InstallerService::ErrorMessage(InstallerService::eResults error) {
} else {
return "UNKNOWN ERROR";
}
}
bool InstallerService::isBackupAvailable(const std::string &path) {
std::string backupList[] = {
{"/content/title.fst.bak"},
{"/content/cos.xml.bak" },
{"/content/safe.rpx.bak" },
{"/content/title.fst.bak"},
{"/content/cos.xml.bak"},
{"/content/safe.rpx.bak"},
};
for (auto &backupEntry : backupList) {
@ -374,7 +372,7 @@ bool InstallerService::isBackupAvailable(const std::string &path) {
}
std::string savedHash = std::string(sha1FileCont, sha1FileCont + sha1FileSize);
std::string fileHash = Utils::hashFile(backupFile);
std::string fileHash = Utils::hashFile(backupFile);
if (fileHash != savedHash) {
return false;
}
@ -385,13 +383,13 @@ bool InstallerService::isBackupAvailable(const std::string &path) {
InstallerService::eResults InstallerService::restoreAppFiles(const std::string &path) {
std::string backupList[][2] = {
{"/code/title.fst", "/content/title.fst.bak"},
{"/code/cos.xml", "/content/cos.xml.bak" },
{"/code/safe.rpx", "/content/safe.rpx.bak" },
{"/code/title.fst", "/content/title.fst.bak"},
{"/code/cos.xml", "/content/cos.xml.bak"},
{"/code/safe.rpx", "/content/safe.rpx.bak"},
};
for (auto &backupOp : backupList) {
std::string destPath = path + backupOp[0];
std::string destPath = path + backupOp[0];
std::string backupPath = path + backupOp[1];
if (!FSUtils::copyFile(backupPath, destPath)) {
@ -408,7 +406,7 @@ InstallerService::eResults InstallerService::restoreAppFiles(const std::string &
}
for (auto &backupOp : backupList) {
std::string backupPath = path + backupOp[1];
std::string backupPath = path + backupOp[1];
std::string backupSha1Path = backupPath + ".sha1";
::remove(backupPath.c_str());
::remove(backupSha1Path.c_str());
@ -420,14 +418,14 @@ InstallerService::eResults InstallerService::restoreAppFiles(const std::string &
InstallerService::eResults InstallerService::backupAppFiles(const std::string &path) {
std::string backupList[][2] = {
{"/code/title.fst", "/content/title.fst.bak"},
{"/code/cos.xml", "/content/cos.xml.bak" },
{"/code/safe.rpx", "/content/safe.rpx.bak" },
{"/code/title.fst", "/content/title.fst.bak"},
{"/code/cos.xml", "/content/cos.xml.bak"},
{"/code/safe.rpx", "/content/safe.rpx.bak"},
};
for (auto &backupOp : backupList) {
std::string backupSrc = path + backupOp[0];
std::string backupDst = path + backupOp[1];
std::string backupSrc = path + backupOp[0];
std::string backupDst = path + backupOp[1];
std::string backupSha1 = backupDst + ".sha1";
if (FSUtils::CheckFile(backupDst.c_str())) {
@ -457,7 +455,7 @@ InstallerService::eResults InstallerService::backupAppFiles(const std::string &p
}
InstallerService::eResults InstallerService::patchFST(const std::string &path, const char *fstHash) {
std::string fstFilePath = path + "/code/title.fst";
std::string fstFilePath = path + "/code/title.fst";
std::string fstBackupFilePath = path + "/code/backup.fst";
std::string fstTargetFilePath = path + "/code/title.fst";
@ -475,7 +473,7 @@ InstallerService::eResults InstallerService::patchFST(const std::string &path, c
return FAILED_TO_CHECK_HASH_COPIED_FILES;
}
uint8_t *fstData = nullptr;
uint8_t *fstData = nullptr;
uint32_t fstDataSize = 0;
DEBUG_FUNCTION_LINE("Trying to load FST from %s", fstFilePath.c_str());
@ -517,7 +515,7 @@ InstallerService::eResults InstallerService::patchFST(const std::string &path, c
}
InstallerService::eResults InstallerService::patchCOS(const std::string &path, char *hash) {
std::string cosFilePath = path + "/code/cos.xml";
std::string cosFilePath = path + "/code/cos.xml";
std::string cosBackupFilePath = path + "/code/cback.xml";
std::string cosTargetFilePath = path + "/code/cos.xml";
@ -619,9 +617,9 @@ InstallerService::eResults InstallerService::copyRPX(const std::string &path, co
}
InstallerService::eResults InstallerService::patchSystemXML(const std::string &path, uint64_t titleId) {
std::string inputFile = std::string(path + "/system.xml");
std::string inputFile = std::string(path + "/system.xml");
std::string backupFile = std::string(path + "/sbackup.xml");
std::string finalFile = std::string(path + "/system.xml");
std::string finalFile = std::string(path + "/system.xml");
if (!FSUtils::copyFile(inputFile, backupFile)) {
DEBUG_CONSOLE_LOG("Failed to copy files");
@ -726,7 +724,7 @@ InstallerService::eResults InstallerService::checkTMDValid(const std::string &pa
InstallerService::eResults result = checkFileHash(filePath, hash);
if(result != SUCCESS){
if (result != SUCCESS) {
// In some cases the tmd seems to have cert appended
return checkFileHash(filePath, tmdWithCertHash);
}
@ -744,7 +742,7 @@ InstallerService::eResults InstallerService::checkRPXAlreadyValid(const std::str
}
InstallerService::eResults InstallerService::checkFileHash(const std::string &filePath, const std::string &hash) {
uint8_t *fileData = nullptr;
uint8_t *fileData = nullptr;
uint32_t fileDataSize = 0;
if (FSUtils::LoadFileToMem(filePath.c_str(), &fileData, &fileDataSize) < 0) {
@ -790,4 +788,3 @@ InstallerService::eResults InstallerService::setBootTitle(uint64_t titleId) {
return SUCCESS;
}

View File

@ -1,45 +1,45 @@
#pragma once
#include "utils/pugixml.hpp"
#include "common/common.h"
#include <optional>
#include "utils/pugixml.hpp"
#include <coreinit/memorymap.h>
#include <optional>
class InstallerService {
public:
enum eResults {
SUCCESS = 0,
NO_COMPATIBLE_APP_INSTALLED = -1,
FAILED_TO_COPY_FILES = -2,
FAILED_TO_CHECK_HASH_COPIED_FILES = -3,
SYSTEM_XML_INFORMATION_NOT_FOUND = -4,
SYSTEM_XML_PARSING_FAILED = -5,
SUCCESS = 0,
NO_COMPATIBLE_APP_INSTALLED = -1,
FAILED_TO_COPY_FILES = -2,
FAILED_TO_CHECK_HASH_COPIED_FILES = -3,
SYSTEM_XML_INFORMATION_NOT_FOUND = -4,
SYSTEM_XML_PARSING_FAILED = -5,
SYSTEM_XML_HASH_MISMATCH_RESTORE_FAILED = -6,
SYSTEM_XML_HASH_MISMATCH = -7,
RPX_HASH_MISMATCH = -8,
RPX_HASH_MISMATCH_RESTORE_FAILED = -9,
COS_XML_PARSING_FAILED = -10,
COS_XML_HASH_MISMATCH = -11,
COS_XML_HASH_MISMATCH_RESTORE_FAILED = -12,
MALLOC_FAILED = -13,
FST_HASH_MISMATCH = -14,
FST_HASH_MISMATCH_RESTORE_FAILED = -15,
FST_HEADER_MISMATCH = -16,
FST_NO_USABLE_SECTION_FOUND = -17,
FAILED_TO_LOAD_FILE = -18,
SYSTEM_XML_HASH_MISMATCH = -7,
RPX_HASH_MISMATCH = -8,
RPX_HASH_MISMATCH_RESTORE_FAILED = -9,
COS_XML_PARSING_FAILED = -10,
COS_XML_HASH_MISMATCH = -11,
COS_XML_HASH_MISMATCH_RESTORE_FAILED = -12,
MALLOC_FAILED = -13,
FST_HASH_MISMATCH = -14,
FST_HASH_MISMATCH_RESTORE_FAILED = -15,
FST_HEADER_MISMATCH = -16,
FST_NO_USABLE_SECTION_FOUND = -17,
FAILED_TO_LOAD_FILE = -18,
};
static bool isColdBootAllowed(){
if (OSIsAddressValid(0x00FFFFF8)) {
uint64_t bootedFrom = *((uint64_t *) 0x00FFFFF8);
if (
bootedFrom == 0x000500101004E000L || // H&S JPN
bootedFrom == 0x000500101004E100L || // H&S USA
bootedFrom == 0x000500101004E200L // H&S EUR
) {
return true;
}
static bool isColdBootAllowed() {
/* if (OSIsAddressValid(0x00FFFFF8)) { */
uint64_t bootedFrom = *((uint64_t *) 0x00FFFFF8);
if (
bootedFrom == 0x000500101004E000L || // H&S JPN
bootedFrom == 0x000500101004E100L || // H&S USA
bootedFrom == 0x000500101004E200L // H&S EUR
) {
return true;
}
// }
return false;
}

View File

@ -1,15 +1,14 @@
#pragma once
#include <string>
#include "input/Input.h"
#include "utils/ScreenUtils.h"
#include "utils/WiiUScreen.h"
#include <functional>
#include <utility>
#include <list>
#include "Input.h"
#include "WiiUScreen.h"
#include "ScreenUtils.h"
#include "VPADInput.h"
#include <string>
#include <utility>
template <typename T>
template<typename T>
class Menu {
public:
Menu() {

View File

@ -1,3 +1,4 @@
// clang-format off
#include "common.h"
systemXMLInformation systemXMLHashInformation[] = {
@ -12,7 +13,7 @@ systemXMLInformation systemXMLHashInformation[] = {
appInformation supportedApps[] = {
{0x000500101004E000L, "Health and Safety Information [JPN]", false, {'\0'}, "9D34DDD91604D781FDB0727AC75021833304964C", "F6EBF7BC8AE3AF3BB8A42E0CF3FDA051278AEB03", "D5BABA20526524977009F7EDE25182D8E41CEFD8", "2CF358E1F51932D305911A6836ED37DB0F94ABE4"}, //v129
{0x000500101004E100L, "Health and Safety Information [USA]", false, {'\0'}, "045734666A36C7EF0258A740855886EBDB20D59B", "F6EBF7BC8AE3AF3BB8A42E0CF3FDA051278AEB03", "5249DA6B75FEFADEBFBB18ECC93CC109FA8AA630", "C53C219FB8F777F9AB8F430D6BE4BC034D5638BA"}, //v129
{0x000500101004E100L, "Health and Safety Information [USA]", false, {'\0'}, "045734666A36C7EF0258A740855886EBDB20D59B", "F6EBF7BC8AE3AF3BB8A42E0CF3FDA051278AEB03", "5249DA6B75FEFADEBFBB18ECC93CC109FA8AA630", "C53C219FB8F777F9AB8F430D6BE4BC034D5638BA"}, //v129
{0x000500101004E200L, "Health and Safety Information [PAL]", false, {'\0'}, "130A76F8B36B36D43B88BBC74393D9AFD9CFD2A4", "F6EBF7BC8AE3AF3BB8A42E0CF3FDA051278AEB03", "87749A8D3EE8694225423953DCF04B01F8DA2F15", "4A29A60E5FBDAF410B7C22ECAEBDDBF29D1A874E"}, //v129
{0, nullptr, false, {'\0'}, {'\0'}, {'\0'}},
};

View File

@ -1,13 +1,13 @@
#pragma once
#include <cstdint>
#include <coreinit/mcp.h>
#include <cstdint>
#ifdef __cplusplus
extern "C" {
#endif
#define VERSION "v0.1"
#define VERSION "v0.1"
enum SYSTEM_XML_DEFAULT_TITLE_ID {
WII_U_MENU_EUR,

View File

@ -59,4 +59,3 @@ WUT_CHECK_OFFSET(FSTNodeEntry, 0x08, file.size);
WUT_CHECK_OFFSET(FSTNodeEntry, 0x0C, permission);
WUT_CHECK_OFFSET(FSTNodeEntry, 0x0E, sectionNumber);
WUT_CHECK_SIZE(FSTNodeEntry, 0x10);

View File

@ -1,13 +1,13 @@
#include "CFile.hpp"
#include <stdarg.h>
#include <stdio.h>
#include <strings.h>
#include "CFile.hpp"
CFile::CFile() {
iFd = -1;
iFd = -1;
mem_file = NULL;
filesize = 0;
pos = 0;
pos = 0;
}
CFile::CFile(const std::string &filepath, eOpenTypes mode) {
@ -33,7 +33,7 @@ int32_t CFile::open(const std::string &filepath, eOpenTypes mode) {
switch (mode) {
default:
case ReadOnly: // file must exist
case ReadOnly: // file must exist
openMode = O_RDONLY;
break;
case WriteOnly: // file will be created / zerod
@ -75,10 +75,10 @@ void CFile::close() {
if (iFd >= 0)
::close(iFd);
iFd = -1;
iFd = -1;
mem_file = NULL;
filesize = 0;
pos = 0;
pos = 0;
}
int32_t CFile::read(uint8_t *ptr, size_t size) {
@ -125,7 +125,7 @@ int32_t CFile::write(const uint8_t *ptr, size_t size) {
}
int32_t CFile::seek(long int offset, int32_t origin) {
int32_t ret = 0;
int32_t ret = 0;
int64_t newPos = pos;
if (origin == SEEK_SET) {
@ -156,7 +156,7 @@ int32_t CFile::seek(long int offset, int32_t origin) {
int32_t CFile::fwrite(const char *format, ...) {
char tmp[512];
tmp[0] = 0;
tmp[0] = 0;
int32_t result = -1;
va_list va;
@ -169,5 +169,3 @@ int32_t CFile::fwrite(const char *format, ...) {
return result;
}

View File

@ -1,10 +1,10 @@
#ifndef CFILE_HPP_
#define CFILE_HPP_
#include <stdio.h>
#include <string>
#include <string.h>
#include <fcntl.h>
#include <stdio.h>
#include <string.h>
#include <string>
#include <unistd.h>
#include <wut_types.h>

View File

@ -1,11 +1,11 @@
#include <malloc.h>
#include <string.h>
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include "FSUtils.h"
#include "CFile.hpp"
#include "utils/logger.h"
#include <fcntl.h>
#include <malloc.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
int32_t FSUtils::LoadFileToMem(const char *filepath, uint8_t **inbuffer, uint32_t *size) {
//! always initialze input
@ -27,8 +27,8 @@ int32_t FSUtils::LoadFileToMem(const char *filepath, uint8_t **inbuffer, uint32_
}
uint32_t blocksize = 0x4000;
uint32_t done = 0;
int32_t readBytes = 0;
uint32_t done = 0;
int32_t readBytes = 0;
while (done < filesize) {
if (done + blocksize > filesize) {
@ -136,7 +136,7 @@ bool FSUtils::copyFile(const std::string &in, const std::string &out) {
size_t size;
int source = open(in.c_str(), O_RDONLY, 0);
int dest = open(out.c_str(), 0x602, 0644);
int dest = open(out.c_str(), 0x602, 0644);
if (source < 0) {
return false;
}
@ -146,7 +146,7 @@ bool FSUtils::copyFile(const std::string &in, const std::string &out) {
}
auto bufferSize = 1024 * 1024;
char *buf = (char *) malloc(bufferSize);
char *buf = (char *) malloc(bufferSize);
if (buf == NULL) {
return false;
}
@ -171,4 +171,3 @@ int32_t FSUtils::saveBufferToFile(const char *path, const void *buffer, uint32_t
file.close();
return written;
}

View File

@ -1,7 +1,7 @@
#pragma once
#include <wut_types.h>
#include <string>
#include <wut_types.h>
class FSUtils {
public:

View File

@ -0,0 +1,21 @@
#pragma once
#include "Input.h"
class CombinedInput : public Input {
public:
void combine(const Input &b) {
data.buttons_h |= b.data.buttons_h;
}
void process() {
data.buttons_d |= (data.buttons_h & (~lastData.buttons_h));
data.buttons_r |= (lastData.buttons_h & (~data.buttons_h));
lastData.buttons_h = data.buttons_h;
}
void reset() {
data.buttons_h = 0;
data.buttons_d = 0;
data.buttons_r = 0;
}
};

60
source/input/Input.h Normal file
View File

@ -0,0 +1,60 @@
#pragma once
#include <cstdint>
#include <cstring>
class Input {
public:
//!Constructor
Input() = default;
//!Destructor
virtual ~Input() = default;
enum eButtons {
BUTTON_NONE = 0x0000,
VPAD_TOUCH = 0x80000000,
BUTTON_Z = 0x20000,
BUTTON_C = 0x10000,
BUTTON_A = 0x8000,
BUTTON_B = 0x4000,
BUTTON_X = 0x2000,
BUTTON_Y = 0x1000,
BUTTON_1 = BUTTON_Y,
BUTTON_2 = BUTTON_X,
BUTTON_LEFT = 0x0800,
BUTTON_RIGHT = 0x0400,
BUTTON_UP = 0x0200,
BUTTON_DOWN = 0x0100,
BUTTON_ZL = 0x0080,
BUTTON_ZR = 0x0040,
BUTTON_L = 0x0020,
BUTTON_R = 0x0010,
BUTTON_PLUS = 0x0008,
BUTTON_MINUS = 0x0004,
BUTTON_HOME = 0x0002,
BUTTON_SYNC = 0x0001,
STICK_R_LEFT = 0x04000000,
STICK_R_RIGHT = 0x02000000,
STICK_R_UP = 0x01000000,
STICK_R_DOWN = 0x00800000,
STICK_L_LEFT = 0x40000000,
STICK_L_RIGHT = 0x20000000,
STICK_L_UP = 0x10000000,
STICK_L_DOWN = 0x08000000
};
typedef struct {
uint32_t buttons_h;
uint32_t buttons_d;
uint32_t buttons_r;
bool validPointer;
bool touched;
float pointerAngle;
int32_t x;
int32_t y;
} PadData;
PadData data{};
PadData lastData{};
};

View File

@ -1,58 +1,61 @@
#pragma once
/****************************************************************************
* Copyright (C) 2015 Dimok
*
* 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 <http://www.gnu.org/licenses/>.
****************************************************************************/
#include <vpad/input.h>
#include "Input.h"
class VPadInput : public Input {
public:
//!Constructor
VPadInput() {
}
//!Destructor
~VPadInput() override {}
bool update(int32_t width, int32_t height) {
lastData = data;
VPADReadError vpadError = VPAD_READ_NO_SAMPLES;
VPADRead(VPAD_CHAN_0, &vpad, 1, &vpadError);
if (vpadError == VPAD_READ_SUCCESS) {
data.buttons_r = vpad.release;
data.buttons_h = vpad.hold;
data.buttons_d = vpad.trigger;
data.validPointer = !vpad.tpNormal.validity;
data.touched = vpad.tpNormal.touched;
VPADGetTPCalibratedPoint(VPAD_CHAN_0, &tpCalib, &vpad.tpFiltered1);
//! calculate the screen offsets
data.x = -(width >> 1) + (int32_t) (((float) tpCalib.x / 1280.0f) * (float) width);
data.y = -(height >> 1) + (int32_t) (float) height - (((float) tpCalib.y / 720.0f) * (float) height);
return true;
}
return false;
}
private:
VPADStatus vpad{};
VPADTouchData tpCalib{};
#pragma once
/****************************************************************************
* Copyright (C) 2015 Dimok
*
* 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 <http://www.gnu.org/licenses/>.
****************************************************************************/
#include "Input.h"
#include <vpad/input.h>
class VPadInput : public Input {
public:
//!Constructor
VPadInput() {
memset(&vpad, 0, sizeof(vpad));
}
//!Destructor
~VPadInput() override = default;
bool update(int32_t width, int32_t height) {
lastData = data;
VPADReadError vpadError = VPAD_READ_NO_SAMPLES;
VPADRead(VPAD_CHAN_0, &vpad, 1, &vpadError);
if (vpadError == VPAD_READ_SUCCESS) {
data.buttons_r = vpad.release;
data.buttons_h = vpad.hold;
data.buttons_d = vpad.trigger;
data.validPointer = !vpad.tpNormal.validity;
data.touched = vpad.tpNormal.touched;
VPADGetTPCalibratedPoint(VPAD_CHAN_0, &tpCalib, &vpad.tpFiltered1);
//! calculate the screen offsets
data.x = -(width >> 1) + (int32_t) (((float) tpCalib.x / 1280.0f) * (float) width);
data.y = -(height >> 1) + (int32_t) (float) height - (((float) tpCalib.y / 720.0f) * (float) height);
return true;
} else {
data.buttons_h = 0;
}
return false;
}
private:
VPADStatus vpad{};
VPADTouchData tpCalib{};
};

View File

@ -16,9 +16,9 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
****************************************************************************/
#include "Input.h"
#include <padscore/kpad.h>
#include <padscore/wpad.h>
#include "Input.h"
class WPADInput : public Input {
public:
@ -31,43 +31,43 @@ public:
uint32_t remapWiiMoteButtons(uint32_t buttons) {
uint32_t conv_buttons = 0;
if(buttons & WPAD_BUTTON_LEFT)
if (buttons & WPAD_BUTTON_LEFT)
conv_buttons |= Input::BUTTON_LEFT;
if(buttons & WPAD_BUTTON_RIGHT)
if (buttons & WPAD_BUTTON_RIGHT)
conv_buttons |= Input::BUTTON_RIGHT;
if(buttons & WPAD_BUTTON_DOWN)
if (buttons & WPAD_BUTTON_DOWN)
conv_buttons |= Input::BUTTON_DOWN;
if(buttons & WPAD_BUTTON_UP)
if (buttons & WPAD_BUTTON_UP)
conv_buttons |= Input::BUTTON_UP;
if(buttons & WPAD_BUTTON_PLUS)
if (buttons & WPAD_BUTTON_PLUS)
conv_buttons |= Input::BUTTON_PLUS;
if(buttons & WPAD_BUTTON_2)
if (buttons & WPAD_BUTTON_2)
conv_buttons |= Input::BUTTON_2;
if(buttons & WPAD_BUTTON_1)
if (buttons & WPAD_BUTTON_1)
conv_buttons |= Input::BUTTON_1;
if(buttons & WPAD_BUTTON_B)
if (buttons & WPAD_BUTTON_B)
conv_buttons |= Input::BUTTON_B;
if(buttons & WPAD_BUTTON_A)
if (buttons & WPAD_BUTTON_A)
conv_buttons |= Input::BUTTON_A;
if(buttons & WPAD_BUTTON_MINUS)
if (buttons & WPAD_BUTTON_MINUS)
conv_buttons |= Input::BUTTON_MINUS;
if(buttons & WPAD_BUTTON_Z)
if (buttons & WPAD_BUTTON_Z)
conv_buttons |= Input::BUTTON_Z;
if(buttons & WPAD_BUTTON_C)
if (buttons & WPAD_BUTTON_C)
conv_buttons |= Input::BUTTON_C;
if(buttons & WPAD_BUTTON_HOME)
if (buttons & WPAD_BUTTON_HOME)
conv_buttons |= Input::BUTTON_HOME;
return conv_buttons;
@ -76,63 +76,65 @@ public:
uint32_t remapClassicButtons(uint32_t buttons) {
uint32_t conv_buttons = 0;
if(buttons & WPAD_CLASSIC_BUTTON_LEFT)
if (buttons & WPAD_CLASSIC_BUTTON_LEFT)
conv_buttons |= Input::BUTTON_LEFT;
if(buttons & WPAD_CLASSIC_BUTTON_RIGHT)
if (buttons & WPAD_CLASSIC_BUTTON_RIGHT)
conv_buttons |= Input::BUTTON_RIGHT;
if(buttons & WPAD_CLASSIC_BUTTON_DOWN)
if (buttons & WPAD_CLASSIC_BUTTON_DOWN)
conv_buttons |= Input::BUTTON_DOWN;
if(buttons & WPAD_CLASSIC_BUTTON_UP)
if (buttons & WPAD_CLASSIC_BUTTON_UP)
conv_buttons |= Input::BUTTON_UP;
if(buttons & WPAD_CLASSIC_BUTTON_PLUS)
if (buttons & WPAD_CLASSIC_BUTTON_PLUS)
conv_buttons |= Input::BUTTON_PLUS;
if(buttons & WPAD_CLASSIC_BUTTON_X)
if (buttons & WPAD_CLASSIC_BUTTON_X)
conv_buttons |= Input::BUTTON_X;
if(buttons & WPAD_CLASSIC_BUTTON_Y)
if (buttons & WPAD_CLASSIC_BUTTON_Y)
conv_buttons |= Input::BUTTON_Y;
if(buttons & WPAD_CLASSIC_BUTTON_B)
if (buttons & WPAD_CLASSIC_BUTTON_B)
conv_buttons |= Input::BUTTON_B;
if(buttons & WPAD_CLASSIC_BUTTON_A)
if (buttons & WPAD_CLASSIC_BUTTON_A)
conv_buttons |= Input::BUTTON_A;
if(buttons & WPAD_CLASSIC_BUTTON_MINUS)
if (buttons & WPAD_CLASSIC_BUTTON_MINUS)
conv_buttons |= Input::BUTTON_MINUS;
if(buttons & WPAD_CLASSIC_BUTTON_HOME)
if (buttons & WPAD_CLASSIC_BUTTON_HOME)
conv_buttons |= Input::BUTTON_HOME;
if(buttons & WPAD_CLASSIC_BUTTON_ZR)
if (buttons & WPAD_CLASSIC_BUTTON_ZR)
conv_buttons |= Input::BUTTON_ZR;
if(buttons & WPAD_CLASSIC_BUTTON_ZL)
if (buttons & WPAD_CLASSIC_BUTTON_ZL)
conv_buttons |= Input::BUTTON_ZL;
if(buttons & WPAD_CLASSIC_BUTTON_R)
if (buttons & WPAD_CLASSIC_BUTTON_R)
conv_buttons |= Input::BUTTON_R;
if(buttons & WPAD_CLASSIC_BUTTON_L)
if (buttons & WPAD_CLASSIC_BUTTON_L)
conv_buttons |= Input::BUTTON_L;
return conv_buttons;
}
bool update(int32_t width, int32_t height) {
lastData = data;
WPADExtensionType type;
if (WPADProbe(channel, &type) != 0) {
data.buttons_h = 0;
return false;
}
KPADRead(channel, &kpad, 1);
if(kpad.extensionType == WPAD_EXT_CORE || kpad.extensionType == WPAD_EXT_NUNCHUK) {
if (kpad.extensionType == WPAD_EXT_CORE || kpad.extensionType == WPAD_EXT_NUNCHUK) {
data.buttons_r = remapWiiMoteButtons(kpad.release);
data.buttons_h = remapWiiMoteButtons(kpad.hold);
data.buttons_d = remapWiiMoteButtons(kpad.trigger);
@ -147,11 +149,11 @@ public:
(kpad.pos.y >= -1.0f && kpad.pos.y <= 1.0f);
//! calculate the screen offsets if pointer is valid else leave old value
if(data.validPointer) {
if (data.validPointer) {
data.x = (width >> 1) * kpad.pos.x;
data.y = (height >> 1) * (-kpad.pos.y);
if(kpad.angle.y > 0.0f) {
if (kpad.angle.y > 0.0f) {
data.pointerAngle = (-kpad.angle.x + 1.0f) * 0.5f * 180.0f;
} else {
data.pointerAngle = (kpad.angle.x + 1.0f) * 0.5f * 180.0f - 180.0f;

View File

@ -1,42 +1,44 @@
#include <coreinit/debug.h>
#include <whb/proc.h>
#include <whb/log.h>
#include <whb/log_udp.h>
#include <whb/proc.h>
#include "InstallerService.h"
#include "utils/WiiUScreen.h"
#include <input/CombinedInput.h>
#include <input/VPADInput.h>
#include <input/WPADInput.h>
#include <iosuhax.h>
#include <iosuhax_devoptab.h>
#include <string_view>
#include "WiiUScreen.h"
#include "InstallerService.h"
#include "ApplicationState.h"
#include "WPADInput.h"
#include "../build/safe_payload.h"
#include "ApplicationState.h"
constexpr bool strings_equal(char const *a, char const *b) {
return std::string_view(a) == b;
}
static_assert(strings_equal(RPX_HASH, "cd4c1459d793a600d12afa33425f43be0cc5dfa3"), "Built with an untested root.rpx! Remove this check if you really know what you're doing.");
static_assert(strings_equal(RPX_HASH, "1736574cf6c949557aed0c817eb1927e35a9b820"), "Built with an untested root.rpx! Remove this check if you really know what you're doing.");
void initIOSUHax();
void deInitIOSUHax();
int sFSAFd = -1;
int sFSAFd = -1;
bool sIosuhaxMount = false;
int main_loop() {
DEBUG_FUNCTION_LINE("Creating state");
ApplicationState state;
CombinedInput baseInput;
VPadInput vpadInput;
WPADInput wpadInputs[4] = {
WPAD_CHAN_0,
WPAD_CHAN_1,
WPAD_CHAN_2,
WPAD_CHAN_3
};
WPAD_CHAN_0,
WPAD_CHAN_1,
WPAD_CHAN_2,
WPAD_CHAN_3};
if (sFSAFd < 0 || !sIosuhaxMount) {
state.setError(ApplicationState::eErrorState::ERROR_IOSUHAX_FAILED);
@ -44,12 +46,17 @@ int main_loop() {
DEBUG_FUNCTION_LINE("Entering main loop");
while (WHBProcIsRunning()) {
vpadInput.update(1280, 720);
for (int i = 0; i < 4; i++) {
wpadInputs[i].update(1280, 720);
vpadInput.combine(wpadInputs[i]);
baseInput.reset();
if (vpadInput.update(1280, 720)) {
baseInput.combine(vpadInput);
}
state.update(&vpadInput);
for (auto &wpadInput : wpadInputs) {
if (wpadInput.update(1280, 720)) {
baseInput.combine(wpadInput);
}
}
baseInput.process();
state.update(&baseInput);
state.render();
}
@ -58,7 +65,7 @@ int main_loop() {
int main(int argc, char **argv) {
WHBLogUdpInit();
DEBUG_FUNCTION_LINE("Hello from Aroma Installer!");
DEBUG_FUNCTION_LINE("Hello from Payload-Loader Installer!");
WHBProcInit();
WiiUScreen::Init();
@ -80,13 +87,13 @@ int main(int argc, char **argv) {
void initIOSUHax() {
sIosuhaxMount = false;
int res = IOSUHAX_Open(nullptr);
int res = IOSUHAX_Open(nullptr);
if (res < 0) {
DEBUG_FUNCTION_LINE("IOSUHAX_open failed");
OSFatal("IOSUHAX_open failed, please start this installer with an CFW");
} else {
sIosuhaxMount = true;
sFSAFd = IOSUHAX_FSA_Open();
sFSAFd = IOSUHAX_FSA_Open();
if (sFSAFd < 0) {
DEBUG_FUNCTION_LINE("IOSUHAX_FSA_Open failed");
} else {

View File

@ -1,48 +1,49 @@
/****************************************************************************
* Copyright (C) 2018 Maschell
*
* 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 <http://www.gnu.org/licenses/>.
****************************************************************************/
#include <coreinit/screen.h>
#include "ScreenUtils.h"
void ScreenUtils::printTextOnScreen(ConsoleScreenID screen, int x, int y, const char *msg) {
if (!msg) {
return;
}
if (screen != CONSOLE_SCREEN_DRC) { // Draw TV if it's not DRC exclusive.
OSScreenPutFontEx(SCREEN_TV, x, y, msg);
}
if (screen != CONSOLE_SCREEN_TV) { // Draw DRC if it's not TV exclusive.
OSScreenPutFontEx(SCREEN_DRC, x, y, msg);
}
}
void ScreenUtils::OSScreenClear(ConsoleScreenID screen, uint32_t color) {
if (screen != CONSOLE_SCREEN_DRC) { // Clear TV if it's not DRC exclusive.
OSScreenClearBufferEx(SCREEN_TV, color);
}
if (screen != CONSOLE_SCREEN_TV) { // Clear DRC if it's not TV exclusive.
OSScreenClearBufferEx(SCREEN_DRC, color);
}
}
void ScreenUtils::flipBuffers(ConsoleScreenID screen) {
if (screen != CONSOLE_SCREEN_DRC) { // Flip TV buffer if it's not DRC exclusive.
OSScreenFlipBuffersEx(SCREEN_TV);
}
if (screen != CONSOLE_SCREEN_TV) { // Flip DRC buffer if it's not TV exclusive.
OSScreenFlipBuffersEx(SCREEN_DRC);
}
}
/****************************************************************************
* Copyright (C) 2018 Maschell
*
* 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 <http://www.gnu.org/licenses/>.
****************************************************************************/
#include "ScreenUtils.h"
#include <coreinit/screen.h>
#include <stdint.h>
void ScreenUtils::printTextOnScreen(ConsoleScreenID screen, int x, int y, const char *msg) {
if (!msg) {
return;
}
if (screen != CONSOLE_SCREEN_DRC) { // Draw TV if it's not DRC exclusive.
OSScreenPutFontEx(SCREEN_TV, x, y, msg);
}
if (screen != CONSOLE_SCREEN_TV) { // Draw DRC if it's not TV exclusive.
OSScreenPutFontEx(SCREEN_DRC, x, y, msg);
}
}
void ScreenUtils::OSScreenClear(ConsoleScreenID screen, uint32_t color) {
if (screen != CONSOLE_SCREEN_DRC) { // Clear TV if it's not DRC exclusive.
OSScreenClearBufferEx(SCREEN_TV, color);
}
if (screen != CONSOLE_SCREEN_TV) { // Clear DRC if it's not TV exclusive.
OSScreenClearBufferEx(SCREEN_DRC, color);
}
}
void ScreenUtils::flipBuffers(ConsoleScreenID screen) {
if (screen != CONSOLE_SCREEN_DRC) { // Flip TV buffer if it's not DRC exclusive.
OSScreenFlipBuffersEx(SCREEN_TV);
}
if (screen != CONSOLE_SCREEN_TV) { // Flip DRC buffer if it's not TV exclusive.
OSScreenFlipBuffersEx(SCREEN_DRC);
}
}

View File

@ -1,55 +1,57 @@
/****************************************************************************
* Copyright (C) 2018-2020 Maschell
*
* 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 <http://www.gnu.org/licenses/>.
****************************************************************************/
#pragma once
//! Defines the ID of a display usable with OSScreen.
typedef enum ConsoleScreenID {
//! Represents the TV connected to the system.
CONSOLE_SCREEN_TV = 0,
//! Represents the screen in the DRC (gamepad).
CONSOLE_SCREEN_DRC = 1,
//! Represents both screens
CONSOLE_SCREEN_BOTH = 2,
} ConsoleScreenID;
class ScreenUtils {
public:
/**
Clears the screen for the given screens
\param screen defines on which screens should be printed
\param x defines the x position (character position) where the text should be printed
\param y defines on which line the text should be printed
\param msg C string that contains the text to be printed.
**/
static void printTextOnScreen(ConsoleScreenID screen, int x, int y, const char *msg);
/**
Clears the screen for the given screens
\param screen defines which screens should be cleared
**/
static void OSScreenClear(ConsoleScreenID screen, uint32_t i);
/**
Flips the buffer for the given screens
\param screen defines which screens should be flipped.
**/
static void flipBuffers(ConsoleScreenID screen);
private:
ScreenUtils() = default;
~ScreenUtils() = default;
/****************************************************************************
* Copyright (C) 2018-2020 Maschell
*
* 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 <http://www.gnu.org/licenses/>.
****************************************************************************/
#pragma once
#include <stdint.h>
//! Defines the ID of a display usable with OSScreen.
typedef enum ConsoleScreenID {
//! Represents the TV connected to the system.
CONSOLE_SCREEN_TV = 0,
//! Represents the screen in the DRC (gamepad).
CONSOLE_SCREEN_DRC = 1,
//! Represents both screens
CONSOLE_SCREEN_BOTH = 2,
} ConsoleScreenID;
class ScreenUtils {
public:
/**
Clears the screen for the given screens
\param screen defines on which screens should be printed
\param x defines the x position (character position) where the text should be printed
\param y defines on which line the text should be printed
\param msg C string that contains the text to be printed.
**/
static void printTextOnScreen(ConsoleScreenID screen, int x, int y, const char *msg);
/**
Clears the screen for the given screens
\param screen defines which screens should be cleared
**/
static void OSScreenClear(ConsoleScreenID screen, uint32_t i);
/**
Flips the buffer for the given screens
\param screen defines which screens should be flipped.
**/
static void flipBuffers(ConsoleScreenID screen);
private:
ScreenUtils() = default;
~ScreenUtils() = default;
};

View File

@ -23,17 +23,16 @@
*
* for WiiXplorer 2010
***************************************************************************/
#include <vector>
#include <string>
#include <string.h>
#include <stdarg.h>
#include <stdlib.h>
#include <stdio.h>
#include <wchar.h>
#include <strings.h>
#include <wut_types.h>
#include <stdio.h>
#include "StringTools.h"
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <strings.h>
#include <vector>
#include <wchar.h>
#include <wut_types.h>
BOOL StringTools::EndsWith(const std::string &a, const std::string &b) {
@ -85,7 +84,7 @@ const wchar_t *StringTools::wfmt(const char *format, ...) {
static char tmp[512];
static wchar_t strWChar[512];
strWChar[0] = 0;
tmp[0] = 0;
tmp[0] = 0;
if (!format)
return (const wchar_t *) strWChar;
@ -98,7 +97,7 @@ const wchar_t *StringTools::wfmt(const char *format, ...) {
if ((vsprintf(tmp, format, va) >= 0)) {
int32_t bt;
int32_t strlength = strlen(tmp);
bt = mbstowcs(strWChar, tmp, (strlength < 512) ? strlength : 512);
bt = mbstowcs(strWChar, tmp, (strlength < 512) ? strlength : 512);
if (bt > 0) {
strWChar[bt] = 0;
@ -112,13 +111,13 @@ const wchar_t *StringTools::wfmt(const char *format, ...) {
int32_t StringTools::strprintf(std::string &str, const char *format, ...) {
static char tmp[512];
tmp[0] = 0;
tmp[0] = 0;
int32_t result = 0;
va_list va;
va_start(va, format);
if ((vsprintf(tmp, format, va) >= 0)) {
str = tmp;
str = tmp;
result = str.size();
}
va_end(va);
@ -214,8 +213,7 @@ bool StringTools::findStringIC(const std::string &strHaystack, const std::string
auto it = std::search(
strHaystack.begin(), strHaystack.end(),
strNeedle.begin(), strNeedle.end(),
[](char ch1, char ch2) { return std::toupper(ch1) == std::toupper(ch2); }
);
[](char ch1, char ch2) { return std::toupper(ch1) == std::toupper(ch2); });
return (it != strHaystack.end());
}

View File

@ -25,11 +25,11 @@
***************************************************************************/
#pragma once
#include <vector>
#include <string>
#include <wut_types.h>
#include <algorithm>
#include <cctype>
#include <string>
#include <vector>
#include <wut_types.h>
class StringTools {
public:
@ -57,7 +57,7 @@ public:
if (!path)
return path;
const char *ptr = path;
const char *ptr = path;
const char *Filename = ptr;
while (*ptr != '\0') {
@ -89,7 +89,7 @@ public:
static bool findStringIC(const std::string &strHaystack, const std::string &strNeedle);
// https://stackoverflow.com/a/3418285
static bool replace(std::string& str, const std::string& from, const std::string& to);
static bool replace(std::string &str, const std::string &from, const std::string &to);
static bool strCompareIC(const std::string &str1, const std::string &str2);
};

View File

@ -1,3 +1,4 @@
// clang-format off
/*
*
* TinySHA1 - a header only implementation of the SHA1 algorithm in C++. Based
@ -21,176 +22,188 @@
*/
#ifndef _TINY_SHA1_HPP_
#define _TINY_SHA1_HPP_
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <stdint.h>
namespace sha1
{
class SHA1
{
public:
typedef uint32_t digest32_t[5];
typedef uint8_t digest8_t[20];
inline static uint32_t LeftRotate(uint32_t value, size_t count) {
return (value << count) ^ (value >> (32-count));
}
SHA1(){ reset(); }
virtual ~SHA1() {}
SHA1(const SHA1& s) { *this = s; }
const SHA1& operator = (const SHA1& s) {
memcpy(m_digest, s.m_digest, 5 * sizeof(uint32_t));
memcpy(m_block, s.m_block, 64);
m_blockByteIndex = s.m_blockByteIndex;
m_byteCount = s.m_byteCount;
return *this;
}
SHA1& reset() {
m_digest[0] = 0x67452301;
m_digest[1] = 0xEFCDAB89;
m_digest[2] = 0x98BADCFE;
m_digest[3] = 0x10325476;
m_digest[4] = 0xC3D2E1F0;
m_blockByteIndex = 0;
m_byteCount = 0;
return *this;
}
SHA1& processByte(uint8_t octet) {
this->m_block[this->m_blockByteIndex++] = octet;
++this->m_byteCount;
if(m_blockByteIndex == 64) {
this->m_blockByteIndex = 0;
processBlock();
}
return *this;
}
SHA1& processBlock(const void* const start, const void* const end) {
const uint8_t* begin = static_cast<const uint8_t*>(start);
const uint8_t* finish = static_cast<const uint8_t*>(end);
while(begin != finish) {
processByte(*begin);
begin++;
}
return *this;
}
SHA1& processBytes(const void* const data, size_t len) {
const uint8_t* block = static_cast<const uint8_t*>(data);
processBlock(block, block + len);
return *this;
}
const uint32_t* getDigest(digest32_t digest) {
size_t bitCount = this->m_byteCount * 8;
processByte(0x80);
if (this->m_blockByteIndex > 56) {
while (m_blockByteIndex != 0) {
processByte(0);
}
while (m_blockByteIndex < 56) {
processByte(0);
}
} else {
while (m_blockByteIndex < 56) {
processByte(0);
}
}
processByte(0);
processByte(0);
processByte(0);
processByte(0);
processByte( static_cast<unsigned char>((bitCount>>24) & 0xFF));
processByte( static_cast<unsigned char>((bitCount>>16) & 0xFF));
processByte( static_cast<unsigned char>((bitCount>>8 ) & 0xFF));
processByte( static_cast<unsigned char>((bitCount) & 0xFF));
memcpy(digest, m_digest, 5 * sizeof(uint32_t));
return digest;
}
const uint8_t* getDigestBytes(digest8_t digest) {
digest32_t d32;
getDigest(d32);
size_t di = 0;
digest[di++] = ((d32[0] >> 24) & 0xFF);
digest[di++] = ((d32[0] >> 16) & 0xFF);
digest[di++] = ((d32[0] >> 8) & 0xFF);
digest[di++] = ((d32[0]) & 0xFF);
digest[di++] = ((d32[1] >> 24) & 0xFF);
digest[di++] = ((d32[1] >> 16) & 0xFF);
digest[di++] = ((d32[1] >> 8) & 0xFF);
digest[di++] = ((d32[1]) & 0xFF);
digest[di++] = ((d32[2] >> 24) & 0xFF);
digest[di++] = ((d32[2] >> 16) & 0xFF);
digest[di++] = ((d32[2] >> 8) & 0xFF);
digest[di++] = ((d32[2]) & 0xFF);
digest[di++] = ((d32[3] >> 24) & 0xFF);
digest[di++] = ((d32[3] >> 16) & 0xFF);
digest[di++] = ((d32[3] >> 8) & 0xFF);
digest[di++] = ((d32[3]) & 0xFF);
digest[di++] = ((d32[4] >> 24) & 0xFF);
digest[di++] = ((d32[4] >> 16) & 0xFF);
digest[di++] = ((d32[4] >> 8) & 0xFF);
digest[di++] = ((d32[4]) & 0xFF);
return digest;
}
protected:
void processBlock() {
uint32_t w[80];
for (size_t i = 0; i < 16; i++) {
w[i] = (m_block[i*4 + 0] << 24);
w[i] |= (m_block[i*4 + 1] << 16);
w[i] |= (m_block[i*4 + 2] << 8);
w[i] |= (m_block[i*4 + 3]);
}
for (size_t i = 16; i < 80; i++) {
w[i] = LeftRotate((w[i-3] ^ w[i-8] ^ w[i-14] ^ w[i-16]), 1);
}
uint32_t a = m_digest[0];
uint32_t b = m_digest[1];
uint32_t c = m_digest[2];
uint32_t d = m_digest[3];
uint32_t e = m_digest[4];
for (std::size_t i=0; i<80; ++i) {
uint32_t f = 0;
uint32_t k = 0;
if (i<20) {
f = (b & c) | (~b & d);
k = 0x5A827999;
} else if (i<40) {
f = b ^ c ^ d;
k = 0x6ED9EBA1;
} else if (i<60) {
f = (b & c) | (b & d) | (c & d);
k = 0x8F1BBCDC;
} else {
f = b ^ c ^ d;
k = 0xCA62C1D6;
}
uint32_t temp = LeftRotate(a, 5) + f + e + k + w[i];
e = d;
d = c;
c = LeftRotate(b, 30);
b = a;
a = temp;
}
m_digest[0] += a;
m_digest[1] += b;
m_digest[2] += c;
m_digest[3] += d;
m_digest[4] += e;
}
private:
digest32_t m_digest;
uint8_t m_block[64];
size_t m_blockByteIndex;
size_t m_byteCount;
};
namespace sha1 {
class SHA1 {
public:
typedef uint32_t digest32_t[5];
typedef uint8_t digest8_t[20];
inline static uint32_t LeftRotate(uint32_t value, size_t count) {
return (value << count) ^ (value >> (32 - count));
}
SHA1() { reset(); }
virtual ~SHA1() {}
SHA1(const SHA1 &s) { *this = s; }
const SHA1 &operator=(const SHA1 &s) {
memcpy(m_digest, s.m_digest, 5 * sizeof(uint32_t));
memcpy(m_block, s.m_block, 64);
m_blockByteIndex = s.m_blockByteIndex;
m_byteCount = s.m_byteCount;
return *this;
}
SHA1 &reset() {
m_digest[0] = 0x67452301;
m_digest[1] = 0xEFCDAB89;
m_digest[2] = 0x98BADCFE;
m_digest[3] = 0x10325476;
m_digest[4] = 0xC3D2E1F0;
m_blockByteIndex = 0;
m_byteCount = 0;
return *this;
}
SHA1 &processByte(uint8_t octet) {
this->m_block[this->m_blockByteIndex++] = octet;
++this->m_byteCount;
if (m_blockByteIndex == 64) {
this->m_blockByteIndex = 0;
processBlock();
}
return *this;
}
SHA1 &processBlock(const void *const start, const void *const end) {
const uint8_t *begin = static_cast<const uint8_t *>(start);
const uint8_t *finish = static_cast<const uint8_t *>(end);
while (begin != finish) {
processByte(*begin);
begin++;
}
return *this;
}
SHA1 &processBytes(const void *const data, size_t len) {
const uint8_t *block = static_cast<const uint8_t *>(data);
processBlock(block, block + len);
return *this;
}
const uint32_t *getDigest(digest32_t digest) {
size_t bitCount = this->m_byteCount * 8;
processByte(0x80);
if (this->m_blockByteIndex > 56) {
while (m_blockByteIndex != 0) {
processByte(0);
}
while (m_blockByteIndex < 56) {
processByte(0);
}
} else {
while (m_blockByteIndex < 56) {
processByte(0);
}
}
processByte(0);
processByte(0);
processByte(0);
processByte(0);
processByte(static_cast<unsigned char>((bitCount >> 24) & 0xFF));
processByte(static_cast<unsigned char>((bitCount >> 16) & 0xFF));
processByte(static_cast<unsigned char>((bitCount >> 8) & 0xFF));
processByte(static_cast<unsigned char>((bitCount) & 0xFF));
memcpy(digest, m_digest, 5 * sizeof(uint32_t));
return digest;
}
const uint8_t *getDigestBytes(digest8_t digest) {
digest32_t d32;
getDigest(d32);
size_t di = 0;
digest[di++] = ((d32[0] >> 24) & 0xFF);
digest[di++] = ((d32[0] >> 16) & 0xFF);
digest[di++] = ((d32[0] >> 8) & 0xFF);
digest[di++] = ((d32[0]) & 0xFF);
digest[di++] = ((d32[1] >> 24) & 0xFF);
digest[di++] = ((d32[1] >> 16) & 0xFF);
digest[di++] = ((d32[1] >> 8) & 0xFF);
digest[di++] = ((d32[1]) & 0xFF);
digest[di++] = ((d32[2] >> 24) & 0xFF);
digest[di++] = ((d32[2] >> 16) & 0xFF);
digest[di++] = ((d32[2] >> 8) & 0xFF);
digest[di++] = ((d32[2]) & 0xFF);
digest[di++] = ((d32[3] >> 24) & 0xFF);
digest[di++] = ((d32[3] >> 16) & 0xFF);
digest[di++] = ((d32[3] >> 8) & 0xFF);
digest[di++] = ((d32[3]) & 0xFF);
digest[di++] = ((d32[4] >> 24) & 0xFF);
digest[di++] = ((d32[4] >> 16) & 0xFF);
digest[di++] = ((d32[4] >> 8) & 0xFF);
digest[di++] = ((d32[4]) & 0xFF);
return digest;
}
protected:
void processBlock() {
uint32_t w[80];
for (size_t i = 0; i < 16; i++) {
w[i] = (m_block[i * 4 + 0] << 24);
w[i] |= (m_block[i * 4 + 1] << 16);
w[i] |= (m_block[i * 4 + 2] << 8);
w[i] |= (m_block[i * 4 + 3]);
}
for (size_t i = 16; i < 80; i++) {
w[i] = LeftRotate((w[i - 3] ^ w[i - 8] ^ w[i - 14] ^ w[i - 16]), 1);
}
uint32_t a = m_digest[0];
uint32_t b = m_digest[1];
uint32_t c = m_digest[2];
uint32_t d = m_digest[3];
uint32_t e = m_digest[4];
for (std::size_t i = 0; i < 80; ++i) {
uint32_t f = 0;
uint32_t k = 0;
if (i < 20) {
f = (b & c) | (~b & d);
k = 0x5A827999;
} else if (i < 40) {
f = b ^ c ^ d;
k = 0x6ED9EBA1;
} else if (i < 60) {
f = (b & c) | (b & d) | (c & d);
k = 0x8F1BBCDC;
} else {
f = b ^ c ^ d;
k = 0xCA62C1D6;
}
uint32_t temp = LeftRotate(a, 5) + f + e + k + w[i];
e = d;
d = c;
c = LeftRotate(b, 30);
b = a;
a = temp;
}
m_digest[0] += a;
m_digest[1] += b;
m_digest[2] += c;
m_digest[3] += d;
m_digest[4] += e;
}
private:
digest32_t m_digest;
uint8_t m_block[64];
size_t m_blockByteIndex;
size_t m_byteCount;
};
}
#endif

View File

@ -1,93 +1,93 @@
#include "WiiUScreen.h"
#include "ScreenUtils.h"
#include <coreinit/memdefaultheap.h>
#include <cstdarg>
#include <cstdio>
void *WiiUScreen::sBufferTV = nullptr;
void *WiiUScreen::sBufferDRC = nullptr;
uint32_t WiiUScreen::sBufferSizeTV = 0;
uint32_t WiiUScreen::sBufferSizeDRC = 0;
bool WiiUScreen::sConsoleHasForeground = true;
uint32_t WiiUScreen::consoleColor = 0x041F60FF;
uint32_t WiiUScreen::consoleCursorY = 0;
uint32_t WiiUScreen::ProcCallbackAcquired(void *context) {
MEMHeapHandle heap = MEMGetBaseHeapHandle(MEM_BASE_HEAP_MEM1);
if (sBufferSizeTV) {
sBufferTV = MEMAllocFromFrmHeapEx(heap, sBufferSizeTV, 4);
}
if (sBufferSizeDRC) {
sBufferDRC = MEMAllocFromFrmHeapEx(heap, sBufferSizeDRC, 4);
}
sConsoleHasForeground = true;
OSScreenSetBufferEx(SCREEN_TV, sBufferTV);
OSScreenSetBufferEx(SCREEN_DRC, sBufferDRC);
return 0;
}
uint32_t WiiUScreen::ProcCallbackReleased(void *context) {
MEMHeapHandle heap = MEMGetBaseHeapHandle(MEM_BASE_HEAP_MEM1);
MEMFreeByStateToFrmHeap(heap, CONSOLE_FRAME_HEAP_TAG);
sConsoleHasForeground = FALSE;
return 0;
}
bool WiiUScreen::Init() {
OSScreenInit();
sBufferSizeTV = OSScreenGetBufferSizeEx(SCREEN_TV);
sBufferSizeDRC = OSScreenGetBufferSizeEx(SCREEN_DRC);
WiiUScreen::ProcCallbackAcquired(nullptr);
OSScreenEnableEx(SCREEN_TV, 1);
OSScreenEnableEx(SCREEN_DRC, 1);
ScreenUtils::OSScreenClear(CONSOLE_SCREEN_BOTH, WiiUScreen::consoleColor);
ProcUIRegisterCallback(PROCUI_CALLBACK_ACQUIRE, WiiUScreen::ProcCallbackAcquired, nullptr, 100);
ProcUIRegisterCallback(PROCUI_CALLBACK_RELEASE, WiiUScreen::ProcCallbackReleased, nullptr, 100);
return true;
}
void WiiUScreen::DeInit() {
if (sConsoleHasForeground) {
OSScreenShutdown();
WiiUScreen::ProcCallbackReleased(nullptr);
}
}
void WiiUScreen::drawLinef(const char *fmt, ...) {
char *buf = (char *) MEMAllocFromDefaultHeapEx(PRINTF_BUFFER_LENGTH, 4);
va_list va;
if (!buf) {
return;
}
va_start(va, fmt);
vsnprintf(buf, PRINTF_BUFFER_LENGTH, fmt, va);
WiiUScreen::drawLine(buf);
MEMFreeToDefaultHeap(buf);
va_end(va);
}
void WiiUScreen::drawLine() {
WiiUScreen::drawLine("");
}
void WiiUScreen::drawLine(const char *msg) {
ScreenUtils::printTextOnScreen(CONSOLE_SCREEN_BOTH, 0, consoleCursorY++, msg);
}
void WiiUScreen::flipBuffers() {
ScreenUtils::flipBuffers(CONSOLE_SCREEN_BOTH);
}
void WiiUScreen::clearScreen() {
ScreenUtils::OSScreenClear(CONSOLE_SCREEN_BOTH, WiiUScreen::consoleColor);
consoleCursorY = 0;
}
#include "WiiUScreen.h"
#include "ScreenUtils.h"
#include <coreinit/memdefaultheap.h>
#include <cstdarg>
#include <cstdio>
void *WiiUScreen::sBufferTV = nullptr;
void *WiiUScreen::sBufferDRC = nullptr;
uint32_t WiiUScreen::sBufferSizeTV = 0;
uint32_t WiiUScreen::sBufferSizeDRC = 0;
bool WiiUScreen::sConsoleHasForeground = true;
uint32_t WiiUScreen::consoleColor = 0x041F60FF;
uint32_t WiiUScreen::consoleCursorY = 0;
uint32_t WiiUScreen::ProcCallbackAcquired(void *context) {
MEMHeapHandle heap = MEMGetBaseHeapHandle(MEM_BASE_HEAP_MEM1);
if (sBufferSizeTV) {
sBufferTV = MEMAllocFromFrmHeapEx(heap, sBufferSizeTV, 4);
}
if (sBufferSizeDRC) {
sBufferDRC = MEMAllocFromFrmHeapEx(heap, sBufferSizeDRC, 4);
}
sConsoleHasForeground = true;
OSScreenSetBufferEx(SCREEN_TV, sBufferTV);
OSScreenSetBufferEx(SCREEN_DRC, sBufferDRC);
return 0;
}
uint32_t WiiUScreen::ProcCallbackReleased(void *context) {
MEMHeapHandle heap = MEMGetBaseHeapHandle(MEM_BASE_HEAP_MEM1);
MEMFreeByStateToFrmHeap(heap, CONSOLE_FRAME_HEAP_TAG);
sConsoleHasForeground = FALSE;
return 0;
}
bool WiiUScreen::Init() {
OSScreenInit();
sBufferSizeTV = OSScreenGetBufferSizeEx(SCREEN_TV);
sBufferSizeDRC = OSScreenGetBufferSizeEx(SCREEN_DRC);
WiiUScreen::ProcCallbackAcquired(nullptr);
OSScreenEnableEx(SCREEN_TV, 1);
OSScreenEnableEx(SCREEN_DRC, 1);
ScreenUtils::OSScreenClear(CONSOLE_SCREEN_BOTH, WiiUScreen::consoleColor);
ProcUIRegisterCallback(PROCUI_CALLBACK_ACQUIRE, WiiUScreen::ProcCallbackAcquired, nullptr, 100);
ProcUIRegisterCallback(PROCUI_CALLBACK_RELEASE, WiiUScreen::ProcCallbackReleased, nullptr, 100);
return true;
}
void WiiUScreen::DeInit() {
if (sConsoleHasForeground) {
OSScreenShutdown();
WiiUScreen::ProcCallbackReleased(nullptr);
}
}
void WiiUScreen::drawLinef(const char *fmt, ...) {
char *buf = (char *) MEMAllocFromDefaultHeapEx(PRINTF_BUFFER_LENGTH, 4);
va_list va;
if (!buf) {
return;
}
va_start(va, fmt);
vsnprintf(buf, PRINTF_BUFFER_LENGTH, fmt, va);
WiiUScreen::drawLine(buf);
MEMFreeToDefaultHeap(buf);
va_end(va);
}
void WiiUScreen::drawLine() {
WiiUScreen::drawLine("");
}
void WiiUScreen::drawLine(const char *msg) {
ScreenUtils::printTextOnScreen(CONSOLE_SCREEN_BOTH, 0, consoleCursorY++, msg);
}
void WiiUScreen::flipBuffers() {
ScreenUtils::flipBuffers(CONSOLE_SCREEN_BOTH);
}
void WiiUScreen::clearScreen() {
ScreenUtils::OSScreenClear(CONSOLE_SCREEN_BOTH, WiiUScreen::consoleColor);
consoleCursorY = 0;
}

View File

@ -1,53 +1,54 @@
#pragma once
#include <whb/log.h>
#include <whb/log_console.h>
#include <coreinit/memheap.h>
#include <coreinit/cache.h>
#include <coreinit/memfrmheap.h>
#include <coreinit/memory.h>
#include <coreinit/screen.h>
#include <proc_ui/procui.h>
#include <cstring>
#include "utils/logger.h"
#define NUM_LINES (16)
#define LINE_LENGTH (128)
#define CONSOLE_FRAME_HEAP_TAG (0x000DECAF)
#define PRINTF_BUFFER_LENGTH 2048
#define DEBUG_CONSOLE_LOG(FMT, ARGS...)do { \
DEBUG_FUNCTION_LINE(FMT, ## ARGS); \
WiiUScreen::drawLinef(FMT, ## ARGS); \
} while (0)
class WiiUScreen {
public:
static uint32_t ProcCallbackAcquired(void *context);
static uint32_t ProcCallbackReleased(void *context);
static bool Init();
static void DeInit();
static void drawLinef(const char *fmt, ...);
static void drawLine(const char *fmt);
static void drawLine();
static void flipBuffers();
static void clearScreen();
private:
static void *sBufferTV, *sBufferDRC;
static uint32_t sBufferSizeTV, sBufferSizeDRC;
static bool sConsoleHasForeground;
static uint32_t consoleColor;
static uint32_t consoleCursorY;
#pragma once
#include <whb/log.h>
#include <whb/log_console.h>
#include "logger.h"
#include <coreinit/cache.h>
#include <coreinit/memfrmheap.h>
#include <coreinit/memheap.h>
#include <coreinit/memory.h>
#include <coreinit/screen.h>
#include <cstring>
#include <proc_ui/procui.h>
#define NUM_LINES (16)
#define LINE_LENGTH (128)
#define CONSOLE_FRAME_HEAP_TAG (0x000DECAF)
#define PRINTF_BUFFER_LENGTH 2048
#define DEBUG_CONSOLE_LOG(FMT, ARGS...) \
do { \
DEBUG_FUNCTION_LINE(FMT, ##ARGS); \
WiiUScreen::drawLinef(FMT, ##ARGS); \
} while (0)
class WiiUScreen {
public:
static uint32_t ProcCallbackAcquired(void *context);
static uint32_t ProcCallbackReleased(void *context);
static bool Init();
static void DeInit();
static void drawLinef(const char *fmt, ...);
static void drawLine(const char *fmt);
static void drawLine();
static void flipBuffers();
static void clearScreen();
private:
static void *sBufferTV, *sBufferDRC;
static uint32_t sBufferSizeTV, sBufferSizeDRC;
static bool sConsoleHasForeground;
static uint32_t consoleColor;
static uint32_t consoleCursorY;
};

View File

@ -8,14 +8,16 @@ extern "C" {
#include <whb/log.h>
#define __FILENAME_X__ (strrchr(__FILE__, '\\') ? strrchr(__FILE__, '\\') + 1 : __FILE__)
#define __FILENAME__ (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILENAME_X__)
#define __FILENAME__ (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILENAME_X__)
#define DEBUG_FUNCTION_LINE(FMT, ARGS...)do { \
WHBLogPrintf("[%23s]%30s@L%04d: " FMT "",__FILENAME__,__FUNCTION__, __LINE__, ## ARGS); \
#define DEBUG_FUNCTION_LINE(FMT, ARGS...) \
do { \
WHBLogPrintf("[%23s]%30s@L%04d: " FMT "", __FILENAME__, __FUNCTION__, __LINE__, ##ARGS); \
} while (0);
#define DEBUG_FUNCTION_LINE_WRITE(FMT, ARGS...)do { \
WHBLogWritef("[%23s]%30s@L%04d: " FMT "",__FILENAME__,__FUNCTION__, __LINE__, ## ARGS); \
#define DEBUG_FUNCTION_LINE_WRITE(FMT, ARGS...) \
do { \
WHBLogWritef("[%23s]%30s@L%04d: " FMT "", __FILENAME__, __FUNCTION__, __LINE__, ##ARGS); \
} while (0);
#ifdef __cplusplus

View File

@ -1,3 +1,4 @@
// clang-format off
/**
* pugixml parser - version 1.10
* --------------------------------------------------------

View File

@ -1,3 +1,4 @@
// clang-format off
/**
* pugixml parser - version 1.10
* --------------------------------------------------------

View File

@ -1,3 +1,4 @@
// clang-format off
/**
* pugixml parser - version 1.10
* --------------------------------------------------------

View File

@ -1,10 +1,10 @@
#include <string.h>
#include <stddef.h>
#include <whb/log.h>
#include <fs/FSUtils.h>
#include "logger.h"
#include "utils.h"
#include "TinySHA1.hpp"
#include "logger.h"
#include <fs/FSUtils.h>
#include <stddef.h>
#include <string.h>
#include <whb/log.h>
// https://gist.github.com/ccbrown/9722406
void Utils::dumpHex(const void *data, size_t size) {
@ -24,7 +24,7 @@ void Utils::dumpHex(const void *data, size_t size) {
if ((i + 1) % 16 == 0) {
WHBLogPrintf("| %s ", ascii);
if (i + 1 < size) {
DEBUG_FUNCTION_LINE("0x%08X (0x%04X); ", ((uint32_t)data) + i + 1, i + 1);
DEBUG_FUNCTION_LINE("0x%08X (0x%04X); ", ((uint32_t) data) + i + 1, i + 1);
}
} else if (i + 1 == size) {
ascii[(i + 1) % 16] = '\0';

View File

@ -7,28 +7,29 @@
extern "C" {
#endif
#define LIMIT(x, min, max) \
({ \
typeof( x ) _x = x; \
typeof( min ) _min = min; \
typeof( max ) _max = max; \
( ( ( _x ) < ( _min ) ) ? ( _min ) : ( ( _x ) > ( _max ) ) ? ( _max) : ( _x ) ); \
})
#define LIMIT(x, min, max) \
({ \
typeof(x) _x = x; \
typeof(min) _min = min; \
typeof(max) _max = max; \
(((_x) < (_min)) ? (_min) : ((_x) > (_max)) ? (_max) \
: (_x)); \
})
#define DegToRad(a) ( (a) * 0.01745329252f )
#define RadToDeg(a) ( (a) * 57.29577951f )
#define DegToRad(a) ((a) *0.01745329252f)
#define RadToDeg(a) ((a) *57.29577951f)
#define ALIGN4(x) (((x) + 3) & ~3)
#define ALIGN32(x) (((x) + 31) & ~31)
#define ALIGN4(x) (((x) + 3) & ~3)
#define ALIGN32(x) (((x) + 31) & ~31)
// those work only in powers of 2
#define ROUNDDOWN(val, align) ((val) & ~(align-1))
#define ROUNDUP(val, align) ROUNDDOWN(((val) + (align-1)), align)
#define ROUNDDOWN(val, align) ((val) & ~(align - 1))
#define ROUNDUP(val, align) ROUNDDOWN(((val) + (align - 1)), align)
#define le16(i) ((((uint16_t) ((i) & 0xFF)) << 8) | ((uint16_t) (((i) & 0xFF00) >> 8)))
#define le32(i) ((((uint32_t)le16((i) & 0xFFFF)) << 16) | ((uint32_t)le16(((i) & 0xFFFF0000) >> 16)))
#define le64(i) ((((uint64_t)le32((i) & 0xFFFFFFFFLL)) << 32) | ((uint64_t)le32(((i) & 0xFFFFFFFF00000000LL) >> 32)))
#define le16(i) ((((uint16_t) ((i) &0xFF)) << 8) | ((uint16_t) (((i) &0xFF00) >> 8)))
#define le32(i) ((((uint32_t) le16((i) &0xFFFF)) << 16) | ((uint32_t) le16(((i) &0xFFFF0000) >> 16)))
#define le64(i) ((((uint64_t) le32((i) &0xFFFFFFFFLL)) << 32) | ((uint64_t) le32(((i) &0xFFFFFFFF00000000LL) >> 32)))
#ifdef __cplusplus
}