forked from PretendoNetwork/Inkay
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
56a115ca79 |
|||
| cc7d9e8d84 | |||
| 14501054ac | |||
| dc1466eb36 | |||
| bc2014fbe8 | |||
| 04bbcbfda9 | |||
| 257d4ba119 | |||
| e14b6b69f1 | |||
| e421ac5a40 | |||
|
|
5960ff1e40 |
||
|
|
890be941a9 | ||
|
|
6df031b26d |
||
|
|
10688b5ac2 | ||
|
|
df01b5b1dd | ||
|
|
39dc7d8c8a | ||
|
|
158c597aeb | ||
|
|
ccf5370f84 | ||
|
|
e5020b88d0 | ||
|
|
8cfbf64d54 | ||
|
|
2df55177cb |
||
|
|
82cca21ff3 |
||
| d5f9207deb | |||
| 1796ebebb5 | |||
|
|
a43aed2456 |
||
| 998abca200 | |||
|
|
1c795ea15b |
||
| 4c432b753c | |||
|
|
8d85d88e4e |
||
|
|
b4407310e5 |
||
|
|
1508e7c1e0 |
||
|
|
b04ebb8624 | ||
| 7403eaecd3 | |||
| bf5336cba9 | |||
| c2e1eef7e5 | |||
| d01d322003 | |||
| 00a75e94cb | |||
|
|
7bb99c30d1 |
||
|
|
cbe54f5467 |
||
|
|
52c877d2e8 |
||
|
|
635f8b55ce |
||
|
|
48ae2f97e0 |
||
|
|
68afedb5ee |
||
|
|
7be7a0040a |
||
|
|
9e90882ec8 |
||
|
|
1f2660f2c1 |
||
|
|
285d9f51fb |
||
|
|
a25a09cede | ||
|
|
d08482ae5d |
||
|
|
fd06e2f2aa |
||
|
|
62c6cec406 |
||
|
|
b7c86c9edc |
||
|
|
4c38d9e303 |
||
|
|
c59e15395c |
||
|
|
fe55961a18 |
||
|
|
e3ff447fa6 |
||
|
|
257f7af9f8 |
||
|
|
4c2cdd09d3 |
||
|
|
c90d91cd62 |
||
|
|
ca313e193e |
||
|
|
9fa4beae2e |
||
|
|
79bc63adb8 |
||
|
|
83790b26bf |
||
|
|
bda6bc0d32 |
||
|
|
cfd4c01896 |
||
|
|
eb26bc32d8 |
||
|
|
d0985dd17a |
||
|
|
0b0fbfc742 |
||
|
|
f1b725867a |
||
|
|
4ad4666272 |
||
|
|
6e1122e1b3 | ||
|
|
907de64376 | ||
|
|
979d9de91a | ||
|
|
8da5fde962 |
||
|
|
194dc90f59 |
||
|
|
3647725527 |
||
|
|
f3522fb5ac |
||
|
|
e62f921d71 |
||
|
|
d1b5ba6113 |
||
|
|
889794f239 |
||
|
|
724060d1c7 |
||
|
|
6a54c86d06 |
||
|
|
2db5735085 |
||
|
|
ee49400d55 | ||
|
|
c1430e5a8c |
||
|
|
ea41e73d8d |
||
|
|
add1d2c2e2 |
||
|
|
8bc8ac0290 |
||
|
|
4cf3b7446e |
||
|
|
93f9a3dff4 |
||
|
|
97167e0dab |
||
|
|
4a880c1a2e | ||
|
|
79ccad1fd4 | ||
|
|
ed75702ac5 | ||
|
|
429d55ba9f |
||
|
|
e2cf529b3f | ||
|
|
24f680c6fb | ||
|
|
f9b0477c4e |
||
|
|
cc3fac1cc7 | ||
|
|
1ffb9cf65a | ||
|
|
f6bb2805f6 |
||
|
|
eef3580fca |
||
|
|
b5cf02bb90 |
||
|
a9ee61babe |
|||
|
|
1acb60ff49 |
||
|
0afd60d7f6 |
|||
|
|
f02eacad88 |
||
|
|
4adf1f267d |
||
|
|
a6e1fae402 |
||
|
|
816b34473b |
||
|
|
b4c4cf424b |
||
|
|
bb34ab259c |
||
|
|
e6fd32cf7a |
||
|
|
85e64547d3 |
||
|
|
4c4f8ae355 |
||
|
|
f5e136704b |
||
|
|
5b4fbd0521 |
||
|
|
3a79f3228f |
||
|
|
abc2e53c6e |
||
|
|
08fa9ec269 |
||
|
|
fa59526cd0 |
||
|
|
eea33cbd18 |
||
|
|
4966ef3eca |
||
|
|
cf6ad91733 |
||
|
|
e1d7cb56c2 |
||
|
|
9e376f7839 | ||
|
|
38f1b1848e | ||
|
|
23728c4288 |
||
|
|
6c78a95872 | ||
|
|
ebecf957f1 |
||
|
|
8d7df27d42 |
||
|
|
0f1e05b021 |
||
|
|
2510c691f1 |
||
|
|
4009d44a97 |
||
|
|
e6edcec5a5 |
||
|
|
a6b91be935 | ||
|
|
727f11d04d | ||
|
|
dbb648729a | ||
|
|
4b0e298b8e |
||
|
|
cd1d530da9 | ||
|
|
2bf5f8bd18 |
||
|
|
0f3115a402 |
||
|
|
06847b21e5 |
||
|
|
a710bd985a | ||
|
|
ea71879bb1 | ||
|
|
68bc066c7b | ||
|
|
7958373394 | ||
|
|
d3ff378cc4 | ||
|
|
3460feeeaf | ||
|
|
f4aeee8034 | ||
|
|
cc967126fe | ||
|
|
22bebff027 | ||
|
|
a1375ca608 |
||
|
|
9d29ad78fd |
||
|
|
6baee13685 | ||
|
|
1d1e094257 | ||
|
|
b16237417c | ||
|
|
aedd02b0d1 | ||
|
|
c6d80bd550 | ||
|
|
1a85a45ce3 | ||
|
|
04d723137b | ||
|
|
956419a438 | ||
|
|
bdfb6ca859 | ||
|
|
a6fd3783f1 | ||
|
|
867ea12f17 | ||
|
|
734e5d40c9 | ||
|
|
538fc25014 | ||
|
|
3f59781bd8 | ||
|
|
349b1f38aa | ||
|
|
9a9bf0949d | ||
|
|
695a077ebd | ||
|
|
b02db3f20b |
||
|
|
b239ae82db | ||
|
|
636354493b | ||
|
|
ddd2c9c803 |
||
|
|
11c170dc06 | ||
|
|
c05c3325d3 |
||
|
|
bf0031faa8 |
||
|
|
216942cb64 | ||
|
|
24596b1bff | ||
|
|
e0962577cd | ||
|
|
cb197bcf40 |
||
|
|
4b051b7d48 | ||
|
|
662ebaf299 | ||
|
|
b6f9995875 | ||
|
|
283dba27a6 | ||
|
|
3bb9359da0 | ||
|
|
a477a4c6b7 | ||
|
|
d62765bab9 | ||
|
|
50b1c9a594 | ||
|
|
467f0d94f1 | ||
|
|
3e01ea8370 | ||
|
|
862e095e5a | ||
|
|
51e9042d71 | ||
|
|
0dfd4cdd1d | ||
|
|
00e9e688cb | ||
|
|
41ed55f1b7 | ||
|
|
96f9caa5c9 | ||
|
|
b1badd8d29 | ||
|
b8ec956eb8 |
|||
|
5450859333 |
|||
|
|
e4b9e97b9f |
67 changed files with 4284 additions and 526 deletions
16
.github/workflows/ci.yml
vendored
16
.github/workflows/ci.yml
vendored
|
|
@ -1,18 +1,22 @@
|
||||||
name: Inkay-CI
|
name: Inkay-CI
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
|
||||||
on: push
|
on:
|
||||||
|
- push
|
||||||
|
- pull_request
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build-inkay:
|
build-inkay:
|
||||||
runs-on: ubuntu-22.04
|
runs-on: debian-trixie
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v7
|
||||||
- name: build toolchain container
|
- name: build toolchain container
|
||||||
run: docker build . -t builder
|
run: docker build . -t builder
|
||||||
- uses: ammaraskar/gcc-problem-matcher@master
|
- uses: https://github.com/ammaraskar/gcc-problem-matcher@master
|
||||||
- name: build Inkay
|
- name: build Inkay
|
||||||
run: docker run --rm -v ${PWD}:/app -w /app builder
|
run: docker run --rm -v ${PWD}:/app -w /app builder
|
||||||
- uses: actions/upload-artifact@master
|
- uses: actions/upload-artifact@v3
|
||||||
with:
|
with:
|
||||||
name: inkay
|
name: inkay
|
||||||
path: "*.wps"
|
path: dist/
|
||||||
6
.gitignore
vendored
6
.gitignore
vendored
|
|
@ -1,6 +1,12 @@
|
||||||
|
.cache/
|
||||||
.vscode/
|
.vscode/
|
||||||
.idea/
|
.idea/
|
||||||
/build
|
/build
|
||||||
|
/plugin/build
|
||||||
|
/dist
|
||||||
*.elf
|
*.elf
|
||||||
|
*.wms
|
||||||
*.wps
|
*.wps
|
||||||
certs/
|
certs/
|
||||||
|
*.lst
|
||||||
|
inkay_config.local.h
|
||||||
|
|
|
||||||
14
Dockerfile
14
Dockerfile
|
|
@ -1,9 +1,11 @@
|
||||||
FROM wiiuenv/devkitppc:20221228
|
FROM ghcr.io/wiiu-env/devkitppc:20260504
|
||||||
|
|
||||||
COPY --from=wiiuenv/libnotifications:20230126 /artifacts $DEVKITPRO
|
COPY --from=ghcr.io/wiiu-env/libnotifications:20240426 /artifacts $DEVKITPRO
|
||||||
COPY --from=wiiuenv/libkernel:20220724 /artifacts $DEVKITPRO
|
COPY --from=ghcr.io/wiiu-env/libfunctionpatcher:20230621 /artifacts $DEVKITPRO
|
||||||
COPY --from=wiiuenv/libmocha:20220903 /artifacts $DEVKITPRO
|
COPY --from=ghcr.io/wiiu-env/libkernel:20230621 /artifacts $DEVKITPRO
|
||||||
COPY --from=wiiuenv/wiiupluginsystem:20230126 /artifacts $DEVKITPRO
|
COPY --from=ghcr.io/wiiu-env/libmocha:20231127 /artifacts $DEVKITPRO
|
||||||
|
COPY --from=ghcr.io/wiiu-env/wiiumodulesystem:20250219 /artifacts $DEVKITPRO
|
||||||
|
COPY --from=ghcr.io/wiiu-env/wiiupluginsystem:20240505 /artifacts $DEVKITPRO
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
CMD make -f Makefile -j$(nproc)
|
CMD make -f Makefile -j$(nproc)
|
||||||
|
|
|
||||||
674
LICENSE
Normal file
674
LICENSE
Normal file
|
|
@ -0,0 +1,674 @@
|
||||||
|
GNU GENERAL PUBLIC LICENSE
|
||||||
|
Version 3, 29 June 2007
|
||||||
|
|
||||||
|
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
||||||
|
Everyone is permitted to copy and distribute verbatim copies
|
||||||
|
of this license document, but changing it is not allowed.
|
||||||
|
|
||||||
|
Preamble
|
||||||
|
|
||||||
|
The GNU General Public License is a free, copyleft license for
|
||||||
|
software and other kinds of works.
|
||||||
|
|
||||||
|
The licenses for most software and other practical works are designed
|
||||||
|
to take away your freedom to share and change the works. By contrast,
|
||||||
|
the GNU General Public License is intended to guarantee your freedom to
|
||||||
|
share and change all versions of a program--to make sure it remains free
|
||||||
|
software for all its users. We, the Free Software Foundation, use the
|
||||||
|
GNU General Public License for most of our software; it applies also to
|
||||||
|
any other work released this way by its authors. You can apply it to
|
||||||
|
your programs, too.
|
||||||
|
|
||||||
|
When we speak of free software, we are referring to freedom, not
|
||||||
|
price. Our General Public Licenses are designed to make sure that you
|
||||||
|
have the freedom to distribute copies of free software (and charge for
|
||||||
|
them if you wish), that you receive source code or can get it if you
|
||||||
|
want it, that you can change the software or use pieces of it in new
|
||||||
|
free programs, and that you know you can do these things.
|
||||||
|
|
||||||
|
To protect your rights, we need to prevent others from denying you
|
||||||
|
these rights or asking you to surrender the rights. Therefore, you have
|
||||||
|
certain responsibilities if you distribute copies of the software, or if
|
||||||
|
you modify it: responsibilities to respect the freedom of others.
|
||||||
|
|
||||||
|
For example, if you distribute copies of such a program, whether
|
||||||
|
gratis or for a fee, you must pass on to the recipients the same
|
||||||
|
freedoms that you received. You must make sure that they, too, receive
|
||||||
|
or can get the source code. And you must show them these terms so they
|
||||||
|
know their rights.
|
||||||
|
|
||||||
|
Developers that use the GNU GPL protect your rights with two steps:
|
||||||
|
(1) assert copyright on the software, and (2) offer you this License
|
||||||
|
giving you legal permission to copy, distribute and/or modify it.
|
||||||
|
|
||||||
|
For the developers' and authors' protection, the GPL clearly explains
|
||||||
|
that there is no warranty for this free software. For both users' and
|
||||||
|
authors' sake, the GPL requires that modified versions be marked as
|
||||||
|
changed, so that their problems will not be attributed erroneously to
|
||||||
|
authors of previous versions.
|
||||||
|
|
||||||
|
Some devices are designed to deny users access to install or run
|
||||||
|
modified versions of the software inside them, although the manufacturer
|
||||||
|
can do so. This is fundamentally incompatible with the aim of
|
||||||
|
protecting users' freedom to change the software. The systematic
|
||||||
|
pattern of such abuse occurs in the area of products for individuals to
|
||||||
|
use, which is precisely where it is most unacceptable. Therefore, we
|
||||||
|
have designed this version of the GPL to prohibit the practice for those
|
||||||
|
products. If such problems arise substantially in other domains, we
|
||||||
|
stand ready to extend this provision to those domains in future versions
|
||||||
|
of the GPL, as needed to protect the freedom of users.
|
||||||
|
|
||||||
|
Finally, every program is threatened constantly by software patents.
|
||||||
|
States should not allow patents to restrict development and use of
|
||||||
|
software on general-purpose computers, but in those that do, we wish to
|
||||||
|
avoid the special danger that patents applied to a free program could
|
||||||
|
make it effectively proprietary. To prevent this, the GPL assures that
|
||||||
|
patents cannot be used to render the program non-free.
|
||||||
|
|
||||||
|
The precise terms and conditions for copying, distribution and
|
||||||
|
modification follow.
|
||||||
|
|
||||||
|
TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
0. Definitions.
|
||||||
|
|
||||||
|
"This License" refers to version 3 of the GNU General Public License.
|
||||||
|
|
||||||
|
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||||
|
works, such as semiconductor masks.
|
||||||
|
|
||||||
|
"The Program" refers to any copyrightable work licensed under this
|
||||||
|
License. Each licensee is addressed as "you". "Licensees" and
|
||||||
|
"recipients" may be individuals or organizations.
|
||||||
|
|
||||||
|
To "modify" a work means to copy from or adapt all or part of the work
|
||||||
|
in a fashion requiring copyright permission, other than the making of an
|
||||||
|
exact copy. The resulting work is called a "modified version" of the
|
||||||
|
earlier work or a work "based on" the earlier work.
|
||||||
|
|
||||||
|
A "covered work" means either the unmodified Program or a work based
|
||||||
|
on the Program.
|
||||||
|
|
||||||
|
To "propagate" a work means to do anything with it that, without
|
||||||
|
permission, would make you directly or secondarily liable for
|
||||||
|
infringement under applicable copyright law, except executing it on a
|
||||||
|
computer or modifying a private copy. Propagation includes copying,
|
||||||
|
distribution (with or without modification), making available to the
|
||||||
|
public, and in some countries other activities as well.
|
||||||
|
|
||||||
|
To "convey" a work means any kind of propagation that enables other
|
||||||
|
parties to make or receive copies. Mere interaction with a user through
|
||||||
|
a computer network, with no transfer of a copy, is not conveying.
|
||||||
|
|
||||||
|
An interactive user interface displays "Appropriate Legal Notices"
|
||||||
|
to the extent that it includes a convenient and prominently visible
|
||||||
|
feature that (1) displays an appropriate copyright notice, and (2)
|
||||||
|
tells the user that there is no warranty for the work (except to the
|
||||||
|
extent that warranties are provided), that licensees may convey the
|
||||||
|
work under this License, and how to view a copy of this License. If
|
||||||
|
the interface presents a list of user commands or options, such as a
|
||||||
|
menu, a prominent item in the list meets this criterion.
|
||||||
|
|
||||||
|
1. Source Code.
|
||||||
|
|
||||||
|
The "source code" for a work means the preferred form of the work
|
||||||
|
for making modifications to it. "Object code" means any non-source
|
||||||
|
form of a work.
|
||||||
|
|
||||||
|
A "Standard Interface" means an interface that either is an official
|
||||||
|
standard defined by a recognized standards body, or, in the case of
|
||||||
|
interfaces specified for a particular programming language, one that
|
||||||
|
is widely used among developers working in that language.
|
||||||
|
|
||||||
|
The "System Libraries" of an executable work include anything, other
|
||||||
|
than the work as a whole, that (a) is included in the normal form of
|
||||||
|
packaging a Major Component, but which is not part of that Major
|
||||||
|
Component, and (b) serves only to enable use of the work with that
|
||||||
|
Major Component, or to implement a Standard Interface for which an
|
||||||
|
implementation is available to the public in source code form. A
|
||||||
|
"Major Component", in this context, means a major essential component
|
||||||
|
(kernel, window system, and so on) of the specific operating system
|
||||||
|
(if any) on which the executable work runs, or a compiler used to
|
||||||
|
produce the work, or an object code interpreter used to run it.
|
||||||
|
|
||||||
|
The "Corresponding Source" for a work in object code form means all
|
||||||
|
the source code needed to generate, install, and (for an executable
|
||||||
|
work) run the object code and to modify the work, including scripts to
|
||||||
|
control those activities. However, it does not include the work's
|
||||||
|
System Libraries, or general-purpose tools or generally available free
|
||||||
|
programs which are used unmodified in performing those activities but
|
||||||
|
which are not part of the work. For example, Corresponding Source
|
||||||
|
includes interface definition files associated with source files for
|
||||||
|
the work, and the source code for shared libraries and dynamically
|
||||||
|
linked subprograms that the work is specifically designed to require,
|
||||||
|
such as by intimate data communication or control flow between those
|
||||||
|
subprograms and other parts of the work.
|
||||||
|
|
||||||
|
The Corresponding Source need not include anything that users
|
||||||
|
can regenerate automatically from other parts of the Corresponding
|
||||||
|
Source.
|
||||||
|
|
||||||
|
The Corresponding Source for a work in source code form is that
|
||||||
|
same work.
|
||||||
|
|
||||||
|
2. Basic Permissions.
|
||||||
|
|
||||||
|
All rights granted under this License are granted for the term of
|
||||||
|
copyright on the Program, and are irrevocable provided the stated
|
||||||
|
conditions are met. This License explicitly affirms your unlimited
|
||||||
|
permission to run the unmodified Program. The output from running a
|
||||||
|
covered work is covered by this License only if the output, given its
|
||||||
|
content, constitutes a covered work. This License acknowledges your
|
||||||
|
rights of fair use or other equivalent, as provided by copyright law.
|
||||||
|
|
||||||
|
You may make, run and propagate covered works that you do not
|
||||||
|
convey, without conditions so long as your license otherwise remains
|
||||||
|
in force. You may convey covered works to others for the sole purpose
|
||||||
|
of having them make modifications exclusively for you, or provide you
|
||||||
|
with facilities for running those works, provided that you comply with
|
||||||
|
the terms of this License in conveying all material for which you do
|
||||||
|
not control copyright. Those thus making or running the covered works
|
||||||
|
for you must do so exclusively on your behalf, under your direction
|
||||||
|
and control, on terms that prohibit them from making any copies of
|
||||||
|
your copyrighted material outside their relationship with you.
|
||||||
|
|
||||||
|
Conveying under any other circumstances is permitted solely under
|
||||||
|
the conditions stated below. Sublicensing is not allowed; section 10
|
||||||
|
makes it unnecessary.
|
||||||
|
|
||||||
|
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||||
|
|
||||||
|
No covered work shall be deemed part of an effective technological
|
||||||
|
measure under any applicable law fulfilling obligations under article
|
||||||
|
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||||
|
similar laws prohibiting or restricting circumvention of such
|
||||||
|
measures.
|
||||||
|
|
||||||
|
When you convey a covered work, you waive any legal power to forbid
|
||||||
|
circumvention of technological measures to the extent such circumvention
|
||||||
|
is effected by exercising rights under this License with respect to
|
||||||
|
the covered work, and you disclaim any intention to limit operation or
|
||||||
|
modification of the work as a means of enforcing, against the work's
|
||||||
|
users, your or third parties' legal rights to forbid circumvention of
|
||||||
|
technological measures.
|
||||||
|
|
||||||
|
4. Conveying Verbatim Copies.
|
||||||
|
|
||||||
|
You may convey verbatim copies of the Program's source code as you
|
||||||
|
receive it, in any medium, provided that you conspicuously and
|
||||||
|
appropriately publish on each copy an appropriate copyright notice;
|
||||||
|
keep intact all notices stating that this License and any
|
||||||
|
non-permissive terms added in accord with section 7 apply to the code;
|
||||||
|
keep intact all notices of the absence of any warranty; and give all
|
||||||
|
recipients a copy of this License along with the Program.
|
||||||
|
|
||||||
|
You may charge any price or no price for each copy that you convey,
|
||||||
|
and you may offer support or warranty protection for a fee.
|
||||||
|
|
||||||
|
5. Conveying Modified Source Versions.
|
||||||
|
|
||||||
|
You may convey a work based on the Program, or the modifications to
|
||||||
|
produce it from the Program, in the form of source code under the
|
||||||
|
terms of section 4, provided that you also meet all of these conditions:
|
||||||
|
|
||||||
|
a) The work must carry prominent notices stating that you modified
|
||||||
|
it, and giving a relevant date.
|
||||||
|
|
||||||
|
b) The work must carry prominent notices stating that it is
|
||||||
|
released under this License and any conditions added under section
|
||||||
|
7. This requirement modifies the requirement in section 4 to
|
||||||
|
"keep intact all notices".
|
||||||
|
|
||||||
|
c) You must license the entire work, as a whole, under this
|
||||||
|
License to anyone who comes into possession of a copy. This
|
||||||
|
License will therefore apply, along with any applicable section 7
|
||||||
|
additional terms, to the whole of the work, and all its parts,
|
||||||
|
regardless of how they are packaged. This License gives no
|
||||||
|
permission to license the work in any other way, but it does not
|
||||||
|
invalidate such permission if you have separately received it.
|
||||||
|
|
||||||
|
d) If the work has interactive user interfaces, each must display
|
||||||
|
Appropriate Legal Notices; however, if the Program has interactive
|
||||||
|
interfaces that do not display Appropriate Legal Notices, your
|
||||||
|
work need not make them do so.
|
||||||
|
|
||||||
|
A compilation of a covered work with other separate and independent
|
||||||
|
works, which are not by their nature extensions of the covered work,
|
||||||
|
and which are not combined with it such as to form a larger program,
|
||||||
|
in or on a volume of a storage or distribution medium, is called an
|
||||||
|
"aggregate" if the compilation and its resulting copyright are not
|
||||||
|
used to limit the access or legal rights of the compilation's users
|
||||||
|
beyond what the individual works permit. Inclusion of a covered work
|
||||||
|
in an aggregate does not cause this License to apply to the other
|
||||||
|
parts of the aggregate.
|
||||||
|
|
||||||
|
6. Conveying Non-Source Forms.
|
||||||
|
|
||||||
|
You may convey a covered work in object code form under the terms
|
||||||
|
of sections 4 and 5, provided that you also convey the
|
||||||
|
machine-readable Corresponding Source under the terms of this License,
|
||||||
|
in one of these ways:
|
||||||
|
|
||||||
|
a) Convey the object code in, or embodied in, a physical product
|
||||||
|
(including a physical distribution medium), accompanied by the
|
||||||
|
Corresponding Source fixed on a durable physical medium
|
||||||
|
customarily used for software interchange.
|
||||||
|
|
||||||
|
b) Convey the object code in, or embodied in, a physical product
|
||||||
|
(including a physical distribution medium), accompanied by a
|
||||||
|
written offer, valid for at least three years and valid for as
|
||||||
|
long as you offer spare parts or customer support for that product
|
||||||
|
model, to give anyone who possesses the object code either (1) a
|
||||||
|
copy of the Corresponding Source for all the software in the
|
||||||
|
product that is covered by this License, on a durable physical
|
||||||
|
medium customarily used for software interchange, for a price no
|
||||||
|
more than your reasonable cost of physically performing this
|
||||||
|
conveying of source, or (2) access to copy the
|
||||||
|
Corresponding Source from a network server at no charge.
|
||||||
|
|
||||||
|
c) Convey individual copies of the object code with a copy of the
|
||||||
|
written offer to provide the Corresponding Source. This
|
||||||
|
alternative is allowed only occasionally and noncommercially, and
|
||||||
|
only if you received the object code with such an offer, in accord
|
||||||
|
with subsection 6b.
|
||||||
|
|
||||||
|
d) Convey the object code by offering access from a designated
|
||||||
|
place (gratis or for a charge), and offer equivalent access to the
|
||||||
|
Corresponding Source in the same way through the same place at no
|
||||||
|
further charge. You need not require recipients to copy the
|
||||||
|
Corresponding Source along with the object code. If the place to
|
||||||
|
copy the object code is a network server, the Corresponding Source
|
||||||
|
may be on a different server (operated by you or a third party)
|
||||||
|
that supports equivalent copying facilities, provided you maintain
|
||||||
|
clear directions next to the object code saying where to find the
|
||||||
|
Corresponding Source. Regardless of what server hosts the
|
||||||
|
Corresponding Source, you remain obligated to ensure that it is
|
||||||
|
available for as long as needed to satisfy these requirements.
|
||||||
|
|
||||||
|
e) Convey the object code using peer-to-peer transmission, provided
|
||||||
|
you inform other peers where the object code and Corresponding
|
||||||
|
Source of the work are being offered to the general public at no
|
||||||
|
charge under subsection 6d.
|
||||||
|
|
||||||
|
A separable portion of the object code, whose source code is excluded
|
||||||
|
from the Corresponding Source as a System Library, need not be
|
||||||
|
included in conveying the object code work.
|
||||||
|
|
||||||
|
A "User Product" is either (1) a "consumer product", which means any
|
||||||
|
tangible personal property which is normally used for personal, family,
|
||||||
|
or household purposes, or (2) anything designed or sold for incorporation
|
||||||
|
into a dwelling. In determining whether a product is a consumer product,
|
||||||
|
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||||
|
product received by a particular user, "normally used" refers to a
|
||||||
|
typical or common use of that class of product, regardless of the status
|
||||||
|
of the particular user or of the way in which the particular user
|
||||||
|
actually uses, or expects or is expected to use, the product. A product
|
||||||
|
is a consumer product regardless of whether the product has substantial
|
||||||
|
commercial, industrial or non-consumer uses, unless such uses represent
|
||||||
|
the only significant mode of use of the product.
|
||||||
|
|
||||||
|
"Installation Information" for a User Product means any methods,
|
||||||
|
procedures, authorization keys, or other information required to install
|
||||||
|
and execute modified versions of a covered work in that User Product from
|
||||||
|
a modified version of its Corresponding Source. The information must
|
||||||
|
suffice to ensure that the continued functioning of the modified object
|
||||||
|
code is in no case prevented or interfered with solely because
|
||||||
|
modification has been made.
|
||||||
|
|
||||||
|
If you convey an object code work under this section in, or with, or
|
||||||
|
specifically for use in, a User Product, and the conveying occurs as
|
||||||
|
part of a transaction in which the right of possession and use of the
|
||||||
|
User Product is transferred to the recipient in perpetuity or for a
|
||||||
|
fixed term (regardless of how the transaction is characterized), the
|
||||||
|
Corresponding Source conveyed under this section must be accompanied
|
||||||
|
by the Installation Information. But this requirement does not apply
|
||||||
|
if neither you nor any third party retains the ability to install
|
||||||
|
modified object code on the User Product (for example, the work has
|
||||||
|
been installed in ROM).
|
||||||
|
|
||||||
|
The requirement to provide Installation Information does not include a
|
||||||
|
requirement to continue to provide support service, warranty, or updates
|
||||||
|
for a work that has been modified or installed by the recipient, or for
|
||||||
|
the User Product in which it has been modified or installed. Access to a
|
||||||
|
network may be denied when the modification itself materially and
|
||||||
|
adversely affects the operation of the network or violates the rules and
|
||||||
|
protocols for communication across the network.
|
||||||
|
|
||||||
|
Corresponding Source conveyed, and Installation Information provided,
|
||||||
|
in accord with this section must be in a format that is publicly
|
||||||
|
documented (and with an implementation available to the public in
|
||||||
|
source code form), and must require no special password or key for
|
||||||
|
unpacking, reading or copying.
|
||||||
|
|
||||||
|
7. Additional Terms.
|
||||||
|
|
||||||
|
"Additional permissions" are terms that supplement the terms of this
|
||||||
|
License by making exceptions from one or more of its conditions.
|
||||||
|
Additional permissions that are applicable to the entire Program shall
|
||||||
|
be treated as though they were included in this License, to the extent
|
||||||
|
that they are valid under applicable law. If additional permissions
|
||||||
|
apply only to part of the Program, that part may be used separately
|
||||||
|
under those permissions, but the entire Program remains governed by
|
||||||
|
this License without regard to the additional permissions.
|
||||||
|
|
||||||
|
When you convey a copy of a covered work, you may at your option
|
||||||
|
remove any additional permissions from that copy, or from any part of
|
||||||
|
it. (Additional permissions may be written to require their own
|
||||||
|
removal in certain cases when you modify the work.) You may place
|
||||||
|
additional permissions on material, added by you to a covered work,
|
||||||
|
for which you have or can give appropriate copyright permission.
|
||||||
|
|
||||||
|
Notwithstanding any other provision of this License, for material you
|
||||||
|
add to a covered work, you may (if authorized by the copyright holders of
|
||||||
|
that material) supplement the terms of this License with terms:
|
||||||
|
|
||||||
|
a) Disclaiming warranty or limiting liability differently from the
|
||||||
|
terms of sections 15 and 16 of this License; or
|
||||||
|
|
||||||
|
b) Requiring preservation of specified reasonable legal notices or
|
||||||
|
author attributions in that material or in the Appropriate Legal
|
||||||
|
Notices displayed by works containing it; or
|
||||||
|
|
||||||
|
c) Prohibiting misrepresentation of the origin of that material, or
|
||||||
|
requiring that modified versions of such material be marked in
|
||||||
|
reasonable ways as different from the original version; or
|
||||||
|
|
||||||
|
d) Limiting the use for publicity purposes of names of licensors or
|
||||||
|
authors of the material; or
|
||||||
|
|
||||||
|
e) Declining to grant rights under trademark law for use of some
|
||||||
|
trade names, trademarks, or service marks; or
|
||||||
|
|
||||||
|
f) Requiring indemnification of licensors and authors of that
|
||||||
|
material by anyone who conveys the material (or modified versions of
|
||||||
|
it) with contractual assumptions of liability to the recipient, for
|
||||||
|
any liability that these contractual assumptions directly impose on
|
||||||
|
those licensors and authors.
|
||||||
|
|
||||||
|
All other non-permissive additional terms are considered "further
|
||||||
|
restrictions" within the meaning of section 10. If the Program as you
|
||||||
|
received it, or any part of it, contains a notice stating that it is
|
||||||
|
governed by this License along with a term that is a further
|
||||||
|
restriction, you may remove that term. If a license document contains
|
||||||
|
a further restriction but permits relicensing or conveying under this
|
||||||
|
License, you may add to a covered work material governed by the terms
|
||||||
|
of that license document, provided that the further restriction does
|
||||||
|
not survive such relicensing or conveying.
|
||||||
|
|
||||||
|
If you add terms to a covered work in accord with this section, you
|
||||||
|
must place, in the relevant source files, a statement of the
|
||||||
|
additional terms that apply to those files, or a notice indicating
|
||||||
|
where to find the applicable terms.
|
||||||
|
|
||||||
|
Additional terms, permissive or non-permissive, may be stated in the
|
||||||
|
form of a separately written license, or stated as exceptions;
|
||||||
|
the above requirements apply either way.
|
||||||
|
|
||||||
|
8. Termination.
|
||||||
|
|
||||||
|
You may not propagate or modify a covered work except as expressly
|
||||||
|
provided under this License. Any attempt otherwise to propagate or
|
||||||
|
modify it is void, and will automatically terminate your rights under
|
||||||
|
this License (including any patent licenses granted under the third
|
||||||
|
paragraph of section 11).
|
||||||
|
|
||||||
|
However, if you cease all violation of this License, then your
|
||||||
|
license from a particular copyright holder is reinstated (a)
|
||||||
|
provisionally, unless and until the copyright holder explicitly and
|
||||||
|
finally terminates your license, and (b) permanently, if the copyright
|
||||||
|
holder fails to notify you of the violation by some reasonable means
|
||||||
|
prior to 60 days after the cessation.
|
||||||
|
|
||||||
|
Moreover, your license from a particular copyright holder is
|
||||||
|
reinstated permanently if the copyright holder notifies you of the
|
||||||
|
violation by some reasonable means, this is the first time you have
|
||||||
|
received notice of violation of this License (for any work) from that
|
||||||
|
copyright holder, and you cure the violation prior to 30 days after
|
||||||
|
your receipt of the notice.
|
||||||
|
|
||||||
|
Termination of your rights under this section does not terminate the
|
||||||
|
licenses of parties who have received copies or rights from you under
|
||||||
|
this License. If your rights have been terminated and not permanently
|
||||||
|
reinstated, you do not qualify to receive new licenses for the same
|
||||||
|
material under section 10.
|
||||||
|
|
||||||
|
9. Acceptance Not Required for Having Copies.
|
||||||
|
|
||||||
|
You are not required to accept this License in order to receive or
|
||||||
|
run a copy of the Program. Ancillary propagation of a covered work
|
||||||
|
occurring solely as a consequence of using peer-to-peer transmission
|
||||||
|
to receive a copy likewise does not require acceptance. However,
|
||||||
|
nothing other than this License grants you permission to propagate or
|
||||||
|
modify any covered work. These actions infringe copyright if you do
|
||||||
|
not accept this License. Therefore, by modifying or propagating a
|
||||||
|
covered work, you indicate your acceptance of this License to do so.
|
||||||
|
|
||||||
|
10. Automatic Licensing of Downstream Recipients.
|
||||||
|
|
||||||
|
Each time you convey a covered work, the recipient automatically
|
||||||
|
receives a license from the original licensors, to run, modify and
|
||||||
|
propagate that work, subject to this License. You are not responsible
|
||||||
|
for enforcing compliance by third parties with this License.
|
||||||
|
|
||||||
|
An "entity transaction" is a transaction transferring control of an
|
||||||
|
organization, or substantially all assets of one, or subdividing an
|
||||||
|
organization, or merging organizations. If propagation of a covered
|
||||||
|
work results from an entity transaction, each party to that
|
||||||
|
transaction who receives a copy of the work also receives whatever
|
||||||
|
licenses to the work the party's predecessor in interest had or could
|
||||||
|
give under the previous paragraph, plus a right to possession of the
|
||||||
|
Corresponding Source of the work from the predecessor in interest, if
|
||||||
|
the predecessor has it or can get it with reasonable efforts.
|
||||||
|
|
||||||
|
You may not impose any further restrictions on the exercise of the
|
||||||
|
rights granted or affirmed under this License. For example, you may
|
||||||
|
not impose a license fee, royalty, or other charge for exercise of
|
||||||
|
rights granted under this License, and you may not initiate litigation
|
||||||
|
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||||
|
any patent claim is infringed by making, using, selling, offering for
|
||||||
|
sale, or importing the Program or any portion of it.
|
||||||
|
|
||||||
|
11. Patents.
|
||||||
|
|
||||||
|
A "contributor" is a copyright holder who authorizes use under this
|
||||||
|
License of the Program or a work on which the Program is based. The
|
||||||
|
work thus licensed is called the contributor's "contributor version".
|
||||||
|
|
||||||
|
A contributor's "essential patent claims" are all patent claims
|
||||||
|
owned or controlled by the contributor, whether already acquired or
|
||||||
|
hereafter acquired, that would be infringed by some manner, permitted
|
||||||
|
by this License, of making, using, or selling its contributor version,
|
||||||
|
but do not include claims that would be infringed only as a
|
||||||
|
consequence of further modification of the contributor version. For
|
||||||
|
purposes of this definition, "control" includes the right to grant
|
||||||
|
patent sublicenses in a manner consistent with the requirements of
|
||||||
|
this License.
|
||||||
|
|
||||||
|
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||||
|
patent license under the contributor's essential patent claims, to
|
||||||
|
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||||
|
propagate the contents of its contributor version.
|
||||||
|
|
||||||
|
In the following three paragraphs, a "patent license" is any express
|
||||||
|
agreement or commitment, however denominated, not to enforce a patent
|
||||||
|
(such as an express permission to practice a patent or covenant not to
|
||||||
|
sue for patent infringement). To "grant" such a patent license to a
|
||||||
|
party means to make such an agreement or commitment not to enforce a
|
||||||
|
patent against the party.
|
||||||
|
|
||||||
|
If you convey a covered work, knowingly relying on a patent license,
|
||||||
|
and the Corresponding Source of the work is not available for anyone
|
||||||
|
to copy, free of charge and under the terms of this License, through a
|
||||||
|
publicly available network server or other readily accessible means,
|
||||||
|
then you must either (1) cause the Corresponding Source to be so
|
||||||
|
available, or (2) arrange to deprive yourself of the benefit of the
|
||||||
|
patent license for this particular work, or (3) arrange, in a manner
|
||||||
|
consistent with the requirements of this License, to extend the patent
|
||||||
|
license to downstream recipients. "Knowingly relying" means you have
|
||||||
|
actual knowledge that, but for the patent license, your conveying the
|
||||||
|
covered work in a country, or your recipient's use of the covered work
|
||||||
|
in a country, would infringe one or more identifiable patents in that
|
||||||
|
country that you have reason to believe are valid.
|
||||||
|
|
||||||
|
If, pursuant to or in connection with a single transaction or
|
||||||
|
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||||
|
covered work, and grant a patent license to some of the parties
|
||||||
|
receiving the covered work authorizing them to use, propagate, modify
|
||||||
|
or convey a specific copy of the covered work, then the patent license
|
||||||
|
you grant is automatically extended to all recipients of the covered
|
||||||
|
work and works based on it.
|
||||||
|
|
||||||
|
A patent license is "discriminatory" if it does not include within
|
||||||
|
the scope of its coverage, prohibits the exercise of, or is
|
||||||
|
conditioned on the non-exercise of one or more of the rights that are
|
||||||
|
specifically granted under this License. You may not convey a covered
|
||||||
|
work if you are a party to an arrangement with a third party that is
|
||||||
|
in the business of distributing software, under which you make payment
|
||||||
|
to the third party based on the extent of your activity of conveying
|
||||||
|
the work, and under which the third party grants, to any of the
|
||||||
|
parties who would receive the covered work from you, a discriminatory
|
||||||
|
patent license (a) in connection with copies of the covered work
|
||||||
|
conveyed by you (or copies made from those copies), or (b) primarily
|
||||||
|
for and in connection with specific products or compilations that
|
||||||
|
contain the covered work, unless you entered into that arrangement,
|
||||||
|
or that patent license was granted, prior to 28 March 2007.
|
||||||
|
|
||||||
|
Nothing in this License shall be construed as excluding or limiting
|
||||||
|
any implied license or other defenses to infringement that may
|
||||||
|
otherwise be available to you under applicable patent law.
|
||||||
|
|
||||||
|
12. No Surrender of Others' Freedom.
|
||||||
|
|
||||||
|
If conditions are imposed on you (whether by court order, agreement or
|
||||||
|
otherwise) that contradict the conditions of this License, they do not
|
||||||
|
excuse you from the conditions of this License. If you cannot convey a
|
||||||
|
covered work so as to satisfy simultaneously your obligations under this
|
||||||
|
License and any other pertinent obligations, then as a consequence you may
|
||||||
|
not convey it at all. For example, if you agree to terms that obligate you
|
||||||
|
to collect a royalty for further conveying from those to whom you convey
|
||||||
|
the Program, the only way you could satisfy both those terms and this
|
||||||
|
License would be to refrain entirely from conveying the Program.
|
||||||
|
|
||||||
|
13. Use with the GNU Affero General Public License.
|
||||||
|
|
||||||
|
Notwithstanding any other provision of this License, you have
|
||||||
|
permission to link or combine any covered work with a work licensed
|
||||||
|
under version 3 of the GNU Affero General Public License into a single
|
||||||
|
combined work, and to convey the resulting work. The terms of this
|
||||||
|
License will continue to apply to the part which is the covered work,
|
||||||
|
but the special requirements of the GNU Affero General Public License,
|
||||||
|
section 13, concerning interaction through a network will apply to the
|
||||||
|
combination as such.
|
||||||
|
|
||||||
|
14. Revised Versions of this License.
|
||||||
|
|
||||||
|
The Free Software Foundation may publish revised and/or new versions of
|
||||||
|
the GNU General Public License from time to time. Such new versions will
|
||||||
|
be similar in spirit to the present version, but may differ in detail to
|
||||||
|
address new problems or concerns.
|
||||||
|
|
||||||
|
Each version is given a distinguishing version number. If the
|
||||||
|
Program specifies that a certain numbered version of the GNU General
|
||||||
|
Public License "or any later version" applies to it, you have the
|
||||||
|
option of following the terms and conditions either of that numbered
|
||||||
|
version or of any later version published by the Free Software
|
||||||
|
Foundation. If the Program does not specify a version number of the
|
||||||
|
GNU General Public License, you may choose any version ever published
|
||||||
|
by the Free Software Foundation.
|
||||||
|
|
||||||
|
If the Program specifies that a proxy can decide which future
|
||||||
|
versions of the GNU General Public License can be used, that proxy's
|
||||||
|
public statement of acceptance of a version permanently authorizes you
|
||||||
|
to choose that version for the Program.
|
||||||
|
|
||||||
|
Later license versions may give you additional or different
|
||||||
|
permissions. However, no additional obligations are imposed on any
|
||||||
|
author or copyright holder as a result of your choosing to follow a
|
||||||
|
later version.
|
||||||
|
|
||||||
|
15. Disclaimer of Warranty.
|
||||||
|
|
||||||
|
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||||
|
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||||
|
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||||
|
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
|
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||||
|
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||||
|
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||||
|
|
||||||
|
16. Limitation of Liability.
|
||||||
|
|
||||||
|
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||||
|
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||||
|
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||||
|
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||||
|
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||||
|
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||||
|
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||||
|
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||||
|
SUCH DAMAGES.
|
||||||
|
|
||||||
|
17. Interpretation of Sections 15 and 16.
|
||||||
|
|
||||||
|
If the disclaimer of warranty and limitation of liability provided
|
||||||
|
above cannot be given local legal effect according to their terms,
|
||||||
|
reviewing courts shall apply local law that most closely approximates
|
||||||
|
an absolute waiver of all civil liability in connection with the
|
||||||
|
Program, unless a warranty or assumption of liability accompanies a
|
||||||
|
copy of the Program in return for a fee.
|
||||||
|
|
||||||
|
END OF TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
How to Apply These Terms to Your New Programs
|
||||||
|
|
||||||
|
If you develop a new program, and you want it to be of the greatest
|
||||||
|
possible use to the public, the best way to achieve this is to make it
|
||||||
|
free software which everyone can redistribute and change under these terms.
|
||||||
|
|
||||||
|
To do so, attach the following notices to the program. It is safest
|
||||||
|
to attach them to the start of each source file to most effectively
|
||||||
|
state the exclusion of warranty; and each file should have at least
|
||||||
|
the "copyright" line and a pointer to where the full notice is found.
|
||||||
|
|
||||||
|
<one line to give the program's name and a brief idea of what it does.>
|
||||||
|
Copyright (C) <year> <name of author>
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Also add information on how to contact you by electronic and paper mail.
|
||||||
|
|
||||||
|
If the program does terminal interaction, make it output a short
|
||||||
|
notice like this when it starts in an interactive mode:
|
||||||
|
|
||||||
|
<program> Copyright (C) <year> <name of author>
|
||||||
|
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||||
|
This is free software, and you are welcome to redistribute it
|
||||||
|
under certain conditions; type `show c' for details.
|
||||||
|
|
||||||
|
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||||
|
parts of the General Public License. Of course, your program's commands
|
||||||
|
might be different; for a GUI interface, you would use an "about box".
|
||||||
|
|
||||||
|
You should also get your employer (if you work as a programmer) or school,
|
||||||
|
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||||
|
For more information on this, and how to apply and follow the GNU GPL, see
|
||||||
|
<https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
The GNU General Public License does not permit incorporating your program
|
||||||
|
into proprietary programs. If your program is a subroutine library, you
|
||||||
|
may consider it more useful to permit linking proprietary applications with
|
||||||
|
the library. If this is what you want to do, use the GNU Lesser General
|
||||||
|
Public License instead of this License. But first, please read
|
||||||
|
<https://www.gnu.org/licenses/why-not-lgpl.html>.
|
||||||
49
Makefile
49
Makefile
|
|
@ -8,10 +8,10 @@ endif
|
||||||
|
|
||||||
TOPDIR ?= $(CURDIR)
|
TOPDIR ?= $(CURDIR)
|
||||||
|
|
||||||
include $(DEVKITPRO)/wups/share/wups_rules
|
include $(DEVKITPRO)/wums/share/wums_rules
|
||||||
|
|
||||||
WUT_ROOT := $(DEVKITPRO)/wut
|
|
||||||
WUMS_ROOT := $(DEVKITPRO)/wums
|
WUMS_ROOT := $(DEVKITPRO)/wums
|
||||||
|
WUT_ROOT := $(DEVKITPRO)/wut
|
||||||
#-------------------------------------------------------------------------------
|
#-------------------------------------------------------------------------------
|
||||||
# TARGET is the name of the output
|
# TARGET is the name of the output
|
||||||
# BUILD is the directory where object files & intermediate files will be placed
|
# BUILD is the directory where object files & intermediate files will be placed
|
||||||
|
|
@ -19,34 +19,38 @@ WUMS_ROOT := $(DEVKITPRO)/wums
|
||||||
# DATA is a list of directories containing data files
|
# DATA is a list of directories containing data files
|
||||||
# INCLUDES is a list of directories containing header files
|
# INCLUDES is a list of directories containing header files
|
||||||
#-------------------------------------------------------------------------------
|
#-------------------------------------------------------------------------------
|
||||||
TARGET := Inkay-pretendo
|
TARGET := Malamar-spfn
|
||||||
BUILD := build
|
BUILD := build
|
||||||
SOURCES := src src/utils
|
SOURCES := src src/patches src/utils src/ext/inih common
|
||||||
DATA := data
|
DATA := data
|
||||||
INCLUDES := src
|
INCLUDES := src src/ext/inih src/lang common
|
||||||
|
|
||||||
#-------------------------------------------------------------------------------
|
#-------------------------------------------------------------------------------
|
||||||
# options for code generation
|
# options for code generation
|
||||||
#-------------------------------------------------------------------------------
|
#-------------------------------------------------------------------------------
|
||||||
CFLAGS := -g -Wall -O2 -ffunction-sections \
|
OPT := -Os -fno-exceptions -fno-asynchronous-unwind-tables
|
||||||
$(MACHDEP)
|
CFLAGS := -Wall -ffunction-sections -fdata-sections \
|
||||||
|
$(MACHDEP) $(OPT)
|
||||||
|
|
||||||
CFLAGS += $(INCLUDE) -D__WIIU__ -D__WUT__ -D__WUPS__
|
CFLAGS += $(INCLUDE) -D__WIIU__ -D__WUT__
|
||||||
|
|
||||||
CXXFLAGS := $(CFLAGS)
|
CXXFLAGS := $(CFLAGS) -std=c++20
|
||||||
|
|
||||||
ASFLAGS := -g $(ARCH)
|
ASFLAGS := -g $(ARCH)
|
||||||
LDFLAGS = -g $(ARCH) $(RPXSPECS) -Wl,-Map,$(notdir $*.map)
|
LDFLAGS = -g $(ARCH) $(OPT) $(RPXSPECS) -Wl,-Map,$(notdir $*.map) -Wl,-gc-sections -T$(WUMS_ROOT)/share/libkernel.ld $(WUMSSPECS)
|
||||||
|
|
||||||
LDFLAGS += -T$(WUMS_ROOT)/share/libkernel.ld $(WUPSSPECS)
|
ifeq ($(DEBUG),1)
|
||||||
|
CXXFLAGS += -DDEBUG -g
|
||||||
|
CFLAGS += -DDEBUG -g
|
||||||
|
endif
|
||||||
|
|
||||||
LIBS := -lwups -lmocha -lkernel -lwut -lnotifications
|
LIBS := -lwums -lmocha -lkernel -lwut -lfunctionpatcher -lnotifications
|
||||||
|
|
||||||
#-------------------------------------------------------------------------------
|
#-------------------------------------------------------------------------------
|
||||||
# list of directories containing libraries, this must be the top level
|
# list of directories containing libraries, this must be the top level
|
||||||
# containing include and lib
|
# containing include and lib
|
||||||
#-------------------------------------------------------------------------------
|
#-------------------------------------------------------------------------------
|
||||||
LIBDIRS := $(PORTLIBS) $(WUMS_ROOT) $(WUPS_ROOT) $(WUT_ROOT) $(WUT_ROOT)/usr
|
LIBDIRS := $(PORTLIBS) $(WUT_ROOT) $(WUMS_ROOT) $(WUT_ROOT)/usr
|
||||||
|
|
||||||
#-------------------------------------------------------------------------------
|
#-------------------------------------------------------------------------------
|
||||||
# no real need to edit anything past this point unless you need to add additional
|
# no real need to edit anything past this point unless you need to add additional
|
||||||
|
|
@ -98,14 +102,20 @@ export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib)
|
||||||
#-------------------------------------------------------------------------------
|
#-------------------------------------------------------------------------------
|
||||||
all: $(BUILD)
|
all: $(BUILD)
|
||||||
|
|
||||||
|
|
||||||
$(BUILD):
|
$(BUILD):
|
||||||
@$(shell [ ! -d $(BUILD) ] && mkdir -p $(BUILD))
|
@$(shell [ ! -d $(BUILD) ] && mkdir -p $(BUILD))
|
||||||
@$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile
|
@$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile
|
||||||
|
@$(MAKE) --no-print-directory -C $(CURDIR)/plugin -f $(CURDIR)/plugin/Makefile
|
||||||
|
mkdir -p dist/
|
||||||
|
cp *.wms dist/
|
||||||
|
cp plugin/*.wps dist/
|
||||||
|
|
||||||
#-------------------------------------------------------------------------------
|
#-------------------------------------------------------------------------------
|
||||||
clean:
|
clean:
|
||||||
@echo clean ...
|
@echo clean ...
|
||||||
@rm -fr $(BUILD) $(TARGET).wps $(TARGET).elf
|
@rm -fr dist $(BUILD) $(TARGET).wms $(TARGET).elf
|
||||||
|
@$(MAKE) --no-print-directory -C $(CURDIR)/plugin -f $(CURDIR)/plugin/Makefile clean
|
||||||
|
|
||||||
#-------------------------------------------------------------------------------
|
#-------------------------------------------------------------------------------
|
||||||
else
|
else
|
||||||
|
|
@ -116,10 +126,10 @@ DEPENDS := $(OFILES:.o=.d)
|
||||||
#-------------------------------------------------------------------------------
|
#-------------------------------------------------------------------------------
|
||||||
# main targets
|
# main targets
|
||||||
#-------------------------------------------------------------------------------
|
#-------------------------------------------------------------------------------
|
||||||
all : $(OUTPUT).wps
|
all : $(OUTPUT).wms
|
||||||
|
|
||||||
$(OUTPUT).wps : $(OUTPUT).elf
|
$(OUTPUT).wms : $(OUTPUT).elf
|
||||||
$(OUTPUT).elf : $(OFILES)
|
$(OUTPUT).elf : $(OFILES)
|
||||||
|
|
||||||
$(OFILES_SRC) : $(HFILES_BIN)
|
$(OFILES_SRC) : $(HFILES_BIN)
|
||||||
|
|
||||||
|
|
@ -136,6 +146,11 @@ $(OFILES_SRC) : $(HFILES_BIN)
|
||||||
@echo $(notdir $<)
|
@echo $(notdir $<)
|
||||||
@$(bin2o)
|
@$(bin2o)
|
||||||
|
|
||||||
|
#---------------------------------------------------------------------------------
|
||||||
|
%.o: %.s
|
||||||
|
@echo $(notdir $<)
|
||||||
|
@$(CC) -MMD -MP -MF $(DEPSDIR)/$*.d -x assembler-with-cpp $(ASFLAGS) -c $< -o $@ $(ERROR_FILTER)
|
||||||
|
|
||||||
-include $(DEPENDS)
|
-include $(DEPENDS)
|
||||||
|
|
||||||
#-------------------------------------------------------------------------------
|
#-------------------------------------------------------------------------------
|
||||||
|
|
|
||||||
42
README.md
42
README.md
|
|
@ -1,16 +1,40 @@
|
||||||
# Inkay - Aroma patches for Pretendo
|
# Malamar - Aroma patches for Splatfestival Network/Spacebar
|
||||||
|
|
||||||
[](https://pretendo.network)
|
Malamar is an Aroma/WUPS plugin based on Pretendo's Malamar that patches various Nintendo Network URLs on a Wii U to use Splatfestival/Spacebar Network instead. It also (for the time being) bypasses SSL verification in most cases. It redirects Nintendo Network in:
|
||||||
|
|
||||||
Inkay is an Aroma/WUPS plugin that patches various Nintendo Network URLs on a Wii U to use Pretendo Network instead. It also (for the time being) bypasses SSL verification in most cases.
|
- IOSU-side connections (Friends, SpotPass, accounts etc.)
|
||||||
|
- Account Settings
|
||||||
|
- NNCS
|
||||||
|
- Nintendo eShop
|
||||||
|
- Miiverse (in-game)
|
||||||
|
- Miiverse applet
|
||||||
|
|
||||||
Inkay does not currently include the game-specific patches present in [Nimble](https://github.com/PretendoNetwork/Nimble). These will be implemented soon™.
|
Malamar also includes game-specific patches to add extra features:
|
||||||
|
- Modpack-specific matchmaking for global, regional rooms (by simulating extra DLC) - **Mario Kart 8**
|
||||||
|
- P2P port override for better connection stability (if you port forward) - **Minecraft: Wii U Edition**, **Mario Kart 8**, **Splatoon**
|
||||||
|
|
||||||
## Dependencies
|
## Requirements
|
||||||
Inkay is only supported on the release version of Aroma configured for autoboot/coldboot. For Tiramisu, see [Nimble](https://github.com/PretendoNetwork/Nimble).
|
Malamar is only supported on the release version of Aroma configured for autoboot/coldboot. Other configurations (specifically lacking coldboot) may cause issues with SpotPass.
|
||||||
|
|
||||||
## Safety
|
## Safety
|
||||||
Inkay's patches are all temporary, and only applied in-memory without modifying your console. The SSL patch, while also temporary, could reduce the overall security of your console while active - this is because it no longer checks if a server is verified. However, this does not apply to the Internet Browser, where SSL still works as expected.
|
Malamar's patches are all temporary, and only applied in-memory without modifying your console. The SSL patch, while also temporary, could reduce the overall security of your console while active - this is because it no longer checks if a server is verified. However, this does not apply to the Internet Browser, where SSL still works as expected.
|
||||||
|
|
||||||
## TODO
|
## Compiling - Docker
|
||||||
See [Issues](https://github.com/PretendoNetwork/Inkay/issues).
|
Malamar's dependencies and build tooling can be handled as a container, which is recommended for WUPS plugins. Using `docker` or `podman`:
|
||||||
|
```shell
|
||||||
|
docker build -t malamar .
|
||||||
|
docker run --rm -v $(pwd):/app malamar make
|
||||||
|
# you can replace "make" with other commands - e.g. make clean
|
||||||
|
```
|
||||||
|
If using `podman` on SELinux systems (like Fedora Linux), you might need to use `$(pwd):/app:Z` instead of `$(pwd):/app`.
|
||||||
|
|
||||||
|
## Compiling - System
|
||||||
|
Malamar has the following dependencies aside from devkitPPC and wut:
|
||||||
|
- [WiiUPluginSystem](https://github.com/wiiu-env/WiiUPluginSystem)
|
||||||
|
- [WiiUModuleSystem](https://github.com/wiiu-env/WiiUModuleSystem)
|
||||||
|
- [libmocha](https://github.com/wiiu-env/libmocha)
|
||||||
|
- [libkernel](https://github.com/wiiu-env/libkernel/)
|
||||||
|
- [libnotifications](https://github.com/wiiu-env/libnotifications/)
|
||||||
|
- [libfunctionpatcher](https://github.com/wiiu-env/libfunctionpatcher)
|
||||||
|
|
||||||
|
Each of these should be `make install`-able. After that, you can compile Malamar with `make`.
|
||||||
|
|
|
||||||
31
common/Notification.cpp
Normal file
31
common/Notification.cpp
Normal file
|
|
@ -0,0 +1,31 @@
|
||||||
|
/* Copyright 2024 Pretendo Network contributors <pretendo.network>
|
||||||
|
|
||||||
|
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 "Notification.h"
|
||||||
|
#include <notifications/notification_defines.h>
|
||||||
|
#include <notifications/notifications.h>
|
||||||
|
|
||||||
|
void ShowNotification(const char* notification) {
|
||||||
|
auto err1 = NotificationModule_SetDefaultValue(NOTIFICATION_MODULE_NOTIFICATION_TYPE_INFO,
|
||||||
|
NOTIFICATION_MODULE_DEFAULT_OPTION_KEEP_UNTIL_SHOWN, true);
|
||||||
|
auto err2 = NotificationModule_SetDefaultValue(NOTIFICATION_MODULE_NOTIFICATION_TYPE_INFO,
|
||||||
|
NOTIFICATION_MODULE_DEFAULT_OPTION_DURATION_BEFORE_FADE_OUT,
|
||||||
|
15.0f);
|
||||||
|
|
||||||
|
if (err1 != NOTIFICATION_MODULE_RESULT_SUCCESS || err2 != NOTIFICATION_MODULE_RESULT_SUCCESS) return;
|
||||||
|
|
||||||
|
NotificationModule_AddInfoNotification(notification);
|
||||||
|
}
|
||||||
3
common/Notification.h
Normal file
3
common/Notification.h
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
void ShowNotification(const char* notification);
|
||||||
21
common/inkay_config.h
Normal file
21
common/inkay_config.h
Normal file
|
|
@ -0,0 +1,21 @@
|
||||||
|
//
|
||||||
|
// Created by ash on 17/12/24.
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef INKAY_INKAY_CONFIG_H
|
||||||
|
#define INKAY_INKAY_CONFIG_H
|
||||||
|
|
||||||
|
#ifdef __has_include
|
||||||
|
#if __has_include("inkay_config.local.h")
|
||||||
|
|
||||||
|
#include "inkay_config.local.h"
|
||||||
|
#define INKAY_CUSTOM 1
|
||||||
|
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef NETWORK_BASEURL
|
||||||
|
#define NETWORK_BASEURL "spbr.net"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif //INKAY_INKAY_CONFIG_H
|
||||||
47
common/lang.cpp
Normal file
47
common/lang.cpp
Normal file
|
|
@ -0,0 +1,47 @@
|
||||||
|
//
|
||||||
|
// Created by ash on 21/11/24.
|
||||||
|
//
|
||||||
|
|
||||||
|
#include "lang.h"
|
||||||
|
|
||||||
|
config_strings get_config_strings(inkay_language language) {
|
||||||
|
switch (language) {
|
||||||
|
case inkay_language::English:
|
||||||
|
default: return {
|
||||||
|
#include "en_US.lang"
|
||||||
|
};
|
||||||
|
case inkay_language::Spanish: return {
|
||||||
|
#include "es_ES.lang"
|
||||||
|
};
|
||||||
|
case inkay_language::French: return {
|
||||||
|
#include "fr_FR.lang"
|
||||||
|
};
|
||||||
|
case inkay_language::Italian: return {
|
||||||
|
#include "it_IT.lang"
|
||||||
|
};
|
||||||
|
case inkay_language::German: return {
|
||||||
|
#include "de_DE.lang"
|
||||||
|
};
|
||||||
|
case inkay_language::SimplifiedChinese: return {
|
||||||
|
#include "zh_CN.lang"
|
||||||
|
};
|
||||||
|
case inkay_language::Portuguese: return {
|
||||||
|
#include "pt_BR.lang"
|
||||||
|
};
|
||||||
|
case inkay_language::Japanese: return {
|
||||||
|
#include "ja_JP.lang"
|
||||||
|
};
|
||||||
|
case inkay_language::Dutch: return {
|
||||||
|
#include "nl_NL.lang"
|
||||||
|
};
|
||||||
|
case inkay_language::Russian: return {
|
||||||
|
#include "ru_RU.lang"
|
||||||
|
};
|
||||||
|
case inkay_language::Korean: return {
|
||||||
|
#include "ko_KR.lang"
|
||||||
|
};
|
||||||
|
case inkay_language::EnUwU: return {
|
||||||
|
#include "en@uwu.lang"
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
47
common/lang.h
Normal file
47
common/lang.h
Normal file
|
|
@ -0,0 +1,47 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <string_view>
|
||||||
|
|
||||||
|
enum inkay_language {
|
||||||
|
// Wii U System Languages
|
||||||
|
Japanese = 0,
|
||||||
|
English,
|
||||||
|
French,
|
||||||
|
German,
|
||||||
|
Italian,
|
||||||
|
Spanish,
|
||||||
|
SimplifiedChinese,
|
||||||
|
Korean,
|
||||||
|
Dutch,
|
||||||
|
Portuguese,
|
||||||
|
Russian,
|
||||||
|
TraditionalChinese,
|
||||||
|
Invalid,
|
||||||
|
// Custom Languages
|
||||||
|
System,
|
||||||
|
EnUwU,
|
||||||
|
};
|
||||||
|
|
||||||
|
struct config_strings {
|
||||||
|
const char *plugin_name;
|
||||||
|
std::string_view network_category;
|
||||||
|
std::string_view connect_to_network_setting;
|
||||||
|
std::string_view show_startup_toast_setting;
|
||||||
|
std::string_view other_category;
|
||||||
|
std::string_view reset_wwp_setting;
|
||||||
|
std::string_view press_a_action;
|
||||||
|
std::string_view restart_to_apply_action;
|
||||||
|
std::string_view need_menu_action;
|
||||||
|
std::string_view using_nintendo_network;
|
||||||
|
std::string_view using_pretendo_network;
|
||||||
|
std::string_view multiplayer_port_display;
|
||||||
|
std::string_view module_not_found;
|
||||||
|
std::string_view module_init_not_found;
|
||||||
|
std::string_view setting_yes;
|
||||||
|
std::string_view setting_no;
|
||||||
|
std::string_view language_setting;
|
||||||
|
std::string_view language_name;
|
||||||
|
std::string_view system_language;
|
||||||
|
};
|
||||||
|
|
||||||
|
config_strings get_config_strings(inkay_language language);
|
||||||
115
common/sysconfig.cpp
Normal file
115
common/sysconfig.cpp
Normal file
|
|
@ -0,0 +1,115 @@
|
||||||
|
/* Copyright 2024 Pretendo Network contributors <pretendo.network>
|
||||||
|
Copyright 2024 Ash Logan <ash@heyquark.com>
|
||||||
|
Copyright 2020-2022 V10lator <v10lator@myway.de>
|
||||||
|
Copyright 2022 Xpl0itU <DaThinkingChair@protonmail.com>
|
||||||
|
|
||||||
|
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 "sysconfig.h"
|
||||||
|
#include "utils/logger.h"
|
||||||
|
#include "utils/scope_exit.h"
|
||||||
|
|
||||||
|
#include <coreinit/mcp.h>
|
||||||
|
#include <coreinit/userconfig.h>
|
||||||
|
#include <optional>
|
||||||
|
|
||||||
|
nn::swkbd::LanguageType get_system_language() {
|
||||||
|
static std::optional <nn::swkbd::LanguageType> cached_language{};
|
||||||
|
if (cached_language) return *cached_language;
|
||||||
|
|
||||||
|
UCHandle handle = UCOpen();
|
||||||
|
if (handle < 0) {
|
||||||
|
DEBUG_FUNCTION_LINE("Error opening UC: %d", handle);
|
||||||
|
return nn::swkbd::LanguageType::English;
|
||||||
|
}
|
||||||
|
scope_exit uc_c([&] { UCClose(handle); });
|
||||||
|
|
||||||
|
nn::swkbd::LanguageType language;
|
||||||
|
|
||||||
|
alignas(0x40) UCSysConfig settings = {
|
||||||
|
.name = "cafe.language",
|
||||||
|
.access = 0,
|
||||||
|
.dataType = UC_DATATYPE_UNSIGNED_INT,
|
||||||
|
.error = UC_ERROR_OK,
|
||||||
|
.dataSize = sizeof(language),
|
||||||
|
.data = &language,
|
||||||
|
};
|
||||||
|
|
||||||
|
UCError err = UCReadSysConfig(handle, 1, &settings);
|
||||||
|
if (err != UC_ERROR_OK) {
|
||||||
|
DEBUG_FUNCTION_LINE("Error reading UC: %d!", err);
|
||||||
|
return nn::swkbd::LanguageType::English;
|
||||||
|
}
|
||||||
|
|
||||||
|
DEBUG_FUNCTION_LINE_VERBOSE("System language found: %d", static_cast<int>(language));
|
||||||
|
cached_language = language;
|
||||||
|
return language;
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::optional<MCPSysProdSettings> mcp_config;
|
||||||
|
static std::optional<MCPSystemVersion> mcp_os_version;
|
||||||
|
static void get_mcp_config() {
|
||||||
|
int mcp = MCP_Open();
|
||||||
|
scope_exit mcp_c([&] { MCP_Close(mcp); });
|
||||||
|
|
||||||
|
alignas(0x40) MCPSysProdSettings config {};
|
||||||
|
if (MCP_GetSysProdSettings(mcp, &config)) {
|
||||||
|
DEBUG_FUNCTION_LINE("Could not get MCP system config!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
mcp_config = config;
|
||||||
|
|
||||||
|
//get os version
|
||||||
|
MCPSystemVersion os_version;
|
||||||
|
if (MCP_GetSystemVersion(mcp, &os_version)) {
|
||||||
|
DEBUG_FUNCTION_LINE("Could not get MCP system config!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
mcp_os_version = os_version;
|
||||||
|
|
||||||
|
DEBUG_FUNCTION_LINE_VERBOSE("Running on %d.%d.%d%c; %s%s",
|
||||||
|
os_version.major, os_version.minor, os_version.patch, os_version.region,
|
||||||
|
config.code_id, config.serial_id
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const char * get_console_serial() {
|
||||||
|
if (!mcp_config) get_mcp_config();
|
||||||
|
|
||||||
|
return mcp_config ? mcp_config->serial_id : "123456789";
|
||||||
|
}
|
||||||
|
|
||||||
|
MCPSystemVersion get_console_os_version() {
|
||||||
|
if (!mcp_os_version) get_mcp_config();
|
||||||
|
|
||||||
|
return mcp_os_version.value_or((MCPSystemVersion) { .major = 5, .minor = 5, .patch = 5, .region = 'E' });
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int digit(char a) {
|
||||||
|
if (a < '0' || a > '9') return 0;
|
||||||
|
return a - '0';
|
||||||
|
}
|
||||||
|
|
||||||
|
uint16_t get_console_peertopeer_port() {
|
||||||
|
const char * serial = get_console_serial();
|
||||||
|
|
||||||
|
uint16_t port = 50000 +
|
||||||
|
(digit(serial[4]) * 1000) +
|
||||||
|
(digit(serial[5]) * 100 ) +
|
||||||
|
(digit(serial[6]) * 10 ) +
|
||||||
|
(digit(serial[7]) * 1 );
|
||||||
|
|
||||||
|
return port;
|
||||||
|
}
|
||||||
16
common/sysconfig.h
Normal file
16
common/sysconfig.h
Normal file
|
|
@ -0,0 +1,16 @@
|
||||||
|
//
|
||||||
|
// Created by ash on 9/04/24.
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef INKAY_SYSCONFIG_H
|
||||||
|
#define INKAY_SYSCONFIG_H
|
||||||
|
|
||||||
|
#include <nn/swkbd.h>
|
||||||
|
#include <coreinit/mcp.h>
|
||||||
|
|
||||||
|
nn::swkbd::LanguageType get_system_language();
|
||||||
|
const char * get_console_serial();
|
||||||
|
MCPSystemVersion get_console_os_version();
|
||||||
|
unsigned short get_console_peertopeer_port();
|
||||||
|
|
||||||
|
#endif //INKAY_SYSCONFIG_H
|
||||||
13
common/utils/scope_exit.h
Normal file
13
common/utils/scope_exit.h
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
#pragma once
|
||||||
|
#include <functional>
|
||||||
|
|
||||||
|
// https://stackoverflow.com/a/61242721
|
||||||
|
template<typename F>
|
||||||
|
struct scope_exit
|
||||||
|
{
|
||||||
|
F func;
|
||||||
|
explicit scope_exit(F&& f): func(std::forward<F>(f)) {}
|
||||||
|
~scope_exit() { func(); }
|
||||||
|
};
|
||||||
|
|
||||||
|
template<typename F> scope_exit(F&& frv) -> scope_exit<F>;
|
||||||
149
plugin/Makefile
Normal file
149
plugin/Makefile
Normal file
|
|
@ -0,0 +1,149 @@
|
||||||
|
#-------------------------------------------------------------------------------
|
||||||
|
.SUFFIXES:
|
||||||
|
#-------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
ifeq ($(strip $(DEVKITPRO)),)
|
||||||
|
$(error "Please set DEVKITPRO in your environment. export DEVKITPRO=<path to>/devkitpro")
|
||||||
|
endif
|
||||||
|
|
||||||
|
TOPDIR ?= $(CURDIR)
|
||||||
|
|
||||||
|
include $(DEVKITPRO)/wups/share/wups_rules
|
||||||
|
|
||||||
|
WUT_ROOT := $(DEVKITPRO)/wut
|
||||||
|
WUMS_ROOT := $(DEVKITPRO)/wums
|
||||||
|
#-------------------------------------------------------------------------------
|
||||||
|
# TARGET is the name of the output
|
||||||
|
# BUILD is the directory where object files & intermediate files will be placed
|
||||||
|
# SOURCES is a list of directories containing source code
|
||||||
|
# DATA is a list of directories containing data files
|
||||||
|
# INCLUDES is a list of directories containing header files
|
||||||
|
#-------------------------------------------------------------------------------
|
||||||
|
TARGET := Malamar-spfn
|
||||||
|
BUILD := build
|
||||||
|
SOURCES := src src/utils ../common
|
||||||
|
DATA := data
|
||||||
|
INCLUDES := src ../src/lang ../common
|
||||||
|
#DEBUG := 1
|
||||||
|
|
||||||
|
#-------------------------------------------------------------------------------
|
||||||
|
# options for code generation
|
||||||
|
#-------------------------------------------------------------------------------
|
||||||
|
OPT := -Os -fno-exceptions -fno-asynchronous-unwind-tables
|
||||||
|
CFLAGS := -Wall -ffunction-sections -fdata-sections \
|
||||||
|
$(MACHDEP) $(OPT)
|
||||||
|
|
||||||
|
CFLAGS += $(INCLUDE) -D__WIIU__ -D__WUT__ -D__WUPS__
|
||||||
|
|
||||||
|
ifeq ($(DEBUG),1)
|
||||||
|
CFLAGS += -DDEBUG -g
|
||||||
|
endif
|
||||||
|
|
||||||
|
CXXFLAGS := $(CFLAGS) -std=c++20
|
||||||
|
|
||||||
|
ASFLAGS := -g $(ARCH)
|
||||||
|
LDFLAGS = -g $(ARCH) $(OPT) $(RPXSPECS) -Wl,-Map,$(notdir $*.map) -Wl,-gc-sections -Wl,--discard-all
|
||||||
|
|
||||||
|
LDFLAGS += $(WUPSSPECS)
|
||||||
|
|
||||||
|
LIBS := -lwups -lwut -lnotifications
|
||||||
|
|
||||||
|
#-------------------------------------------------------------------------------
|
||||||
|
# list of directories containing libraries, this must be the top level
|
||||||
|
# containing include and lib
|
||||||
|
#-------------------------------------------------------------------------------
|
||||||
|
LIBDIRS := $(PORTLIBS) $(WUMS_ROOT) $(WUPS_ROOT) $(WUT_ROOT)
|
||||||
|
|
||||||
|
#-------------------------------------------------------------------------------
|
||||||
|
# no real need to edit anything past this point unless you need to add additional
|
||||||
|
# rules for different file extensions
|
||||||
|
#-------------------------------------------------------------------------------
|
||||||
|
ifneq ($(BUILD),$(notdir $(CURDIR)))
|
||||||
|
#-------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
export OUTPUT := $(CURDIR)/$(TARGET)
|
||||||
|
export TOPDIR := $(CURDIR)
|
||||||
|
|
||||||
|
export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \
|
||||||
|
$(foreach dir,$(DATA),$(CURDIR)/$(dir))
|
||||||
|
|
||||||
|
export DEPSDIR := $(CURDIR)/$(BUILD)
|
||||||
|
|
||||||
|
CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
|
||||||
|
CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
|
||||||
|
SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
|
||||||
|
BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))
|
||||||
|
|
||||||
|
#-------------------------------------------------------------------------------
|
||||||
|
# use CXX for linking C++ projects, CC for standard C
|
||||||
|
#-------------------------------------------------------------------------------
|
||||||
|
ifeq ($(strip $(CPPFILES)),)
|
||||||
|
#-------------------------------------------------------------------------------
|
||||||
|
export LD := $(CC)
|
||||||
|
#-------------------------------------------------------------------------------
|
||||||
|
else
|
||||||
|
#-------------------------------------------------------------------------------
|
||||||
|
export LD := $(CXX)
|
||||||
|
#-------------------------------------------------------------------------------
|
||||||
|
endif
|
||||||
|
#-------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
export OFILES_BIN := $(addsuffix .o,$(BINFILES))
|
||||||
|
export OFILES_SRC := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o)
|
||||||
|
export OFILES := $(OFILES_BIN) $(OFILES_SRC)
|
||||||
|
export HFILES_BIN := $(addsuffix .h,$(subst .,_,$(BINFILES)))
|
||||||
|
|
||||||
|
export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \
|
||||||
|
$(foreach dir,$(LIBDIRS),-I$(dir)/include) \
|
||||||
|
-I$(CURDIR)/$(BUILD)
|
||||||
|
|
||||||
|
export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib)
|
||||||
|
|
||||||
|
.PHONY: $(BUILD) clean all
|
||||||
|
|
||||||
|
#-------------------------------------------------------------------------------
|
||||||
|
all: $(BUILD)
|
||||||
|
|
||||||
|
$(BUILD):
|
||||||
|
@$(shell [ ! -d $(BUILD) ] && mkdir -p $(BUILD))
|
||||||
|
@$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile
|
||||||
|
|
||||||
|
#-------------------------------------------------------------------------------
|
||||||
|
clean:
|
||||||
|
@echo clean ...
|
||||||
|
@rm -fr $(BUILD) $(TARGET).wps $(TARGET).elf
|
||||||
|
|
||||||
|
#-------------------------------------------------------------------------------
|
||||||
|
else
|
||||||
|
.PHONY: all
|
||||||
|
|
||||||
|
DEPENDS := $(OFILES:.o=.d)
|
||||||
|
|
||||||
|
#-------------------------------------------------------------------------------
|
||||||
|
# main targets
|
||||||
|
#-------------------------------------------------------------------------------
|
||||||
|
all : $(OUTPUT).wps
|
||||||
|
|
||||||
|
$(OUTPUT).wps : $(OUTPUT).elf
|
||||||
|
$(OUTPUT).elf : $(OFILES)
|
||||||
|
|
||||||
|
$(OFILES_SRC) : $(HFILES_BIN)
|
||||||
|
|
||||||
|
#-------------------------------------------------------------------------------
|
||||||
|
# you need a rule like this for each extension you use as binary data
|
||||||
|
#-------------------------------------------------------------------------------
|
||||||
|
%.bin.o %_bin.h : %.bin
|
||||||
|
#-------------------------------------------------------------------------------
|
||||||
|
@echo $(notdir $<)
|
||||||
|
@$(bin2o)
|
||||||
|
|
||||||
|
%.pem.o %_pem.h : %.pem
|
||||||
|
#-------------------------------------------------------------------------------
|
||||||
|
@echo $(notdir $<)
|
||||||
|
@$(bin2o)
|
||||||
|
|
||||||
|
-include $(DEPENDS)
|
||||||
|
|
||||||
|
#-------------------------------------------------------------------------------
|
||||||
|
endif
|
||||||
|
#-------------------------------------------------------------------------------
|
||||||
331
plugin/src/config.cpp
Normal file
331
plugin/src/config.cpp
Normal file
|
|
@ -0,0 +1,331 @@
|
||||||
|
/* Copyright 2022 Pretendo Network contributors <pretendo.network>
|
||||||
|
Copyright 2022 Ash Logan <ash@heyquark.com>
|
||||||
|
|
||||||
|
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 "config.h"
|
||||||
|
|
||||||
|
#include "wut_extra.h"
|
||||||
|
#include "utils/logger.h"
|
||||||
|
#include "sysconfig.h"
|
||||||
|
#include "lang.h"
|
||||||
|
|
||||||
|
#include <wups.h>
|
||||||
|
#include <wups/storage.h>
|
||||||
|
#include <wups/config_api.h>
|
||||||
|
#include <wups/config/WUPSConfigItemMultipleValues.h>
|
||||||
|
#include <wups/config/WUPSConfigItemBoolean.h>
|
||||||
|
#include <wups/config/WUPSConfigItemStub.h>
|
||||||
|
|
||||||
|
#include <coreinit/title.h>
|
||||||
|
#include <coreinit/launch.h>
|
||||||
|
#include <sysapp/title.h>
|
||||||
|
#include <sysapp/launch.h>
|
||||||
|
#include <nn/act.h>
|
||||||
|
|
||||||
|
#include <format>
|
||||||
|
|
||||||
|
static config_strings strings;
|
||||||
|
|
||||||
|
bool Config::connect_to_network = true;
|
||||||
|
bool Config::show_startup_toast = true;
|
||||||
|
bool Config::need_relaunch = false;
|
||||||
|
bool Config::unregister_task_item_pressed = false;
|
||||||
|
bool Config::is_wiiu_menu = false;
|
||||||
|
uint32_t Config::language = 13;
|
||||||
|
inkay_language Config::current_language = English;
|
||||||
|
|
||||||
|
static WUPSConfigAPICallbackStatus report_error(WUPSConfigAPIStatus err, int line) {
|
||||||
|
DEBUG_FUNCTION_LINE_VERBOSE("WUPS config error: %s (L%04d)", WUPSConfigAPI_GetStatusStr(err), line);
|
||||||
|
return WUPSCONFIG_API_CALLBACK_RESULT_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void report_storage_error(WUPSStorageError err) {
|
||||||
|
DEBUG_FUNCTION_LINE_VERBOSE("WUPS storage error: %s", WUPSStorageAPI_GetStatusStr(err));
|
||||||
|
}
|
||||||
|
|
||||||
|
static void connect_to_network_changed(ConfigItemBoolean *item, bool new_value) {
|
||||||
|
DEBUG_FUNCTION_LINE_VERBOSE("connect_to_network changed to: %d", new_value);
|
||||||
|
if (new_value != Config::connect_to_network) {
|
||||||
|
Config::need_relaunch = true;
|
||||||
|
}
|
||||||
|
Config::connect_to_network = new_value;
|
||||||
|
|
||||||
|
WUPSStorageError res = WUPSStorageAPI_StoreBool(nullptr, "connect_to_network", Config::connect_to_network);
|
||||||
|
if (res != WUPS_STORAGE_ERROR_SUCCESS) return report_storage_error(res);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void language_changed(ConfigItemMultipleValues *item, uint32_t new_value) {
|
||||||
|
DEBUG_FUNCTION_LINE_VERBOSE("language changed to: %d", new_value);
|
||||||
|
if (new_value != Config::language) {
|
||||||
|
if (new_value == inkay_language::System)
|
||||||
|
Config::current_language = (inkay_language) get_system_language();
|
||||||
|
else
|
||||||
|
Config::current_language = (inkay_language) new_value;
|
||||||
|
}
|
||||||
|
Config::language = new_value;
|
||||||
|
|
||||||
|
WUPSStorageError res = WUPSStorageAPI_StoreU32(nullptr, "language", Config::language);
|
||||||
|
if (res != WUPS_STORAGE_ERROR_SUCCESS) return report_storage_error(res);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void show_startup_toast_changed(ConfigItemBoolean *item, bool new_value) {
|
||||||
|
DEBUG_FUNCTION_LINE_VERBOSE("show_startup_toast changed to: %d", new_value);
|
||||||
|
Config::show_startup_toast = new_value;
|
||||||
|
|
||||||
|
WUPSStorageError res = WUPSStorageAPI_StoreBool(nullptr, "show_startup_toast", Config::show_startup_toast);
|
||||||
|
if (res != WUPS_STORAGE_ERROR_SUCCESS) return report_storage_error(res);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void unregister_task_item_on_input_cb(void *context, WUPSConfigSimplePadData input) {
|
||||||
|
if (!Config::unregister_task_item_pressed && Config::is_wiiu_menu && (
|
||||||
|
(input.buttons_d & WUPS_CONFIG_BUTTON_A) == WUPS_CONFIG_BUTTON_A)) {
|
||||||
|
nn::act::Initialize();
|
||||||
|
Initialize__Q2_2nn4bossFv();
|
||||||
|
|
||||||
|
for (uint8_t i = 1; i <= nn::act::GetNumOfAccounts(); i++) {
|
||||||
|
if (nn::act::IsSlotOccupied(i) && nn::act::IsNetworkAccountEx(i)) {
|
||||||
|
nn::boss::Task task{};
|
||||||
|
nn::act::PersistentId persistentId = nn::act::GetPersistentIdEx(i);
|
||||||
|
|
||||||
|
__ct__Q3_2nn4boss4TaskFv(&task);
|
||||||
|
Initialize__Q3_2nn4boss4TaskFPCcUi(&task, "oltopic", persistentId);
|
||||||
|
|
||||||
|
// bypasses compiler warning about unused variable
|
||||||
|
#ifdef DEBUG
|
||||||
|
uint32_t res = Unregister__Q3_2nn4boss4TaskFv(&task);
|
||||||
|
DEBUG_FUNCTION_LINE_VERBOSE("Unregistered oltopic for: SlotNo %d | Persistent ID %08x -> 0x%08x", i,
|
||||||
|
persistentId, res);
|
||||||
|
#else
|
||||||
|
Unregister__Q3_2nn4boss4TaskFv(&task);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Finalize__Q2_2nn4bossFv();
|
||||||
|
nn::act::Finalize();
|
||||||
|
|
||||||
|
Config::unregister_task_item_pressed = !Config::unregister_task_item_pressed;
|
||||||
|
Config::need_relaunch = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t unregister_task_item_get_display_value(void *context, char *out_buf, int32_t out_size) {
|
||||||
|
auto string = strings.need_menu_action;
|
||||||
|
if (Config::is_wiiu_menu) {
|
||||||
|
if (Config::unregister_task_item_pressed) {
|
||||||
|
string = strings.restart_to_apply_action;
|
||||||
|
} else {
|
||||||
|
string = strings.press_a_action;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((int) string.length() > out_size - 1) return -1;
|
||||||
|
string.copy(out_buf, string.length());
|
||||||
|
out_buf[string.length()] = '\0';
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static WUPSConfigAPICallbackStatus ConfigMenuOpenedCallback(WUPSConfigCategoryHandle root_cat) {
|
||||||
|
WUPSConfigAPIStatus err;
|
||||||
|
|
||||||
|
uint64_t current_title_id = OSGetTitleID();
|
||||||
|
uint64_t wiiu_menu_tid = _SYSGetSystemApplicationTitleId(SYSTEM_APP_ID_WII_U_MENU);
|
||||||
|
Config::is_wiiu_menu = (current_title_id == wiiu_menu_tid);
|
||||||
|
|
||||||
|
// get translation strings
|
||||||
|
strings = get_config_strings(Config::current_language);
|
||||||
|
|
||||||
|
// Network submenu
|
||||||
|
// Connect to Pretendo Network Yes/No
|
||||||
|
// Using UDP port 5000 for multiplayer
|
||||||
|
|
||||||
|
WUPSConfigCategoryHandle network_cat;
|
||||||
|
err = WUPSConfigAPI_Category_Create({strings.network_category.data()}, &network_cat);
|
||||||
|
if (err != WUPSCONFIG_API_RESULT_SUCCESS) return report_error(err, __LINE__);
|
||||||
|
|
||||||
|
WUPSConfigItemHandle connect_item;
|
||||||
|
err = WUPSConfigItemBoolean_CreateEx(
|
||||||
|
"connect_to_network", strings.connect_to_network_setting.data(), true, Config::connect_to_network,
|
||||||
|
&connect_to_network_changed, strings.setting_yes.data(), strings.setting_no.data(), &connect_item);
|
||||||
|
if (err != WUPSCONFIG_API_RESULT_SUCCESS) return report_error(err, __LINE__);
|
||||||
|
|
||||||
|
err = WUPSConfigAPI_Category_AddItem(network_cat, connect_item);
|
||||||
|
if (err != WUPSCONFIG_API_RESULT_SUCCESS) return report_error(err, __LINE__);
|
||||||
|
|
||||||
|
const uint16_t port = get_console_peertopeer_port();
|
||||||
|
char buffer[256];
|
||||||
|
snprintf(buffer, sizeof(buffer), strings.multiplayer_port_display.data(), port);
|
||||||
|
|
||||||
|
WUPSConfigItemHandle multiplayer_port_display;
|
||||||
|
err = WUPSConfigItemStub_Create(buffer, &multiplayer_port_display);
|
||||||
|
if (err != WUPSCONFIG_API_RESULT_SUCCESS) return report_error(err, __LINE__);
|
||||||
|
|
||||||
|
err = WUPSConfigAPI_Category_AddItem(network_cat, multiplayer_port_display);
|
||||||
|
if (err != WUPSCONFIG_API_RESULT_SUCCESS) return report_error(err, __LINE__);
|
||||||
|
|
||||||
|
// Add to root and finish
|
||||||
|
err = WUPSConfigAPI_Category_AddCategory(root_cat, network_cat);
|
||||||
|
if (err != WUPSCONFIG_API_RESULT_SUCCESS) return report_error(err, __LINE__);
|
||||||
|
|
||||||
|
// Other category
|
||||||
|
// Reset Wara Wara Plaza Press A
|
||||||
|
// Language English/Spanish/etc..
|
||||||
|
// Show startup toast Yes/No
|
||||||
|
|
||||||
|
WUPSConfigCategoryHandle other_cat;
|
||||||
|
err = WUPSConfigAPI_Category_Create({strings.other_category.data()}, &other_cat);
|
||||||
|
if (err != WUPSCONFIG_API_RESULT_SUCCESS) return report_error(err, __LINE__);
|
||||||
|
|
||||||
|
WUPSConfigItemHandle unregisterTasksItem;
|
||||||
|
err = WUPSConfigAPI_Item_Create({
|
||||||
|
.displayName = strings.reset_wwp_setting.data(),
|
||||||
|
.context = nullptr,
|
||||||
|
.callbacks = {
|
||||||
|
.getCurrentValueDisplay = unregister_task_item_get_display_value,
|
||||||
|
.getCurrentValueSelectedDisplay = unregister_task_item_get_display_value,
|
||||||
|
.onSelected = nullptr,
|
||||||
|
.restoreDefault = nullptr,
|
||||||
|
.isMovementAllowed = nullptr,
|
||||||
|
.onCloseCallback = nullptr,
|
||||||
|
.onInput = unregister_task_item_on_input_cb,
|
||||||
|
.onInputEx = nullptr,
|
||||||
|
.onDelete = nullptr
|
||||||
|
},
|
||||||
|
}, &unregisterTasksItem);
|
||||||
|
if (err != WUPSCONFIG_API_RESULT_SUCCESS) return report_error(err, __LINE__);
|
||||||
|
|
||||||
|
err = WUPSConfigAPI_Category_AddItem(other_cat, unregisterTasksItem);
|
||||||
|
if (err != WUPSCONFIG_API_RESULT_SUCCESS) return report_error(err, __LINE__);
|
||||||
|
|
||||||
|
// TODO localise these!
|
||||||
|
constexpr std::array<ConfigItemMultipleValuesPair, 14> languages = {
|
||||||
|
{
|
||||||
|
{0, "Japanese"},
|
||||||
|
{1, "English"},
|
||||||
|
{2, "French"},
|
||||||
|
{3, "German"},
|
||||||
|
{4, "Italian"},
|
||||||
|
{5, "Spanish"},
|
||||||
|
{6, "Simplified Chinese"},
|
||||||
|
{7, "Korean"},
|
||||||
|
{8, "Dutch"},
|
||||||
|
{9, "Portuguese"},
|
||||||
|
{10, "Russian"},
|
||||||
|
{11, "Traditional Chinese"},
|
||||||
|
{13, "System"},
|
||||||
|
{14, "English (UwU)"},
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
constexpr auto find_lang = [languages](const uint32_t lang) -> int {
|
||||||
|
return std::ranges::find_if(languages, [lang](auto const l) { return l.value == lang; }) -
|
||||||
|
std::begin(languages);
|
||||||
|
};
|
||||||
|
constexpr int system_language = find_lang(13 /* System */);
|
||||||
|
const int current_language = find_lang(Config::language);
|
||||||
|
|
||||||
|
WUPSConfigItemHandle language_item;
|
||||||
|
err = WUPSConfigItemMultipleValues_Create("language", strings.language_setting.data(), system_language,
|
||||||
|
current_language,
|
||||||
|
const_cast<ConfigItemMultipleValuesPair *>(languages.data()), // Yikes!
|
||||||
|
languages.size(), &language_changed, &language_item);
|
||||||
|
if (err != WUPSCONFIG_API_RESULT_SUCCESS) return report_error(err, __LINE__);
|
||||||
|
|
||||||
|
err = WUPSConfigAPI_Category_AddItem(other_cat, language_item);
|
||||||
|
if (err != WUPSCONFIG_API_RESULT_SUCCESS) return report_error(err, __LINE__);
|
||||||
|
|
||||||
|
WUPSConfigItemHandle startup_toast_item;
|
||||||
|
err = WUPSConfigItemBoolean_CreateEx("show_startup_toast", strings.show_startup_toast_setting.data(), true,
|
||||||
|
Config::show_startup_toast, &show_startup_toast_changed,
|
||||||
|
strings.setting_yes.data(), strings.setting_no.data(), &startup_toast_item);
|
||||||
|
if (err != WUPSCONFIG_API_RESULT_SUCCESS) return report_error(err, __LINE__);
|
||||||
|
|
||||||
|
err = WUPSConfigAPI_Category_AddItem(other_cat, startup_toast_item);
|
||||||
|
if (err != WUPSCONFIG_API_RESULT_SUCCESS) return report_error(err, __LINE__);
|
||||||
|
|
||||||
|
// finish up
|
||||||
|
err = WUPSConfigAPI_Category_AddCategory(root_cat, other_cat);
|
||||||
|
if (err != WUPSCONFIG_API_RESULT_SUCCESS) return report_error(err, __LINE__);
|
||||||
|
|
||||||
|
return WUPSCONFIG_API_CALLBACK_RESULT_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ConfigMenuClosedCallback() {
|
||||||
|
// Save all changes
|
||||||
|
WUPSStorageError res = WUPSStorageAPI_SaveStorage(false);
|
||||||
|
if (res != WUPS_STORAGE_ERROR_SUCCESS) return report_storage_error(res);
|
||||||
|
|
||||||
|
if (Config::need_relaunch) {
|
||||||
|
// Need to reload the console so the patches reset
|
||||||
|
OSForceFullRelaunch();
|
||||||
|
SYSLaunchMenu();
|
||||||
|
Config::need_relaunch = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Config::Init() {
|
||||||
|
// Init the config api
|
||||||
|
WUPSConfigAPIStatus cres =
|
||||||
|
WUPSConfigAPI_Init({.name = "Inkay"}, ConfigMenuOpenedCallback, ConfigMenuClosedCallback);
|
||||||
|
if (cres != WUPSCONFIG_API_RESULT_SUCCESS) return (void) report_error(cres, __LINE__);
|
||||||
|
|
||||||
|
WUPSStorageError res;
|
||||||
|
// Try to get values from storage
|
||||||
|
res = WUPSStorageAPI_GetBool(nullptr, "connect_to_network", &Config::connect_to_network);
|
||||||
|
if (res == WUPS_STORAGE_ERROR_NOT_FOUND) {
|
||||||
|
DEBUG_FUNCTION_LINE_VERBOSE("Connect to network value not found, attempting to migrate/create");
|
||||||
|
|
||||||
|
bool skipPatches = false;
|
||||||
|
if (WUPSStorageAPI_GetBool(nullptr, "skipPatches", &skipPatches) == WUPS_STORAGE_ERROR_SUCCESS) {
|
||||||
|
// Migrate old config value
|
||||||
|
Config::connect_to_network = !skipPatches;
|
||||||
|
WUPSStorageAPI_DeleteItem(nullptr, "skipPatches");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add the value to the storage if it's missing.
|
||||||
|
res = WUPSStorageAPI_StoreBool(nullptr, "connect_to_network", connect_to_network);
|
||||||
|
if (res != WUPS_STORAGE_ERROR_SUCCESS) return report_storage_error(res);
|
||||||
|
} else if (res != WUPS_STORAGE_ERROR_SUCCESS) return report_storage_error(res);
|
||||||
|
|
||||||
|
res = WUPSStorageAPI_GetU32(nullptr, "language", &Config::language);
|
||||||
|
if (res == WUPS_STORAGE_ERROR_NOT_FOUND) {
|
||||||
|
DEBUG_FUNCTION_LINE_VERBOSE("Language value not found, attempting to create");
|
||||||
|
|
||||||
|
// Add the value to the storage.
|
||||||
|
res = WUPSStorageAPI_StoreU32(nullptr, "language", Config::language);
|
||||||
|
if (res != WUPS_STORAGE_ERROR_SUCCESS) return report_storage_error(res);
|
||||||
|
} else if (res != WUPS_STORAGE_ERROR_SUCCESS) return report_storage_error(res);
|
||||||
|
|
||||||
|
res = WUPSStorageAPI_GetBool(nullptr, "show_startup_toast", &Config::show_startup_toast);
|
||||||
|
if (res == WUPS_STORAGE_ERROR_NOT_FOUND) {
|
||||||
|
DEBUG_FUNCTION_LINE_VERBOSE("Show startup toast value not found, attempting to create");
|
||||||
|
|
||||||
|
// Add the value to the storage if it's missing.
|
||||||
|
res = WUPSStorageAPI_StoreBool(nullptr, "show_startup_toast", show_startup_toast);
|
||||||
|
if (res != WUPS_STORAGE_ERROR_SUCCESS) return report_storage_error(res);
|
||||||
|
} else if (res != WUPS_STORAGE_ERROR_SUCCESS) return report_storage_error(res);
|
||||||
|
|
||||||
|
// Set the language that's currently used
|
||||||
|
if (Config::language == inkay_language::System)
|
||||||
|
Config::current_language = (inkay_language) get_system_language();
|
||||||
|
else
|
||||||
|
Config::current_language = (inkay_language) Config::language;
|
||||||
|
|
||||||
|
// Save storage
|
||||||
|
res = WUPSStorageAPI_SaveStorage(false);
|
||||||
|
if (res != WUPS_STORAGE_ERROR_SUCCESS) return report_storage_error(res);
|
||||||
|
}
|
||||||
31
plugin/src/config.h
Normal file
31
plugin/src/config.h
Normal file
|
|
@ -0,0 +1,31 @@
|
||||||
|
//
|
||||||
|
// Created by ash on 10/12/22.
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef INKAY_CONFIG_H
|
||||||
|
#define INKAY_CONFIG_H
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
#include "lang.h"
|
||||||
|
|
||||||
|
class Config {
|
||||||
|
public:
|
||||||
|
static void Init();
|
||||||
|
|
||||||
|
// wups config items
|
||||||
|
static bool connect_to_network;
|
||||||
|
static uint32_t language;
|
||||||
|
|
||||||
|
static bool show_startup_toast;
|
||||||
|
|
||||||
|
// private stuff
|
||||||
|
static bool need_relaunch;
|
||||||
|
|
||||||
|
// private stuff
|
||||||
|
static bool is_wiiu_menu;
|
||||||
|
|
||||||
|
static inkay_language current_language;
|
||||||
|
static bool unregister_task_item_pressed;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif //INKAY_CONFIG_H
|
||||||
152
plugin/src/main.cpp
Normal file
152
plugin/src/main.cpp
Normal file
|
|
@ -0,0 +1,152 @@
|
||||||
|
/* Copyright 2022 Pretendo Network contributors <pretendo.network>
|
||||||
|
Copyright 2022 Ash Logan <ash@heyquark.com>
|
||||||
|
Copyright 2019 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 <wups.h>
|
||||||
|
|
||||||
|
#include <notifications/notifications.h>
|
||||||
|
#include <utils/logger.h>
|
||||||
|
#include "config.h"
|
||||||
|
#include<coreinit/title.h>
|
||||||
|
#include<coreinit/dynload.h>
|
||||||
|
#include<vector>
|
||||||
|
#include "module.h"
|
||||||
|
|
||||||
|
#define INKAY_VERSION "v3.1.0"
|
||||||
|
|
||||||
|
/**
|
||||||
|
Mandatory plugin information.
|
||||||
|
If not set correctly, the loader will refuse to use the plugin.
|
||||||
|
**/
|
||||||
|
WUPS_META(name, "Malamar (SPFN)");
|
||||||
|
WUPS_META(wups, WUPS_VERSION_STR);
|
||||||
|
WUPS_USE_WUT_MALLOC();
|
||||||
|
WUPS_USE_WUT_SOCKETS();
|
||||||
|
WUPS_USE_WUT_NEWLIB();
|
||||||
|
WUPS___INIT_WRAPPER();
|
||||||
|
WUPS___FINI_WRAPPER();
|
||||||
|
WUPS_INIT_CONFIG_FUNCTIONS();
|
||||||
|
WUPS_META(buildtimestamp, __DATE__ " " __TIME__);
|
||||||
|
extern const char wups_meta_plugin_name[] WUPS_SECTION("meta");
|
||||||
|
const char wups_meta_plugin_name[] = "Malamar (SPFN)";
|
||||||
|
extern const char wups_meta_info_dump[] WUPS_SECTION("meta");
|
||||||
|
const char wups_meta_info_dump[] = "(plugin: Malamar (SPFN);" \
|
||||||
|
"wups " WUPS_VERSION_STR ";" \
|
||||||
|
"buildtime: " __DATE__ " " __TIME__ ")";
|
||||||
|
extern const char wups_meta_info_linking_order[] WUPS_SECTION("meta");
|
||||||
|
const char wups_meta_info_linking_order[] = "Loading \"Malamar (SPFN)\" failed.\n" \
|
||||||
|
"Function \"wut_get_thread_specific\" returned unexpected value.\n" \
|
||||||
|
"Please check linking order (expected \"-lwups -lwut\")";
|
||||||
|
|
||||||
|
WUPS_PLUGIN_DESCRIPTION("SPFN Network Patcher");
|
||||||
|
WUPS_PLUGIN_VERSION(INKAY_VERSION);
|
||||||
|
WUPS_PLUGIN_AUTHOR("redbinder0526, kittentm and Pretendo contributors");
|
||||||
|
WUPS_PLUGIN_LICENSE("GPLv3");
|
||||||
|
|
||||||
|
WUPS_USE_STORAGE("inkay");
|
||||||
|
|
||||||
|
WUPS_USE_WUT_DEVOPTAB();
|
||||||
|
|
||||||
|
bool is_current_game_splatoon(){
|
||||||
|
auto current_game = OSGetTitleID();
|
||||||
|
|
||||||
|
if(
|
||||||
|
current_game == 0x0005000010162B00 ||
|
||||||
|
current_game == 0x0005000010176900 ||
|
||||||
|
current_game == 0x0005000010176A00
|
||||||
|
){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void splatoon_patcher(){
|
||||||
|
if (!Config::connect_to_network) {
|
||||||
|
DEBUG_FUNCTION_LINE_VERBOSE("Inkay: Splatoon patches skipped");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if(is_current_game_splatoon()){
|
||||||
|
NotificationModule_AddInfoNotification("Splatoon Detected, applying patch");
|
||||||
|
|
||||||
|
auto rpl_count = OSDynLoad_GetNumberOfRPLs();
|
||||||
|
|
||||||
|
std::vector<OSDynLoad_NotifyData> rpls(rpl_count);
|
||||||
|
|
||||||
|
if(!OSDynLoad_GetRPLInfo(0, rpl_count, rpls.data())){
|
||||||
|
NotificationModule_AddInfoNotification("failed to get rpls");
|
||||||
|
}
|
||||||
|
|
||||||
|
for(auto rpl: rpls){
|
||||||
|
if(rpl.name != 0){
|
||||||
|
if(strstr(rpl.name, "Gambit") != NULL){
|
||||||
|
NotificationModule_AddInfoNotification(rpl.name);
|
||||||
|
auto text_color = NMColor();
|
||||||
|
text_color.r = 255;
|
||||||
|
text_color.g = 255;
|
||||||
|
text_color.b = 255;
|
||||||
|
text_color.a = 255;
|
||||||
|
|
||||||
|
auto bg_color = NMColor();
|
||||||
|
bg_color.r = 0;
|
||||||
|
bg_color.g = 0;
|
||||||
|
bg_color.b = 0;
|
||||||
|
bg_color.a = 0;
|
||||||
|
|
||||||
|
NotificationModule_AddInfoNotificationEx(rpl.name, 30.0f, text_color, bg_color, nullptr, nullptr, true);
|
||||||
|
|
||||||
|
NotificationModule_AddInfoNotification("applying patches!!!!");
|
||||||
|
|
||||||
|
void* game_data_region = (void*)rpl.dataAddr;
|
||||||
|
|
||||||
|
auto str_loc = (char*)(0x000009ac + (uint32_t)game_data_region);
|
||||||
|
|
||||||
|
strcpy(str_loc, "https://splatpost.spbr.net/post");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
INITIALIZE_PLUGIN() {
|
||||||
|
WHBLogCafeInit();
|
||||||
|
|
||||||
|
Config::Init();
|
||||||
|
|
||||||
|
if (NotificationModule_InitLibrary() != NOTIFICATION_MODULE_RESULT_SUCCESS) {
|
||||||
|
DEBUG_FUNCTION_LINE("NotificationModule_InitLibrary failed");
|
||||||
|
}
|
||||||
|
|
||||||
|
// if using pretendo then (try to) apply the ssl patches
|
||||||
|
Inkay_Initialize(Config::connect_to_network, Config::show_startup_toast);
|
||||||
|
}
|
||||||
|
|
||||||
|
DEINITIALIZE_PLUGIN() {
|
||||||
|
Inkay_Finalize();
|
||||||
|
NotificationModule_DeInitLibrary();
|
||||||
|
|
||||||
|
WHBLogCafeDeinit();
|
||||||
|
}
|
||||||
|
|
||||||
|
ON_APPLICATION_START() {
|
||||||
|
// Tell the module the plugin is running!
|
||||||
|
splatoon_patcher();
|
||||||
|
Inkay_SetPluginRunning();
|
||||||
|
}
|
||||||
|
|
||||||
|
ON_APPLICATION_ENDS() {
|
||||||
|
|
||||||
|
}
|
||||||
93
plugin/src/module.cpp
Normal file
93
plugin/src/module.cpp
Normal file
|
|
@ -0,0 +1,93 @@
|
||||||
|
/* Copyright 2024 Pretendo Network contributors <pretendo.network>
|
||||||
|
|
||||||
|
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 "module.h"
|
||||||
|
|
||||||
|
#include "Notification.h"
|
||||||
|
#include "utils/logger.h"
|
||||||
|
#include "config.h"
|
||||||
|
#include "lang.h"
|
||||||
|
|
||||||
|
#include <coreinit/dynload.h>
|
||||||
|
|
||||||
|
static OSDynLoad_Module module;
|
||||||
|
static void (*moduleInitialize)(bool, bool, inkay_language) = nullptr;
|
||||||
|
static InkayStatus (*moduleGetStatus)() = nullptr;
|
||||||
|
static void (*moduleSetPluginRunning)() = nullptr;
|
||||||
|
|
||||||
|
static const char *get_module_not_found_message() {
|
||||||
|
return get_config_strings(Config::current_language).module_not_found.data();
|
||||||
|
}
|
||||||
|
|
||||||
|
static const char *get_module_init_not_found_message() {
|
||||||
|
return get_config_strings(Config::current_language).module_init_not_found.data();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Inkay_Initialize(bool apply_patches, bool show_startup_toast) {
|
||||||
|
if (module) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (OSDynLoad_Acquire("inkay", &module) != OS_DYNLOAD_OK) {
|
||||||
|
DEBUG_FUNCTION_LINE("Failed to acquire module");
|
||||||
|
ShowNotification(get_module_not_found_message());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (OSDynLoad_FindExport(module, OS_DYNLOAD_EXPORT_FUNC, "Inkay_Initialize", reinterpret_cast<void * *>(&moduleInitialize)) != OS_DYNLOAD_OK) {
|
||||||
|
DEBUG_FUNCTION_LINE("Failed to find function %s", "Inkay_Initialize");
|
||||||
|
ShowNotification(get_module_init_not_found_message());
|
||||||
|
OSDynLoad_Release(module);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
moduleInitialize(apply_patches, show_startup_toast, Config::current_language);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Inkay_Finalize() {
|
||||||
|
if (module) {
|
||||||
|
OSDynLoad_Release(module);
|
||||||
|
moduleInitialize = nullptr;
|
||||||
|
moduleGetStatus = nullptr;
|
||||||
|
moduleSetPluginRunning = nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
InkayStatus Inkay_GetStatus() {
|
||||||
|
if (!module) {
|
||||||
|
return InkayStatus::Error;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!moduleGetStatus && OSDynLoad_FindExport(module, OS_DYNLOAD_EXPORT_FUNC, "Inkay_GetStatus", reinterpret_cast<void * *>(&moduleGetStatus)) != OS_DYNLOAD_OK) {
|
||||||
|
DEBUG_FUNCTION_LINE("Failed to find function %s", "Inkay_GetStatus");
|
||||||
|
return InkayStatus::Error;
|
||||||
|
}
|
||||||
|
|
||||||
|
return moduleGetStatus();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Inkay_SetPluginRunning() {
|
||||||
|
if (!module) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!moduleSetPluginRunning && OSDynLoad_FindExport(module, OS_DYNLOAD_EXPORT_FUNC, "Inkay_SetPluginRunning", reinterpret_cast<void * *>(&moduleSetPluginRunning)) != OS_DYNLOAD_OK) {
|
||||||
|
DEBUG_FUNCTION_LINE("Failed to find function %s", "Inkay_SetPluginRunning");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
moduleSetPluginRunning();
|
||||||
|
}
|
||||||
30
plugin/src/module.h
Normal file
30
plugin/src/module.h
Normal file
|
|
@ -0,0 +1,30 @@
|
||||||
|
/* Copyright 2024 Pretendo Network contributors <pretendo.network>
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
enum class InkayStatus {
|
||||||
|
Uninitialized, ///< The module isn't initialized
|
||||||
|
Nintendo, ///< The module is initialized but hasn't applied any patches
|
||||||
|
Pretendo, ///< The module is initialized and has applied the Pretendo patches
|
||||||
|
|
||||||
|
Error = -1 ///< Failed to retrieve the module status
|
||||||
|
};
|
||||||
|
|
||||||
|
void Inkay_Initialize(bool apply_patches, bool show_startup_toast);
|
||||||
|
void Inkay_Finalize();
|
||||||
|
InkayStatus Inkay_GetStatus();
|
||||||
|
void Inkay_SetPluginRunning();
|
||||||
36
plugin/src/utils/logger.h
Normal file
36
plugin/src/utils/logger.h
Normal file
|
|
@ -0,0 +1,36 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
|
#include <whb/log.h>
|
||||||
|
#include <whb/log_module.h>
|
||||||
|
#include <whb/log_cafe.h>
|
||||||
|
#include <whb/log_udp.h>
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define __FILENAME_X__ (strrchr(__FILE__, '\\') ? strrchr(__FILE__, '\\') + 1 : __FILE__)
|
||||||
|
#define __FILENAME__ (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILENAME_X__)
|
||||||
|
|
||||||
|
#define OSFATAL_FUNCTION_LINE(FMT, ARGS...)do { \
|
||||||
|
OSFatal_printf("[(P) Inkay][%23s]%30s@L%04d: " FMT "",__FILENAME__,__FUNCTION__, __LINE__, ## ARGS); \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
|
#define DEBUG_FUNCTION_LINE(FMT, ARGS...)do { \
|
||||||
|
WHBLogPrintf("[(P) Inkay][%23s]%30s@L%04d: " FMT "",__FILENAME__,__FUNCTION__, __LINE__, ## ARGS); \
|
||||||
|
} while (0);
|
||||||
|
|
||||||
|
#define DEBUG_FUNCTION_LINE_WRITE(FMT, ARGS...)do { \
|
||||||
|
WHBLogWritef("[(P) Inkay][%23s]%30s@L%04d: " FMT "",__FILENAME__,__FUNCTION__, __LINE__, ## ARGS); \
|
||||||
|
} while (0);
|
||||||
|
|
||||||
|
#ifdef DEBUG
|
||||||
|
#define DEBUG_FUNCTION_LINE_VERBOSE(FMT, ARGS...) DEBUG_FUNCTION_LINE(FMT, ##ARGS)
|
||||||
|
#else
|
||||||
|
#define DEBUG_FUNCTION_LINE_VERBOSE(FMT, ARGS...) while (0);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
41
plugin/src/wut_extra.h
Normal file
41
plugin/src/wut_extra.h
Normal file
|
|
@ -0,0 +1,41 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <assert.h>
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
|
#include <nn/act.h>
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
namespace nn::boss {
|
||||||
|
class Task {
|
||||||
|
public:
|
||||||
|
nn::act::PersistentId persistentId;
|
||||||
|
uint32_t unk1;
|
||||||
|
char task_name[8];
|
||||||
|
uint64_t title_id;
|
||||||
|
uint32_t unk2;
|
||||||
|
uint32_t unk3;
|
||||||
|
};
|
||||||
|
|
||||||
|
static_assert(sizeof(Task) == 32, "nn::boss::Task must be 32 bytes.");
|
||||||
|
}
|
||||||
|
|
||||||
|
extern "C" uint32_t Initialize__Q2_2nn4bossFv();
|
||||||
|
extern "C" uint32_t Finalize__Q2_2nn4bossFv();
|
||||||
|
|
||||||
|
extern "C" void __ct__Q3_2nn4boss4TaskFv(nn::boss::Task *task);
|
||||||
|
extern "C" uint32_t Initialize__Q3_2nn4boss4TaskFPCcUi(nn::boss::Task *task, char const *, unsigned int);
|
||||||
|
extern "C" uint32_t Unregister__Q3_2nn4boss4TaskFv(nn::boss::Task *task);
|
||||||
|
extern "C" void __dt__Q3_2nn4boss4TaskFv(nn::boss::Task *task);
|
||||||
|
extern "C" uint32_t StartScheduling__Q3_2nn4boss4TaskFb(nn::boss::Task *task, bool queueTaskOnCall);
|
||||||
|
extern "C" uint32_t GetState__Q3_2nn4boss4TaskCFPUi(nn::boss::Task *task, uint32_t *outExecCount);
|
||||||
|
extern "C" uint32_t Run__Q3_2nn4boss4TaskFb(nn::boss::Task *task, bool unk);
|
||||||
|
extern "C" uint32_t UpdateIntervalSec__Q3_2nn4boss4TaskFUi(nn::boss::Task *task, uint32_t seconds);
|
||||||
|
extern "C" bool IsRegistered__Q3_2nn4boss4TaskCFv(nn::boss::Task *task);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
3
renovate.json
Normal file
3
renovate.json
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
{
|
||||||
|
"$schema": "https://docs.renovatebot.com/renovate-schema.json"
|
||||||
|
}
|
||||||
|
|
@ -1,39 +0,0 @@
|
||||||
#include "Notification.h"
|
|
||||||
#include <coreinit/cache.h>
|
|
||||||
#include <coreinit/thread.h>
|
|
||||||
#include <coreinit/title.h>
|
|
||||||
#include <notifications/notification_defines.h>
|
|
||||||
#include <notifications/notifications.h>
|
|
||||||
#include <thread>
|
|
||||||
|
|
||||||
static std::unique_ptr<std::thread> sShowHintThread;
|
|
||||||
static bool sShutdownHintThread = false;
|
|
||||||
|
|
||||||
void ShowNotification(const char * notification) {
|
|
||||||
// Wait for notification module to be ready
|
|
||||||
bool isOverlayReady = false;
|
|
||||||
while (!sShutdownHintThread && NotificationModule_IsOverlayReady(&isOverlayReady) == NOTIFICATION_MODULE_RESULT_SUCCESS && !isOverlayReady)
|
|
||||||
OSSleepTicks(OSMillisecondsToTicks(16));
|
|
||||||
if (sShutdownHintThread || !isOverlayReady) return;
|
|
||||||
NotificationModuleStatus err = NotificationModule_SetDefaultValue(NOTIFICATION_MODULE_NOTIFICATION_TYPE_INFO, NOTIFICATION_MODULE_DEFAULT_OPTION_DURATION_BEFORE_FADE_OUT, 15.0f);
|
|
||||||
if(err != NOTIFICATION_MODULE_RESULT_SUCCESS) return;
|
|
||||||
|
|
||||||
NotificationModule_AddInfoNotification(notification);
|
|
||||||
}
|
|
||||||
|
|
||||||
void StartNotificationThread(const char * value) {
|
|
||||||
uint64_t titleID = OSGetTitleID();
|
|
||||||
if (titleID == 0x0005001010040000L || titleID == 0x0005001010040100L || titleID == 0x0005001010040200L) {
|
|
||||||
sShutdownHintThread = false;
|
|
||||||
sShowHintThread = std::make_unique<std::thread>(ShowNotification, value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void StopNotificationThread() {
|
|
||||||
if (sShowHintThread != nullptr) {
|
|
||||||
sShutdownHintThread = true;
|
|
||||||
OSMemoryBarrier();
|
|
||||||
sShowHintThread->join();
|
|
||||||
sShowHintThread.reset();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,7 +0,0 @@
|
||||||
#pragma once
|
|
||||||
|
|
||||||
void ShowNotification(const char * notification);
|
|
||||||
|
|
||||||
void StartNotificationThread(const char * value);
|
|
||||||
|
|
||||||
void StopNotificationThread();
|
|
||||||
104
src/config.cpp
104
src/config.cpp
|
|
@ -1,85 +1,25 @@
|
||||||
//
|
/* Copyright 2022 Pretendo Network contributors <pretendo.network>
|
||||||
// Created by ash on 10/12/22.
|
Copyright 2022 Ash Logan <ash@heyquark.com>
|
||||||
//
|
|
||||||
|
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 "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#include "utils/logger.h"
|
bool Config::connect_to_network = false;
|
||||||
#include <wups.h>
|
bool Config::show_startup_toast = false;
|
||||||
#include <wups/config/WUPSConfigItemBoolean.h>
|
bool Config::initialized = false;
|
||||||
|
bool Config::shown_warning = false;
|
||||||
#include <coreinit/launch.h>
|
bool Config::plugin_is_loaded = false;
|
||||||
#include <sysapp/launch.h>
|
bool Config::block_initialize = false;
|
||||||
|
|
||||||
bool Config::connect_to_network = true;
|
|
||||||
bool Config::need_relaunch = false;
|
|
||||||
|
|
||||||
void Config::Init() {
|
|
||||||
WUPSStorageError storageRes = WUPS_OpenStorage();
|
|
||||||
if (storageRes != WUPS_STORAGE_ERROR_SUCCESS) {
|
|
||||||
DEBUG_FUNCTION_LINE("Failed to open storage %s (%d)", WUPS_GetStorageStatusStr(storageRes), storageRes);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
// Try to get value from storage
|
|
||||||
if ((storageRes = WUPS_GetBool(nullptr, "connect_to_network", &connect_to_network)) == WUPS_STORAGE_ERROR_NOT_FOUND) {
|
|
||||||
bool skipPatches = false;
|
|
||||||
if ((storageRes = WUPS_GetBool(nullptr, "skipPatches", &skipPatches)) != WUPS_STORAGE_ERROR_NOT_FOUND) {
|
|
||||||
// Migrate old config value
|
|
||||||
connect_to_network = !skipPatches;
|
|
||||||
}
|
|
||||||
// Add the value to the storage if it's missing.
|
|
||||||
if (WUPS_StoreBool(nullptr, "connect_to_network", connect_to_network) != WUPS_STORAGE_ERROR_SUCCESS) {
|
|
||||||
DEBUG_FUNCTION_LINE("Failed to store bool");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (storageRes != WUPS_STORAGE_ERROR_SUCCESS) {
|
|
||||||
DEBUG_FUNCTION_LINE("Failed to get bool %s (%d)", WUPS_GetStorageStatusStr(storageRes), storageRes);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Close storage
|
|
||||||
if (WUPS_CloseStorage() != WUPS_STORAGE_ERROR_SUCCESS) {
|
|
||||||
DEBUG_FUNCTION_LINE("Failed to close storage");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void connect_to_network_changed(ConfigItemBoolean* item, bool new_value) {
|
|
||||||
DEBUG_FUNCTION_LINE("New value in skipPatchesChanged: %d", new_value);
|
|
||||||
if (new_value != Config::connect_to_network) {
|
|
||||||
Config::need_relaunch = true;
|
|
||||||
}
|
|
||||||
Config::connect_to_network = new_value;
|
|
||||||
WUPS_StoreInt(nullptr, "connect_to_network", Config::connect_to_network);
|
|
||||||
}
|
|
||||||
|
|
||||||
WUPS_GET_CONFIG() {
|
|
||||||
// We open the storage so we can persist the configuration the user did.
|
|
||||||
if (WUPS_OpenStorage() != WUPS_STORAGE_ERROR_SUCCESS) {
|
|
||||||
DEBUG_FUNCTION_LINE("Failed to open storage");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
WUPSConfigHandle config;
|
|
||||||
WUPSConfig_CreateHandled(&config, "Inkay");
|
|
||||||
|
|
||||||
WUPSConfigCategoryHandle cat;
|
|
||||||
WUPSConfig_AddCategoryByNameHandled(config, "Patching", &cat);
|
|
||||||
|
|
||||||
WUPSConfigItemBoolean_AddToCategoryHandled(config, cat, "connect_to_network", "Connect to the Pretendo network", Config::connect_to_network, &connect_to_network_changed);
|
|
||||||
|
|
||||||
return config;
|
|
||||||
}
|
|
||||||
|
|
||||||
WUPS_CONFIG_CLOSED() {
|
|
||||||
// Save all changes
|
|
||||||
if (WUPS_CloseStorage() != WUPS_STORAGE_ERROR_SUCCESS) {
|
|
||||||
DEBUG_FUNCTION_LINE("Failed to close storage");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Config::need_relaunch) {
|
|
||||||
// Need to reload the console so the patches reset
|
|
||||||
OSForceFullRelaunch();
|
|
||||||
SYSLaunchMenu();
|
|
||||||
Config::need_relaunch = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
||||||
13
src/config.h
13
src/config.h
|
|
@ -7,13 +7,18 @@
|
||||||
|
|
||||||
class Config {
|
class Config {
|
||||||
public:
|
public:
|
||||||
static void Init();
|
|
||||||
|
|
||||||
// wups config items
|
|
||||||
static bool connect_to_network;
|
static bool connect_to_network;
|
||||||
|
|
||||||
// private stuff
|
static bool show_startup_toast;
|
||||||
static bool need_relaunch;
|
|
||||||
|
static bool initialized;
|
||||||
|
|
||||||
|
static bool shown_warning;
|
||||||
|
|
||||||
|
static bool plugin_is_loaded;
|
||||||
|
|
||||||
|
static bool block_initialize;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif //INKAY_CONFIG_H
|
#endif //INKAY_CONFIG_H
|
||||||
|
|
|
||||||
25
src/export.h
Normal file
25
src/export.h
Normal file
|
|
@ -0,0 +1,25 @@
|
||||||
|
/* Copyright 2024 Pretendo Network contributors <pretendo.network>
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
enum class InkayStatus {
|
||||||
|
Uninitialized, ///< The module isn't initialized
|
||||||
|
Nintendo, ///< The module is initialized but hasn't applied any patches
|
||||||
|
Pretendo, ///< The module is initialized and has applied the Pretendo patches
|
||||||
|
|
||||||
|
Error = -1 ///< Failed to retrieve the module status
|
||||||
|
};
|
||||||
27
src/ext/inih/LICENSE.txt
Normal file
27
src/ext/inih/LICENSE.txt
Normal file
|
|
@ -0,0 +1,27 @@
|
||||||
|
|
||||||
|
The "inih" library is distributed under the New BSD license:
|
||||||
|
|
||||||
|
Copyright (c) 2009, Ben Hoyt
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
modification, are permitted provided that the following conditions are met:
|
||||||
|
* Redistributions of source code must retain the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer.
|
||||||
|
* Redistributions in binary form must reproduce the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer in the
|
||||||
|
documentation and/or other materials provided with the distribution.
|
||||||
|
* Neither the name of Ben Hoyt nor the names of its contributors
|
||||||
|
may be used to endorse or promote products derived from this software
|
||||||
|
without specific prior written permission.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY BEN HOYT ''AS IS'' AND ANY
|
||||||
|
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
|
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
DISCLAIMED. IN NO EVENT SHALL BEN HOYT BE LIABLE FOR ANY
|
||||||
|
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
|
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
|
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
|
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
304
src/ext/inih/ini.c
Normal file
304
src/ext/inih/ini.c
Normal file
|
|
@ -0,0 +1,304 @@
|
||||||
|
/* inih -- simple .INI file parser
|
||||||
|
|
||||||
|
SPDX-License-Identifier: BSD-3-Clause
|
||||||
|
|
||||||
|
Copyright (C) 2009-2020, Ben Hoyt
|
||||||
|
|
||||||
|
inih is released under the New BSD license (see LICENSE.txt). Go to the project
|
||||||
|
home page for more info:
|
||||||
|
|
||||||
|
https://github.com/benhoyt/inih
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
#if defined(_MSC_VER) && !defined(_CRT_SECURE_NO_WARNINGS)
|
||||||
|
#define _CRT_SECURE_NO_WARNINGS
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <ctype.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#include "ini.h"
|
||||||
|
|
||||||
|
#if !INI_USE_STACK
|
||||||
|
#if INI_CUSTOM_ALLOCATOR
|
||||||
|
#include <stddef.h>
|
||||||
|
void* ini_malloc(size_t size);
|
||||||
|
void ini_free(void* ptr);
|
||||||
|
void* ini_realloc(void* ptr, size_t size);
|
||||||
|
#else
|
||||||
|
#include <stdlib.h>
|
||||||
|
#define ini_malloc malloc
|
||||||
|
#define ini_free free
|
||||||
|
#define ini_realloc realloc
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define MAX_SECTION 50
|
||||||
|
#define MAX_NAME 50
|
||||||
|
|
||||||
|
/* Used by ini_parse_string() to keep track of string parsing state. */
|
||||||
|
typedef struct {
|
||||||
|
const char* ptr;
|
||||||
|
size_t num_left;
|
||||||
|
} ini_parse_string_ctx;
|
||||||
|
|
||||||
|
/* Strip whitespace chars off end of given string, in place. Return s. */
|
||||||
|
static char* rstrip(char* s)
|
||||||
|
{
|
||||||
|
char* p = s + strlen(s);
|
||||||
|
while (p > s && isspace((unsigned char)(*--p)))
|
||||||
|
*p = '\0';
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Return pointer to first non-whitespace char in given string. */
|
||||||
|
static char* lskip(const char* s)
|
||||||
|
{
|
||||||
|
while (*s && isspace((unsigned char)(*s)))
|
||||||
|
s++;
|
||||||
|
return (char*)s;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Return pointer to first char (of chars) or inline comment in given string,
|
||||||
|
or pointer to NUL at end of string if neither found. Inline comment must
|
||||||
|
be prefixed by a whitespace character to register as a comment. */
|
||||||
|
static char* find_chars_or_comment(const char* s, const char* chars)
|
||||||
|
{
|
||||||
|
#if INI_ALLOW_INLINE_COMMENTS
|
||||||
|
int was_space = 0;
|
||||||
|
while (*s && (!chars || !strchr(chars, *s)) &&
|
||||||
|
!(was_space && strchr(INI_INLINE_COMMENT_PREFIXES, *s))) {
|
||||||
|
was_space = isspace((unsigned char)(*s));
|
||||||
|
s++;
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
while (*s && (!chars || !strchr(chars, *s))) {
|
||||||
|
s++;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
return (char*)s;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Similar to strncpy, but ensures dest (size bytes) is
|
||||||
|
NUL-terminated, and doesn't pad with NULs. */
|
||||||
|
static char* strncpy0(char* dest, const char* src, size_t size)
|
||||||
|
{
|
||||||
|
/* Could use strncpy internally, but it causes gcc warnings (see issue #91) */
|
||||||
|
size_t i;
|
||||||
|
for (i = 0; i < size - 1 && src[i]; i++)
|
||||||
|
dest[i] = src[i];
|
||||||
|
dest[i] = '\0';
|
||||||
|
return dest;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* See documentation in header file. */
|
||||||
|
int ini_parse_stream(ini_reader reader, void* stream, ini_handler handler,
|
||||||
|
void* user)
|
||||||
|
{
|
||||||
|
/* Uses a fair bit of stack (use heap instead if you need to) */
|
||||||
|
#if INI_USE_STACK
|
||||||
|
char line[INI_MAX_LINE];
|
||||||
|
size_t max_line = INI_MAX_LINE;
|
||||||
|
#else
|
||||||
|
char* line;
|
||||||
|
size_t max_line = INI_INITIAL_ALLOC;
|
||||||
|
#endif
|
||||||
|
#if INI_ALLOW_REALLOC && !INI_USE_STACK
|
||||||
|
char* new_line;
|
||||||
|
size_t offset;
|
||||||
|
#endif
|
||||||
|
char section[MAX_SECTION] = "";
|
||||||
|
char prev_name[MAX_NAME] = "";
|
||||||
|
|
||||||
|
char* start;
|
||||||
|
char* end;
|
||||||
|
char* name;
|
||||||
|
char* value;
|
||||||
|
int lineno = 0;
|
||||||
|
int error = 0;
|
||||||
|
|
||||||
|
#if !INI_USE_STACK
|
||||||
|
line = (char*)ini_malloc(INI_INITIAL_ALLOC);
|
||||||
|
if (!line) {
|
||||||
|
return -2;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if INI_HANDLER_LINENO
|
||||||
|
#define HANDLER(u, s, n, v) handler(u, s, n, v, lineno)
|
||||||
|
#else
|
||||||
|
#define HANDLER(u, s, n, v) handler(u, s, n, v)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Scan through stream line by line */
|
||||||
|
while (reader(line, (int)max_line, stream) != NULL) {
|
||||||
|
#if INI_ALLOW_REALLOC && !INI_USE_STACK
|
||||||
|
offset = strlen(line);
|
||||||
|
while (offset == max_line - 1 && line[offset - 1] != '\n') {
|
||||||
|
max_line *= 2;
|
||||||
|
if (max_line > INI_MAX_LINE)
|
||||||
|
max_line = INI_MAX_LINE;
|
||||||
|
new_line = ini_realloc(line, max_line);
|
||||||
|
if (!new_line) {
|
||||||
|
ini_free(line);
|
||||||
|
return -2;
|
||||||
|
}
|
||||||
|
line = new_line;
|
||||||
|
if (reader(line + offset, (int)(max_line - offset), stream) == NULL)
|
||||||
|
break;
|
||||||
|
if (max_line >= INI_MAX_LINE)
|
||||||
|
break;
|
||||||
|
offset += strlen(line + offset);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
lineno++;
|
||||||
|
|
||||||
|
start = line;
|
||||||
|
#if INI_ALLOW_BOM
|
||||||
|
if (lineno == 1 && (unsigned char)start[0] == 0xEF &&
|
||||||
|
(unsigned char)start[1] == 0xBB &&
|
||||||
|
(unsigned char)start[2] == 0xBF) {
|
||||||
|
start += 3;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
start = lskip(rstrip(start));
|
||||||
|
|
||||||
|
if (strchr(INI_START_COMMENT_PREFIXES, *start)) {
|
||||||
|
/* Start-of-line comment */
|
||||||
|
}
|
||||||
|
#if INI_ALLOW_MULTILINE
|
||||||
|
else if (*prev_name && *start && start > line) {
|
||||||
|
#if INI_ALLOW_INLINE_COMMENTS
|
||||||
|
end = find_chars_or_comment(start, NULL);
|
||||||
|
if (*end)
|
||||||
|
*end = '\0';
|
||||||
|
rstrip(start);
|
||||||
|
#endif
|
||||||
|
/* Non-blank line with leading whitespace, treat as continuation
|
||||||
|
of previous name's value (as per Python configparser). */
|
||||||
|
if (!HANDLER(user, section, prev_name, start) && !error)
|
||||||
|
error = lineno;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
else if (*start == '[') {
|
||||||
|
/* A "[section]" line */
|
||||||
|
end = find_chars_or_comment(start + 1, "]");
|
||||||
|
if (*end == ']') {
|
||||||
|
*end = '\0';
|
||||||
|
strncpy0(section, start + 1, sizeof(section));
|
||||||
|
*prev_name = '\0';
|
||||||
|
#if INI_CALL_HANDLER_ON_NEW_SECTION
|
||||||
|
if (!HANDLER(user, section, NULL, NULL) && !error)
|
||||||
|
error = lineno;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
else if (!error) {
|
||||||
|
/* No ']' found on section line */
|
||||||
|
error = lineno;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (*start) {
|
||||||
|
/* Not a comment, must be a name[=:]value pair */
|
||||||
|
end = find_chars_or_comment(start, "=:");
|
||||||
|
if (*end == '=' || *end == ':') {
|
||||||
|
*end = '\0';
|
||||||
|
name = rstrip(start);
|
||||||
|
value = end + 1;
|
||||||
|
#if INI_ALLOW_INLINE_COMMENTS
|
||||||
|
end = find_chars_or_comment(value, NULL);
|
||||||
|
if (*end)
|
||||||
|
*end = '\0';
|
||||||
|
#endif
|
||||||
|
value = lskip(value);
|
||||||
|
rstrip(value);
|
||||||
|
|
||||||
|
/* Valid name[=:]value pair found, call handler */
|
||||||
|
strncpy0(prev_name, name, sizeof(prev_name));
|
||||||
|
if (!HANDLER(user, section, name, value) && !error)
|
||||||
|
error = lineno;
|
||||||
|
}
|
||||||
|
else if (!error) {
|
||||||
|
/* No '=' or ':' found on name[=:]value line */
|
||||||
|
#if INI_ALLOW_NO_VALUE
|
||||||
|
*end = '\0';
|
||||||
|
name = rstrip(start);
|
||||||
|
if (!HANDLER(user, section, name, NULL) && !error)
|
||||||
|
error = lineno;
|
||||||
|
#else
|
||||||
|
error = lineno;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#if INI_STOP_ON_FIRST_ERROR
|
||||||
|
if (error)
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
#if !INI_USE_STACK
|
||||||
|
ini_free(line);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return error;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* See documentation in header file. */
|
||||||
|
int ini_parse_file(FILE* file, ini_handler handler, void* user)
|
||||||
|
{
|
||||||
|
return ini_parse_stream((ini_reader)fgets, file, handler, user);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* See documentation in header file. */
|
||||||
|
int ini_parse(const char* filename, ini_handler handler, void* user)
|
||||||
|
{
|
||||||
|
FILE* file;
|
||||||
|
int error;
|
||||||
|
|
||||||
|
file = fopen(filename, "r");
|
||||||
|
if (!file)
|
||||||
|
return -1;
|
||||||
|
error = ini_parse_file(file, handler, user);
|
||||||
|
fclose(file);
|
||||||
|
return error;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* An ini_reader function to read the next line from a string buffer. This
|
||||||
|
is the fgets() equivalent used by ini_parse_string(). */
|
||||||
|
static char* ini_reader_string(char* str, int num, void* stream) {
|
||||||
|
ini_parse_string_ctx* ctx = (ini_parse_string_ctx*)stream;
|
||||||
|
const char* ctx_ptr = ctx->ptr;
|
||||||
|
size_t ctx_num_left = ctx->num_left;
|
||||||
|
char* strp = str;
|
||||||
|
char c;
|
||||||
|
|
||||||
|
if (ctx_num_left == 0 || num < 2)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
while (num > 1 && ctx_num_left != 0) {
|
||||||
|
c = *ctx_ptr++;
|
||||||
|
ctx_num_left--;
|
||||||
|
*strp++ = c;
|
||||||
|
if (c == '\n')
|
||||||
|
break;
|
||||||
|
num--;
|
||||||
|
}
|
||||||
|
|
||||||
|
*strp = '\0';
|
||||||
|
ctx->ptr = ctx_ptr;
|
||||||
|
ctx->num_left = ctx_num_left;
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* See documentation in header file. */
|
||||||
|
int ini_parse_string(const char* string, ini_handler handler, void* user) {
|
||||||
|
ini_parse_string_ctx ctx;
|
||||||
|
|
||||||
|
ctx.ptr = string;
|
||||||
|
ctx.num_left = strlen(string);
|
||||||
|
return ini_parse_stream((ini_reader)ini_reader_string, &ctx, handler,
|
||||||
|
user);
|
||||||
|
}
|
||||||
178
src/ext/inih/ini.h
Normal file
178
src/ext/inih/ini.h
Normal file
|
|
@ -0,0 +1,178 @@
|
||||||
|
/* inih -- simple .INI file parser
|
||||||
|
|
||||||
|
SPDX-License-Identifier: BSD-3-Clause
|
||||||
|
|
||||||
|
Copyright (C) 2009-2020, Ben Hoyt
|
||||||
|
|
||||||
|
inih is released under the New BSD license (see LICENSE.txt). Go to the project
|
||||||
|
home page for more info:
|
||||||
|
|
||||||
|
https://github.com/benhoyt/inih
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef INI_H
|
||||||
|
#define INI_H
|
||||||
|
|
||||||
|
/* Make this header file easier to include in C++ code */
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
/* Nonzero if ini_handler callback should accept lineno parameter. */
|
||||||
|
#ifndef INI_HANDLER_LINENO
|
||||||
|
#define INI_HANDLER_LINENO 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Visibility symbols, required for Windows DLLs */
|
||||||
|
#ifndef INI_API
|
||||||
|
#if defined _WIN32 || defined __CYGWIN__
|
||||||
|
# ifdef INI_SHARED_LIB
|
||||||
|
# ifdef INI_SHARED_LIB_BUILDING
|
||||||
|
# define INI_API __declspec(dllexport)
|
||||||
|
# else
|
||||||
|
# define INI_API __declspec(dllimport)
|
||||||
|
# endif
|
||||||
|
# else
|
||||||
|
# define INI_API
|
||||||
|
# endif
|
||||||
|
#else
|
||||||
|
# if defined(__GNUC__) && __GNUC__ >= 4
|
||||||
|
# define INI_API __attribute__ ((visibility ("default")))
|
||||||
|
# else
|
||||||
|
# define INI_API
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Typedef for prototype of handler function. */
|
||||||
|
#if INI_HANDLER_LINENO
|
||||||
|
typedef int (*ini_handler)(void* user, const char* section,
|
||||||
|
const char* name, const char* value,
|
||||||
|
int lineno);
|
||||||
|
#else
|
||||||
|
typedef int (*ini_handler)(void* user, const char* section,
|
||||||
|
const char* name, const char* value);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Typedef for prototype of fgets-style reader function. */
|
||||||
|
typedef char* (*ini_reader)(char* str, int num, void* stream);
|
||||||
|
|
||||||
|
/* Parse given INI-style file. May have [section]s, name=value pairs
|
||||||
|
(whitespace stripped), and comments starting with ';' (semicolon). Section
|
||||||
|
is "" if name=value pair parsed before any section heading. name:value
|
||||||
|
pairs are also supported as a concession to Python's configparser.
|
||||||
|
|
||||||
|
For each name=value pair parsed, call handler function with given user
|
||||||
|
pointer as well as section, name, and value (data only valid for duration
|
||||||
|
of handler call). Handler should return nonzero on success, zero on error.
|
||||||
|
|
||||||
|
Returns 0 on success, line number of first error on parse error (doesn't
|
||||||
|
stop on first error), -1 on file open error, or -2 on memory allocation
|
||||||
|
error (only when INI_USE_STACK is zero).
|
||||||
|
*/
|
||||||
|
INI_API int ini_parse(const char* filename, ini_handler handler, void* user);
|
||||||
|
|
||||||
|
/* Same as ini_parse(), but takes a FILE* instead of filename. This doesn't
|
||||||
|
close the file when it's finished -- the caller must do that. */
|
||||||
|
INI_API int ini_parse_file(FILE* file, ini_handler handler, void* user);
|
||||||
|
|
||||||
|
/* Same as ini_parse(), but takes an ini_reader function pointer instead of
|
||||||
|
filename. Used for implementing custom or string-based I/O (see also
|
||||||
|
ini_parse_string). */
|
||||||
|
INI_API int ini_parse_stream(ini_reader reader, void* stream, ini_handler handler,
|
||||||
|
void* user);
|
||||||
|
|
||||||
|
/* Same as ini_parse(), but takes a zero-terminated string with the INI data
|
||||||
|
instead of a file. Useful for parsing INI data from a network socket or
|
||||||
|
already in memory. */
|
||||||
|
INI_API int ini_parse_string(const char* string, ini_handler handler, void* user);
|
||||||
|
|
||||||
|
/* Nonzero to allow multi-line value parsing, in the style of Python's
|
||||||
|
configparser. If allowed, ini_parse() will call the handler with the same
|
||||||
|
name for each subsequent line parsed. */
|
||||||
|
#ifndef INI_ALLOW_MULTILINE
|
||||||
|
#define INI_ALLOW_MULTILINE 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Nonzero to allow a UTF-8 BOM sequence (0xEF 0xBB 0xBF) at the start of
|
||||||
|
the file. See https://github.com/benhoyt/inih/issues/21 */
|
||||||
|
#ifndef INI_ALLOW_BOM
|
||||||
|
#define INI_ALLOW_BOM 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Chars that begin a start-of-line comment. Per Python configparser, allow
|
||||||
|
both ; and # comments at the start of a line by default. */
|
||||||
|
#ifndef INI_START_COMMENT_PREFIXES
|
||||||
|
#define INI_START_COMMENT_PREFIXES ";#"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Nonzero to allow inline comments (with valid inline comment characters
|
||||||
|
specified by INI_INLINE_COMMENT_PREFIXES). Set to 0 to turn off and match
|
||||||
|
Python 3.2+ configparser behaviour. */
|
||||||
|
#ifndef INI_ALLOW_INLINE_COMMENTS
|
||||||
|
#define INI_ALLOW_INLINE_COMMENTS 1
|
||||||
|
#endif
|
||||||
|
#ifndef INI_INLINE_COMMENT_PREFIXES
|
||||||
|
#define INI_INLINE_COMMENT_PREFIXES ";"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Nonzero to use stack for line buffer, zero to use heap (malloc/free). */
|
||||||
|
#ifndef INI_USE_STACK
|
||||||
|
#define INI_USE_STACK 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Maximum line length for any line in INI file (stack or heap). Note that
|
||||||
|
this must be 3 more than the longest line (due to '\r', '\n', and '\0'). */
|
||||||
|
#ifndef INI_MAX_LINE
|
||||||
|
#define INI_MAX_LINE 200
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Nonzero to allow heap line buffer to grow via realloc(), zero for a
|
||||||
|
fixed-size buffer of INI_MAX_LINE bytes. Only applies if INI_USE_STACK is
|
||||||
|
zero. */
|
||||||
|
#ifndef INI_ALLOW_REALLOC
|
||||||
|
#define INI_ALLOW_REALLOC 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Initial size in bytes for heap line buffer. Only applies if INI_USE_STACK
|
||||||
|
is zero. */
|
||||||
|
#ifndef INI_INITIAL_ALLOC
|
||||||
|
#define INI_INITIAL_ALLOC 200
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Stop parsing on first error (default is to keep parsing). */
|
||||||
|
#ifndef INI_STOP_ON_FIRST_ERROR
|
||||||
|
#define INI_STOP_ON_FIRST_ERROR 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Nonzero to call the handler at the start of each new section (with
|
||||||
|
name and value NULL). Default is to only call the handler on
|
||||||
|
each name=value pair. */
|
||||||
|
#ifndef INI_CALL_HANDLER_ON_NEW_SECTION
|
||||||
|
#define INI_CALL_HANDLER_ON_NEW_SECTION 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Nonzero to allow a name without a value (no '=' or ':' on the line) and
|
||||||
|
call the handler with value NULL in this case. Default is to treat
|
||||||
|
no-value lines as an error. */
|
||||||
|
#ifndef INI_ALLOW_NO_VALUE
|
||||||
|
#define INI_ALLOW_NO_VALUE 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Nonzero to use custom ini_malloc, ini_free, and ini_realloc memory
|
||||||
|
allocation functions (INI_USE_STACK must also be 0). These functions must
|
||||||
|
have the same signatures as malloc/free/realloc and behave in a similar
|
||||||
|
way. ini_realloc is only needed if INI_ALLOW_REALLOC is set. */
|
||||||
|
#ifndef INI_CUSTOM_ALLOCATOR
|
||||||
|
#define INI_CUSTOM_ALLOCATOR 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* INI_H */
|
||||||
43
src/iosu_url_patches.h
Normal file
43
src/iosu_url_patches.h
Normal file
|
|
@ -0,0 +1,43 @@
|
||||||
|
#ifndef _PATCHER_H
|
||||||
|
#define _PATCHER_H
|
||||||
|
|
||||||
|
typedef struct URL_Patch {
|
||||||
|
unsigned int address;
|
||||||
|
char url[80];
|
||||||
|
} URL_Patch;
|
||||||
|
|
||||||
|
static const URL_Patch url_patches[] = {
|
||||||
|
//nim-boss .rodata
|
||||||
|
{0xE2282550, "http://pushmorewupshop.spbr.net/pushmore/r/%s"},
|
||||||
|
{0xE229A0A0, "http://npns-devcapp.spbr.net/bst.dat"},
|
||||||
|
{0xE229A0D0, "http://npns-devcapp.spbr.net/bst2.dat"},
|
||||||
|
{0xE2281964, "https://tagayawupshop.spbr.net/tagaya/versionlist/%s/%s/%s"},
|
||||||
|
{0xE22819B4, "https://tagayawupshop.spbr.net/tagaya/versionlist/%s/%s/latest_version"},
|
||||||
|
{0xE2282584, "http://pushmowupshop.spbr.net/pushmo/d/%s/%u"},
|
||||||
|
{0xE22825B8, "http://pushmowupshop.spbr.net/pushmo/c/%u/%u"},
|
||||||
|
{0xE2282DB4, "https://ecswupshop.spbr.net/ecs/services/ECommerceSOAP"},
|
||||||
|
{0xE22830A0, "https://ecswupshop.spbr.net/ecs/services/ECommerceSOAP"},
|
||||||
|
{0xE22830E0, "https://nuswupshop.spbr.net/nus/services/NetUpdateSOAP"},
|
||||||
|
{0xE2299990, "policylist.spbr.net"},
|
||||||
|
{0xE229A600, "https://plswupshop.spbr.net/pls/upload"},
|
||||||
|
{0xE229A6AC, "https://npvk-devapp.spbr.net/reports"},
|
||||||
|
{0xE229A6D8, "https://npvkapp.spbr.net/reports"},
|
||||||
|
{0xE229B1F4, "https://tasksheets.spbr.net/p01/tasksheet/%s/%s/%s/%s?c=%s&l=%s"},
|
||||||
|
{0xE229B238, "https://tasksheets.spbr.net/p01/tasksheet/%s/%s/%s?c=%s&l=%s"},
|
||||||
|
{0xE22AB2D8, "https://idbe-wupcdn.spbr.net/icondata/%02X/%016llX.idbe"},
|
||||||
|
{0xE22AB318, "https://idbe-ctrcdn.spbr.net/icondata/%02X/%016llX.idbe"},
|
||||||
|
{0xE22AB358, "https://idbe-wupcdn.spbr.net/icondata/%02X/%016llX-%d.idbe"},
|
||||||
|
{0xE22AB398, "https://idbe-ctrcdn.spbr.net/icondata/%02X/%016llX-%d.idbe"},
|
||||||
|
{0xE22B3EF8, "https://ecscshop.spbr.net"},
|
||||||
|
{0xE22B3F30, "https://ecscshop.spbr.net/ecs/services/ECommerceSOAP"},
|
||||||
|
{0xE22B3F70, "https://iascshop.spbr.net/ias/services/IdentityAuthenticationSOAP"},
|
||||||
|
{0xE22B3FBC, "https://cascshop.spbr.net/cas/services/CatalogingSOAP"},
|
||||||
|
{0xE22B3FFC, "https://nuscshop.spbr.net/nus/services/NetUpdateSOAP"},
|
||||||
|
{0xE229DE0C, "n.app.spbr.net"},
|
||||||
|
//nim-boss .bss
|
||||||
|
{0xE24B8A24, "https://policylist.spbr.net/p01/policylist/1/1/UNK"},
|
||||||
|
{0xE31930D4, "https://%s%saccount.spbr.net/v%u/api/"}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
18
src/lang/de_DE.lang
Normal file
18
src/lang/de_DE.lang
Normal file
|
|
@ -0,0 +1,18 @@
|
||||||
|
.plugin_name="Inkay"
|
||||||
|
,.network_category="Netzwerkauswahl"
|
||||||
|
,.connect_to_network_setting="Verbinde zum SPFN"
|
||||||
|
,.other_category="Andere Einstellungen"
|
||||||
|
,.reset_wwp_setting="Wara Wara Plaza zurücksetzen"
|
||||||
|
,.press_a_action="Drücke A"
|
||||||
|
,.restart_to_apply_action="Neustarten zum Anwenden"
|
||||||
|
,.need_menu_action="Nur vom Wii U-Menü aus"
|
||||||
|
,.using_nintendo_network="Nutze Nintendo Network"
|
||||||
|
,.using_pretendo_network="Nutze SPFN"
|
||||||
|
,.multiplayer_port_display="Nutze UDP Port %hu für Mehrspieler"
|
||||||
|
,.module_not_found="SPFN Patch fehlgeschlagen - nutze Aroma Updater zum Reparieren (686-1001 Module missing)"
|
||||||
|
,.module_init_not_found="SPFN Patch fehlgeschlagen - nutze Aroma Updater zum Reparieren (686-1002 Module init)"
|
||||||
|
,.setting_yes=""
|
||||||
|
,.setting_no=""
|
||||||
|
,.language_setting=""
|
||||||
|
,.language_name="Deutsch"
|
||||||
|
,.system_language=""
|
||||||
19
src/lang/en@uwu.lang
Normal file
19
src/lang/en@uwu.lang
Normal file
|
|
@ -0,0 +1,19 @@
|
||||||
|
.plugin_name="Inky ^w^"
|
||||||
|
,.network_category="Newowk sewectiown! :3"
|
||||||
|
,.connect_to_network_setting="use dah pretender!!!!"
|
||||||
|
,.show_startup_toast_setting="show da deets :3"
|
||||||
|
,.other_category="oth3r stuffzz"
|
||||||
|
,.reset_wwp_setting="warah wara go BYEBYE x3c"
|
||||||
|
,.press_a_action="Press A plz?"
|
||||||
|
,.restart_to_apply_action="ima restart ur consoel >:3c"
|
||||||
|
,.need_menu_action="no menu?? only menu -w-"
|
||||||
|
,.using_nintendo_network="meanie network!!!"
|
||||||
|
,.using_pretendo_network="pretender netw3rk >:D"
|
||||||
|
,.multiplayer_port_display="mah secret word is %hu... ur modem will know"
|
||||||
|
,.module_not_found="oh noez! pls get aroma updater help :( (686-1001 Module missing)"
|
||||||
|
,.module_init_not_found="oh noez! pls get aroma updater help :( (686-1002 Module init)"
|
||||||
|
,.setting_yes="yaah!"
|
||||||
|
,.setting_no="nu >w<"
|
||||||
|
,.language_setting="spek..."
|
||||||
|
,.language_name="kitteh speak!!"
|
||||||
|
,.system_language="System"
|
||||||
19
src/lang/en_US.lang
Normal file
19
src/lang/en_US.lang
Normal file
|
|
@ -0,0 +1,19 @@
|
||||||
|
.plugin_name="Malamar"
|
||||||
|
,.network_category="Network selection"
|
||||||
|
,.connect_to_network_setting="Connect to SPFN"
|
||||||
|
,.show_startup_toast_setting="Show startup toast"
|
||||||
|
,.other_category="Other settings"
|
||||||
|
,.reset_wwp_setting="Reset Wara Wara Plaza"
|
||||||
|
,.press_a_action="Press A"
|
||||||
|
,.restart_to_apply_action="Restart to apply"
|
||||||
|
,.need_menu_action="From WiiU menu only"
|
||||||
|
,.using_nintendo_network="Using Nintendo Network"
|
||||||
|
,.using_pretendo_network="Using SPFN"
|
||||||
|
,.multiplayer_port_display="Using UDP port %hu for multiplayer"
|
||||||
|
,.module_not_found="SPFN patch failed - use Aroma Updater to repair (686-1001 Module missing)"
|
||||||
|
,.module_init_not_found="SPFN patch failed - use Aroma Updater to repair (686-1002 Module init)"
|
||||||
|
,.setting_yes="Yes"
|
||||||
|
,.setting_no="No"
|
||||||
|
,.language_setting="Language"
|
||||||
|
,.language_name="English"
|
||||||
|
,.system_language="System"
|
||||||
19
src/lang/es_ES.lang
Normal file
19
src/lang/es_ES.lang
Normal file
|
|
@ -0,0 +1,19 @@
|
||||||
|
.plugin_name="Inkay"
|
||||||
|
,.network_category="Seleccionar red"
|
||||||
|
,.connect_to_network_setting="Conectar a SPFN"
|
||||||
|
,.show_startup_toast_setting=""
|
||||||
|
,.other_category="Otros ajustes"
|
||||||
|
,.reset_wwp_setting="Restablecer Plaza Wara Wara"
|
||||||
|
,.press_a_action="Pulsa A"
|
||||||
|
,.restart_to_apply_action="Reiniciar para aplicar"
|
||||||
|
,.need_menu_action="Solo desde el Menú de Wii U"
|
||||||
|
,.using_nintendo_network="Usando Nintendo Network"
|
||||||
|
,.using_pretendo_network="Usando SPFN"
|
||||||
|
,.multiplayer_port_display="Usando puerto UDP %hu para multijugador"
|
||||||
|
,.module_not_found="Ha fallado el parche SPFN - usa Aroma Updater para repararlo (686-1001 Falta un módulo)"
|
||||||
|
,.module_init_not_found="Ha fallado el parche SPFN - usa Aroma Updater para repararlo (686-1002 Inicialización del módulo)"
|
||||||
|
,.setting_yes=""
|
||||||
|
,.setting_no=""
|
||||||
|
,.language_setting=""
|
||||||
|
,.language_name="Español"
|
||||||
|
,.system_language=""
|
||||||
18
src/lang/fr_FR.lang
Normal file
18
src/lang/fr_FR.lang
Normal file
|
|
@ -0,0 +1,18 @@
|
||||||
|
.plugin_name="Inkay"
|
||||||
|
,.network_category="Sélection du réseau"
|
||||||
|
,.connect_to_network_setting="Connexion au SPFN"
|
||||||
|
,.other_category="Autres paramètres"
|
||||||
|
,.reset_wwp_setting="Réinitialiser la place WaraWara"
|
||||||
|
,.press_a_action="Appuyez sur A"
|
||||||
|
,.restart_to_apply_action="Redémarrer pour appliquer"
|
||||||
|
,.need_menu_action="(retournez d'abord au menu Wii U)"
|
||||||
|
,.using_nintendo_network="Réseau sélectionné : Nintendo Network"
|
||||||
|
,.using_pretendo_network="Réseau sélectionné : SPFN"
|
||||||
|
,.multiplayer_port_display="Le port UDP %hu sera utilisé pour le multijoueur"
|
||||||
|
,.module_not_found="Le patch SPFN a rencontré un problème, veuillez le réparer avec Aroma Updater (686-1001 Module missing)"
|
||||||
|
,.module_init_not_found="Le patch SPFN a rencontré un problème, veuillez le réparer avec Aroma Updater (686-1002 Module init)"
|
||||||
|
,.setting_yes=""
|
||||||
|
,.setting_no=""
|
||||||
|
,.language_setting=""
|
||||||
|
,.language_name="Français"
|
||||||
|
,.system_language=""
|
||||||
19
src/lang/it_IT.lang
Normal file
19
src/lang/it_IT.lang
Normal file
|
|
@ -0,0 +1,19 @@
|
||||||
|
.plugin_name="Inkay"
|
||||||
|
,.network_category="Seleziona la rete"
|
||||||
|
,.connect_to_network_setting="Connettiti a SPFN"
|
||||||
|
,.show_startup_toast_setting=""
|
||||||
|
,.other_category="Altre impostazioni"
|
||||||
|
,.reset_wwp_setting="Ripristina Wara Wara Plaza"
|
||||||
|
,.press_a_action="Premi A"
|
||||||
|
,.restart_to_apply_action="Riavvia per applicare"
|
||||||
|
,.need_menu_action="Solo dal menu WiiU"
|
||||||
|
,.using_nintendo_network="In uso Nintendo Network"
|
||||||
|
,.using_pretendo_network="In uso SPFN"
|
||||||
|
,.multiplayer_port_display="È in uso la porta UDP %hu per il multigiocatore"
|
||||||
|
,.module_not_found="Patch di SPFN fallita - usa Aroma Updater per correggere (686-1001 Modulo mancante)"
|
||||||
|
,.module_init_not_found="Patch di SPFN fallita - usa Aroma Updater per correggere (686-1002 Module init)"
|
||||||
|
,.setting_yes=""
|
||||||
|
,.setting_no=""
|
||||||
|
,.language_setting=""
|
||||||
|
,.language_name="Italiano"
|
||||||
|
,.system_language=""
|
||||||
19
src/lang/ja_JP.lang
Normal file
19
src/lang/ja_JP.lang
Normal file
|
|
@ -0,0 +1,19 @@
|
||||||
|
.plugin_name="Inkay"
|
||||||
|
,.network_category="ネットワークの選択"
|
||||||
|
,.connect_to_network_setting="SPFNネットワークに接続する"
|
||||||
|
,.show_startup_toast_setting=""
|
||||||
|
,.other_category="その他の設定"
|
||||||
|
,.reset_wwp_setting="わらわら広場をリセット"
|
||||||
|
,.press_a_action="Aボタンを押そう"
|
||||||
|
,.restart_to_apply_action="再起動後に反映されます"
|
||||||
|
,.need_menu_action="Wii Uメニューからのみ実行可能"
|
||||||
|
,.using_nintendo_network="選択済み:ニンテンドーネットワーク"
|
||||||
|
,.using_pretendo_network="選択済み:SPFN ネットワーク"
|
||||||
|
,.multiplayer_port_display="マルチプレイに UDPポート %hu を使用します"
|
||||||
|
,.module_not_found="SPFN パッチに失敗しました。Aroma Updaterを使用して解決してみてください。(686-1001 Module missing)"
|
||||||
|
,.module_init_not_found="SPFN パッチに失敗しました。Aroma Updaterを使用して解決してみてください。(686-1002 Module init)"
|
||||||
|
,.setting_yes=""
|
||||||
|
,.setting_no=""
|
||||||
|
,.language_setting=""
|
||||||
|
,.language_name="日本語"
|
||||||
|
,.system_language=""
|
||||||
19
src/lang/ko_KR.lang
Normal file
19
src/lang/ko_KR.lang
Normal file
|
|
@ -0,0 +1,19 @@
|
||||||
|
.plugin_name="Inkay"
|
||||||
|
,.network_category="네트워크 선택"
|
||||||
|
,.connect_to_network_setting="SPFN 사용"
|
||||||
|
,.show_startup_toast_setting=""
|
||||||
|
,.other_category="기타 설정"
|
||||||
|
,.reset_wwp_setting="Wara Wara Plaza 초기화"
|
||||||
|
,.press_a_action="A 버튼을 누르세요"
|
||||||
|
,.restart_to_apply_action="재시작 후 적용"
|
||||||
|
,.need_menu_action="Wii U 메뉴에서만"
|
||||||
|
,.using_nintendo_network="Nintendo Network 사용 중"
|
||||||
|
,.using_pretendo_network="SPFN 사용 중"
|
||||||
|
,.multiplayer_port_display="멀티플레이어에 UDP 포트 %hu을(를) 사용합니다"
|
||||||
|
,.module_not_found="패치를 적용하는 데 실패했습니다. Aroma Updater로 복구해 주세요. (686-1001 모듈 없음)"
|
||||||
|
,.module_init_not_found="패치를 적용하는 데 실패했습니다. Aroma Updater로 복구해 주세요. (686-1002 모듈 초기화)"
|
||||||
|
,.setting_yes=""
|
||||||
|
,.setting_no=""
|
||||||
|
,.language_setting=""
|
||||||
|
,.language_name="한국어"
|
||||||
|
,.system_language=""
|
||||||
19
src/lang/nl_NL.lang
Normal file
19
src/lang/nl_NL.lang
Normal file
|
|
@ -0,0 +1,19 @@
|
||||||
|
.plugin_name="Inkay"
|
||||||
|
,.network_category="Netwerkselectie"
|
||||||
|
,.connect_to_network_setting="Verbind met het SPFN-netwerk"
|
||||||
|
,.show_startup_toast_setting=""
|
||||||
|
,.other_category="Overige instellingen"
|
||||||
|
,.reset_wwp_setting="Reset het Wara Wara Plaza"
|
||||||
|
,.press_a_action="Druk A"
|
||||||
|
,.restart_to_apply_action="Herstart om toe te passen"
|
||||||
|
,.need_menu_action="Alleen vanuit het WiiU-menu"
|
||||||
|
,.using_nintendo_network="Nintendo Network wordt gebruikt"
|
||||||
|
,.using_pretendo_network="SPFN wordt gebruikt"
|
||||||
|
,.multiplayer_port_display="Gebruikt UDP port %hu voor multiplayer"
|
||||||
|
,.module_not_found="SPFN patch mislukt - gebruik Aroma Updater om het te herstellen (686-1001 Module ontbreekt)"
|
||||||
|
,.module_init_not_found="SPFN patch mislukt - gebruik Aroma Updater om het te herstellen (686-1002 Module init)"
|
||||||
|
,.setting_yes=""
|
||||||
|
,.setting_no=""
|
||||||
|
,.language_setting=""
|
||||||
|
,.language_name="Nederlands"
|
||||||
|
,.system_language=""
|
||||||
19
src/lang/pt_BR.lang
Normal file
19
src/lang/pt_BR.lang
Normal file
|
|
@ -0,0 +1,19 @@
|
||||||
|
.plugin_name="Inkay"
|
||||||
|
,.network_category="Selecionar rede"
|
||||||
|
,.connect_to_network_setting="Conecta-se à SPFN"
|
||||||
|
,.show_startup_toast_setting=""
|
||||||
|
,.other_category="Outras configurações"
|
||||||
|
,.reset_wwp_setting="Resetar Wara Wara Plaza"
|
||||||
|
,.press_a_action="Aperte A"
|
||||||
|
,.restart_to_apply_action="Reinicie para aplicar"
|
||||||
|
,.need_menu_action="Apenas no menu do Wii U"
|
||||||
|
,.using_nintendo_network="Usando Nintendo Network"
|
||||||
|
,.using_pretendo_network="Usando SPFN"
|
||||||
|
,.multiplayer_port_display="Usando UDP port %hu para a jogatina multiplayer"
|
||||||
|
,.module_not_found="Atualização do SPFN falhou - use o Aroma Updater para corrigir (686-1001 Módulo faltando)"
|
||||||
|
,.module_init_not_found="Atualização do SPFN falhou - use o Aroma Updater para corrigir (686-1002 Módulo de início)"
|
||||||
|
,.setting_yes=""
|
||||||
|
,.setting_no=""
|
||||||
|
,.language_setting=""
|
||||||
|
,.language_name="Português"
|
||||||
|
,.system_language=""
|
||||||
19
src/lang/ru_RU.lang
Normal file
19
src/lang/ru_RU.lang
Normal file
|
|
@ -0,0 +1,19 @@
|
||||||
|
.plugin_name="Inkay"
|
||||||
|
,.network_category="Выбор сети"
|
||||||
|
,.connect_to_network_setting="Подключиться к SPFN"
|
||||||
|
,.show_startup_toast_setting=""
|
||||||
|
,.other_category="Другие настройки"
|
||||||
|
,.reset_wwp_setting="Сбросить Wara Wara Plaza"
|
||||||
|
,.press_a_action="Нажмите A"
|
||||||
|
,.restart_to_apply_action="Перезагрузите для применения изменений"
|
||||||
|
,.need_menu_action="Только из меню Wii U"
|
||||||
|
,.using_nintendo_network="Используется Nintendo Network"
|
||||||
|
,.using_pretendo_network="Используется SPFN"
|
||||||
|
,.multiplayer_port_display="Используем UDP-порт %hu для сетевой игры"
|
||||||
|
,.module_not_found="Ошибка установки патча SPFN - для восстановления, запустите Aroma Updater (686-1001 Модуль отсутствует)"
|
||||||
|
,.module_init_not_found="Ошибка установки патча SPFN - для восстановления, запустите Aroma Updater (686-1002 Инициализация модуля)"
|
||||||
|
,.setting_yes=""
|
||||||
|
,.setting_no=""
|
||||||
|
,.language_setting=""
|
||||||
|
,.language_name="Русский язык"
|
||||||
|
,.system_language=""
|
||||||
18
src/lang/zh_CN.lang
Normal file
18
src/lang/zh_CN.lang
Normal file
|
|
@ -0,0 +1,18 @@
|
||||||
|
.plugin_name="Inkay"
|
||||||
|
,.network_category="选择网络"
|
||||||
|
,.connect_to_network_setting="连接到SPFN"
|
||||||
|
,.other_category="其他设置"
|
||||||
|
,.reset_wwp_setting="重置Wara Wara Plaza"
|
||||||
|
,.press_a_action="请按 A"
|
||||||
|
,.restart_to_apply_action="重启以应用设置"
|
||||||
|
,.need_menu_action="仅来自WiiU Menu"
|
||||||
|
,.using_nintendo_network="使用 Nintendo Network"
|
||||||
|
,.using_pretendo_network="使用 SPFN"
|
||||||
|
,.multiplayer_port_display="多人游戏使用 UDP 端口 %hu"
|
||||||
|
,.module_not_found="SPFN 补丁失败 - 使用 Aroma Updater 修复(686-1001 模块丢失)"
|
||||||
|
,.module_init_not_found="SPFN 补丁失败 - 使用 Aroma Updater 修复(686-1002 模块初始化)"
|
||||||
|
,.setting_yes=""
|
||||||
|
,.setting_no=""
|
||||||
|
,.language_setting=""
|
||||||
|
,.language_name="中文(简体)"
|
||||||
|
,.system_language=""
|
||||||
20
src/lang/zh_Hant.lang
Normal file
20
src/lang/zh_Hant.lang
Normal file
|
|
@ -0,0 +1,20 @@
|
||||||
|
.plugin_name="Inkay"
|
||||||
|
,.network_category="選擇網路"
|
||||||
|
,.connect_to_network_setting="連接到SPFN"
|
||||||
|
,.show_startup_toast_setting=""
|
||||||
|
,.other_category="其他設定"
|
||||||
|
,.reset_wwp_setting="重置Wara Wara Plaza"
|
||||||
|
,.press_a_action="請按 A"
|
||||||
|
,.restart_to_apply_action="重啓以套用設定"
|
||||||
|
,.need_menu_action="僅來自WiiU Menu"
|
||||||
|
,.using_nintendo_network="使用 Nintendo Network"
|
||||||
|
,.using_pretendo_network="使用 SPFN"
|
||||||
|
,.multiplayer_port_display="Using UDP port %hu for multiplayer"
|
||||||
|
,.module_not_found="SPFN patch failed - use Aroma Updater to repair (686-1001 Module missing)"
|
||||||
|
,.module_init_not_found="SPFN patch failed - use Aroma Updater to repair (686-1002 Module init)"
|
||||||
|
,.multiplayer_port_display="使用 UDP 端口 %hu 進行多人遊戲"
|
||||||
|
,.setting_yes=""
|
||||||
|
,.setting_no=""
|
||||||
|
,.language_setting=""
|
||||||
|
,.language_name="中文(繁體)"
|
||||||
|
,.system_language=""
|
||||||
501
src/main.cpp
501
src/main.cpp
|
|
@ -2,137 +2,204 @@
|
||||||
Copyright 2022 Ash Logan <ash@heyquark.com>
|
Copyright 2022 Ash Logan <ash@heyquark.com>
|
||||||
Copyright 2019 Maschell
|
Copyright 2019 Maschell
|
||||||
|
|
||||||
Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby
|
This program is free software: you can redistribute it and/or modify
|
||||||
granted, provided that the above copyright notice and this permission notice appear in all copies.
|
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.
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
|
This program is distributed in the hope that it will be useful,
|
||||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
GNU General Public License for more details.
|
||||||
PERFORMANCE OF THIS SOFTWARE.
|
|
||||||
|
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 <stdio.h>
|
#include "export.h"
|
||||||
#include <stdint.h>
|
#include "iosu_url_patches.h"
|
||||||
#include <stdlib.h>
|
|
||||||
#include <wups.h>
|
|
||||||
#include <optional>
|
|
||||||
#include <nsysnet/nssl.h>
|
|
||||||
#include <coreinit/cache.h>
|
|
||||||
#include <coreinit/dynload.h>
|
|
||||||
#include <coreinit/mcp.h>
|
|
||||||
#include <coreinit/memory.h>
|
|
||||||
#include <coreinit/memorymap.h>
|
|
||||||
#include <coreinit/memexpheap.h>
|
|
||||||
#include <notifications/notifications.h>
|
|
||||||
#include "wut_extra.h"
|
|
||||||
#include <utils/logger.h>
|
|
||||||
#include "url_patches.h"
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "Notification.h"
|
#include "Notification.h"
|
||||||
|
#include "patches/olv_urls.h"
|
||||||
|
#include "patches/game_matchmaking.h"
|
||||||
|
|
||||||
|
#include <wums.h>
|
||||||
|
|
||||||
|
#include <coreinit/dynload.h>
|
||||||
|
#include <coreinit/mcp.h>
|
||||||
|
|
||||||
|
#include <notifications/notifications.h>
|
||||||
|
#include <utils/logger.h>
|
||||||
|
|
||||||
#include <coreinit/filesystem.h>
|
|
||||||
#include <cstring>
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <nn/erreula/erreula_cpp.h>
|
#include <optional>
|
||||||
#include <nn/act/client_cpp.h>
|
|
||||||
|
#include <cstring>
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
#include <curl/curl.h>
|
|
||||||
#include "ca_pem.h"
|
#include "ca_pem.h"
|
||||||
|
|
||||||
#include <gx2/surface.h>
|
#define INKAY_VERSION "v3.1.0"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Mandatory plugin information.
|
Mandatory plugin information.
|
||||||
If not set correctly, the loader will refuse to use the plugin.
|
If not set correctly, the loader will refuse to use the plugin.
|
||||||
**/
|
**/
|
||||||
WUPS_PLUGIN_NAME("Inkay");
|
WUMS_META(export_name, "inkay");
|
||||||
WUPS_PLUGIN_DESCRIPTION("Pretendo Network Patcher");
|
WUMS_META(wums, WUMS_VERSION);
|
||||||
WUPS_PLUGIN_VERSION("v2.1");
|
WUMS_USE_WUT_MALLOC();
|
||||||
WUPS_PLUGIN_AUTHOR("Pretendo contributors");
|
WUMS_USE_WUT_SOCKETS();
|
||||||
WUPS_PLUGIN_LICENSE("ISC");
|
WUMS_USE_WUT_NEWLIB();
|
||||||
|
WUMS___INIT_WRAPPER();
|
||||||
|
WUMS___FINI_WRAPPER();
|
||||||
|
WUMS_META(buildtimestamp, __DATE__ " " __TIME__);
|
||||||
|
extern const char wums_meta_module_name[] WUMS_SECTION("meta");
|
||||||
|
const char wums_meta_module_name[] = "inkay";
|
||||||
|
extern const char wums_meta_info_dump[] WUMS_SECTION("meta");
|
||||||
|
const char wums_meta_info_dump[] = "(module: inkay;" \
|
||||||
|
"wums " WUMS_VERSION ";" \
|
||||||
|
"buildtime: " __DATE__ " " __TIME__ ")";
|
||||||
|
extern const char wums_meta_info_linking_order[] WUMS_SECTION("meta");
|
||||||
|
const char wums_meta_info_linking_order[] = "Loading module \"inkay\" failed.\n" \
|
||||||
|
"Function \"wut_get_thread_specific\" returned unexpected value.\n" \
|
||||||
|
"Please check linking order (expected \"-lwums -lwut\")";
|
||||||
|
|
||||||
WUPS_USE_STORAGE("inkay");
|
WUMS_MODULE_DESCRIPTION("SPFN Network Patcher");
|
||||||
|
WUMS_MODULE_VERSION(INKAY_VERSION);
|
||||||
|
WUMS_MODULE_AUTHOR("Pretendo contributors and RusticMaple");
|
||||||
|
WUMS_MODULE_LICENSE("GPLv3");
|
||||||
|
|
||||||
|
WUMS_DEPENDS_ON(homebrew_functionpatcher);
|
||||||
|
WUMS_DEPENDS_ON(homebrew_kernel);
|
||||||
|
WUMS_DEPENDS_ON(homebrew_notifications);
|
||||||
|
|
||||||
|
WUMS_USE_WUT_DEVOPTAB();
|
||||||
|
|
||||||
#include <kernel/kernel.h>
|
|
||||||
#include <mocha/mocha.h>
|
#include <mocha/mocha.h>
|
||||||
|
#include <function_patcher/function_patching.h>
|
||||||
const char original_url[] = "discovery.olv.nintendo.net/v1/endpoint";
|
#include "patches/account_settings.h"
|
||||||
const char new_url[] = "discovery.olv.pretendo.cc/v1/endpoint";
|
#include "patches/dns_hooks.h"
|
||||||
const char wave_original[] = {
|
#include "patches/eshop_applet.h"
|
||||||
0x68, 0x74, 0x74, 0x70, 0x73, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
#include "patches/olv_applet.h"
|
||||||
0x00, 0x00, 0x00, 0x00, 0x2E, 0x6E, 0x69, 0x6E, 0x74, 0x65, 0x6E, 0x64,
|
#include "patches/game_peertopeer.h"
|
||||||
0x6F, 0x2E, 0x6E, 0x65, 0x74
|
#include "sysconfig.h"
|
||||||
};
|
#include "lang.h"
|
||||||
const char wave_new[] = {
|
|
||||||
0x68, 0x74, 0x74, 0x70, 0x73, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x2E, 0x70, 0x72, 0x65, 0x74, 0x65, 0x6E, 0x64,
|
|
||||||
0x6F, 0x2E, 0x63, 0x63, 0x00
|
|
||||||
};
|
|
||||||
|
|
||||||
const char miiverse_green_highlight[] = {
|
|
||||||
0x82,0xff,0x05,0xff,0x82,0xff,0x05,0xff,0x1d,0xff,0x04,0xff,0x1d,0xff,0x04,0xff
|
|
||||||
};
|
|
||||||
|
|
||||||
const char juxt_purple_highlight[] = {
|
|
||||||
0x5d,0x4a,0x9a,0xff,0x5d,0x4a,0x9a,0xff,0x5d,0x4a,0x9a,0xff,0x5d,0x4a,0x9a,0xff
|
|
||||||
};
|
|
||||||
|
|
||||||
const char miiverse_green_touch1[] = {
|
|
||||||
0x94,0xd9,0x2a,0x00,0x57,0xbd,0x12,0xff
|
|
||||||
};
|
|
||||||
|
|
||||||
const char juxt_purple_touch1[] = {
|
|
||||||
0x5d,0x4a,0x9a,0x00,0x5d,0x4a,0x9a,0xff
|
|
||||||
};
|
|
||||||
|
|
||||||
const char miiverse_green_touch2[] = {
|
|
||||||
0x57,0xbd,0x12,0x00,0x94,0xd9,0x2a,0xff
|
|
||||||
};
|
|
||||||
|
|
||||||
const char juxt_purple_touch2[] = {
|
|
||||||
0x5d,0x4a,0x9a,0x00,0x5d,0x4a,0x9a,0xff
|
|
||||||
};
|
|
||||||
|
|
||||||
_Static_assert(sizeof(original_url) > sizeof(new_url),
|
|
||||||
"new_url too long! Must be less than 38chars.");
|
|
||||||
|
|
||||||
//thanks @Gary#4139 :p
|
//thanks @Gary#4139 :p
|
||||||
static void write_string(uint32_t addr, const char* str)
|
static void write_string(uint32_t addr, const char *str) {
|
||||||
{
|
|
||||||
int len = strlen(str) + 1;
|
int len = strlen(str) + 1;
|
||||||
int remaining = len % 4;
|
int remaining = len % 4;
|
||||||
int num = len - remaining;
|
int num = len - remaining;
|
||||||
|
|
||||||
for (int i = 0; i < (num / 4); i++) {
|
for (int i = 0; i < (num / 4); i++) {
|
||||||
Mocha_IOSUKernelWrite32(addr + i * 4, *(uint32_t*)(str + i * 4));
|
Mocha_IOSUKernelWrite32(addr + i * 4, *(uint32_t * )(str + i * 4));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (remaining > 0) {
|
if (remaining > 0) {
|
||||||
uint8_t buf[4];
|
uint8_t buf[4];
|
||||||
Mocha_IOSUKernelRead32(addr + num, (uint32_t*)&buf);
|
Mocha_IOSUKernelRead32(addr + num, (uint32_t * ) & buf);
|
||||||
|
|
||||||
for (int i = 0; i < remaining; i++) {
|
for (int i = 0; i < remaining; i++) {
|
||||||
buf[i] = *(str + num + i);
|
buf[i] = *(str + num + i);
|
||||||
}
|
}
|
||||||
|
|
||||||
Mocha_IOSUKernelWrite32(addr + num, *(uint32_t*)&buf);
|
Mocha_IOSUKernelWrite32(addr + num, *(uint32_t * ) & buf);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool is555(MCP_SystemVersion version) {
|
static bool is555(MCPSystemVersion version) {
|
||||||
return (version.major == 5) && (version.minor == 5) && (version.patch >= 5);
|
return (version.major == 5) && (version.minor == 5) && (version.patch >= 5);
|
||||||
}
|
}
|
||||||
|
|
||||||
INITIALIZE_PLUGIN() {
|
static const char *get_nintendo_network_message(inkay_language language) {
|
||||||
WHBLogUdpInit();
|
// TL note: "Nintendo Network" is a proper noun - "Network" is part of the name
|
||||||
|
// TL note: "Using" instead of "Connected" is deliberate - we don't know if a successful connection exists, we are
|
||||||
|
// only specifying what we'll *attempt* to connect to
|
||||||
|
return get_config_strings(language).using_nintendo_network.data();
|
||||||
|
}
|
||||||
|
|
||||||
|
static const char *get_pretendo_message(inkay_language language) {
|
||||||
|
// TL note: "Pretendo Network" is also a proper noun - though "Pretendo" alone can refer to us as a project
|
||||||
|
// TL note: "Using" instead of "Connected" is deliberate - we don't know if a successful connection exists, we are
|
||||||
|
// only specifying what we'll *attempt* to connect to
|
||||||
|
return get_config_strings(language).using_pretendo_network.data();
|
||||||
|
}
|
||||||
|
|
||||||
|
static void Inkay_SetPluginRunning() {
|
||||||
|
Config::plugin_is_loaded = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
static InkayStatus Inkay_GetStatus() {
|
||||||
|
if (!Config::initialized)
|
||||||
|
return InkayStatus::Uninitialized;
|
||||||
|
|
||||||
|
if (Config::connect_to_network) {
|
||||||
|
return InkayStatus::Pretendo;
|
||||||
|
} else {
|
||||||
|
return InkayStatus::Nintendo;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void Inkay_Initialize(bool apply_patches, bool show_startup_toast, inkay_language language) {
|
||||||
|
if (Config::initialized)
|
||||||
|
return;
|
||||||
|
|
||||||
|
Config::show_startup_toast = show_startup_toast;
|
||||||
|
|
||||||
|
if (Config::block_initialize) {
|
||||||
|
ShowNotification("Cannot load Inkay while the system is running. Please restart the console");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// if using pretendo then (try to) apply the ssl patches
|
||||||
|
if (apply_patches) {
|
||||||
|
Config::connect_to_network = true;
|
||||||
|
|
||||||
|
if (is555(get_console_os_version())) {
|
||||||
|
Mocha_IOSUKernelWrite32(0xE1019F78, 0xE3A00001); // mov r0, #1
|
||||||
|
} else {
|
||||||
|
Mocha_IOSUKernelWrite32(0xE1019E84, 0xE3A00001); // mov r0, #1
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const auto &patch: url_patches) {
|
||||||
|
write_string(patch.address, patch.url);
|
||||||
|
}
|
||||||
|
|
||||||
|
// IOS-NIM-BOSS GlobalPolicyList->state: poking this forces a refresh after we changed the url
|
||||||
|
Mocha_IOSUKernelWrite32(0xE24B3D90, 4);
|
||||||
|
|
||||||
|
DEBUG_FUNCTION_LINE_VERBOSE("Pretendo URL and NoSSL patches applied successfully.");
|
||||||
|
|
||||||
|
if (Config::show_startup_toast) {
|
||||||
|
ShowNotification(get_pretendo_message(language));
|
||||||
|
}
|
||||||
|
Config::initialized = true;
|
||||||
|
} else {
|
||||||
|
DEBUG_FUNCTION_LINE_VERBOSE("Pretendo URL and NoSSL patches skipped.");
|
||||||
|
|
||||||
|
if(Config::show_startup_toast) {
|
||||||
|
ShowNotification(get_nintendo_network_message(language));
|
||||||
|
}
|
||||||
|
Config::initialized = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (FunctionPatcher_InitLibrary() == FUNCTION_PATCHER_RESULT_SUCCESS) {
|
||||||
|
patchDNS();
|
||||||
|
patchEshop();
|
||||||
|
patchOlvApplet();
|
||||||
|
patchAccountSettings();
|
||||||
|
install_matchmaking_patches();
|
||||||
|
} else {
|
||||||
|
DEBUG_FUNCTION_LINE("FunctionPatcher_InitLibrary failed");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
WUMS_INITIALIZE() {
|
||||||
WHBLogCafeInit();
|
WHBLogCafeInit();
|
||||||
|
WHBLogUdpInit();
|
||||||
|
|
||||||
Config::Init();
|
if (const auto res = Mocha_InitLibrary(); res != MOCHA_RESULT_SUCCESS) {
|
||||||
|
|
||||||
auto res = Mocha_InitLibrary();
|
|
||||||
|
|
||||||
if (res != MOCHA_RESULT_SUCCESS) {
|
|
||||||
DEBUG_FUNCTION_LINE("Mocha init failed with code %d!", res);
|
DEBUG_FUNCTION_LINE("Mocha init failed with code %d!", res);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -140,236 +207,56 @@ INITIALIZE_PLUGIN() {
|
||||||
if (NotificationModule_InitLibrary() != NOTIFICATION_MODULE_RESULT_SUCCESS) {
|
if (NotificationModule_InitLibrary() != NOTIFICATION_MODULE_RESULT_SUCCESS) {
|
||||||
DEBUG_FUNCTION_LINE("NotificationModule_InitLibrary failed");
|
DEBUG_FUNCTION_LINE("NotificationModule_InitLibrary failed");
|
||||||
}
|
}
|
||||||
|
|
||||||
//get os version
|
|
||||||
MCP_SystemVersion os_version;
|
|
||||||
int mcp = MCP_Open();
|
|
||||||
int ret = MCP_GetSystemVersion(mcp, &os_version);
|
|
||||||
if (ret < 0) {
|
|
||||||
DEBUG_FUNCTION_LINE("getting system version failed (%d/%d)!", mcp, ret);
|
|
||||||
os_version = (MCP_SystemVersion) {
|
|
||||||
.major = 5, .minor = 5, .patch = 5, .region = 'E'
|
|
||||||
};
|
|
||||||
}
|
|
||||||
DEBUG_FUNCTION_LINE("Running on %d.%d.%d%c",
|
|
||||||
os_version.major, os_version.minor, os_version.patch, os_version.region
|
|
||||||
);
|
|
||||||
|
|
||||||
if (Config::connect_to_network) {
|
|
||||||
if (is555(os_version)) {
|
|
||||||
Mocha_IOSUKernelWrite32(0xE1019F78, 0xE3A00001); // mov r0, #1
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
Mocha_IOSUKernelWrite32(0xE1019E84, 0xE3A00001); // mov r0, #1
|
|
||||||
}
|
|
||||||
|
|
||||||
for (const auto& patch : url_patches) {
|
|
||||||
write_string(patch.address, patch.url);
|
|
||||||
}
|
|
||||||
DEBUG_FUNCTION_LINE("Pretendo URL and NoSSL patches applied successfully.");
|
|
||||||
StartNotificationThread("Using Pretendo Network");
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
DEBUG_FUNCTION_LINE("Pretendo URL and NoSSL patches skipped.");
|
|
||||||
StartNotificationThread("Using Nintendo Network");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
MCP_Close(mcp);
|
|
||||||
}
|
}
|
||||||
DEINITIALIZE_PLUGIN() {
|
|
||||||
WHBLogUdpDeinit();
|
WUMS_DEINITIALIZE() {
|
||||||
|
unpatchDNS();
|
||||||
|
unpatchEshop();
|
||||||
|
unpatchOlvApplet();
|
||||||
|
unpatchAccountSettings();
|
||||||
|
remove_matchmaking_patches();
|
||||||
|
|
||||||
Mocha_DeInitLibrary();
|
Mocha_DeInitLibrary();
|
||||||
NotificationModule_DeInitLibrary();
|
NotificationModule_DeInitLibrary();
|
||||||
|
FunctionPatcher_DeInitLibrary();
|
||||||
|
|
||||||
|
WHBLogCafeDeinit();
|
||||||
|
WHBLogUdpDeinit();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool check_olv_libs() {
|
WUMS_APPLICATION_STARTS() {
|
||||||
OSDynLoad_Module olv_handle = 0;
|
DEBUG_FUNCTION_LINE_VERBOSE("Inkay " INKAY_VERSION " starting up...\n");
|
||||||
OSDynLoad_Error dret;
|
|
||||||
|
|
||||||
dret = OSDynLoad_IsModuleLoaded("nn_olv", &olv_handle);
|
// Reset plugin loaded flag
|
||||||
if (dret == OS_DYNLOAD_OK && olv_handle != 0) {
|
Config::plugin_is_loaded = false;
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
dret = OSDynLoad_IsModuleLoaded("nn_olv2", &olv_handle);
|
|
||||||
if (dret == OS_DYNLOAD_OK && olv_handle != 0) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool replace(uint32_t start, uint32_t size, const char* original_val, size_t original_val_sz, const char* new_val, size_t new_val_sz) {
|
WUMS_ALL_APPLICATION_STARTS_DONE() {
|
||||||
for (uint32_t addr = start; addr < start + size - original_val_sz; addr++) {
|
// we need to do the patches here because otherwise the Config::connect_to_network flag might be set yet
|
||||||
int ret = memcmp(original_val, (void*)addr, original_val_sz);
|
setup_olv_libs();
|
||||||
if (ret == 0) {
|
peertopeer_patch();
|
||||||
DEBUG_FUNCTION_LINE("found str @%08x: %s", addr, (const char*)addr);
|
matchmaking_notify_titleswitch();
|
||||||
KernelCopyData(OSEffectiveToPhysical(addr), OSEffectiveToPhysical((uint32_t)new_val), new_val_sz);
|
hotpatchAccountSettings();
|
||||||
DEBUG_FUNCTION_LINE("new str @%08x: %s", addr, (const char*)addr);
|
|
||||||
return true;
|
if (Config::initialized && !Config::plugin_is_loaded) {
|
||||||
|
DEBUG_FUNCTION_LINE("Inkay is running but the plugin got unloaded");
|
||||||
|
if (!Config::block_initialize) {
|
||||||
|
ShowNotification("Inkay module is still running. Please restart the console");
|
||||||
}
|
}
|
||||||
|
Config::shown_warning = true;
|
||||||
|
} else if (!Config::initialized && !Config::shown_warning) {
|
||||||
|
DEBUG_FUNCTION_LINE("Inkay module not initialized");
|
||||||
|
ShowNotification("Inkay module was not initialized. Ensure you have the Inkay plugin loaded");
|
||||||
|
Config::shown_warning = true;
|
||||||
}
|
}
|
||||||
|
if (!Config::initialized) {
|
||||||
return false;
|
Config::block_initialize = true;
|
||||||
}
|
|
||||||
|
|
||||||
#define OLV_RPL "nn_olv.rpl"
|
|
||||||
bool path_is_olv(const char* path) {
|
|
||||||
auto path_len = strlen(path);
|
|
||||||
auto* path_suffix = path + path_len - (sizeof(OLV_RPL) - 1); //1 for null
|
|
||||||
return strcmp(path_suffix, OLV_RPL) == 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void new_rpl_loaded(OSDynLoad_Module module, void* ctx, OSDynLoad_NotifyReason reason, OSDynLoad_NotifyData* rpl) {
|
|
||||||
if (!Config::connect_to_network) {
|
|
||||||
DEBUG_FUNCTION_LINE("Inkay: Miiverse patches skipped.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Loaded olv?
|
|
||||||
if (reason != OS_DYNLOAD_NOTIFY_LOADED) return;
|
|
||||||
if (!path_is_olv(rpl->name)) return;
|
|
||||||
|
|
||||||
replace(rpl->dataAddr, rpl->dataSize, original_url, sizeof(original_url), new_url, sizeof(new_url));
|
|
||||||
}
|
|
||||||
|
|
||||||
void replaceBulk(uint32_t start, uint32_t size, const char* original_val, size_t original_val_sz, const char* new_val, size_t new_val_sz) {
|
|
||||||
for (uint32_t addr = start; addr < start + size - original_val_sz; addr++) {
|
|
||||||
int ret = memcmp(original_val, (void*)addr, original_val_sz);
|
|
||||||
if (ret == 0) {
|
|
||||||
DEBUG_FUNCTION_LINE("found bulk @%08x", addr);
|
|
||||||
KernelCopyData(OSEffectiveToPhysical(addr), OSEffectiveToPhysical((uint32_t)new_val), new_val_sz);
|
|
||||||
DEBUG_FUNCTION_LINE("new bulk @%08x", addr);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ON_APPLICATION_START() {
|
WUMS_APPLICATION_ENDS() {
|
||||||
WHBLogUdpInit();
|
|
||||||
WHBLogCafeInit();
|
|
||||||
|
|
||||||
DEBUG_FUNCTION_LINE("Inkay: hewwo!\n");
|
|
||||||
|
|
||||||
OSDynLoad_AddNotifyCallback(&new_rpl_loaded, nullptr);
|
|
||||||
|
|
||||||
auto olvLoaded = check_olv_libs();
|
|
||||||
if (!olvLoaded) {
|
|
||||||
DEBUG_FUNCTION_LINE("Inkay: no olv, quitting for now\n");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!Config::connect_to_network) {
|
|
||||||
DEBUG_FUNCTION_LINE("Inkay: Miiverse patches skipped.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
//wish there was a better way than "blow through MEM2"
|
|
||||||
uint32_t base_addr, size;
|
|
||||||
if (OSGetMemBound(OS_MEM2, &base_addr, &size)) {
|
|
||||||
DEBUG_FUNCTION_LINE("Inkay: OSGetMemBound failed!");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
replace(base_addr, size, original_url, sizeof(original_url), new_url, sizeof(new_url));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ON_APPLICATION_ENDS() {
|
WUMS_EXPORT_FUNCTION(Inkay_Initialize);
|
||||||
DEBUG_FUNCTION_LINE("Inkay: shutting down...\n");
|
WUMS_EXPORT_FUNCTION(Inkay_GetStatus);
|
||||||
StopNotificationThread();
|
WUMS_EXPORT_FUNCTION(Inkay_SetPluginRunning);
|
||||||
}
|
|
||||||
|
|
||||||
static std::optional<FSFileHandle> rootca_pem_handle{};
|
|
||||||
|
|
||||||
DECL_FUNCTION(int, FSOpenFile, FSClient *client, FSCmdBlock *block, char *path, const char *mode, uint32_t *handle, int error) {
|
|
||||||
const char *initialOma = "vol/content/initial.oma";
|
|
||||||
|
|
||||||
if (!Config::connect_to_network) {
|
|
||||||
DEBUG_FUNCTION_LINE("Inkay: Miiverse patches skipped.");
|
|
||||||
return real_FSOpenFile(client, block, path, mode, handle, error);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (strcmp(initialOma, path) == 0) {
|
|
||||||
//below is a hacky (yet functional!) way to get Inkay to redirect URLs from the Miiverse applet
|
|
||||||
//we do it when loading this file since it should only load once, preventing massive lag spikes as it searches all of MEM2 xD
|
|
||||||
//WHBLogUdpInit();
|
|
||||||
|
|
||||||
DEBUG_FUNCTION_LINE("Inkay: hewwo!\n");
|
|
||||||
|
|
||||||
auto olvLoaded = check_olv_libs();
|
|
||||||
|
|
||||||
if (!olvLoaded) {
|
|
||||||
DEBUG_FUNCTION_LINE("Inkay: no olv, quitting for now\n");
|
|
||||||
} else {
|
|
||||||
uint32_t base_addr, size;
|
|
||||||
if (OSGetMemBound(OS_MEM2, &base_addr, &size)) {
|
|
||||||
DEBUG_FUNCTION_LINE("Inkay: OSGetMemBound failed!");
|
|
||||||
} else {
|
|
||||||
//We replace 2 times here.
|
|
||||||
//The first is for nn_olv, the second Wave (the applet itself)
|
|
||||||
replace(base_addr, size, original_url, sizeof(original_url), new_url, sizeof(new_url));
|
|
||||||
replace(0x10000000, 0x10000000, wave_original, sizeof(wave_original), wave_new, sizeof(wave_new));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Check for root CA file and take note of its handle
|
|
||||||
} else if (strcmp("vol/content/browser/rootca.pem", path) == 0) {
|
|
||||||
int ret = real_FSOpenFile(client, block, path, mode, handle, error);
|
|
||||||
rootca_pem_handle = *handle;
|
|
||||||
DEBUG_FUNCTION_LINE("Inkay: Found Miiverse CA, replacing...");
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
return real_FSOpenFile(client, block, path, mode, handle, error);
|
|
||||||
}
|
|
||||||
|
|
||||||
DECL_FUNCTION(FSStatus, FSReadFile, FSClient *client, FSCmdBlock *block, uint8_t *buffer, uint32_t size, uint32_t count, FSFileHandle handle, uint32_t unk1, uint32_t flags) {
|
|
||||||
if (size != 1) {
|
|
||||||
DEBUG_FUNCTION_LINE("Inkay: Miiverse CA replacement failed!");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (rootca_pem_handle && *rootca_pem_handle == handle) {
|
|
||||||
memset(buffer, 0, size);
|
|
||||||
strcpy((char*)buffer, (const char*)ca_pem);
|
|
||||||
|
|
||||||
//this can't be done above (in the FSOpenFile hook) since it's not loaded yet.
|
|
||||||
replaceBulk(0x10000000, 0x10000000, miiverse_green_highlight, sizeof(miiverse_green_highlight), juxt_purple_highlight, sizeof(juxt_purple_highlight));
|
|
||||||
replaceBulk(0x10000000, 0x10000000, miiverse_green_touch1, sizeof(miiverse_green_touch1), juxt_purple_touch1, sizeof(juxt_purple_touch1));
|
|
||||||
replaceBulk(0x10000000, 0x10000000, miiverse_green_touch2, sizeof(miiverse_green_touch2), juxt_purple_touch2, sizeof(juxt_purple_touch2));
|
|
||||||
|
|
||||||
return (FSStatus)count;
|
|
||||||
}
|
|
||||||
|
|
||||||
return real_FSReadFile(client, block, buffer, size, count, handle, unk1, flags);
|
|
||||||
}
|
|
||||||
|
|
||||||
DECL_FUNCTION(FSStatus, FSCloseFile, FSClient * client, FSCmdBlock * block, FSFileHandle handle, FSErrorFlag errorMask) {
|
|
||||||
if (handle == rootca_pem_handle) {
|
|
||||||
rootca_pem_handle.reset();
|
|
||||||
}
|
|
||||||
|
|
||||||
return real_FSCloseFile(client, block, handle, errorMask);
|
|
||||||
}
|
|
||||||
|
|
||||||
DECL_FUNCTION(uint32_t, NSSLExportInternalServerCertificate, NSSLServerCertId cert, int unk, void* unk2, void* unk3) {
|
|
||||||
if (cert == NSSL_SERVER_CERT_THAWTE_PREMIUM_SERVER_CA) { // Martini patches
|
|
||||||
OSFatal("[598-0069] Please uninstall Martini patches to continue.\n" \
|
|
||||||
"See pretendo.network/docs/search for more info.\n\n" \
|
|
||||||
"Hold the POWER button for 4 seconds to shut down.\n\n"
|
|
||||||
" .\n"
|
|
||||||
".---------.'---.\n"
|
|
||||||
"'. : .'\n"
|
|
||||||
" '. .::: .'\n"
|
|
||||||
" '.'::'.'\n"
|
|
||||||
" '||'\n"
|
|
||||||
" ||\n"
|
|
||||||
" ||\n"
|
|
||||||
"mrz ||\n"
|
|
||||||
" ---====---");
|
|
||||||
}
|
|
||||||
return real_NSSLExportInternalServerCertificate(cert, unk, unk2, unk3);
|
|
||||||
}
|
|
||||||
|
|
||||||
WUPS_MUST_REPLACE_FOR_PROCESS(FSOpenFile, WUPS_LOADER_LIBRARY_COREINIT, FSOpenFile, WUPS_FP_TARGET_PROCESS_MIIVERSE);
|
|
||||||
WUPS_MUST_REPLACE_FOR_PROCESS(FSReadFile, WUPS_LOADER_LIBRARY_COREINIT, FSReadFile, WUPS_FP_TARGET_PROCESS_MIIVERSE);
|
|
||||||
WUPS_MUST_REPLACE_FOR_PROCESS(FSCloseFile, WUPS_LOADER_LIBRARY_COREINIT, FSCloseFile, WUPS_FP_TARGET_PROCESS_MIIVERSE);
|
|
||||||
WUPS_MUST_REPLACE_FOR_PROCESS(NSSLExportInternalServerCertificate, WUPS_LOADER_LIBRARY_NSYSNET, NSSLExportInternalServerCertificate, WUPS_FP_TARGET_PROCESS_MIIVERSE);
|
|
||||||
|
|
|
||||||
170
src/patches/account_settings.cpp
Normal file
170
src/patches/account_settings.cpp
Normal file
|
|
@ -0,0 +1,170 @@
|
||||||
|
/* Copyright 2023 Pretendo Network contributors <pretendo.network>
|
||||||
|
Copyright 2023 Jemma Poffinbarger <jemma@jemsoftware.dev>
|
||||||
|
Copyright 2023 Ash Logan <ash@heyquark.com>
|
||||||
|
Copyright 2019 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 "config.h"
|
||||||
|
#include "olv_urls.h"
|
||||||
|
#include "utils/logger.h"
|
||||||
|
#include "utils/replace_mem.h"
|
||||||
|
#include "inkay_config.h"
|
||||||
|
|
||||||
|
#include <function_patcher/function_patching.h>
|
||||||
|
|
||||||
|
#include <coreinit/filesystem.h>
|
||||||
|
#include <coreinit/title.h>
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
#include <optional>
|
||||||
|
|
||||||
|
#include "ca_pem.h" // generated at buildtime
|
||||||
|
|
||||||
|
#define ACCOUNT_SETTINGS_TID_J 0x000500101004B000
|
||||||
|
#define ACCOUNT_SETTINGS_TID_U 0x000500101004B100
|
||||||
|
#define ACCOUNT_SETTINGS_TID_E 0x000500101004B200
|
||||||
|
|
||||||
|
struct account_settings_allowlist {
|
||||||
|
char scheme[16];
|
||||||
|
char domain[128];
|
||||||
|
char path[128]; // unverified
|
||||||
|
uint32_t flags;
|
||||||
|
};
|
||||||
|
|
||||||
|
constexpr struct account_settings_allowlist original_entry = {
|
||||||
|
.scheme = "https",
|
||||||
|
.domain = "account.nintendo.net",
|
||||||
|
.path = "",
|
||||||
|
.flags = 0x01010101,
|
||||||
|
};
|
||||||
|
|
||||||
|
constexpr struct account_settings_allowlist new_entry = {
|
||||||
|
.scheme = "https",
|
||||||
|
.domain = "account." NETWORK_BASEURL,
|
||||||
|
.path = "",
|
||||||
|
.flags = 0x01010101,
|
||||||
|
};
|
||||||
|
constexpr char wave_original[] = "saccount.nintendo.net";
|
||||||
|
|
||||||
|
constexpr char wave_new[] = "saccount." NETWORK_BASEURL;
|
||||||
|
|
||||||
|
static bool isAccountSettingsTitle() {
|
||||||
|
return (OSGetTitleID() != 0 && (
|
||||||
|
OSGetTitleID() == ACCOUNT_SETTINGS_TID_J ||
|
||||||
|
OSGetTitleID() == ACCOUNT_SETTINGS_TID_U ||
|
||||||
|
OSGetTitleID() == ACCOUNT_SETTINGS_TID_E
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::optional<FSFileHandle> rootca_pem_handle{};
|
||||||
|
std::vector<PatchedFunctionHandle> account_patches;
|
||||||
|
|
||||||
|
DECL_FUNCTION(int, FSOpenFile_accSettings, FSClient *client, FSCmdBlock *block, char *path, const char *mode, uint32_t *handle,
|
||||||
|
int error) {
|
||||||
|
if(!isAccountSettingsTitle()) {
|
||||||
|
return real_FSOpenFile_accSettings(client, block, path, mode, handle, error);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!Config::connect_to_network) {
|
||||||
|
DEBUG_FUNCTION_LINE_VERBOSE("Inkay: account settings patches skipped.");
|
||||||
|
return real_FSOpenFile_accSettings(client, block, path, mode, handle, error);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check for root CA file and take note of its handle
|
||||||
|
if (strcmp("vol/content/browser/rootca.pem", path) == 0) {
|
||||||
|
int ret = real_FSOpenFile_accSettings(client, block, path, mode, handle, error);
|
||||||
|
rootca_pem_handle = *handle;
|
||||||
|
DEBUG_FUNCTION_LINE_VERBOSE("Inkay: Found account settings CA, replacing...");
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
return real_FSOpenFile_accSettings(client, block, path, mode, handle, error);
|
||||||
|
}
|
||||||
|
|
||||||
|
DECL_FUNCTION(FSStatus, FSReadFile_accSettings, FSClient *client, FSCmdBlock *block, uint8_t *buffer, uint32_t size, uint32_t count,
|
||||||
|
FSFileHandle handle, uint32_t unk1, uint32_t flags) {
|
||||||
|
if(!isAccountSettingsTitle()) {
|
||||||
|
return real_FSReadFile_accSettings(client, block, buffer, size, count, handle, unk1, flags);
|
||||||
|
}
|
||||||
|
if (size != 1) {
|
||||||
|
DEBUG_FUNCTION_LINE("Inkay: account settings CA replacement failed!");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rootca_pem_handle && *rootca_pem_handle == handle) {
|
||||||
|
strlcpy((char *) buffer, (const char *) ca_pem, size * count);
|
||||||
|
return (FSStatus) count;
|
||||||
|
}
|
||||||
|
return real_FSReadFile_accSettings(client, block, buffer, size, count, handle, unk1, flags);
|
||||||
|
}
|
||||||
|
|
||||||
|
DECL_FUNCTION(FSStatus, FSCloseFile_accSettings, FSClient *client, FSCmdBlock *block, FSFileHandle handle, FSErrorFlag errorMask) {
|
||||||
|
if(!isAccountSettingsTitle()) {
|
||||||
|
return real_FSCloseFile_accSettings(client, block, handle, errorMask);
|
||||||
|
}
|
||||||
|
if (handle == rootca_pem_handle) {
|
||||||
|
rootca_pem_handle.reset();
|
||||||
|
}
|
||||||
|
return real_FSCloseFile_accSettings(client, block, handle, errorMask);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool patchAccountSettings() {
|
||||||
|
account_patches.reserve(3);
|
||||||
|
|
||||||
|
auto add_patch = [](function_replacement_data_t repl, const char *name) {
|
||||||
|
PatchedFunctionHandle handle = 0;
|
||||||
|
if (FunctionPatcher_AddFunctionPatch(&repl, &handle, nullptr) != FUNCTION_PATCHER_RESULT_SUCCESS) {
|
||||||
|
DEBUG_FUNCTION_LINE("Inkay/Account: Failed to patch %s!", name);
|
||||||
|
}
|
||||||
|
account_patches.push_back(handle);
|
||||||
|
};
|
||||||
|
|
||||||
|
add_patch(REPLACE_FUNCTION_FOR_PROCESS(FSOpenFile_accSettings, LIBRARY_COREINIT, FSOpenFile, FP_TARGET_PROCESS_GAME), "FSOpenFile_accSettings");
|
||||||
|
add_patch(REPLACE_FUNCTION_FOR_PROCESS(FSReadFile_accSettings, LIBRARY_COREINIT, FSReadFile, FP_TARGET_PROCESS_GAME), "FSReadFile_accSettings");
|
||||||
|
add_patch(REPLACE_FUNCTION_FOR_PROCESS(FSCloseFile_accSettings, LIBRARY_COREINIT, FSCloseFile, FP_TARGET_PROCESS_GAME), "FSCloseFile_accSettings");
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool hotpatchAccountSettings() {
|
||||||
|
if(!isAccountSettingsTitle()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!Config::connect_to_network) {
|
||||||
|
DEBUG_FUNCTION_LINE_VERBOSE("Inkay: account settings patches skipped.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
DEBUG_FUNCTION_LINE_VERBOSE("Inkay: hewwo account settings!\n");
|
||||||
|
|
||||||
|
if (!replace(0x10000000, 0x10000000, wave_original, sizeof(wave_original), wave_new, sizeof(wave_new))) {
|
||||||
|
DEBUG_FUNCTION_LINE("Inkay: We didn't find the url /)>~<(\\");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!replace(0x10000000, 0x10000000, (const char *)&original_entry, sizeof(original_entry), (const char *)&new_entry, sizeof(new_entry))) {
|
||||||
|
DEBUG_FUNCTION_LINE("Inkay: We didn't find the whitelist /)>~<(\\");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void unpatchAccountSettings() {
|
||||||
|
for (const auto handle: account_patches) {
|
||||||
|
FunctionPatcher_RemoveFunctionPatch(handle);
|
||||||
|
}
|
||||||
|
account_patches.clear();
|
||||||
|
}
|
||||||
20
src/patches/account_settings.h
Normal file
20
src/patches/account_settings.h
Normal file
|
|
@ -0,0 +1,20 @@
|
||||||
|
/* Copyright 2023 Pretendo Network contributors <pretendo.network>
|
||||||
|
Copyright 2023 Jemma Poffinbarger <jemma@jemsoftware.dev>
|
||||||
|
Copyright 2023 Ash Logan <ash@heyquark.com>
|
||||||
|
Copyright 2019 Maschell
|
||||||
|
|
||||||
|
Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby
|
||||||
|
granted, provided that the above copyright notice and this permission notice appear in all copies.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
|
||||||
|
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
||||||
|
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
|
||||||
|
IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||||
|
PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
bool patchAccountSettings();
|
||||||
|
bool hotpatchAccountSettings();
|
||||||
|
void unpatchAccountSettings();
|
||||||
76
src/patches/dns_hooks.cpp
Normal file
76
src/patches/dns_hooks.cpp
Normal file
|
|
@ -0,0 +1,76 @@
|
||||||
|
/* Copyright 2024 Pretendo Network contributors <pretendo.network>
|
||||||
|
Copyright 2024 Ash Logan <ash@heyquark.com>
|
||||||
|
|
||||||
|
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 <netdb.h>
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
#include "utils/logger.h"
|
||||||
|
#include "inkay_config.h"
|
||||||
|
#include <array>
|
||||||
|
#include <vector>
|
||||||
|
#include <function_patcher/function_patching.h>
|
||||||
|
|
||||||
|
std::vector<PatchedFunctionHandle> dns_patches;
|
||||||
|
|
||||||
|
constexpr std::pair<const char *, const char *> dns_replacements[] = {
|
||||||
|
// NNCS servers
|
||||||
|
{ "nncs1.app.nintendowifi.net", "nncs1.app." NETWORK_BASEURL },
|
||||||
|
{ "nncs2.app.nintendowifi.net", "nncs2.app." NETWORK_BASEURL },
|
||||||
|
};
|
||||||
|
|
||||||
|
static const char * replace_dns_name(const char *dns_name) {
|
||||||
|
if (!Config::connect_to_network) return dns_name;
|
||||||
|
|
||||||
|
for (auto [original, replacement] : dns_replacements) {
|
||||||
|
if (strcmp(original, dns_name) == 0)
|
||||||
|
return replacement;
|
||||||
|
}
|
||||||
|
|
||||||
|
return dns_name;
|
||||||
|
}
|
||||||
|
|
||||||
|
DECL_FUNCTION(struct hostent *, gethostbyname, const char *dns_name) {
|
||||||
|
return real_gethostbyname(replace_dns_name(dns_name));
|
||||||
|
}
|
||||||
|
|
||||||
|
DECL_FUNCTION(int, getaddrinfo, const char *node, const char *service, const struct addrinfo *hints, struct addrinfo **res) {
|
||||||
|
return real_getaddrinfo(replace_dns_name(node), service, hints, res);
|
||||||
|
}
|
||||||
|
|
||||||
|
void patchDNS() {
|
||||||
|
dns_patches.reserve(2);
|
||||||
|
|
||||||
|
auto add_patch = [](function_replacement_data_t repl, const char *name) {
|
||||||
|
PatchedFunctionHandle handle = 0;
|
||||||
|
if (FunctionPatcher_AddFunctionPatch(&repl, &handle, nullptr) != FUNCTION_PATCHER_RESULT_SUCCESS) {
|
||||||
|
DEBUG_FUNCTION_LINE("Inkay/DNS: Failed to patch %s!", name);
|
||||||
|
}
|
||||||
|
dns_patches.push_back(handle);
|
||||||
|
};
|
||||||
|
|
||||||
|
// might need a REPLACE_FUNCTION_FOR_PROCESS for Friends
|
||||||
|
add_patch(REPLACE_FUNCTION(gethostbyname, LIBRARY_NSYSNET, gethostbyname), "gethostbyname");
|
||||||
|
|
||||||
|
add_patch(REPLACE_FUNCTION(getaddrinfo, LIBRARY_NSYSNET, getaddrinfo), "getaddrinfo");
|
||||||
|
}
|
||||||
|
|
||||||
|
void unpatchDNS() {
|
||||||
|
for (auto handle: dns_patches) {
|
||||||
|
FunctionPatcher_RemoveFunctionPatch(handle);
|
||||||
|
}
|
||||||
|
dns_patches.clear();
|
||||||
|
}
|
||||||
20
src/patches/dns_hooks.h
Normal file
20
src/patches/dns_hooks.h
Normal file
|
|
@ -0,0 +1,20 @@
|
||||||
|
/* Copyright 2024 Pretendo Network contributors <pretendo.network>
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
void patchDNS();
|
||||||
|
void unpatchDNS();
|
||||||
136
src/patches/eshop_applet.cpp
Normal file
136
src/patches/eshop_applet.cpp
Normal file
|
|
@ -0,0 +1,136 @@
|
||||||
|
/* Copyright 2023 Pretendo Network contributors <pretendo.network>
|
||||||
|
Copyright 2023 Ash Logan <ash@heyquark.com>
|
||||||
|
Copyright 2019 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 "config.h"
|
||||||
|
#include "olv_urls.h"
|
||||||
|
#include "utils/logger.h"
|
||||||
|
#include "utils/replace_mem.h"
|
||||||
|
#include "inkay_config.h"
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
#include <function_patcher/function_patching.h>
|
||||||
|
#include <optional>
|
||||||
|
#include <coreinit/debug.h>
|
||||||
|
#include <coreinit/filesystem.h>
|
||||||
|
#include <nsysnet/nssl.h>
|
||||||
|
|
||||||
|
#include "ca_pem.h" // generated at buildtime
|
||||||
|
|
||||||
|
constexpr char wave_original[] = "https://ninja.wup.shop.nintendo.net/ninja/wood_index.html?";
|
||||||
|
constexpr char wave_new[] = "http://samurai.wup.shop." NETWORK_BASEURL "/ninja/wood_index.html?";
|
||||||
|
|
||||||
|
struct eshop_allowlist {
|
||||||
|
char scheme[16];
|
||||||
|
char domain[128];
|
||||||
|
char path[128]; // unverified
|
||||||
|
unsigned char flags[5];
|
||||||
|
};
|
||||||
|
|
||||||
|
constexpr struct eshop_allowlist original_entry = {
|
||||||
|
.scheme = "https",
|
||||||
|
.domain = "samurai.wup.shop.nintendo.net",
|
||||||
|
.path = "",
|
||||||
|
.flags = {1, 1, 1, 1, 0},
|
||||||
|
};
|
||||||
|
|
||||||
|
constexpr struct eshop_allowlist new_entry = {
|
||||||
|
.scheme = "http",
|
||||||
|
.domain = "samurai.wup.shop." NETWORK_BASEURL,
|
||||||
|
.path = "",
|
||||||
|
.flags = {1, 1, 1, 1, 0},
|
||||||
|
};
|
||||||
|
|
||||||
|
static std::optional<FSFileHandle> rootca_pem_handle{};
|
||||||
|
std::vector<PatchedFunctionHandle> eshop_patches;
|
||||||
|
|
||||||
|
DECL_FUNCTION(int, FSOpenFile_eShop, FSClient *client, FSCmdBlock *block, char *path, const char *mode, uint32_t *handle,
|
||||||
|
int error) {
|
||||||
|
const char *initialOma = "vol/content/initial.oma";
|
||||||
|
|
||||||
|
if (!Config::connect_to_network) {
|
||||||
|
DEBUG_FUNCTION_LINE_VERBOSE("Inkay: eShop patches skipped.");
|
||||||
|
return real_FSOpenFile_eShop(client, block, path, mode, handle, error);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (strcmp(initialOma, path) == 0) {
|
||||||
|
//below is a hacky (yet functional!) way to get Inkay to redirect URLs from the Miiverse applet
|
||||||
|
//we do it when loading this file since it should only load once, preventing massive lag spikes as it searches all of MEM2 xD
|
||||||
|
|
||||||
|
DEBUG_FUNCTION_LINE_VERBOSE("Inkay: hewwo eShop!\n");
|
||||||
|
|
||||||
|
if (!replace(0x10000000, 0x10000000, wave_original, sizeof(wave_original), wave_new, sizeof(wave_new)))
|
||||||
|
DEBUG_FUNCTION_LINE_VERBOSE("Inkay: We didn't find the url /)>~<(\\");
|
||||||
|
|
||||||
|
if (!replace(0x10000000, 0x10000000, (const char *)&original_entry, sizeof(original_entry), (const char *)&new_entry, sizeof(new_entry)))
|
||||||
|
DEBUG_FUNCTION_LINE_VERBOSE("Inkay: We didn't find the whitelist /)>~<(\\");
|
||||||
|
|
||||||
|
// Check for root CA file and take note of its handle
|
||||||
|
} else if (strcmp("vol/content/browser/rootca.pem", path) == 0) {
|
||||||
|
int ret = real_FSOpenFile_eShop(client, block, path, mode, handle, error);
|
||||||
|
rootca_pem_handle = *handle;
|
||||||
|
DEBUG_FUNCTION_LINE_VERBOSE("Inkay: Found eShop CA, replacing...");
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
return real_FSOpenFile_eShop(client, block, path, mode, handle, error);
|
||||||
|
}
|
||||||
|
|
||||||
|
DECL_FUNCTION(FSStatus, FSReadFile_eShop, FSClient *client, FSCmdBlock *block, uint8_t *buffer, uint32_t size, uint32_t count,
|
||||||
|
FSFileHandle handle, uint32_t unk1, uint32_t flags) {
|
||||||
|
if (size != 1) {
|
||||||
|
DEBUG_FUNCTION_LINE("Inkay: eShop CA replacement failed!");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rootca_pem_handle && *rootca_pem_handle == handle) {
|
||||||
|
strlcpy((char *) buffer, (const char *) ca_pem, size * count);
|
||||||
|
return (FSStatus) count;
|
||||||
|
}
|
||||||
|
|
||||||
|
return real_FSReadFile_eShop(client, block, buffer, size, count, handle, unk1, flags);
|
||||||
|
}
|
||||||
|
|
||||||
|
DECL_FUNCTION(FSStatus, FSCloseFile_eShop, FSClient *client, FSCmdBlock *block, FSFileHandle handle, FSErrorFlag errorMask) {
|
||||||
|
if (handle == rootca_pem_handle) {
|
||||||
|
rootca_pem_handle.reset();
|
||||||
|
}
|
||||||
|
|
||||||
|
return real_FSCloseFile_eShop(client, block, handle, errorMask);
|
||||||
|
}
|
||||||
|
|
||||||
|
void patchEshop() {
|
||||||
|
eshop_patches.reserve(3);
|
||||||
|
|
||||||
|
auto add_patch = [](function_replacement_data_t repl, const char *name) {
|
||||||
|
PatchedFunctionHandle handle = 0;
|
||||||
|
if (FunctionPatcher_AddFunctionPatch(&repl, &handle, nullptr) != FUNCTION_PATCHER_RESULT_SUCCESS) {
|
||||||
|
DEBUG_FUNCTION_LINE("Inkay/eShop: Failed to patch %s!", name);
|
||||||
|
}
|
||||||
|
eshop_patches.push_back(handle);
|
||||||
|
};
|
||||||
|
|
||||||
|
add_patch(REPLACE_FUNCTION_FOR_PROCESS(FSOpenFile_eShop, LIBRARY_COREINIT, FSOpenFile, FP_TARGET_PROCESS_ESHOP), "FSOpenFile_eShop");
|
||||||
|
add_patch(REPLACE_FUNCTION_FOR_PROCESS(FSReadFile_eShop, LIBRARY_COREINIT, FSReadFile, FP_TARGET_PROCESS_ESHOP), "FSReadFile_eShop");
|
||||||
|
add_patch(REPLACE_FUNCTION_FOR_PROCESS(FSCloseFile_eShop, LIBRARY_COREINIT, FSCloseFile, FP_TARGET_PROCESS_ESHOP), "FSCloseFile_eShop");
|
||||||
|
}
|
||||||
|
|
||||||
|
void unpatchEshop() {
|
||||||
|
for (auto handle: eshop_patches) {
|
||||||
|
FunctionPatcher_RemoveFunctionPatch(handle);
|
||||||
|
}
|
||||||
|
eshop_patches.clear();
|
||||||
|
}
|
||||||
20
src/patches/eshop_applet.h
Normal file
20
src/patches/eshop_applet.h
Normal file
|
|
@ -0,0 +1,20 @@
|
||||||
|
/* Copyright 2024 Pretendo Network contributors <pretendo.network>
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
void patchEshop();
|
||||||
|
void unpatchEshop();
|
||||||
150
src/patches/game_matchmaking.cpp
Normal file
150
src/patches/game_matchmaking.cpp
Normal file
|
|
@ -0,0 +1,150 @@
|
||||||
|
/* Copyright 2023 Pretendo Network contributors <pretendo.network>
|
||||||
|
Copyright 2023 Ash Logan <ash@heyquark.com>
|
||||||
|
Copyright 2019 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 "config.h"
|
||||||
|
#include "game_matchmaking.h"
|
||||||
|
#include "utils/logger.h"
|
||||||
|
|
||||||
|
#include "ini.h"
|
||||||
|
#include <array>
|
||||||
|
#include <optional>
|
||||||
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
#include <function_patcher/function_patching.h>
|
||||||
|
|
||||||
|
#define MARIO_KART_8_TID_J 0x000500001010EB00
|
||||||
|
#define MARIO_KART_8_TID_U 0x000500001010EC00
|
||||||
|
#define MARIO_KART_8_TID_E 0x000500001010ED00
|
||||||
|
|
||||||
|
constexpr std::array<uint64_t, 3> mk8_tids = {MARIO_KART_8_TID_J, MARIO_KART_8_TID_U, MARIO_KART_8_TID_E};
|
||||||
|
std::vector<PatchedFunctionHandle> matchmaking_patches;
|
||||||
|
|
||||||
|
struct modpack {
|
||||||
|
std::string name = "Mario Kart 8";
|
||||||
|
int dlc_id = -1;
|
||||||
|
};
|
||||||
|
std::optional<modpack> dlc_modpack;
|
||||||
|
|
||||||
|
static int handler(void *user, const char *section, const char *name, const char *value) {
|
||||||
|
auto *mod = (modpack *) user;
|
||||||
|
auto match = [section, name](const char *s, const char *n) -> bool {
|
||||||
|
return strcmp(section, s) == 0 && strcmp(name, n) == 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
if (match("pretendo", "name")) {
|
||||||
|
mod->name = value;
|
||||||
|
} else if (match("pretendo", "dlc_id")) {
|
||||||
|
mod->dlc_id = std::strtol(value, nullptr, 16);
|
||||||
|
} else return 0;
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void check_modpack() {
|
||||||
|
modpack mod;
|
||||||
|
if (ini_parse("fs:/vol/content/pretendo.ini", handler, &mod)) {
|
||||||
|
DEBUG_FUNCTION_LINE_VERBOSE("Inkay/MK8: Doesn't look like a modpack");
|
||||||
|
}
|
||||||
|
|
||||||
|
DEBUG_FUNCTION_LINE("Inkay/MK8: Playing %s (%08x)", mod.name.c_str(), mod.dlc_id);
|
||||||
|
dlc_modpack = mod;
|
||||||
|
}
|
||||||
|
|
||||||
|
DECL_FUNCTION(void, mk8_MatchmakeSessionSearchCriteria_SetAttribute, void *_this, uint32_t attributeIndex,
|
||||||
|
uint32_t attributeValue) {
|
||||||
|
if (attributeIndex == 4) {
|
||||||
|
if (!dlc_modpack) check_modpack();
|
||||||
|
|
||||||
|
const int dlc_id = dlc_modpack->dlc_id;
|
||||||
|
if (dlc_id != -1) {
|
||||||
|
DEBUG_FUNCTION_LINE_VERBOSE("Inkay/MK8: Searching for %s session (%08x)", dlc_modpack->name.c_str(), dlc_id);
|
||||||
|
attributeValue = dlc_id;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
real_mk8_MatchmakeSessionSearchCriteria_SetAttribute(_this, attributeIndex, attributeValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
DECL_FUNCTION(void, mk8_MatchmakeSession_SetAttribute, void *_this, uint32_t attributeIndex, uint32_t attributeValue) {
|
||||||
|
if (attributeIndex == 4) {
|
||||||
|
if (!dlc_modpack) check_modpack();
|
||||||
|
|
||||||
|
const int dlc_id = dlc_modpack->dlc_id;
|
||||||
|
if (dlc_id != -1) {
|
||||||
|
DEBUG_FUNCTION_LINE_VERBOSE("Inkay/MK8: Creating %s session (%08x)", dlc_modpack->name.c_str(), dlc_id);
|
||||||
|
attributeValue = dlc_id;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
real_mk8_MatchmakeSession_SetAttribute(_this, attributeIndex, attributeValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
void install_matchmaking_patches() {
|
||||||
|
if (!Config::connect_to_network) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
matchmaking_patches.reserve(4);
|
||||||
|
|
||||||
|
auto add_patch = [](function_replacement_data_t repl, const char *game, const char *name) {
|
||||||
|
PatchedFunctionHandle handle = 0;
|
||||||
|
if (FunctionPatcher_AddFunctionPatch(&repl, &handle, nullptr) != FUNCTION_PATCHER_RESULT_SUCCESS) {
|
||||||
|
DEBUG_FUNCTION_LINE("Inkay/%s: Failed to patch %s!", game, name);
|
||||||
|
}
|
||||||
|
matchmaking_patches.push_back(handle);
|
||||||
|
};
|
||||||
|
|
||||||
|
add_patch(REPLACE_FUNCTION_OF_EXECUTABLE_BY_ADDRESS_WITH_VERSION(
|
||||||
|
mk8_MatchmakeSessionSearchCriteria_SetAttribute,
|
||||||
|
mk8_tids.data(), mk8_tids.size(),
|
||||||
|
"Turbo.rpx",
|
||||||
|
0x0098e7b4, 64, 64
|
||||||
|
), "MK8", "MatchmakeSessionSearchCriteria::SetAttribute");
|
||||||
|
add_patch(REPLACE_FUNCTION_OF_EXECUTABLE_BY_ADDRESS_WITH_VERSION(
|
||||||
|
mk8_MatchmakeSessionSearchCriteria_SetAttribute,
|
||||||
|
mk8_tids.data(), mk8_tids.size(),
|
||||||
|
"Turbo.rpx",
|
||||||
|
0x0098eafc, 81, 81
|
||||||
|
), "MK8", "MatchmakeSessionSearchCriteria::SetAttribute");
|
||||||
|
|
||||||
|
|
||||||
|
add_patch(REPLACE_FUNCTION_OF_EXECUTABLE_BY_ADDRESS_WITH_VERSION(
|
||||||
|
mk8_MatchmakeSession_SetAttribute,
|
||||||
|
mk8_tids.data(), mk8_tids.size(),
|
||||||
|
"Turbo.rpx",
|
||||||
|
0x0098e52c, 64, 64
|
||||||
|
), "MK8", "MatchmakeSession::SetAttribute");
|
||||||
|
|
||||||
|
add_patch(REPLACE_FUNCTION_OF_EXECUTABLE_BY_ADDRESS_WITH_VERSION(
|
||||||
|
mk8_MatchmakeSession_SetAttribute,
|
||||||
|
mk8_tids.data(), mk8_tids.size(),
|
||||||
|
"Turbo.rpx",
|
||||||
|
0x0098e874, 81, 81
|
||||||
|
), "MK8", "MatchmakeSession::SetAttribute");
|
||||||
|
}
|
||||||
|
|
||||||
|
void remove_matchmaking_patches() {
|
||||||
|
for (auto handle: matchmaking_patches) {
|
||||||
|
FunctionPatcher_RemoveFunctionPatch(handle);
|
||||||
|
}
|
||||||
|
matchmaking_patches.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
void matchmaking_notify_titleswitch() {
|
||||||
|
dlc_modpack.reset();
|
||||||
|
}
|
||||||
19
src/patches/game_matchmaking.h
Normal file
19
src/patches/game_matchmaking.h
Normal file
|
|
@ -0,0 +1,19 @@
|
||||||
|
/* Copyright 2023 Pretendo Network contributors <pretendo.network>
|
||||||
|
Copyright 2023 Ash Logan <ash@heyquark.com>
|
||||||
|
Copyright 2019 Maschell
|
||||||
|
|
||||||
|
Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby
|
||||||
|
granted, provided that the above copyright notice and this permission notice appear in all copies.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
|
||||||
|
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
||||||
|
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
|
||||||
|
IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||||
|
PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
void install_matchmaking_patches();
|
||||||
|
void remove_matchmaking_patches();
|
||||||
|
void matchmaking_notify_titleswitch();
|
||||||
131
src/patches/game_peertopeer.cpp
Normal file
131
src/patches/game_peertopeer.cpp
Normal file
|
|
@ -0,0 +1,131 @@
|
||||||
|
/* Copyright 2024 Pretendo Network contributors <pretendo.network>
|
||||||
|
Copyright 2024 Ash Logan <ash@heyquark.com>
|
||||||
|
|
||||||
|
Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby
|
||||||
|
granted, provided that the above copyright notice and this permission notice appear in all copies.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
|
||||||
|
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
||||||
|
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
|
||||||
|
IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||||
|
PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <coreinit/title.h>
|
||||||
|
#include <coreinit/dynload.h>
|
||||||
|
#include "game_peertopeer.h"
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
#include "sysconfig.h"
|
||||||
|
#include "utils/logger.h"
|
||||||
|
#include "utils/rpl_info.h"
|
||||||
|
#include "utils/replace_mem.h"
|
||||||
|
|
||||||
|
#include <optional>
|
||||||
|
#include <algorithm>
|
||||||
|
#include <string_view>
|
||||||
|
using namespace std::string_view_literals;
|
||||||
|
|
||||||
|
static struct {
|
||||||
|
std::array<uint64_t, 3> tid;
|
||||||
|
uint16_t version;
|
||||||
|
uint32_t min_port_addr;
|
||||||
|
uint32_t max_port_addr;
|
||||||
|
std::string_view rpx;
|
||||||
|
} generic_patch_games[] = {
|
||||||
|
{
|
||||||
|
// MARIO KART 8
|
||||||
|
{0x00050000'1010ec00, 0x00050000'1010ed00, 0x00050000'1010eb00},
|
||||||
|
81,
|
||||||
|
0x101a9a52,
|
||||||
|
0x101a9a54,
|
||||||
|
"Turbo.rpx"sv,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
// Splatoon
|
||||||
|
{0x00050000'10176900, 0x00050000'10176a00, 0x00050000'10162b00},
|
||||||
|
288,
|
||||||
|
0x101e8952,
|
||||||
|
0x101e8954,
|
||||||
|
"Gambit.rpx"sv,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
static void generic_peertopeer_patch() {
|
||||||
|
uint64_t tid = OSGetTitleID();
|
||||||
|
uint16_t title_version = 0;
|
||||||
|
if (const auto version_opt = get_current_title_version(); !version_opt) {
|
||||||
|
DEBUG_FUNCTION_LINE("Failed to detect current title version");
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
title_version = *version_opt;
|
||||||
|
DEBUG_FUNCTION_LINE("Title version detected: %d", title_version);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const auto &patch: generic_patch_games) {
|
||||||
|
if (std::ranges::find(patch.tid, tid) == patch.tid.end()) continue;
|
||||||
|
|
||||||
|
std::optional<OSDynLoad_NotifyData> game = search_for_rpl(patch.rpx);
|
||||||
|
if (!game) {
|
||||||
|
DEBUG_FUNCTION_LINE("Couldn't find game rpx! (%s)", patch.rpx.data());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (title_version != patch.version) {
|
||||||
|
DEBUG_FUNCTION_LINE("Unexpected title version. Expected %d but got %d (%s)", patch.version, title_version,
|
||||||
|
patch.rpx.data());
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto port = get_console_peertopeer_port();
|
||||||
|
DEBUG_FUNCTION_LINE_VERBOSE("Will use port %d. %08x", port, game->textAddr);
|
||||||
|
|
||||||
|
auto target = (uint16_t *)rpl_addr(*game, patch.min_port_addr);
|
||||||
|
replace_unsigned<uint16_t>(target, 0xc000, port);
|
||||||
|
|
||||||
|
target = (uint16_t *)rpl_addr(*game, patch.max_port_addr);
|
||||||
|
replace_unsigned<uint16_t>(target, 0xffff, port);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void minecraft_peertopeer_patch() {
|
||||||
|
std::optional<OSDynLoad_NotifyData> minecraft = search_for_rpl("Minecraft.Client.rpx"sv);
|
||||||
|
if (!minecraft) {
|
||||||
|
DEBUG_FUNCTION_LINE("Couldn't find minecraft rpx!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (const auto version_opt = get_current_title_version(); !version_opt || *version_opt != 688) {
|
||||||
|
DEBUG_FUNCTION_LINE("Wrong mincecraft version detected");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto port = get_console_peertopeer_port();
|
||||||
|
DEBUG_FUNCTION_LINE_VERBOSE("Will use port %d. %08x", port, minecraft->textAddr);
|
||||||
|
|
||||||
|
auto target_func = (uint32_t *)rpl_addr(*minecraft, 0x03579530);
|
||||||
|
replace_instruction(&target_func[0], 0x3c600001, 0x3c600000); // li r3, 0
|
||||||
|
replace_instruction(&target_func[1], 0x3863c000, 0x60630000 | port); // ori r3, r3, port
|
||||||
|
// blr
|
||||||
|
|
||||||
|
target_func = (uint32_t *)rpl_addr(*minecraft, 0x0357953c);
|
||||||
|
replace_instruction(&target_func[0], 0x3c600001, 0x3c600000); // li r3, 0
|
||||||
|
replace_instruction(&target_func[1], 0x3863ffff, 0x60630000 | port); // ori r3, r3, port
|
||||||
|
// blr
|
||||||
|
}
|
||||||
|
|
||||||
|
void peertopeer_patch() {
|
||||||
|
if (!Config::connect_to_network) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint64_t tid = OSGetTitleID();
|
||||||
|
if (tid == 0x00050000'101D7500 || // EUR
|
||||||
|
tid == 0x00050000'101D9D00 || // USA
|
||||||
|
tid == 0x00050000'101DBE00) { // JPN
|
||||||
|
|
||||||
|
minecraft_peertopeer_patch();
|
||||||
|
} else {
|
||||||
|
generic_peertopeer_patch();
|
||||||
|
}
|
||||||
|
}
|
||||||
16
src/patches/game_peertopeer.h
Normal file
16
src/patches/game_peertopeer.h
Normal file
|
|
@ -0,0 +1,16 @@
|
||||||
|
/* Copyright 2024 Pretendo Network contributors <pretendo.network>
|
||||||
|
Copyright 2024 Ash Logan <ash@heyquark.com>
|
||||||
|
|
||||||
|
Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby
|
||||||
|
granted, provided that the above copyright notice and this permission notice appear in all copies.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
|
||||||
|
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
||||||
|
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
|
||||||
|
IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||||
|
PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
void peertopeer_patch();
|
||||||
202
src/patches/olv_applet.cpp
Normal file
202
src/patches/olv_applet.cpp
Normal file
|
|
@ -0,0 +1,202 @@
|
||||||
|
/* Copyright 2023 Pretendo Network contributors <pretendo.network>
|
||||||
|
Copyright 2023 Ash Logan <ash@heyquark.com>
|
||||||
|
Copyright 2019 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 "config.h"
|
||||||
|
#include "olv_urls.h"
|
||||||
|
#include "utils/logger.h"
|
||||||
|
#include "utils/replace_mem.h"
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
#include <optional>
|
||||||
|
#include <coreinit/debug.h>
|
||||||
|
#include <coreinit/filesystem.h>
|
||||||
|
#include <nsysnet/nssl.h>
|
||||||
|
#include <function_patcher/function_patching.h>
|
||||||
|
|
||||||
|
#include "ca_pem.h" // generated at buildtime
|
||||||
|
|
||||||
|
struct olv_allowlist {
|
||||||
|
char scheme[16];
|
||||||
|
char domain[128];
|
||||||
|
char path[128]; // unverified
|
||||||
|
unsigned char flags[5];
|
||||||
|
};
|
||||||
|
|
||||||
|
constexpr struct olv_allowlist original_entry = {
|
||||||
|
.scheme = "https",
|
||||||
|
.domain = ".nintendo.net",
|
||||||
|
.path = "",
|
||||||
|
.flags = {1, 1, 1, 1, 1},
|
||||||
|
};
|
||||||
|
|
||||||
|
constexpr struct olv_allowlist new_entry = {
|
||||||
|
.scheme = "https",
|
||||||
|
.domain = ".spbr.net",
|
||||||
|
.path = "",
|
||||||
|
.flags = {1, 1, 1, 1, 1},
|
||||||
|
};
|
||||||
|
|
||||||
|
const unsigned char miiverse_green_highlight[] = {
|
||||||
|
0x82, 0xff, 0x05, 0xff, 0x82, 0xff, 0x05, 0xff, 0x1d, 0xff, 0x04, 0xff, 0x1d, 0xff, 0x04, 0xff
|
||||||
|
};
|
||||||
|
const unsigned char juxt_purple_highlight[] = {
|
||||||
|
0x5d, 0x4a, 0x9a, 0xff, 0x5d, 0x4a, 0x9a, 0xff, 0x5d, 0x4a, 0x9a, 0xff, 0x5d, 0x4a, 0x9a, 0xff
|
||||||
|
};
|
||||||
|
const unsigned char miiverse_green_touch1[] = {
|
||||||
|
0x94, 0xd9, 0x2a, 0x00, 0x57, 0xbd, 0x12, 0xff
|
||||||
|
};
|
||||||
|
const unsigned char juxt_purple_touch1[] = {
|
||||||
|
0x5d, 0x4a, 0x9a, 0x00, 0x5d, 0x4a, 0x9a, 0xff
|
||||||
|
};
|
||||||
|
const unsigned char miiverse_green_touch2[] = {
|
||||||
|
0x57, 0xbd, 0x12, 0x00, 0x94, 0xd9, 0x2a, 0xff
|
||||||
|
};
|
||||||
|
const unsigned char juxt_purple_touch2[] = {
|
||||||
|
0x5d, 0x4a, 0x9a, 0x00, 0x5d, 0x4a, 0x9a, 0xff
|
||||||
|
};
|
||||||
|
|
||||||
|
const replacement replacements[] = {
|
||||||
|
{miiverse_green_highlight, juxt_purple_highlight},
|
||||||
|
{miiverse_green_touch1, juxt_purple_touch1},
|
||||||
|
{miiverse_green_touch2, juxt_purple_touch2},
|
||||||
|
};
|
||||||
|
|
||||||
|
static std::optional<FSFileHandle> rootca_pem_handle{};
|
||||||
|
static std::optional<FSFileHandle> valid_tld_handle{};
|
||||||
|
std::vector<PatchedFunctionHandle> olv_patches;
|
||||||
|
|
||||||
|
DECL_FUNCTION(int, FSOpenFile, FSClient *client, FSCmdBlock *block, char *path, const char *mode, uint32_t *handle,
|
||||||
|
int error) {
|
||||||
|
const char *initialOma = "vol/content/initial.oma";
|
||||||
|
|
||||||
|
if (!Config::connect_to_network) {
|
||||||
|
DEBUG_FUNCTION_LINE_VERBOSE("Inkay: Miiverse patches skipped.");
|
||||||
|
return real_FSOpenFile(client, block, path, mode, handle, error);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (strcmp(initialOma, path) == 0) {
|
||||||
|
//below is a hacky (yet functional!) way to get Inkay to redirect URLs from the Miiverse applet
|
||||||
|
//we do it when loading this file since it should only load once, preventing massive lag spikes as it searches all of MEM2 xD
|
||||||
|
//WHBLogUdpInit();
|
||||||
|
|
||||||
|
DEBUG_FUNCTION_LINE_VERBOSE("Inkay: hewwo!\n");
|
||||||
|
|
||||||
|
auto olv_ok = setup_olv_libs();
|
||||||
|
// Patch applet binary too
|
||||||
|
if (olv_ok)
|
||||||
|
replace(0x10000000, 0x10000000, (const char *)&original_entry, sizeof(original_entry), (const char *)&new_entry, sizeof(new_entry));
|
||||||
|
// Check for root CA file and take note of its handle
|
||||||
|
} else if (strcmp("vol/content/browser/rootca.pem", path) == 0) {
|
||||||
|
int ret = real_FSOpenFile(client, block, path, mode, handle, error);
|
||||||
|
rootca_pem_handle = *handle;
|
||||||
|
DEBUG_FUNCTION_LINE_VERBOSE("Inkay: Found Miiverse CA, replacing...");
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
else if (strcmp("vol/content/browser/effective_tld_names.dat", path) == 0)
|
||||||
|
{
|
||||||
|
// we patch the TLD because .cafe isnt on the list
|
||||||
|
int ret = real_FSOpenFile(client, block, path, mode, handle, error);
|
||||||
|
valid_tld_handle = *handle;
|
||||||
|
DEBUG_FUNCTION_LINE_VERBOSE("Inkay: Found Miiverse TLD List, patching...");
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
return real_FSOpenFile(client, block, path, mode, handle, error);
|
||||||
|
}
|
||||||
|
|
||||||
|
DECL_FUNCTION(FSStatus, FSReadFile, FSClient *client, FSCmdBlock *block, uint8_t *buffer, uint32_t size, uint32_t count,
|
||||||
|
FSFileHandle handle, uint32_t unk1, uint32_t flags)
|
||||||
|
{
|
||||||
|
if (size != 1)
|
||||||
|
{
|
||||||
|
DEBUG_FUNCTION_LINE("Inkay: Miiverse CA/LTD replacement failed!");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rootca_pem_handle && *rootca_pem_handle == handle)
|
||||||
|
{
|
||||||
|
strlcpy((char *)buffer, (const char *)ca_pem, size * count);
|
||||||
|
|
||||||
|
// this can't be done above (in the FSOpenFile hook) since it's not loaded yet.
|
||||||
|
// the hardcoded offsets suck but they really are at Random Places In The Heap
|
||||||
|
return (FSStatus)count;
|
||||||
|
}
|
||||||
|
else if (valid_tld_handle && *valid_tld_handle == handle)
|
||||||
|
{
|
||||||
|
// we patch the tld "aero"...
|
||||||
|
FSStatus ret = real_FSReadFile(
|
||||||
|
client, block, buffer, size, count, handle, unk1, flags);
|
||||||
|
|
||||||
|
if (ret > 0)
|
||||||
|
{
|
||||||
|
uint32_t totalSize = size * count;
|
||||||
|
char *buf = (char *)buffer;
|
||||||
|
|
||||||
|
for (uint32_t i = 0; i + 4 <= totalSize; i++)
|
||||||
|
{
|
||||||
|
if (memcmp(&buf[i], "aero", 4) == 0)
|
||||||
|
{
|
||||||
|
memcpy(&buf[i], "cafe", 4);
|
||||||
|
|
||||||
|
DEBUG_FUNCTION_LINE_VERBOSE(
|
||||||
|
"Inkay: patched TLD aero -> cafe");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
return real_FSReadFile(client, block, buffer, size, count, handle, unk1, flags);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
DECL_FUNCTION(FSStatus, FSCloseFile, FSClient *client, FSCmdBlock *block, FSFileHandle handle, FSErrorFlag errorMask) {
|
||||||
|
if (handle == rootca_pem_handle) {
|
||||||
|
rootca_pem_handle.reset();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (handle == valid_tld_handle)
|
||||||
|
{
|
||||||
|
valid_tld_handle.reset();
|
||||||
|
}
|
||||||
|
|
||||||
|
return real_FSCloseFile(client, block, handle, errorMask);
|
||||||
|
}
|
||||||
|
|
||||||
|
void patchOlvApplet() {
|
||||||
|
olv_patches.reserve(3);
|
||||||
|
|
||||||
|
auto add_patch = [](function_replacement_data_t repl, const char *name) {
|
||||||
|
PatchedFunctionHandle handle = 0;
|
||||||
|
if (FunctionPatcher_AddFunctionPatch(&repl, &handle, nullptr) != FUNCTION_PATCHER_RESULT_SUCCESS) {
|
||||||
|
DEBUG_FUNCTION_LINE("Inkay/OLV: Failed to patch %s!", name);
|
||||||
|
}
|
||||||
|
olv_patches.push_back(handle);
|
||||||
|
};
|
||||||
|
|
||||||
|
add_patch(REPLACE_FUNCTION_FOR_PROCESS(FSOpenFile, LIBRARY_COREINIT, FSOpenFile, FP_TARGET_PROCESS_MIIVERSE), "FSOpenFile");
|
||||||
|
add_patch(REPLACE_FUNCTION_FOR_PROCESS(FSReadFile, LIBRARY_COREINIT, FSReadFile, FP_TARGET_PROCESS_MIIVERSE), "FSReadFile");
|
||||||
|
add_patch(REPLACE_FUNCTION_FOR_PROCESS(FSCloseFile, LIBRARY_COREINIT, FSCloseFile, FP_TARGET_PROCESS_MIIVERSE), "FSCloseFile");
|
||||||
|
}
|
||||||
|
|
||||||
|
void unpatchOlvApplet() {
|
||||||
|
for (auto handle: olv_patches) {
|
||||||
|
FunctionPatcher_RemoveFunctionPatch(handle);
|
||||||
|
}
|
||||||
|
olv_patches.clear();
|
||||||
|
}
|
||||||
20
src/patches/olv_applet.h
Normal file
20
src/patches/olv_applet.h
Normal file
|
|
@ -0,0 +1,20 @@
|
||||||
|
/* Copyright 2024 Pretendo Network contributors <pretendo.network>
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
void patchOlvApplet();
|
||||||
|
void unpatchOlvApplet();
|
||||||
87
src/patches/olv_urls.cpp
Normal file
87
src/patches/olv_urls.cpp
Normal file
|
|
@ -0,0 +1,87 @@
|
||||||
|
/* Copyright 2023 Pretendo Network contributors <pretendo.network>
|
||||||
|
Copyright 2023 Ash Logan <ash@heyquark.com>
|
||||||
|
Copyright 2019 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 "config.h"
|
||||||
|
#include "olv_urls.h"
|
||||||
|
#include "utils/logger.h"
|
||||||
|
#include "utils/replace_mem.h"
|
||||||
|
|
||||||
|
#include <cstring>
|
||||||
|
#include <coreinit/dynload.h>
|
||||||
|
#include <coreinit/memory.h>
|
||||||
|
|
||||||
|
bool check_olv_libs() {
|
||||||
|
OSDynLoad_Module olv_handle = 0;
|
||||||
|
OSDynLoad_Error dret;
|
||||||
|
|
||||||
|
dret = OSDynLoad_IsModuleLoaded("nn_olv", &olv_handle);
|
||||||
|
if (dret == OS_DYNLOAD_OK && olv_handle != 0) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
dret = OSDynLoad_IsModuleLoaded("nn_olv2", &olv_handle);
|
||||||
|
if (dret == OS_DYNLOAD_OK && olv_handle != 0) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
#define OLV_RPL "nn_olv.rpl"
|
||||||
|
bool path_is_olv(const char* path) {
|
||||||
|
auto path_len = strlen(path);
|
||||||
|
auto* path_suffix = path + path_len - (sizeof(OLV_RPL) - 1); //1 for null
|
||||||
|
return strcmp(path_suffix, OLV_RPL) == 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void new_rpl_loaded(OSDynLoad_Module module, void* ctx, OSDynLoad_NotifyReason reason, OSDynLoad_NotifyData* rpl) {
|
||||||
|
if (!Config::connect_to_network) {
|
||||||
|
DEBUG_FUNCTION_LINE_VERBOSE("Inkay: Miiverse patches skipped.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Loaded olv?
|
||||||
|
if (reason != OS_DYNLOAD_NOTIFY_LOADED) return;
|
||||||
|
if (!rpl->name || !path_is_olv(rpl->name)) return;
|
||||||
|
|
||||||
|
replace(rpl->dataAddr, rpl->dataSize, original_url, sizeof(original_url), new_url, sizeof(new_url));
|
||||||
|
}
|
||||||
|
|
||||||
|
bool setup_olv_libs() {
|
||||||
|
if (!Config::connect_to_network) {
|
||||||
|
DEBUG_FUNCTION_LINE_VERBOSE("Inkay: Miiverse patches skipped.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
OSDynLoad_AddNotifyCallback(&new_rpl_loaded, nullptr);
|
||||||
|
|
||||||
|
auto olvLoaded = check_olv_libs();
|
||||||
|
if (!olvLoaded) {
|
||||||
|
DEBUG_FUNCTION_LINE_VERBOSE("Inkay: no olv, quitting for now\n");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
//wish there was a better way than "blow through MEM2"
|
||||||
|
uint32_t base_addr, size;
|
||||||
|
if (OSGetMemBound(OS_MEM2, &base_addr, &size)) {
|
||||||
|
DEBUG_FUNCTION_LINE("Inkay: OSGetMemBound failed!");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return replace(base_addr, size, original_url, sizeof(original_url), new_url, sizeof(new_url));
|
||||||
|
}
|
||||||
26
src/patches/olv_urls.h
Normal file
26
src/patches/olv_urls.h
Normal file
|
|
@ -0,0 +1,26 @@
|
||||||
|
/* Copyright 2023 Pretendo Network contributors <pretendo.network>
|
||||||
|
Copyright 2023 Ash Logan <ash@heyquark.com>
|
||||||
|
Copyright 2019 Maschell
|
||||||
|
|
||||||
|
Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby
|
||||||
|
granted, provided that the above copyright notice and this permission notice appear in all copies.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
|
||||||
|
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
||||||
|
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
|
||||||
|
IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||||
|
PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <cstdlib>
|
||||||
|
#include "inkay_config.h"
|
||||||
|
|
||||||
|
constexpr char original_url[] = "discovery.olv.nintendo.net/v1/endpoint";
|
||||||
|
constexpr char new_url[] = "discovery.olv.spbr.net/v1/endpoint";
|
||||||
|
|
||||||
|
_Static_assert(sizeof(original_url) >= sizeof(new_url),
|
||||||
|
"new_url too long! Must be less than 38chars.");
|
||||||
|
|
||||||
|
bool setup_olv_libs();
|
||||||
|
|
@ -1,43 +0,0 @@
|
||||||
#ifndef _PATCHER_H
|
|
||||||
#define _PATCHER_H
|
|
||||||
|
|
||||||
typedef struct URL_Patch
|
|
||||||
{
|
|
||||||
unsigned int address;
|
|
||||||
char url[80];
|
|
||||||
} URL_Patch;
|
|
||||||
|
|
||||||
static const URL_Patch url_patches[] = {
|
|
||||||
//nim-boss .rodata
|
|
||||||
{0xE2282550, "http://pushmore.wup.shop.pretendo.cc/pushmore/r/%s"},
|
|
||||||
{0xE229A0A0, "http://npns-dev.c.app.pretendo.cc/bst.dat"},
|
|
||||||
{0xE229A0D0, "http://npns-dev.c.app.pretendo.cc/bst2.dat"},
|
|
||||||
{0xE2281964, "https://tagaya.wup.shop.pretendo.cc/tagaya/versionlist/%s/%s/%s"},
|
|
||||||
{0xE22819B4, "https://tagaya.wup.shop.pretendo.cc/tagaya/versionlist/%s/%s/latest_version"},
|
|
||||||
{0xE2282584, "http://pushmo.wup.shop.pretendo.cc/pushmo/d/%s/%u"},
|
|
||||||
{0xE22825B8, "http://pushmo.wup.shop.pretendo.cc/pushmo/c/%u/%u"},
|
|
||||||
{0xE2282DB4, "https://ecs.wup.shop.pretendo.cc/ecs/services/ECommerceSOAP"},
|
|
||||||
{0xE22830A0, "https://ecs.wup.shop.pretendo.cc/ecs/services/ECommerceSOAP"},
|
|
||||||
{0xE22830E0, "https://nus.wup.shop.pretendo.cc/nus/services/NetUpdateSOAP"},
|
|
||||||
{0xE2299990, "nppl.app.pretendo.cc"},
|
|
||||||
{0xE229A600, "https://pls.wup.shop.pretendo.cc/pls/upload"},
|
|
||||||
{0xE229A6AC, "https://npvk-dev.app.pretendo.cc/reports"},
|
|
||||||
{0xE229A6D8, "https://npvk.app.pretendo.cc/reports"},
|
|
||||||
{0xE229B1F4, "https://npts.app.pretendo.cc/p01/tasksheet/%s/%s/%s/%s?c=%s&l=%s"},
|
|
||||||
{0xE229B238, "https://npts.app.pretendo.cc/p01/tasksheet/%s/%s/%s?c=%s&l=%s"},
|
|
||||||
{0xE22AB2D8, "https://idbe-wup.cdn.pretendo.cc/icondata/%02X/%016llX.idbe"},
|
|
||||||
{0xE22AB318, "https://idbe-ctr.cdn.pretendo.cc/icondata/%02X/%016llX.idbe"},
|
|
||||||
{0xE22AB358, "https://idbe-wup.cdn.pretendo.cc/icondata/%02X/%016llX-%d.idbe"},
|
|
||||||
{0xE22AB398, "https://idbe-ctr.cdn.pretendo.cc/icondata/%02X/%016llX-%d.idbe"},
|
|
||||||
{0xE22B3EF8, "https://ecs.c.shop.pretendo.cc"},
|
|
||||||
{0xE22B3F30, "https://ecs.c.shop.pretendo.cc/ecs/services/ECommerceSOAP"},
|
|
||||||
{0xE22B3F70, "https://ias.c.shop.pretendo.cc/ias/services/IdentityAuthenticationSOAP"},
|
|
||||||
{0xE22B3FBC, "https://cas.c.shop.pretendo.cc/cas/services/CatalogingSOAP"},
|
|
||||||
{0xE22B3FFC, "https://nus.c.shop.pretendo.cc/nus/services/NetUpdateSOAP"},
|
|
||||||
{0xE229DE0C, "n.app.pretendo.cc"},
|
|
||||||
//nim-boss .bss
|
|
||||||
{0xE31930D4, "https://%s%saccount.pretendo.cc/v%u/api/"}
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
@ -1,29 +1,36 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
|
#include <whb/log.h>
|
||||||
|
#include <whb/log_module.h>
|
||||||
|
#include <whb/log_cafe.h>
|
||||||
|
#include <whb/log_udp.h>
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <string.h>
|
|
||||||
#include <whb/log.h>
|
|
||||||
#include <whb/log_udp.h>
|
|
||||||
#include <whb/log_cafe.h>
|
|
||||||
|
|
||||||
#define __FILENAME_X__ (strrchr(__FILE__, '\\') ? strrchr(__FILE__, '\\') + 1 : __FILE__)
|
#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 OSFATAL_FUNCTION_LINE(FMT, ARGS...)do { \
|
#define OSFATAL_FUNCTION_LINE(FMT, ARGS...)do { \
|
||||||
OSFatal_printf("[%s]%s@L%04d: " FMT "",__FILENAME__,__FUNCTION__, __LINE__, ## ARGS); \
|
OSFatal_printf("[(M) Inkay][%23s]%30s@L%04d: " FMT "",__FILENAME__,__FUNCTION__, __LINE__, ## ARGS); \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
#define DEBUG_FUNCTION_LINE(FMT, ARGS...)do { \
|
#define DEBUG_FUNCTION_LINE(FMT, ARGS...)do { \
|
||||||
WHBLogPrintf("[%23s]%30s@L%04d: " FMT "",__FILENAME__,__FUNCTION__, __LINE__, ## ARGS); \
|
WHBLogPrintf("[(M) Inkay][%23s]%30s@L%04d: " FMT "",__FILENAME__,__FUNCTION__, __LINE__, ## ARGS); \
|
||||||
} while (0);
|
} while (0);
|
||||||
|
|
||||||
#define DEBUG_FUNCTION_LINE_WRITE(FMT, ARGS...)do { \
|
#define DEBUG_FUNCTION_LINE_WRITE(FMT, ARGS...)do { \
|
||||||
WHBLogWritef("[%23s]%30s@L%04d: " FMT "",__FILENAME__,__FUNCTION__, __LINE__, ## ARGS); \
|
WHBLogWritef("[(M) Inkay][%23s]%30s@L%04d: " FMT "",__FILENAME__,__FUNCTION__, __LINE__, ## ARGS); \
|
||||||
} while (0);
|
} while (0);
|
||||||
|
|
||||||
|
#ifdef DEBUG
|
||||||
|
#define DEBUG_FUNCTION_LINE_VERBOSE(FMT, ARGS...) DEBUG_FUNCTION_LINE(FMT, ##ARGS)
|
||||||
|
#else
|
||||||
|
#define DEBUG_FUNCTION_LINE_VERBOSE(FMT, ARGS...) while (0);
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
101
src/utils/replace_mem.cpp
Normal file
101
src/utils/replace_mem.cpp
Normal file
|
|
@ -0,0 +1,101 @@
|
||||||
|
/* Copyright 2023 Pretendo Network contributors <pretendo.network>
|
||||||
|
Copyright 2023 Ash Logan <ash@heyquark.com>
|
||||||
|
Copyright 2019 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 "replace_mem.h"
|
||||||
|
#include "utils/logger.h"
|
||||||
|
|
||||||
|
#include <kernel/kernel.h>
|
||||||
|
#include <coreinit/memorymap.h>
|
||||||
|
#include <algorithm>
|
||||||
|
#include <coreinit/cache.h>
|
||||||
|
|
||||||
|
bool replace(uint32_t start, uint32_t size, const char *original_val, size_t original_val_sz, const char *new_val,
|
||||||
|
size_t new_val_sz) {
|
||||||
|
for (uint32_t addr = start; addr < start + size - original_val_sz; addr++) {
|
||||||
|
int ret = memcmp(original_val, (void *) addr, original_val_sz);
|
||||||
|
if (ret == 0) {
|
||||||
|
DEBUG_FUNCTION_LINE_VERBOSE("found str @%08x: %s", addr, (const char *) addr);
|
||||||
|
KernelCopyData(OSEffectiveToPhysical(addr), OSEffectiveToPhysical((uint32_t) new_val), new_val_sz);
|
||||||
|
DEBUG_FUNCTION_LINE_VERBOSE("new str @%08x: %s", addr, (const char *) addr);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void replaceBulk(uint32_t start, uint32_t size, std::span<const replacement> replacements) {
|
||||||
|
// work out the biggest input replacement
|
||||||
|
auto max_sz = std::max_element(replacements.begin(), replacements.end(), [](auto &a, auto &b) {
|
||||||
|
return a.orig.size_bytes() < b.orig.size_bytes();
|
||||||
|
})->orig.size_bytes();
|
||||||
|
|
||||||
|
int counts[replacements.size()];
|
||||||
|
for (auto &c: counts) {
|
||||||
|
c = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (uint32_t addr = start; addr < start + size - max_sz; addr++) {
|
||||||
|
for (int i = 0; i < (int) replacements.size(); i++) {
|
||||||
|
const auto &replacement = replacements[i];
|
||||||
|
|
||||||
|
int ret = memcmp((void *) addr, replacement.orig.data(), replacement.orig.size_bytes());
|
||||||
|
if (ret == 0) {
|
||||||
|
KernelCopyData(
|
||||||
|
OSEffectiveToPhysical(addr),
|
||||||
|
OSEffectiveToPhysical((uint32_t) replacement.repl.data()),
|
||||||
|
replacement.repl.size_bytes()
|
||||||
|
);
|
||||||
|
counts[i]++;
|
||||||
|
break; // don't check the other replacements
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#ifdef DEBUG
|
||||||
|
for (auto c: counts) {
|
||||||
|
DEBUG_FUNCTION_LINE("replaced %d times", c);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename U>
|
||||||
|
requires std::integral<U>
|
||||||
|
bool replace_unsigned(U *addr, U original_value, U new_value) {
|
||||||
|
if (*addr != original_value) return false;
|
||||||
|
|
||||||
|
KernelCopyData(
|
||||||
|
OSEffectiveToPhysical((uint32_t) addr),
|
||||||
|
OSEffectiveToPhysical((uint32_t) &new_value),
|
||||||
|
sizeof(new_value)
|
||||||
|
);
|
||||||
|
DCFlushRange(addr, sizeof(new_value));
|
||||||
|
|
||||||
|
return *addr == new_value;
|
||||||
|
}
|
||||||
|
template bool replace_unsigned<uint64_t>(uint64_t *, uint64_t, uint64_t);
|
||||||
|
template bool replace_unsigned<uint32_t>(uint32_t *, uint32_t, uint32_t);
|
||||||
|
template bool replace_unsigned<uint16_t>(uint16_t *, uint16_t, uint16_t);
|
||||||
|
template bool replace_unsigned<uint8_t>(uint8_t *, uint8_t, uint8_t);
|
||||||
|
|
||||||
|
bool replace_instruction(uint32_t *inst, uint32_t original_value, uint32_t new_value) {
|
||||||
|
bool res = replace_unsigned<uint32_t>(inst, original_value, new_value);
|
||||||
|
if (!res) return res;
|
||||||
|
|
||||||
|
ICInvalidateRange(inst, sizeof(new_value));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
35
src/utils/replace_mem.h
Normal file
35
src/utils/replace_mem.h
Normal file
|
|
@ -0,0 +1,35 @@
|
||||||
|
/* Copyright 2023 Pretendo Network contributors <pretendo.network>
|
||||||
|
Copyright 2023 Ash Logan <ash@heyquark.com>
|
||||||
|
Copyright 2019 Maschell
|
||||||
|
|
||||||
|
Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby
|
||||||
|
granted, provided that the above copyright notice and this permission notice appear in all copies.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
|
||||||
|
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
||||||
|
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
|
||||||
|
IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||||
|
PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
#include <cstddef>
|
||||||
|
#include <span>
|
||||||
|
|
||||||
|
bool replace(uint32_t start, uint32_t size, const char *original_val, size_t original_val_sz, const char *new_val,
|
||||||
|
size_t new_val_sz);
|
||||||
|
|
||||||
|
struct replacement {
|
||||||
|
std::span<const uint8_t> orig;
|
||||||
|
std::span<const uint8_t> repl;
|
||||||
|
};
|
||||||
|
|
||||||
|
void replaceBulk(uint32_t start, uint32_t size, std::span<const replacement> replacements);
|
||||||
|
|
||||||
|
template <typename U>
|
||||||
|
requires std::integral<U>
|
||||||
|
bool replace_unsigned(U *addr, U original_value, U new_value);
|
||||||
|
|
||||||
|
bool replace_instruction(uint32_t *inst, uint32_t original_value, uint32_t new_value);
|
||||||
64
src/utils/rpl_info.cpp
Normal file
64
src/utils/rpl_info.cpp
Normal file
|
|
@ -0,0 +1,64 @@
|
||||||
|
/* Copyright 2024 Pretendo Network contributors <pretendo.network>
|
||||||
|
Copyright 2024 Ash Logan <ash@heyquark.com>
|
||||||
|
|
||||||
|
Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby
|
||||||
|
granted, provided that the above copyright notice and this permission notice appear in all copies.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
|
||||||
|
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
||||||
|
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
|
||||||
|
IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||||
|
PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "rpl_info.h"
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
#include <algorithm>
|
||||||
|
#include <string_view>
|
||||||
|
#include <coreinit/mcp.h>
|
||||||
|
#include <coreinit/title.h>
|
||||||
|
|
||||||
|
#include "logger.h"
|
||||||
|
|
||||||
|
// if we get more than like.. two callsites for this, it should really be refactored out rather than doing a fresh
|
||||||
|
// search every time
|
||||||
|
std::optional<OSDynLoad_NotifyData> search_for_rpl(std::string_view name) {
|
||||||
|
int num_rpls = OSDynLoad_GetNumberOfRPLs();
|
||||||
|
if (!num_rpls)
|
||||||
|
return std::nullopt;
|
||||||
|
|
||||||
|
// allocates but we free it at return
|
||||||
|
std::vector<OSDynLoad_NotifyData> rpls(num_rpls);
|
||||||
|
if (!OSDynLoad_GetRPLInfo(0, num_rpls, rpls.data()))
|
||||||
|
return std::nullopt;
|
||||||
|
|
||||||
|
auto rpl = std::find_if(rpls.begin(), rpls.end(), [=](const OSDynLoad_NotifyData &rpl) {
|
||||||
|
return std::string_view(rpl.name).ends_with(name);
|
||||||
|
});
|
||||||
|
if (rpl == rpls.end())
|
||||||
|
return std::nullopt;
|
||||||
|
|
||||||
|
return *rpl;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::optional<uint16_t> get_current_title_version() {
|
||||||
|
const auto mcpHandle = MCP_Open();
|
||||||
|
MCPTitleListType titleInfo;
|
||||||
|
int32_t res = -1;
|
||||||
|
const uint64_t curTitleId = OSGetTitleID();
|
||||||
|
if ((curTitleId & 0x0000000F00000000) == 0) {
|
||||||
|
res = MCP_GetTitleInfo(mcpHandle, curTitleId | 0x0000000E00000000, &titleInfo);
|
||||||
|
}
|
||||||
|
if (res != 0) {
|
||||||
|
res = MCP_GetTitleInfo(mcpHandle, curTitleId, &titleInfo);
|
||||||
|
}
|
||||||
|
MCP_Close(mcpHandle);
|
||||||
|
if (res != 0) {
|
||||||
|
DEBUG_FUNCTION_LINE("Failed to get title version of %016llX.", curTitleId);
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
MCP_Close(mcpHandle);
|
||||||
|
const auto tmp_result = titleInfo.titleVersion; // make the compiler happy because we access a packed struct
|
||||||
|
return tmp_result;
|
||||||
|
}
|
||||||
30
src/utils/rpl_info.h
Normal file
30
src/utils/rpl_info.h
Normal file
|
|
@ -0,0 +1,30 @@
|
||||||
|
/* Copyright 2024 Pretendo Network contributors <pretendo.network>
|
||||||
|
Copyright 2024 Ash Logan <ash@heyquark.com>
|
||||||
|
|
||||||
|
Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby
|
||||||
|
granted, provided that the above copyright notice and this permission notice appear in all copies.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
|
||||||
|
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
||||||
|
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
|
||||||
|
IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||||
|
PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <optional>
|
||||||
|
#include <string_view>
|
||||||
|
#include <coreinit/dynload.h>
|
||||||
|
|
||||||
|
std::optional<OSDynLoad_NotifyData> search_for_rpl(std::string_view name);
|
||||||
|
|
||||||
|
constexpr void *rpl_addr(OSDynLoad_NotifyData rpl, uint32_t cemu_addr) {
|
||||||
|
if (cemu_addr < 0x1000'0000) {
|
||||||
|
return (void *)(rpl.textAddr + cemu_addr - 0x0200'0000);
|
||||||
|
} else {
|
||||||
|
return (void *)(rpl.dataAddr + cemu_addr - 0x1000'0000);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
std::optional<uint16_t> get_current_title_version();
|
||||||
|
|
@ -1,21 +0,0 @@
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include <assert.h>
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
//remove all this if wut adds it and it causes errors
|
|
||||||
typedef struct {
|
|
||||||
uint32_t major;
|
|
||||||
uint32_t minor;
|
|
||||||
uint32_t patch;
|
|
||||||
char region;
|
|
||||||
} MCP_SystemVersion;
|
|
||||||
static_assert(sizeof(MCP_SystemVersion) == 0x10);
|
|
||||||
int MCP_GetSystemVersion(int handle, MCP_SystemVersion* version);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
Loading…
Reference in a new issue