├── .clang-format ├── .gitattributes ├── .github └── workflows │ └── main.yml ├── .gitignore ├── Dockerfile ├── LICENSE ├── Makefile ├── README.md ├── data ├── title_00000000.bin ├── title_00000001.bin ├── title_cetk.bin └── title_tmd.bin ├── meta ├── hbl │ ├── icon.png │ └── meta.xml └── wuhb │ ├── drc-splash.png │ ├── icon.png │ └── tv-splash.png └── src ├── InputUtils.cpp ├── InputUtils.h ├── StateUtils.cpp ├── StateUtils.h ├── installer.cpp ├── installer.h └── main.cpp /.clang-format: -------------------------------------------------------------------------------- 1 | BasedOnStyle: LLVM 2 | AccessModifierOffset: -4 3 | AlignAfterOpenBracket: Align 4 | AlignConsecutiveMacros: AcrossEmptyLinesAndComments 5 | AlignOperands: Align 6 | AllowAllArgumentsOnNextLine: false 7 | AllowAllConstructorInitializersOnNextLine: false 8 | AllowAllParametersOfDeclarationOnNextLine: false 9 | AllowShortBlocksOnASingleLine: Always 10 | AllowShortCaseLabelsOnASingleLine: false 11 | AllowShortFunctionsOnASingleLine: All 12 | AllowShortIfStatementsOnASingleLine: Always 13 | AllowShortLambdasOnASingleLine: All 14 | AllowShortLoopsOnASingleLine: true 15 | AlwaysBreakAfterReturnType: None 16 | AlwaysBreakTemplateDeclarations: Yes 17 | BreakBeforeBraces: Custom 18 | BraceWrapping: 19 | AfterCaseLabel: false 20 | AfterClass: false 21 | AfterControlStatement: Never 22 | AfterEnum: false 23 | AfterFunction: false 24 | AfterNamespace: false 25 | AfterUnion: false 26 | BeforeCatch: false 27 | BeforeElse: false 28 | IndentBraces: false 29 | SplitEmptyFunction: false 30 | SplitEmptyRecord: true 31 | BreakBeforeBinaryOperators: None 32 | BreakBeforeTernaryOperators: true 33 | BreakConstructorInitializers: BeforeColon 34 | BreakInheritanceList: BeforeColon 35 | ColumnLimit: 0 36 | CompactNamespaces: false 37 | ContinuationIndentWidth: 8 38 | IndentCaseLabels: true 39 | IndentPPDirectives: None 40 | IndentWidth: 4 41 | KeepEmptyLinesAtTheStartOfBlocks: true 42 | MaxEmptyLinesToKeep: 2 43 | NamespaceIndentation: All 44 | ObjCSpaceAfterProperty: false 45 | ObjCSpaceBeforeProtocolList: true 46 | PointerAlignment: Right 47 | ReflowComments: false 48 | SpaceAfterCStyleCast: true 49 | SpaceAfterLogicalNot: false 50 | SpaceAfterTemplateKeyword: false 51 | SpaceBeforeAssignmentOperators: true 52 | SpaceBeforeCpp11BracedList: false 53 | SpaceBeforeCtorInitializerColon: true 54 | SpaceBeforeInheritanceColon: true 55 | SpaceBeforeParens: ControlStatements 56 | SpaceBeforeRangeBasedForLoopColon: true 57 | SpaceInEmptyParentheses: false 58 | SpacesBeforeTrailingComments: 1 59 | SpacesInAngles: false 60 | SpacesInCStyleCastParentheses: false 61 | SpacesInContainerLiterals: false 62 | SpacesInParentheses: false 63 | SpacesInSquareBrackets: false 64 | TabWidth: 4 65 | UseTab: Never -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /.github/workflows/main.yml: -------------------------------------------------------------------------------- 1 | name: CI-Release 2 | 3 | on: [ push, pull_request ] 4 | 5 | jobs: 6 | build-binary: 7 | runs-on: ubuntu-22.04 8 | steps: 9 | - name: Checkout 10 | uses: actions/checkout@v3 11 | with: 12 | fetch-depth: 0 13 | - name: Docker Layer Caching 14 | uses: jpribyl/action-docker-layer-caching@v0.1.1 15 | continue-on-error: true 16 | with: 17 | key: compat-installer-docker-cache-{hash} 18 | restore-keys: | 19 | compat-installer-docker-cache- 20 | - name: Build artifacts 21 | run: | 22 | docker build . --file Dockerfile --tag builder 23 | docker run --rm -v ${PWD}:/project builder make -j$(nproc) release 24 | - name: Upload HBL version 25 | uses: actions/upload-artifact@v3 26 | with: 27 | name: compat_installer-HBL.zip 28 | path: compat_installer-HBL.zip 29 | if-no-files-found: warn 30 | - name: Upload Aroma version 31 | uses: actions/upload-artifact@v3 32 | with: 33 | name: compat_installer-Aroma.zip 34 | path: compat_installer-Aroma.zip 35 | if-no-files-found: warn 36 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | build 2 | *.elf 3 | *.lst 4 | *.rpx 5 | *.wuhb 6 | *.zip 7 | .DS_Store -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ghcr.io/wiiu-env/devkitppc:20230402 2 | 3 | COPY --from=ghcr.io/wiiu-env/libmocha:20230417 /artifacts $DEVKITPRO 4 | 5 | RUN git config --global --add safe.directory /project 6 | 7 | WORKDIR /project 8 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 2, June 1991 3 | 4 | Copyright (C) 1989, 1991 Free Software Foundation, Inc., 5 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 6 | Everyone is permitted to copy and distribute verbatim copies 7 | of this license document, but changing it is not allowed. 8 | 9 | Preamble 10 | 11 | The licenses for most software are designed to take away your 12 | freedom to share and change it. By contrast, the GNU General Public 13 | License is intended to guarantee your freedom to share and change free 14 | software--to make sure the software is free for all its users. This 15 | General Public License applies to most of the Free Software 16 | Foundation's software and to any other program whose authors commit to 17 | using it. (Some other Free Software Foundation software is covered by 18 | the GNU Lesser General Public License instead.) You can apply it to 19 | your programs, too. 20 | 21 | When we speak of free software, we are referring to freedom, not 22 | price. Our General Public Licenses are designed to make sure that you 23 | have the freedom to distribute copies of free software (and charge for 24 | this service if you wish), that you receive source code or can get it 25 | if you want it, that you can change the software or use pieces of it 26 | in new free programs; and that you know you can do these things. 27 | 28 | To protect your rights, we need to make restrictions that forbid 29 | anyone to deny you these rights or to ask you to surrender the rights. 30 | These restrictions translate to certain responsibilities for you if you 31 | distribute copies of the software, or if you modify it. 32 | 33 | For example, if you distribute copies of such a program, whether 34 | gratis or for a fee, you must give the recipients all the rights that 35 | you have. You must make sure that they, too, receive or can get the 36 | source code. And you must show them these terms so they know their 37 | rights. 38 | 39 | We protect your rights with two steps: (1) copyright the software, and 40 | (2) offer you this license which gives you legal permission to copy, 41 | distribute and/or modify the software. 42 | 43 | Also, for each author's protection and ours, we want to make certain 44 | that everyone understands that there is no warranty for this free 45 | software. If the software is modified by someone else and passed on, we 46 | want its recipients to know that what they have is not the original, so 47 | that any problems introduced by others will not reflect on the original 48 | authors' reputations. 49 | 50 | Finally, any free program is threatened constantly by software 51 | patents. We wish to avoid the danger that redistributors of a free 52 | program will individually obtain patent licenses, in effect making the 53 | program proprietary. To prevent this, we have made it clear that any 54 | patent must be licensed for everyone's free use or not licensed at all. 55 | 56 | The precise terms and conditions for copying, distribution and 57 | modification follow. 58 | 59 | GNU GENERAL PUBLIC LICENSE 60 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 61 | 62 | 0. This License applies to any program or other work which contains 63 | a notice placed by the copyright holder saying it may be distributed 64 | under the terms of this General Public License. The "Program", below, 65 | refers to any such program or work, and a "work based on the Program" 66 | means either the Program or any derivative work under copyright law: 67 | that is to say, a work containing the Program or a portion of it, 68 | either verbatim or with modifications and/or translated into another 69 | language. (Hereinafter, translation is included without limitation in 70 | the term "modification".) Each licensee is addressed as "you". 71 | 72 | Activities other than copying, distribution and modification are not 73 | covered by this License; they are outside its scope. The act of 74 | running the Program is not restricted, and the output from the Program 75 | is covered only if its contents constitute a work based on the 76 | Program (independent of having been made by running the Program). 77 | Whether that is true depends on what the Program does. 78 | 79 | 1. You may copy and distribute verbatim copies of the Program's 80 | source code as you receive it, in any medium, provided that you 81 | conspicuously and appropriately publish on each copy an appropriate 82 | copyright notice and disclaimer of warranty; keep intact all the 83 | notices that refer to this License and to the absence of any warranty; 84 | and give any other recipients of the Program a copy of this License 85 | along with the Program. 86 | 87 | You may charge a fee for the physical act of transferring a copy, and 88 | you may at your option offer warranty protection in exchange for a fee. 89 | 90 | 2. You may modify your copy or copies of the Program or any portion 91 | of it, thus forming a work based on the Program, and copy and 92 | distribute such modifications or work under the terms of Section 1 93 | above, provided that you also meet all of these conditions: 94 | 95 | a) You must cause the modified files to carry prominent notices 96 | stating that you changed the files and the date of any change. 97 | 98 | b) You must cause any work that you distribute or publish, that in 99 | whole or in part contains or is derived from the Program or any 100 | part thereof, to be licensed as a whole at no charge to all third 101 | parties under the terms of this License. 102 | 103 | c) If the modified program normally reads commands interactively 104 | when run, you must cause it, when started running for such 105 | interactive use in the most ordinary way, to print or display an 106 | announcement including an appropriate copyright notice and a 107 | notice that there is no warranty (or else, saying that you provide 108 | a warranty) and that users may redistribute the program under 109 | these conditions, and telling the user how to view a copy of this 110 | License. (Exception: if the Program itself is interactive but 111 | does not normally print such an announcement, your work based on 112 | the Program is not required to print an announcement.) 113 | 114 | These requirements apply to the modified work as a whole. If 115 | identifiable sections of that work are not derived from the Program, 116 | and can be reasonably considered independent and separate works in 117 | themselves, then this License, and its terms, do not apply to those 118 | sections when you distribute them as separate works. But when you 119 | distribute the same sections as part of a whole which is a work based 120 | on the Program, the distribution of the whole must be on the terms of 121 | this License, whose permissions for other licensees extend to the 122 | entire whole, and thus to each and every part regardless of who wrote it. 123 | 124 | Thus, it is not the intent of this section to claim rights or contest 125 | your rights to work written entirely by you; rather, the intent is to 126 | exercise the right to control the distribution of derivative or 127 | collective works based on the Program. 128 | 129 | In addition, mere aggregation of another work not based on the Program 130 | with the Program (or with a work based on the Program) on a volume of 131 | a storage or distribution medium does not bring the other work under 132 | the scope of this License. 133 | 134 | 3. You may copy and distribute the Program (or a work based on it, 135 | under Section 2) in object code or executable form under the terms of 136 | Sections 1 and 2 above provided that you also do one of the following: 137 | 138 | a) Accompany it with the complete corresponding machine-readable 139 | source code, which must be distributed under the terms of Sections 140 | 1 and 2 above on a medium customarily used for software interchange; or, 141 | 142 | b) Accompany it with a written offer, valid for at least three 143 | years, to give any third party, for a charge no more than your 144 | cost of physically performing source distribution, a complete 145 | machine-readable copy of the corresponding source code, to be 146 | distributed under the terms of Sections 1 and 2 above on a medium 147 | customarily used for software interchange; or, 148 | 149 | c) Accompany it with the information you received as to the offer 150 | to distribute corresponding source code. (This alternative is 151 | allowed only for noncommercial distribution and only if you 152 | received the program in object code or executable form with such 153 | an offer, in accord with Subsection b above.) 154 | 155 | The source code for a work means the preferred form of the work for 156 | making modifications to it. For an executable work, complete source 157 | code means all the source code for all modules it contains, plus any 158 | associated interface definition files, plus the scripts used to 159 | control compilation and installation of the executable. However, as a 160 | special exception, the source code distributed need not include 161 | anything that is normally distributed (in either source or binary 162 | form) with the major components (compiler, kernel, and so on) of the 163 | operating system on which the executable runs, unless that component 164 | itself accompanies the executable. 165 | 166 | If distribution of executable or object code is made by offering 167 | access to copy from a designated place, then offering equivalent 168 | access to copy the source code from the same place counts as 169 | distribution of the source code, even though third parties are not 170 | compelled to copy the source along with the object code. 171 | 172 | 4. You may not copy, modify, sublicense, or distribute the Program 173 | except as expressly provided under this License. Any attempt 174 | otherwise to copy, modify, sublicense or distribute the Program is 175 | void, and will automatically terminate your rights under this License. 176 | However, parties who have received copies, or rights, from you under 177 | this License will not have their licenses terminated so long as such 178 | parties remain in full compliance. 179 | 180 | 5. You are not required to accept this License, since you have not 181 | signed it. However, nothing else grants you permission to modify or 182 | distribute the Program or its derivative works. These actions are 183 | prohibited by law if you do not accept this License. Therefore, by 184 | modifying or distributing the Program (or any work based on the 185 | Program), you indicate your acceptance of this License to do so, and 186 | all its terms and conditions for copying, distributing or modifying 187 | the Program or works based on it. 188 | 189 | 6. Each time you redistribute the Program (or any work based on the 190 | Program), the recipient automatically receives a license from the 191 | original licensor to copy, distribute or modify the Program subject to 192 | these terms and conditions. You may not impose any further 193 | restrictions on the recipients' exercise of the rights granted herein. 194 | You are not responsible for enforcing compliance by third parties to 195 | this License. 196 | 197 | 7. If, as a consequence of a court judgment or allegation of patent 198 | infringement or for any other reason (not limited to patent issues), 199 | conditions are imposed on you (whether by court order, agreement or 200 | otherwise) that contradict the conditions of this License, they do not 201 | excuse you from the conditions of this License. If you cannot 202 | distribute so as to satisfy simultaneously your obligations under this 203 | License and any other pertinent obligations, then as a consequence you 204 | may not distribute the Program at all. For example, if a patent 205 | license would not permit royalty-free redistribution of the Program by 206 | all those who receive copies directly or indirectly through you, then 207 | the only way you could satisfy both it and this License would be to 208 | refrain entirely from distribution of the Program. 209 | 210 | If any portion of this section is held invalid or unenforceable under 211 | any particular circumstance, the balance of the section is intended to 212 | apply and the section as a whole is intended to apply in other 213 | circumstances. 214 | 215 | It is not the purpose of this section to induce you to infringe any 216 | patents or other property right claims or to contest validity of any 217 | such claims; this section has the sole purpose of protecting the 218 | integrity of the free software distribution system, which is 219 | implemented by public license practices. Many people have made 220 | generous contributions to the wide range of software distributed 221 | through that system in reliance on consistent application of that 222 | system; it is up to the author/donor to decide if he or she is willing 223 | to distribute software through any other system and a licensee cannot 224 | impose that choice. 225 | 226 | This section is intended to make thoroughly clear what is believed to 227 | be a consequence of the rest of this License. 228 | 229 | 8. If the distribution and/or use of the Program is restricted in 230 | certain countries either by patents or by copyrighted interfaces, the 231 | original copyright holder who places the Program under this License 232 | may add an explicit geographical distribution limitation excluding 233 | those countries, so that distribution is permitted only in or among 234 | countries not thus excluded. In such case, this License incorporates 235 | the limitation as if written in the body of this License. 236 | 237 | 9. The Free Software Foundation may publish revised and/or new versions 238 | of the General Public License from time to time. Such new versions will 239 | be similar in spirit to the present version, but may differ in detail to 240 | address new problems or concerns. 241 | 242 | Each version is given a distinguishing version number. If the Program 243 | specifies a version number of this License which applies to it and "any 244 | later version", you have the option of following the terms and conditions 245 | either of that version or of any later version published by the Free 246 | Software Foundation. If the Program does not specify a version number of 247 | this License, you may choose any version ever published by the Free Software 248 | Foundation. 249 | 250 | 10. If you wish to incorporate parts of the Program into other free 251 | programs whose distribution conditions are different, write to the author 252 | to ask for permission. For software which is copyrighted by the Free 253 | Software Foundation, write to the Free Software Foundation; we sometimes 254 | make exceptions for this. Our decision will be guided by the two goals 255 | of preserving the free status of all derivatives of our free software and 256 | of promoting the sharing and reuse of software generally. 257 | 258 | NO WARRANTY 259 | 260 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY 261 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN 262 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES 263 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED 264 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 265 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS 266 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE 267 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, 268 | REPAIR OR CORRECTION. 269 | 270 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 271 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR 272 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, 273 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING 274 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED 275 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY 276 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER 277 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE 278 | POSSIBILITY OF SUCH DAMAGES. 279 | 280 | END OF TERMS AND CONDITIONS 281 | 282 | How to Apply These Terms to Your New Programs 283 | 284 | If you develop a new program, and you want it to be of the greatest 285 | possible use to the public, the best way to achieve this is to make it 286 | free software which everyone can redistribute and change under these terms. 287 | 288 | To do so, attach the following notices to the program. It is safest 289 | to attach them to the start of each source file to most effectively 290 | convey the exclusion of warranty; and each file should have at least 291 | the "copyright" line and a pointer to where the full notice is found. 292 | 293 | 294 | Copyright (C) 295 | 296 | This program is free software; you can redistribute it and/or modify 297 | it under the terms of the GNU General Public License as published by 298 | the Free Software Foundation; either version 2 of the License, or 299 | (at your option) any later version. 300 | 301 | This program is distributed in the hope that it will be useful, 302 | but WITHOUT ANY WARRANTY; without even the implied warranty of 303 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 304 | GNU General Public License for more details. 305 | 306 | You should have received a copy of the GNU General Public License along 307 | with this program; if not, write to the Free Software Foundation, Inc., 308 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 309 | 310 | Also add information on how to contact you by electronic and paper mail. 311 | 312 | If the program is interactive, make it output a short notice like this 313 | when it starts in an interactive mode: 314 | 315 | Gnomovision version 69, Copyright (C) year name of author 316 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 317 | This is free software, and you are welcome to redistribute it 318 | under certain conditions; type `show c' for details. 319 | 320 | The hypothetical commands `show w' and `show c' should show the appropriate 321 | parts of the General Public License. Of course, the commands you use may 322 | be called something other than `show w' and `show c'; they could even be 323 | mouse-clicks or menu items--whatever suits your program. 324 | 325 | You should also get your employer (if you work as a programmer) or your 326 | school, if any, to sign a "copyright disclaimer" for the program, if 327 | necessary. Here is a sample; alter the names: 328 | 329 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program 330 | `Gnomovision' (which makes passes at compilers) written by James Hacker. 331 | 332 | , 1 April 1989 333 | Ty Coon, President of Vice 334 | 335 | This General Public License does not permit incorporating your program into 336 | proprietary programs. If your program is a subroutine library, you may 337 | consider it more useful to permit linking proprietary applications with the 338 | library. If this is what you want to do, use the GNU Lesser General 339 | Public License instead of this License. 340 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | #------------------------------------------------------------------------------- 2 | .SUFFIXES: 3 | #------------------------------------------------------------------------------- 4 | 5 | ifeq ($(strip $(DEVKITPRO)),) 6 | $(error "Please set DEVKITPRO in your environment. export DEVKITPRO=/devkitpro") 7 | endif 8 | 9 | TOPDIR ?= $(CURDIR) 10 | 11 | #------------------------------------------------------------------------------- 12 | # APP_NAME sets the long name of the application 13 | # APP_SHORTNAME sets the short name of the application 14 | # APP_AUTHOR sets the author of the application 15 | #------------------------------------------------------------------------------- 16 | APP_NAME := vWii Compat Installer 17 | APP_SHORTNAME := vWii Compat Title Installer 18 | APP_AUTHOR := TheLordScruffy, DaThinkingChair 19 | 20 | include $(DEVKITPRO)/wut/share/wut_rules 21 | 22 | #------------------------------------------------------------------------------- 23 | # TARGET is the name of the output 24 | # BUILD is the directory where object files & intermediate files will be placed 25 | # SOURCES is a list of directories containing source code 26 | # DATA is a list of directories containing data files 27 | # INCLUDES is a list of directories containing header files 28 | # CONTENT is the path to the bundled folder that will be mounted as /vol/content/ 29 | # ICON is the game icon, leave blank to use default rule 30 | # TV_SPLASH is the image displayed during bootup on the TV, leave blank to use default rule 31 | # DRC_SPLASH is the image displayed during bootup on the DRC, leave blank to use default rule 32 | #------------------------------------------------------------------------------- 33 | TARGET := compat_installer 34 | BUILD := build 35 | SOURCES := src 36 | DATA := data 37 | INCLUDES := include 38 | CONTENT := 39 | ICON := meta/wuhb/icon.png 40 | TV_SPLASH := meta/wuhb/tv-splash.png 41 | DRC_SPLASH := meta/wuhb/drc-splash.png 42 | 43 | #------------------------------------------------------------------------------- 44 | # options for code generation 45 | #------------------------------------------------------------------------------- 46 | CFLAGS := $(MACHDEP) $(INCLUDE) -Ofast -flto=auto -fno-fat-lto-objects \ 47 | -fuse-linker-plugin -fipa-pta -pipe \ 48 | -Wall -Wextra -Wundef -Wshadow -Wpointer-arith \ 49 | -Wcast-align \ 50 | -D__WIIU__ -D__WUT__ \ 51 | -Wno-trigraphs 52 | 53 | CXXFLAGS := -std=gnu++20 $(CFLAGS) 54 | 55 | ASFLAGS := -g $(ARCH) 56 | LDFLAGS = -g $(ARCH) $(RPXSPECS) -Wl,-Map,$(notdir $*.map) -Wno-odr 57 | 58 | LIBS := -lwut -lmocha 59 | 60 | #------------------------------------------------------------------------------- 61 | # list of directories containing libraries, this must be the top level 62 | # containing include and lib 63 | #------------------------------------------------------------------------------- 64 | LIBDIRS := $(PORTLIBS) $(WUT_ROOT) $(WUT_ROOT)/usr 65 | 66 | #------------------------------------------------------------------------------- 67 | # no real need to edit anything past this point unless you need to add additional 68 | # rules for different file extensions 69 | #------------------------------------------------------------------------------- 70 | ifneq ($(BUILD),$(notdir $(CURDIR))) 71 | #------------------------------------------------------------------------------- 72 | 73 | export OUTPUT := $(CURDIR)/$(TARGET) 74 | export TOPDIR := $(CURDIR) 75 | 76 | export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \ 77 | $(foreach dir,$(DATA),$(CURDIR)/$(dir)) 78 | 79 | export DEPSDIR := $(CURDIR)/$(BUILD) 80 | 81 | CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c))) 82 | CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp))) 83 | SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s))) 84 | BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*))) 85 | 86 | #------------------------------------------------------------------------------- 87 | # use CXX for linking C++ projects, CC for standard C 88 | #------------------------------------------------------------------------------- 89 | ifeq ($(strip $(CPPFILES)),) 90 | #------------------------------------------------------------------------------- 91 | export LD := $(CC) 92 | #------------------------------------------------------------------------------- 93 | else 94 | #------------------------------------------------------------------------------- 95 | export LD := $(CXX) 96 | #------------------------------------------------------------------------------- 97 | endif 98 | #------------------------------------------------------------------------------- 99 | 100 | export OFILES := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) \ 101 | $(sFILES:.s=.o) $(SFILES:.S=.o) \ 102 | $(BINFILES:.bin=.o) 103 | export HFILES_BIN := $(addsuffix .h,$(subst .,_,$(BINFILES))) 104 | 105 | export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \ 106 | $(foreach dir,$(LIBDIRS),-I$(dir)/include) \ 107 | -I$(CURDIR)/$(BUILD) 108 | 109 | export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib) 110 | 111 | ifneq (,$(strip $(CONTENT))) 112 | export APP_CONTENT := $(TOPDIR)/$(CONTENT) 113 | endif 114 | 115 | ifneq (,$(strip $(ICON))) 116 | export APP_ICON := $(TOPDIR)/$(ICON) 117 | else ifneq (,$(wildcard $(TOPDIR)/$(TARGET).png)) 118 | export APP_ICON := $(TOPDIR)/$(TARGET).png 119 | else ifneq (,$(wildcard $(TOPDIR)/icon.png)) 120 | export APP_ICON := $(TOPDIR)/icon.png 121 | endif 122 | 123 | ifneq (,$(strip $(TV_SPLASH))) 124 | export APP_TV_SPLASH := $(TOPDIR)/$(TV_SPLASH) 125 | else ifneq (,$(wildcard $(TOPDIR)/tv-splash.png)) 126 | export APP_TV_SPLASH := $(TOPDIR)/tv-splash.png 127 | else ifneq (,$(wildcard $(TOPDIR)/splash.png)) 128 | export APP_TV_SPLASH := $(TOPDIR)/splash.png 129 | endif 130 | 131 | ifneq (,$(strip $(DRC_SPLASH))) 132 | export APP_DRC_SPLASH := $(TOPDIR)/$(DRC_SPLASH) 133 | else ifneq (,$(wildcard $(TOPDIR)/drc-splash.png)) 134 | export APP_DRC_SPLASH := $(TOPDIR)/drc-splash.png 135 | else ifneq (,$(wildcard $(TOPDIR)/splash.png)) 136 | export APP_DRC_SPLASH := $(TOPDIR)/splash.png 137 | endif 138 | 139 | .PHONY: $(BUILD) clean all 140 | 141 | #------------------------------------------------------------------------------- 142 | all: $(BUILD) 143 | 144 | $(BUILD): 145 | @$(shell [ ! -d $(BUILD) ] && mkdir -p $(BUILD)) 146 | @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile 147 | 148 | #------------------------------------------------------------------------------- 149 | clean: 150 | @echo clean ... 151 | @rm -fr $(BUILD) $(TARGET).wuhb $(TARGET).rpx $(TARGET).elf SaveMiiModWUTPort *.zip 152 | 153 | #------------------------------------------------------------------------------- 154 | release: $(BUILD) 155 | @mkdir -p compat_installer 156 | @cp compat_installer.rpx compat_installer 157 | @cp meta/hbl/icon.png compat_installer 158 | @cp meta/hbl/meta.xml compat_installer 159 | @zip -9 -r compat_installer-HBL.zip compat_installer 160 | @zip -9 compat_installer-Aroma.zip compat_installer.wuhb 161 | @rm -rf compat_installer 162 | #------------------------------------------------------------------------------- 163 | else 164 | .PHONY: all 165 | 166 | DEPENDS := $(OFILES:.o=.d) 167 | 168 | #------------------------------------------------------------------------------- 169 | # main targets 170 | #------------------------------------------------------------------------------- 171 | all : $(OUTPUT).wuhb 172 | 173 | $(OUTPUT).wuhb : $(OUTPUT).rpx 174 | $(OUTPUT).rpx : $(OUTPUT).elf 175 | $(OUTPUT).elf : $(OFILES) 176 | 177 | $(OFILES_SRC) : $(HFILES_BIN) 178 | 179 | #------------------------------------------------------------------------------- 180 | # you need a rule like this for each extension you use as binary data 181 | #------------------------------------------------------------------------------- 182 | %.bin.o %_bin.h : %.bin 183 | #------------------------------------------------------------------------------- 184 | @echo $(notdir $<) 185 | @$(bin2o) 186 | #------------------------------------------------------------------------------- 187 | %.o %.bin.o : %.bin 188 | #------------------------------------------------------------------------------- 189 | @echo $(notdir $<) 190 | @bin2s -a 32 $< | $(AS) -o $(@) 191 | 192 | -include $(DEPENDS) 193 | 194 | #------------------------------------------------------------------------------- 195 | endif 196 | #------------------------------------------------------------------------------- -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Compat Title Installer 2 | 3 | Install a channel to the vWii Menu from Wii U Mode. In its current state, it 4 | simply installs the Homebrew Channel. 5 | 6 | ## Building 7 | 8 | You need devkitPPC, devkitARM and WUT installed, and the environment variables set 9 | correctly. You will need the following libraries: 10 | 11 | * [libmocha](https://github.com/wiiu-env/libmocha) 12 | 13 | If everything is installed, run 'make release' and the output will be available as 14 | 'compat_installer-HBL.zip' and 'compat_installer-Aroma.zip'. 15 | 16 | ## Credits 17 | 18 | * Dimok, smealum, others for iosuhax and Mocha CFW. 19 | * FIX94, this repo is largely based off of wuphax. 20 | * @Ingunar on GitHub, for the awesome icons 21 | * TheLordScruffy/mkwcat, for the original Compat Title Installer 22 | 23 | ## License 24 | 25 | This software is licensed under the GNU General Public License version 2 (or any 26 | later version). The full license can be found in the LICENSE file. 27 | 28 | The Homebrew Channel is licensed under GPLv2 and is included in binary form. A 29 | copy of the source code is available at 30 | [fail0verflow/hbc](https://github.com/fail0verflow/hbc). 31 | -------------------------------------------------------------------------------- /data/title_00000000.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Xpl0itU/vwii-compat-installer/f3552b8fe03762608259cff955984f13e9ec93ad/data/title_00000000.bin -------------------------------------------------------------------------------- /data/title_00000001.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Xpl0itU/vwii-compat-installer/f3552b8fe03762608259cff955984f13e9ec93ad/data/title_00000001.bin -------------------------------------------------------------------------------- /data/title_cetk.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Xpl0itU/vwii-compat-installer/f3552b8fe03762608259cff955984f13e9ec93ad/data/title_cetk.bin -------------------------------------------------------------------------------- /data/title_tmd.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Xpl0itU/vwii-compat-installer/f3552b8fe03762608259cff955984f13e9ec93ad/data/title_tmd.bin -------------------------------------------------------------------------------- /meta/hbl/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Xpl0itU/vwii-compat-installer/f3552b8fe03762608259cff955984f13e9ec93ad/meta/hbl/icon.png -------------------------------------------------------------------------------- /meta/hbl/meta.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | vWii Compat Installer 4 | TheLordScruffy, DaThinkingChair 5 | 1.6 6 | https://github.com/Xpl0itU/vwii-compat-installer 7 | Install the Homebrew Channel to the vWii Menu from Wii U Mode. 8 | Install a channel to the vWii Menu from Wii U Mode. In its current state, it simply installs the Homebrew Channel. 9 | source code: https://github.com/Xpl0itU/vwii-compat-installer 10 | 11 | tool 12 | 13 | 14 | -------------------------------------------------------------------------------- /meta/wuhb/drc-splash.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Xpl0itU/vwii-compat-installer/f3552b8fe03762608259cff955984f13e9ec93ad/meta/wuhb/drc-splash.png -------------------------------------------------------------------------------- /meta/wuhb/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Xpl0itU/vwii-compat-installer/f3552b8fe03762608259cff955984f13e9ec93ad/meta/wuhb/icon.png -------------------------------------------------------------------------------- /meta/wuhb/tv-splash.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Xpl0itU/vwii-compat-installer/f3552b8fe03762608259cff955984f13e9ec93ad/meta/wuhb/tv-splash.png -------------------------------------------------------------------------------- /src/InputUtils.cpp: -------------------------------------------------------------------------------- 1 | #include "InputUtils.h" 2 | 3 | void Input::read() { 4 | VPADRead(VPAD_CHAN_0, &vpad_status, 1, &vpad_error); 5 | if (vpad_error != VPAD_READ_SUCCESS) 6 | memset(&vpad_status, 0, sizeof(VPADStatus)); 7 | 8 | memset(&kpad_status, 0, sizeof(KPADStatus)); 9 | WPADExtensionType controllerType; 10 | for (int i = 0; i < 4; i++) { 11 | if (WPADProbe((WPADChan) i, &controllerType) == 0) { 12 | KPADRead((WPADChan) i, &kpad_status, 1); 13 | break; 14 | } 15 | } 16 | } 17 | 18 | bool Input::get(ButtonState state, Button button) const { 19 | uint32_t vpadState = 0; 20 | uint32_t kpadState = 0; 21 | uint32_t kpadClassicState = 0; 22 | uint32_t kpadProState = 0; 23 | 24 | switch (state) { 25 | case TRIGGER: 26 | vpadState = vpad_status.trigger; 27 | kpadState = kpad_status.trigger; 28 | kpadClassicState = kpad_status.classic.trigger; 29 | kpadProState = kpad_status.pro.trigger; 30 | break; 31 | case HOLD: 32 | vpadState = vpad_status.hold; 33 | kpadState = kpad_status.hold; 34 | kpadClassicState = kpad_status.classic.hold; 35 | kpadProState = kpad_status.pro.hold; 36 | break; 37 | case RELEASE: 38 | vpadState = vpad_status.release; 39 | kpadState = kpad_status.release; 40 | kpadClassicState = kpad_status.classic.release; 41 | kpadProState = kpad_status.pro.release; 42 | break; 43 | } 44 | if ((vpadState != 0) || (kpadState != 0) || (kpadClassicState != 0) || (kpadProState != 0)) { 45 | switch (button) { 46 | case PAD_BUTTON_A: 47 | if (vpadState & VPAD_BUTTON_A) return true; 48 | if (kpadState & WPAD_BUTTON_A) return true; 49 | if (kpadClassicState & WPAD_CLASSIC_BUTTON_A) return true; 50 | if (kpadProState & WPAD_PRO_BUTTON_A) return true; 51 | break; 52 | case PAD_BUTTON_B: 53 | if (vpadState & VPAD_BUTTON_B) return true; 54 | if (kpadState & WPAD_BUTTON_B) return true; 55 | if (kpadClassicState & WPAD_CLASSIC_BUTTON_B) return true; 56 | if (kpadProState & WPAD_PRO_BUTTON_B) return true; 57 | break; 58 | case PAD_BUTTON_X: 59 | if (vpadState & VPAD_BUTTON_X) return true; 60 | if (kpadState & WPAD_BUTTON_1) return true; 61 | if (kpadClassicState & WPAD_CLASSIC_BUTTON_X) return true; 62 | if (kpadProState & WPAD_PRO_BUTTON_X) return true; 63 | break; 64 | case PAD_BUTTON_UP: 65 | if (vpadState & VPAD_BUTTON_UP) return true; 66 | if (vpadState & VPAD_STICK_L_EMULATION_UP) return true; 67 | if (kpadState & WPAD_BUTTON_UP) return true; 68 | if (kpadClassicState & WPAD_CLASSIC_BUTTON_UP) return true; 69 | if (kpadClassicState & WPAD_CLASSIC_STICK_L_EMULATION_UP) return true; 70 | if (kpadProState & WPAD_PRO_BUTTON_UP) return true; 71 | if (kpadProState & WPAD_PRO_STICK_L_EMULATION_UP) return true; 72 | break; 73 | case PAD_BUTTON_DOWN: 74 | if (vpadState & VPAD_BUTTON_DOWN) return true; 75 | if (vpadState & VPAD_STICK_L_EMULATION_DOWN) return true; 76 | if (kpadState & WPAD_BUTTON_DOWN) return true; 77 | if (kpadClassicState & WPAD_CLASSIC_BUTTON_DOWN) return true; 78 | if (kpadClassicState & WPAD_CLASSIC_STICK_L_EMULATION_DOWN) return true; 79 | if (kpadProState & WPAD_PRO_BUTTON_DOWN) return true; 80 | if (kpadProState & WPAD_PRO_STICK_L_EMULATION_DOWN) return true; 81 | break; 82 | case PAD_BUTTON_LEFT: 83 | if (vpadState & VPAD_BUTTON_LEFT) return true; 84 | if (vpadState & VPAD_STICK_L_EMULATION_LEFT) return true; 85 | if (kpadState & WPAD_BUTTON_LEFT) return true; 86 | if (kpadClassicState & WPAD_CLASSIC_BUTTON_LEFT) return true; 87 | if (kpadClassicState & WPAD_CLASSIC_STICK_L_EMULATION_LEFT) return true; 88 | if (kpadProState & WPAD_PRO_BUTTON_LEFT) return true; 89 | if (kpadProState & WPAD_PRO_STICK_L_EMULATION_LEFT) return true; 90 | break; 91 | case PAD_BUTTON_RIGHT: 92 | if (vpadState & VPAD_BUTTON_RIGHT) return true; 93 | if (vpadState & VPAD_STICK_L_EMULATION_RIGHT) return true; 94 | if (kpadState & WPAD_BUTTON_RIGHT) return true; 95 | if (kpadClassicState & WPAD_CLASSIC_BUTTON_RIGHT) return true; 96 | if (kpadClassicState & WPAD_CLASSIC_STICK_L_EMULATION_RIGHT) return true; 97 | if (kpadProState & WPAD_PRO_BUTTON_RIGHT) return true; 98 | if (kpadProState & WPAD_PRO_STICK_L_EMULATION_RIGHT) return true; 99 | break; 100 | case PAD_BUTTON_L: 101 | if (vpadState & VPAD_BUTTON_L) return true; 102 | if (kpadState & WPAD_BUTTON_MINUS) return true; 103 | if (kpadClassicState & WPAD_CLASSIC_BUTTON_L) return true; 104 | if (kpadProState & WPAD_PRO_TRIGGER_L) return true; 105 | break; 106 | case PAD_BUTTON_R: 107 | if (vpadState & VPAD_BUTTON_R) return true; 108 | if (kpadState & WPAD_BUTTON_PLUS) return true; 109 | if (kpadClassicState & WPAD_CLASSIC_BUTTON_R) return true; 110 | if (kpadProState & WPAD_PRO_TRIGGER_R) return true; 111 | break; 112 | case PAD_BUTTON_ANY: 113 | if (vpadState) return true; 114 | if (kpadState) return true; 115 | if (kpadClassicState) return true; 116 | if (kpadProState) return true; 117 | break; 118 | } 119 | } 120 | return false; 121 | } -------------------------------------------------------------------------------- /src/InputUtils.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | typedef enum Button { 8 | PAD_BUTTON_A, 9 | PAD_BUTTON_B, 10 | PAD_BUTTON_X, 11 | PAD_BUTTON_UP, 12 | PAD_BUTTON_DOWN, 13 | PAD_BUTTON_LEFT, 14 | PAD_BUTTON_RIGHT, 15 | PAD_BUTTON_L, 16 | PAD_BUTTON_R, 17 | PAD_BUTTON_ANY 18 | } Button; 19 | 20 | typedef enum ButtonState { 21 | TRIGGER, 22 | HOLD, 23 | RELEASE 24 | } ButtonState; 25 | 26 | class Input { 27 | public: 28 | void read() __attribute__((hot)); 29 | bool get(ButtonState state, Button button) const __attribute__((hot)); 30 | 31 | private: 32 | VPADStatus vpad_status; 33 | VPADReadError vpad_error; 34 | KPADStatus kpad[4], kpad_status; 35 | }; -------------------------------------------------------------------------------- /src/StateUtils.cpp: -------------------------------------------------------------------------------- 1 | #include "StateUtils.h" 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | bool State::aroma = false; 10 | 11 | void State::init() { 12 | OSDynLoad_Module mod; 13 | aroma = OSDynLoad_Acquire("homebrew_kernel", &mod) == OS_DYNLOAD_OK; 14 | if (aroma) { 15 | OSDynLoad_Release(mod); 16 | ProcUIInit(&OSSavesDone_ReadyToRelease); 17 | OSEnableHomeButtonMenu(true); 18 | } else 19 | WHBProcInit(); 20 | } 21 | 22 | bool State::AppRunning() { 23 | if (aroma) { 24 | bool app = true; 25 | if (OSIsMainCore()) { 26 | switch (ProcUIProcessMessages(true)) { 27 | case PROCUI_STATUS_EXITING: 28 | // Being closed, prepare to exit 29 | app = false; 30 | break; 31 | case PROCUI_STATUS_RELEASE_FOREGROUND: 32 | // Free up MEM1 to next foreground app, deinit screen, etc. 33 | ProcUIDrawDoneRelease(); 34 | break; 35 | case PROCUI_STATUS_IN_FOREGROUND: 36 | // Executed while app is in foreground 37 | app = true; 38 | break; 39 | case PROCUI_STATUS_IN_BACKGROUND: 40 | OSSleepTicks(OSMillisecondsToTicks(20)); 41 | break; 42 | } 43 | } 44 | 45 | return app; 46 | } 47 | return WHBProcIsRunning(); 48 | } 49 | 50 | void State::shutdown() { 51 | if (!aroma) { 52 | WHBProcShutdown(); 53 | OSScreenShutdown(); 54 | } 55 | ProcUIShutdown(); 56 | } -------------------------------------------------------------------------------- /src/StateUtils.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class State { 4 | public: 5 | static void init(); 6 | static bool AppRunning(); 7 | static void shutdown(); 8 | 9 | private: 10 | static bool aroma; 11 | }; -------------------------------------------------------------------------------- /src/installer.cpp: -------------------------------------------------------------------------------- 1 | /* Wii title installer for Wii U Mode 2 | * Copyright (C) 2021 TheLordScruffy 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License along 15 | * with this program; if not, write to the Free Software Foundation, Inc., 16 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 17 | */ 18 | 19 | #include "installer.h" 20 | #include 21 | #include 22 | #include 23 | #include 24 | 25 | void WUPI_putstr(const char *); 26 | 27 | #define CINS_Log(...) \ 28 | do { \ 29 | char _wupi_print_str[256]; \ 30 | snprintf(_wupi_print_str, 255, __VA_ARGS__); \ 31 | WUPI_putstr(_wupi_print_str); \ 32 | } while (0) 33 | 34 | #define IOS_SUCCESS FS_ERROR_OK 35 | 36 | #define CINS_PATH_LEN (sizeof("/vol/slccmpt01") + 63) 37 | 38 | #define CINS_ID_HI ((uint32_t) (CINS_TITLEID >> 32)) 39 | #define CINS_ID_LO ((uint32_t) (CINS_TITLEID & 0xFFFFFFFF)) 40 | 41 | #define CINS_TRY(c) \ 42 | if (!(c)) \ 43 | do { \ 44 | CINS_Log("Failed, please exit and try again\n"); \ 45 | goto error; \ 46 | } while (0) 47 | 48 | extern FSAClientHandle fsaClient; 49 | 50 | int32_t CINS_Install(const void *ticket, uint32_t ticket_size, const void *tmd, 51 | uint32_t tmd_size, CINS_Content *contents, 52 | uint16_t numContents) { 53 | FSError ret; 54 | int32_t i; 55 | FSAFileHandle fd; 56 | char path[CINS_PATH_LEN], pathd[CINS_PATH_LEN]; 57 | char titlePath[CINS_PATH_LEN], ticketPath[CINS_PATH_LEN], 58 | ticketFolder[CINS_PATH_LEN]; 59 | 60 | CINS_Log("Starting install\n"); 61 | 62 | /* This installer originally created a temporary directory for the 63 | * installation, wrote everything to flash there, then renamed it all to 64 | * other directories. The wupserver doesn't already support renaming files, 65 | * and my attempt to add it failed so I gave up. */ 66 | snprintf(titlePath, CINS_PATH_LEN, "/vol/slccmpt01/title/%08x/%08x", CINS_ID_HI, 67 | CINS_ID_LO); 68 | snprintf(path, CINS_PATH_LEN, "/vol/slccmpt01/title/%08x", CINS_ID_HI); 69 | snprintf(ticketPath, CINS_PATH_LEN, "/vol/slccmpt01/ticket/%08x/%08x.tik", CINS_ID_HI, 70 | CINS_ID_LO); 71 | snprintf(ticketFolder, CINS_PATH_LEN, "/vol/slccmpt01/ticket/%08x", CINS_ID_HI); 72 | /* Init stage is not needed anymore. */ 73 | 74 | CINS_Log("Writing ticket...\n"); 75 | { 76 | FSARemove(fsaClient, ticketPath); 77 | 78 | ret = FSAMakeDir(fsaClient, ticketFolder, (FSMode) 0x666); 79 | if (ret == FS_ERROR_OK || ret == FS_ERROR_ALREADY_EXISTS) { 80 | CINS_TRY(FSAOpenFileEx(fsaClient, ticketPath, "wb", (FSMode) 0x666, FS_OPEN_FLAG_NONE, 0, &fd) == FS_ERROR_OK); 81 | CINS_TRY(FSAWriteFile(fsaClient, const_cast(ticket), ticket_size, 1, fd, FSA_WRITE_FLAG_NONE) == 1); 82 | 83 | FSACloseFile(fsaClient, fd); 84 | 85 | ret = FS_ERROR_OK; 86 | } 87 | 88 | CINS_TRY(ret == FS_ERROR_OK); // ret == 0 89 | } 90 | 91 | CINS_Log("Creating title directory...\n"); 92 | { 93 | /* Create the title directory if it doesn't already exist. The first 94 | * word (type) should exist, but the second one (the unique title) 95 | * shouldn't unless there is save data. */ 96 | ret = FSAMakeDir(fsaClient, path, (FSMode) 0x666); 97 | if (ret == FS_ERROR_OK || ret == FS_ERROR_ALREADY_EXISTS) { 98 | ret = FSAMakeDir(fsaClient, titlePath, (FSMode) 0x666); 99 | if (ret == FS_ERROR_ALREADY_EXISTS) { 100 | /* The title is already installed, delete content but preserve 101 | * the data directory. */ 102 | CINS_Log( 103 | "Title directory already exists, deleting content...\n"); 104 | snprintf(path, CINS_PATH_LEN, "/vol/slccmpt01/title/%08x/%08x/content", 105 | CINS_ID_HI, CINS_ID_LO); 106 | ret = FSARemove(fsaClient, path); 107 | if (ret == FS_ERROR_OK || ret == FS_ERROR_NOT_FOUND) 108 | ret = FS_ERROR_OK; 109 | } 110 | } 111 | 112 | CINS_TRY(ret == FS_ERROR_OK); // ret == 0 113 | 114 | /* This directory is necessary for the Wii Menu to function 115 | * correctly, but also don't overwrite any data that might already 116 | * exist. */ 117 | strncpy(pathd, titlePath, CINS_PATH_LEN); 118 | strncat(pathd, "/data", CINS_PATH_LEN - 1); 119 | ret = FSAMakeDir(fsaClient, pathd, (FSMode) 0x666); 120 | if (ret != FS_ERROR_OK && ret != FS_ERROR_ALREADY_EXISTS) { 121 | CINS_Log("Failed to create the data directory, ret = %d\n", ret); 122 | goto error; 123 | } 124 | 125 | strncpy(pathd, titlePath, CINS_PATH_LEN); 126 | strncat(pathd, "/content", CINS_PATH_LEN - 1); 127 | CINS_TRY(FSAMakeDir(fsaClient, pathd, (FSMode) 0x666) == FS_ERROR_OK); 128 | } 129 | 130 | CINS_Log("Writing TMD...\n"); 131 | { 132 | /* pathd should be the content directory */ 133 | strncpy(path, pathd, CINS_PATH_LEN); 134 | strncat(path, "/title.tmd", CINS_PATH_LEN - 1); 135 | 136 | CINS_TRY(FSAOpenFileEx(fsaClient, path, "wb", (FSMode) 0x666, FS_OPEN_FLAG_NONE, 0, &fd) == FS_ERROR_OK); 137 | CINS_TRY(FSAWriteFile(fsaClient, const_cast(tmd), tmd_size, 1, fd, FSA_WRITE_FLAG_NONE) == 1); 138 | 139 | FSACloseFile(fsaClient, fd); 140 | } 141 | 142 | CINS_Log("Writing contents...\n"); 143 | { 144 | for (i = 0; i < numContents; i++) { 145 | // CINS_Log("Writing content %08x.app\n", i); 146 | snprintf(path, CINS_PATH_LEN, 147 | "/vol/slccmpt01/title/%08x/%08x/content/%08x.app", CINS_ID_HI, 148 | CINS_ID_LO, i); 149 | 150 | CINS_TRY(FSAOpenFileEx(fsaClient, path, "wb", (FSMode) 0x666, FS_OPEN_FLAG_NONE, 0, &fd) == FS_ERROR_OK); 151 | CINS_TRY(FSAWriteFile(fsaClient, const_cast(contents[i].data), contents[i].length, 1, fd, FSA_WRITE_FLAG_NONE) == 1); 152 | 153 | FSACloseFile(fsaClient, fd); 154 | } 155 | } 156 | ret = IOS_SUCCESS; 157 | CINS_Log("Install succeeded!\n"); 158 | 159 | error: 160 | FSACloseFile(fsaClient, fd); 161 | if (ret < 0) { 162 | CINS_Log("Install failed, attempting to delete title...\n"); 163 | /* Installation failed in the final stages. Delete these to be sure 164 | * there is no 'half installed' title lurking in the filesystem. */ 165 | FSARemove(fsaClient, titlePath); 166 | FSARemove(fsaClient, ticketPath); 167 | } 168 | 169 | return ret > 0 ? 0 : ret; 170 | } 171 | -------------------------------------------------------------------------------- /src/installer.h: -------------------------------------------------------------------------------- 1 | /* installer.h 2 | * Copyright (C) 2021 TheLordScruffy 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License along 15 | * with this program; if not, write to the Free Software Foundation, Inc., 16 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 17 | */ 18 | 19 | #pragma once 20 | 21 | #ifdef __cplusplus 22 | extern "C" { 23 | #endif 24 | 25 | #include 26 | #include 27 | #include 28 | 29 | typedef struct 30 | { 31 | const void *data; 32 | size_t length; 33 | } CINS_Content; 34 | 35 | #define CINS_TITLEID 0x000100014F484243 36 | #define CINS_GROUPID 0x5453 37 | /* IOS58 */ 38 | #define CINS_SYSVERSION 0x000000010000003A 39 | #define CINS_TITLE_VERSION 0x0000 40 | 41 | extern int32_t CINS_iosuhaxFd; 42 | extern int32_t CINS_fsaFd; 43 | extern int32_t CINS_logLine; 44 | 45 | int32_t CINS_Install(const void *ticket, uint32_t ticket_size, const void *tmd, 46 | uint32_t tmd_size, CINS_Content *contents, 47 | uint16_t numContents); 48 | 49 | #ifdef __cplusplus 50 | } 51 | #endif 52 | -------------------------------------------------------------------------------- /src/main.cpp: -------------------------------------------------------------------------------- 1 | /* Compat Title Installer main source file 2 | * Copyright (C) 2021 TheLordScruffy 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License along 15 | * with this program; if not, write to the Free Software Foundation, Inc., 16 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 17 | */ 18 | 19 | #include "installer.h" 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include 38 | 39 | #include "InputUtils.h" 40 | #include "StateUtils.h" 41 | 42 | #define FS_ALIGN(x) ((x + 0x3F) & ~(0x3F)) 43 | 44 | void WUPI_printTop(); 45 | void WUPI_putstr(const char *str); 46 | void WUPI_resetScreen(); 47 | 48 | int32_t wupiLine; 49 | uint8_t *screen_buffer; 50 | uint32_t screen_size; 51 | 52 | FSAClientHandle fsaClient; 53 | 54 | /* Title data */ 55 | extern const uint8_t title_cetk_bin[]; 56 | extern const uint32_t title_cetk_bin_size; 57 | extern const uint8_t title_tmd_bin[]; 58 | extern const uint32_t title_tmd_bin_size; 59 | extern const uint8_t title_00000000_bin[]; 60 | extern const uint32_t title_00000000_bin_size; 61 | extern const uint8_t title_00000001_bin[]; 62 | extern const uint32_t title_00000001_bin_size; 63 | 64 | bool mounted = false, exploit = false; 65 | CINS_Content contents[2]; 66 | int32_t ret, fsaFd = -1; 67 | 68 | bool initFS() { 69 | FSAInit(); 70 | fsaClient = FSAAddClient(nullptr); 71 | bool retUnlock = 72 | Mocha_UnlockFSClientEx(fsaClient) == MOCHA_RESULT_SUCCESS; 73 | if (retUnlock) { 74 | FSAMount(fsaClient, "/dev/slccmpt01", "/vol/slccmpt01", FSA_MOUNT_FLAG_LOCAL_MOUNT, nullptr, 0); 75 | return true; 76 | } 77 | return false; 78 | } 79 | 80 | void deinitFS() { 81 | FSAUnmount(fsaClient, "/vol/slccmpt01", FSA_UNMOUNT_FLAG_NONE); 82 | Mocha_DeInitLibrary(); 83 | FSADelClient(fsaClient); 84 | FSAShutdown(); 85 | } 86 | 87 | static void wupiPrintln(int32_t line, const char *str) { 88 | /* put line twice for double buffer */ 89 | OSScreenPutFontEx(SCREEN_TV, 0, line, str); 90 | OSScreenPutFontEx(SCREEN_DRC, 0, line, str); 91 | OSScreenFlipBuffersEx(SCREEN_TV); 92 | OSScreenFlipBuffersEx(SCREEN_DRC); 93 | 94 | OSScreenPutFontEx(SCREEN_TV, 0, line, str); 95 | OSScreenPutFontEx(SCREEN_DRC, 0, line, str); 96 | OSScreenFlipBuffersEx(SCREEN_TV); 97 | OSScreenFlipBuffersEx(SCREEN_DRC); 98 | } 99 | 100 | void WUPI_printTop() { 101 | wupiPrintln(0, "Compat Title Installer v1.6"); 102 | wupiPrintln(1, "COPYRIGHT (c) 2021-2023 TheLordScruffy, DaThinkingChair"); 103 | } 104 | 105 | /* I don't care enough to implement a va arg function */ 106 | #define WUPI_printf(...) \ 107 | do { \ 108 | char _wupi_print_str[256]; \ 109 | snprintf(_wupi_print_str, 255, __VA_ARGS__); \ 110 | WUPI_putstr(_wupi_print_str); \ 111 | } while (0) 112 | 113 | void WUPI_putstr(const char *str) { 114 | wupiPrintln(wupiLine++, str); 115 | } 116 | 117 | void WUPI_resetScreen() { 118 | memset((void *) screen_buffer, 0, screen_size); 119 | wupiLine = 4; 120 | 121 | WUPI_printTop(); 122 | } 123 | 124 | void WUPI_waitHome() { 125 | WUPI_putstr("Press HOME to exit."); 126 | while (State::AppRunning()) 127 | continue; 128 | return; 129 | } 130 | 131 | int32_t WUPI_setupInstall() { 132 | if (Mocha_InitLibrary() == MOCHA_RESULT_SUCCESS) 133 | return 0; 134 | return -1; 135 | } 136 | 137 | void WUPI_install() { 138 | /* We should only end up here if the A button was pressed. */ 139 | WUPI_resetScreen(); 140 | if (WUPI_setupInstall() < 0) { 141 | WUPI_putstr("Error: IOS exploit failed."); 142 | WUPI_waitHome(); 143 | return; 144 | } 145 | exploit = true; 146 | 147 | if (!(ret = initFS())) { 148 | WUPI_putstr("Error: Failed to mount /vol/slccmpt01.\n"); 149 | WUPI_waitHome(); 150 | return; 151 | } 152 | mounted = true; 153 | 154 | WUPI_putstr("Installing the Homebrew Channel...\n"); 155 | 156 | void *title_cetk_bin_aligned = aligned_alloc(0x40, FS_ALIGN(title_cetk_bin_size)); 157 | void *title_tmd_bin_aligned = aligned_alloc(0x40, FS_ALIGN(title_tmd_bin_size)); 158 | memmove(title_cetk_bin_aligned, title_cetk_bin, title_cetk_bin_size); 159 | memmove(title_tmd_bin_aligned, title_tmd_bin, title_tmd_bin_size); 160 | 161 | void *title_00000000_bin_aligned = aligned_alloc(0x40, FS_ALIGN(title_00000000_bin_size)); 162 | void *title_00000001_bin_aligned = aligned_alloc(0x40, FS_ALIGN(title_00000001_bin_size)); 163 | memmove(title_00000000_bin_aligned, title_00000000_bin, title_00000000_bin_size); 164 | memmove(title_00000001_bin_aligned, title_00000001_bin, title_00000001_bin_size); 165 | 166 | contents[0].data = (const void *) title_00000000_bin_aligned; 167 | contents[0].length = title_00000000_bin_size; 168 | contents[1].data = (const void *) title_00000001_bin_aligned; 169 | contents[1].length = title_00000001_bin_size; 170 | ret = CINS_Install((const void *) title_cetk_bin_aligned, title_cetk_bin_size, 171 | (const void *) title_tmd_bin_aligned, title_tmd_bin_size, contents, 172 | 2); 173 | free(title_cetk_bin_aligned); 174 | free(title_tmd_bin_aligned); 175 | free(title_00000000_bin_aligned); 176 | free(title_00000001_bin_aligned); 177 | if (ret < 0) 178 | WUPI_printf("Install failed. Error Code: %06X\n", -ret); 179 | WUPI_waitHome(); 180 | } 181 | 182 | int main() { 183 | int32_t tv_screen_size, drc_screen_size; 184 | Input input; 185 | 186 | State::init(); 187 | AXInit(); 188 | AXQuit(); 189 | 190 | WPADInit(); 191 | KPADInit(); 192 | WPADEnableURCC(1); 193 | 194 | /* Initialize screen */ 195 | OSScreenInit(); 196 | tv_screen_size = OSScreenGetBufferSizeEx(SCREEN_TV); 197 | drc_screen_size = OSScreenGetBufferSizeEx(SCREEN_DRC); 198 | screen_size = tv_screen_size + drc_screen_size; 199 | screen_buffer = (uint8_t *) memalign(0x100, screen_size); 200 | OSScreenSetBufferEx(SCREEN_TV, screen_buffer); /* TV */ 201 | OSScreenSetBufferEx(SCREEN_DRC, screen_buffer + tv_screen_size); /* DRC */ 202 | OSScreenEnableEx(SCREEN_TV, 1); 203 | OSScreenEnableEx(SCREEN_DRC, 1); 204 | OSScreenClearBufferEx(SCREEN_TV, 0); 205 | OSScreenClearBufferEx(SCREEN_DRC, 0); 206 | 207 | WUPI_resetScreen(); 208 | WUPI_putstr("Press A to install the Homebrew Channel to the Wii Menu."); 209 | WUPI_putstr("Press HOME to exit."); 210 | 211 | while (State::AppRunning()) { 212 | input.read(); 213 | if (input.get(TRIGGER, PAD_BUTTON_ANY)) { 214 | WUPI_resetScreen(); 215 | WUPI_putstr("Press A to install the Homebrew Channel to the Wii Menu."); 216 | WUPI_putstr("Press HOME to exit."); 217 | } 218 | if (input.get(TRIGGER, PAD_BUTTON_A)) { 219 | WUPI_install(); 220 | break; 221 | } 222 | } 223 | 224 | deinitFS(); 225 | 226 | if (screen_buffer) 227 | free(screen_buffer); 228 | State::shutdown(); 229 | return 0; 230 | } 231 | --------------------------------------------------------------------------------