diff --git a/.gitignore b/.gitignore index 643f697..1d67595 100644 --- a/.gitignore +++ b/.gitignore @@ -41,21 +41,20 @@ $RECYCLE.BIN/ Network Trash Folder Temporary Items .apdisk -saviine/installer/bin/* -saviine/client/build/* -saviine/server/src/bin/logs/* -saviine/server/src/bin/saviine_root/* -saviine/server/src/bin/saviine_server.pdb -saviine/server/src/bin/saviine_server.vshost.exe.manifest -saviine/server/src/obj/x86/Debug/saviine_server.exe -saviine/server/src/obj/x86/Debug/saviine_server.pdb -saviine/server/src/bin/saviine_server.vshost.exe -saviine/server/src/bin/saviine_server.exe.config -saviine/server/src/bin/saviine_server.vshost.exe.config -saviine/server/src/obj/x86/Debug/DesignTimeResolveAssemblyReferences.cache -saviine/server/src/obj/x86/Debug/DesignTimeResolveAssemblyReferencesInput.cache -saviine/server/src/obj/x86/Debug/saviine_server.csprojResolveAssemblyReference.cache -saviine/server/src/obj/x86/Debug/saviine_server.csproj.FileListAbsolute.txt -saviine/server/src/obj/x86/Debug/saviine_server.csproj.GenerateResource.Cache -saviine/server/src/obj/x86/Debug/saviine_server.Form1.resources -saviine/server/src/bin/saviine_server.exe + +server/src/bin/logs/* +server/src/bin/saviine_root/* +server/src/bin/saviine_server.pdb +server/src/bin/saviine_server.vshost.exe.manifest +server/src/obj/x86/Debug/saviine_server.exe +server/src/obj/x86/Debug/saviine_server.pdb +server/src/bin/saviine_server.vshost.exe +server/src/bin/saviine_server.exe.config +server/src/bin/saviine_server.vshost.exe.config +server/src/obj/x86/Debug/DesignTimeResolveAssemblyReferences.cache +server/src/obj/x86/Debug/DesignTimeResolveAssemblyReferencesInput.cache +server/src/obj/x86/Debug/saviine_server.csprojResolveAssemblyReference.cache +server/src/obj/x86/Debug/saviine_server.csproj.FileListAbsolute.txt +server/src/obj/x86/Debug/saviine_server.csproj.GenerateResource.Cache +server/src/obj/x86/Debug/saviine_server.Form1.resources +server/src/bin/saviine_server.exe diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..9cecc1d --- /dev/null +++ b/LICENSE @@ -0,0 +1,674 @@ + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + {one line to give the program's name and a brief idea of what it does.} + Copyright (C) {year} {name of author} + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + {project} Copyright (C) {year} {fullname} + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +. diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..cb85e99 --- /dev/null +++ b/Makefile @@ -0,0 +1,217 @@ +#--------------------------------------------------------------------------------- +# Clear the implicit built in rules +#--------------------------------------------------------------------------------- +.SUFFIXES: +#--------------------------------------------------------------------------------- +ifeq ($(strip $(DEVKITPPC)),) +$(error "Please set DEVKITPPC in your environment. export DEVKITPPC=devkitPPC") +endif +ifeq ($(strip $(DEVKITPRO)),) +$(error "Please set DEVKITPRO in your environment. export DEVKITPRO=devkitPRO") +endif +export PATH := $(DEVKITPPC)/bin:$(PORTLIBS)/bin:$(PATH) +export LIBOGC_INC := $(DEVKITPRO)/libogc/include +export LIBOGC_LIB := $(DEVKITPRO)/libogc/lib/wii +export PORTLIBS := $(DEVKITPRO)/portlibs/ppc + +PREFIX := powerpc-eabi- + +export AS := $(PREFIX)as +export CC := $(PREFIX)gcc +export CXX := $(PREFIX)g++ +export AR := $(PREFIX)ar +export OBJCOPY := $(PREFIX)objcopy + +#--------------------------------------------------------------------------------- +# TARGET is the name of the output +# BUILD is the directory where object files & intermediate files will be placed +# SOURCES is a list of directories containing source code +# INCLUDES is a list of directories containing extra header files +#--------------------------------------------------------------------------------- +TARGET := saviine +BUILD := build +BUILD_DBG := $(TARGET)_dbg +SOURCES := src \ + src/dynamic_libs \ + src/game \ + src/kernel \ + src/patcher \ + src/system \ + src/utils +DATA := + +INCLUDES := src + +#--------------------------------------------------------------------------------- +# options for code generation +#--------------------------------------------------------------------------------- +CFLAGS := -std=gnu11 -mrvl -mcpu=750 -meabi -mhard-float -ffast-math \ + -O3 -Wall -Wextra -Wno-unused-parameter -Wno-strict-aliasing $(INCLUDE) +CXXFLAGS := -std=gnu++11 -mrvl -mcpu=750 -meabi -mhard-float -ffast-math \ + -O3 -Wall -Wextra -Wno-unused-parameter -Wno-strict-aliasing $(INCLUDE) +ASFLAGS := -mregnames +LDFLAGS := -nostartfiles -Wl,-Map,$(notdir $@).map,-wrap,malloc,-wrap,free,-wrap,memalign,-wrap,calloc,-wrap,realloc,-wrap,malloc_usable_size,-wrap,_malloc_r,-wrap,_free_r,-wrap,_realloc_r,-wrap,_calloc_r,-wrap,_memalign_r,-wrap,_malloc_usable_size_r,-wrap,valloc,-wrap,_valloc_r,-wrap,_pvalloc_r,--gc-sections + +#--------------------------------------------------------------------------------- +Q := @ +MAKEFLAGS += --no-print-directory +#--------------------------------------------------------------------------------- +# any extra libraries we wish to link with the project +#--------------------------------------------------------------------------------- +LIBS := + +#--------------------------------------------------------------------------------- +# list of directories containing libraries, this must be the top level containing +# include and lib +#--------------------------------------------------------------------------------- +LIBDIRS := $(CURDIR) \ + $(DEVKITPPC)/lib \ + $(DEVKITPPC)/lib/gcc/powerpc-eabi/4.8.2 + + +#--------------------------------------------------------------------------------- +# no real need to edit anything past this point unless you need to add additional +# rules for different file extensions +#--------------------------------------------------------------------------------- +ifneq ($(BUILD),$(notdir $(CURDIR))) +#--------------------------------------------------------------------------------- +export PROJECTDIR := $(CURDIR) +export OUTPUT := $(CURDIR)/$(TARGETDIR)/$(TARGET) +export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \ + $(foreach dir,$(DATA),$(CURDIR)/$(dir)) +export DEPSDIR := $(CURDIR)/$(BUILD) + +#--------------------------------------------------------------------------------- +# automatically build a list of object files for our project +#--------------------------------------------------------------------------------- +CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c))) +CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp))) +sFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s))) +SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.S))) +BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*))) +TTFFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.ttf))) +PNGFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.png))) + +#--------------------------------------------------------------------------------- +# use CXX for linking C++ projects, CC for standard C +#--------------------------------------------------------------------------------- +ifeq ($(strip $(CPPFILES)),) + export LD := $(CC) +else + export LD := $(CXX) +endif + +export OFILES := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) \ + $(sFILES:.s=.o) $(SFILES:.S=.o) \ + $(PNGFILES:.png=.png.o) $(addsuffix .o,$(BINFILES)) + +#--------------------------------------------------------------------------------- +# build a list of include paths +#--------------------------------------------------------------------------------- +export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \ + $(foreach dir,$(LIBDIRS),-I$(dir)/include) \ + -I$(CURDIR)/$(BUILD) -I$(LIBOGC_INC) \ + -I$(PORTLIBS)/include -I$(PORTLIBS)/include/freetype2 + +#--------------------------------------------------------------------------------- +# build a list of library paths +#--------------------------------------------------------------------------------- +export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib) \ + -L$(LIBOGC_LIB) -L$(PORTLIBS)/lib + +export OUTPUT := $(CURDIR)/$(TARGET) +.PHONY: $(BUILD) clean install + +#--------------------------------------------------------------------------------- +$(BUILD): + @[ -d $@ ] || mkdir -p $@ + @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile + +#--------------------------------------------------------------------------------- +clean: + @echo clean ... + @rm -fr $(BUILD) $(OUTPUT).elf $(OUTPUT).bin $(BUILD_DBG).elf + +#--------------------------------------------------------------------------------- +else + +DEPENDS := $(OFILES:.o=.d) + +#--------------------------------------------------------------------------------- +# main targets +#--------------------------------------------------------------------------------- +$(OUTPUT).elf: $(OFILES) + +#--------------------------------------------------------------------------------- +# This rule links in binary data with the .jpg extension +#--------------------------------------------------------------------------------- +%.elf: link.ld $(OFILES) + @echo "linking ... $(TARGET).elf" + $(Q)$(LD) -n -T $^ $(LDFLAGS) -o ../$(BUILD_DBG).elf $(LIBPATHS) $(LIBS) + $(Q)$(OBJCOPY) -S -R .comment -R .gnu.attributes ../$(BUILD_DBG).elf $@ + +../data/loader.bin: + $(MAKE) -C ../loader clean + $(MAKE) -C ../loader +#--------------------------------------------------------------------------------- +%.a: +#--------------------------------------------------------------------------------- + @echo $(notdir $@) + @rm -f $@ + @$(AR) -rc $@ $^ + +#--------------------------------------------------------------------------------- +%.o: %.cpp + @echo $(notdir $<) + @$(CXX) -MMD -MP -MF $(DEPSDIR)/$*.d $(CXXFLAGS) -c $< -o $@ $(ERROR_FILTER) + +#--------------------------------------------------------------------------------- +%.o: %.c + @echo $(notdir $<) + @$(CC) -MMD -MP -MF $(DEPSDIR)/$*.d $(CFLAGS) -c $< -o $@ $(ERROR_FILTER) + +#--------------------------------------------------------------------------------- +%.o: %.S + @echo $(notdir $<) + @$(CC) -MMD -MP -MF $(DEPSDIR)/$*.d -x assembler-with-cpp $(ASFLAGS) -c $< -o $@ $(ERROR_FILTER) + +#--------------------------------------------------------------------------------- +%.png.o : %.png + @echo $(notdir $<) + @bin2s -a 32 $< | $(AS) -o $(@) + +#--------------------------------------------------------------------------------- +%.jpg.o : %.jpg + @echo $(notdir $<) + @bin2s -a 32 $< | $(AS) -o $(@) + +#--------------------------------------------------------------------------------- +%.ttf.o : %.ttf + @echo $(notdir $<) + @bin2s -a 32 $< | $(AS) -o $(@) + +#--------------------------------------------------------------------------------- +%.bin.o : %.bin + @echo $(notdir $<) + @bin2s -a 32 $< | $(AS) -o $(@) + +#--------------------------------------------------------------------------------- +%.wav.o : %.wav + @echo $(notdir $<) + @bin2s -a 32 $< | $(AS) -o $(@) + +#--------------------------------------------------------------------------------- +%.mp3.o : %.mp3 + @echo $(notdir $<) + @bin2s -a 32 $< | $(AS) -o $(@) + +#--------------------------------------------------------------------------------- +%.ogg.o : %.ogg + @echo $(notdir $<) + @bin2s -a 32 $< | $(AS) -o $(@) + +-include $(DEPENDS) + +#--------------------------------------------------------------------------------- +endif +#--------------------------------------------------------------------------------- diff --git a/README b/README index a9c0500..1cc520e 100644 --- a/README +++ b/README @@ -1,16 +1,13 @@ -Saviine 1.0 (25.10.2015) +Saviine 1.1 (02.04.2016) -Compatible with 5.3.2 fw - -dumps and injects (experimental) WiiU Saves(Thanks to everyone who worked on cafiine! code is based on cafiine) +Dumps and injects (experimental) WiiU Saves. +Works with homebrew launcher (https://github.com/dimok789/homebrew_launcher), compatible with FW 5.0.0, 5.1,0, 5.3.2, 5.4.0, 5.5.x (But requires a kernel exploit) Compilation : -- in order to compile saviine you need to put the saviine folder in your libwiiu project -- libwiiu/saviine/installer must be compiled like the other libwiiu examples (with the build.py script) -- copy the saviine532.elf from the saviine/installer/bin to the www folder +- just compile it with "make" and put the saviine.elf on your sd card Pre-made version : -- in www/saviine, it is already compiled, just put the folder in your server +- you can fine a release package under the "releases" tab Note : - make sure you already have a save of the game on you console before trying to dump/inject them @@ -19,6 +16,7 @@ Note : - backup your savedata before dumping it!!! I'm not responsible for any lost data. - make sure that your game version and the game version from injecting save are the same - e.g. injecting PAL saves into NTSC one is untested! +- this new version only runs with the homebrew_launcher. NOTE FOR SUPER SMASH BROS FOR WIIU the common data is too big to inject at one time. The data will may be flushed at some time. automaticly restoring the data after flushing is not possible. MAKE SURE TO MAKE A BACKUP! This may also applies to other gaames @@ -33,8 +31,11 @@ saviine_root/inject <-- place the saves here if you want to inject them How to use : temporary installing saviine: -- launch the "normal" kernel exploit in the brower -- relaunch browser and launch saviine app, set saviine server ip in the application with up/down/left/right, and press A to install saviine. if you see crap on the screen, press up/down to fix it +- put the elf into the app path on your SD Card (e.g. /wiiu/apps/saviine/saviine.elf) and insert the sd card into your WiiU (You can also use the sendelf method) +- launch the homebrew launcher to install the kernel exploit +- relaunch browser and launch the homebrew launcher again. This time the homebrew launcher will start. +- select saviine and start it. +- set saviine server ip in the application with up/down/left/right, and press A to install saviine. if you see crap on the screen, press up/down to fix it -> browser should exit dumping: diff --git a/meta/meta.xml b/meta/meta.xml new file mode 100644 index 0000000..98d2a8a --- /dev/null +++ b/meta/meta.xml @@ -0,0 +1,10 @@ + + + Saviine + Maschell + 1.1 + 20160402200000 + Savegame tool + This application dumps and injects savegames of any title that is entered over network to a PC application. + + diff --git a/saviine.elf b/saviine.elf new file mode 100644 index 0000000..ac1739f Binary files /dev/null and b/saviine.elf differ diff --git a/saviine/client/Makefile b/saviine/client/Makefile deleted file mode 100644 index c8478fe..0000000 --- a/saviine/client/Makefile +++ /dev/null @@ -1,69 +0,0 @@ - -PATH := $(DEVKITPPC)/bin:$(PATH) - -PREFIX ?= powerpc-eabi- -LD := $(PREFIX)ld -AS := $(PREFIX)as -CC := $(PREFIX)gcc -OBJDUMP ?= $(PREFIX)objdump -OBJCOPY ?= $(PREFIX)objcopy - -SFLAGS := -mgekko -mregnames - -# -O2: optimise lots -# -Wall: generate lots of warnings -# -x c: compile as C code -# -std=gnu99: use the C99 standard with GNU extensions -# -ffreestanding: we don't have libc; don't expect we do -# -mrvl: enable wii/gamecube compilation -# -mcpu=750: enable processor specific compilation -# -meabi: enable eabi specific compilation -# -mhard-float: enable hardware floating point instructions -# -fshort-wchar: use 16 bit whcar_t type in keeping with Wii executables -# -msdata-none: do not use r2 or r13 as small data areas -# -memb: enable embedded application specific compilation -# -ffunction-sections: split up functions so linker can garbage collect -# -fdata-sections: split up data so linker can garbage collect -CFLAGS := -O2 -Wall -x c -std=gnu99 \ - -ffreestanding \ - -mrvl -mcpu=750 -meabi -mhard-float -fshort-wchar \ - -msdata=none -memb -ffunction-sections -fdata-sections \ - -Wno-unknown-pragmas -Wno-strict-aliasing \ - -SRC := $(wildcard *.S) $(wildcard *.c) -OBJ := $(patsubst %.S,%.o,$(patsubst %.c,%.o,$(SRC))) - - -# Simulate an order only dependency -BUILD_REQ := $(filter-out $(wildcard build),build) -BIN_REQ := $(filter-out $(wildcard bin),bin) - -all: build/saviine532.elf copy - -../installer/saviine%.h: build/saviine%.text.bin build/saviine%.magic.bin $(BIN_REQ) - xxd -i build/saviine$*.magic.bin | sed "s/unsigned/static const unsigned/g;s/saviine$*/saviine/g" > $@ - xxd -i build/saviine$*.text.bin | sed "s/unsigned/static const unsigned/g;s/saviine$*/saviine/g" >> $@ - -build/saviine%.text.bin: build/saviine%.elf $(BUILD_REQ) - $(OBJCOPY) -j .text -O binary $< $@ -build/saviine%.magic.bin: build/saviine%.elf $(BUILD_REQ) - $(OBJCOPY) -j .magic -O binary $< $@ - -build/saviine%.elf: saviine%.ld $(OBJ) $(BUILD_REQ) - $(LD) -o $@ -T $< $(OBJ) -s -L"$(DEVKITPPC)/lib/gcc/powerpc-eabi/4.8.2" -lgcc - -build/%.o: %.c $(BUILD_REQ) - $(CC) -c $(CFLAGS) -o $@ $+ -build/%.o: %.S $(BUILD_REQ) - $(AS) $(SFLAGS) -o $@ $+ - -bin: - mkdir $@ -build: - mkdir $@ - -copy: - cp build/saviine532.elf ../installer/bin/ - -clean: - rm -rf $(wildcard build) $(wildcard bin) $(wildcard ../installer/saviine532.h) diff --git a/saviine/client/main.c b/saviine/client/main.c deleted file mode 100644 index 5243a93..0000000 --- a/saviine/client/main.c +++ /dev/null @@ -1,643 +0,0 @@ -#include "main.h" - -#define DECL(res, name, ...) \ - extern res name(__VA_ARGS__); \ - res (* real_ ## name)(__VA_ARGS__) __attribute__((section(".magicptr"))); \ - res my_ ## name(__VA_ARGS__) -#define DEBUG_LOG 0 -#define BUFFER_SIZE 0x400 * 101 -#define BUFFER_SIZE_STEPS 0x200 - -DECL(int, FSAInit, void) { - if ((int)bss_ptr == 0x0a000000) { - bss_ptr = memalign(sizeof(struct bss_t), 0x40); - memset(bss_ptr, 0, sizeof(struct bss_t)); - } - return real_FSAInit(); -} -DECL(int, FSAShutdown, void) { - return real_FSAShutdown(); -} -DECL(int, FSAAddClient, void *r3) { - int res = real_FSAAddClient(r3); - - if ((int)bss_ptr != 0x0a000000 && res < MAX_CLIENT && res >= 0) { - cafiine_connect(&bss.socket_fsa[res]); - } - - return res; -} -DECL(int, FSADelClient, int client) { - - if ((int)bss_ptr != 0x0a000000 && client < MAX_CLIENT && client >= 0) { - cafiine_disconnect(bss.socket_fsa[client]); - } - - return real_FSADelClient(client); -} - -static int strlen(char* path) { - int i = 0; - while (path[i++]) - ; - return i; -} - -static int client_num_alloc(void *pClient) { - int i; - - for (i = 0; i < MAX_CLIENT; i++) - if (bss.pClient_fs[i] == 0) { - bss.pClient_fs[i] = pClient; - return i; - } - return -1; -} - -static void client_num_free(int client) { - bss.pClient_fs[client] = 0; -} - -static int client_num(void *pClient) { - int i; - - for (i = 0; i < MAX_CLIENT; i++) - if (bss.pClient_fs[i] == pClient) - return i; - return -1; -} - -DECL(int, FSInit, void) { - if ((int)bss_ptr == 0x0a000000) { - bss_ptr = memalign(sizeof(struct bss_t), 0x40); - memset(bss_ptr, 0, sizeof(struct bss_t)); - - } - return real_FSInit(); -} -DECL(int, FSShutdown, void) { - return real_FSShutdown(); -} -DECL(int, FSDelClient, void *pClient) { - if ((int)bss_ptr != 0x0a000000) { - int client = client_num(pClient); - if (client < MAX_CLIENT && client >= 0) { - cafiine_disconnect(bss.socket_fs[client]); - client_num_free(client); - } - } - return real_FSDelClient(pClient); -} -DECL(int, FSWriteFile,FSClient *pClient, FSCmdBlock *pCmd, const void *source,int size, int count, int fileHandle, int flag,FSRetFlag error) { - return real_FSWriteFile(pClient,pCmd,source,size,count,fileHandle,flag,error); -} - -DECL(int, FSFlushQuota,FSClient *pClient,FSCmdBlock *pCmd,const char *path,FSRetFlag error) { - return real_FSFlushQuota(pClient,pCmd,path,error); -} -DECL(void, _Exit,void) { - return real__Exit(); -} - - -DECL(int, FSAddClientEx, void *r3, void *r4, void *r5) { - if(!bss.saveinitfs){ //bypass the check for save_init - if(bss.saveFolderChecked != 2){ - - if(bss.saveFolderChecked == 1){ - if(r3 != bss.on_start_hook_client){ // block every other client until the on_start method is done - while(bss.saveFolderChecked != 2 || bss.saveFolderChecked != 3){ - GX2WaitForVsync(); - } - } - } - - if ((int)bss_ptr != 0x0a000000) { - int error = 0; - if(bss.saveFolderChecked == 0){ - bss.saveFolderChecked = 1; - // Create client and cmd block - FSClient* pClient_ = (FSClient*)malloc(sizeof(FSClient)); - FSCmdBlock* pCmd = (FSCmdBlock*)malloc(sizeof(FSCmdBlock)); - if (pClient_ && pCmd){ - // need to save the pointer of our client to find it again where adding our client to the FS - bss.on_start_hook_client = pClient_; - // Add client to FS. - if(FSAddClient(pClient_, FS_RET_ALL_ERROR) >= 0){ - int client = client_num_alloc(pClient_); - if(client < MAX_CLIENT && client >= 0) { - cafiine_connect(&bss.socket_fs[client]); - bss.logsock = bss.socket_fs[client]; - }else{ - error = 3; - bss.saveFolderChecked = 3; - } - // Init command block. - FSInitCmdBlock(pCmd); - if(DEBUG_LOG) log_string(bss.logsock, "FSInitCmdBlock() done", BYTE_LOG_STR); - hook(pClient_, pCmd,FS_RET_ALL_ERROR); - // Init command block. - if(DEBUG_LOG) log_string(bss.logsock, "hook done", BYTE_LOG_STR); - - - real_FSDelClient(pClient_); - }else{ - error = 2; - bss.saveFolderChecked = 3; - } - free(pClient_); - free(pCmd); - if(DEBUG_LOG) log_string(bss.logsock, "freed the client and buffer", BYTE_LOG_STR); - if(bss.saveFolderChecked != 3) - bss.saveFolderChecked = 2; - if(DEBUG_LOG) log_string(bss.logsock, "set status to done;", BYTE_LOG_STR); - }else{ - error = 1; - bss.saveFolderChecked = 3; - } - } - } - } - }else{ - bss.saveinitfs = 0; - } - - int res = real_FSAddClientEx(r3, r4, r5); - return res; -} - -void hook(void * pClient,void * pCmd, int error){ - if(DEBUG_LOG) log_string(bss.logsock, "hook", BYTE_LOG_STR); - handle_saves(pClient, pCmd,error); -} - -void handle_saves(void *pClient, void *pCmd,int error){ - if(DEBUG_LOG) log_string(bss.logsock, "init", BYTE_LOG_STR); - int client = client_num(pClient); - unsigned char slotNo; - long id = getPesistentID(&slotNo); - init_Save(slotNo); - int mode; - - if(DEBUG_LOG)log_string(bss.logsock, "getting mode", BYTE_LOG_STR); - if(getMode(bss.socket_fsa[client],&mode)){ - if(id >= 0x80000000 && id <= 0x90000000){ - char savepath[20]; - __os_snprintf(savepath, sizeof(savepath), "/vol/save/%08x",id); - if(mode == BYTE_MODE_D){ - log_string(bss.logsock, "dump mode!", BYTE_LOG_STR); - dumpSavaData(pClient, pCmd,id,error); - }else if(mode == BYTE_MODE_I){ - log_string(bss.logsock, "inject mode", BYTE_LOG_STR); - injectSaveData(pClient,pCmd,id,error); - } - } - } -} - -void dumpSavaData(void *pClient, void *pCmd,long persistentID,int error){ - int client = client_num(pClient); - /* - Allocate buffer for injection - */ - int buf_size = BUFFER_SIZE; - char * pBuffer; - int failed = 0; - do{ - buf_size -= BUFFER_SIZE_STEPS; - if(buf_size < 0){ - log_string(bss.logsock, "error on buffer allocation", BYTE_LOG_STR); - failed = 1; - break; - } - pBuffer = (char *)MEMAllocFromDefaultHeapEx(buf_size, 0x40); - if(pBuffer) memset(pBuffer, 0x00, buf_size); - }while(!pBuffer); - - if(!failed){ - int mask = 0; - char buffer[60]; - __os_snprintf(buffer, sizeof(buffer), "allocated %d bytes",buf_size); - log_string(bss.logsock, buffer, BYTE_LOG_STR); - if(saviine_start_dump(bss.socket_fsa[client], persistentID,&mask)){ - if((mask & MASK_USER) == MASK_USER){ - char savepath[20]; - __os_snprintf(savepath, sizeof(savepath), "/vol/save/%08x",persistentID); - log_string(bss.logsock, "dumping user savedata", BYTE_LOG_STR); - if(dump_dir(pClient,pCmd,savepath,pBuffer,buf_size,error,50) == -1){ - log_string(bss.logsock, "error dumping user dir", BYTE_LOG_STR); - failed = 1; - } - } - if((mask & MASK_COMMON) == MASK_COMMON && !failed){ - char * commonDir = "/vol/save/common"; - log_string(bss.logsock, "dumping common savedata", BYTE_LOG_STR); - if(dump_dir(pClient,pCmd,commonDir,pBuffer,buf_size,error,60) == -1){ - log_string(bss.logsock, "error dumping common dir (maybe the game has no common folder?)", BYTE_LOG_STR); - } - } - - log_string(bss.logsock, "done!", BYTE_LOG_STR); - - if(!saviine_end_dump(bss.socket_fsa[client])) if(DEBUG_LOG) log_string(bss.logsock, "saviine_end_injection() failed", BYTE_LOG_STR); - if(DEBUG_LOG) log_string(bss.logsock, "end of dump", BYTE_LOG_STR); - }else{ - log_string(bss.logsock, "saviine_start_dump() failed", BYTE_LOG_STR); - } - - if(DEBUG_LOG) log_string(bss.logsock, "free(pBuffer) coming next", BYTE_LOG_STR); - free(pBuffer); - if(DEBUG_LOG) log_string(bss.logsock, "free(pBuffer)", BYTE_LOG_STR); - } -} - -int dump_dir(void *pClient, void *pCmd, char *path, void * pBuffer, int size,int error, int handle){ - int client = client_num(pClient); - int dir_handle = handle; - int my_handle = handle +1; - int ret = 0; - int final_result = 0; - if ((ret = FSOpenDir(pClient, pCmd, path, &dir_handle, FS_RET_ALL_ERROR)) == FS_STATUS_OK){ - char buffer[strlen(path) + 30]; - __os_snprintf(buffer, sizeof(buffer), "open dir %s",path); - log_string(bss.logsock, buffer, BYTE_LOG_STR); - FSDirEntry dir_entry; - while (FSReadDir(pClient, pCmd, dir_handle, &dir_entry, FS_RET_ALL_ERROR) == FS_STATUS_OK && final_result == 0) - { - char full_path[strlen(path) + 1 + strlen(dir_entry.name) +1]; - __os_snprintf(full_path, sizeof(full_path), "%s/%s",path,dir_entry.name); - - if((dir_entry.stat.flag&FS_STAT_FLAG_IS_DIRECTORY) == FS_STAT_FLAG_IS_DIRECTORY){ - log_string(bss.logsock, "-> dir", BYTE_LOG_STR); - - if(dump_dir(pClient, pCmd,full_path,pBuffer,size,error,my_handle) == -1){ - log_string(bss.logsock, "error", BYTE_LOG_STR); - final_result = -1; - } - }else{ - //DUMP - ret = FSOpenFile(pClient, pCmd, full_path, "r", &my_handle, error); - if (ret >= 0) { - __os_snprintf(buffer, sizeof(buffer), "dumping %s",dir_entry.name); - log_string(bss.logsock, buffer, BYTE_LOG_STR); - - int ret2; - - int my_ret = cafiine_send_handle(bss.socket_fsa[client], client, full_path, my_handle); - if(my_ret != -1){ - while ((ret2 = FSReadFile(pClient, pCmd, pBuffer, 1, size, my_handle, 0, 0)) > 0) - cafiine_send_file(bss.socket_fsa[client], pBuffer, ret2, my_handle); - cafiine_fclose(bss.socket_fsa[client], &ret2, my_handle,1); - }else{ - log_string(bss.logsock, "error on opening file on pc" , BYTE_LOG_STR); - final_result = -1; - } - if((ret2 = FSCloseFile(pClient, pCmd, my_handle, error)) < FS_STATUS_OK){ - __os_snprintf(buffer, sizeof(buffer), "error on FSOpenFile: %d",ret2); - log_string(bss.logsock, buffer, BYTE_LOG_STR); - } - }else{ - __os_snprintf(buffer, sizeof(buffer), "error on FSOpenFile: %d",ret); - log_string(bss.logsock, buffer, BYTE_LOG_STR); - final_result = -1; - } - } - } - if(FSCloseDir(pClient, pCmd, dir_handle, error) < FS_STATUS_OK){ - if(DEBUG_LOG) log_string(bss.logsock, "error on FSCloseDir()", BYTE_LOG_STR); - } - }else{ - log_string(bss.logsock, "error on FSOpenDir()", BYTE_LOG_STR); - final_result = -1; - } - return final_result; -} - -/************************** - Injection functions -**************************/ -void injectSaveData(void *pClient, void *pCmd,long persistentID,int error){ - int client = client_num(pClient); - char logbuffer[255]; - /* - Allocate buffer for injection - */ - int buf_size = BUFFER_SIZE; - char * pBuffer; - int failed = 0; - do{ - buf_size -= BUFFER_SIZE_STEPS; - if(buf_size < 0){ - log_string(bss.logsock, "error on buffer allocation", BYTE_LOG_STR); - failed = 1; - break; - } - pBuffer = (char *)MEMAllocFromDefaultHeapEx(buf_size, 0x40); - if(pBuffer) memset(pBuffer, 0x00, buf_size); - }while(!pBuffer); - - if(!failed){ - char buffer[60]; - __os_snprintf(buffer, sizeof(buffer), "allocated %d bytes",buf_size); - log_string(bss.logsock, buffer, BYTE_LOG_STR); - int result = 0; - int mask = 0; - if((result = saviine_start_injection(bss.socket_fsa[client], persistentID,&mask))){ - if((mask & MASK_USER) == MASK_USER){ - char savepath[20]; - __os_snprintf(savepath, sizeof(savepath), "/vol/save/%08x",persistentID); - __os_snprintf(logbuffer, sizeof(logbuffer), "injecting new userdata in %08x",persistentID); - log_string(bss.logsock, logbuffer, BYTE_LOG_STR); - log_string(bss.logsock, "deleting user save", BYTE_LOG_STR); - if(remove_files_in_dir(pClient,pCmd,savepath,0) == -1){ - failed = 1; - }else{ - /* - Inject Save - */ - result = injectFiles(pClient,pCmd,savepath,"/",savepath,pBuffer,buf_size,error); - doFlushOrRollback(pClient,pCmd,result,savepath); - } - } - if((mask & MASK_COMMON) == MASK_COMMON && !failed){ - char * commonDir = "/vol/save/common"; - - if((mask & MASK_COMMON_CLEAN) == MASK_COMMON_CLEAN){ - log_string(bss.logsock, "deleting common save", BYTE_LOG_STR); - if(remove_files_in_dir(pClient,pCmd,commonDir,0) == -1){ - failed = 1; - } - } - if(!failed){ - /* - Inject common - */ - result = injectFiles(pClient,pCmd,commonDir,"/",commonDir,pBuffer,buf_size,error); - doFlushOrRollback(pClient,pCmd,result,commonDir); - } - } - if(!saviine_end_injection(bss.socket_fsa[client])) if(DEBUG_LOG) log_string(bss.logsock, "saviine_end_injection() failed", BYTE_LOG_STR); - if(DEBUG_LOG)log_string(bss.logsock, "end of injection", BYTE_LOG_STR); - }else{ - log_string(bss.logsock, "saviine_start_injection() failed", BYTE_LOG_STR); - } - free(pBuffer); - } -} - -int injectFiles(void *pClient, void *pCmd, char * path,char * relativepath, char * basepath, char * pBuffer, int buffer_size, int error){ - int client = client_num(pClient); - int failed = 0; - int filesinjected = 0; - int type = 0; - log_string(bss.logsock, "injecting files", BYTE_LOG_STR); - char namebuffer[255]; - char logbuffer[255]; - int filesize = 0; - - if(!failed){ - while(saviine_readdir(bss.socket_fsa[client],path,namebuffer, &type,&filesize) && !failed){ - if(DEBUG_LOG)log_string(bss.logsock, "got a file", BYTE_LOG_STR); - char newpath[strlen(path) + 1 + strlen(namebuffer)]; - __os_snprintf(newpath, sizeof(newpath), "%s/%s",path,namebuffer); - if(type == BYTE_FILE){ - __os_snprintf(logbuffer, sizeof(logbuffer), "file: %s%s size: %d",relativepath,namebuffer,filesize); - log_string(bss.logsock, logbuffer, BYTE_LOG_STR); - if(DEBUG_LOG) log_string(bss.logsock, "downloading it", BYTE_LOG_STR); - - int handle = 10; - if(FSOpenFile(pClient, pCmd, newpath,"w+",&handle,error) >= FS_STATUS_OK){ - if(DEBUG_LOG) log_string(bss.logsock, "file opened and created", BYTE_LOG_STR); - - if(filesize > 0){ - failed = doInjectForFile(pClient,pCmd,handle,newpath,filesize,basepath,pBuffer,buffer_size); - if(failed == 2) // trying it again if the journal was full - failed = doInjectForFile(pClient,pCmd,handle,newpath,filesize,basepath,pBuffer,buffer_size); - }else{ - if(DEBUG_LOG) log_string(bss.logsock, "filesize is 0", BYTE_LOG_STR); - } - - if((FSCloseFile (pClient, pCmd, handle, error)) < FS_STATUS_OK){ - log_string(bss.logsock, "FSCloseFile failed", BYTE_LOG_STR); - failed = 1; - } - }else{ - log_string(bss.logsock, "opening the file failed", BYTE_LOG_STR); - failed = 1; - } - if(!failed) filesinjected++; - }else if( type == BYTE_FOLDER){ - __os_snprintf(logbuffer, sizeof(logbuffer), "dir: %s",namebuffer); - log_string(bss.logsock, logbuffer, BYTE_LOG_STR); - if(DEBUG_LOG) log_string(bss.logsock, newpath, BYTE_LOG_STR); - int ret = 0; - if((ret = FSMakeDir(pClient, pCmd, newpath, -1)) == FS_STATUS_OK || ret == FS_STATUS_EXISTS ){ - char op_offset[strlen(relativepath) + strlen(namebuffer)+ 1 + 1]; - __os_snprintf(op_offset, sizeof(op_offset), "%s%s/",relativepath,namebuffer); - int injectedsub = injectFiles(pClient, pCmd, newpath,op_offset,basepath,pBuffer,buffer_size,error); - if(injectedsub == -1){ - failed = 1; - }else{ - filesinjected += injectedsub; - } - }else{ - log_string(bss.logsock, "folder creation failed", BYTE_LOG_STR); - failed = 1; - } - } - } - if(failed) return -1; - else return filesinjected; - }else{ - return -1; - } -} - -int doInjectForFile(void * pClient, void * pCmd,int handle,char * filepath,int filesize, char * basepath,void * pBuffer,int buf_size){ - int client = client_num(pClient); - int failed = 0; - int myhandle; - int ret = 0; - char logbuffer[255]; - if((cafiine_fopen(bss.socket_fsa[client], &ret, filepath, "r", &myhandle)) == 0 && ret == FS_STATUS_OK){ - if(DEBUG_LOG)__os_snprintf(logbuffer, sizeof(logbuffer), "cafiine_fopen with handle %d",myhandle); - if(DEBUG_LOG) log_string(bss.logsock, logbuffer, BYTE_LOG_STR); - int retsize = 0; - int pos = 0; - while(pos < filesize){ - if(DEBUG_LOG) log_string(bss.logsock, "reading", BYTE_LOG_STR); - if(cafiine_fread(bss.socket_fsa[client], &retsize, pBuffer, buf_size , myhandle) == FS_STATUS_OK){ - if(DEBUG_LOG)__os_snprintf(logbuffer, sizeof(logbuffer), "got %d",retsize); - if(DEBUG_LOG) log_string(bss.logsock, logbuffer, BYTE_LOG_STR); - int fwrite = 0; - if((fwrite = my_FSWriteFile(pClient, pCmd, pBuffer,sizeof(char),retsize,handle,0,0x0200)) >= FS_STATUS_OK){ - if(DEBUG_LOG)__os_snprintf(logbuffer, sizeof(logbuffer), "wrote %d",retsize); - if(DEBUG_LOG) log_string(bss.logsock, logbuffer, BYTE_LOG_STR); - }else{ - if(fwrite == FS_STATUS_JOURNAL_FULL || fwrite == FS_STATUS_STORAGE_FULL){ - log_string(bss.logsock, "journal or storage is full, flushing it now.", BYTE_LOG_STR); - if(FSFlushQuota(pClient,pCmd,basepath,FS_RET_ALL_ERROR) == FS_STATUS_OK){ - log_string(bss.logsock, "success", BYTE_LOG_STR); - failed = 2; - break; - }else{ - log_string(bss.logsock, "failed", BYTE_LOG_STR); - failed = 1; - break; - } - - } - __os_snprintf(logbuffer, sizeof(logbuffer), "my_FSWriteFile failed with error: %d",fwrite); - log_string(bss.logsock, logbuffer, BYTE_LOG_STR); - //log_string(bss.logsock, "error while FSWriteFile", BYTE_LOG_STR); - failed = 1; - break; - } - if(DEBUG_LOG)__os_snprintf(logbuffer, sizeof(logbuffer), "old p %d new p %d",pos,pos+retsize); - if(DEBUG_LOG) log_string(bss.logsock, logbuffer, BYTE_LOG_STR); - pos += retsize; - }else{ - log_string(bss.logsock, "error while recieving file", BYTE_LOG_STR); - failed = 1; - break; - } - } - - int result = 0; - if((cafiine_fclose(bss.socket_fsa[client], &result, myhandle,0)) == 0 && result == FS_STATUS_OK){ - if(DEBUG_LOG) log_string(bss.logsock, "cafiine_fclose success", BYTE_LOG_STR); - }else{ - log_string(bss.logsock, "cafiine_fclose failed", BYTE_LOG_STR); - failed = 1; - } - - - }else{ - log_string(bss.logsock, "cafiine_fopen failed", BYTE_LOG_STR); - failed = 1; - } - return failed; -} - -/************************* - Util functions -**************************/ - -/*flush if result != -1*/ -void doFlushOrRollback(void *pClient, void *pCmd,int result,char *savepath){ - char logbuffer[50 + strlen(savepath)]; - if(result != -1){ - __os_snprintf(logbuffer, sizeof(logbuffer), "injected %d files",result); - log_string(bss.logsock, logbuffer, BYTE_LOG_STR); - log_string(bss.logsock, "Flushing data now", BYTE_LOG_STR); - if(FSFlushQuota(pClient,pCmd,savepath,FS_RET_ALL_ERROR) == FS_STATUS_OK){ - log_string(bss.logsock, "success", BYTE_LOG_STR); - }else{ - log_string(bss.logsock, "failed", BYTE_LOG_STR); - } - }else{ - log_string(bss.logsock, "injection failed, trying to restore the data", BYTE_LOG_STR); - if(FSRollbackQuota(pClient,pCmd,savepath,FS_RET_ALL_ERROR) == FS_STATUS_OK){ - log_string(bss.logsock, "rollback done", BYTE_LOG_STR); - }else{ - log_string(bss.logsock, "rollback failed", BYTE_LOG_STR); - } - } -} - -void init_Save(unsigned char slotNo){ - int (*SAVEInit)(); - int (*SAVEInitSaveDir)(unsigned char accountSlotNo); - unsigned int save_handle; - OSDynLoad_Acquire("nn_save.rpl", &save_handle); - OSDynLoad_FindExport(save_handle, 0, "SAVEInit", (void **)&SAVEInit); - OSDynLoad_FindExport(save_handle, 0, "SAVEInitSaveDir", (void **)&SAVEInitSaveDir); - bss.saveinitfs = 1; - SAVEInit(); - if(DEBUG_LOG) log_string(bss.logsock, "saveinit done", BYTE_LOG_STR); - SAVEInitSaveDir(slotNo); - if(DEBUG_LOG) log_string(bss.logsock, "SAVEInitSaveDir done", BYTE_LOG_STR); - SAVEInitSaveDir(255U); - if(DEBUG_LOG) log_string(bss.logsock, "SAVEInitSaveDir 2 done", BYTE_LOG_STR); -} - -long getPesistentID(unsigned char * slotno){ - unsigned int nn_act_handle; - unsigned long (*GetPersistentIdEx)(unsigned char); - int (*GetSlotNo)(void); - void (*nn_Initialize)(void); - void (*nn_Finalize)(void); - OSDynLoad_Acquire("nn_act.rpl", &nn_act_handle); - OSDynLoad_FindExport(nn_act_handle, 0, "GetPersistentIdEx__Q2_2nn3actFUc", (void **)&GetPersistentIdEx); - OSDynLoad_FindExport(nn_act_handle, 0, "GetSlotNo__Q2_2nn3actFv", (void **)&GetSlotNo); - OSDynLoad_FindExport(nn_act_handle, 0, "Initialize__Q2_2nn3actFv", (void **)&nn_Initialize); - OSDynLoad_FindExport(nn_act_handle, 0, "Finalize__Q2_2nn3actFv", (void **)&nn_Finalize); - - nn_Initialize(); // To be sure that it is really Initialized - - *slotno = GetSlotNo(); - - long idlong = GetPersistentIdEx(*slotno); - - nn_Finalize(); //must be called an equal number of times to nn_Initialize - return idlong; -} - -int remove_files_in_dir(void * pClient,void * pCmd, char * path, int handle){ - int ret = 0; - int my_handle = handle +1; - char buffer[strlen(path) + 50]; - if ((ret = FSOpenDir(pClient, pCmd, path, &handle, FS_RET_ALL_ERROR)) == FS_STATUS_OK){ - __os_snprintf(buffer, sizeof(buffer), "remove files in dir %s",path); - log_string(bss.logsock, buffer, BYTE_LOG_STR); - FSDirEntry dir_entry; - while (FSReadDir(pClient, pCmd, handle, &dir_entry, FS_RET_ALL_ERROR) == FS_STATUS_OK) - { - char full_path[strlen(path) + 1 + strlen(dir_entry.name) +1]; - __os_snprintf(full_path, sizeof(full_path), "%s/%s",path,dir_entry.name); - if((dir_entry.stat.flag&FS_STAT_FLAG_IS_DIRECTORY) == FS_STAT_FLAG_IS_DIRECTORY){ - if(DEBUG_LOG) log_string(bss.logsock, "recursive deletion", BYTE_LOG_STR); - if(remove_files_in_dir(pClient,pCmd,full_path,my_handle) == -1) return -1; - - } - char buffer[strlen(full_path) + 50]; - __os_snprintf(buffer, sizeof(buffer), "deleting %s",full_path); - log_string(bss.logsock, buffer, BYTE_LOG_STR); - if((ret = FSRemove(pClient,pCmd,full_path,FS_RET_ALL_ERROR)) < FS_STATUS_OK){ - __os_snprintf(buffer, sizeof(buffer), "error: %d on removing %s",ret,full_path); - log_string(bss.logsock, buffer, BYTE_LOG_STR); - return -1; - } - - } - if((FSCloseDir(pClient, pCmd, handle, FS_RET_NO_ERROR)) < FS_STATUS_OK ){ - log_string(bss.logsock, "error while closing dir", BYTE_LOG_STR); - return -1; - } - }else{ - __os_snprintf(buffer, sizeof(buffer), "error: %d on opening %s",ret,path); - log_string(bss.logsock, buffer, BYTE_LOG_STR); - return -1; - } - return 0; -} - -#define MAKE_MAGIC(x) { x, my_ ## x, &real_ ## x } - -struct magic_t { - const void *real; - const void *replacement; - const void *call; -} methods[] __attribute__((section(".magic"))) = { - MAKE_MAGIC(FSAInit), - MAKE_MAGIC(FSAShutdown), - MAKE_MAGIC(FSAAddClient), - MAKE_MAGIC(FSADelClient), - MAKE_MAGIC(FSInit), - MAKE_MAGIC(FSShutdown), - MAKE_MAGIC(FSAddClientEx), - MAKE_MAGIC(FSDelClient), - MAKE_MAGIC(FSWriteFile), - MAKE_MAGIC(FSFlushQuota), - MAKE_MAGIC(_Exit), -}; diff --git a/saviine/client/main.h b/saviine/client/main.h deleted file mode 100644 index 958dd20..0000000 --- a/saviine/client/main.h +++ /dev/null @@ -1,147 +0,0 @@ -/* string.h */ -#include "../common/fs_defs.h" -#define NULL ((void *)0) - -#define BYTE_NORMAL 0xff -#define BYTE_SPECIAL 0xfe -#define BYTE_OPEN 0x00 -#define BYTE_READ 0x01 -#define BYTE_CLOSE 0x02 -#define BYTE_OK 0x03 -#define BYTE_SETPOS 0x04 -#define BYTE_STATFILE 0x05 -#define BYTE_EOF 0x06 -#define BYTE_GETPOS 0x07 -#define BYTE_REQUEST 0x08 -#define BYTE_REQUEST_SLOW 0x09 -#define BYTE_HANDLE 0x0A -#define BYTE_DUMP 0x0B -#define BYTE_PING 0x0C -#define BYTE_G_MODE 0x0D -#define BYTE_MODE_D 0x0E -#define BYTE_MODE_I 0x0F -#define BYTE_CLOSE_DUMP 0x10 -#define BYTE_LOG_STR 0xfb -#define BYTE_FILE 0xC0 -#define BYTE_FOLDER 0xC1 -#define BYTE_READ_DIR 0xCC -#define BYTE_INJECTSTART 0x40 -#define BYTE_INJECTEND 0x41 -#define BYTE_DUMPSTART 0x42 -#define BYTE_DUMPEND 0x43 -#define BYTE_END 0xfd - -#define MASK_NORMAL 0x8000 -#define MASK_USER 0x0100 -#define MASK_COMMON 0x0200 -#define MASK_COMMON_CLEAN 0x0400 - -void GX2WaitForVsync(void); - -void *memcpy(void *dst, const void *src, int bytes); -void *memset(void *dst, int val, int bytes); - -/* malloc.h */ -extern void *(* const MEMAllocFromDefaultHeapEx)(int size, int align); -extern void *(* const MEMAllocFromDefaultHeap)(int size); -extern void *(* const MEMFreeToDefaultHeap)(void *ptr); -#define memalign (*MEMAllocFromDefaultHeapEx) -#define malloc (*MEMAllocFromDefaultHeap) -#define free (*MEMFreeToDefaultHeap) -/* socket.h */ -#define AF_INET 2 -#define SOCK_STREAM 1 -#define IPPROTO_TCP 6 - -/* FS Functions */ -extern FSStatus FSAddClient(FSClient *pClient, FSRetFlag errHandling); -extern void FSInitCmdBlock(FSCmdBlock *pCmd); -extern FSStatus FSCloseDir(FSClient *pClient, FSCmdBlock *pCmd, int dh, FSRetFlag errHandling); -extern FSStatus FSOpenFile(FSClient *pClient, FSCmdBlock *pCmd, char *path,char *mode,int *dh,FSRetFlag errHandling); -extern FSStatus FSOpenDir(FSClient *pClient, FSCmdBlock *pCmd, const char *path, int *dh, FSRetFlag errHandling); -extern FSStatus FSReadDir(FSClient *pClient, FSCmdBlock *pCmd, int dh, FSDirEntry *dir_entry, FSRetFlag errHandling); -extern FSStatus FSChangeDir(FSClient *pClient, FSCmdBlock *pCmd, const char *path, FSRetFlag errHandling); -extern FSStatus FSCloseDir(FSClient *pClient, FSCmdBlock *pCmd, int dh, FSRetFlag errHandling); -extern FSStatus FSReadFile(FSClient *pClient, FSCmdBlock *pCmd, void *buffer, int size, int count, int fd, int flag, int error); -extern FSStatus FSSetPosFile(FSClient *pClient, FSCmdBlock *pCmd, int fd, int pos, int error); -extern FSStatus FSCloseFile (FSClient *pClient, FSCmdBlock *pCmd, int fd, int error); -extern FSStatus FSMakeDir(FSClient *pClient, FSCmdBlock *pCmd,const char *path, FSRetFlag errHandling); -extern FSStatus FSRemove(FSClient *pClient, FSCmdBlock *pCmd, const char *path, FSRetFlag errHandling); -extern FSStatus FSRollbackQuota(FSClient *pClient, FSCmdBlock *pCmd, const char *path, FSRetFlag errHandling); -extern void OSDynLoad_Acquire (char* rpl, unsigned int *handle); -extern void OSDynLoad_FindExport (unsigned int handle, int isdata, char *symbol, void *address); -extern void _Exit(); - -extern void socket_lib_init(); -extern int socket(int domain, int type, int protocol); -extern int socketclose(int socket); -extern int connect(int socket, void *addr, int addrlen); -extern int send(int socket, const void *buffer, int size, int flags); -extern int recv(int socket, void *buffer, int size, int flags); - -extern int __os_snprintf(char* s, int n, const char * format, ...); - -int saviine_readdir(int sock, char * path,char * resultname, int * resulttype,int *filesize); -int injectFiles(void *pClient, void *pCmd, char * path,char * relativepath, char * basepath, char * pBuffer, int buffer_size, int error); -void doFlushOrRollback(void *pClient,void *pCmd,int result,char *savepath); -void injectSaveData(void *pClient, void *pCmd,long persistentID,int error); -void dumpSavaData(void *pClient, void *pCmd,long persistentID,int error); -long getPesistentID(unsigned char * slotno); -void init_Save(unsigned char slotNo); -int doInjectForFile(void * pClient, void * pCmd,int handle,char * filepath,int filesize, char * basepath,void * pBuffer,int buf_size); -void handle_saves(void *pClient, void *pCmd,int error); -void hook(void * pClient,void * pCmd, int error); -int dump_dir(void *pClient, void *pCmd, char *path, void * pBuffer, int size,int error, int handle); -int remove_files_in_dir(void * pClient,void * pCmd, char * path, int handle); - -struct in_addr { - unsigned int s_addr; -}; -struct sockaddr_in { - short sin_family; - unsigned short sin_port; - struct in_addr sin_addr; - char sin_zero[8]; -}; - -/* OS stuff */ -extern const long long title_id; - -/* Forward declarations */ -#define MAX_CLIENT 32 -#define MASK_FD 0x0fff00ff - -struct bss_t { - int socket_fsa[MAX_CLIENT]; - void *pClient_fs[MAX_CLIENT]; - int socket_fs[MAX_CLIENT]; - char save_path[255]; - volatile int saveFolderChecked; - volatile void * on_start_hook_client; - volatile int lock; - volatile int saveinitfs; - int logsock; -}; - -#define bss_ptr (*(struct bss_t **)0x100000e4) -#define bss (*bss_ptr) - -void cafiine_connect(int *socket); -void cafiine_disconnect(int socket); -int getMode(int sock, int * result); -int cafiine_fopen(int socket, int *result, const char *path, const char *mode, int *handle); -int cafiine_send_handle(int sock, int client, const char *path, int handle); -void cafiine_send_file(int sock, char *file, int size, int fd); -int cafiine_fread(int socket, int *result, void *buffer, int size, int fd); -int cafiine_fclose(int socket, int *result, int fd, int dumpclose); -int cafiine_fsetpos(int socket, int *result, int fd, int set); -int cafiine_fgetpos(int socket, int *result, int fd, int *pos); -int cafiine_fstat(int sock, int *result, int fd, void *ptr); -int cafiine_feof(int sock, int *result, int fd); -void cafiine_send_ping(int sock, int val1, int val2); -void log_string(int sock, const char* str, char flag_byte); - -int saviine_end_injection(int sock); -int saviine_start_injection(int sock, long persistentID,int * mask); -int saviine_start_dump(int sock, long persistentID,int * mask); -int saviine_end_dump(int sock); \ No newline at end of file diff --git a/saviine/client/saviine532.ld b/saviine/client/saviine532.ld deleted file mode 100644 index e0e33a4..0000000 --- a/saviine/client/saviine532.ld +++ /dev/null @@ -1,90 +0,0 @@ -OUTPUT(saviine532.elf); - -SECTIONS { - .text 0x011e0000 : { - server_ip = .; - . = . + 4; - *(.text._start); - *(.text*); - *(.magicptr*); - } - .magic : { - *(.magic*); - } - .rodata : { - *(.rodata*); - } - /DISCARD/ : { - *(*); - } -} - -/* FSA methods */ -PROVIDE(FSAInit = 0x10608ac); -PROVIDE(FSAShutdown = 0x1060974); -PROVIDE(FSAAddClient = 0x106546c); -PROVIDE(FSADelClient = 0x1060aa4); -PROVIDE(FSAOpenFile = 0x10621f8); - -/*FE3C00*/ -/* FS methods */ -PROVIDE(FSInit = 0x10683c8); -PROVIDE(FSShutdown = 0x1068538); -PROVIDE(FSAddClientEx = 0x10685fc); -PROVIDE(FSAddClient = 0x010689fc); -PROVIDE(FSDelClient = 0x1068a08); -PROVIDE(FSOpenFile = 0x106ef7c); -PROVIDE(FSOpenFileAsync = 0x0106a434); -PROVIDE(FSInitCmdBlock = 0x01068c54); -PROVIDE(FSMakeDir = 0x0106f8e0); -PROVIDE(FSCloseFile = 0x106f088); -PROVIDE(FSReadFile = 0x106f108); -PROVIDE(FSReadFileWithPos = 0x106f194); -PROVIDE(FSGetPosFile = 0x106f4c0); -PROVIDE(FSSetPosFile = 0x106f530); -PROVIDE(FSGetStatFile = 0x106f5a0); -PROVIDE(FSIsEof = 0x106f610); -PROVIDE(FSWriteFile = 0x106F228); -PROVIDE(FSFlushQuota = 0x106FAC8); -PROVIDE(FSRollbackQuota = 0x106FC48); -PROVIDE(_Exit = 0x101CD70); - -/* */ -PROVIDE(FSGetStat = 0x0106fdc8); -PROVIDE(FSGetStatAsync = 0x0106bff4); -PROVIDE(FSOpenFileAsync = 0x0106a434); - -PROVIDE(FSOpenDir = 0x0106f690); -PROVIDE(FSReadDir = 0x0106f780); -PROVIDE(FSCloseDir = 0x0106f700); -PROVIDE(FSChangeDir = 0x0106eefc); -PROVIDE(FSCloseDir = 0x0106f700); -PROVIDE(FSRemove = 0x0106F960); - -/* GX2 methods */ -PROVIDE(GX2WaitForVsync = 0x1151964); - -/* Socket methods */ -PROVIDE(socket_lib_init = 0x10c02f4); -PROVIDE(socket = 0x10c21c8); -PROVIDE(socketclose = 0x10c2314); -PROVIDE(connect = 0x10c0828); -PROVIDE(send = 0x10c16ac); -PROVIDE(recv = 0x10c0aec); - -/* Standard library methods */ -PROVIDE(memcpy = 0x1035a68); -PROVIDE(memset = 0x1035a54); -PROVIDE(MEMAllocFromDefaultHeapEx = 0x1004e9c0); -PROVIDE(MEMFreeToDefaultHeap = 0x100b487c); -PROVIDE(MEMAllocFromDefaultHeapEx = 0x1004e9c0); -PROVIDE(MEMAllocFromDefaultHeap = 0x100b4878); -PROVIDE(MEMFreeToDefaultHeap = 0x100b487c); - -/* OS data */ -PROVIDE(title_id = 0x100136D0); - -/* OS methods */ -PROVIDE(__os_snprintf = 0x102f09c); -PROVIDE(OSDynLoad_FindExport = 0x102b790); -PROVIDE(OSDynLoad_Acquire = 0x102a31c); \ No newline at end of file diff --git a/saviine/common/common.h b/saviine/common/common.h deleted file mode 100644 index 4327bbf..0000000 --- a/saviine/common/common.h +++ /dev/null @@ -1,45 +0,0 @@ -#ifndef COMMON_H -#define COMMON_H - -/* DATA_ADDRESS : address where flags start */ -#define DATA_ADDR ((void *)0x011e3800) -#define BOUNCE_FLAG_ADDR (DATA_ADDR - 0x04) // bounce flag -#define IS_ACTIVE_ADDR (DATA_ADDR - 0x08) // is replacement active -#define RPL_REPLACE_ADDR (DATA_ADDR - 0x0C) // is it a new rpl to add -#define RPL_ENTRY_INDEX_ADDR (DATA_ADDR - 0x10) // entry index of the rpx in our table - -/* RPX Address : where the rpx is copied or retrieve, depends if we dump or replace */ -/* Note : from phys 0x30789C5D to 0x31E20000, memory seems empty (space reserved for root.rpx) which let us approximatly 22.5mB of memory free to put the rpx and additional rpls */ -#define MEM_BASE ((void*)0xC0800000) -#define MEM_SIZE ((void*)(MEM_BASE - 0x04)) -#define MEM_OFFSET ((void*)(MEM_BASE - 0x08)) -#define MEM_PART ((void*)(MEM_BASE - 0x0C)) -#define RPX_NAME ((void*)(MEM_BASE - 0x10)) -#define RPX_NAME_PENDING ((void*)(MEM_BASE - 0x14)) -#define GAME_DIR_NAME ((void*)(MEM_BASE - 0x100)) - -/* RPX_RPL_ARRAY contains an array of multiple rpl/rpl structures: */ -/* Note : The first entry is always the one referencing the rpx (cf. struct s_rpx_rpl) */ -#define RPX_RPL_ARRAY ((void*)0xC07A0000) -#define RPX_RPL_ENTRY_COUNT ((void*)(RPX_RPL_ARRAY - 0x04)) - -/* RPX Name : from which app/game, our rpx is launched */ -#define RPX_CHECK_NAME 0x63726F73 // 0xEFE00000 contains the rpx name, 0x63726F73 => cros (for smash brox : cross_f.rpx) - -/* Union for rpx name */ -typedef union uRpxName { - int name_full; - char name[4]; -} uRpxName; - -/* Struct used to organize rpx/rpl data in memory */ -typedef struct s_rpx_rpl -{ - int address; - int size; - int offset; - char name[64]; // TODO: maybe set the exact same size than dir_entry->name -} s_rpx_rpl; - -#endif /* COMMON_H */ - diff --git a/saviine/common/fs_defs.h b/saviine/common/fs_defs.h deleted file mode 100644 index f78a3c3..0000000 --- a/saviine/common/fs_defs.h +++ /dev/null @@ -1,85 +0,0 @@ -#ifndef FS_DEFS_H -#define FS_DEFS_H - -#include "../common/types.h" - -/* FS defines and types */ -#define FS_MAX_LOCALPATH_SIZE 511 -#define FS_MAX_MOUNTPATH_SIZE 128 -#define FS_MAX_FULLPATH_SIZE (FS_MAX_LOCALPATH_SIZE + FS_MAX_MOUNTPATH_SIZE) -#define FS_MAX_ARGPATH_SIZE FS_MAX_FULLPATH_SIZE - -#define FS_STATUS_OK 0 -#define FS_STATUS_EXISTS -5 -#define FS_STATUS_STORAGE_FULL -12 -#define FS_STATUS_JOURNAL_FULL -13 - - -#define FS_RET_UNSUPPORTED_CMD 0x0400 -#define FS_RET_NO_ERROR 0x0000 -#define FS_RET_ALL_ERROR (uint)(-1) - - -/* directory entry stat flag */ -#define FS_STAT_ATTRIBUTES_SIZE (48) /* size of FS-specific attributes field */ -#define FS_STAT_FLAG_IS_DIRECTORY 0x80000000 /* entry is directory */ - -/* max length of file/dir name */ -#define FS_MAX_ENTNAME_SIZE 256 - -/* typedef FSStatus, FSRetFlag*/ -typedef int FSStatus; -typedef uint FSRetFlag; -typedef uint FSFlag; - -/* FS Mount */ -typedef enum -{ - FS_SOURCETYPE_EXTERNAL = 0, // Manual mounted external device - FS_SOURCETYPE_HFIO, // Host file IO - FS_SOURCETYPE_MAX -} FSSourceType; - -typedef struct -{ - FSSourceType type; - char path[FS_MAX_ARGPATH_SIZE]; -} FSMountSource; - -/* FS Client context buffer */ -typedef struct -{ - uint8_t buffer[5888]; -} FSClient; - -/* FS command block buffer */ -typedef struct -{ - uint8_t buffer[2688]; -} FSCmdBlock; - -/* File/Dir status */ -typedef struct -{ - uint flag; - uint permission; - uint owner_id; - uint group_id; - uint size; - uint alloc_size; - uint64_t quota_size; - uint ent_id; - uint64_t ctime; - uint64_t mtime; - uint8_t attributes[FS_STAT_ATTRIBUTES_SIZE]; -} __attribute__((packed)) FSStat; - -/* Directory entry */ -typedef struct -{ - FSStat stat; - char name[FS_MAX_ENTNAME_SIZE]; -} FSDirEntry; - -#endif /* FS_DEFS_H */ - diff --git a/saviine/common/types.h b/saviine/common/types.h deleted file mode 100644 index eefac9b..0000000 --- a/saviine/common/types.h +++ /dev/null @@ -1,22 +0,0 @@ -#ifndef TYPES_H -#define TYPES_H - -/* Define base types */ -typedef unsigned long long uint64_t; -typedef long long int64_t; -typedef unsigned int uint32_t; -typedef unsigned int uint; -typedef int int32_t; -typedef unsigned short uint16_t; -typedef short int16_t; -typedef unsigned char uint8_t; -typedef char int8_t; - -typedef _Bool bool; -#define true 1 -#define false 0 -#define null 0 - - -#endif /* TYPES_H */ - diff --git a/saviine/installer/Makefile b/saviine/installer/Makefile deleted file mode 100644 index ecc2dc5..0000000 --- a/saviine/installer/Makefile +++ /dev/null @@ -1,31 +0,0 @@ -CC=powerpc-eabi-gcc -CFLAGS=-std=gnu99 -nostdinc -fno-builtin -c -LD=powerpc-eabi-ld -LDFLAGS=-Ttext 1800000 --oformat binary -project := . -root:=$(CURDIR) -build := $(root)/bin -libs := $(root)/../../libwiiu/bin -www :=$(root)/../../www -framework:=$(root)/../../framework - -all: clean setup client main532 - -setup: - mkdir -p $(root)/bin/ - -client: - cd ../client/ && make - -main532: - $(CC) $(CFLAGS) -DVER=532 $(project)/saviine.c - #-Wa,-a,-ad - cp -r $(root)/*.o $(build) - rm $(root)/*.o - #$(LD) $(LDFLAGS) -o $(build)/code532.bin $(build)/saviine.o $(libs)/532/*.o `find $(build) -name "*.o" ! -name "saviine.o"` - $(LD) $(LDFLAGS) -o $(build)/code532.bin $(build)/saviine.o `find $(build) -name "*.o" ! -name "saviine.o"` -L"$(DEVKITPPC)/lib/gcc/powerpc-eabi/4.8.2" -lgcc - -clean: - make -C ../client/ clean - rm -rf $(build)/* - diff --git a/saviine/installer/bin/code532.bin b/saviine/installer/bin/code532.bin deleted file mode 100644 index e4a58b2..0000000 Binary files a/saviine/installer/bin/code532.bin and /dev/null differ diff --git a/saviine/installer/bin/saviine.o b/saviine/installer/bin/saviine.o deleted file mode 100644 index a39d907..0000000 Binary files a/saviine/installer/bin/saviine.o and /dev/null differ diff --git a/saviine/installer/elf_abi.h b/saviine/installer/elf_abi.h deleted file mode 100644 index 4d9c796..0000000 --- a/saviine/installer/elf_abi.h +++ /dev/null @@ -1,591 +0,0 @@ -/* - * Copyright (c) 1995, 1996, 2001, 2002 - * Erik Theisen. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/* - * This is the ELF ABI header file - * formerly known as "elf_abi.h". - */ - -#ifndef _ELF_ABI_H -#define _ELF_ABI_H - -/* - * This version doesn't work for 64-bit ABIs - Erik. - */ - -/* - * These typedefs need to be handled better. - */ -typedef unsigned int Elf32_Addr; /* Unsigned program address */ -typedef unsigned int Elf32_Off; /* Unsigned file offset */ -typedef signed int Elf32_Sword; /* Signed large integer */ -typedef unsigned int Elf32_Word; /* Unsigned large integer */ -typedef unsigned short Elf32_Half; /* Unsigned medium integer */ - -/* e_ident[] identification indexes */ -#define EI_MAG0 0 /* file ID */ -#define EI_MAG1 1 /* file ID */ -#define EI_MAG2 2 /* file ID */ -#define EI_MAG3 3 /* file ID */ -#define EI_CLASS 4 /* file class */ -#define EI_DATA 5 /* data encoding */ -#define EI_VERSION 6 /* ELF header version */ -#define EI_OSABI 7 /* OS/ABI specific ELF extensions */ -#define EI_ABIVERSION 8 /* ABI target version */ -#define EI_PAD 9 /* start of pad bytes */ -#define EI_NIDENT 16 /* Size of e_ident[] */ - -/* e_ident[] magic number */ -#define ELFMAG0 0x7f /* e_ident[EI_MAG0] */ -#define ELFMAG1 'E' /* e_ident[EI_MAG1] */ -#define ELFMAG2 'L' /* e_ident[EI_MAG2] */ -#define ELFMAG3 'F' /* e_ident[EI_MAG3] */ -#define ELFMAG "\177ELF" /* magic */ -#define SELFMAG 4 /* size of magic */ - -/* e_ident[] file class */ -#define ELFCLASSNONE 0 /* invalid */ -#define ELFCLASsigned int 1 /* 32-bit objs */ -#define ELFCLASS64 2 /* 64-bit objs */ -#define ELFCLASSNUM 3 /* number of classes */ - -/* e_ident[] data encoding */ -#define ELFDATANONE 0 /* invalid */ -#define ELFDATA2LSB 1 /* Little-Endian */ -#define ELFDATA2MSB 2 /* Big-Endian */ -#define ELFDATANUM 3 /* number of data encode defines */ - -/* e_ident[] OS/ABI specific ELF extensions */ -#define ELFOSABI_NONE 0 /* No extension specified */ -#define ELFOSABI_HPUX 1 /* Hewlett-Packard HP-UX */ -#define ELFOSABI_NETBSD 2 /* NetBSD */ -#define ELFOSABI_LINUX 3 /* Linux */ -#define ELFOSABI_SOLARIS 6 /* Sun Solaris */ -#define ELFOSABI_AIX 7 /* AIX */ -#define ELFOSABI_IRIX 8 /* IRIX */ -#define ELFOSABI_FREEBSD 9 /* FreeBSD */ -#define ELFOSABI_TRU64 10 /* Compaq TRU64 UNIX */ -#define ELFOSABI_MODESTO 11 /* Novell Modesto */ -#define ELFOSABI_OPENBSD 12 /* OpenBSD */ -/* 64-255 Architecture-specific value range */ - -/* e_ident[] ABI Version */ -#define ELFABIVERSION 0 - -/* e_ident */ -#define IS_ELF(ehdr) ((ehdr).e_ident[EI_MAG0] == ELFMAG0 && \ - (ehdr).e_ident[EI_MAG1] == ELFMAG1 && \ - (ehdr).e_ident[EI_MAG2] == ELFMAG2 && \ - (ehdr).e_ident[EI_MAG3] == ELFMAG3) - -/* ELF Header */ -typedef struct elfhdr{ - unsigned char e_ident[EI_NIDENT]; /* ELF Identification */ - Elf32_Half e_type; /* object file type */ - Elf32_Half e_machine; /* machine */ - Elf32_Word e_version; /* object file version */ - Elf32_Addr e_entry; /* virtual entry point */ - Elf32_Off e_phoff; /* program header table offset */ - Elf32_Off e_shoff; /* section header table offset */ - Elf32_Word e_flags; /* processor-specific flags */ - Elf32_Half e_ehsize; /* ELF header size */ - Elf32_Half e_phentsize; /* program header entry size */ - Elf32_Half e_phnum; /* number of program header entries */ - Elf32_Half e_shentsize; /* section header entry size */ - Elf32_Half e_shnum; /* number of section header entries */ - Elf32_Half e_shstrndx; /* section header table's "section - header string table" entry offset */ -} Elf32_Ehdr; - -/* e_type */ -#define ET_NONE 0 /* No file type */ -#define ET_REL 1 /* relocatable file */ -#define ET_EXEC 2 /* executable file */ -#define ET_DYN 3 /* shared object file */ -#define ET_CORE 4 /* core file */ -#define ET_NUM 5 /* number of types */ -#define ET_LOOS 0xfe00 /* reserved range for operating */ -#define ET_HIOS 0xfeff /* system specific e_type */ -#define ET_LOPROC 0xff00 /* reserved range for processor */ -#define ET_HIPROC 0xffff /* specific e_type */ - -/* e_machine */ -#define EM_NONE 0 /* No Machine */ -#define EM_M32 1 /* AT&T WE 32100 */ -#define EM_SPARC 2 /* SPARC */ -#define EM_386 3 /* Intel 80386 */ -#define EM_68K 4 /* Motorola 68000 */ -#define EM_88K 5 /* Motorola 88000 */ -#if 0 -#define EM_486 6 /* RESERVED - was Intel 80486 */ -#endif -#define EM_860 7 /* Intel 80860 */ -#define EM_MIPS 8 /* MIPS R3000 Big-Endian only */ -#define EM_S370 9 /* IBM System/370 Processor */ -#define EM_MIPS_RS4_BE 10 /* MIPS R4000 Big-Endian */ -#if 0 -#define EM_SPARC64 11 /* RESERVED - was SPARC v9 - 64-bit unoffical */ -#endif -/* RESERVED 11-14 for future use */ -#define EM_PARISC 15 /* HPPA */ -/* RESERVED 16 for future use */ -#define EM_VPP500 17 /* Fujitsu VPP500 */ -#define EM_SPARC32PLUS 18 /* Enhanced instruction set SPARC */ -#define EM_960 19 /* Intel 80960 */ -#define EM_PPC 20 /* PowerPC */ -#define EM_PPC64 21 /* 64-bit PowerPC */ -#define EM_S390 22 /* IBM System/390 Processor */ -/* RESERVED 23-35 for future use */ -#define EM_V800 36 /* NEC V800 */ -#define EM_FR20 37 /* Fujitsu FR20 */ -#define EM_RH32 38 /* TRW RH-32 */ -#define EM_RCE 39 /* Motorola RCE */ -#define EM_ARM 40 /* Advanced Risc Machines ARM */ -#define EM_ALPHA 41 /* Digital Alpha */ -#define EM_SH 42 /* Hitachi SH */ -#define EM_SPARCV9 43 /* SPARC Version 9 */ -#define EM_TRICORE 44 /* Siemens TriCore embedded processor */ -#define EM_ARC 45 /* Argonaut RISC Core */ -#define EM_H8_300 46 /* Hitachi H8/300 */ -#define EM_H8_300H 47 /* Hitachi H8/300H */ -#define EM_H8S 48 /* Hitachi H8S */ -#define EM_H8_500 49 /* Hitachi H8/500 */ -#define EM_IA_64 50 /* Intel Merced */ -#define EM_MIPS_X 51 /* Stanford MIPS-X */ -#define EM_COLDFIRE 52 /* Motorola Coldfire */ -#define EM_68HC12 53 /* Motorola M68HC12 */ -#define EM_MMA 54 /* Fujitsu MMA Multimedia Accelerator*/ -#define EM_PCP 55 /* Siemens PCP */ -#define EM_NCPU 56 /* Sony nCPU embeeded RISC */ -#define EM_NDR1 57 /* Denso NDR1 microprocessor */ -#define EM_STARCORE 58 /* Motorola Start*Core processor */ -#define EM_ME16 59 /* Toyota ME16 processor */ -#define EM_ST100 60 /* STMicroelectronic ST100 processor */ -#define EM_TINYJ 61 /* Advanced Logic Corp. Tinyj emb.fam*/ -#define EM_X86_64 62 /* AMD x86-64 */ -#define EM_PDSP 63 /* Sony DSP Processor */ -/* RESERVED 64,65 for future use */ -#define EM_FX66 66 /* Siemens FX66 microcontroller */ -#define EM_ST9PLUS 67 /* STMicroelectronics ST9+ 8/16 mc */ -#define EM_ST7 68 /* STmicroelectronics ST7 8 bit mc */ -#define EM_68HC16 69 /* Motorola MC68HC16 microcontroller */ -#define EM_68HC11 70 /* Motorola MC68HC11 microcontroller */ -#define EM_68HC08 71 /* Motorola MC68HC08 microcontroller */ -#define EM_68HC05 72 /* Motorola MC68HC05 microcontroller */ -#define EM_SVX 73 /* Silicon Graphics SVx */ -#define EM_ST19 74 /* STMicroelectronics ST19 8 bit mc */ -#define EM_VAX 75 /* Digital VAX */ -#define EM_CHRIS 76 /* Axis Communications embedded proc. */ -#define EM_JAVELIN 77 /* Infineon Technologies emb. proc. */ -#define EM_FIREPATH 78 /* Element 14 64-bit DSP Processor */ -#define EM_ZSP 79 /* LSI Logic 16-bit DSP Processor */ -#define EM_MMIX 80 /* Donald Knuth's edu 64-bit proc. */ -#define EM_HUANY 81 /* Harvard University mach-indep objs */ -#define EM_PRISM 82 /* SiTera Prism */ -#define EM_AVR 83 /* Atmel AVR 8-bit microcontroller */ -#define EM_FR30 84 /* Fujitsu FR30 */ -#define EM_D10V 85 /* Mitsubishi DV10V */ -#define EM_D30V 86 /* Mitsubishi DV30V */ -#define EM_V850 87 /* NEC v850 */ -#define EM_M32R 88 /* Mitsubishi M32R */ -#define EM_MN10300 89 /* Matsushita MN10200 */ -#define EM_MN10200 90 /* Matsushita MN10200 */ -#define EM_PJ 91 /* picoJava */ -#define EM_NUM 92 /* number of machine types */ - -/* Version */ -#define EV_NONE 0 /* Invalid */ -#define EV_CURRENT 1 /* Current */ -#define EV_NUM 2 /* number of versions */ - -/* Section Header */ -typedef struct { - Elf32_Word sh_name; /* name - index into section header - string table section */ - Elf32_Word sh_type; /* type */ - Elf32_Word sh_flags; /* flags */ - Elf32_Addr sh_addr; /* address */ - Elf32_Off sh_offset; /* file offset */ - Elf32_Word sh_size; /* section size */ - Elf32_Word sh_link; /* section header table index link */ - Elf32_Word sh_info; /* extra information */ - Elf32_Word sh_addralign; /* address alignment */ - Elf32_Word sh_entsize; /* section entry size */ -} Elf32_Shdr; - -/* Special Section Indexes */ -#define SHN_UNDEF 0 /* undefined */ -#define SHN_LORESERVE 0xff00 /* lower bounds of reserved indexes */ -#define SHN_LOPROC 0xff00 /* reserved range for processor */ -#define SHN_HIPROC 0xff1f /* specific section indexes */ -#define SHN_LOOS 0xff20 /* reserved range for operating */ -#define SHN_HIOS 0xff3f /* specific semantics */ -#define SHN_ABS 0xfff1 /* absolute value */ -#define SHN_COMMON 0xfff2 /* common symbol */ -#define SHN_XINDEX 0xffff /* Index is an extra table */ -#define SHN_HIRESERVE 0xffff /* upper bounds of reserved indexes */ - -/* sh_type */ -#define SHT_NULL 0 /* inactive */ -#define SHT_PROGBITS 1 /* program defined information */ -#define SHT_SYMTAB 2 /* symbol table section */ -#define SHT_STRTAB 3 /* string table section */ -#define SHT_RELA 4 /* relocation section with addends*/ -#define SHT_HASH 5 /* symbol hash table section */ -#define SHT_DYNAMIC 6 /* dynamic section */ -#define SHT_NOTE 7 /* note section */ -#define SHT_NOBITS 8 /* no space section */ -#define SHT_REL 9 /* relation section without addends */ -#define SHT_SHLIB 10 /* reserved - purpose unknown */ -#define SHT_DYNSYM 11 /* dynamic symbol table section */ -#define SHT_INIT_ARRAY 14 /* Array of constructors */ -#define SHT_FINI_ARRAY 15 /* Array of destructors */ -#define SHT_PREINIT_ARRAY 16 /* Array of pre-constructors */ -#define SHT_GROUP 17 /* Section group */ -#define SHT_SYMTAB_SHNDX 18 /* Extended section indeces */ -#define SHT_NUM 19 /* number of section types */ -#define SHT_LOOS 0x60000000 /* Start OS-specific */ -#define SHT_HIOS 0x6fffffff /* End OS-specific */ -#define SHT_LOPROC 0x70000000 /* reserved range for processor */ -#define SHT_HIPROC 0x7fffffff /* specific section header types */ -#define SHT_LOUSER 0x80000000 /* reserved range for application */ -#define SHT_HIUSER 0xffffffff /* specific indexes */ - -/* Section names */ -#define ELF_BSS ".bss" /* uninitialized data */ -#define ELF_COMMENT ".comment" /* version control information */ -#define ELF_DATA ".data" /* initialized data */ -#define ELF_DATA1 ".data1" /* initialized data */ -#define ELF_DEBUG ".debug" /* debug */ -#define ELF_DYNAMIC ".dynamic" /* dynamic linking information */ -#define ELF_DYNSTR ".dynstr" /* dynamic string table */ -#define ELF_DYNSYM ".dynsym" /* dynamic symbol table */ -#define ELF_FINI ".fini" /* termination code */ -#define ELF_FINI_ARRAY ".fini_array" /* Array of destructors */ -#define ELF_GOT ".got" /* global offset table */ -#define ELF_HASH ".hash" /* symbol hash table */ -#define ELF_INIT ".init" /* initialization code */ -#define ELF_INIT_ARRAY ".init_array" /* Array of constuctors */ -#define ELF_INTERP ".interp" /* Pathname of program interpreter */ -#define ELF_LINE ".line" /* Symbolic line numnber information */ -#define ELF_NOTE ".note" /* Contains note section */ -#define ELF_PLT ".plt" /* Procedure linkage table */ -#define ELF_PREINIT_ARRAY ".preinit_array" /* Array of pre-constructors */ -#define ELF_REL_DATA ".rel.data" /* relocation data */ -#define ELF_REL_FINI ".rel.fini" /* relocation termination code */ -#define ELF_REL_INIT ".rel.init" /* relocation initialization code */ -#define ELF_REL_DYN ".rel.dyn" /* relocaltion dynamic link info */ -#define ELF_REL_RODATA ".rel.rodata" /* relocation read-only data */ -#define ELF_REL_TEXT ".rel.text" /* relocation code */ -#define ELF_RODATA ".rodata" /* read-only data */ -#define ELF_RODATA1 ".rodata1" /* read-only data */ -#define ELF_SHSTRTAB ".shstrtab" /* section header string table */ -#define ELF_STRTAB ".strtab" /* string table */ -#define ELF_SYMTAB ".symtab" /* symbol table */ -#define ELF_SYMTAB_SHNDX ".symtab_shndx"/* symbol table section index */ -#define ELF_TBSS ".tbss" /* thread local uninit data */ -#define ELF_TDATA ".tdata" /* thread local init data */ -#define ELF_TDATA1 ".tdata1" /* thread local init data */ -#define ELF_TEXT ".text" /* code */ - -/* Section Attribute Flags - sh_flags */ -#define SHF_WRITE 0x1 /* Writable */ -#define SHF_ALLOC 0x2 /* occupies memory */ -#define SHF_EXECINSTR 0x4 /* executable */ -#define SHF_MERGE 0x10 /* Might be merged */ -#define SHF_STRINGS 0x20 /* Contains NULL terminated strings */ -#define SHF_INFO_LINK 0x40 /* sh_info contains SHT index */ -#define SHF_LINK_ORDER 0x80 /* Preserve order after combining*/ -#define SHF_OS_NONCONFORMING 0x100 /* Non-standard OS specific handling */ -#define SHF_GROUP 0x200 /* Member of section group */ -#define SHF_TLS 0x400 /* Thread local storage */ -#define SHF_MASKOS 0x0ff00000 /* OS specific */ -#define SHF_MASKPROC 0xf0000000 /* reserved bits for processor */ - /* specific section attributes */ - -/* Section Group Flags */ -#define GRP_COMDAT 0x1 /* COMDAT group */ -#define GRP_MASKOS 0x0ff00000 /* Mask OS specific flags */ -#define GRP_MASKPROC 0xf0000000 /* Mask processor specific flags */ - -/* Symbol Table Entry */ -typedef struct elf32_sym { - Elf32_Word st_name; /* name - index into string table */ - Elf32_Addr st_value; /* symbol value */ - Elf32_Word st_size; /* symbol size */ - unsigned char st_info; /* type and binding */ - unsigned char st_other; /* 0 - no defined meaning */ - Elf32_Half st_shndx; /* section header index */ -} Elf32_Sym; - -/* Symbol table index */ -#define STN_UNDEF 0 /* undefined */ - -/* Extract symbol info - st_info */ -#define ELF32_ST_BIND(x) ((x) >> 4) -#define ELF32_ST_TYPE(x) (((unsigned int) x) & 0xf) -#define ELF32_ST_INFO(b,t) (((b) << 4) + ((t) & 0xf)) -#define ELF32_ST_VISIBILITY(x) ((x) & 0x3) - -/* Symbol Binding - ELF32_ST_BIND - st_info */ -#define STB_LOCAL 0 /* Local symbol */ -#define STB_GLOBAL 1 /* Global symbol */ -#define STB_WEAK 2 /* like global - lower precedence */ -#define STB_NUM 3 /* number of symbol bindings */ -#define STB_LOOS 10 /* reserved range for operating */ -#define STB_HIOS 12 /* system specific symbol bindings */ -#define STB_LOPROC 13 /* reserved range for processor */ -#define STB_HIPROC 15 /* specific symbol bindings */ - -/* Symbol type - ELF32_ST_TYPE - st_info */ -#define STT_NOTYPE 0 /* not specified */ -#define STT_OBJECT 1 /* data object */ -#define STT_FUNC 2 /* function */ -#define STT_SECTION 3 /* section */ -#define STT_FILE 4 /* file */ -#define STT_NUM 5 /* number of symbol types */ -#define STT_TLS 6 /* Thread local storage symbol */ -#define STT_LOOS 10 /* reserved range for operating */ -#define STT_HIOS 12 /* system specific symbol types */ -#define STT_LOPROC 13 /* reserved range for processor */ -#define STT_HIPROC 15 /* specific symbol types */ - -/* Symbol visibility - ELF32_ST_VISIBILITY - st_other */ -#define STV_DEFAULT 0 /* Normal visibility rules */ -#define STV_INTERNAL 1 /* Processor specific hidden class */ -#define STV_HIDDEN 2 /* Symbol unavailable in other mods */ -#define STV_PROTECTED 3 /* Not preemptible, not exported */ - - -/* Relocation entry with implicit addend */ -typedef struct -{ - Elf32_Addr r_offset; /* offset of relocation */ - Elf32_Word r_info; /* symbol table index and type */ -} Elf32_Rel; - -/* Relocation entry with explicit addend */ -typedef struct -{ - Elf32_Addr r_offset; /* offset of relocation */ - Elf32_Word r_info; /* symbol table index and type */ - Elf32_Sword r_addend; -} Elf32_Rela; - -/* Extract relocation info - r_info */ -#define ELF32_R_SYM(i) ((i) >> 8) -#define ELF32_R_TYPE(i) ((unsigned char) (i)) -#define ELF32_R_INFO(s,t) (((s) << 8) + (unsigned char)(t)) - -/* Program Header */ -typedef struct { - Elf32_Word p_type; /* segment type */ - Elf32_Off p_offset; /* segment offset */ - Elf32_Addr p_vaddr; /* virtual address of segment */ - Elf32_Addr p_paddr; /* physical address - ignored? */ - Elf32_Word p_filesz; /* number of bytes in file for seg. */ - Elf32_Word p_memsz; /* number of bytes in mem. for seg. */ - Elf32_Word p_flags; /* flags */ - Elf32_Word p_align; /* memory alignment */ -} Elf32_Phdr; - -/* Segment types - p_type */ -#define PT_NULL 0 /* unused */ -#define PT_LOAD 1 /* loadable segment */ -#define PT_DYNAMIC 2 /* dynamic linking section */ -#define PT_INTERP 3 /* the RTLD */ -#define PT_NOTE 4 /* auxiliary information */ -#define PT_SHLIB 5 /* reserved - purpose undefined */ -#define PT_PHDR 6 /* program header */ -#define PT_TLS 7 /* Thread local storage template */ -#define PT_NUM 8 /* Number of segment types */ -#define PT_LOOS 0x60000000 /* reserved range for operating */ -#define PT_HIOS 0x6fffffff /* system specific segment types */ -#define PT_LOPROC 0x70000000 /* reserved range for processor */ -#define PT_HIPROC 0x7fffffff /* specific segment types */ - -/* Segment flags - p_flags */ -#define PF_X 0x1 /* Executable */ -#define PF_W 0x2 /* Writable */ -#define PF_R 0x4 /* Readable */ -#define PF_MASKOS 0x0ff00000 /* OS specific segment flags */ -#define PF_MASKPROC 0xf0000000 /* reserved bits for processor */ - /* specific segment flags */ -/* Dynamic structure */ -typedef struct -{ - Elf32_Sword d_tag; /* controls meaning of d_val */ - union - { - Elf32_Word d_val; /* Multiple meanings - see d_tag */ - Elf32_Addr d_ptr; /* program virtual address */ - } d_un; -} Elf32_Dyn; - -extern Elf32_Dyn _DYNAMIC[]; - -/* Dynamic Array Tags - d_tag */ -#define DT_NULL 0 /* marks end of _DYNAMIC array */ -#define DT_NEEDED 1 /* string table offset of needed lib */ -#define DT_PLTRELSZ 2 /* size of relocation entries in PLT */ -#define DT_PLTGOT 3 /* address PLT/GOT */ -#define DT_HASH 4 /* address of symbol hash table */ -#define DT_STRTAB 5 /* address of string table */ -#define DT_SYMTAB 6 /* address of symbol table */ -#define DT_RELA 7 /* address of relocation table */ -#define DT_RELASZ 8 /* size of relocation table */ -#define DT_RELAENT 9 /* size of relocation entry */ -#define DT_STRSZ 10 /* size of string table */ -#define DT_SYMENT 11 /* size of symbol table entry */ -#define DT_INIT 12 /* address of initialization func. */ -#define DT_FINI 13 /* address of termination function */ -#define DT_SONAME 14 /* string table offset of shared obj */ -#define DT_RPATH 15 /* string table offset of library - search path */ -#define DT_SYMBOLIC 16 /* start sym search in shared obj. */ -#define DT_REL 17 /* address of rel. tbl. w addends */ -#define DT_RELSZ 18 /* size of DT_REL relocation table */ -#define DT_RELENT 19 /* size of DT_REL relocation entry */ -#define DT_PLTREL 20 /* PLT referenced relocation entry */ -#define DT_DEBUG 21 /* bugger */ -#define DT_TEXTREL 22 /* Allow rel. mod. to unwritable seg */ -#define DT_JMPREL 23 /* add. of PLT's relocation entries */ -#define DT_BIND_NOW 24 /* Process relocations of object */ -#define DT_INIT_ARRAY 25 /* Array with addresses of init fct */ -#define DT_FINI_ARRAY 26 /* Array with addresses of fini fct */ -#define DT_INIT_ARRAYSZ 27 /* Size in bytes of DT_INIT_ARRAY */ -#define DT_FINI_ARRAYSZ 28 /* Size in bytes of DT_FINI_ARRAY */ -#define DT_RUNPATH 29 /* Library search path */ -#define DT_FLAGS 30 /* Flags for the object being loaded */ -#define DT_ENCODING 32 /* Start of encoded range */ -#define DT_PREINIT_ARRAY 32 /* Array with addresses of preinit fct*/ -#define DT_PREINIT_ARRAYSZ 33 /* size in bytes of DT_PREINIT_ARRAY */ -#define DT_NUM 34 /* Number used. */ -#define DT_LOOS 0x60000000 /* reserved range for OS */ -#define DT_HIOS 0x6fffffff /* specific dynamic array tags */ -#define DT_LOPROC 0x70000000 /* reserved range for processor */ -#define DT_HIPROC 0x7fffffff /* specific dynamic array tags */ - -/* Dynamic Tag Flags - d_un.d_val */ -#define DF_ORIGIN 0x01 /* Object may use DF_ORIGIN */ -#define DF_SYMBOLIC 0x02 /* Symbol resolutions starts here */ -#define DF_TEXTREL 0x04 /* Object contains text relocations */ -#define DF_BIND_NOW 0x08 /* No lazy binding for this object */ -#define DF_STATIC_TLS 0x10 /* Static thread local storage */ - -/* Standard ELF hashing function */ -unsigned long elf_hash(const unsigned char *name); - -#define ELF_TARG_VER 1 /* The ver for which this code is intended */ - -/* - * XXX - PowerPC defines really don't belong in here, - * but we'll put them in for simplicity. - */ - -/* Values for Elf32/64_Ehdr.e_flags. */ -#define EF_PPC_EMB 0x80000000 /* PowerPC embedded flag */ - -/* Cygnus local bits below */ -#define EF_PPC_RELOCATABLE 0x00010000 /* PowerPC -mrelocatable flag*/ -#define EF_PPC_RELOCATABLE_LIB 0x00008000 /* PowerPC -mrelocatable-lib - flag */ - -/* PowerPC relocations defined by the ABIs */ -#define R_PPC_NONE 0 -#define R_PPC_ADDR32 1 /* 32bit absolute address */ -#define R_PPC_ADDR24 2 /* 26bit address, 2 bits ignored. */ -#define R_PPC_ADDR16 3 /* 16bit absolute address */ -#define R_PPC_ADDR16_LO 4 /* lower 16bit of absolute address */ -#define R_PPC_ADDR16_HI 5 /* high 16bit of absolute address */ -#define R_PPC_ADDR16_HA 6 /* adjusted high 16bit */ -#define R_PPC_ADDR14 7 /* 16bit address, 2 bits ignored */ -#define R_PPC_ADDR14_BRTAKEN 8 -#define R_PPC_ADDR14_BRNTAKEN 9 -#define R_PPC_REL24 10 /* PC relative 26 bit */ -#define R_PPC_REL14 11 /* PC relative 16 bit */ -#define R_PPC_REL14_BRTAKEN 12 -#define R_PPC_REL14_BRNTAKEN 13 -#define R_PPC_GOT16 14 -#define R_PPC_GOT16_LO 15 -#define R_PPC_GOT16_HI 16 -#define R_PPC_GOT16_HA 17 -#define R_PPC_PLTREL24 18 -#define R_PPC_COPY 19 -#define R_PPC_GLOB_DAT 20 -#define R_PPC_JMP_SLOT 21 -#define R_PPC_RELATIVE 22 -#define R_PPC_LOCAL24PC 23 -#define R_PPC_UADDR32 24 -#define R_PPC_UADDR16 25 -#define R_PPC_REL32 26 -#define R_PPC_PLT32 27 -#define R_PPC_PLTREL32 28 -#define R_PPC_PLT16_LO 29 -#define R_PPC_PLT16_HI 30 -#define R_PPC_PLT16_HA 31 -#define R_PPC_SDAREL16 32 -#define R_PPC_SECTOFF 33 -#define R_PPC_SECTOFF_LO 34 -#define R_PPC_SECTOFF_HI 35 -#define R_PPC_SECTOFF_HA 36 -/* Keep this the last entry. */ -#define R_PPC_NUM 37 - -/* The remaining relocs are from the Embedded ELF ABI, and are not - in the SVR4 ELF ABI. */ -#define R_PPC_EMB_NADDR32 101 -#define R_PPC_EMB_NADDR16 102 -#define R_PPC_EMB_NADDR16_LO 103 -#define R_PPC_EMB_NADDR16_HI 104 -#define R_PPC_EMB_NADDR16_HA 105 -#define R_PPC_EMB_SDAI16 106 -#define R_PPC_EMB_SDA2I16 107 -#define R_PPC_EMB_SDA2REL 108 -#define R_PPC_EMB_SDA21 109 /* 16 bit offset in SDA */ -#define R_PPC_EMB_MRKREF 110 -#define R_PPC_EMB_RELSEC16 111 -#define R_PPC_EMB_RELST_LO 112 -#define R_PPC_EMB_RELST_HI 113 -#define R_PPC_EMB_RELST_HA 114 -#define R_PPC_EMB_BIT_FLD 115 -#define R_PPC_EMB_RELSDA 116 /* 16 bit relative offset in SDA */ - -/* Diab tool relocations. */ -#define R_PPC_DIAB_SDA21_LO 180 /* like EMB_SDA21, but lower 16 bit */ -#define R_PPC_DIAB_SDA21_HI 181 /* like EMB_SDA21, but high 16 bit */ -#define R_PPC_DIAB_SDA21_HA 182 /* like EMB_SDA21, adjusted high 16 */ -#define R_PPC_DIAB_RELSDA_LO 183 /* like EMB_RELSDA, but lower 16 bit */ -#define R_PPC_DIAB_RELSDA_HI 184 /* like EMB_RELSDA, but high 16 bit */ -#define R_PPC_DIAB_RELSDA_HA 185 /* like EMB_RELSDA, adjusted high 16 */ - -/* This is a phony reloc to handle any old fashioned TOC16 references - that may still be in object files. */ -#define R_PPC_TOC16 255 - -#endif /* _ELF_H */ diff --git a/saviine/installer/saviine.c b/saviine/installer/saviine.c deleted file mode 100644 index 934f0ab..0000000 --- a/saviine/installer/saviine.c +++ /dev/null @@ -1,646 +0,0 @@ -#include "saviine.h" -#include "elf_abi.h" -#include "../../../../libwiiu/src/coreinit.h" -#include "../../../../libwiiu/src/vpad.h" - -#if VER == 532 - // Includes - - // Function definitions - #define _Exit ((void (*)(void))0x0101cd70) - #define OSEffectiveToPhysical ((void* (*)(const void*))0x0101f510) - #define memcpy ((void * (*)(void * dest, const void * src, int num))0x1035a6c) - #define DCFlushRange ((void (*)(const void *addr, uint length))0x1023ee8) - #define ICInvalidateRange ((void (*)(const void *addr, uint length))0x1024010) - - // Install addresses -// #define INSTALL_MENU_ADDR 0x011dd000 // where the menu is copied in memory -// #define INSTALL_LOADER_ADDR 0x011df000 // where the loader code is copied in memory - #define INSTALL_FS_ADDR 0x011e0000 // where the fs functions are copied in memory - #define KERN_ADDRESS_TBL 0xFFEAAA10 - - #define socket_lib_finish ((void (*)(void))0x10c0404) - - // Install flags - #define INSTALL_FS_DONE_ADDR (INSTALL_FS_ADDR - 0x4) // Used to know if fs is already installed - #define INSTALL_FS_DONE_FLAG 0xCACACACA - - // IP settings // - #define DEFAULT_SERVER_IP 0xC0A80102 - -#endif -void kern_write(void *addr, uint32_t value); -#define PRINT_TEXT1(x, y, str) { OSScreenPutFontEx(1, x, y, str); } -#define PRINT_TEXT2(x, y, _fmt, ...) { __os_snprintf(msg, 80, _fmt, __VA_ARGS__); OSScreenPutFontEx(1, x, y, msg); } -#define BTN_PRESSED (BUTTON_LEFT | BUTTON_RIGHT | BUTTON_UP | BUTTON_DOWN) - - -typedef union u_serv_ip -{ - uint8_t digit[4]; - uint32_t full; -} u_serv_ip; - -typedef struct { - char tag[8]; /* 0x000 "OSContxt" */ - int32_t gpr[32]; /* 0x008 from OSDumpContext */ - uint32_t cr; /* 0x088 from OSDumpContext */ - uint32_t lr; /* 0x08c from OSDumpContext */ - uint32_t ctr; /* 0x090 from context switch code */ - uint32_t xer; /* 0x094 from context switch code */ - uint32_t srr0; /* 0x098 from OSDumpContext */ - uint32_t srr1; /* 0x09c from OSDumpContext */ - char _unknowna0[0xb8 - 0xa0]; - uint64_t fpr[32]; /* 0x0b8 from OSDumpContext */ - int16_t spinLockCount; /* 0x1b8 from OSDumpContext */ - char _unknown1ba[0x1bc - 0x1ba]; /* 0x1ba could genuinely be padding? */ - uint32_t gqr[8]; /* 0x1bc from OSDumpContext */ - char _unknown1dc[0x1e0 - 0x1dc]; - uint64_t psf[32]; /* 0x1e0 from OSDumpContext */ - int64_t coretime[3]; /* 0x2e0 from OSDumpContext */ - int64_t starttime; /* 0x2f8 from OSDumpContext */ - int32_t error; /* 0x300 from OSDumpContext */ - char _unknown304[0x6a0 - 0x304]; -} __attribute__((packed)) OSThread; /* 0x6a0 total length from RAM dumps */ - -typedef struct { - unsigned char *data; - int len; - int alloc_size; - - void*(*MEMAllocFromDefaultHeapEx)(unsigned int size, unsigned int align); - void(*MEMFreeToDefaultHeap)(void *ptr); -} file_struct_t; - -typedef struct { - unsigned char *data_menu; - unsigned char *data_loader; - unsigned char *data_fs; - int len_menu; - int len_loader; - int len_fs; - - unsigned int coreinit_handle; - /* function pointers */ - void*(*memset)(void * dest, unsigned int value, unsigned int bytes); - - void*(*MEMAllocFromDefaultHeapEx)(unsigned int size, unsigned int align); - void(*MEMFreeToDefaultHeap)(void *ptr); - - void*(*curl_easy_init)(); - void(*curl_easy_setopt)(void *handle, unsigned int param, void *op); - int(*curl_easy_perform)(void *handle); - void(*curl_easy_getinfo)(void *handle, unsigned int param, void *op); - void (*curl_easy_cleanup)(void *handle); -} private_data_t; - -/* Install functions */ -static void InstallFS(private_data_t *private_data); - -static int show_ip_selection_screen(unsigned int coreinit_handle, unsigned int *ip_address); -static void curl_thread_callback(int argc, void *argv); - -/* ****************************************************************** */ -/* ENTRY POINT */ -/* ****************************************************************** */ -void _start() -{ - /* Load a good stack */ - asm( - "lis %r1, 0x1ab5 ;" - "ori %r1, %r1, 0xd138 ;" - ); - - /* Make sure the kernel exploit has been run */ - if (OSEffectiveToPhysical((void *)0xa0000000) != (void *)0x31000000) - { - OSFatal("No ksploit."); - } - else - { - private_data_t private_data; - - /* Get coreinit handle and keep it in memory */ - unsigned int coreinit_handle; - OSDynLoad_Acquire("coreinit", &coreinit_handle); - private_data.coreinit_handle = coreinit_handle; - - /* Get our memory functions */ - void*(*memset)(void * dest, unsigned int value, unsigned int bytes); - OSDynLoad_FindExport(coreinit_handle, 0, "memset", &memset); - memset(&private_data, 0, sizeof(private_data_t)); - private_data.memset = memset; - - unsigned int *functionPointer = 0; - OSDynLoad_FindExport(coreinit_handle, 1, "MEMAllocFromDefaultHeapEx", &functionPointer); - private_data.MEMAllocFromDefaultHeapEx = (void*(*)(unsigned int size, unsigned int align))*functionPointer; - OSDynLoad_FindExport(coreinit_handle, 1, "MEMFreeToDefaultHeap", &functionPointer); - private_data.MEMFreeToDefaultHeap = (void (*)(void *))*functionPointer; - - /* Get functions to send restart signal */ - int(*IM_Open)(); - int(*IM_Close)(int fd); - int(*IM_SetDeviceState)(int fd, void *mem, int state, int a, int b); - void*(*OSAllocFromSystem)(unsigned int size, int align); - void(*OSFreeToSystem)(void *ptr); - OSDynLoad_FindExport(coreinit_handle, 0, "IM_Open", &IM_Open); - OSDynLoad_FindExport(coreinit_handle, 0, "IM_Close", &IM_Close); - OSDynLoad_FindExport(coreinit_handle, 0, "IM_SetDeviceState", &IM_SetDeviceState); - OSDynLoad_FindExport(coreinit_handle, 0, "OSAllocFromSystem", &OSAllocFromSystem); - OSDynLoad_FindExport(coreinit_handle, 0, "OSFreeToSystem", &OSFreeToSystem); - - /* Send restart signal to get rid of uneeded threads */ - /* Cause the other browser threads to exit */ - int fd = IM_Open(); - void *mem = OSAllocFromSystem(0x100, 64); - memset(mem, 0, 0x100); - - /* Sets wanted flag */ - IM_SetDeviceState(fd, mem, 3, 0, 0); - IM_Close(fd); - OSFreeToSystem(mem); - - /* Waits for thread exits */ - unsigned int t1 = 0x1FFFFFFF; - while(t1--) ; - - /* Prepare for thread startups */ - int (*OSCreateThread)(OSThread *thread, void *entry, int argc, void *args, unsigned int stack, unsigned int stack_size, int priority, unsigned short attr); - int (*OSResumeThread)(OSThread *thread); - int (*OSIsThreadTerminated)(OSThread *thread); - - OSDynLoad_FindExport(coreinit_handle, 0, "OSCreateThread", &OSCreateThread); - OSDynLoad_FindExport(coreinit_handle, 0, "OSResumeThread", &OSResumeThread); - OSDynLoad_FindExport(coreinit_handle, 0, "OSIsThreadTerminated", &OSIsThreadTerminated); - - /* Allocate a stack for the thread */ - /* IMPORTANT: libcurl uses around 0x1000 internally so make - sure to allocate more for the stack to avoid crashes */ - void *stack = private_data.MEMAllocFromDefaultHeapEx(0x2000, 0x20); - /* Create the thread variable */ - OSThread *thread = (OSThread *) private_data.MEMAllocFromDefaultHeapEx(sizeof(OSThread), 8); - if(!thread || !stack) - OSFatal("Thread memory allocation failed."); - - // the thread stack is too small on current thread, switch to an own created thread - // create a detached thread with priority 0 and use core 1 - int ret = OSCreateThread(thread, curl_thread_callback, 1, (void*)&private_data, (unsigned int)stack+0x2000, 0x2000, 0, 0x1A); - if (ret == 0) - OSFatal("Failed to create thread"); - - /* Schedule it for execution */ - OSResumeThread(thread); - - /* while we are downloading let the user select his IP stuff */ - unsigned int ip_address = 0; - int result = show_ip_selection_screen(coreinit_handle, &ip_address); - - // Keep this main thread around for ELF loading - // Can not use OSJoinThread, which hangs for some reason, so we use a detached one and wait for it to terminate - while(OSIsThreadTerminated(thread) == 0) - { - asm volatile ( - " nop\n" - " nop\n" - " nop\n" - " nop\n" - " nop\n" - " nop\n" - " nop\n" - " nop\n" - ); - } - - /* Free thread memory and stack */ - private_data.MEMFreeToDefaultHeap(thread); - private_data.MEMFreeToDefaultHeap(stack); - - /* Install our ELF files */ - if(result){ - InstallFS(&private_data); - /* patch server IP */ - *((volatile unsigned int *)(INSTALL_FS_ADDR + 0xa0000000)) = ip_address; - } - - /* free memory allocated */ - if(private_data.data_menu) { - private_data.MEMFreeToDefaultHeap(private_data.data_menu); - } - if(private_data.data_loader) { - private_data.MEMFreeToDefaultHeap(private_data.data_loader); - } - if(private_data.data_fs) { - private_data.MEMFreeToDefaultHeap(private_data.data_fs); - } - } - _Exit(); -} - -/* IP selection screen implemented by Maschell */ -static int show_ip_selection_screen(unsigned int coreinit_handle, unsigned int *ip_address) -{ - - /************************************************************************/ - // Prepare screen - void (*OSScreenInit)(); - unsigned int (*OSScreenGetBufferSizeEx)(unsigned int bufferNum); - unsigned int (*OSScreenSetBufferEx)(unsigned int bufferNum, void * addr); - unsigned int (*OSScreenClearBufferEx)(unsigned int bufferNum, unsigned int temp); - unsigned int (*OSScreenFlipBuffersEx)(unsigned int bufferNum); - unsigned int (*OSScreenPutFontEx)(unsigned int bufferNum, unsigned int posX, unsigned int posY, void * buffer); - - OSDynLoad_FindExport(coreinit_handle, 0, "OSScreenInit", &OSScreenInit); - OSDynLoad_FindExport(coreinit_handle, 0, "OSScreenGetBufferSizeEx", &OSScreenGetBufferSizeEx); - OSDynLoad_FindExport(coreinit_handle, 0, "OSScreenSetBufferEx", &OSScreenSetBufferEx); - OSDynLoad_FindExport(coreinit_handle, 0, "OSScreenClearBufferEx", &OSScreenClearBufferEx); - OSDynLoad_FindExport(coreinit_handle, 0, "OSScreenFlipBuffersEx", &OSScreenFlipBuffersEx); - OSDynLoad_FindExport(coreinit_handle, 0, "OSScreenPutFontEx", &OSScreenPutFontEx); - - - /* ****************************************************************** */ - /* IP Settings */ - /* ****************************************************************** */ - - // Set server ip - u_serv_ip ip; - ip.full = DEFAULT_SERVER_IP; - char msg[80]; - // Prepare screen - int screen_buf0_size = 0; - int screen_buf1_size = 0; - uint screen_color = 0; // (r << 24) | (g << 16) | (b << 8) | a; - - // Init screen and screen buffers - OSScreenInit(); - screen_buf0_size = OSScreenGetBufferSizeEx(0); - screen_buf1_size = OSScreenGetBufferSizeEx(1); - OSScreenSetBufferEx(0, (void *)0xF4000000); - OSScreenSetBufferEx(1, (void *)0xF4000000 + screen_buf0_size); - - // Clear screens - OSScreenClearBufferEx(0, screen_color); - OSScreenClearBufferEx(1, screen_color); - - // Flush the cache - DCFlushRange((void *)0xF4000000, screen_buf0_size); - DCFlushRange((void *)0xF4000000 + screen_buf0_size, screen_buf1_size); - - // Flip buffers - OSScreenFlipBuffersEx(0); - OSScreenFlipBuffersEx(1); - - // Prepare vpad - unsigned int vpad_handle; - int (*VPADRead)(int controller, VPADData *buffer, unsigned int num, int *error); - OSDynLoad_Acquire("vpad.rpl", &vpad_handle); - OSDynLoad_FindExport(vpad_handle, 0, "VPADRead", &VPADRead); - - // Set server ip with buttons - uint8_t sel_ip = 3; - int error; - uint8_t update_screen = 1; // refresh screen initially - VPADData vpad_data; - VPADRead(0, &vpad_data, 1, &error); //Read initial vpad status - int noip = 1; - int result = 0; - int delay = 0; - - while (1) - { - // Print message - PRINT_TEXT1(14, 1, "-- SAVIINE 1.0 (a cafiine mod) --"); - PRINT_TEXT2(0, 5, "%s : %3d.%3d.%3d.%3d", "1. Server IP", ip.digit[0], ip.digit[1], ip.digit[2], ip.digit[3]); - PRINT_TEXT1(0, 6, "2. Press A to install saviine"); - PRINT_TEXT1(42, 17, "home button to exit ..."); - - // Print ip digit selector - uint8_t x_shift = 15 + 4 * sel_ip; - PRINT_TEXT1(x_shift, 4, "vvv"); - - // Refresh screen if needed - if (update_screen) - { - OSScreenFlipBuffersEx(1); - OSScreenClearBufferEx(1, 0); - } - - // Read vpad - VPADRead(0, &vpad_data, 1, &error); - - // Check for buttons - // Home Button - if (vpad_data.btn_trigger & BUTTON_HOME) { - result = 0; - break; - } - // A Button - if (vpad_data.btn_trigger & BUTTON_A){ - *ip_address = ip.full; - result = 1; - break; - } - // Left/Right Buttons - if (vpad_data.btn_trigger & BUTTON_LEFT ) sel_ip = !sel_ip ? sel_ip = 3 : --sel_ip; - if (vpad_data.btn_trigger & BUTTON_RIGHT) sel_ip = ++sel_ip % 4; - - // Up/Down Buttons - if ((vpad_data.btn_hold & BUTTON_UP) || (vpad_data.btn_trigger & BUTTON_UP)) { - if(--delay <= 0) { - ip.digit[sel_ip]++; - delay = (vpad_data.btn_trigger & BUTTON_UP) ? 30 : 3; - } - } - else if ((vpad_data.btn_hold & BUTTON_DOWN) || (vpad_data.btn_trigger & BUTTON_DOWN)) { - if(--delay <= 0) { - ip.digit[sel_ip]--; - delay = (vpad_data.btn_trigger & BUTTON_DOWN) ? 30 : 3; - } - } - else { - delay = 0; - } - - // Button pressed ? - update_screen = (vpad_data.btn_hold & BTN_PRESSED) ? 1 : 0; - } - - return result; -} - -/* libcurl data write callback */ -static int curl_write_data_callback(void *buffer, int size, int nmemb, void *userp) -{ - file_struct_t *file = (file_struct_t *)userp; - int insize = size*nmemb; - - while(file->len + insize > file->alloc_size) { - if(file->data) { - file->MEMFreeToDefaultHeap(file->data); - } - file->alloc_size += 0x20000; - file->data = file->MEMAllocFromDefaultHeapEx(file->alloc_size, 0x20); - if(!file->data) - OSFatal("Memory allocation failed"); - } - - memcpy(file->data + file->len, buffer, insize); - file->len += insize; - return insize; -} - -/* The downloader thread */ -#define CURLOPT_WRITEDATA 10001 -#define CURLOPT_URL 10002 -#define CURLOPT_WRITEFUNCTION 20011 -#define CURLINFO_RESPONSE_CODE 0x200002 - -static int curl_download_file(private_data_t *private_data, void * curl, char *url, unsigned char **out_buffer) -{ - file_struct_t file; - file.MEMAllocFromDefaultHeapEx = private_data->MEMAllocFromDefaultHeapEx; - file.MEMFreeToDefaultHeap = private_data->MEMFreeToDefaultHeap; - file.data = 0; - file.len = 0; - file.alloc_size = 0; - private_data->curl_easy_setopt(curl, CURLOPT_URL, url); - private_data->curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, curl_write_data_callback); - private_data->curl_easy_setopt(curl, CURLOPT_WRITEDATA, &file); - - /* Download file */ - int ret = private_data->curl_easy_perform(curl); - if(ret) - OSFatal(url); - - /* Do error checks */ - if(!file.len) { - OSFatal(url); - } - - int resp = 404; - private_data->curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &resp); - if(resp != 200) { - OSFatal(url); - } - - *out_buffer = file.data; - return file.len; -} - -static void curl_thread_callback(int argc, void *argv) -{ - private_data_t *private_data = (private_data_t *)argv; - char *leaddr = (char*)0; - unsigned char *str; - - char buf[128]; - /* find address left in ram */ - for(str = (unsigned char*)0x1A000000; str < (unsigned char*)0x20000000; str++) - { /* Search for /payload which indicates the current address */ - if(*(unsigned int*)str == 0x2F706179 && *(unsigned int*)(str+4) == 0x6C6F6164) - { - leaddr = (char*)str; - while(*leaddr) leaddr--; - leaddr++; - /* If string starts with http its likely to be correct */ - if(*(unsigned int*)leaddr == 0x68747470) - break; - leaddr = (char*)0; - } - } - if(leaddr == (char*)0) - OSFatal("URL not found"); - - /* Acquire and setup libcurl */ - unsigned int libcurl_handle; - OSDynLoad_Acquire("nlibcurl", &libcurl_handle); - - OSDynLoad_FindExport(libcurl_handle, 0, "curl_easy_init", &private_data->curl_easy_init); - OSDynLoad_FindExport(libcurl_handle, 0, "curl_easy_setopt", &private_data->curl_easy_setopt); - OSDynLoad_FindExport(libcurl_handle, 0, "curl_easy_perform", &private_data->curl_easy_perform); - OSDynLoad_FindExport(libcurl_handle, 0, "curl_easy_getinfo", &private_data->curl_easy_getinfo); - OSDynLoad_FindExport(libcurl_handle, 0, "curl_easy_cleanup", &private_data->curl_easy_cleanup); - - void *curl = private_data->curl_easy_init(); - if(!curl) { - OSFatal("cURL init failed"); - } - - /* Generate the url address */ - char *src_ptr = leaddr; - char *ptr = buf; - while(*src_ptr) { - *ptr++ = *src_ptr++; - } - *ptr = 0; - // go back to last / - while(*ptr != 0x2F) - ptr--; - - memcpy(ptr+1, "saviine532.elf", 15); - private_data->len_fs = curl_download_file(private_data, curl, buf, &private_data->data_fs); - - - /* Cleanup to gain back memory */ - private_data->curl_easy_cleanup(curl); - - /* Release libcurl and exit thread */ - // TODO: get correct address of OSDynLoad_Release and release the handle - // finding export is not working - //void (*OSDynLoad_Release)(unsigned int handle); - //OSDynLoad_FindExport(private_data->coreinit_handle, 0, "OSDynLoad_Release", &OSDynLoad_Release); - //OSDynLoad_Release(libcurl_handle); - - -} - -static int strcmp(const char *s1, const char *s2) -{ - while(*s1 && *s2) - { - if(*s1 != *s2) { - return -1; - } - s1++; - s2++; - } - - if(*s1 != *s2) { - return -1; - } - return 0; -} - -static unsigned int get_section(private_data_t *private_data, unsigned char *data, const char *name, unsigned int * size, unsigned int * addr) -{ - Elf32_Ehdr *ehdr = (Elf32_Ehdr *) data; - - if ( !data - || !IS_ELF (*ehdr) - || (ehdr->e_type != ET_EXEC) - || (ehdr->e_machine != EM_PPC)) - { - OSFatal("Invalid elf"); - } - - Elf32_Shdr *shdr = (Elf32_Shdr *) (data + ehdr->e_shoff); - int i; - for(i = 0; i < ehdr->e_shnum; i++) - { - const char *section_name = ((const char*)data) + shdr[ehdr->e_shstrndx].sh_offset + shdr[i].sh_name; - if(strcmp(section_name, name) == 0) - { - if(addr) - *addr = shdr[i].sh_addr; - if(size) - *size = shdr[i].sh_size; - return shdr[i].sh_offset; - } - } - - OSFatal((char*)name); -} - -/* ****************************************************************** */ -/* INSTALL FS */ -/* Install filesystem functions */ -/* ****************************************************************** */ -static void InstallFS(private_data_t *private_data) -{ - /* Check if already installed */ - if (*(volatile unsigned int *)(INSTALL_FS_DONE_ADDR + 0xa0000000) == INSTALL_FS_DONE_FLAG) - return; - *(volatile unsigned int *)(INSTALL_FS_DONE_ADDR + 0xa0000000) = INSTALL_FS_DONE_FLAG; - - // get .text section - unsigned int fs_text_addr = 0; - unsigned int fs_text_len = 0; - unsigned int section_offset = get_section(private_data, private_data->data_fs, ELF_TEXT, &fs_text_len, &fs_text_addr); - unsigned char *fs_text = private_data->data_fs + section_offset; - // get .rodata section - unsigned int fs_rodata_addr = 0; - unsigned int fs_rodata_len = 0; - section_offset = get_section(private_data, private_data->data_fs, ELF_RODATA, &fs_rodata_len, &fs_rodata_addr); - unsigned char *fs_rodata = private_data->data_fs + section_offset; - // get .magic section - unsigned int fs_magic_addr = 0; - unsigned int fs_magic_len = 0; - section_offset = get_section(private_data, private_data->data_fs, ".magic", &fs_magic_len, &fs_magic_addr); - unsigned char *fs_magic = private_data->data_fs + section_offset; - - /* Copy fs code section to memory */ - unsigned int cpy_addr = (0xa0000000 + fs_text_addr); - memcpy((void*)cpy_addr, fs_text, fs_text_len); - DCFlushRange((void*)cpy_addr, fs_text_len); - ICInvalidateRange((void*)cpy_addr, fs_text_len); - - /* Copy fs rodata section to memory */ - cpy_addr = (0xa0000000 + fs_rodata_addr); - memcpy((void*)cpy_addr, fs_rodata, fs_rodata_len); - DCFlushRange((void*)cpy_addr, fs_rodata_len); - - /* ------------------------------------------------------------------------------------------------------------------------*/ - /* patch the FS functions to branch to our functions */ - /* ------------------------------------------------------------------------------------------------------------------------*/ - struct magic_t { - void *real; - void *replacement; - void *call; - } *magic = (struct magic_t *)fs_magic; - unsigned int len = fs_magic_len / sizeof(struct magic_t); - - /* Patch branches to it. */ - volatile int *space = (volatile int *)(0xa0000000 + fs_text_addr + fs_text_len); - while (len--) { - int real_addr = (int)magic[len].real; - int repl_addr = (int)magic[len].replacement; - int call_addr = (int)magic[len].call; - - // set pointer to the real function - *(volatile int *)(0xa0000000 + call_addr) = (int)space - 0xa0000000; - - // fill the pointer of the real function - *space = *(volatile int *)(0xa0000000 + real_addr); - space++; - - // jump to real function skipping the "mflr r0" instruction - *space = 0x48000002 | ((real_addr + 4) & 0x03fffffc); - space++; - DCFlushRange((void*)space - 2, 8); - ICInvalidateRange((void*)space - 2, 8); - - // in the real function, replace the "mflr r0" instruction by a jump to the replacement function - *(volatile int *)(0xa0000000 + real_addr) = 0x48000002 | (repl_addr & 0x03fffffc); - DCFlushRange((int *)(0xa0000000 + real_addr), 4); - ICInvalidateRange((int *)(0xa0000000 + real_addr), 4); - } - unsigned int *socket_finish = (unsigned int *)((char *)socket_lib_finish + 0xa0000000); - socket_finish[0] = 0x38600000; - socket_finish[1] = 0x4e800020; - - /* The fix for Splatoon and such */ - kern_write(KERN_ADDRESS_TBL + (0x12 * 4), 0x00000000); - kern_write(KERN_ADDRESS_TBL + (0x13 * 4), 0x14000000); -} - -/* Write a 32-bit word with kernel permissions */ -void kern_write(void *addr, uint32_t value) -{ - asm( - "li 3,1\n" - "li 4,0\n" - "mr 5,%1\n" - "li 6,0\n" - "li 7,0\n" - "lis 8,1\n" - "mr 9,%0\n" - "mr %1,1\n" - "li 0,0x3500\n" - "sc\n" - "nop\n" - "mr 1,%1\n" - : - :"r"(addr), "r"(value) - :"memory", "ctr", "lr", "0", "3", "4", "5", "6", "7", "8", "9", "10", - "11", "12" - ); -} \ No newline at end of file diff --git a/saviine/installer/saviine.h b/saviine/installer/saviine.h deleted file mode 100644 index c818d70..0000000 --- a/saviine/installer/saviine.h +++ /dev/null @@ -1,7 +0,0 @@ -#ifndef SAVIINE_H -#define SAVIINE_H - -/* Include base types */ -#include "../common/types.h" - -#endif /* SAVIINE_H */ diff --git a/saviine/server/src/bin/saviine_server.exe b/saviine/server/src/bin/saviine_server.exe deleted file mode 100644 index 9aea226..0000000 Binary files a/saviine/server/src/bin/saviine_server.exe and /dev/null differ diff --git a/saviine/server/src/obj/x86/Debug/saviine_server.csproj.FileListAbsolute.txt b/saviine/server/src/obj/x86/Debug/saviine_server.csproj.FileListAbsolute.txt deleted file mode 100644 index f376321..0000000 --- a/saviine/server/src/obj/x86/Debug/saviine_server.csproj.FileListAbsolute.txt +++ /dev/null @@ -1,9 +0,0 @@ -G:\Programmieren\libwiiu-master\saviinet\saviine\saviine\server\src\bin\saviine_server.exe.config -G:\Programmieren\libwiiu-master\saviinet\saviine\saviine\server\src\bin\saviine_server.exe -G:\Programmieren\libwiiu-master\saviinet\saviine\saviine\server\src\bin\saviine_server.pdb -G:\Programmieren\libwiiu-master\saviinet\saviine\saviine\server\src\obj\x86\Debug\saviine_server.exe -G:\Programmieren\libwiiu-master\saviinet\saviine\saviine\server\src\obj\x86\Debug\saviine_server.pdb -G:\Programmieren\libwiiu-master\saviinet\saviine\saviine\server\src\obj\x86\Debug\saviine_server.csproj.GenerateResource.Cache -G:\Programmieren\libwiiu-master\saviinet\saviine\saviine\server\src\obj\x86\Debug\saviine_server.SaveSelectorDialog.resources -G:\Programmieren\libwiiu-master\saviinet\saviine\saviine\server\src\obj\x86\Debug\saviine_server.csprojResolveAssemblyReference.cache -G:\Programmieren\libwiiu-master\saviinet\saviine\saviine\server\src\obj\x86\Debug\saviine_server.DumpDialog.resources diff --git a/saviine/server/src/obj/x86/Debug/saviine_server.csprojResolveAssemblyReference.cache b/saviine/server/src/obj/x86/Debug/saviine_server.csprojResolveAssemblyReference.cache deleted file mode 100644 index 5f8b667..0000000 Binary files a/saviine/server/src/obj/x86/Debug/saviine_server.csprojResolveAssemblyReference.cache and /dev/null differ diff --git a/saviine/server/dump.bat b/server/dump.bat similarity index 100% rename from saviine/server/dump.bat rename to server/dump.bat diff --git a/saviine/server/inject.bat b/server/inject.bat similarity index 100% rename from saviine/server/inject.bat rename to server/inject.bat diff --git a/saviine/server/saviine_server.exe b/server/saviine_server.exe similarity index 100% rename from saviine/server/saviine_server.exe rename to server/saviine_server.exe diff --git a/saviine/server/src/.vs/cafiine_server/v14/.suo b/server/src/.vs/cafiine_server/v14/.suo similarity index 100% rename from saviine/server/src/.vs/cafiine_server/v14/.suo rename to server/src/.vs/cafiine_server/v14/.suo diff --git a/server/src/DumpDialog.Designer.cs b/server/src/DumpDialog.Designer.cs new file mode 100644 index 0000000..d0d4404 --- /dev/null +++ b/server/src/DumpDialog.Designer.cs @@ -0,0 +1,140 @@ +namespace saviine_server +{ + partial class DumpDialog + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.btn_ok = new System.Windows.Forms.Button(); + this.btn_cancel = new System.Windows.Forms.Button(); + this.lbl_message = new System.Windows.Forms.Label(); + this.label1 = new System.Windows.Forms.Label(); + this.Inj = new System.Windows.Forms.Label(); + this.checkBoxUser = new System.Windows.Forms.CheckBox(); + this.checkBoxCommon = new System.Windows.Forms.CheckBox(); + this.SuspendLayout(); + // + // btn_ok + // + this.btn_ok.DialogResult = System.Windows.Forms.DialogResult.OK; + this.btn_ok.Location = new System.Drawing.Point(15, 133); + this.btn_ok.Name = "btn_ok"; + this.btn_ok.Size = new System.Drawing.Size(81, 21); + this.btn_ok.TabIndex = 0; + this.btn_ok.Text = "OK"; + this.btn_ok.UseVisualStyleBackColor = true; + this.btn_ok.Click += new System.EventHandler(this.btn_ok_Click); + // + // btn_cancel + // + this.btn_cancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; + this.btn_cancel.Location = new System.Drawing.Point(148, 133); + this.btn_cancel.Name = "btn_cancel"; + this.btn_cancel.Size = new System.Drawing.Size(81, 21); + this.btn_cancel.TabIndex = 1; + this.btn_cancel.Text = "Cancel"; + this.btn_cancel.UseVisualStyleBackColor = true; + // + // lbl_message + // + this.lbl_message.AutoSize = true; + this.lbl_message.Location = new System.Drawing.Point(12, 9); + this.lbl_message.Name = "lbl_message"; + this.lbl_message.Size = new System.Drawing.Size(217, 13); + this.lbl_message.TabIndex = 3; + this.lbl_message.Text = "Got a dump request"; + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(12, 51); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(84, 13); + this.label1.TabIndex = 5; + this.label1.Text = "Dump user save"; + // + // Inj + // + this.Inj.AutoSize = true; + this.Inj.Location = new System.Drawing.Point(12, 86); + this.Inj.Name = "Inj"; + this.Inj.Size = new System.Drawing.Size(104, 13); + this.Inj.TabIndex = 7; + this.Inj.Text = "Dump common save"; + // + // checkBoxUser + // + this.checkBoxUser.AutoSize = true; + this.checkBoxUser.Checked = true; + this.checkBoxUser.CheckState = System.Windows.Forms.CheckState.Checked; + this.checkBoxUser.Location = new System.Drawing.Point(202, 50); + this.checkBoxUser.Name = "checkBoxUser"; + this.checkBoxUser.Size = new System.Drawing.Size(15, 14); + this.checkBoxUser.TabIndex = 9; + this.checkBoxUser.UseVisualStyleBackColor = true; + // + // checkBoxCommon + // + this.checkBoxCommon.AutoSize = true; + this.checkBoxCommon.Checked = true; + this.checkBoxCommon.CheckState = System.Windows.Forms.CheckState.Checked; + this.checkBoxCommon.Location = new System.Drawing.Point(202, 85); + this.checkBoxCommon.Name = "checkBoxCommon"; + this.checkBoxCommon.Size = new System.Drawing.Size(15, 14); + this.checkBoxCommon.TabIndex = 10; + this.checkBoxCommon.UseVisualStyleBackColor = true; + // + // DumpDialog + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(257, 166); + this.Controls.Add(this.checkBoxCommon); + this.Controls.Add(this.checkBoxUser); + this.Controls.Add(this.Inj); + this.Controls.Add(this.label1); + this.Controls.Add(this.lbl_message); + this.Controls.Add(this.btn_cancel); + this.Controls.Add(this.btn_ok); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; + this.Name = "DumpDialog"; + this.Text = "Dump request"; + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.Button btn_ok; + private System.Windows.Forms.Button btn_cancel; + private System.Windows.Forms.Label lbl_message; + private System.Windows.Forms.Label label1; + private System.Windows.Forms.Label Inj; + private System.Windows.Forms.CheckBox checkBoxUser; + private System.Windows.Forms.CheckBox checkBoxCommon; + } +} \ No newline at end of file diff --git a/saviine/server/src/DumpDialog.cs b/server/src/DumpDialog.cs similarity index 100% rename from saviine/server/src/DumpDialog.cs rename to server/src/DumpDialog.cs diff --git a/saviine/server/src/DumpDialog.resx b/server/src/DumpDialog.resx similarity index 100% rename from saviine/server/src/DumpDialog.resx rename to server/src/DumpDialog.resx diff --git a/saviine/server/src/Program.cs b/server/src/Program.cs similarity index 100% rename from saviine/server/src/Program.cs rename to server/src/Program.cs diff --git a/saviine/server/src/Properties/AssemblyInfo.cs b/server/src/Properties/AssemblyInfo.cs similarity index 100% rename from saviine/server/src/Properties/AssemblyInfo.cs rename to server/src/Properties/AssemblyInfo.cs diff --git a/saviine/server/src/SaveSelectorDialog.Designer.cs b/server/src/SaveSelectorDialog.Designer.cs similarity index 100% rename from saviine/server/src/SaveSelectorDialog.Designer.cs rename to server/src/SaveSelectorDialog.Designer.cs diff --git a/saviine/server/src/SaveSelectorDialog.cs b/server/src/SaveSelectorDialog.cs similarity index 100% rename from saviine/server/src/SaveSelectorDialog.cs rename to server/src/SaveSelectorDialog.cs diff --git a/saviine/server/src/SaveSelectorDialog.resx b/server/src/SaveSelectorDialog.resx similarity index 100% rename from saviine/server/src/SaveSelectorDialog.resx rename to server/src/SaveSelectorDialog.resx diff --git a/saviine/server/src/System/IO/EndianBinaryReader.cs b/server/src/System/IO/EndianBinaryReader.cs similarity index 100% rename from saviine/server/src/System/IO/EndianBinaryReader.cs rename to server/src/System/IO/EndianBinaryReader.cs diff --git a/saviine/server/src/System/IO/EndianBinaryWriter.cs b/server/src/System/IO/EndianBinaryWriter.cs similarity index 100% rename from saviine/server/src/System/IO/EndianBinaryWriter.cs rename to server/src/System/IO/EndianBinaryWriter.cs diff --git a/saviine/server/src/app.config b/server/src/app.config similarity index 100% rename from saviine/server/src/app.config rename to server/src/app.config diff --git a/saviine/server/src/cafiine_server.v12.suo b/server/src/cafiine_server.v12.suo similarity index 100% rename from saviine/server/src/cafiine_server.v12.suo rename to server/src/cafiine_server.v12.suo diff --git a/saviine/server/src/obj/x86/Debug/saviine_server.DumpDialog.resources b/server/src/obj/x86/Debug/saviine_server.DumpDialog.resources similarity index 100% rename from saviine/server/src/obj/x86/Debug/saviine_server.DumpDialog.resources rename to server/src/obj/x86/Debug/saviine_server.DumpDialog.resources diff --git a/saviine/server/src/obj/x86/Debug/saviine_server.SaveSelectorDialog.resources b/server/src/obj/x86/Debug/saviine_server.SaveSelectorDialog.resources similarity index 100% rename from saviine/server/src/obj/x86/Debug/saviine_server.SaveSelectorDialog.resources rename to server/src/obj/x86/Debug/saviine_server.SaveSelectorDialog.resources diff --git a/saviine/server/src/saviine_server.csproj b/server/src/saviine_server.csproj similarity index 100% rename from saviine/server/src/saviine_server.csproj rename to server/src/saviine_server.csproj diff --git a/saviine/server/src/saviine_server.csproj.user b/server/src/saviine_server.csproj.user similarity index 100% rename from saviine/server/src/saviine_server.csproj.user rename to server/src/saviine_server.csproj.user diff --git a/saviine/server/src/saviine_server.sln b/server/src/saviine_server.sln similarity index 100% rename from saviine/server/src/saviine_server.sln rename to server/src/saviine_server.sln diff --git a/saviine/server/src/saviine_server.suo b/server/src/saviine_server.suo similarity index 100% rename from saviine/server/src/saviine_server.suo rename to server/src/saviine_server.suo diff --git a/saviine/server/src/saviine_server.v12.suo b/server/src/saviine_server.v12.suo similarity index 100% rename from saviine/server/src/saviine_server.v12.suo rename to server/src/saviine_server.v12.suo diff --git a/src/common/common.h b/src/common/common.h new file mode 100644 index 0000000..e6c89ec --- /dev/null +++ b/src/common/common.h @@ -0,0 +1,56 @@ +#ifndef COMMON_H +#define COMMON_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include "os_defs.h" + +#define CAFE_OS_SD_PATH "/vol/external01" +#define SD_PATH "sd:" +#define WIIU_PATH "/wiiu" + +/* Macros for libs */ +#define LIB_CORE_INIT 0 +#define LIB_NSYSNET 1 +#define LIB_GX2 2 +// none dynamic libs +#define LIB_LOADER 0x1001 + + +#ifndef MEM_BASE +#define MEM_BASE (0x00800000) +#endif + +#define ELF_DATA_ADDR (*(volatile unsigned int*)(MEM_BASE + 0x1300 + 0x00)) +#define ELF_DATA_SIZE (*(volatile unsigned int*)(MEM_BASE + 0x1300 + 0x04)) +#define MAIN_ENTRY_ADDR (*(volatile unsigned int*)(MEM_BASE + 0x1400 + 0x00)) +#define OS_FIRMWARE (*(volatile unsigned int*)(MEM_BASE + 0x1400 + 0x04)) + +#define OS_SPECIFICS ((OsSpecifics*)(MEM_BASE + 0x1500)) + +#ifndef EXIT_SUCCESS +#define EXIT_SUCCESS 0 +#endif +#define EXIT_HBL_EXIT 0xFFFFFFFE +#define EXIT_RELAUNCH_ON_LOAD 0xFFFFFFFD + +#define RESTORE_INSTR_MAGIC 0xC001C0DE +#define RESTORE_INSTR_ADDR ((restore_instructions_t*)(MEM_BASE + 0x1600)) + +typedef struct _restore_instructions_t { + unsigned int magic; + unsigned int instr_count; + struct { + unsigned int addr; + unsigned int instr; + } data[0]; +} restore_instructions_t; + +#ifdef __cplusplus +} +#endif + +#endif /* COMMON_H */ + diff --git a/src/common/fs_defs.h b/src/common/fs_defs.h new file mode 100644 index 0000000..702e9ef --- /dev/null +++ b/src/common/fs_defs.h @@ -0,0 +1,67 @@ +#ifndef FS_DEFS_H +#define FS_DEFS_H + +#include "types.h" + +#ifdef __cplusplus +extern "C" { +#endif + + +/* FS defines and types */ +#define FS_MAX_LOCALPATH_SIZE 511 +#define FS_MAX_MOUNTPATH_SIZE 128 +#define FS_MAX_FULLPATH_SIZE (FS_MAX_LOCALPATH_SIZE + FS_MAX_MOUNTPATH_SIZE) +#define FS_MAX_ARGPATH_SIZE FS_MAX_FULLPATH_SIZE + +#define FS_STATUS_OK 0 +#define FS_STATUS_EXISTS -5 +#define FS_STATUS_STORAGE_FULL -12 +#define FS_STATUS_JOURNAL_FULL -13 + +#define FS_RET_UNSUPPORTED_CMD 0x0400 +#define FS_RET_NO_ERROR 0x0000 +#define FS_RET_ALL_ERROR (unsigned int)(-1) + + +#define FS_STAT_FLAG_IS_DIRECTORY 0x80000000 + +/* max length of file/dir name */ +#define FS_MAX_ENTNAME_SIZE 256 + +#define FS_SOURCETYPE_EXTERNAL 0 +#define FS_SOURCETYPE_HFIO 1 +#define FS_SOURCETYPE_HFIO 1 + +#define FS_MOUNT_SOURCE_SIZE 0x300 +#define FS_CLIENT_SIZE 0x1700 +#define FS_CMD_BLOCK_SIZE 0xA80 + +typedef struct +{ + uint32_t flag; + uint32_t permission; + uint32_t owner_id; + uint32_t group_id; + uint32_t size; + uint32_t alloc_size; + uint64_t quota_size; + uint32_t ent_id; + uint64_t ctime; + uint64_t mtime; + uint8_t attributes[48]; +} __attribute__((packed)) FSStat; + +typedef struct +{ + FSStat stat; + char name[FS_MAX_ENTNAME_SIZE]; +} FSDirEntry; + + +#ifdef __cplusplus +} +#endif + +#endif /* FS_DEFS_H */ + diff --git a/src/common/kernel_defs.h b/src/common/kernel_defs.h new file mode 100644 index 0000000..d199c96 --- /dev/null +++ b/src/common/kernel_defs.h @@ -0,0 +1,116 @@ +#ifndef __KERNEL_DEFS_H_ +#define __KERNEL_DEFS_H_ + +#include "types.h" +#include "fs_defs.h" + +#ifdef __cplusplus +extern "C" { +#endif + +// original structure in the kernel that is originally 0x1270 long +typedef struct +{ + uint32_t version_cos_xml; // version tag from cos.xml + uint64_t os_version; // os_version from app.xml + uint64_t title_id; // title_id tag from app.xml + uint32_t app_type; // app_type tag from app.xml + uint32_t cmdFlags; // unknown tag as it is always 0 (might be cmdFlags from cos.xml but i am not sure) + char rpx_name[0x1000]; // rpx name from cos.xml + uint32_t unknown2; // 0x050B8304 in mii maker and system menu (looks a bit like permissions complex that got masked!?) + uint32_t unknown3[63]; // those were all zeros, but its probably connected with unknown2 + uint32_t max_size; // max_size in cos.xml which defines the maximum amount of memory reserved for the app + uint32_t avail_size; // avail_size or codegen_size in cos.xml (seems to mostly be 0?) + uint32_t codegen_size; // codegen_size or avail_size in cos.xml (seems to mostly be 0?) + uint32_t codegen_core; // codegen_core in cos.xml (seems to mostly be 1?) + uint32_t max_codesize; // max_codesize in cos.xml + uint32_t overlay_arena; // overlay_arena in cos.xml + uint32_t unknown4[59]; // all zeros it seems + uint32_t default_stack0_size; // not sure because always 0 but very likely + uint32_t default_stack1_size; // not sure because always 0 but very likely + uint32_t default_stack2_size; // not sure because always 0 but very likely + uint32_t default_redzone0_size; // not sure because always 0 but very likely + uint32_t default_redzone1_size; // not sure because always 0 but very likely + uint32_t default_redzone2_size; // not sure because always 0 but very likely + uint32_t exception_stack0_size; // from cos.xml, 0x1000 on mii maker + uint32_t exception_stack1_size; // from cos.xml, 0x1000 on mii maker + uint32_t exception_stack2_size; // from cos.xml, 0x1000 on mii maker + uint32_t sdk_version; // from app.xml, 20909 (0x51AD) on mii maker + uint32_t title_version; // from app.xml, 0x32 on mii maker + /* + // --------------------------------------------------------------------------------------------------------------------------------------------- + // the next part might be changing from title to title?! I don't think its important but nice to know maybe.... + // --------------------------------------------------------------------------------------------------------------------------------------------- + char mlc[4]; // string "mlc" on mii maker and sysmenu + uint32_t unknown5[7]; // all zeros on mii maker and sysmenu + uint32_t unknown6_one; // 0x01 on mii maker and sysmenu + // --------------------------------------------------------------------------------------------------------------------------------------------- + char ACP[4]; // string "ACP" on mii maker and sysmenu + uint32_t unknown7[15]; // all zeros on mii maker and sysmenu + uint32_t unknown8_5; // 0x05 on mii maker and sysmenu + uint32_t unknown9_zero; // 0x00 on mii maker and sysmenu + uint32_t unknown10_ptr; // 0xFF23DD0C pointer on mii maker and sysmenu + // --------------------------------------------------------------------------------------------------------------------------------------------- + char UVD[4]; // string "UVD" on mii maker and sysmenu + uint32_t unknown11[15]; // all zeros on mii maker and sysmenu + uint32_t unknown12_5; // 0x05 on mii maker and sysmenu + uint32_t unknown13_zero; // 0x00 on mii maker and sysmenu + uint32_t unknown14_ptr; // 0xFF23EFC8 pointer on mii maker and sysmenu + // --------------------------------------------------------------------------------------------------------------------------------------------- + char SND[4]; // string "SND" on mii maker and sysmenu + uint32_t unknown15[15]; // all zeros on mii maker and sysmenu + uint32_t unknown16_5; // 0x05 on mii maker and sysmenu + uint32_t unknown17_zero; // 0x00 on mii maker and sysmenu + uint32_t unknown18_ptr; // 0xFF23F014 pointer on mii maker and sysmenu + // --------------------------------------------------------------------------------------------------------------------------------------------- + uint32_t unknown19; // 0x02 on miimaker, 0x0F on system menu + */ + // after that only zeros follow +} __attribute__((packed)) CosAppXmlInfo; + + +// Our own cos/app.xml struct which uses only uses as much memory as really needed, since many things are just zeros in the above structure +// This structure is only 0x64 bytes long + RPX name length (dynamic up to 0x1000 theoretically) +typedef struct +{ + uint32_t version_cos_xml; // version tag from cos.xml + uint64_t os_version; // os_version from app.xml + uint64_t title_id; // title_id tag from app.xml + uint32_t app_type; // app_type tag from app.xml + uint32_t cmdFlags; // unknown tag as it is always 0 (might be cmdFlags from cos.xml but i am not sure) + uint32_t max_size; // max_size in cos.xml which defines the maximum amount of memory reserved for the app + uint32_t avail_size; // avail_size or codegen_size in cos.xml (seems to mostly be 0?) + uint32_t codegen_size; // codegen_size or avail_size in cos.xml (seems to mostly be 0?) + uint32_t codegen_core; // codegen_core in cos.xml (seems to mostly be 1?) + uint32_t max_codesize; // max_codesize in cos.xml + uint32_t overlay_arena; // overlay_arena in cos.xml + uint32_t default_stack0_size; // not sure because always 0 but very likely + uint32_t default_stack1_size; // not sure because always 0 but very likely + uint32_t default_stack2_size; // not sure because always 0 but very likely + uint32_t default_redzone0_size; // not sure because always 0 but very likely + uint32_t default_redzone1_size; // not sure because always 0 but very likely + uint32_t default_redzone2_size; // not sure because always 0 but very likely + uint32_t exception_stack0_size; // from cos.xml, 0x1000 on mii maker + uint32_t exception_stack1_size; // from cos.xml, 0x1000 on mii maker + uint32_t exception_stack2_size; // from cos.xml, 0x1000 on mii maker + uint32_t sdk_version; // from app.xml, 20909 (0x51AD) on mii maker + uint32_t title_version; // from app.xml, 0x32 on mii maker + char rpx_name[FS_MAX_ENTNAME_SIZE]; // rpx name from cos.xml, length 256 as it can't get bigger from FS anyway +} __attribute__((packed)) ReducedCosAppXmlInfo; + +typedef struct _bat_t +{ + u32 h; + u32 l; +} bat_t; + +typedef struct _bat_table_t +{ + bat_t bat[8]; +} bat_table_t; + +#ifdef __cplusplus +} +#endif + +#endif // __KERNEL_DEFS_H_ diff --git a/src/common/loader_defs.h b/src/common/loader_defs.h new file mode 100644 index 0000000..97c237c --- /dev/null +++ b/src/common/loader_defs.h @@ -0,0 +1,40 @@ +#ifndef __LOADER_DEFS_H_ +#define __LOADER_DEFS_H_ + +#include "types.h" + +#ifdef __cplusplus +extern "C" { +#endif + +// struct holding the globals of the loader (there are actually more but we don't need others) +typedef struct _loader_globals_t +{ + int sgIsLoadingBuffer; + int sgFileType; + int sgProcId; + int sgGotBytes; + int sgFileOffset; + int sgBufferNumber; + int sgBounceError; + char sgLoadName[0x1000]; +} __attribute__((packed)) loader_globals_t; + +typedef struct _loader_globals_550_t +{ + int sgFinishedLoadingBuffer; + int sgFileType; + int sgProcId; + int sgGotBytes; + int sgTotalBytes; + int sgFileOffset; + int sgBufferNumber; + int sgBounceError; + char sgLoadName[0x1000]; +} __attribute__((packed)) loader_globals_550_t; + +#ifdef __cplusplus +} +#endif + +#endif // __LOADER_DEFS_H_ diff --git a/src/common/os_defs.h b/src/common/os_defs.h new file mode 100644 index 0000000..48a4c8f --- /dev/null +++ b/src/common/os_defs.h @@ -0,0 +1,25 @@ +#ifndef __OS_DEFS_H_ +#define __OS_DEFS_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct _OsSpecifics +{ + unsigned int addr_OSDynLoad_Acquire; + unsigned int addr_OSDynLoad_FindExport; + unsigned int addr_OSTitle_main_entry; + + unsigned int addr_KernSyscallTbl1; + unsigned int addr_KernSyscallTbl2; + unsigned int addr_KernSyscallTbl3; + unsigned int addr_KernSyscallTbl4; + unsigned int addr_KernSyscallTbl5; +} OsSpecifics; + +#ifdef __cplusplus +} +#endif + +#endif // __OS_DEFS_H_ diff --git a/src/common/types.h b/src/common/types.h new file mode 100644 index 0000000..3435e56 --- /dev/null +++ b/src/common/types.h @@ -0,0 +1,7 @@ +#ifndef TYPES_H +#define TYPES_H + +#include + +#endif /* TYPES_H */ + diff --git a/src/discdumper.c b/src/discdumper.c new file mode 100644 index 0000000..4c10d31 --- /dev/null +++ b/src/discdumper.c @@ -0,0 +1,553 @@ +#include +#include +#include +#include "common/kernel_defs.h" +#include "dynamic_libs/os_functions.h" +#include "dynamic_libs/fs_functions.h" +#include "dynamic_libs/aoc_functions.h" +#include "dynamic_libs/socket_functions.h" +#include "dynamic_libs/sys_functions.h" +#include "game/rpx_rpl_table.h" +#include "game/memory_area_table.h" +#include "utils/net.h" +#include "discdumper.h" +#include "utils/logger.h" + +#define TITLE_LOCATION_ODD 0 +#define TITLE_LOCATION_USB 1 +#define TITLE_LOCATION_MLC 2 + +#define BUFFER_SIZE 0x400 * 101 +#define BUFFER_SIZE_STEPS 0x200 + +#define DEBUG_LOG 0 + +extern ReducedCosAppXmlInfo cosAppXmlInfoStruct; + +//! setup some default IP +static u32 serverIpAddress = 0xC0A800B5; + +static int socket_saviine = -1; +static int socket_log = -1; + +void StartDumper() +{ + void *pClient = NULL; + void *pCmd = NULL; + + do{ + pClient = malloc(FS_CLIENT_SIZE); + if (!pClient) + break; + + pCmd = malloc(FS_CMD_BLOCK_SIZE); + if (!pCmd) + break; + + + log_printf("StartDumper\n"); + FSInit(); + FSInitCmdBlock(pCmd); + + FSAddClientEx(pClient, 0, -1); + + log_printf("StartDumper\n"); + cafiine_connect(&socket_saviine,serverIpAddress); + cafiine_connect(&socket_log,serverIpAddress); + log_printf("StartDumper\n"); + + if(socket_saviine >= 0 && socket_log >= 0){ + handle_saves(pClient, pCmd,-1); + } + FSDelClient(pClient); + + }while(0); + + if(pCmd) + free(pCmd); + if(pClient) + free(pClient); + + if(socket_saviine >= 0) + { + cafiine_disconnect(socket_saviine); + socket_saviine = -1; + } + if(socket_log >= 0) + { + cafiine_disconnect(socket_log); + socket_log = -1; + } +} + +void handle_saves(void *pClient, void *pCmd,int error){ + if(DEBUG_LOG) log_string(socket_log, "init", BYTE_LOG_STR); + unsigned char slotNo; + long id = getPesistentID(&slotNo); + init_Save(slotNo); + int mode; + + if(DEBUG_LOG)log_string(socket_log, "getting mode", BYTE_LOG_STR); + if(getMode(socket_saviine,&mode)){ + if(id >= 0x80000000 && id <= 0x90000000){ + char savepath[20]; + __os_snprintf(savepath, sizeof(savepath), "/vol/save/%08x",id); + if(mode == BYTE_MODE_D){ + log_string(socket_log, "dump mode!", BYTE_LOG_STR); + dumpSavaData(pClient, pCmd,id,error); + }else if(mode == BYTE_MODE_I){ + log_string(socket_log, "inject mode", BYTE_LOG_STR); + injectSaveData(pClient,pCmd,id,error); + } + } + } +} + +void dumpSavaData(void *pClient, void *pCmd,long persistentID,int error){ + /* + Allocate buffer for injection + */ + int buf_size = BUFFER_SIZE; + char * pBuffer; + int failed = 0; + do{ + buf_size -= BUFFER_SIZE_STEPS; + if(buf_size < 0){ + log_string(socket_log, "error on buffer allocation", BYTE_LOG_STR); + failed = 1; + break; + } + pBuffer = (char *)memalign(0x40,buf_size); + if(pBuffer) memset(pBuffer, 0x00, buf_size); + }while(!pBuffer); + + if(!failed){ + int mask = 0; + char buffer[60]; + __os_snprintf(buffer, sizeof(buffer), "allocated %d bytes",buf_size); + log_string(socket_log, buffer, BYTE_LOG_STR); + if(saviine_start_dump(socket_saviine, persistentID,&mask)){ + if((mask & MASK_USER) == MASK_USER){ + char savepath[20]; + __os_snprintf(savepath, sizeof(savepath), "/vol/save/%08x",persistentID); + log_string(socket_log, "dumping user savedata", BYTE_LOG_STR); + if(dump_dir(pClient,pCmd,savepath,pBuffer,buf_size,error,50) == -1){ + log_string(socket_log, "error dumping user dir", BYTE_LOG_STR); + failed = 1; + } + } + if((mask & MASK_COMMON) == MASK_COMMON && !failed){ + char * commonDir = "/vol/save/common"; + log_string(socket_log, "dumping common savedata", BYTE_LOG_STR); + if(dump_dir(pClient,pCmd,commonDir,pBuffer,buf_size,error,60) == -1){ + log_string(socket_log, "error dumping common dir (maybe the game has no common folder?)", BYTE_LOG_STR); + } + } + + log_string(socket_log, "done!", BYTE_LOG_STR); + + if(!saviine_end_dump(socket_saviine)) if(DEBUG_LOG) log_string(socket_log, "saviine_end_injection() failed", BYTE_LOG_STR); + if(DEBUG_LOG) log_string(socket_log, "end of dump", BYTE_LOG_STR); + }else{ + log_string(socket_log, "saviine_start_dump() failed", BYTE_LOG_STR); + } + + if(DEBUG_LOG) log_string(socket_log, "free(pBuffer) coming next", BYTE_LOG_STR); + free(pBuffer); + if(DEBUG_LOG) log_string(socket_log, "free(pBuffer)", BYTE_LOG_STR); + } +} + +int dump_dir(void *pClient, void *pCmd, char *path, void * pBuffer, int size,int error, int handle){ + int dir_handle = handle; + int my_handle = handle +1; + int ret = 0; + int final_result = 0; + if ((ret = FSOpenDir(pClient, pCmd, path, &dir_handle, FS_RET_ALL_ERROR)) == FS_STATUS_OK){ + char buffer[strlen(path) + 30]; + __os_snprintf(buffer, sizeof(buffer), "open dir %s",path); + log_string(socket_log, buffer, BYTE_LOG_STR); + FSDirEntry dir_entry; + while (FSReadDir(pClient, pCmd, dir_handle, &dir_entry, FS_RET_ALL_ERROR) == FS_STATUS_OK && final_result == 0) + { + char full_path[strlen(path) + 1 + strlen(dir_entry.name) +1]; + __os_snprintf(full_path, sizeof(full_path), "%s/%s",path,dir_entry.name); + + if((dir_entry.stat.flag&FS_STAT_FLAG_IS_DIRECTORY) == FS_STAT_FLAG_IS_DIRECTORY){ + log_string(socket_log, "-> dir", BYTE_LOG_STR); + + if(dump_dir(pClient, pCmd,full_path,pBuffer,size,error,my_handle) == -1){ + log_string(socket_log, "error", BYTE_LOG_STR); + final_result = -1; + } + }else{ + //DUMP + ret = FSOpenFile(pClient, pCmd, full_path, "r", &my_handle, error); + if (ret >= 0) { + __os_snprintf(buffer, sizeof(buffer), "dumping %s",dir_entry.name); + log_string(socket_log, buffer, BYTE_LOG_STR); + + int ret2; + + int my_ret = cafiine_send_handle(socket_saviine, full_path, my_handle); + if(my_ret != -1){ + while ((ret2 = FSReadFile(pClient, pCmd, pBuffer, 1, size, my_handle, 0, 0)) > 0) + cafiine_send_file(socket_saviine, pBuffer, ret2, my_handle); + cafiine_fclose(socket_saviine, &ret2, my_handle,1); + }else{ + log_string(socket_log, "error on opening file on pc" , BYTE_LOG_STR); + final_result = -1; + } + if((ret2 = FSCloseFile(pClient, pCmd, my_handle, error)) < FS_STATUS_OK){ + __os_snprintf(buffer, sizeof(buffer), "error on FSOpenFile: %d",ret2); + log_string(socket_log, buffer, BYTE_LOG_STR); + } + }else{ + __os_snprintf(buffer, sizeof(buffer), "error on FSOpenFile: %d",ret); + log_string(socket_log, buffer, BYTE_LOG_STR); + final_result = -1; + } + } + } + if(FSCloseDir(pClient, pCmd, dir_handle, error) < FS_STATUS_OK){ + if(DEBUG_LOG) log_string(socket_log, "error on FSCloseDir()", BYTE_LOG_STR); + } + }else{ + log_string(socket_log, "error on FSOpenDir()", BYTE_LOG_STR); + final_result = -1; + } + return final_result; +} + +/************************** + Injection functions +**************************/ + +void injectSaveData(void *pClient, void *pCmd,long persistentID,int error){ + char logbuffer[255]; + /* + Allocate buffer for injection + */ + int buf_size = BUFFER_SIZE; + char * pBuffer; + int failed = 0; + do{ + buf_size -= BUFFER_SIZE_STEPS; + if(buf_size < 0){ + log_string(socket_log, "error on buffer allocation", BYTE_LOG_STR); + failed = 1; + break; + } + pBuffer = (char *)memalign(0x40,buf_size); + if(pBuffer) memset(pBuffer, 0x00, buf_size); + }while(!pBuffer); + + if(!failed){ + char buffer[60]; + __os_snprintf(buffer, sizeof(buffer), "allocated %d bytes",buf_size); + log_string(socket_log, buffer, BYTE_LOG_STR); + int result = 0; + int mask = 0; + if((result = saviine_start_injection(socket_saviine, persistentID,&mask))){ + if((mask & MASK_USER) == MASK_USER){ + char savepath[20]; + __os_snprintf(savepath, sizeof(savepath), "/vol/save/%08x",persistentID); + __os_snprintf(logbuffer, sizeof(logbuffer), "injecting new userdata in %08x",persistentID); + log_string(socket_log, logbuffer, BYTE_LOG_STR); + log_string(socket_log, "deleting user save", BYTE_LOG_STR); + if(remove_files_in_dir(pClient,pCmd,savepath,0) == -1){ + failed = 1; + }else{ + /* + Inject Save + */ + result = injectFiles(pClient,pCmd,savepath,"/",savepath,pBuffer,buf_size,error); + doFlushOrRollback(pClient,pCmd,result,savepath); + } + } + if((mask & MASK_COMMON) == MASK_COMMON && !failed){ + char * commonDir = "/vol/save/common"; + + if((mask & MASK_COMMON_CLEAN) == MASK_COMMON_CLEAN){ + log_string(socket_log, "deleting common save", BYTE_LOG_STR); + if(remove_files_in_dir(pClient,pCmd,commonDir,0) == -1){ + failed = 1; + } + } + if(!failed){ + /* + Inject common + */ + result = injectFiles(pClient,pCmd,commonDir,"/",commonDir,pBuffer,buf_size,error); + doFlushOrRollback(pClient,pCmd,result,commonDir); + } + } + if(!saviine_end_injection(socket_saviine)) if(DEBUG_LOG) log_string(socket_log, "saviine_end_injection() failed", BYTE_LOG_STR); + if(DEBUG_LOG)log_string(socket_log, "end of injection", BYTE_LOG_STR); + }else{ + log_string(socket_log, "saviine_start_injection() failed", BYTE_LOG_STR); + } + free(pBuffer); + } +} + +int injectFiles(void *pClient, void *pCmd, char * path,char * relativepath, char * basepath, char * pBuffer, int buffer_size, int error){ + int failed = 0; + int filesinjected = 0; + int type = 0; + log_string(socket_log, "injecting files", BYTE_LOG_STR); + char namebuffer[255]; + char logbuffer[255]; + int filesize = 0; + + if(!failed){ + while(saviine_readdir(socket_saviine,path,namebuffer, &type,&filesize) && !failed){ + if(DEBUG_LOG)log_string(socket_log, "got a file", BYTE_LOG_STR); + char newpath[strlen(path) + 1 + strlen(namebuffer) + 1]; + __os_snprintf(newpath, sizeof(newpath), "%s/%s",path,namebuffer); + if(type == BYTE_FILE){ + __os_snprintf(logbuffer, sizeof(logbuffer), "file: %s%s size: %d",relativepath,namebuffer,filesize); + log_string(socket_log, logbuffer, BYTE_LOG_STR); + + __os_snprintf(logbuffer, sizeof(logbuffer), "newpath: %s ",newpath); + log_string(socket_log, logbuffer, BYTE_LOG_STR); + + if(DEBUG_LOG) log_string(socket_log, "downloading it", BYTE_LOG_STR); + + int handle = 10; + if(FSOpenFile(pClient, pCmd, newpath,"w+",&handle,error) >= FS_STATUS_OK){ + if(DEBUG_LOG) log_string(socket_log, "file opened and created", BYTE_LOG_STR); + + if(filesize > 0){ + failed = doInjectForFile(pClient,pCmd,handle,newpath,filesize,basepath,pBuffer,buffer_size); + if(failed == 2) // trying it again if the journal was full + failed = doInjectForFile(pClient,pCmd,handle,newpath,filesize,basepath,pBuffer,buffer_size); + }else{ + if(DEBUG_LOG) log_string(socket_log, "filesize is 0", BYTE_LOG_STR); + } + + if((FSCloseFile (pClient, pCmd, handle, error)) < FS_STATUS_OK){ + log_string(socket_log, "FSCloseFile failed", BYTE_LOG_STR); + failed = 1; + } + }else{ + log_string(socket_log, "opening the file failed", BYTE_LOG_STR); + failed = 1; + } + if(!failed) filesinjected++; + }else if( type == BYTE_FOLDER){ + __os_snprintf(logbuffer, sizeof(logbuffer), "dir: %s",namebuffer); + log_string(socket_log, logbuffer, BYTE_LOG_STR); + if(DEBUG_LOG) log_string(socket_log, newpath, BYTE_LOG_STR); + int ret = 0; + if((ret = FSMakeDir(pClient, pCmd, newpath, -1)) == FS_STATUS_OK || ret == FS_STATUS_EXISTS ){ + char op_offset[strlen(relativepath) + strlen(namebuffer)+ 1 + 1]; + __os_snprintf(op_offset, sizeof(op_offset), "%s%s/",relativepath,namebuffer); + int injectedsub = injectFiles(pClient, pCmd, newpath,op_offset,basepath,pBuffer,buffer_size,error); + if(injectedsub == -1){ + failed = 1; + }else{ + filesinjected += injectedsub; + } + }else{ + log_string(socket_log, "folder creation failed", BYTE_LOG_STR); + failed = 1; + } + } + } + if(failed) return -1; + else return filesinjected; + }else{ + return -1; + } +} + +int doInjectForFile(void * pClient, void * pCmd,int handle,char * filepath,int filesize, char * basepath,void * pBuffer,int buf_size){ + int failed = 0; + int myhandle; + int ret = 0; + char logbuffer[255]; + if(DEBUG_LOG)__os_snprintf(logbuffer, sizeof(logbuffer), "cafiine_fopen %s",filepath); + if(DEBUG_LOG) log_string(socket_log, logbuffer, BYTE_LOG_STR); + + if((cafiine_fopen(socket_saviine, &ret, filepath, "r", &myhandle)) == 0 && ret == FS_STATUS_OK){ + if(DEBUG_LOG)__os_snprintf(logbuffer, sizeof(logbuffer), "cafiine_fopen with handle %d",myhandle); + if(DEBUG_LOG) log_string(socket_log, logbuffer, BYTE_LOG_STR); + int retsize = 0; + int pos = 0; + while(pos < filesize){ + if(DEBUG_LOG) log_string(socket_log, "reading", BYTE_LOG_STR); + if(cafiine_fread(socket_saviine, &retsize, pBuffer, buf_size , myhandle) == FS_STATUS_OK){ + if(DEBUG_LOG)__os_snprintf(logbuffer, sizeof(logbuffer), "got %d",retsize); + if(DEBUG_LOG) log_string(socket_log, logbuffer, BYTE_LOG_STR); + int fwrite = 0; + if((fwrite = FSWriteFile(pClient, pCmd, pBuffer,sizeof(char),retsize,handle,0,0x0200)) >= FS_STATUS_OK){ + if(DEBUG_LOG)__os_snprintf(logbuffer, sizeof(logbuffer), "wrote %d",retsize); + if(DEBUG_LOG) log_string(socket_log, logbuffer, BYTE_LOG_STR); + }else{ + if(fwrite == FS_STATUS_JOURNAL_FULL || fwrite == FS_STATUS_STORAGE_FULL){ + log_string(socket_log, "journal or storage is full, flushing it now.", BYTE_LOG_STR); + if(FSFlushQuota(pClient,pCmd,basepath,FS_RET_ALL_ERROR) == FS_STATUS_OK){ + log_string(socket_log, "success", BYTE_LOG_STR); + failed = 2; + break; + }else{ + log_string(socket_log, "failed", BYTE_LOG_STR); + failed = 1; + break; + } + + } + __os_snprintf(logbuffer, sizeof(logbuffer), "my_FSWriteFile failed with error: %d",fwrite); + log_string(socket_log, logbuffer, BYTE_LOG_STR); + //log_string(socket_log, "error while FSWriteFile", BYTE_LOG_STR); + failed = 1; + break; + } + if(DEBUG_LOG)__os_snprintf(logbuffer, sizeof(logbuffer), "old p %d new p %d",pos,pos+retsize); + if(DEBUG_LOG) log_string(socket_log, logbuffer, BYTE_LOG_STR); + pos += retsize; + }else{ + log_string(socket_log, "error while recieving file", BYTE_LOG_STR); + failed = 1; + break; + } + } + + int result = 0; + if((cafiine_fclose(socket_saviine, &result, myhandle,0)) == 0 && result == FS_STATUS_OK){ + if(DEBUG_LOG) log_string(socket_log, "cafiine_fclose success", BYTE_LOG_STR); + }else{ + log_string(socket_log, "cafiine_fclose failed", BYTE_LOG_STR); + failed = 1; + } + + + }else{ + log_string(socket_log, "cafiine_fopen failed", BYTE_LOG_STR); + failed = 1; + } + return failed; +} + +/************************* + Util functions +**************************/ + +/*flush if result != -1*/ + +void doFlushOrRollback(void *pClient, void *pCmd,int result,char *savepath){ + char logbuffer[50 + strlen(savepath)]; + if(result != -1){ + __os_snprintf(logbuffer, sizeof(logbuffer), "injected %d files",result); + log_string(socket_log, logbuffer, BYTE_LOG_STR); + log_string(socket_log, "Flushing data now", BYTE_LOG_STR); + if(FSFlushQuota(pClient,pCmd,savepath,FS_RET_ALL_ERROR) == FS_STATUS_OK){ + log_string(socket_log, "success", BYTE_LOG_STR); + }else{ + log_string(socket_log, "failed", BYTE_LOG_STR); + } + }else{ + log_string(socket_log, "injection failed, trying to restore the data", BYTE_LOG_STR); + if(FSRollbackQuota(pClient,pCmd,savepath,FS_RET_ALL_ERROR) == FS_STATUS_OK){ + log_string(socket_log, "rollback done", BYTE_LOG_STR); + }else{ + log_string(socket_log, "rollback failed", BYTE_LOG_STR); + } + } +} + +void init_Save(unsigned char slotNo){ + int (*SAVEInit)(); + int (*SAVEInitSaveDir)(unsigned char accountSlotNo); + unsigned int save_handle; + OSDynLoad_Acquire("nn_save.rpl", &save_handle); + OSDynLoad_FindExport(save_handle, 0, "SAVEInit", (void **)&SAVEInit); + OSDynLoad_FindExport(save_handle, 0, "SAVEInitSaveDir", (void **)&SAVEInitSaveDir); + SAVEInit(); + if(DEBUG_LOG) log_string(socket_log, "saveinit done", BYTE_LOG_STR); + SAVEInitSaveDir(slotNo); + if(DEBUG_LOG) log_string(socket_log, "SAVEInitSaveDir done", BYTE_LOG_STR); + SAVEInitSaveDir(255U); + if(DEBUG_LOG) log_string(socket_log, "SAVEInitSaveDir 2 done", BYTE_LOG_STR); +} + +long getPesistentID(unsigned char * slotno){ + unsigned int nn_act_handle; + unsigned long (*GetPersistentIdEx)(unsigned char); + int (*GetSlotNo)(void); + void (*nn_Initialize)(void); + void (*nn_Finalize)(void); + OSDynLoad_Acquire("nn_act.rpl", &nn_act_handle); + OSDynLoad_FindExport(nn_act_handle, 0, "GetPersistentIdEx__Q2_2nn3actFUc", (void **)&GetPersistentIdEx); + OSDynLoad_FindExport(nn_act_handle, 0, "GetSlotNo__Q2_2nn3actFv", (void **)&GetSlotNo); + OSDynLoad_FindExport(nn_act_handle, 0, "Initialize__Q2_2nn3actFv", (void **)&nn_Initialize); + OSDynLoad_FindExport(nn_act_handle, 0, "Finalize__Q2_2nn3actFv", (void **)&nn_Finalize); + + nn_Initialize(); // To be sure that it is really Initialized + + *slotno = GetSlotNo(); + + long idlong = GetPersistentIdEx(*slotno); + + nn_Finalize(); //must be called an equal number of times to nn_Initialize + return idlong; +} + +int remove_files_in_dir(void * pClient,void * pCmd, char * path, int handle){ + int ret = 0; + int my_handle = handle +1; + char buffer[strlen(path) + 50]; + if ((ret = FSOpenDir(pClient, pCmd, path, &handle, FS_RET_ALL_ERROR)) == FS_STATUS_OK){ + __os_snprintf(buffer, sizeof(buffer), "remove files in dir %s",path); + log_string(socket_log, buffer, BYTE_LOG_STR); + FSDirEntry dir_entry; + while (FSReadDir(pClient, pCmd, handle, &dir_entry, FS_RET_ALL_ERROR) == FS_STATUS_OK) + { + char full_path[strlen(path) + 1 + strlen(dir_entry.name) +1]; + __os_snprintf(full_path, sizeof(full_path), "%s/%s",path,dir_entry.name); + if((dir_entry.stat.flag&FS_STAT_FLAG_IS_DIRECTORY) == FS_STAT_FLAG_IS_DIRECTORY){ + if(DEBUG_LOG) log_string(socket_log, "recursive deletion", BYTE_LOG_STR); + if(remove_files_in_dir(pClient,pCmd,full_path,my_handle) == -1) return -1; + + } + char buffer[strlen(full_path) + 50]; + __os_snprintf(buffer, sizeof(buffer), "deleting %s",full_path); + log_string(socket_log, buffer, BYTE_LOG_STR); + if((ret = FSRemove(pClient,pCmd,full_path,FS_RET_ALL_ERROR)) < FS_STATUS_OK){ + __os_snprintf(buffer, sizeof(buffer), "error: %d on removing %s",ret,full_path); + log_string(socket_log, buffer, BYTE_LOG_STR); + return -1; + } + + } + if((FSCloseDir(pClient, pCmd, handle, FS_RET_NO_ERROR)) < FS_STATUS_OK ){ + log_string(socket_log, "error while closing dir", BYTE_LOG_STR); + return -1; + } + }else{ + __os_snprintf(buffer, sizeof(buffer), "error: %d on opening %s",ret,path); + log_string(socket_log, buffer, BYTE_LOG_STR); + return -1; + } + return 0; +} + +void ResetDumper(void) +{ + socket_saviine = -1; + socket_log = -1; + + // reset RPX table on every launch of system menu + rpxRplTableInit(); +} + +void SetServerIp(u32 ip) +{ + serverIpAddress = ip; +} + +u32 GetServerIp(void) +{ + return serverIpAddress; +} diff --git a/src/discdumper.h b/src/discdumper.h new file mode 100644 index 0000000..9da6b3f --- /dev/null +++ b/src/discdumper.h @@ -0,0 +1,36 @@ +#ifndef _DISCDUMPER_H_ +#define _DISCDUMPER_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct { + unsigned char tag; + unsigned int length; + unsigned char data[0]; +} __attribute__((packed)) SendData; + + +long getPesistentID(unsigned char * slotno); +void handle_saves(void *pClient, void *pCmd,int error); +void dumpSavaData(void *pClient, void *pCmd,long persistentID,int error); +int dump_dir(void *pClient, void *pCmd, char *path, void * pBuffer, int size,int error, int handle); +void injectSaveData(void *pClient, void *pCmd,long persistentID,int error); +int injectFiles(void *pClient, void *pCmd, char * path,char * relativepath, char * basepath, char * pBuffer, int buffer_size, int error); +int doInjectForFile(void * pClient, void * pCmd,int handle,char * filepath,int filesize, char * basepath,void * pBuffer,int buf_size); +void doFlushOrRollback(void *pClient, void *pCmd,int result,char *savepath); +void init_Save(unsigned char slotNo); +long getPesistentID(unsigned char * slotno); +int remove_files_in_dir(void * pClient,void * pCmd, char * path, int handle); +void StartDumper(void); +void ResetDumper(void); + +void SetServerIp(u32 ip); +u32 GetServerIp(void); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/dynamic_libs/aoc_functions.c b/src/dynamic_libs/aoc_functions.c new file mode 100644 index 0000000..e3449e7 --- /dev/null +++ b/src/dynamic_libs/aoc_functions.c @@ -0,0 +1,49 @@ +/**************************************************************************** + * Copyright (C) 2015 + * by Dimok + * + * This software is provided 'as-is', without any express or implied + * warranty. In no event will the authors be held liable for any + * damages arising from the use of this software. + * + * Permission is granted to anyone to use this software for any + * purpose, including commercial applications, and to alter it and + * redistribute it freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you + * must not claim that you wrote the original software. If you use + * this software in a product, an acknowledgment in the product + * documentation would be appreciated but is not required. + * + * 2. Altered source versions must be plainly marked as such, and + * must not be misrepresented as being the original software. + * + * 3. This notice may not be removed or altered from any source + * distribution. + ***************************************************************************/ +#include "os_functions.h" + +EXPORT_DECL(s32, AOC_Initialize, void); +EXPORT_DECL(s32, AOC_Finalize, void); +EXPORT_DECL(u32, AOC_CalculateWorkBufferSize, u32 num_titles); +EXPORT_DECL(s32, AOC_ListTitle, u32 * num_titles, void * titles, u32 max_titles, void * buffer, u32 buffer_size); +EXPORT_DECL(s32, AOC_OpenTitle, char* aoc_path, void * title, void * buffer, u32 buffer_size); +EXPORT_DECL(s32, AOC_CloseTitle, void * title); + +void InitAocFunctionPointers(void) +{ + unsigned int aoc_handle = 0; + OSDynLoad_Acquire("nn_aoc.rpl", &aoc_handle); + + if(aoc_handle == 0) + return; + + //! assigning those is not mandatory and it does not always work to load them + OSDynLoad_FindExport(aoc_handle, 0, "AOC_Initialize", &AOC_Initialize); + OSDynLoad_FindExport(aoc_handle, 0, "AOC_Finalize", &AOC_Finalize); + OSDynLoad_FindExport(aoc_handle, 0, "AOC_CalculateWorkBufferSize", &AOC_CalculateWorkBufferSize); + OSDynLoad_FindExport(aoc_handle, 0, "AOC_ListTitle", &AOC_ListTitle); + OSDynLoad_FindExport(aoc_handle, 0, "AOC_OpenTitle", &AOC_OpenTitle); + OSDynLoad_FindExport(aoc_handle, 0, "AOC_CloseTitle", &AOC_CloseTitle); +} + diff --git a/src/dynamic_libs/aoc_functions.h b/src/dynamic_libs/aoc_functions.h new file mode 100644 index 0000000..9eff6b1 --- /dev/null +++ b/src/dynamic_libs/aoc_functions.h @@ -0,0 +1,46 @@ +/**************************************************************************** + * Copyright (C) 2015 + * by Dimok + * + * This software is provided 'as-is', without any express or implied + * warranty. In no event will the authors be held liable for any + * damages arising from the use of this software. + * + * Permission is granted to anyone to use this software for any + * purpose, including commercial applications, and to alter it and + * redistribute it freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you + * must not claim that you wrote the original software. If you use + * this software in a product, an acknowledgment in the product + * documentation would be appreciated but is not required. + * + * 2. Altered source versions must be plainly marked as such, and + * must not be misrepresented as being the original software. + * + * 3. This notice may not be removed or altered from any source + * distribution. + ***************************************************************************/ +#ifndef __AOC_FUNCTIONS_H_ +#define __AOC_FUNCTIONS_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#define AOC_TITLE_SIZE 104 + +void InitAocFunctionPointers(void); + +extern s32 (* AOC_Initialize)(void); +extern s32 (* AOC_Finalize)(void); +extern u32 (* AOC_CalculateWorkBufferSize)(u32 num_titles); +extern s32 (* AOC_ListTitle)(u32 * num_titles, void * titles, u32 max_titles, void * buffer, u32 buffer_size); +extern s32 (* AOC_OpenTitle)(char* aoc_path, void * title, void * buffer, u32 buffer_size); +extern s32 (* AOC_CloseTitle)(void * title); + +#ifdef __cplusplus +} +#endif + +#endif // __SYS_FUNCTIONS_H_ diff --git a/src/dynamic_libs/ax_functions.c b/src/dynamic_libs/ax_functions.c new file mode 100644 index 0000000..d84d6f8 --- /dev/null +++ b/src/dynamic_libs/ax_functions.c @@ -0,0 +1,74 @@ +/**************************************************************************** + * Copyright (C) 2015 + * by Dimok + * + * This software is provided 'as-is', without any express or implied + * warranty. In no event will the authors be held liable for any + * damages arising from the use of this software. + * + * Permission is granted to anyone to use this software for any + * purpose, including commercial applications, and to alter it and + * redistribute it freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you + * must not claim that you wrote the original software. If you use + * this software in a product, an acknowledgment in the product + * documentation would be appreciated but is not required. + * + * 2. Altered source versions must be plainly marked as such, and + * must not be misrepresented as being the original software. + * + * 3. This notice may not be removed or altered from any source + * distribution. + ***************************************************************************/ +#include "os_functions.h" +#include "ax_functions.h" + +EXPORT_DECL(void, AXInitWithParams, u32 * params); +EXPORT_DECL(void, AXQuit, void); +EXPORT_DECL(u32, AXGetInputSamplesPerSec, void); +EXPORT_DECL(u32, AXGetInputSamplesPerFrame, void); +EXPORT_DECL(s32, AXVoiceBegin, void *v); +EXPORT_DECL(s32, AXVoiceEnd, void *v); +EXPORT_DECL(void, AXSetVoiceType, void *v, u16 type); +EXPORT_DECL(void, AXSetVoiceOffsets, void *v, const void *buf); +EXPORT_DECL(void, AXSetVoiceSrcType, void *v, u32 type); +EXPORT_DECL(void, AXSetVoiceVe, void *v, const void *vol); +EXPORT_DECL(s32, AXSetVoiceDeviceMix, void *v, s32 device, u32 id, void *mix); +EXPORT_DECL(void, AXSetVoiceState, void *v, u16 state); +EXPORT_DECL(void, AXSetVoiceSrc, void *v, const void *src); +EXPORT_DECL(s32, AXSetVoiceSrcRatio, void *v,f32 ratio) +EXPORT_DECL(void *, AXAcquireVoice, u32 prio, void * callback, u32 arg); +EXPORT_DECL(void, AXFreeVoice, void *v); +EXPORT_DECL(void, AXRegisterFrameCallback, void * callback); +EXPORT_DECL(u32, AXGetVoiceLoopCount, void *v); +EXPORT_DECL(void, AXSetVoiceEndOffset, void *v, u32 offset); +EXPORT_DECL(void, AXSetVoiceLoopOffset, void *v, u32 offset); + +void InitAXFunctionPointers(void) +{ + unsigned int *funcPointer = 0; + unsigned int sound_handle; + OSDynLoad_Acquire("sndcore2.rpl", &sound_handle); + + OS_FIND_EXPORT(sound_handle, AXInitWithParams); + OS_FIND_EXPORT(sound_handle, AXQuit); + OS_FIND_EXPORT(sound_handle, AXGetInputSamplesPerSec); + OS_FIND_EXPORT(sound_handle, AXVoiceBegin); + OS_FIND_EXPORT(sound_handle, AXVoiceEnd); + OS_FIND_EXPORT(sound_handle, AXSetVoiceType); + OS_FIND_EXPORT(sound_handle, AXSetVoiceOffsets); + OS_FIND_EXPORT(sound_handle, AXSetVoiceSrcType); + OS_FIND_EXPORT(sound_handle, AXSetVoiceVe); + OS_FIND_EXPORT(sound_handle, AXSetVoiceDeviceMix); + OS_FIND_EXPORT(sound_handle, AXSetVoiceState); + OS_FIND_EXPORT(sound_handle, AXSetVoiceSrc); + OS_FIND_EXPORT(sound_handle, AXSetVoiceSrcRatio); + OS_FIND_EXPORT(sound_handle, AXAcquireVoice); + OS_FIND_EXPORT(sound_handle, AXFreeVoice); + OS_FIND_EXPORT(sound_handle, AXRegisterFrameCallback); + OS_FIND_EXPORT(sound_handle, AXGetVoiceLoopCount); + OS_FIND_EXPORT(sound_handle, AXSetVoiceEndOffset); + OS_FIND_EXPORT(sound_handle, AXSetVoiceLoopOffset); +} + diff --git a/src/dynamic_libs/ax_functions.h b/src/dynamic_libs/ax_functions.h new file mode 100644 index 0000000..df9647c --- /dev/null +++ b/src/dynamic_libs/ax_functions.h @@ -0,0 +1,59 @@ +/**************************************************************************** + * Copyright (C) 2015 + * by Dimok + * + * This software is provided 'as-is', without any express or implied + * warranty. In no event will the authors be held liable for any + * damages arising from the use of this software. + * + * Permission is granted to anyone to use this software for any + * purpose, including commercial applications, and to alter it and + * redistribute it freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you + * must not claim that you wrote the original software. If you use + * this software in a product, an acknowledgment in the product + * documentation would be appreciated but is not required. + * + * 2. Altered source versions must be plainly marked as such, and + * must not be misrepresented as being the original software. + * + * 3. This notice may not be removed or altered from any source + * distribution. + ***************************************************************************/ +#ifndef __AX_FUNCTIONS_H_ +#define __AX_FUNCTIONS_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +void InitAXFunctionPointers(void); + +extern void (* AXInitWithParams)(u32 * params); +extern void (* AXQuit)(void); +extern u32 (* AXGetInputSamplesPerSec)(void); +extern s32 (* AXVoiceBegin)(void *v); +extern s32 (* AXVoiceEnd)(void *v); +extern void (* AXSetVoiceType)(void *v, u16 type); +extern void (* AXSetVoiceOffsets)(void *v, const void *buf); +extern void (* AXSetVoiceSrcType)(void *v, u32 type); +extern void (* AXSetVoiceVe)(void *v, const void *vol); +extern s32 (* AXSetVoiceDeviceMix)(void *v, s32 device, u32 id, void *mix); +extern void (* AXSetVoiceState)(void *v, u16 state); +extern void (* AXSetVoiceSrc)(void *v, const void *src); +extern s32 (* AXSetVoiceSrcRatio)(void *v, f32 ratio); +extern void * (* AXAcquireVoice)(u32 prio, void * callback, u32 arg); +extern void (* AXFreeVoice)(void *v); +extern void (* AXRegisterFrameCallback)(void * callback); +extern u32 (* AXGetVoiceLoopCount)(void * v); +extern void (* AXSetVoiceEndOffset)(void * v, u32 offset); +extern void (* AXSetVoiceLoopOffset)(void * v, u32 offset); + +#ifdef __cplusplus +} +#endif + +#endif // __VPAD_FUNCTIONS_H_ diff --git a/src/dynamic_libs/fs_functions.c b/src/dynamic_libs/fs_functions.c new file mode 100644 index 0000000..af8856e --- /dev/null +++ b/src/dynamic_libs/fs_functions.c @@ -0,0 +1,126 @@ +/**************************************************************************** + * Copyright (C) 2015 + * by Dimok + * + * This software is provided 'as-is', without any express or implied + * warranty. In no event will the authors be held liable for any + * damages arising from the use of this software. + * + * Permission is granted to anyone to use this software for any + * purpose, including commercial applications, and to alter it and + * redistribute it freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you + * must not claim that you wrote the original software. If you use + * this software in a product, an acknowledgment in the product + * documentation would be appreciated but is not required. + * + * 2. Altered source versions must be plainly marked as such, and + * must not be misrepresented as being the original software. + * + * 3. This notice may not be removed or altered from any source + * distribution. + ***************************************************************************/ +#include "fs_functions.h" +#include "os_functions.h" +#include "utils/utils.h" + +EXPORT_DECL(int, FSInit, void); +EXPORT_DECL(int, FSShutdown, void); +EXPORT_DECL(int, FSAddClientEx, void *pClient, int unk_zero_param, int errHandling); +EXPORT_DECL(int, FSDelClient, void *pClient); +EXPORT_DECL(void, FSInitCmdBlock, void *pCmd); +EXPORT_DECL(int, FSGetMountSource, void *pClient, void *pCmd, int type, void *source, int errHandling); + +EXPORT_DECL(int, FSMount, void *pClient, void *pCmd, void *source, char *target, uint32_t bytes, int errHandling); +EXPORT_DECL(int, FSUnmount, void *pClient, void *pCmd, const char *target, int errHandling); + +EXPORT_DECL(int, FSGetStat, void *pClient, void *pCmd, const char *path, FSStat *stats, int errHandling); +EXPORT_DECL(int, FSGetStatAsync, void *pClient, void *pCmd, const char *path, void *stats, int error, void *asyncParams); +EXPORT_DECL(int, FSRename, void *pClient, void *pCmd, const char *oldPath, const char *newPath, int error); +EXPORT_DECL(int, FSRenameAsync, void *pClient, void *pCmd, const char *oldPath, const char *newPath, int error, void *asyncParams); +EXPORT_DECL(int, FSRemove, void *pClient, void *pCmd, const char *path, int error); +EXPORT_DECL(int, FSRemoveAsync, void *pClient, void *pCmd, const char *path, int error, void *asyncParams); +EXPORT_DECL(int, FSFlushQuota, void *pClient, void *pCmd, const char* path, int error); +EXPORT_DECL(int, FSFlushQuotaAsync, void *pClient, void *pCmd, const char *path, int error, void *asyncParams); +EXPORT_DECL(int, FSGetFreeSpaceSize, void *pClient, void *pCmd, const char *path, uint64_t *returnedFreeSize, int error); +EXPORT_DECL(int, FSGetFreeSpaceSizeAsync, void *pClient, void *pCmd, const char *path, uint64_t *returnedFreeSize, int error, void *asyncParams); +EXPORT_DECL(int, FSRollbackQuota, void *pClient, void *pCmd, const char *path, int error); +EXPORT_DECL(int, FSRollbackQuotaAsync, void *pClient, void *pCmd, const char *path, int error, void *asyncParams); + +EXPORT_DECL(int, FSOpenDir, void *pClient, void *pCmd, const char *path, int *dh, int errHandling); +EXPORT_DECL(int, FSOpenDirAsync, void *pClient, void* pCmd, const char *path, int *handle, int error, void *asyncParams); +EXPORT_DECL(int, FSReadDir, void *pClient, void *pCmd, int dh, FSDirEntry *dir_entry, int errHandling); +EXPORT_DECL(int, FSRewindDir, void *pClient, void *pCmd, int dh, int errHandling); +EXPORT_DECL(int, FSCloseDir, void *pClient, void *pCmd, int dh, int errHandling); +EXPORT_DECL(int, FSChangeDir, void *pClient, void *pCmd, const char *path, int errHandling); +EXPORT_DECL(int, FSChangeDirAsync, void *pClient, void *pCmd, const char *path, int error, void *asyncParams); +EXPORT_DECL(int, FSMakeDir, void *pClient, void *pCmd, const char *path, int errHandling); +EXPORT_DECL(int, FSMakeDirAsync, void *pClient, void *pCmd, const char *path, int error, void *asyncParams); + +EXPORT_DECL(int, FSOpenFile, void *pClient, void *pCmd, const char *path, const char *mode, int *fd, int errHandling); +EXPORT_DECL(int, FSOpenFileAsync, void *pClient, void *pCmd, const char *path, const char *mode, int *handle, int error, const void *asyncParams); +EXPORT_DECL(int, FSReadFile, void *pClient, void *pCmd, void *buffer, int size, int count, int fd, int flag, int errHandling); +EXPORT_DECL(int, FSCloseFile, void *pClient, void *pCmd, int fd, int errHandling); + +EXPORT_DECL(int, FSFlushFile, void *pClient, void *pCmd, int fd, int error); +EXPORT_DECL(int, FSTruncateFile, void *pClient, void *pCmd, int fd, int error); +EXPORT_DECL(int, FSGetStatFile, void *pClient, void *pCmd, int fd, void *buffer, int error); +EXPORT_DECL(int, FSSetPosFile, void *pClient, void *pCmd, int fd, int pos, int error); +EXPORT_DECL(int, FSWriteFile, void *pClient, void *pCmd, const void *source, int block_size, int block_count, int fd, int flag, int error); + +EXPORT_DECL(int, FSBindMount, void *pClient, void *pCmd, char *source, char *target, int error); +EXPORT_DECL(int, FSBindUnmount, void *pClient, void *pCmd, char *target, int error); + +void InitFSFunctionPointers(void) +{ + unsigned int *funcPointer = 0; + + OS_FIND_EXPORT(coreinit_handle, FSInit); + OS_FIND_EXPORT(coreinit_handle, FSShutdown); + OS_FIND_EXPORT(coreinit_handle, FSAddClientEx); + OS_FIND_EXPORT(coreinit_handle, FSDelClient); + OS_FIND_EXPORT(coreinit_handle, FSInitCmdBlock); + OS_FIND_EXPORT(coreinit_handle, FSGetMountSource); + + OS_FIND_EXPORT(coreinit_handle, FSMount); + OS_FIND_EXPORT(coreinit_handle, FSUnmount); + + OS_FIND_EXPORT(coreinit_handle, FSGetStat); + OS_FIND_EXPORT(coreinit_handle, FSGetStatAsync); + OS_FIND_EXPORT(coreinit_handle, FSRename); + OS_FIND_EXPORT(coreinit_handle, FSRenameAsync); + OS_FIND_EXPORT(coreinit_handle, FSRemove); + OS_FIND_EXPORT(coreinit_handle, FSRemoveAsync); + OS_FIND_EXPORT(coreinit_handle, FSFlushQuota); + OS_FIND_EXPORT(coreinit_handle, FSFlushQuotaAsync); + OS_FIND_EXPORT(coreinit_handle, FSGetFreeSpaceSize); + OS_FIND_EXPORT(coreinit_handle, FSGetFreeSpaceSizeAsync); + OS_FIND_EXPORT(coreinit_handle, FSRollbackQuota); + OS_FIND_EXPORT(coreinit_handle, FSRollbackQuotaAsync); + + OS_FIND_EXPORT(coreinit_handle, FSOpenDir); + OS_FIND_EXPORT(coreinit_handle, FSOpenDirAsync); + OS_FIND_EXPORT(coreinit_handle, FSReadDir); + OS_FIND_EXPORT(coreinit_handle, FSRewindDir); + OS_FIND_EXPORT(coreinit_handle, FSCloseDir); + OS_FIND_EXPORT(coreinit_handle, FSChangeDir); + OS_FIND_EXPORT(coreinit_handle, FSChangeDirAsync); + OS_FIND_EXPORT(coreinit_handle, FSMakeDir); + OS_FIND_EXPORT(coreinit_handle, FSMakeDirAsync); + + + OS_FIND_EXPORT(coreinit_handle, FSOpenFile); + OS_FIND_EXPORT(coreinit_handle, FSOpenFileAsync); + OS_FIND_EXPORT(coreinit_handle, FSReadFile); + OS_FIND_EXPORT(coreinit_handle, FSCloseFile); + + OS_FIND_EXPORT(coreinit_handle, FSFlushFile); + OS_FIND_EXPORT(coreinit_handle, FSTruncateFile); + OS_FIND_EXPORT(coreinit_handle, FSGetStatFile); + OS_FIND_EXPORT(coreinit_handle, FSSetPosFile); + OS_FIND_EXPORT(coreinit_handle, FSWriteFile); + + OS_FIND_EXPORT(coreinit_handle, FSBindMount); + OS_FIND_EXPORT(coreinit_handle, FSBindUnmount); +} diff --git a/src/dynamic_libs/fs_functions.h b/src/dynamic_libs/fs_functions.h new file mode 100644 index 0000000..6721a45 --- /dev/null +++ b/src/dynamic_libs/fs_functions.h @@ -0,0 +1,90 @@ +/**************************************************************************** + * Copyright (C) 2015 + * by Dimok + * + * This software is provided 'as-is', without any express or implied + * warranty. In no event will the authors be held liable for any + * damages arising from the use of this software. + * + * Permission is granted to anyone to use this software for any + * purpose, including commercial applications, and to alter it and + * redistribute it freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you + * must not claim that you wrote the original software. If you use + * this software in a product, an acknowledgment in the product + * documentation would be appreciated but is not required. + * + * 2. Altered source versions must be plainly marked as such, and + * must not be misrepresented as being the original software. + * + * 3. This notice may not be removed or altered from any source + * distribution. + ***************************************************************************/ +#ifndef __FS_FUNCTIONS_H_ +#define __FS_FUNCTIONS_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include "common/fs_defs.h" + +void InitFSFunctionPointers(void); + +extern int (* FSInit)(void); +extern int (* FSShutdown)(void); +extern int (* FSAddClientEx)(void *pClient, int unk_zero_param, int errHandling); +extern int (* FSDelClient)(void *pClient); +extern void (* FSInitCmdBlock)(void *pCmd); +extern int (* FSGetMountSource)(void *pClient, void *pCmd, int type, void *source, int errHandling); + +extern int (* FSMount)(void *pClient, void *pCmd, void *source, char *target, uint32_t bytes, int errHandling); +extern int (* FSUnmount)(void *pClient, void *pCmd, const char *target, int errHandling); +extern int (* FSRename)(void *pClient, void *pCmd, const char *oldPath, const char *newPath, int error); +extern int (* FSRenameAsync)(void *pClient, void *pCmd, const char *oldPath, const char *newPath, int error, void *asyncParams); +extern int (* FSRemove)(void *pClient, void *pCmd, const char *path, int error); +extern int (* FSRemoveAsync)(void *pClient, void *pCmd, const char *path, int error, void *asyncParams); + +extern int (* FSGetStat)(void *pClient, void *pCmd, const char *path, FSStat *stats, int errHandling); +extern int (* FSGetStatAsync)(void *pClient, void *pCmd, const char *path, void *stats, int error, void *asyncParams); +extern int (* FSRename)(void *pClient, void *pCmd, const char *oldPath, const char *newPath, int error); +extern int (* FSRenameAsync)(void *pClient, void *pCmd, const char *oldPath, const char *newPath, int error, void *asyncParams); +extern int (* FSRemove)(void *pClient, void *pCmd, const char *path, int error); +extern int (* FSRemoveAsync)(void *pClient, void *pCmd, const char *path, int error, void *asyncParams); +extern int (* FSFlushQuota)(void *pClient, void *pCmd, const char* path, int error); +extern int (* FSFlushQuotaAsync)(void *pClient, void *pCmd, const char *path, int error, void *asyncParams); +extern int (* FSGetFreeSpaceSize)(void *pClient, void *pCmd, const char *path, uint64_t *returnedFreeSize, int error); +extern int (* FSGetFreeSpaceSizeAsync)(void *pClient, void *pCmd, const char *path, uint64_t *returnedFreeSize, int error, void *asyncParams); +extern int (* FSRollbackQuota)(void *pClient, void *pCmd, const char *path, int error); +extern int (* FSRollbackQuotaAsync)(void *pClient, void *pCmd, const char *path, int error, void *asyncParams); + +extern int (* FSOpenDir)(void *pClient, void *pCmd, const char *path, int *dh, int errHandling); +extern int (* FSOpenDirAsync)(void *pClient, void* pCmd, const char *path, int *handle, int error, void *asyncParams); +extern int (* FSReadDir)(void *pClient, void *pCmd, int dh, FSDirEntry *dir_entry, int errHandling); +extern int (* FSRewindDir)(void *pClient, void *pCmd, int dh, int errHandling); +extern int (* FSCloseDir)(void *pClient, void *pCmd, int dh, int errHandling); +extern int (* FSChangeDir)(void *pClient, void *pCmd, const char *path, int errHandling); +extern int (* FSChangeDirAsync)(void *pClient, void *pCmd, const char *path, int error, void *asyncParams); +extern int (* FSMakeDir)(void *pClient, void *pCmd, const char *path, int errHandling); +extern int (* FSMakeDirAsync)(void *pClient, void *pCmd, const char *path, int error, void *asyncParams); + +extern int (* FSOpenFile)(void *pClient, void *pCmd, const char *path, const char *mode, int *fd, int errHandling); +extern int (* FSOpenFileAsync)(void *pClient, void *pCmd, const char *path, const char *mode, int *handle, int error, const void *asyncParams); +extern int (* FSReadFile)(void *pClient, void *pCmd, void *buffer, int size, int count, int fd, int flag, int errHandling); +extern int (* FSCloseFile)(void *pClient, void *pCmd, int fd, int errHandling); + +extern int (* FSFlushFile)(void *pClient, void *pCmd, int fd, int error); +extern int (* FSTruncateFile)(void *pClient, void *pCmd, int fd, int error); +extern int (* FSGetStatFile)(void *pClient, void *pCmd, int fd, void *buffer, int error); +extern int (* FSSetPosFile)(void *pClient, void *pCmd, int fd, int pos, int error); +extern int (* FSWriteFile)(void *pClient, void *pCmd, const void *source, int block_size, int block_count, int fd, int flag, int error); + +extern int (* FSBindMount)(void *pClient, void *pCmd, char *source, char *target, int error); +extern int (* FSBindUnmount)(void *pClient, void *pCmd, char *target, int error); + +#ifdef __cplusplus +} +#endif + +#endif // __FS_FUNCTIONS_H_ diff --git a/src/dynamic_libs/gx2_functions.c b/src/dynamic_libs/gx2_functions.c new file mode 100644 index 0000000..b9bf671 --- /dev/null +++ b/src/dynamic_libs/gx2_functions.c @@ -0,0 +1,162 @@ +/**************************************************************************** + * Copyright (C) 2015 + * by Dimok + * + * This software is provided 'as-is', without any express or implied + * warranty. In no event will the authors be held liable for any + * damages arising from the use of this software. + * + * Permission is granted to anyone to use this software for any + * purpose, including commercial applications, and to alter it and + * redistribute it freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you + * must not claim that you wrote the original software. If you use + * this software in a product, an acknowledgment in the product + * documentation would be appreciated but is not required. + * + * 2. Altered source versions must be plainly marked as such, and + * must not be misrepresented as being the original software. + * + * 3. This notice may not be removed or altered from any source + * distribution. + ***************************************************************************/ +#include "os_functions.h" +#include "gx2_types.h" +#include "utils/utils.h" + +EXPORT_DECL(void, GX2Init, u32 * init_attribs); +EXPORT_DECL(void, GX2Shutdown, void); +EXPORT_DECL(void, GX2Flush, void); +EXPORT_DECL(s32, GX2GetMainCoreId, void) ; +EXPORT_DECL(s32, GX2DrawDone, void); +EXPORT_DECL(void, GX2ClearColor, GX2ColorBuffer *colorBuffer, f32 r, f32 g, f32 b, f32 a); +EXPORT_DECL(void, GX2SetViewport, f32 x, f32 y, f32 w, f32 h, f32 nearZ, f32 farZ); +EXPORT_DECL(void, GX2SetScissor, u32 x_orig, u32 y_orig, u32 wd, u32 ht); +EXPORT_DECL(void, GX2SetContextState, const GX2ContextState* state); +EXPORT_DECL(void, GX2DrawEx, s32 primitive_type, u32 count, u32 first_vertex, u32 instances_count); +EXPORT_DECL(void, GX2DrawIndexedEx, s32 primitive_type, u32 count, s32 index_format, const void* idx, u32 first_vertex, u32 instances_count); +EXPORT_DECL(void, GX2ClearDepthStencilEx, GX2DepthBuffer *depthBuffer, f32 depth_value, u8 stencil_value, s32 clear_mode); +EXPORT_DECL(void, GX2CopyColorBufferToScanBuffer, const GX2ColorBuffer *colorBuffer, s32 scan_target); +EXPORT_DECL(void, GX2SwapScanBuffers, void); +EXPORT_DECL(void, GX2SetTVEnable, s32 enable); +EXPORT_DECL(void, GX2SetSwapInterval, u32 swap_interval); +EXPORT_DECL(u32, GX2GetSwapInterval, void); +EXPORT_DECL(void, GX2WaitForVsync, void); +EXPORT_DECL(void, GX2CalcTVSize, s32 tv_render_mode, s32 format, s32 buffering_mode, u32 * size, s32 * scale_needed); +EXPORT_DECL(void, GX2Invalidate, s32 invalidate_type, void * ptr, u32 buffer_size); +EXPORT_DECL(void, GX2SetTVBuffer, void *buffer, u32 buffer_size, s32 tv_render_mode, s32 format, s32 buffering_mode); +EXPORT_DECL(void, GX2CalcSurfaceSizeAndAlignment, GX2Surface *surface); +EXPORT_DECL(void, GX2InitDepthBufferRegs, GX2DepthBuffer *depthBuffer); +EXPORT_DECL(void, GX2InitColorBufferRegs, GX2ColorBuffer *colorBuffer); +EXPORT_DECL(void, GX2CalcColorBufferAuxInfo, GX2ColorBuffer *colorBuffer, u32 *size, u32 *align); +EXPORT_DECL(void, GX2CalcDepthBufferHiZInfo, GX2DepthBuffer *depthBuffer, u32 *size, u32 *align); +EXPORT_DECL(void, GX2InitDepthBufferHiZEnable, GX2DepthBuffer *depthBuffer, s32 hiZ_enable); +EXPORT_DECL(void, GX2SetupContextStateEx, GX2ContextState* state, s32 enable_profiling); +EXPORT_DECL(void, GX2SetColorBuffer, const GX2ColorBuffer *colorBuffer, s32 target); +EXPORT_DECL(void, GX2SetDepthBuffer, const GX2DepthBuffer *depthBuffer); +EXPORT_DECL(void, GX2SetAttribBuffer, u32 attr_index, u32 attr_size, u32 stride, const void* attr); +EXPORT_DECL(void, GX2InitTextureRegs, GX2Texture *texture); +EXPORT_DECL(void, GX2InitSampler, GX2Sampler *sampler, s32 tex_clamp, s32 min_mag_filter); +EXPORT_DECL(u32, GX2CalcFetchShaderSizeEx, u32 num_attrib, s32 fetch_shader_type, s32 tessellation_mode); +EXPORT_DECL(void, GX2InitFetchShaderEx, GX2FetchShader* fs, void* fs_buffer, u32 count, const GX2AttribStream* attribs, s32 fetch_shader_type, s32 tessellation_mode); +EXPORT_DECL(void, GX2SetFetchShader, const GX2FetchShader* fs); +EXPORT_DECL(void, GX2SetVertexUniformReg, u32 offset, u32 count, const void *values); +EXPORT_DECL(void, GX2SetPixelUniformReg, u32 offset, u32 count, const void *values); +EXPORT_DECL(void, GX2SetPixelTexture, const GX2Texture *texture, u32 texture_hw_location); +EXPORT_DECL(void, GX2SetVertexTexture, const GX2Texture *texture, u32 texture_hw_location); +EXPORT_DECL(void, GX2SetPixelSampler, const GX2Sampler *sampler, u32 sampler_hw_location); +EXPORT_DECL(void, GX2SetVertexSampler, const GX2Sampler *sampler, u32 sampler_hw_location); +EXPORT_DECL(void, GX2SetPixelShader, const GX2PixelShader* pixelShader); +EXPORT_DECL(void, GX2SetVertexShader, const GX2VertexShader* vertexShader); +EXPORT_DECL(void, GX2InitSamplerZMFilter, GX2Sampler *sampler, s32 z_filter, s32 mip_filter); +EXPORT_DECL(void, GX2SetColorControl, s32 lop, u8 blend_enable_mask, s32 enable_multi_write, s32 enable_color_buffer); +EXPORT_DECL(void, GX2SetDepthOnlyControl, s32 enable_depth, s32 enable_depth_write, s32 depth_comp_function); +EXPORT_DECL(void, GX2SetBlendControl, s32 target, s32 color_src_blend, s32 color_dst_blend, s32 color_combine, s32 separate_alpha_blend, s32 alpha_src_blend, s32 alpha_dst_blend, s32 alpha_combine); +EXPORT_DECL(void, GX2CalcDRCSize, s32 drc_mode, s32 format, s32 buffering_mode, u32 *size, s32 *scale_needed); +EXPORT_DECL(void, GX2SetDRCBuffer, void *buffer, u32 buffer_size, s32 drc_mode, s32 surface_format, s32 buffering_mode); +EXPORT_DECL(void, GX2SetDRCScale, u32 width, u32 height); +EXPORT_DECL(void, GX2SetDRCEnable, s32 enable); +EXPORT_DECL(void, GX2SetPolygonControl, s32 front_face_mode, s32 cull_front, s32 cull_back, s32 enable_mode, s32 mode_font, s32 mode_back, s32 poly_offset_front, s32 poly_offset_back, s32 point_line_offset); +EXPORT_DECL(void, GX2SetCullOnlyControl, s32 front_face_mode, s32 cull_front, s32 cull_back); +EXPORT_DECL(void, GX2SetDepthStencilControl, s32 enable_depth_test, s32 enable_depth_write, s32 depth_comp_function, s32 stencil_test_enable, s32 back_stencil_enable, + s32 font_stencil_func, s32 front_stencil_z_pass, s32 front_stencil_z_fail, s32 front_stencil_fail, + s32 back_stencil_func, s32 back_stencil_z_pass, s32 back_stencil_z_fail, s32 back_stencil_fail); +EXPORT_DECL(void, GX2SetStencilMask, u8 mask_front, u8 write_mask_front, u8 ref_front, u8 mask_back, u8 write_mask_back, u8 ref_back); +EXPORT_DECL(void, GX2SetLineWidth, f32 width); +EXPORT_DECL(void, GX2SetTVGamma, f32 val); +EXPORT_DECL(void, GX2SetDRCGamma, f32 gam); +EXPORT_DECL(s32, GX2GetSystemTVScanMode, void); +EXPORT_DECL(s32, GX2GetSystemDRCScanMode, void); +EXPORT_DECL(void, GX2RSetAllocator, void * (* allocFunc)(u32, u32, u32), void (* freeFunc)(u32, void*)); + + +void InitGX2FunctionPointers(void) +{ + unsigned int *funcPointer = 0; + unsigned int gx2_handle; + OSDynLoad_Acquire("gx2.rpl", &gx2_handle); + + OS_FIND_EXPORT(gx2_handle, GX2Init); + OS_FIND_EXPORT(gx2_handle, GX2Shutdown); + OS_FIND_EXPORT(gx2_handle, GX2Flush); + OS_FIND_EXPORT(gx2_handle, GX2GetMainCoreId); + OS_FIND_EXPORT(gx2_handle, GX2DrawDone); + OS_FIND_EXPORT(gx2_handle, GX2ClearColor); + OS_FIND_EXPORT(gx2_handle, GX2SetViewport); + OS_FIND_EXPORT(gx2_handle, GX2SetScissor); + OS_FIND_EXPORT(gx2_handle, GX2SetContextState); + OS_FIND_EXPORT(gx2_handle, GX2DrawEx); + OS_FIND_EXPORT(gx2_handle, GX2DrawIndexedEx); + OS_FIND_EXPORT(gx2_handle, GX2ClearDepthStencilEx); + OS_FIND_EXPORT(gx2_handle, GX2CopyColorBufferToScanBuffer); + OS_FIND_EXPORT(gx2_handle, GX2SwapScanBuffers); + OS_FIND_EXPORT(gx2_handle, GX2SetTVEnable); + OS_FIND_EXPORT(gx2_handle, GX2SetSwapInterval); + OS_FIND_EXPORT(gx2_handle, GX2GetSwapInterval); + OS_FIND_EXPORT(gx2_handle, GX2WaitForVsync); + OS_FIND_EXPORT(gx2_handle, GX2CalcTVSize); + OS_FIND_EXPORT(gx2_handle, GX2Invalidate); + OS_FIND_EXPORT(gx2_handle, GX2SetTVBuffer); + OS_FIND_EXPORT(gx2_handle, GX2CalcSurfaceSizeAndAlignment); + OS_FIND_EXPORT(gx2_handle, GX2InitDepthBufferRegs); + OS_FIND_EXPORT(gx2_handle, GX2InitColorBufferRegs); + OS_FIND_EXPORT(gx2_handle, GX2CalcColorBufferAuxInfo); + OS_FIND_EXPORT(gx2_handle, GX2CalcDepthBufferHiZInfo); + OS_FIND_EXPORT(gx2_handle, GX2InitDepthBufferHiZEnable); + OS_FIND_EXPORT(gx2_handle, GX2SetupContextStateEx); + OS_FIND_EXPORT(gx2_handle, GX2SetColorBuffer); + OS_FIND_EXPORT(gx2_handle, GX2SetDepthBuffer); + OS_FIND_EXPORT(gx2_handle, GX2SetAttribBuffer); + OS_FIND_EXPORT(gx2_handle, GX2InitTextureRegs); + OS_FIND_EXPORT(gx2_handle, GX2InitSampler); + OS_FIND_EXPORT(gx2_handle, GX2CalcFetchShaderSizeEx); + OS_FIND_EXPORT(gx2_handle, GX2InitFetchShaderEx); + OS_FIND_EXPORT(gx2_handle, GX2SetFetchShader); + OS_FIND_EXPORT(gx2_handle, GX2SetVertexUniformReg); + OS_FIND_EXPORT(gx2_handle, GX2SetPixelUniformReg); + OS_FIND_EXPORT(gx2_handle, GX2SetPixelTexture); + OS_FIND_EXPORT(gx2_handle, GX2SetVertexTexture); + OS_FIND_EXPORT(gx2_handle, GX2SetPixelSampler); + OS_FIND_EXPORT(gx2_handle, GX2SetVertexSampler); + OS_FIND_EXPORT(gx2_handle, GX2SetPixelShader); + OS_FIND_EXPORT(gx2_handle, GX2SetVertexShader); + OS_FIND_EXPORT(gx2_handle, GX2InitSamplerZMFilter); + OS_FIND_EXPORT(gx2_handle, GX2SetColorControl); + OS_FIND_EXPORT(gx2_handle, GX2SetDepthOnlyControl); + OS_FIND_EXPORT(gx2_handle, GX2SetBlendControl); + OS_FIND_EXPORT(gx2_handle, GX2CalcDRCSize); + OS_FIND_EXPORT(gx2_handle, GX2SetDRCBuffer); + OS_FIND_EXPORT(gx2_handle, GX2SetDRCScale); + OS_FIND_EXPORT(gx2_handle, GX2SetDRCEnable); + OS_FIND_EXPORT(gx2_handle, GX2SetPolygonControl); + OS_FIND_EXPORT(gx2_handle, GX2SetCullOnlyControl); + OS_FIND_EXPORT(gx2_handle, GX2SetDepthStencilControl); + OS_FIND_EXPORT(gx2_handle, GX2SetStencilMask); + OS_FIND_EXPORT(gx2_handle, GX2SetLineWidth); + OS_FIND_EXPORT(gx2_handle, GX2SetDRCGamma); + OS_FIND_EXPORT(gx2_handle, GX2SetTVGamma); + OS_FIND_EXPORT(gx2_handle, GX2GetSystemTVScanMode); + OS_FIND_EXPORT(gx2_handle, GX2GetSystemDRCScanMode); + OS_FIND_EXPORT(gx2_handle, GX2RSetAllocator); +} diff --git a/src/dynamic_libs/gx2_functions.h b/src/dynamic_libs/gx2_functions.h new file mode 100644 index 0000000..1737833 --- /dev/null +++ b/src/dynamic_libs/gx2_functions.h @@ -0,0 +1,205 @@ +/**************************************************************************** + * Copyright (C) 2015 + * by Dimok + * + * This software is provided 'as-is', without any express or implied + * warranty. In no event will the authors be held liable for any + * damages arising from the use of this software. + * + * Permission is granted to anyone to use this software for any + * purpose, including commercial applications, and to alter it and + * redistribute it freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you + * must not claim that you wrote the original software. If you use + * this software in a product, an acknowledgment in the product + * documentation would be appreciated but is not required. + * + * 2. Altered source versions must be plainly marked as such, and + * must not be misrepresented as being the original software. + * + * 3. This notice may not be removed or altered from any source + * distribution. + ***************************************************************************/ +#ifndef __GX2_FUNCTIONS_H_ +#define __GX2_FUNCTIONS_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include "gx2_types.h" + +void InitGX2FunctionPointers(void); + +extern void (* GX2Init)(u32 * init_attribs); +extern void (* GX2Shutdown)(void); +extern void (* GX2Flush)(void); +extern s32 (* GX2GetMainCoreId)(void) ; +extern s32 (* GX2DrawDone)(void); +extern void (* GX2ClearColor)(GX2ColorBuffer *colorBuffer, f32 r, f32 g, f32 b, f32 a); +extern void (* GX2SetViewport)(f32 x, f32 y, f32 w, f32 h, f32 nearZ, f32 farZ); +extern void (* GX2SetScissor)(u32 x_orig, u32 y_orig, u32 wd, u32 ht); +extern void (* GX2SetContextState)(const GX2ContextState* state); +extern void (* GX2DrawEx)(s32 primitive_type, u32 count, u32 first_vertex, u32 instances_count); +extern void (* GX2DrawIndexedEx)(s32 primitive_type, u32 count, s32 index_format, const void* idx, u32 first_vertex, u32 instances_count); +extern void (* GX2ClearDepthStencilEx)(GX2DepthBuffer *depthBuffer, f32 depth_value, u8 stencil_value, s32 clear_mode); +extern void (* GX2CopyColorBufferToScanBuffer)(const GX2ColorBuffer *colorBuffer, s32 scan_target); +extern void (* GX2SwapScanBuffers)(void); +extern void (* GX2SetTVEnable)(s32 enable); +extern void (* GX2SetSwapInterval)(u32 swap_interval); +extern u32 (* GX2GetSwapInterval)(void); +extern void (* GX2WaitForVsync)(void); +extern void (* GX2CalcTVSize)(s32 tv_render_mode, s32 format, s32 buffering_mode, u32 * size, s32 * scale_needed); +extern void (* GX2Invalidate)(s32 invalidate_type, void * ptr, u32 buffer_size); +extern void (* GX2SetTVBuffer)(void *buffer, u32 buffer_size, s32 tv_render_mode, s32 format, s32 buffering_mode); +extern void (* GX2CalcSurfaceSizeAndAlignment)(GX2Surface *surface); +extern void (* GX2InitDepthBufferRegs)(GX2DepthBuffer *depthBuffer); +extern void (* GX2InitColorBufferRegs)(GX2ColorBuffer *colorBuffer); +extern void (* GX2CalcColorBufferAuxInfo)(GX2ColorBuffer *colorBuffer, u32 *size, u32 *align); +extern void (* GX2CalcDepthBufferHiZInfo)(GX2DepthBuffer *depthBuffer, u32 *size, u32 *align); +extern void (* GX2InitDepthBufferHiZEnable)(GX2DepthBuffer *depthBuffer, s32 hiZ_enable); +extern void (* GX2SetupContextStateEx)(GX2ContextState* state, s32 enable_profiling); +extern void (* GX2SetColorBuffer)(const GX2ColorBuffer *colorBuffer, s32 target); +extern void (* GX2SetDepthBuffer)(const GX2DepthBuffer *depthBuffer); +extern void (* GX2SetAttribBuffer)(u32 attr_index, u32 attr_size, u32 stride, const void* attr); +extern void (* GX2InitTextureRegs)(GX2Texture *texture); +extern void (* GX2InitSampler)(GX2Sampler *sampler, s32 tex_clamp, s32 min_mag_filter); +extern u32 (* GX2CalcFetchShaderSizeEx)(u32 num_attrib, s32 fetch_shader_type, s32 tessellation_mode); +extern void (* GX2InitFetchShaderEx)(GX2FetchShader* fs, void* fs_buffer, u32 count, const GX2AttribStream* attribs, s32 fetch_shader_type, s32 tessellation_mode); +extern void (* GX2SetFetchShader)(const GX2FetchShader* fs); +extern void (* GX2SetVertexUniformReg)(u32 offset, u32 count, const void *values); +extern void (* GX2SetPixelUniformReg)(u32 offset, u32 count, const void *values); +extern void (* GX2SetPixelTexture)(const GX2Texture *texture, u32 texture_hw_location); +extern void (* GX2SetVertexTexture)(const GX2Texture *texture, u32 texture_hw_location); +extern void (* GX2SetPixelSampler)(const GX2Sampler *sampler, u32 sampler_hw_location); +extern void (* GX2SetVertexSampler)(const GX2Sampler *sampler, u32 sampler_hw_location); +extern void (* GX2SetPixelShader)(const GX2PixelShader* pixelShader); +extern void (* GX2SetVertexShader)(const GX2VertexShader* vertexShader); +extern void (* GX2InitSamplerZMFilter)(GX2Sampler *sampler, s32 z_filter, s32 mip_filter); +extern void (* GX2SetColorControl)(s32 lop, u8 blend_enable_mask, s32 enable_multi_write, s32 enable_color_buffer); +extern void (* GX2SetDepthOnlyControl)(s32 enable_depth, s32 enable_depth_write, s32 depth_comp_function); +extern void (* GX2SetBlendControl)(s32 target, s32 color_src_blend, s32 color_dst_blend, s32 color_combine, s32 separate_alpha_blend, s32 alpha_src_blend, s32 alpha_dst_blend, s32 alpha_combine); +extern void (* GX2CalcDRCSize)(s32 drc_mode, s32 format, s32 buffering_mode, u32 *size, s32 *scale_needed); +extern void (* GX2SetDRCBuffer)(void *buffer, u32 buffer_size, s32 drc_mode, s32 surface_format, s32 buffering_mode); +extern void (* GX2SetDRCScale)(u32 width, u32 height); +extern void (* GX2SetDRCEnable)(s32 enable); +extern void (* GX2SetPolygonControl)(s32 front_face_mode, s32 cull_front, s32 cull_back, s32 enable_mode, s32 mode_font, s32 mode_back, s32 poly_offset_front, s32 poly_offset_back, s32 point_line_offset); +extern void (* GX2SetCullOnlyControl)(s32 front_face_mode, s32 cull_front, s32 cull_back); +extern void (* GX2SetDepthStencilControl)(s32 enable_depth_test, s32 enable_depth_write, s32 depth_comp_function, s32 stencil_test_enable, s32 back_stencil_enable, + s32 font_stencil_func, s32 front_stencil_z_pass, s32 front_stencil_z_fail, s32 front_stencil_fail, + s32 back_stencil_func, s32 back_stencil_z_pass, s32 back_stencil_z_fail, s32 back_stencil_fail); +extern void (* GX2SetStencilMask)(u8 mask_front, u8 write_mask_front, u8 ref_front, u8 mask_back, u8 write_mask_back, u8 ref_back); +extern void (* GX2SetLineWidth)(f32 width); +extern void (* GX2SetTVGamma)(f32 val); +extern void (* GX2SetDRCGamma)(f32 val); +extern s32 (* GX2GetSystemTVScanMode)(void); +extern s32 (* GX2GetSystemDRCScanMode)(void); +extern void (* GX2RSetAllocator)(void * (*allocFunc)(u32, u32, u32), void (*freeFunc)(u32, void*)); + +static inline void GX2InitDepthBuffer(GX2DepthBuffer *depthBuffer, s32 dimension, u32 width, u32 height, u32 depth, s32 format, s32 aa) +{ + depthBuffer->surface.dimension = dimension; + depthBuffer->surface.width = width; + depthBuffer->surface.height = height; + depthBuffer->surface.depth = depth; + depthBuffer->surface.num_mips = 1; + depthBuffer->surface.format = format; + depthBuffer->surface.aa = aa; + depthBuffer->surface.use = ((format==GX2_SURFACE_FORMAT_D_D24_S8_UNORM) || (format==GX2_SURFACE_FORMAT_D_D24_S8_FLOAT)) ? GX2_SURFACE_USE_DEPTH_BUFFER : GX2_SURFACE_USE_DEPTH_BUFFER_TEXTURE; + depthBuffer->surface.tile = GX2_TILE_MODE_DEFAULT; + depthBuffer->surface.swizzle = 0; + depthBuffer->view_mip = 0; + depthBuffer->view_first_slice = 0; + depthBuffer->view_slices_count = depth; + depthBuffer->clear_depth = 1.0f; + depthBuffer->clear_stencil = 0; + depthBuffer->hiZ_data = NULL; + depthBuffer->hiZ_size = 0; + GX2CalcSurfaceSizeAndAlignment(&depthBuffer->surface); + GX2InitDepthBufferRegs(depthBuffer); +} + +static inline void GX2InitColorBuffer(GX2ColorBuffer *colorBuffer, s32 dimension, u32 width, u32 height, u32 depth, s32 format, s32 aa) +{ + colorBuffer->surface.dimension = dimension; + colorBuffer->surface.width = width; + colorBuffer->surface.height = height; + colorBuffer->surface.depth = depth; + colorBuffer->surface.num_mips = 1; + colorBuffer->surface.format = format; + colorBuffer->surface.aa = aa; + colorBuffer->surface.use = GX2_SURFACE_USE_COLOR_BUFFER_TEXTURE_FTV; + colorBuffer->surface.image_size = 0; + colorBuffer->surface.image_data = NULL; + colorBuffer->surface.mip_size = 0; + colorBuffer->surface.mip_data = NULL; + colorBuffer->surface.tile = GX2_TILE_MODE_DEFAULT; + colorBuffer->surface.swizzle = 0; + colorBuffer->surface.align = 0; + colorBuffer->surface.pitch = 0; + u32 i; + for(i = 0; i < 13; i++) + colorBuffer->surface.mip_offset[i] = 0; + colorBuffer->view_mip = 0; + colorBuffer->view_first_slice = 0; + colorBuffer->view_slices_count = depth; + colorBuffer->aux_data = NULL; + colorBuffer->aux_size = 0; + for(i = 0; i < 5; i++) + colorBuffer->regs[i] = 0; + + GX2CalcSurfaceSizeAndAlignment(&colorBuffer->surface); + GX2InitColorBufferRegs(colorBuffer); +} + +static inline void GX2InitAttribStream(GX2AttribStream* attr, u32 location, u32 buffer, u32 offset, s32 format) +{ + attr->location = location; + attr->buffer = buffer; + attr->offset = offset; + attr->format = format; + attr->index_type = 0; + attr->divisor = 0; + attr->destination_selector = attribute_dest_comp_selector[format & 0xff]; + attr->endian_swap = GX2_ENDIANSWAP_DEFAULT; +} + +static inline void GX2InitTexture(GX2Texture *tex, u32 width, u32 height, u32 depth, u32 num_mips, s32 format, s32 dimension, s32 tile) +{ + tex->surface.dimension = dimension; + tex->surface.width = width; + tex->surface.height = height; + tex->surface.depth = depth; + tex->surface.num_mips = num_mips; + tex->surface.format = format; + tex->surface.aa = GX2_AA_MODE_1X; + tex->surface.use = GX2_SURFACE_USE_TEXTURE; + tex->surface.image_size = 0; + tex->surface.image_data = NULL; + tex->surface.mip_size = 0; + tex->surface.mip_data = NULL; + tex->surface.tile = tile; + tex->surface.swizzle = 0; + tex->surface.align = 0; + tex->surface.pitch = 0; + u32 i; + for(i = 0; i < 13; i++) + tex->surface.mip_offset[i] = 0; + tex->view_first_mip = 0; + tex->view_mips_count = num_mips; + tex->view_first_slice = 0; + tex->view_slices_count = depth; + tex->component_selector = texture_comp_selector[format & 0x3f]; + for(i = 0; i < 5; i++) + tex->regs[i] = 0; + + GX2CalcSurfaceSizeAndAlignment(&tex->surface); + GX2InitTextureRegs(tex); +} + +#ifdef __cplusplus +} +#endif + +#endif // __GX2_FUNCTIONS_H_ diff --git a/src/dynamic_libs/gx2_types.h b/src/dynamic_libs/gx2_types.h new file mode 100644 index 0000000..e292318 --- /dev/null +++ b/src/dynamic_libs/gx2_types.h @@ -0,0 +1,699 @@ +/**************************************************************************** + * Copyright (C) 2015 + * by Dimok + * + * This software is provided 'as-is', without any express or implied + * warranty. In no event will the authors be held liable for any + * damages arising from the use of this software. + * + * Permission is granted to anyone to use this software for any + * purpose, including commercial applications, and to alter it and + * redistribute it freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you + * must not claim that you wrote the original software. If you use + * this software in a product, an acknowledgment in the product + * documentation would be appreciated but is not required. + * + * 2. Altered source versions must be plainly marked as such, and + * must not be misrepresented as being the original software. + * + * 3. This notice may not be removed or altered from any source + * distribution. + ***************************************************************************/ +#ifndef _GX2_TYPES_H_ +#define _GX2_TYPES_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +//!----------------------------------------------------------------------------------------------------------------------- +//! Constants +//!----------------------------------------------------------------------------------------------------------------------- +#define GX2_COMMAND_BUFFER_SIZE 0x400000 +#define GX2_SCAN_BUFFER_ALIGNMENT 0x1000 +#define GX2_SHADER_ALIGNMENT 0x100 +#define GX2_CONTEXT_STATE_ALIGNMENT 0x100 +#define GX2_DISPLAY_LIST_ALIGNMENT 0x20 +#define GX2_VERTEX_BUFFER_ALIGNMENT 0x40 +#define GX2_INDEX_BUFFER_ALIGNMENT 0x20 + +#define GX2_CONTEXT_STATE_SIZE 0xA100 + +#define GX2_AUX_BUFFER_CLEAR_VALUE 0xCC + +//!----------------------------------------------------------------------------------------------------------------------- +//! Common +//!----------------------------------------------------------------------------------------------------------------------- +#define GX2_FALSE 0 +#define GX2_TRUE 1 +#define GX2_DISABLE 0 +#define GX2_ENABLE 1 + +//!----------------------------------------------------------------------------------------------------------------------- +//! GX2InitAttrib +//!----------------------------------------------------------------------------------------------------------------------- +#define GX2_INIT_ATTRIB_NULL 0 +#define GX2_INIT_ATTRIB_CB_BASE 1 +#define GX2_INIT_ATTRIB_CB_SIZE 2 +#define GX2_INIT_ATTRIB_ARGC 7 +#define GX2_INIT_ATTRIB_ARGV 8 + +//!----------------------------------------------------------------------------------------------------------------------- +//! GX2 compare functions +//!----------------------------------------------------------------------------------------------------------------------- +#define GX2_COMPARE_NEVER 0 +#define GX2_COMPARE_LESS 1 +#define GX2_COMPARE_EQUAL 2 +#define GX2_COMPARE_LEQUAL 3 +#define GX2_COMPARE_GREATER 4 +#define GX2_COMPARE_NOTEQUAL 5 +#define GX2_COMPARE_GEQUAL 6 +#define GX2_COMPARE_ALWAYS 7 + +//!----------------------------------------------------------------------------------------------------------------------- +//! GX2 stencil functions +//!----------------------------------------------------------------------------------------------------------------------- +#define GX2_STENCIL_KEEP 0 +#define GX2_STENCIL_ZERO 1 +#define GX2_STENCIL_REPLACE 2 +#define GX2_STENCIL_INCR 3 +#define GX2_STENCIL_DECR 4 +#define GX2_STENCIL_INVERT 5 +#define GX2_STENCIL_INCR_WRAP 6 +#define GX2_STENCIL_DECR_WRAP 7 + +//!----------------------------------------------------------------------------------------------------------------------- +//! GX2 logic op functions +//!----------------------------------------------------------------------------------------------------------------------- +#define GX2_LOGIC_OP_CLEAR 0x00 +#define GX2_LOGIC_OP_NOR 0x11 +#define GX2_LOGIC_OP_INVAND 0x22 +#define GX2_LOGIC_OP_INVCOPY 0x33 +#define GX2_LOGIC_OP_REVAND 0x44 +#define GX2_LOGIC_OP_INV 0x55 +#define GX2_LOGIC_OP_XOR 0x66 +#define GX2_LOGIC_OP_NAND 0x77 +#define GX2_LOGIC_OP_AND 0x88 +#define GX2_LOGIC_OP_EQUIV 0x99 +#define GX2_LOGIC_OP_NOOP 0xAA +#define GX2_LOGIC_OP_INVOR 0xBB +#define GX2_LOGIC_OP_COPY 0xCC +#define GX2_LOGIC_OP_REVOR 0xDD +#define GX2_LOGIC_OP_OR 0xEE +#define GX2_LOGIC_OP_SET 0xFF + +//!----------------------------------------------------------------------------------------------------------------------- +//! GX2 blend combination functions +//!----------------------------------------------------------------------------------------------------------------------- +#define GX2_BLEND_COMBINE_ADD 0x00 +#define GX2_BLEND_COMBINE_SRC_MINUS_DST 0x01 +#define GX2_BLEND_COMBINE_MIN 0x02 +#define GX2_BLEND_COMBINE_MAX 0x03 +#define GX2_BLEND_COMBINE_DST_MINUS_SRC 0x04 + +//!----------------------------------------------------------------------------------------------------------------------- +//! GX2 blend functions +//!----------------------------------------------------------------------------------------------------------------------- +#define GX2_BLEND_ZERO 0x00 +#define GX2_BLEND_ONE 0x01 +#define GX2_BLEND_SRC_ALPHA 0x04 +#define GX2_BLEND_ONE_MINUS_SRC_ALPHA 0x05 + +//!----------------------------------------------------------------------------------------------------------------------- +//! GX2 render targets +//!----------------------------------------------------------------------------------------------------------------------- +#define GX2_RENDER_TARGET_0 0 +#define GX2_RENDER_TARGET_1 1 +#define GX2_RENDER_TARGET_2 2 +#define GX2_RENDER_TARGET_3 3 +#define GX2_RENDER_TARGET_4 4 +#define GX2_RENDER_TARGET_5 5 +#define GX2_RENDER_TARGET_6 6 +#define GX2_RENDER_TARGET_7 7 + +//!----------------------------------------------------------------------------------------------------------------------- +//! GX2 cull modes +//!----------------------------------------------------------------------------------------------------------------------- +#define GX2_FRONT_FACE_CCW 0 +#define GX2_FRONT_FACE_CW 1 +//!----------------------------------------------------------------------------------------------------------------------- +//! GX2 polygon modes +//!----------------------------------------------------------------------------------------------------------------------- +#define GX2_POLYGON_MODE_POINT 0 +#define GX2_POLYGON_MODE_LINE 1 +#define GX2_POLYGON_MODE_TRIANGLE 2 + +//!----------------------------------------------------------------------------------------------------------------------- +//! GX2 special states +//!----------------------------------------------------------------------------------------------------------------------- +#define GX2_SPECIAL_STATE_CLEAR 0 +#define GX2_SPECIAL_STATE_CLEAR_HIZ 1 +#define GX2_SPECIAL_STATE_COPY 2 +#define GX2_SPECIAL_STATE_EXPAND_COLOR 3 +#define GX2_SPECIAL_STATE_EXPAND_DEPTH 4 +#define GX2_SPECIAL_STATE_CONVERT_DEPTH 5 +#define GX2_SPECIAL_STATE_CONVERT_AADEPTH 6 +#define GX2_SPECIAL_STATE_RESOLVE_COLOR 7 +#define GX2_SPECIAL_STATE_CLEAR_COLOR_AS_DEPTH 8 + +//!----------------------------------------------------------------------------------------------------------------------- +//! GX2 attribute formats +//!----------------------------------------------------------------------------------------------------------------------- +#define GX2_ATTRIB_FORMAT_8_UNORM 0x00000000 +#define GX2_ATTRIB_FORMAT_4_4_UNORM 0x00000001 +#define GX2_ATTRIB_FORMAT_16_UNORM 0x00000002 +#define GX2_ATTRIB_FORMAT_8_8_UNORM 0x00000004 +#define GX2_ATTRIB_FORMAT_16_16_UNORM 0x00000007 +#define GX2_ATTRIB_FORMAT_8_8_8_8_UNORM 0x0000000A +#define GX2_ATTRIB_FORMAT_10_10_10_2_UNORM 0x0000000B +#define GX2_ATTRIB_FORMAT_16_16_16_16_UNORM 0x0000000E + +#define GX2_ATTRIB_FORMAT_8_UINT 0x00000100 +#define GX2_ATTRIB_FORMAT_16_UINT 0x00000102 +#define GX2_ATTRIB_FORMAT_8_8_UINT 0x00000104 +#define GX2_ATTRIB_FORMAT_32_UINT 0x00000105 +#define GX2_ATTRIB_FORMAT_16_16_UINT 0x00000107 +#define GX2_ATTRIB_FORMAT_8_8_8_8_UINT 0x0000010A +#define GX2_ATTRIB_FORMAT_10_10_10_2_UINT 0x0000010B +#define GX2_ATTRIB_FORMAT_32_32_UINT 0x0000010C +#define GX2_ATTRIB_FORMAT_16_16_16_16_UINT 0x0000010E +#define GX2_ATTRIB_FORMAT_32_32_32_UINT 0x00000110 +#define GX2_ATTRIB_FORMAT_32_32_32_32_UINT 0x00000112 + +#define GX2_ATTRIB_FORMAT_8_SNORM 0x00000200 +#define GX2_ATTRIB_FORMAT_16_SNORM 0x00000202 +#define GX2_ATTRIB_FORMAT_8_8_SNORM 0x00000204 +#define GX2_ATTRIB_FORMAT_16_16_SNORM 0x00000207 +#define GX2_ATTRIB_FORMAT_8_8_8_8_SNORM 0x0000020A +#define GX2_ATTRIB_FORMAT_10_10_10_2_SNORM 0x0000020B +#define GX2_ATTRIB_FORMAT_16_16_16_16_SNORM 0x0000020E + +#define GX2_ATTRIB_FORMAT_8_SINT 0x00000300 +#define GX2_ATTRIB_FORMAT_16_SINT 0x00000303 +#define GX2_ATTRIB_FORMAT_8_8_SINT 0x00000304 +#define GX2_ATTRIB_FORMAT_32_SINT 0x00000305 +#define GX2_ATTRIB_FORMAT_16_16_SINT 0x00000307 +#define GX2_ATTRIB_FORMAT_8_8_8_8_SINT 0x0000030A +#define GX2_ATTRIB_FORMAT_10_10_10_2_SINT 0x0000030B +#define GX2_ATTRIB_FORMAT_32_32_SINT 0x0000030C +#define GX2_ATTRIB_FORMAT_16_16_16_16_SINT 0x0000030E +#define GX2_ATTRIB_FORMAT_32_32_32_SINT 0x00000310 +#define GX2_ATTRIB_FORMAT_32_32_32_32_SINT 0x00000312 + +#define GX2_ATTRIB_FORMAT_8_UINT_TO_FLOAT 0x00000800 +#define GX2_ATTRIB_FORMAT_16_UINT_TO_FLOAT 0x00000802 +#define GX2_ATTRIB_FORMAT_16_FLOAT 0x00000803 +#define GX2_ATTRIB_FORMAT_8_8_UINT_TO_FLOAT 0x00000804 +#define GX2_ATTRIB_FORMAT_32_FLOAT 0x00000806 +#define GX2_ATTRIB_FORMAT_16_16_UINT_TO_FLOAT 0x00000807 +#define GX2_ATTRIB_FORMAT_16_16_FLOAT 0x00000808 +#define GX2_ATTRIB_FORMAT_10_11_11_FLOAT 0x00000809 +#define GX2_ATTRIB_FORMAT_8_8_8_8_UINT_TO_FLOAT 0x0000080A +#define GX2_ATTRIB_FORMAT_32_32_FLOAT 0x0000080D +#define GX2_ATTRIB_FORMAT_16_16_16_16_UINT_TO_FLOAT 0x0000080E +#define GX2_ATTRIB_FORMAT_16_16_16_16_FLOAT 0x0000080F +#define GX2_ATTRIB_FORMAT_32_32_32_FLOAT 0x00000811 +#define GX2_ATTRIB_FORMAT_32_32_32_32_FLOAT 0x00000813 + +#define GX2_ATTRIB_FORMAT_8_SINT_TO_FLOAT 0x00000A00 +#define GX2_ATTRIB_FORMAT_16_SINT_TO_FLOAT 0x00000A02 +#define GX2_ATTRIB_FORMAT_8_8_SINT_TO_FLOAT 0x00000A04 +#define GX2_ATTRIB_FORMAT_16_16_SINT_TO_FLOAT 0x00000A07 +#define GX2_ATTRIB_FORMAT_8_8_8_8_SINT_TO_FLOAT 0x00000A0A +#define GX2_ATTRIB_FORMAT_16_16_16_16_SINT_TO_FLOAT 0x00000A0E + +//!----------------------------------------------------------------------------------------------------------------------- +//! GX2 shader modes +//!----------------------------------------------------------------------------------------------------------------------- +#define GX2_SHADER_MODE_UNIFORM_REGISTER 0 +#define GX2_SHADER_MODE_UNIFORM_BLOCK 1 +#define GX2_SHADER_MODE_GEOMETRY_SHADER 2 +#define GX2_SHADER_MODE_COMPUTE_SHADER 3 + +//!----------------------------------------------------------------------------------------------------------------------- +//! GX2 shader modes +//!----------------------------------------------------------------------------------------------------------------------- +#define GX2_COMP_SEL_NONE 0x04040405 +#define GX2_COMP_SEL_X001 0x00040405 +#define GX2_COMP_SEL_XY01 0x00010405 +#define GX2_COMP_SEL_XYZ1 0x00010205 +#define GX2_COMP_SEL_XYZW 0x00010203 +#define GX2_COMP_SEL_XXXX 0x00000000 +#define GX2_COMP_SEL_YYYY 0x01010101 +#define GX2_COMP_SEL_ZZZZ 0x02020202 +#define GX2_COMP_SEL_WWWW 0x03030303 +#define GX2_COMP_SEL_WZYX 0x03020100 +#define GX2_COMP_SEL_WXYZ 0x03000102 + +//!----------------------------------------------------------------------------------------------------------------------- +//! GX2 variable types +//!----------------------------------------------------------------------------------------------------------------------- +#define GX2_VAR_TYPE_VOID 0 +#define GX2_VAR_TYPE_BOOL 1 +#define GX2_VAR_TYPE_INT 2 +#define GX2_VAR_TYPE_UINT 3 +#define GX2_VAR_TYPE_FLOAT 4 +#define GX2_VAR_TYPE_DOUBLE 5 +#define GX2_VAR_TYPE_VEC2 9 +#define GX2_VAR_TYPE_VEC3 10 +#define GX2_VAR_TYPE_VEC4 11 +#define GX2_VAR_TYPE_MAT2 21 +#define GX2_VAR_TYPE_MAT3 25 +#define GX2_VAR_TYPE_MAT4 29 + +//!----------------------------------------------------------------------------------------------------------------------- +//! GX2 sample types +//!----------------------------------------------------------------------------------------------------------------------- +#define GX2_SAMPLER_TYPE_2D 1 + + +//!----------------------------------------------------------------------------------------------------------------------- +//! GX2 index formats +//!----------------------------------------------------------------------------------------------------------------------- +#define GX2_INDEX_FORMAT_U16 4 +#define GX2_INDEX_FORMAT_U32 9 + +//!----------------------------------------------------------------------------------------------------------------------- +//! GX2 primitive types +//!----------------------------------------------------------------------------------------------------------------------- +#define GX2_PRIMITIVE_POINTS 0x01 +#define GX2_PRIMITIVE_LINES 0x02 +#define GX2_PRIMITIVE_LINE_STRIP 0x03 +#define GX2_PRIMITIVE_TRIANGLES 0x04 +#define GX2_PRIMITIVE_TRIANGLE_FAN 0x05 +#define GX2_PRIMITIVE_TRIANGLE_STRIP 0x06 +#define GX2_PRIMITIVE_RECTS 0x11 +#define GX2_PRIMITIVE_QUADS 0x13 +#define GX2_PRIMITIVE_QUAD_STRIP 0x14 + +//!----------------------------------------------------------------------------------------------------------------------- +//! GX2 clear modes +//!----------------------------------------------------------------------------------------------------------------------- +#define GX2_CLEAR_DEPTH 0x01 +#define GX2_CLEAR_STENCIL 0x02 +#define GX2_CLEAR_BOTH (GX2_CLEAR_DEPTH | GX2_CLEAR_STENCIL) + +//!----------------------------------------------------------------------------------------------------------------------- +//! GX2 surface formats +//!----------------------------------------------------------------------------------------------------------------------- +#define GX2_SURFACE_FORMAT_TC_R8_UNORM 0x00000001 +#define GX2_SURFACE_FORMAT_T_R4_G4_UNORM 0x00000002 +#define GX2_SURFACE_FORMAT_TCD_R16_UNORM 0x00000005 +#define GX2_SURFACE_FORMAT_TC_R8_G8_UNORM 0x00000007 +#define GX2_SURFACE_FORMAT_TCS_R5_G6_B5_UNORM 0x00000008 +#define GX2_SURFACE_FORMAT_TC_R5_G5_B5_A1_UNORM 0x0000000a +#define GX2_SURFACE_FORMAT_TC_R4_G4_B4_A4_UNORM 0x0000000b +#define GX2_SURFACE_FORMAT_TC_A1_B5_G5_R5_UNORM 0x0000000c +#define GX2_SURFACE_FORMAT_TC_R16_G16_UNORM 0x0000000f +#define GX2_SURFACE_FORMAT_D_D24_S8_UNORM 0x00000011 +#define GX2_SURFACE_FORMAT_T_R24_UNORM_X8 0x00000011 +#define GX2_SURFACE_FORMAT_TCS_R10_G10_B10_A2_UNORM 0x00000019 +#define GX2_SURFACE_FORMAT_TCS_R8_G8_B8_A8_UNORM 0x0000001a +#define GX2_SURFACE_FORMAT_TCS_A2_B10_G10_R10_UNORM 0x0000001b +#define GX2_SURFACE_FORMAT_TC_R16_G16_B16_A16_UNORM 0x0000001f +#define GX2_SURFACE_FORMAT_T_BC1_UNORM 0x00000031 +#define GX2_SURFACE_FORMAT_T_BC2_UNORM 0x00000032 +#define GX2_SURFACE_FORMAT_T_BC3_UNORM 0x00000033 +#define GX2_SURFACE_FORMAT_T_BC4_UNORM 0x00000034 +#define GX2_SURFACE_FORMAT_T_BC5_UNORM 0x00000035 +#define GX2_SURFACE_FORMAT_T_NV12_UNORM 0x00000081 + +#define GX2_SURFACE_FORMAT_TC_R8_UINT 0x00000101 +#define GX2_SURFACE_FORMAT_TC_R16_UINT 0x00000105 +#define GX2_SURFACE_FORMAT_TC_R8_G8_UINT 0x00000107 +#define GX2_SURFACE_FORMAT_TC_R32_UINT 0x0000010d +#define GX2_SURFACE_FORMAT_TC_R16_G16_UINT 0x0000010f +#define GX2_SURFACE_FORMAT_T_X24_G8_UINT 0x00000111 +#define GX2_SURFACE_FORMAT_TC_R10_G10_B10_A2_UINT 0x00000119 +#define GX2_SURFACE_FORMAT_TC_R8_G8_B8_A8_UINT 0x0000011a +#define GX2_SURFACE_FORMAT_TC_A2_B10_G10_R10_UINT 0x0000011b +#define GX2_SURFACE_FORMAT_T_X32_G8_UINT_X24 0x0000011c +#define GX2_SURFACE_FORMAT_TC_R32_G32_UINT 0x0000011d +#define GX2_SURFACE_FORMAT_TC_R16_G16_B16_A16_UINT 0x0000011f +#define GX2_SURFACE_FORMAT_TC_R32_G32_B32_A32_UINT 0x00000122 + +#define GX2_SURFACE_FORMAT_TC_R8_SNORM 0x00000201 +#define GX2_SURFACE_FORMAT_TC_R16_SNORM 0x00000205 +#define GX2_SURFACE_FORMAT_TC_R8_G8_SNORM 0x00000207 +#define GX2_SURFACE_FORMAT_TC_R16_G16_SNORM 0x0000020f +#define GX2_SURFACE_FORMAT_T_R10_G10_B10_A2_SNORM 0x00000219 +#define GX2_SURFACE_FORMAT_TC_R10_G10_B10_A2_SNORM 0x00000219 +#define GX2_SURFACE_FORMAT_TC_R8_G8_B8_A8_SNORM 0x0000021a +#define GX2_SURFACE_FORMAT_TC_R16_G16_B16_A16_SNORM 0x0000021f +#define GX2_SURFACE_FORMAT_T_BC4_SNORM 0x00000234 +#define GX2_SURFACE_FORMAT_T_BC5_SNORM 0x00000235 + +#define GX2_SURFACE_FORMAT_TC_R8_SINT 0x00000301 +#define GX2_SURFACE_FORMAT_TC_R16_SINT 0x00000305 +#define GX2_SURFACE_FORMAT_TC_R8_G8_SINT 0x00000307 +#define GX2_SURFACE_FORMAT_TC_R32_SINT 0x0000030d +#define GX2_SURFACE_FORMAT_TC_R16_G16_SINT 0x0000030f +#define GX2_SURFACE_FORMAT_TC_R10_G10_B10_A2_SINT 0x00000319 +#define GX2_SURFACE_FORMAT_TC_R8_G8_B8_A8_SINT 0x0000031a +#define GX2_SURFACE_FORMAT_TC_R32_G32_SINT 0x0000031d +#define GX2_SURFACE_FORMAT_TC_R16_G16_B16_A16_SINT 0x0000031f +#define GX2_SURFACE_FORMAT_TC_R32_G32_B32_A32_SINT 0x00000322 + +#define GX2_SURFACE_FORMAT_TCS_R8_G8_B8_A8_SRGB 0x0000041a +#define GX2_SURFACE_FORMAT_T_BC1_SRGB 0x00000431 +#define GX2_SURFACE_FORMAT_T_BC2_SRGB 0x00000432 +#define GX2_SURFACE_FORMAT_T_BC3_SRGB 0x00000433 + +#define GX2_SURFACE_FORMAT_TC_R16_FLOAT 0x00000806 +#define GX2_SURFACE_FORMAT_TCD_R32_FLOAT 0x0000080e +#define GX2_SURFACE_FORMAT_TC_R16_G16_FLOAT 0x00000810 +#define GX2_SURFACE_FORMAT_D_D24_S8_FLOAT 0x00000811 +#define GX2_SURFACE_FORMAT_TC_R11_G11_B10_FLOAT 0x00000816 +#define GX2_SURFACE_FORMAT_D_D32_FLOAT_S8_UINT_X24 0x0000081c +#define GX2_SURFACE_FORMAT_T_R32_FLOAT_X8_X24 0x0000081c +#define GX2_SURFACE_FORMAT_TC_R32_G32_FLOAT 0x0000081e +#define GX2_SURFACE_FORMAT_TC_R16_G16_B16_A16_FLOAT 0x00000820 +#define GX2_SURFACE_FORMAT_TC_R32_G32_B32_A32_FLOAT 0x00000823 + +//!----------------------------------------------------------------------------------------------------------------------- +//! GX2 tile modes +//!----------------------------------------------------------------------------------------------------------------------- +#define GX2_TILE_MODE_DEFAULT 0x00000000 +#define GX2_TILE_MODE_LINEAR_ALIGNED 0x00000001 + +//!----------------------------------------------------------------------------------------------------------------------- +//! GX2 surface use +//!----------------------------------------------------------------------------------------------------------------------- +#define GX2_SURFACE_USE_TEXTURE 0x00000001 +#define GX2_SURFACE_USE_COLOR_BUFFER 0x00000002 +#define GX2_SURFACE_USE_DEPTH_BUFFER 0x00000004 +#define GX2_SURFACE_USE_SCAN_BUFFER 0x00000008 +#define GX2_SURFACE_USE_FTV 0x80000000 +#define GX2_SURFACE_USE_COLOR_BUFFER_TEXTURE (GX2_SURFACE_USE_COLOR_BUFFER | GX2_SURFACE_USE_TEXTURE) +#define GX2_SURFACE_USE_DEPTH_BUFFER_TEXTURE (GX2_SURFACE_USE_DEPTH_BUFFER | GX2_SURFACE_USE_TEXTURE) +#define GX2_SURFACE_USE_COLOR_BUFFER_FTV (GX2_SURFACE_USE_COLOR_BUFFER | GX2_SURFACE_USE_FTV) +#define GX2_SURFACE_USE_COLOR_BUFFER_TEXTURE_FTV (GX2_SURFACE_USE_COLOR_BUFFER_TEXTURE | GX2_SURFACE_USE_FTV) + +//!----------------------------------------------------------------------------------------------------------------------- +//! GX2 surface dim +//!----------------------------------------------------------------------------------------------------------------------- +#define GX2_SURFACE_DIM_1D 0x00000000 +#define GX2_SURFACE_DIM_2D 0x00000001 +#define GX2_SURFACE_DIM_3D 0x00000002 +#define GX2_SURFACE_DIM_CUBE 0x00000003 +#define GX2_SURFACE_DIM_1D_ARRAY 0x00000004 +#define GX2_SURFACE_DIM_2D_ARRAY 0x00000005 +#define GX2_SURFACE_DIM_2D_MSAA 0x00000006 +#define GX2_SURFACE_DIM_2D_MSAA_ARRAY 0x00000007 + +//!----------------------------------------------------------------------------------------------------------------------- +//! GX2 AA modes +//!----------------------------------------------------------------------------------------------------------------------- +#define GX2_AA_MODE_1X 0x00000000 +#define GX2_AA_MODE_2X 0x00000001 +#define GX2_AA_MODE_4X 0x00000002 +#define GX2_AA_MODE_8X 0x00000003 + +//!----------------------------------------------------------------------------------------------------------------------- +//! GX2 texture clamp +//!----------------------------------------------------------------------------------------------------------------------- +#define GX2_TEX_CLAMP_WRAP 0x00000000 +#define GX2_TEX_CLAMP_MIRROR 0x00000001 +#define GX2_TEX_CLAMP_CLAMP 0x00000002 +#define GX2_TEX_CLAMP_MIRROR_ONCE 0x00000003 +#define GX2_TEX_CLAMP_CLAMP_HALF_BORDER 0x00000004 +#define GX2_TEX_CLAMP_MIRROR_ONCE_HALF_BORDER 0x00000005 +#define GX2_TEX_CLAMP_CLAMP_BORDER 0x00000006 +#define GX2_TEX_CLAMP_MIRROR_ONCE_BORDER 0x00000007 + +//!----------------------------------------------------------------------------------------------------------------------- +//! GX2 texture filter +//!----------------------------------------------------------------------------------------------------------------------- +#define GX2_TEX_XY_FILTER_POINT 0x00000000 +#define GX2_TEX_XY_FILTER_BILINEAR 0x00000001 + +//!----------------------------------------------------------------------------------------------------------------------- +//! GX2 TV scan modes +//!----------------------------------------------------------------------------------------------------------------------- +#define GX2_TV_SCAN_MODE_NONE 0x00000000 +#define GX2_TV_SCAN_MODE_576I 0x00000001 +#define GX2_TV_SCAN_MODE_480I 0x00000002 +#define GX2_TV_SCAN_MODE_480P 0x00000003 +#define GX2_TV_SCAN_MODE_720P 0x00000004 +#define GX2_TV_SCAN_MODE_1080I 0x00000006 +#define GX2_TV_SCAN_MODE_1080P 0x00000007 + +//!----------------------------------------------------------------------------------------------------------------------- +//! GX2 TV render modes +//!----------------------------------------------------------------------------------------------------------------------- +#define GX2_TV_RENDER_480_NARROW 0x00000001 +#define GX2_TV_RENDER_480_WIDE 0x00000002 +#define GX2_TV_RENDER_720 0x00000003 +#define GX2_TV_RENDER_1080 0x00000005 + +//!----------------------------------------------------------------------------------------------------------------------- +//! GX2 DRC render modes +//!----------------------------------------------------------------------------------------------------------------------- +#define GX2_DRC_NONE 0x00000000 +#define GX2_DRC_SINGLE 0x00000001 +#define GX2_DRC_DOUBLE 0x00000002 +#define GX2_DRC_SINGLE_30HZ 0x00000004 + +//!----------------------------------------------------------------------------------------------------------------------- +//! GX2 buffering mode +//!----------------------------------------------------------------------------------------------------------------------- +#define GX2_BUFFERING_SINGLE 0x00000001 +#define GX2_BUFFERING_DOUBLE 0x00000002 +#define GX2_BUFFERING_TRIPLE 0x00000003 +#define GX2_BUFFERING_QUAD +//!----------------------------------------------------------------------------------------------------------------------- +//! GX2 scan targets +//!----------------------------------------------------------------------------------------------------------------------- +#define GX2_SCAN_TARGET_TV 0x00000001 +#define GX2_SCAN_TARGET_DRC_FIRST 0x00000004 +#define GX2_SCAN_TARGET_DRC_SECOND 0x00000008 + +//!----------------------------------------------------------------------------------------------------------------------- +//! GX2 invalidate types +//!----------------------------------------------------------------------------------------------------------------------- +#define GX2_INVALIDATE_ATTRIB_BUFFER 0x00000001 +#define GX2_INVALIDATE_TEXTURE 0x00000002 +#define GX2_INVALIDATE_UNIFORM_BLOCK 0x00000004 +#define GX2_INVALIDATE_SHADER 0x00000008 +#define GX2_INVALIDATE_COLOR_BUFFER 0x00000010 +#define GX2_INVALIDATE_DEPTH_BUFFER 0x00000020 +#define GX2_INVALIDATE_CPU 0x00000040 +#define GX2_INVALIDATE_CPU_ATTRIB_BUFFER (GX2_INVALIDATE_CPU | GX2_INVALIDATE_ATTRIB_BUFFER) +#define GX2_INVALIDATE_CPU_TEXTURE (GX2_INVALIDATE_CPU | GX2_INVALIDATE_TEXTURE) +#define GX2_INVALIDATE_CPU_UNIFORM_BLOCK (GX2_INVALIDATE_CPU | GX2_INVALIDATE_UNIFORM_BLOCK) +#define GX2_INVALIDATE_CPU_SHADER (GX2_INVALIDATE_CPU | GX2_INVALIDATE_SHADER) + +//!----------------------------------------------------------------------------------------------------------------------- +//! GX2 swap modes +//!----------------------------------------------------------------------------------------------------------------------- +#define GX2_ENDIANSWAP_DEFAULT 0x00000003 + +//!----------------------------------------------------------------------------------------------------------------------- +//! GX2 tessellation modes +//!----------------------------------------------------------------------------------------------------------------------- +#define GX2_TESSELLATION_MODE_DISCRETE 0x00000000 +#define GX2_TESSELLATION_MODE_CONTINUOUS 0x00000001 +#define GX2_TESSELLATION_MODE_ADAPTIVE 0x00000002 + +//!----------------------------------------------------------------------------------------------------------------------- +//! GX2 fetch shader types +//!----------------------------------------------------------------------------------------------------------------------- +#define GX2_FETCH_SHADER_TESSELATION_NONE 0x00000000 +#define GX2_FETCH_SHADER_TESSELATION_LINES 0x00000001 +#define GX2_FETCH_SHADER_TESSELATION_TRIANGLES 0x00000002 +#define GX2_FETCH_SHADER_TESSELATION_QUADS 0x00000003 + + +typedef struct _GX2ContextState { + u8 data[GX2_CONTEXT_STATE_SIZE]; +} GX2ContextState; + +typedef struct _GX2Surface { + s32 dimension; + u32 width; + u32 height; + u32 depth; + u32 num_mips; + s32 format; + s32 aa; + s32 use; + u32 image_size; + void *image_data; + u32 mip_size; + void *mip_data; + s32 tile; + u32 swizzle; + u32 align; + u32 pitch; + u32 mip_offset[13]; +} GX2Surface; + +typedef struct _GX2ColorBuffer { + GX2Surface surface; + u32 view_mip; + u32 view_first_slice; + u32 view_slices_count; + void *aux_data; + u32 aux_size; + u32 regs[5]; +} GX2ColorBuffer; + +typedef struct _GX2DepthBuffer { + GX2Surface surface; + u32 view_mip; + u32 view_first_slice; + u32 view_slices_count; + void *hiZ_data; + u32 hiZ_size; + f32 clear_depth; + u32 clear_stencil; + u32 regs[7]; +} GX2DepthBuffer; + + +typedef struct _GX2Texture { + GX2Surface surface; + u32 view_first_mip; + u32 view_mips_count; + u32 view_first_slice; + u32 view_slices_count; + u32 component_selector; + u32 regs[5]; +} GX2Texture; + + +typedef struct _GX2Sampler { + u32 regs[3]; +} GX2Sampler; + +typedef struct _GX2AttribStream { + u32 location; + u32 buffer; + u32 offset; + s32 format; + s32 index_type; + u32 divisor; + u32 destination_selector; + s32 endian_swap; +} GX2AttribStream; + +typedef struct _GX2FetchShader { + s32 type; + u32 reg; + u32 shader_size; + void *shader_program; + u32 attributes_count; + u32 divisor[3]; +} GX2FetchShader; + +typedef struct _GX2AttribVar +{ + const char *name; + s32 var_type; + u32 array_count; + u32 location; +} GX2AttribVar; + + +typedef struct _GX2UniformBlock { + const char *name; + u32 location; + u32 block_size; +} GX2UniformBlock; + +typedef struct _GX2UniformInitialValue { + f32 value[4]; + u32 offset; +} GX2UniformInitialValue; + +typedef struct _GX2SamplerVar +{ + const char *name; + s32 sampler_type; + u32 location; +} GX2SamplerVar; + +typedef struct _GX2UniformVar +{ + const char *name; + s32 var_type; + u32 array_count; + u32 offset; + u32 block_index; +} GX2UniformVar; + +typedef struct _GX2VertexShader { + u32 regs[52]; + u32 shader_size; + void *shader_data; + s32 shader_mode; + u32 uniform_blocks_count; + GX2UniformBlock *uniform_block; + u32 uniform_vars_count; + GX2UniformVar *uniform_var; + u32 initial_values_count; + GX2UniformInitialValue *initial_value; + u32 loops_count; + void *loops_data; + u32 sampler_vars_count; + GX2SamplerVar *sampler_var; + u32 attribute_vars_count; + GX2AttribVar *attribute_var; + u32 data[6]; + u32 shader_program_buffer[16]; +} GX2VertexShader; + +typedef struct _GX2PixelShader { + u32 regs[41]; + u32 shader_size; + void *shader_data; + s32 shader_mode; + u32 uniform_blocks_count; + GX2UniformBlock *uniform_block; + u32 uniform_vars_count; + GX2UniformVar *uniform_var; + u32 initial_values_count; + GX2UniformInitialValue *initial_value; + u32 loops_count; + void *loops_data; + u32 sampler_vars_count; + GX2SamplerVar *sampler_var; + u32 shader_program_buffer[16]; +} GX2PixelShader; + +static const u32 attribute_dest_comp_selector[20] = { + GX2_COMP_SEL_X001, GX2_COMP_SEL_XY01, GX2_COMP_SEL_X001, GX2_COMP_SEL_X001, GX2_COMP_SEL_XY01, GX2_COMP_SEL_X001, + GX2_COMP_SEL_X001, GX2_COMP_SEL_XY01, GX2_COMP_SEL_XY01, GX2_COMP_SEL_XYZ1, GX2_COMP_SEL_XYZW, GX2_COMP_SEL_XYZW, + GX2_COMP_SEL_XY01, GX2_COMP_SEL_XY01, GX2_COMP_SEL_XYZW, GX2_COMP_SEL_XYZW, GX2_COMP_SEL_XYZ1, GX2_COMP_SEL_XYZ1, + GX2_COMP_SEL_XYZW, GX2_COMP_SEL_XYZW +}; + +static const u32 texture_comp_selector[54] = { + GX2_COMP_SEL_NONE, GX2_COMP_SEL_X001, GX2_COMP_SEL_XY01, GX2_COMP_SEL_NONE, GX2_COMP_SEL_NONE, GX2_COMP_SEL_X001, + GX2_COMP_SEL_X001, GX2_COMP_SEL_XY01, GX2_COMP_SEL_XYZ1, GX2_COMP_SEL_XYZ1, GX2_COMP_SEL_XYZW, GX2_COMP_SEL_XYZW, + GX2_COMP_SEL_WZYX, GX2_COMP_SEL_X001, GX2_COMP_SEL_X001, GX2_COMP_SEL_XY01, GX2_COMP_SEL_XY01, GX2_COMP_SEL_NONE, + GX2_COMP_SEL_NONE, GX2_COMP_SEL_NONE, GX2_COMP_SEL_NONE, GX2_COMP_SEL_NONE, GX2_COMP_SEL_XYZ1, GX2_COMP_SEL_NONE, + GX2_COMP_SEL_NONE, GX2_COMP_SEL_XYZW, GX2_COMP_SEL_XYZW, GX2_COMP_SEL_WZYX, GX2_COMP_SEL_XY01, GX2_COMP_SEL_XY01, + GX2_COMP_SEL_XY01, GX2_COMP_SEL_XYZW, GX2_COMP_SEL_XYZW, GX2_COMP_SEL_NONE, GX2_COMP_SEL_XYZW, GX2_COMP_SEL_XYZW, + GX2_COMP_SEL_NONE, GX2_COMP_SEL_NONE, GX2_COMP_SEL_NONE, GX2_COMP_SEL_XYZ1, GX2_COMP_SEL_XYZ1, GX2_COMP_SEL_X001, + GX2_COMP_SEL_XY01, GX2_COMP_SEL_XYZ1, GX2_COMP_SEL_NONE, GX2_COMP_SEL_NONE, GX2_COMP_SEL_NONE, GX2_COMP_SEL_XYZ1, + GX2_COMP_SEL_XYZ1, GX2_COMP_SEL_XYZW, GX2_COMP_SEL_XYZW, GX2_COMP_SEL_XYZW, GX2_COMP_SEL_X001, GX2_COMP_SEL_XY01 +}; + +typedef struct _GX2Color { + u8 r, g, b, a; +} GX2Color; + +typedef struct _GX2ColorF32 { + f32 r, g, b, a; +} GX2ColorF32; + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/dynamic_libs/os_functions.c b/src/dynamic_libs/os_functions.c new file mode 100644 index 0000000..a8fceea --- /dev/null +++ b/src/dynamic_libs/os_functions.c @@ -0,0 +1,214 @@ +/**************************************************************************** + * Copyright (C) 2015 + * by Dimok + * + * This software is provided 'as-is', without any express or implied + * warranty. In no event will the authors be held liable for any + * damages arising from the use of this software. + * + * Permission is granted to anyone to use this software for any + * purpose, including commercial applications, and to alter it and + * redistribute it freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you + * must not claim that you wrote the original software. If you use + * this software in a product, an acknowledgment in the product + * documentation would be appreciated but is not required. + * + * 2. Altered source versions must be plainly marked as such, and + * must not be misrepresented as being the original software. + * + * 3. This notice may not be removed or altered from any source + * distribution. + ***************************************************************************/ +#include "common/common.h" +#include "os_functions.h" + +unsigned int coreinit_handle = 0; + +//!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +//! Lib handle functions +//!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +EXPORT_DECL(int, OSDynLoad_Acquire, const char* rpl, u32 *handle); +EXPORT_DECL(int, OSDynLoad_FindExport, u32 handle, int isdata, const char *symbol, void *address); + +//!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +//! Thread functions +//!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +EXPORT_DECL(int, OSCreateThread, void *thread, s32 (*callback)(s32, void*), s32 argc, void *args, u32 stack, u32 stack_size, s32 priority, u32 attr); +EXPORT_DECL(int, OSResumeThread, void *thread); +EXPORT_DECL(int, OSSuspendThread, void *thread); +EXPORT_DECL(int, OSIsThreadTerminated, void *thread); +EXPORT_DECL(int, OSIsThreadSuspended, void *thread); +EXPORT_DECL(int, OSSetThreadPriority, void * thread, int priority); +EXPORT_DECL(int, OSJoinThread, void * thread, int * ret_val); +EXPORT_DECL(void, OSDetachThread, void * thread); +EXPORT_DECL(void, OSSleepTicks, u64 ticks); +EXPORT_DECL(u64, OSGetTick, void); + +//!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +//! Mutex functions +//!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +EXPORT_DECL(void, OSInitMutex, void* mutex); +EXPORT_DECL(void, OSLockMutex, void* mutex); +EXPORT_DECL(void, OSUnlockMutex, void* mutex); +EXPORT_DECL(int, OSTryLockMutex, void* mutex); + +//!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +//! System functions +//!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +EXPORT_DECL(u64, OSGetTitleID, void); +EXPORT_DECL(void, __Exit, void); +EXPORT_DECL(void, OSFatal, const char* msg); +EXPORT_DECL(void, OSSetExceptionCallback, u8 exceptionType, exception_callback newCallback); +EXPORT_DECL(void, DCFlushRange, const void *addr, u32 length); +EXPORT_DECL(void, ICInvalidateRange, const void *addr, u32 length); +EXPORT_DECL(void*, OSEffectiveToPhysical, const void*); +EXPORT_DECL(int, __os_snprintf, char* s, int n, const char * format, ...); + +EXPORT_DECL(void, OSScreenInit, void); +EXPORT_DECL(unsigned int, OSScreenGetBufferSizeEx, unsigned int bufferNum); +EXPORT_DECL(int, OSScreenSetBufferEx, unsigned int bufferNum, void * addr); +EXPORT_DECL(int, OSScreenClearBufferEx, unsigned int bufferNum, unsigned int temp); +EXPORT_DECL(int, OSScreenFlipBuffersEx, unsigned int bufferNum); +EXPORT_DECL(int, OSScreenPutFontEx, unsigned int bufferNum, unsigned int posX, unsigned int posY, const char * buffer); +EXPORT_DECL(int, OSScreenEnableEx, unsigned int bufferNum, int enable); + +//!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +//! Memory functions +//!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +EXPORT_VAR(unsigned int *, pMEMAllocFromDefaultHeapEx); +EXPORT_VAR(unsigned int *, pMEMAllocFromDefaultHeap); +EXPORT_VAR(unsigned int *, pMEMFreeToDefaultHeap); + +EXPORT_DECL(int, MEMGetBaseHeapHandle, int mem_arena); +EXPORT_DECL(unsigned int, MEMGetAllocatableSizeForFrmHeapEx, int heap, int align); +EXPORT_DECL(void *, MEMAllocFromFrmHeapEx, int heap, unsigned int size, int align); +EXPORT_DECL(void, MEMFreeToFrmHeap, int heap, int mode); +EXPORT_DECL(void *, MEMAllocFromExpHeapEx, int heap, unsigned int size, int align); +EXPORT_DECL(int , MEMCreateExpHeapEx, void* address, unsigned int size, unsigned short flags); +EXPORT_DECL(void *, MEMDestroyExpHeap, int heap); +EXPORT_DECL(void, MEMFreeToExpHeap, int heap, void* ptr); + +//!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +//! MCP functions +//!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +EXPORT_DECL(int, MCP_Open, void); +EXPORT_DECL(int, MCP_Close, int handle); +EXPORT_DECL(int, MCP_GetOwnTitleInfo, int handle, void * data); + +//!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +//! Loader functions (not real rpl) +//!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +EXPORT_DECL(int, LiWaitIopComplete, int unknown_syscall_arg_r3, int * remaining_bytes); +EXPORT_DECL(int, LiWaitIopCompleteWithInterrupts, int unknown_syscall_arg_r3, int * remaining_bytes); +EXPORT_DECL(void, addr_LiWaitOneChunk, void); + +//!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +//! Kernel function addresses +//!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +EXPORT_DECL(void, addr_PrepareTitle_hook, void); + +void InitOSFunctionPointers(void) +{ + unsigned int *funcPointer = 0; + //!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + //! Lib handle functions + //!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + EXPORT_FUNC_WRITE(OSDynLoad_Acquire, (int (*)(const char*, unsigned *))OS_SPECIFICS->addr_OSDynLoad_Acquire); + EXPORT_FUNC_WRITE(OSDynLoad_FindExport, (int (*)(u32, int, const char *, void *))OS_SPECIFICS->addr_OSDynLoad_FindExport); + + OSDynLoad_Acquire("coreinit.rpl", &coreinit_handle); + + //!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + //! System functions + //!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + OS_FIND_EXPORT(coreinit_handle, OSFatal); + OS_FIND_EXPORT(coreinit_handle, OSGetTitleID); + OS_FIND_EXPORT(coreinit_handle, OSSetExceptionCallback); + OS_FIND_EXPORT(coreinit_handle, DCFlushRange); + OS_FIND_EXPORT(coreinit_handle, ICInvalidateRange); + OS_FIND_EXPORT(coreinit_handle, OSEffectiveToPhysical); + OS_FIND_EXPORT(coreinit_handle, __os_snprintf); + OSDynLoad_FindExport(coreinit_handle, 0, "_Exit", &__Exit); + + OS_FIND_EXPORT(coreinit_handle, OSScreenInit); + OS_FIND_EXPORT(coreinit_handle, OSScreenGetBufferSizeEx); + OS_FIND_EXPORT(coreinit_handle, OSScreenSetBufferEx); + OS_FIND_EXPORT(coreinit_handle, OSScreenClearBufferEx); + OS_FIND_EXPORT(coreinit_handle, OSScreenFlipBuffersEx); + OS_FIND_EXPORT(coreinit_handle, OSScreenPutFontEx); + OS_FIND_EXPORT(coreinit_handle, OSScreenEnableEx); + //!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + //! Thread functions + //!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + OS_FIND_EXPORT(coreinit_handle, OSCreateThread); + OS_FIND_EXPORT(coreinit_handle, OSResumeThread); + OS_FIND_EXPORT(coreinit_handle, OSSuspendThread); + OS_FIND_EXPORT(coreinit_handle, OSIsThreadTerminated); + OS_FIND_EXPORT(coreinit_handle, OSIsThreadSuspended); + OS_FIND_EXPORT(coreinit_handle, OSJoinThread); + OS_FIND_EXPORT(coreinit_handle, OSSetThreadPriority); + OS_FIND_EXPORT(coreinit_handle, OSDetachThread); + OS_FIND_EXPORT(coreinit_handle, OSSleepTicks); + OS_FIND_EXPORT(coreinit_handle, OSGetTick); + //!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + //! Mutex functions + //!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + OS_FIND_EXPORT(coreinit_handle, OSInitMutex); + OS_FIND_EXPORT(coreinit_handle, OSLockMutex); + OS_FIND_EXPORT(coreinit_handle, OSUnlockMutex); + OS_FIND_EXPORT(coreinit_handle, OSTryLockMutex); + //!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + //! MCP functions + //!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + OS_FIND_EXPORT(coreinit_handle, MCP_Open); + OS_FIND_EXPORT(coreinit_handle, MCP_Close); + OS_FIND_EXPORT(coreinit_handle, MCP_GetOwnTitleInfo); + + //!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + //! Memory functions + //!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + OSDynLoad_FindExport(coreinit_handle, 1, "MEMAllocFromDefaultHeapEx", &pMEMAllocFromDefaultHeapEx); + OSDynLoad_FindExport(coreinit_handle, 1, "MEMAllocFromDefaultHeap", &pMEMAllocFromDefaultHeap); + OSDynLoad_FindExport(coreinit_handle, 1, "MEMFreeToDefaultHeap", &pMEMFreeToDefaultHeap); + + OS_FIND_EXPORT(coreinit_handle, MEMGetBaseHeapHandle); + OS_FIND_EXPORT(coreinit_handle, MEMGetAllocatableSizeForFrmHeapEx); + OS_FIND_EXPORT(coreinit_handle, MEMAllocFromFrmHeapEx); + OS_FIND_EXPORT(coreinit_handle, MEMFreeToFrmHeap); + OS_FIND_EXPORT(coreinit_handle, MEMAllocFromExpHeapEx); + OS_FIND_EXPORT(coreinit_handle, MEMCreateExpHeapEx); + OS_FIND_EXPORT(coreinit_handle, MEMDestroyExpHeap); + OS_FIND_EXPORT(coreinit_handle, MEMFreeToExpHeap); + + //!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + //! Special non library functions + //!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + if(OS_FIRMWARE == 532 || OS_FIRMWARE == 540) + { + EXPORT_FUNC_WRITE(LiWaitIopComplete, (int (*)(int, int *))0x0100FFA4); + EXPORT_FUNC_WRITE(LiWaitIopCompleteWithInterrupts, (int (*)(int, int *))0x0100FE90); + EXPORT_FUNC_WRITE(addr_LiWaitOneChunk, (int (*)(int, int *))0x010007EC); + EXPORT_FUNC_WRITE(addr_PrepareTitle_hook, (int (*)(int, int *))0xFFF18558); + } + else if(OS_FIRMWARE == 500 || OS_FIRMWARE == 510) + { + EXPORT_FUNC_WRITE(LiWaitIopComplete, (int (*)(int, int *))0x0100FBC4); + EXPORT_FUNC_WRITE(LiWaitIopCompleteWithInterrupts, (int (*)(int, int *))0x0100FAB0); + EXPORT_FUNC_WRITE(addr_LiWaitOneChunk, (int (*)(int, int *))0x010007EC); + EXPORT_FUNC_WRITE(addr_PrepareTitle_hook, (int (*)(int, int *))0xFFF18534); + } + else if(OS_FIRMWARE == 550) + { + EXPORT_FUNC_WRITE(LiWaitIopComplete, (int (*)(int, int *))0x01010180); + EXPORT_FUNC_WRITE(LiWaitIopCompleteWithInterrupts, (int (*)(int, int *))0x0101006C); + EXPORT_FUNC_WRITE(addr_LiWaitOneChunk, (int (*)(int, int *))0x0100080C); + EXPORT_FUNC_WRITE(addr_PrepareTitle_hook, (int (*)(int, int *))0xFFF184E4); + } + else + { + OSFatal("Missing all OS specific addresses."); + } +} + diff --git a/src/dynamic_libs/os_functions.h b/src/dynamic_libs/os_functions.h new file mode 100644 index 0000000..3546a54 --- /dev/null +++ b/src/dynamic_libs/os_functions.h @@ -0,0 +1,144 @@ +/**************************************************************************** + * Copyright (C) 2015 + * by Dimok + * + * This software is provided 'as-is', without any express or implied + * warranty. In no event will the authors be held liable for any + * damages arising from the use of this software. + * + * Permission is granted to anyone to use this software for any + * purpose, including commercial applications, and to alter it and + * redistribute it freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you + * must not claim that you wrote the original software. If you use + * this software in a product, an acknowledgment in the product + * documentation would be appreciated but is not required. + * + * 2. Altered source versions must be plainly marked as such, and + * must not be misrepresented as being the original software. + * + * 3. This notice may not be removed or altered from any source + * distribution. + ***************************************************************************/ +#ifndef __OS_FUNCTIONS_H_ +#define __OS_FUNCTIONS_H_ + +#include +#include "common/os_defs.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#define BUS_SPEED 248625000 +#define SECS_TO_TICKS(sec) (((unsigned long long)(sec)) * (BUS_SPEED/4)) +#define MILLISECS_TO_TICKS(msec) (SECS_TO_TICKS(msec) / 1000) +#define MICROSECS_TO_TICKS(usec) (SECS_TO_TICKS(usec) / 1000000) + +#define usleep(usecs) OSSleepTicks(MICROSECS_TO_TICKS(usecs)) +#define sleep(secs) OSSleepTicks(SECS_TO_TICKS(secs)) + +#define FLUSH_DATA_BLOCK(addr) asm volatile("dcbf 0, %0; sync" : : "r"(((addr) & ~31))) +#define INVAL_DATA_BLOCK(addr) asm volatile("dcbi 0, %0; sync" : : "r"(((addr) & ~31))) + +#define EXPORT_DECL(res, func, ...) res (* func)(__VA_ARGS__) __attribute__((section(".data"))) = 0; +#define EXPORT_VAR(type, var) type var __attribute__((section(".data"))); + + +#define EXPORT_FUNC_WRITE(func, val) *(u32*)(((u32)&func) + 0) = (u32)val + +#define OS_FIND_EXPORT(handle, func) funcPointer = 0; \ + OSDynLoad_FindExport(handle, 0, # func, &funcPointer); \ + if(!funcPointer) \ + OSFatal("Function " # func " is NULL"); \ + EXPORT_FUNC_WRITE(func, funcPointer); + +#define OS_FIND_EXPORT_EX(handle, func, func_p) \ + funcPointer = 0; \ + OSDynLoad_FindExport(handle, 0, # func, &funcPointer); \ + if(!funcPointer) \ + OSFatal("Function " # func " is NULL"); \ + EXPORT_FUNC_WRITE(func_p, funcPointer); + +#define OS_MUTEX_SIZE 44 + +/* Handle for coreinit */ +extern unsigned int coreinit_handle; +void InitOSFunctionPointers(void); + +//!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +//! Lib handle functions +//!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +extern int (* OSDynLoad_Acquire)(const char* rpl, u32 *handle); +extern int (* OSDynLoad_FindExport)(u32 handle, int isdata, const char *symbol, void *address); + +//!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +//! Thread functions +//!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +extern int (* OSCreateThread)(void *thread, s32 (*callback)(s32, void*), s32 argc, void *args, u32 stack, u32 stack_size, s32 priority, u32 attr); +extern int (* OSResumeThread)(void *thread); +extern int (* OSSuspendThread)(void *thread); +extern int (* OSIsThreadTerminated)(void *thread); +extern int (* OSIsThreadSuspended)(void *thread); +extern int (* OSJoinThread)(void * thread, int * ret_val); +extern int (* OSSetThreadPriority)(void * thread, int priority); +extern void (* OSDetachThread)(void * thread); +extern void (* OSSleepTicks)(u64 ticks); +extern u64 (* OSGetTick)(void); + +//!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +//! Mutex functions +//!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +extern void (* OSInitMutex)(void* mutex); +extern void (* OSLockMutex)(void* mutex); +extern void (* OSUnlockMutex)(void* mutex); +extern int (* OSTryLockMutex)(void* mutex); + +//!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +//! System functions +//!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +extern u64 (* OSGetTitleID)(void); +extern void (* __Exit)(void); +extern void (* OSFatal)(const char* msg); +extern void (* DCFlushRange)(const void *addr, u32 length); +extern void (* ICInvalidateRange)(const void *addr, u32 length); +extern void* (* OSEffectiveToPhysical)(const void*); +extern int (* __os_snprintf)(char* s, int n, const char * format, ...); + +extern void (*OSScreenInit)(void); +extern unsigned int (*OSScreenGetBufferSizeEx)(unsigned int bufferNum); +extern int (*OSScreenSetBufferEx)(unsigned int bufferNum, void * addr); +extern int (*OSScreenClearBufferEx)(unsigned int bufferNum, unsigned int temp); +extern int (*OSScreenFlipBuffersEx)(unsigned int bufferNum); +extern int (*OSScreenPutFontEx)(unsigned int bufferNum, unsigned int posX, unsigned int posY, const char * buffer); +extern int (*OSScreenEnableEx)(unsigned int bufferNum, int enable); + +typedef unsigned char (*exception_callback)(void * interruptedContext); +extern void (* OSSetExceptionCallback)(u8 exceptionType, exception_callback newCallback); + +//!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +//! MCP functions +//!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +extern int (* MCP_Open)(void); +extern int (* MCP_Close)(int handle); +extern int (* MCP_GetOwnTitleInfo)(int handle, void * data); + +//!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +//! LOADER functions +//!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +extern int (* LiWaitIopComplete)(int unknown_syscall_arg_r3, int * remaining_bytes); +extern int (* LiWaitIopCompleteWithInterrupts)(int unknown_syscall_arg_r3, int * remaining_bytes); +extern void (* addr_LiWaitOneChunk)(void); + +//!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +//! Kernel function addresses +//!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +extern void (* addr_PrepareTitle_hook)(void); + + +#ifdef __cplusplus +} +#endif + +#endif // __OS_FUNCTIONS_H_ diff --git a/src/dynamic_libs/padscore_functions.c b/src/dynamic_libs/padscore_functions.c new file mode 100644 index 0000000..c51764f --- /dev/null +++ b/src/dynamic_libs/padscore_functions.c @@ -0,0 +1,50 @@ +/**************************************************************************** + * Copyright (C) 2015 + * by Dimok + * + * This software is provided 'as-is', without any express or implied + * warranty. In no event will the authors be held liable for any + * damages arising from the use of this software. + * + * Permission is granted to anyone to use this software for any + * purpose, including commercial applications, and to alter it and + * redistribute it freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you + * must not claim that you wrote the original software. If you use + * this software in a product, an acknowledgment in the product + * documentation would be appreciated but is not required. + * + * 2. Altered source versions must be plainly marked as such, and + * must not be misrepresented as being the original software. + * + * 3. This notice may not be removed or altered from any source + * distribution. + ***************************************************************************/ +#include "os_functions.h" +#include "padscore_functions.h" + +EXPORT_DECL(void, KPADInit, void); +EXPORT_DECL(s32, WPADProbe, s32 chan, u32 * pad_type); +EXPORT_DECL(s32, WPADSetDataFormat, s32 chan, s32 format); +EXPORT_DECL(void, WPADEnableURCC, s32 enable); +EXPORT_DECL(void, WPADRead, s32 chan, void * data); +EXPORT_DECL(s32, KPADRead, s32 chan, void * data, u32 size); + +void InitPadScoreFunctionPointers(void) +{ + unsigned int *funcPointer = 0; + unsigned int padscore_handle; + OSDynLoad_Acquire("padscore.rpl", &padscore_handle); + + OS_FIND_EXPORT(padscore_handle, KPADInit); + OS_FIND_EXPORT(padscore_handle, WPADProbe); + OS_FIND_EXPORT(padscore_handle, WPADSetDataFormat); + OS_FIND_EXPORT(padscore_handle, WPADEnableURCC); + OS_FIND_EXPORT(padscore_handle, WPADRead); + OS_FIND_EXPORT(padscore_handle, KPADRead); + + KPADInit(); + WPADEnableURCC(1); +} + diff --git a/src/dynamic_libs/padscore_functions.h b/src/dynamic_libs/padscore_functions.h new file mode 100644 index 0000000..26eda1a --- /dev/null +++ b/src/dynamic_libs/padscore_functions.h @@ -0,0 +1,122 @@ +/**************************************************************************** + * Copyright (C) 2015 + * by Dimok + * + * This software is provided 'as-is', without any express or implied + * warranty. In no event will the authors be held liable for any + * damages arising from the use of this software. + * + * Permission is granted to anyone to use this software for any + * purpose, including commercial applications, and to alter it and + * redistribute it freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you + * must not claim that you wrote the original software. If you use + * this software in a product, an acknowledgment in the product + * documentation would be appreciated but is not required. + * + * 2. Altered source versions must be plainly marked as such, and + * must not be misrepresented as being the original software. + * + * 3. This notice may not be removed or altered from any source + * distribution. + ***************************************************************************/ +#ifndef __PAD_SCORE_FUNCTIONS_H_ +#define __PAD_SCORE_FUNCTIONS_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +#define WPAD_BUTTON_LEFT 0x0001 +#define WPAD_BUTTON_RIGHT 0x0002 +#define WPAD_BUTTON_DOWN 0x0004 +#define WPAD_BUTTON_UP 0x0008 +#define WPAD_BUTTON_PLUS 0x0010 +#define WPAD_BUTTON_2 0x0100 +#define WPAD_BUTTON_1 0x0200 +#define WPAD_BUTTON_B 0x0400 +#define WPAD_BUTTON_A 0x0800 +#define WPAD_BUTTON_MINUS 0x1000 +#define WPAD_BUTTON_Z 0x2000 +#define WPAD_BUTTON_C 0x4000 +#define WPAD_BUTTON_HOME 0x8000 + +#define WPAD_CLASSIC_BUTTON_UP 0x0001 +#define WPAD_CLASSIC_BUTTON_LEFT 0x0002 +#define WPAD_CLASSIC_BUTTON_ZR 0x0004 +#define WPAD_CLASSIC_BUTTON_X 0x0008 +#define WPAD_CLASSIC_BUTTON_A 0x0010 +#define WPAD_CLASSIC_BUTTON_Y 0x0020 +#define WPAD_CLASSIC_BUTTON_B 0x0040 +#define WPAD_CLASSIC_BUTTON_ZL 0x0080 +#define WPAD_CLASSIC_BUTTON_R 0x0200 +#define WPAD_CLASSIC_BUTTON_PLUS 0x0400 +#define WPAD_CLASSIC_BUTTON_HOME 0x0800 +#define WPAD_CLASSIC_BUTTON_MINUS 0x1000 +#define WPAD_CLASSIC_BUTTON_L 0x2000 +#define WPAD_CLASSIC_BUTTON_DOWN 0x4000 +#define WPAD_CLASSIC_BUTTON_RIGHT 0x8000 + +void InitPadScoreFunctionPointers(void); + + +typedef struct _KPADData +{ + u32 btns_h; + u32 btns_d; + u32 btns_r; + u32 unused_1[5]; + f32 pos_x; + f32 pos_y; + u32 unused_2[3]; + f32 angle_x; + f32 angle_y; + u32 unused_3[8]; + u8 device_type; + u8 wpad_error; + u8 pos_valid; + u8 unused_4[1]; + + union + { + struct + { + f32 stick_x; + f32 stick_y; + } nunchuck; + + struct + { + u32 btns_h; + u32 btns_d; + u32 btns_r; + f32 lstick_x; + f32 lstick_y; + f32 rstick_x; + f32 rstick_y; + f32 ltrigger; + f32 rtrigger; + } classic; + + u32 unused_6[20]; + }; + u32 unused_7[16]; +} KPADData; + +typedef void (* wpad_connect_callback_t)(s32 chan, s32 status); + +extern void (* KPADInit)(void); +extern s32 (* WPADProbe)(s32 chan, u32 * pad_type); +extern s32 (* WPADSetDataFormat)(s32 chan, s32 format); +extern void (* WPADEnableURCC)(s32 enable); +extern void (* WPADRead)(s32 chan, void * data); +extern s32 (* KPADRead)(s32 chan, void * data, u32 size); + +#ifdef __cplusplus +} +#endif + +#endif // __PAD_SCORE_FUNCTIONS_H_ diff --git a/src/dynamic_libs/socket_functions.c b/src/dynamic_libs/socket_functions.c new file mode 100644 index 0000000..8f72ced --- /dev/null +++ b/src/dynamic_libs/socket_functions.c @@ -0,0 +1,82 @@ +/**************************************************************************** + * Copyright (C) 2015 + * by Dimok + * + * This software is provided 'as-is', without any express or implied + * warranty. In no event will the authors be held liable for any + * damages arising from the use of this software. + * + * Permission is granted to anyone to use this software for any + * purpose, including commercial applications, and to alter it and + * redistribute it freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you + * must not claim that you wrote the original software. If you use + * this software in a product, an acknowledgment in the product + * documentation would be appreciated but is not required. + * + * 2. Altered source versions must be plainly marked as such, and + * must not be misrepresented as being the original software. + * + * 3. This notice may not be removed or altered from any source + * distribution. + ***************************************************************************/ +#include "os_functions.h" +#include "socket_functions.h" + +u32 hostIpAddress = 0; + +EXPORT_DECL(void, socket_lib_init, void); +EXPORT_DECL(int, socket, int domain, int type, int protocol); +EXPORT_DECL(int, socketclose, int s); +EXPORT_DECL(int, connect, int s, void *addr, int addrlen); +EXPORT_DECL(int, bind, s32 s,struct sockaddr *name,s32 namelen); +EXPORT_DECL(int, listen, s32 s,u32 backlog); +EXPORT_DECL(int, accept, s32 s,struct sockaddr *addr,s32 *addrlen); +EXPORT_DECL(int, send, int s, const void *buffer, int size, int flags); +EXPORT_DECL(int, recv, int s, void *buffer, int size, int flags); +EXPORT_DECL(int, sendto, int s, const void *buffer, int size, int flags, const struct sockaddr *dest, int dest_len); +EXPORT_DECL(int, setsockopt, int s, int level, int optname, void *optval, int optlen); +EXPORT_DECL(char *, inet_ntoa, struct in_addr in); +EXPORT_DECL(int, inet_aton, const char *cp, struct in_addr *inp); + +void InitSocketFunctionPointers(void) +{ + unsigned int nsysnet_handle; + unsigned int *funcPointer = 0; + OSDynLoad_Acquire("nsysnet.rpl", &nsysnet_handle); + + unsigned int nn_ac_handle; + int(*ACInitialize)(); + int(*ACGetStartupId) (unsigned int *id); + int(*ACConnectWithConfigId) (unsigned int id); + int(*ACGetAssignedAddress) (u32 * ip); + OSDynLoad_Acquire("nn_ac.rpl", &nn_ac_handle); + OSDynLoad_FindExport(nn_ac_handle, 0, "ACInitialize", &ACInitialize); + OSDynLoad_FindExport(nn_ac_handle, 0, "ACGetStartupId", &ACGetStartupId); + OSDynLoad_FindExport(nn_ac_handle, 0, "ACConnectWithConfigId",&ACConnectWithConfigId); + OSDynLoad_FindExport(nn_ac_handle, 0, "ACGetAssignedAddress",&ACGetAssignedAddress); + + OS_FIND_EXPORT(nsysnet_handle, socket_lib_init); + OS_FIND_EXPORT(nsysnet_handle, socket); + OS_FIND_EXPORT(nsysnet_handle, socketclose); + OS_FIND_EXPORT(nsysnet_handle, connect); + OS_FIND_EXPORT(nsysnet_handle, bind); + OS_FIND_EXPORT(nsysnet_handle, listen); + OS_FIND_EXPORT(nsysnet_handle, accept); + OS_FIND_EXPORT(nsysnet_handle, send); + OS_FIND_EXPORT(nsysnet_handle, recv); + OS_FIND_EXPORT(nsysnet_handle, sendto); + OS_FIND_EXPORT(nsysnet_handle, setsockopt); + OS_FIND_EXPORT(nsysnet_handle, inet_ntoa); + OS_FIND_EXPORT(nsysnet_handle, inet_aton); + + unsigned int nn_startupid; + ACInitialize(); + ACGetStartupId(&nn_startupid); + ACConnectWithConfigId(nn_startupid); + ACGetAssignedAddress(&hostIpAddress); + + socket_lib_init(); +} + diff --git a/src/dynamic_libs/socket_functions.h b/src/dynamic_libs/socket_functions.h new file mode 100644 index 0000000..c051246 --- /dev/null +++ b/src/dynamic_libs/socket_functions.h @@ -0,0 +1,95 @@ +/**************************************************************************** + * Copyright (C) 2015 + * by Dimok + * + * This software is provided 'as-is', without any express or implied + * warranty. In no event will the authors be held liable for any + * damages arising from the use of this software. + * + * Permission is granted to anyone to use this software for any + * purpose, including commercial applications, and to alter it and + * redistribute it freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you + * must not claim that you wrote the original software. If you use + * this software in a product, an acknowledgment in the product + * documentation would be appreciated but is not required. + * + * 2. Altered source versions must be plainly marked as such, and + * must not be misrepresented as being the original software. + * + * 3. This notice may not be removed or altered from any source + * distribution. + ***************************************************************************/ +#ifndef __SOCKET_FUNCTIONS_H_ +#define __SOCKET_FUNCTIONS_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +#define INADDR_ANY 0 + +#define AF_INET 2 + +#define SOCK_STREAM 1 +#define SOCK_DGRAM 2 + +#define IPPROTO_IP 0 +#define IPPROTO_TCP 6 +#define IPPROTO_UDP 17 + +#define TCP_NODELAY 0x2004 + +#define SOL_SOCKET -1 +#define SO_REUSEADDR 0x0004 +#define SO_NONBLOCK 0x1016 +#define SO_MYADDR 0x1013 + +#define htonl(x) x +#define htons(x) x +#define ntohl(x) x +#define ntohs(x) x + + +struct in_addr { + unsigned int s_addr; +}; +struct sockaddr_in { + short sin_family; + unsigned short sin_port; + struct in_addr sin_addr; + char sin_zero[8]; +}; + +struct sockaddr +{ + unsigned short sa_family; + char sa_data[14]; +}; + + +void InitSocketFunctionPointers(void); + +extern void (*socket_lib_init)(void); +extern int (*socket)(int domain, int type, int protocol); +extern int (*socketclose)(int s); +extern int (*connect)(int s, void *addr, int addrlen); +extern int (*bind)(s32 s,struct sockaddr *name,s32 namelen); +extern int (*listen)(s32 s,u32 backlog); +extern int (*accept)(s32 s,struct sockaddr *addr,s32 *addrlen); +extern int (*send)(int s, const void *buffer, int size, int flags); +extern int (*recv)(int s, void *buffer, int size, int flags); +extern int (*sendto)(int s, const void *buffer, int size, int flags, const struct sockaddr *dest, int dest_len); +extern int (*setsockopt)(int s, int level, int optname, void *optval, int optlen); + +extern char * (*inet_ntoa)(struct in_addr in); +extern int (*inet_aton)(const char *cp, struct in_addr *inp); + +#ifdef __cplusplus +} +#endif + +#endif // __SOCKET_FUNCTIONS_H_ diff --git a/src/dynamic_libs/sys_functions.c b/src/dynamic_libs/sys_functions.c new file mode 100644 index 0000000..b2a1d89 --- /dev/null +++ b/src/dynamic_libs/sys_functions.c @@ -0,0 +1,42 @@ +/**************************************************************************** + * Copyright (C) 2015 + * by Dimok + * + * This software is provided 'as-is', without any express or implied + * warranty. In no event will the authors be held liable for any + * damages arising from the use of this software. + * + * Permission is granted to anyone to use this software for any + * purpose, including commercial applications, and to alter it and + * redistribute it freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you + * must not claim that you wrote the original software. If you use + * this software in a product, an acknowledgment in the product + * documentation would be appreciated but is not required. + * + * 2. Altered source versions must be plainly marked as such, and + * must not be misrepresented as being the original software. + * + * 3. This notice may not be removed or altered from any source + * distribution. + ***************************************************************************/ +#include "os_functions.h" + +EXPORT_DECL(void, _SYSLaunchTitleByPathFromLauncher, const char* path, int len, int zero); +EXPORT_DECL(int, SYSRelaunchTitle, int argc, char* argv); +EXPORT_DECL(int, SYSLaunchMenu, void); +EXPORT_DECL(int, SYSCheckTitleExists, u64 titleId); + +void InitSysFunctionPointers(void) +{ + unsigned int *funcPointer = 0; + unsigned int sysapp_handle; + OSDynLoad_Acquire("sysapp.rpl", &sysapp_handle); + + OS_FIND_EXPORT(sysapp_handle, _SYSLaunchTitleByPathFromLauncher); + OS_FIND_EXPORT(sysapp_handle, SYSRelaunchTitle); + OS_FIND_EXPORT(sysapp_handle, SYSLaunchMenu); + OS_FIND_EXPORT(sysapp_handle, SYSCheckTitleExists); +} + diff --git a/src/dynamic_libs/sys_functions.h b/src/dynamic_libs/sys_functions.h new file mode 100644 index 0000000..5bd2119 --- /dev/null +++ b/src/dynamic_libs/sys_functions.h @@ -0,0 +1,43 @@ +/**************************************************************************** + * Copyright (C) 2015 + * by Dimok + * + * This software is provided 'as-is', without any express or implied + * warranty. In no event will the authors be held liable for any + * damages arising from the use of this software. + * + * Permission is granted to anyone to use this software for any + * purpose, including commercial applications, and to alter it and + * redistribute it freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you + * must not claim that you wrote the original software. If you use + * this software in a product, an acknowledgment in the product + * documentation would be appreciated but is not required. + * + * 2. Altered source versions must be plainly marked as such, and + * must not be misrepresented as being the original software. + * + * 3. This notice may not be removed or altered from any source + * distribution. + ***************************************************************************/ +#ifndef __SYS_FUNCTIONS_H_ +#define __SYS_FUNCTIONS_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +void InitSysFunctionPointers(void); + +extern void(*_SYSLaunchTitleByPathFromLauncher)(const char* path, int len, int zero); +extern int (* SYSRelaunchTitle)(int argc, char* argv); +extern int (* SYSLaunchMenu)(void); +extern int (* SYSCheckTitleExists)(u64 titleId); + + +#ifdef __cplusplus +} +#endif + +#endif // __SYS_FUNCTIONS_H_ diff --git a/src/dynamic_libs/vpad_functions.c b/src/dynamic_libs/vpad_functions.c new file mode 100644 index 0000000..a2d8e3f --- /dev/null +++ b/src/dynamic_libs/vpad_functions.c @@ -0,0 +1,39 @@ +/**************************************************************************** + * Copyright (C) 2015 + * by Dimok + * + * This software is provided 'as-is', without any express or implied + * warranty. In no event will the authors be held liable for any + * damages arising from the use of this software. + * + * Permission is granted to anyone to use this software for any + * purpose, including commercial applications, and to alter it and + * redistribute it freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you + * must not claim that you wrote the original software. If you use + * this software in a product, an acknowledgment in the product + * documentation would be appreciated but is not required. + * + * 2. Altered source versions must be plainly marked as such, and + * must not be misrepresented as being the original software. + * + * 3. This notice may not be removed or altered from any source + * distribution. + ***************************************************************************/ +#include "os_functions.h" +#include "vpad_functions.h" + +EXPORT_DECL(void, VPADInit, void); +EXPORT_DECL(void, VPADRead, int chan, VPADData *buffer, u32 buffer_size, s32 *error); + +void InitVPadFunctionPointers(void) +{ + unsigned int *funcPointer = 0; + unsigned int vpad_handle; + OSDynLoad_Acquire("vpad.rpl", &vpad_handle); + + OS_FIND_EXPORT(vpad_handle, VPADInit); + OS_FIND_EXPORT(vpad_handle, VPADRead); +} + diff --git a/src/dynamic_libs/vpad_functions.h b/src/dynamic_libs/vpad_functions.h new file mode 100644 index 0000000..00f7983 --- /dev/null +++ b/src/dynamic_libs/vpad_functions.h @@ -0,0 +1,102 @@ +/**************************************************************************** + * Copyright (C) 2015 + * by Dimok + * + * This software is provided 'as-is', without any express or implied + * warranty. In no event will the authors be held liable for any + * damages arising from the use of this software. + * + * Permission is granted to anyone to use this software for any + * purpose, including commercial applications, and to alter it and + * redistribute it freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you + * must not claim that you wrote the original software. If you use + * this software in a product, an acknowledgment in the product + * documentation would be appreciated but is not required. + * + * 2. Altered source versions must be plainly marked as such, and + * must not be misrepresented as being the original software. + * + * 3. This notice may not be removed or altered from any source + * distribution. + ***************************************************************************/ +#ifndef __VPAD_FUNCTIONS_H_ +#define __VPAD_FUNCTIONS_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +#define VPAD_BUTTON_A 0x8000 +#define VPAD_BUTTON_B 0x4000 +#define VPAD_BUTTON_X 0x2000 +#define VPAD_BUTTON_Y 0x1000 +#define VPAD_BUTTON_LEFT 0x0800 +#define VPAD_BUTTON_RIGHT 0x0400 +#define VPAD_BUTTON_UP 0x0200 +#define VPAD_BUTTON_DOWN 0x0100 +#define VPAD_BUTTON_ZL 0x0080 +#define VPAD_BUTTON_ZR 0x0040 +#define VPAD_BUTTON_L 0x0020 +#define VPAD_BUTTON_R 0x0010 +#define VPAD_BUTTON_PLUS 0x0008 +#define VPAD_BUTTON_MINUS 0x0004 +#define VPAD_BUTTON_HOME 0x0002 +#define VPAD_BUTTON_SYNC 0x0001 +#define VPAD_BUTTON_STICK_R 0x00020000 +#define VPAD_BUTTON_STICK_L 0x00040000 +#define VPAD_BUTTON_TV 0x00010000 + +#define VPAD_STICK_R_EMULATION_LEFT 0x04000000 +#define VPAD_STICK_R_EMULATION_RIGHT 0x02000000 +#define VPAD_STICK_R_EMULATION_UP 0x01000000 +#define VPAD_STICK_R_EMULATION_DOWN 0x00800000 + +#define VPAD_STICK_L_EMULATION_LEFT 0x40000000 +#define VPAD_STICK_L_EMULATION_RIGHT 0x20000000 +#define VPAD_STICK_L_EMULATION_UP 0x10000000 +#define VPAD_STICK_L_EMULATION_DOWN 0x08000000 + + +typedef struct +{ + f32 x,y; +} Vec2D; + +typedef struct +{ + u16 x, y; /* Touch coordinates */ + u16 touched; /* 1 = Touched, 0 = Not touched */ + u16 invalid; /* 0 = All valid, 1 = X invalid, 2 = Y invalid, 3 = Both invalid? */ +} VPADTPData; + +typedef struct +{ + u32 btns_h; /* Held buttons */ + u32 btns_d; /* Buttons that are pressed at that instant */ + u32 btns_r; /* Released buttons */ + Vec2D lstick, rstick; /* Each contains 4-byte X and Y components */ + char unknown1c[0x52 - 0x1c]; /* Contains accelerometer and gyroscope data somewhere */ + VPADTPData tpdata; /* Normal touchscreen data */ + VPADTPData tpdata1; /* Modified touchscreen data 1 */ + VPADTPData tpdata2; /* Modified touchscreen data 2 */ + char unknown6a[0xa0 - 0x6a]; + uint8_t volume; + uint8_t battery; /* 0 to 6 */ + uint8_t unk_volume; /* One less than volume */ + char unknowna4[0xac - 0xa4]; +} VPADData; + +void InitVPadFunctionPointers(void); + +extern void (* VPADInit)(void); +extern void (* VPADRead)(int chan, VPADData *buffer, u32 buffer_size, s32 *error); + +#ifdef __cplusplus +} +#endif + +#endif // __VPAD_FUNCTIONS_H_ diff --git a/src/entry.c b/src/entry.c new file mode 100644 index 0000000..759cee0 --- /dev/null +++ b/src/entry.c @@ -0,0 +1,14 @@ +#include +#include "dynamic_libs/os_functions.h" +#include "dynamic_libs/sys_functions.h" +#include "common/common.h" +#include "utils/utils.h" +#include "main.h" + +int __entry_menu(int argc, char **argv) +{ + //! ******************************************************************* + //! * Jump to our application * + //! ******************************************************************* + return Menu_Main(); +} diff --git a/src/game/memory_area_table.c b/src/game/memory_area_table.c new file mode 100644 index 0000000..20ea351 --- /dev/null +++ b/src/game/memory_area_table.c @@ -0,0 +1,1729 @@ +/**************************************************************************** + * Copyright (C) 2015 Dimok + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + ****************************************************************************/ +#include +#include +#include +#include "common/common.h" +#include "memory_area_table.h" + +typedef struct _memory_values_t +{ + unsigned int start_address; + unsigned int end_address; +} memory_values_t; + +static const memory_values_t mem_vals_500[] = +{ + // TODO: Check which of those areas are usable +// { 0xB801308C, 0xB801701C } // size 16276 (15 kB) (0 MB) +// { 0xB80170B8, 0xB801B00C } // size 16216 (15 kB) (0 MB) +// { 0xB801B0B8, 0xB801F01C } // size 16232 (15 kB) (0 MB) +// { 0xB801F0C4, 0xB8023014 } // size 16212 (15 kB) (0 MB) +// { 0xB80230C4, 0xB8026EFC } // size 15932 (15 kB) (0 MB) +// { 0xB80270C4, 0xB802B014 } // size 16212 (15 kB) (0 MB) +// { 0xB802B0C4, 0xB802F014 } // size 16212 (15 kB) (0 MB) +// { 0xB802F0C4, 0xB8032E14 } // size 15700 (15 kB) (0 MB) +// { 0xB80330C4, 0xB8037014 } // size 16212 (15 kB) (0 MB) +// { 0xB803B068, 0xB803BC68 } // size 3076 (3 kB) (0 MB) +// { 0xB8043168, 0xB8044364 } // size 4608 (4 kB) (0 MB) +// { 0xB8045AF0, 0xB804E09C } // size 34224 (33 kB) (0 MB) +// { 0xB804E3D4, 0xB8050B24 } // size 10068 (9 kB) (0 MB) +// { 0xB8051940, 0xB805287C } // size 3904 (3 kB) (0 MB) +// { 0xB8052930, 0xB80538D4 } // size 4008 (3 kB) (0 MB) +// { 0xB8053934, 0xB805487C } // size 3916 (3 kB) (0 MB) +// { 0xB80566EC, 0xB8058664 } // size 8060 (7 kB) (0 MB) +// { 0xB80586EC, 0xB805A664 } // size 8060 (7 kB) (0 MB) +// { 0xB805A6EC, 0xB805C664 } // size 8060 (7 kB) (0 MB) +// { 0xB805CB90, 0xB805DC78 } // size 4332 (4 kB) (0 MB) +// { 0xB805E40C, 0xB805ECF0 } // size 2280 (2 kB) (0 MB) +// { 0xB8060044, 0xB8060F8C } // size 3916 (3 kB) (0 MB) +// { 0xB8061040, 0xB806203C } // size 4096 (4 kB) (0 MB) +// { 0xB8062DB4, 0xB806EE3C } // size 49292 (48 kB) (0 MB) +// { 0xB806EE84, 0xB8070DC4 } // size 8004 (7 kB) (0 MB) +// { 0xB8070E84, 0xB8072CFC } // size 7804 (7 kB) (0 MB) +// { 0xB8072E84, 0xB8074DC4 } // size 8004 (7 kB) (0 MB) +// { 0xB8076A30, 0xB807745C } // size 2608 (2 kB) (0 MB) +// { 0xB807FAF8, 0xB8081350 } // size 6236 (6 kB) (0 MB) +// { 0xB8081358, 0xB808228C } // size 3896 (3 kB) (0 MB) +// { 0xB8082358, 0xB808328C } // size 3896 (3 kB) (0 MB) +// { 0xB8083358, 0xB808428C } // size 3896 (3 kB) (0 MB) +// { 0xB80858E4, 0xB808787C } // size 8092 (7 kB) (0 MB) +// { 0xB80878F8, 0xB808B8A4 } // size 16304 (15 kB) (0 MB) +// { 0xB808C240, 0xB80901BC } // size 16256 (15 kB) (0 MB) +// { 0xB8090278, 0xB8092888 } // size 9748 (9 kB) (0 MB) +// { 0xB8092890, 0xB8097744 } // size 20152 (19 kB) (0 MB) +// { 0xB8097888, 0xB80A37E4 } // size 48992 (47 kB) (0 MB) +// { 0xB80A3818, 0xB80AF848 } // size 49204 (48 kB) (0 MB) +// { 0xB80AFAA0, 0xB80B0310 } // size 2164 (2 kB) (0 MB) +// { 0xB80B0320, 0xB80B16BC } // size 5024 (4 kB) (0 MB) +// { 0xB80B16C4, 0xB80B262C } // size 3948 (3 kB) (0 MB) +// { 0xB80B26C0, 0xB80B3B3C } // size 5248 (5 kB) (0 MB) +// { 0xB80B4200, 0xB80B5900 } // size 5892 (5 kB) (0 MB) +// { 0xB80B5934, 0xB80B713C } // size 6156 (6 kB) (0 MB) +// { 0xB80B8910, 0xB80BC074 } // size 14184 (13 kB) (0 MB) +// { 0xB80BC138, 0xB80BD13C } // size 4104 (4 kB) (0 MB) +// { 0xB80BD144, 0xB80C1084 } // size 16196 (15 kB) (0 MB) +// { 0xB80C1144, 0xB80C4E84 } // size 15684 (15 kB) (0 MB) +// { 0xB80C5144, 0xB80C9084 } // size 16196 (15 kB) (0 MB) +// { 0xB80CC780, 0xB80CCFA4 } // size 2088 (2 kB) (0 MB) +// { 0xB80CDEE4, 0xB80CE6E4 } // size 2052 (2 kB) (0 MB) +// { 0xB80CF600, 0xB80D707C } // size 31360 (30 kB) (0 MB) +// { 0xB80D719C, 0xB80DC3FC } // size 21092 (20 kB) (0 MB) +// { 0xB80DC61C, 0xB81748FC } // size 623332 (608 kB) (0 MB) +// { 0xB817552C, 0xB817B534 } // size 24588 (24 kB) (0 MB) +// { 0xB817BD38, 0xB818037C } // size 17992 (17 kB) (0 MB) +// { 0xB81804E0, 0xB81C037C } // size 261792 (255 kB) (0 MB) +// { 0xB81C14E8, 0xB81C85FC } // size 28952 (28 kB) (0 MB) +// { 0xB81C881C, 0xB81C97C0 } // size 4008 (3 kB) (0 MB) +// { 0xB81C981C, 0xB81CA7C0 } // size 4008 (3 kB) (0 MB) +// { 0xB81CA81C, 0xB81CB7C0 } // size 4008 (3 kB) (0 MB) +// { 0xB81CB81C, 0xB81CC7C0 } // size 4008 (3 kB) (0 MB) +// { 0xB81CC81C, 0xB81CD7C0 } // size 4008 (3 kB) (0 MB) +// { 0xB81CD9C0, 0xB81CE7C0 } // size 3588 (3 kB) (0 MB) +// { 0xB81CE870, 0xB81CF7C0 } // size 3924 (3 kB) (0 MB) +// { 0xB81CF870, 0xB81D07C0 } // size 3924 (3 kB) (0 MB) +// { 0xB81D0870, 0xB81D17C0 } // size 3924 (3 kB) (0 MB) +// { 0xB81D1870, 0xB81D27C0 } // size 3924 (3 kB) (0 MB) +// { 0xB81D296C, 0xB81D37C0 } // size 3672 (3 kB) (0 MB) +// { 0xB81D3ABC, 0xB81D47C0 } // size 3336 (3 kB) (0 MB) +// { 0xB81D481C, 0xB81D57C0 } // size 4008 (3 kB) (0 MB) +// { 0xB81D581C, 0xB81D67C0 } // size 4008 (3 kB) (0 MB) +// { 0xB81D6A68, 0xB81D77C0 } // size 3420 (3 kB) (0 MB) +// { 0xB81D796C, 0xB81D87C0 } // size 3672 (3 kB) (0 MB) +// { 0xB81D89C0, 0xB81D97C0 } // size 3588 (3 kB) (0 MB) +// { 0xB81D9870, 0xB81DA7C0 } // size 3924 (3 kB) (0 MB) +// { 0xB81DA81C, 0xB81DB7C0 } // size 4008 (3 kB) (0 MB) +// { 0xB81DB96C, 0xB81DC7C0 } // size 3672 (3 kB) (0 MB) +// { 0xB81DC9C0, 0xB81DD7C0 } // size 3588 (3 kB) (0 MB) +// { 0xB81DD870, 0xB81DE7C0 } // size 3924 (3 kB) (0 MB) +// { 0xB81DE81C, 0xB81DF7C0 } // size 4008 (3 kB) (0 MB) +// { 0xB81DF96C, 0xB81E07C0 } // size 3672 (3 kB) (0 MB) +// { 0xB81E09C0, 0xB81E17C0 } // size 3588 (3 kB) (0 MB) +// { 0xB81E1870, 0xB81E27C0 } // size 3924 (3 kB) (0 MB) +// { 0xB81E281C, 0xB820863C } // size 155172 (151 kB) (0 MB) +// { 0xB820B7C4, 0xB821063C } // size 20092 (19 kB) (0 MB) +// { 0xB8229490, 0xB822A4EC } // size 4192 (4 kB) (0 MB) +// { 0xB822F48C, 0xB823153C } // size 8372 (8 kB) (0 MB) +// { 0xB82327E4, 0xB8233060 } // size 2176 (2 kB) (0 MB) +// { 0xB8234080, 0xB824B340 } // size 94916 (92 kB) (0 MB) +// { 0xB824D8C0, 0xB828D880 } // size 262084 (255 kB) (0 MB) +// { 0xB82A8DE0, 0xB82B64FC } // size 55072 (53 kB) (0 MB) +// { 0xB82BC624, 0xB82C63FC } // size 40412 (39 kB) (0 MB) +// { 0xB82C642C, 0xB82CA42C } // size 16388 (16 kB) (0 MB) +// { 0xB82CBB6C, 0xB82CDB80 } // size 8216 (8 kB) (0 MB) +// { 0xB82CF708, 0xB82D0790 } // size 4236 (4 kB) (0 MB) +// { 0xB82D38FC, 0xB82D4A0C } // size 4372 (4 kB) (0 MB) +// { 0xB82EDF80, 0xB82EF77C } // size 6144 (6 kB) (0 MB) +// { 0xB82F6CA4, 0xB82F7820 } // size 2944 (2 kB) (0 MB) +// { 0xB82F79B0, 0xB82F861C } // size 3184 (3 kB) (0 MB) +// { 0xB82F8FB0, 0xB82FA080 } // size 4308 (4 kB) (0 MB) +// { 0xB8302A78, 0xB830428C } // size 6168 (6 kB) (0 MB) +// { 0xB8333434, 0xB8337D0C } // size 18652 (18 kB) (0 MB) +// { 0xB8338ED0, 0xB83396DC } // size 2064 (2 kB) (0 MB) +// { 0xB833C5E0, 0xB8340EAC } // size 18640 (18 kB) (0 MB) +// { 0xB834DB34, 0xB834EB40 } // size 4112 (4 kB) (0 MB) +// { 0xB83542F0, 0xB8356344 } // size 8280 (8 kB) (0 MB) +// { 0xB83574B0, 0xB83583FC } // size 3920 (3 kB) (0 MB) +// { 0xB8358A80, 0xB835A430 } // size 6580 (6 kB) (0 MB) +// { 0xB835AA08, 0xB8366884 } // size 48768 (47 kB) (0 MB) +// { 0xB8366B04, 0xB836DEE8 } // size 29672 (28 kB) (0 MB) +// { 0xB836E0DC, 0xB8378E3C } // size 44388 (43 kB) (0 MB) +// { 0xB8378E44, 0xB837CC6C } // size 15916 (15 kB) (0 MB) +// { 0xB837D5E4, 0xB8381524 } // size 16196 (15 kB) (0 MB) +// { 0xB83A3AE4, 0xB83A5308 } // size 6184 (6 kB) (0 MB) +// { 0xB83A73DC, 0xB84D2AE4 } // size 1226508 (1197 kB) (1 MB) +// { 0xB84D2F80, 0xB84D393C } // size 2496 (2 kB) (0 MB) +// { 0xB84D43C0, 0xB84D513C } // size 3456 (3 kB) (0 MB) +// { 0xB84D604C, 0xB84D6F68 } // size 3872 (3 kB) (0 MB) +// { 0xB84D7730, 0xB85021FC } // size 174800 (170 kB) (0 MB) +// { 0xB8583B7C, 0xB8584538 } // size 2496 (2 kB) (0 MB) +// { 0xB8585F34, 0xB858937C } // size 13388 (13 kB) (0 MB) +// { 0xB8589A88, 0xB858DC3C } // size 16824 (16 kB) (0 MB) +// { 0xB858DC64, 0xB859B40C } // size 55212 (53 kB) (0 MB) +// { 0xB85A8728, 0xB85A90A4 } // size 2432 (2 kB) (0 MB) +// { 0xB85A90BC, 0xB85B3448 } // size 41872 (40 kB) (0 MB) +// { 0xB85B3488, 0xB85C626C } // size 77288 (75 kB) (0 MB) +// { 0xB85C6314, 0xB85C7874 } // size 5476 (5 kB) (0 MB) +// { 0xB85CF8DC, 0xB85D147C } // size 7076 (6 kB) (0 MB) +// { 0xB85D1484, 0xB85E1284 } // size 65028 (63 kB) (0 MB) +// { 0xB85E1484, 0xB85ED094 } // size 48148 (47 kB) (0 MB) +// { 0xB85ED1E4, 0xB85EECFC } // size 6940 (6 kB) (0 MB) +// { 0xB85EF1C8, 0xB85F02DC } // size 4376 (4 kB) (0 MB) +// { 0xB85F1484, 0xB8601284 } // size 65028 (63 kB) (0 MB) +// { 0xB8601480, 0xB8604FFC } // size 15232 (14 kB) (0 MB) +// { 0xB8608F18, 0xB86147F8 } // size 47332 (46 kB) (0 MB) +// { 0xB8615000, 0xB8615FFC } // size 4096 (4 kB) (0 MB) +// { 0xB861CA00, 0xB861DF40 } // size 5444 (5 kB) (0 MB) +// { 0xB861F3E4, 0xB8632B00 } // size 79648 (77 kB) (0 MB) +// { 0xB8639790, 0xB8649BC0 } // size 66612 (65 kB) (0 MB) +// { 0xB86502E0, 0xB865EE00 } // size 60196 (58 kB) (0 MB) +// { 0xB86601FC, 0xB8667EE0 } // size 31976 (31 kB) (0 MB) +// { 0xB866A894, 0xB866B6C0 } // size 3632 (3 kB) (0 MB) +// { 0xB866BF58, 0xB86745A0 } // size 34380 (33 kB) (0 MB) +// { 0xB86807B4, 0xB868D680 } // size 52944 (51 kB) (0 MB) +// { 0xB8690D2C, 0xB86B3CA0 } // size 143224 (139 kB) (0 MB) +// { 0xB86C45F8, 0xB86D2900 } // size 58124 (56 kB) (0 MB) +// { 0xB86D7AA4, 0xB86EEB80 } // size 94432 (92 kB) (0 MB) +// { 0xB86F0700, 0xB86F1FC0 } // size 6340 (6 kB) (0 MB) +// { 0xB86F21A0, 0xB86F2BB8 } // size 2588 (2 kB) (0 MB) +// { 0xB86F3290, 0xB86F73A0 } // size 16660 (16 kB) (0 MB) +// { 0xB86F740C, 0xB8702DC0 } // size 47544 (46 kB) (0 MB) +// { 0xB8704880, 0xB871E3C0 } // size 105284 (102 kB) (0 MB) +// { 0xB87202F0, 0xB8720D80 } // size 2708 (2 kB) (0 MB) +// { 0xB8721978, 0xB872AD80 } // size 37900 (37 kB) (0 MB) +// { 0xB873B684, 0xB874C180 } // size 68352 (66 kB) (0 MB) +// { 0xB8751354, 0xB8769780 } // size 99376 (97 kB) (0 MB) +// { 0xB876CC88, 0xB876D5C8 } // size 2372 (2 kB) (0 MB) +// { 0xB87768AC, 0xB877BF7C } // size 22228 (21 kB) (0 MB) +// { 0xB877C238, 0xB8788B40 } // size 51468 (50 kB) (0 MB) +// { 0xB8789618, 0xB878A67C } // size 4200 (4 kB) (0 MB) +// { 0xB878A684, 0xB878B6FC } // size 4220 (4 kB) (0 MB) +// { 0xB878B798, 0xB878C7FC } // size 4200 (4 kB) (0 MB) +// { 0xB878C804, 0xB878D87C } // size 4220 (4 kB) (0 MB) +// { 0xB878D918, 0xB878E97C } // size 4200 (4 kB) (0 MB) +// { 0xB878E984, 0xB878F9FC } // size 4220 (4 kB) (0 MB) +// { 0xB878FA98, 0xB8790AFC } // size 4200 (4 kB) (0 MB) +// { 0xB8790B04, 0xB8791B7C } // size 4220 (4 kB) (0 MB) +// { 0xB8791C18, 0xB8792C7C } // size 4200 (4 kB) (0 MB) +// { 0xB8792C84, 0xB8793CFC } // size 4220 (4 kB) (0 MB) +// { 0xB8793D98, 0xB8794DFC } // size 4200 (4 kB) (0 MB) +// { 0xB8794E04, 0xB8795E7C } // size 4220 (4 kB) (0 MB) +// { 0xB8795F18, 0xB8796F7C } // size 4200 (4 kB) (0 MB) +// { 0xB8796F84, 0xB8797FFC } // size 4220 (4 kB) (0 MB) +// { 0xB8798098, 0xB87990FC } // size 4200 (4 kB) (0 MB) +// { 0xB8799104, 0xB879A17C } // size 4220 (4 kB) (0 MB) +// { 0xB879A218, 0xB879B27C } // size 4200 (4 kB) (0 MB) +// { 0xB879B284, 0xB879C2FC } // size 4220 (4 kB) (0 MB) +// { 0xB879C398, 0xB879D3FC } // size 4200 (4 kB) (0 MB) +// { 0xB879D404, 0xB879E47C } // size 4220 (4 kB) (0 MB) +// { 0xB879E518, 0xB879F57C } // size 4200 (4 kB) (0 MB) +// { 0xB879F584, 0xB87A05FC } // size 4220 (4 kB) (0 MB) +// { 0xB87A0698, 0xB87A16FC } // size 4200 (4 kB) (0 MB) +// { 0xB87A1704, 0xB87A277C } // size 4220 (4 kB) (0 MB) +// { 0xB87A2818, 0xB87A387C } // size 4200 (4 kB) (0 MB) +// { 0xB87A3884, 0xB87A48FC } // size 4220 (4 kB) (0 MB) +// { 0xB87A4998, 0xB87A59FC } // size 4200 (4 kB) (0 MB) +// { 0xB87A5A04, 0xB87A6A7C } // size 4220 (4 kB) (0 MB) +// { 0xB87A6B18, 0xB87A7B7C } // size 4200 (4 kB) (0 MB) +// { 0xB87A7B84, 0xB87A8BFC } // size 4220 (4 kB) (0 MB) +// { 0xB87A8C98, 0xB87A9CFC } // size 4200 (4 kB) (0 MB) +// { 0xB87A9D04, 0xB87AAD7C } // size 4220 (4 kB) (0 MB) +// { 0xB87AAE18, 0xB87ABE7C } // size 4200 (4 kB) (0 MB) +// { 0xB87ABE84, 0xB87ACEFC } // size 4220 (4 kB) (0 MB) +// { 0xB87AD004, 0xB87ADFFC } // size 4092 (3 kB) (0 MB) +// { 0xB87AE004, 0xB87AF07C } // size 4220 (4 kB) (0 MB) +// { 0xB87AF118, 0xB87B017C } // size 4200 (4 kB) (0 MB) +// { 0xB87B0184, 0xB87B11FC } // size 4220 (4 kB) (0 MB) +// { 0xB87B1298, 0xB87B22FC } // size 4200 (4 kB) (0 MB) +// { 0xB87B2304, 0xB87B337C } // size 4220 (4 kB) (0 MB) +// { 0xB87B3418, 0xB87B447C } // size 4200 (4 kB) (0 MB) +// { 0xB87B474C, 0xB87B54FC } // size 3508 (3 kB) (0 MB) +// { 0xB87B5598, 0xB87B65FC } // size 4200 (4 kB) (0 MB) +// { 0xB87B6684, 0xB87B767C } // size 4092 (3 kB) (0 MB) +// { 0xB87B7718, 0xB87B877C } // size 4200 (4 kB) (0 MB) +// { 0xB87B8784, 0xB87B97FC } // size 4220 (4 kB) (0 MB) +// { 0xB87B9898, 0xB87BA8FC } // size 4200 (4 kB) (0 MB) +// { 0xB87BA904, 0xB87BB97C } // size 4220 (4 kB) (0 MB) +// { 0xB87BBA18, 0xB87BCA7C } // size 4200 (4 kB) (0 MB) +// { 0xB87BCA84, 0xB87BDAFC } // size 4220 (4 kB) (0 MB) +// { 0xB87BDB98, 0xB87BEBFC } // size 4200 (4 kB) (0 MB) +// { 0xB87BEC04, 0xB87BFC7C } // size 4220 (4 kB) (0 MB) +// { 0xB87BFD18, 0xB87C0D7C } // size 4200 (4 kB) (0 MB) +// { 0xB87C0D84, 0xB87C1DFC } // size 4220 (4 kB) (0 MB) +// { 0xB87C1E98, 0xB87C2EFC } // size 4200 (4 kB) (0 MB) +// { 0xB87C2F04, 0xB87C3F7C } // size 4220 (4 kB) (0 MB) +// { 0xB87C4018, 0xB87C507C } // size 4200 (4 kB) (0 MB) +// { 0xB87C5084, 0xB87C60FC } // size 4220 (4 kB) (0 MB) +// { 0xB87C6198, 0xB87C71FC } // size 4200 (4 kB) (0 MB) +// { 0xB87C7204, 0xB87C827C } // size 4220 (4 kB) (0 MB) +// { 0xB87C8318, 0xB87C937C } // size 4200 (4 kB) (0 MB) +// { 0xB87C9384, 0xB87CA3FC } // size 4220 (4 kB) (0 MB) +// { 0xB87CA498, 0xB87CB4FC } // size 4200 (4 kB) (0 MB) +// { 0xB87CB504, 0xB87CC57C } // size 4220 (4 kB) (0 MB) +// { 0xB87CC618, 0xB87CD67C } // size 4200 (4 kB) (0 MB) +// { 0xB87CD684, 0xB87CE6FC } // size 4220 (4 kB) (0 MB) +// { 0xB87CE798, 0xB87CF7FC } // size 4200 (4 kB) (0 MB) +// { 0xB87CF804, 0xB87D087C } // size 4220 (4 kB) (0 MB) +// { 0xB87D0918, 0xB87D197C } // size 4200 (4 kB) (0 MB) +// { 0xB87D1984, 0xB87D29FC } // size 4220 (4 kB) (0 MB) +// { 0xB87D2A98, 0xB87D3AFC } // size 4200 (4 kB) (0 MB) +// { 0xB87D3B04, 0xB87D4B7C } // size 4220 (4 kB) (0 MB) +// { 0xB87D4C18, 0xB87D5C7C } // size 4200 (4 kB) (0 MB) +// { 0xB87D5C84, 0xB87D6CFC } // size 4220 (4 kB) (0 MB) +// { 0xB87D6D98, 0xB87D7DFC } // size 4200 (4 kB) (0 MB) +// { 0xB87D7E04, 0xB87D8EFC } // size 4348 (4 kB) (0 MB) +// { 0xB87D8F18, 0xB87D9F7C } // size 4200 (4 kB) (0 MB) +// { 0xB87D9F84, 0xB87DB07C } // size 4348 (4 kB) (0 MB) +// { 0xB87DB098, 0xB87DC0FC } // size 4200 (4 kB) (0 MB) +// { 0xB87DC104, 0xB87DD17C } // size 4220 (4 kB) (0 MB) +// { 0xB87DD284, 0xB87DE27C } // size 4092 (3 kB) (0 MB) +// { 0xB87DE284, 0xB87DF37C } // size 4348 (4 kB) (0 MB) +// { 0xB87DF398, 0xB87E03FC } // size 4200 (4 kB) (0 MB) +// { 0xB87E06CC, 0xB87E147C } // size 3508 (3 kB) (0 MB) +// { 0xB87E1518, 0xB87E257C } // size 4200 (4 kB) (0 MB) +// { 0xB87E2604, 0xB87E35FC } // size 4092 (3 kB) (0 MB) +// { 0xB87E3698, 0xB87E46FC } // size 4200 (4 kB) (0 MB) +// { 0xB87E4704, 0xB87E577C } // size 4220 (4 kB) (0 MB) +// { 0xB87E5818, 0xB87E687C } // size 4200 (4 kB) (0 MB) +// { 0xB87E6884, 0xB87E78FC } // size 4220 (4 kB) (0 MB) +// { 0xB87E7998, 0xB87E89FC } // size 4200 (4 kB) (0 MB) +// { 0xB87E8A04, 0xB87E9A7C } // size 4220 (4 kB) (0 MB) +// { 0xB87E9B18, 0xB87EAB7C } // size 4200 (4 kB) (0 MB) +// { 0xB87EAB84, 0xB87EBBFC } // size 4220 (4 kB) (0 MB) +// { 0xB87EBC98, 0xB87ECCFC } // size 4200 (4 kB) (0 MB) +// { 0xB87ECD04, 0xB87EDD7C } // size 4220 (4 kB) (0 MB) +// { 0xB87EDE18, 0xB87EEE7C } // size 4200 (4 kB) (0 MB) +// { 0xB87EEE84, 0xB87EFEFC } // size 4220 (4 kB) (0 MB) +// { 0xB87EFF98, 0xB87F0FFC } // size 4200 (4 kB) (0 MB) +// { 0xB87F1004, 0xB87F207C } // size 4220 (4 kB) (0 MB) +// { 0xB87F2118, 0xB87F317C } // size 4200 (4 kB) (0 MB) +// { 0xB87F3184, 0xB87F41FC } // size 4220 (4 kB) (0 MB) +// { 0xB87F4298, 0xB87F52FC } // size 4200 (4 kB) (0 MB) +// { 0xB87F5304, 0xB87F637C } // size 4220 (4 kB) (0 MB) +// { 0xB87F6418, 0xB87F747C } // size 4200 (4 kB) (0 MB) +// { 0xB87F7484, 0xB87F84FC } // size 4220 (4 kB) (0 MB) +// { 0xB87F8598, 0xB87F95FC } // size 4200 (4 kB) (0 MB) +// { 0xB87F9604, 0xB87FA67C } // size 4220 (4 kB) (0 MB) +// { 0xB87FA718, 0xB87FB77C } // size 4200 (4 kB) (0 MB) +// { 0xB87FB784, 0xB87FC7FC } // size 4220 (4 kB) (0 MB) +// { 0xB87FC898, 0xB87FD8FC } // size 4200 (4 kB) (0 MB) +// { 0xB87FD904, 0xB87FE97C } // size 4220 (4 kB) (0 MB) +// { 0xB87FEA18, 0xB87FFA7C } // size 4200 (4 kB) (0 MB) +// { 0xB87FFA84, 0xB8800AFC } // size 4220 (4 kB) (0 MB) +// { 0xB8800B98, 0xB8801BFC } // size 4200 (4 kB) (0 MB) +// { 0xB8801C04, 0xB8802C7C } // size 4220 (4 kB) (0 MB) +// { 0xB8802D18, 0xB8803D7C } // size 4200 (4 kB) (0 MB) +// { 0xB8803D84, 0xB8804E7C } // size 4348 (4 kB) (0 MB) +// { 0xB8804E98, 0xB8805EFC } // size 4200 (4 kB) (0 MB) +// { 0xB8805F04, 0xB8806FFC } // size 4348 (4 kB) (0 MB) +// { 0xB8807018, 0xB880807C } // size 4200 (4 kB) (0 MB) +// { 0xB8808084, 0xB88090FC } // size 4220 (4 kB) (0 MB) +// { 0xB8809204, 0xB880A1FC } // size 4092 (3 kB) (0 MB) +// { 0xB880A204, 0xB880B2FC } // size 4348 (4 kB) (0 MB) +// { 0xB880B318, 0xB880C37C } // size 4200 (4 kB) (0 MB) +// { 0xB880C64C, 0xB880D3FC } // size 3508 (3 kB) (0 MB) +// { 0xB880D498, 0xB880E4FC } // size 4200 (4 kB) (0 MB) +// { 0xB880E584, 0xB880F57C } // size 4092 (3 kB) (0 MB) +// { 0xB880F584, 0xB881183C } // size 8892 (8 kB) (0 MB) +// { 0xB8811844, 0xB881B680 } // size 40512 (39 kB) (0 MB) +// { 0xB882058C, 0xB882F6E0 } // size 61784 (60 kB) (0 MB) +// { 0xB8832638, 0xB883AA40 } // size 33804 (33 kB) (0 MB) +// { 0xB883ECDC, 0xB883F900 } // size 3112 (3 kB) (0 MB) +// { 0xB8840298, 0xB8847BC0 } // size 31020 (30 kB) (0 MB) +// { 0xB88485D0, 0xB88565BC } // size 57328 (55 kB) (0 MB) +// { 0xB88565D8, 0xB88626D4 } // size 49408 (48 kB) (0 MB) +// { 0xB88627DC, 0xB8872900 } // size 65832 (64 kB) (0 MB) +// { 0xB8875AE0, 0xB8883100 } // size 54820 (53 kB) (0 MB) +// { 0xB888482C, 0xB8885EBC } // size 5780 (5 kB) (0 MB) +// { 0xB8885ED8, 0xB888B100 } // size 21036 (20 kB) (0 MB) +// { 0xB888D590, 0xB8891F40 } // size 18868 (18 kB) (0 MB) +// { 0xB88954F8, 0xB8895CF8 } // size 2052 (2 kB) (0 MB) +// { 0xB8897854, 0xB8898054 } // size 2052 (2 kB) (0 MB) +// { 0xB88998F4, 0xB889C350 } // size 10848 (10 kB) (0 MB) +// { 0xB889C35C, 0xB889D780 } // size 5160 (5 kB) (0 MB) +// { 0xB889DA80, 0xB88A9A80 } // size 49156 (48 kB) (0 MB) +// { 0xB88A9A88, 0xB88B5C88 } // size 49668 (48 kB) (0 MB) +// { 0xB88B5C90, 0xB88C1E90 } // size 49668 (48 kB) (0 MB) +// { 0xB88C1E98, 0xB88EB09C } // size 168456 (164 kB) (0 MB) +// { 0xB88EB0A4, 0xB88EEC10 } // size 15216 (14 kB) (0 MB) +// { 0xB88EEC30, 0xB8B06E94 } // size 2196072 (2144 kB) (2 MB) +// { 0xB8B06EC4, 0xB8B930C0 } // size 573952 (560 kB) (0 MB) +// { 0xB8BA1868, 0xB8BC22A0 } // size 133692 (130 kB) (0 MB) +// { 0xB8BC47F0, 0xB8BDEC80 } // size 107668 (105 kB) (0 MB) +// { 0xB8BDFBF4, 0xB8BE2640 } // size 10832 (10 kB) (0 MB) +// { 0xB8BE2C7C, 0xB8BE3D8C } // size 4372 (4 kB) (0 MB) +// { 0xB8BE3DC0, 0xB8C02280 } // size 124100 (121 kB) (0 MB) +// { 0xB8C02FC8, 0xB8C19920 } // size 92508 (90 kB) (0 MB) +// { 0xB8C2D35C, 0xB8C3DDC0 } // size 68200 (66 kB) (0 MB) +// { 0xB8C48654, 0xB8C6E2E0 } // size 154768 (151 kB) (0 MB) +// { 0xB8C80608, 0xB8C87040 } // size 27196 (26 kB) (0 MB) +// { 0xB8C8C694, 0xB8C8F3C0 } // size 11568 (11 kB) (0 MB) +// { 0xB8C90734, 0xB8C94904 } // size 16852 (16 kB) (0 MB) +// { 0xB8C94970, 0xB8CA1500 } // size 52116 (50 kB) (0 MB) +// { 0xB8CA28B8, 0xB8CA5080 } // size 10188 (9 kB) (0 MB) +// { 0xB8CA50C4, 0xB8CA6E94 } // size 7636 (7 kB) (0 MB) +// { 0xB8CA7104, 0xB8CA88AC } // size 6060 (5 kB) (0 MB) +// { 0xB8CA9144, 0xB8CAAF14 } // size 7636 (7 kB) (0 MB) +// { 0xB8CAB180, 0xB8CAD180 } // size 8196 (8 kB) (0 MB) +// { 0xB8CADB7C, 0xB8CAEFC0 } // size 5192 (5 kB) (0 MB) +// { 0xB8CF81C0, 0xB8CF8F3C } // size 3456 (3 kB) (0 MB) +// { 0xB8CF8F44, 0xB8CF9E8C } // size 3916 (3 kB) (0 MB) +// { 0xB8CFA100, 0xB8CFA9C4 } // size 2248 (2 kB) (0 MB) +// { 0xB8CFB940, 0xB8CFCD30 } // size 5108 (4 kB) (0 MB) +// { 0xB8CFDD40, 0xB8CFECFC } // size 4032 (3 kB) (0 MB) +// { 0xB8CFEEE0, 0xB8CFFEFC } // size 4128 (4 kB) (0 MB) +// { 0xB8CFFF38, 0xB8D021FC } // size 8904 (8 kB) (0 MB) +// { 0xB8D0221C, 0xB8D035FC } // size 5092 (4 kB) (0 MB) +// { 0xB8D04E04, 0xB8D36934 } // size 203572 (198 kB) (0 MB) +// { 0xB8D3C194, 0xB8D3CE30 } // size 3232 (3 kB) (0 MB) +// { 0xB8D3CF44, 0xB8D3DBE0 } // size 3232 (3 kB) (0 MB) +// { 0xB8D3DCF4, 0xB8D3E990 } // size 3232 (3 kB) (0 MB) +// { 0xB8D3EAA4, 0xB8D3F740 } // size 3232 (3 kB) (0 MB) +// { 0xB8D3F850, 0xB8D404F0 } // size 3236 (3 kB) (0 MB) +// { 0xB8D40600, 0xB8D412A0 } // size 3236 (3 kB) (0 MB) +// { 0xB8D413B0, 0xB8D42050 } // size 3236 (3 kB) (0 MB) +// { 0xB8D47148, 0xB8D485C0 } // size 5244 (5 kB) (0 MB) +// { 0xB8D488D4, 0xB8D49D40 } // size 5232 (5 kB) (0 MB) +// { 0xB8D49FE4, 0xB8D4B440 } // size 5216 (5 kB) (0 MB) +// { 0xB8D4B7EC, 0xB8D4CC40 } // size 5208 (5 kB) (0 MB) +// { 0xB8D81D64, 0xB8D8FF8C } // size 57900 (56 kB) (0 MB) +// { 0xB8D954E0, 0xB8D9634C } // size 3696 (3 kB) (0 MB) +// { 0xB8D9A238, 0xB8D9C1CC } // size 8088 (7 kB) (0 MB) +// { 0xB8D9D258, 0xB8D9F1EC } // size 8088 (7 kB) (0 MB) +// { 0xB8D9FF20, 0xB8DA1EB4 } // size 8088 (7 kB) (0 MB) +// { 0xB8DB58E0, 0xB8DB74C0 } // size 7140 (6 kB) (0 MB) +// { 0xB8DB7E4C, 0xB8DB8C1C } // size 3540 (3 kB) (0 MB) +// { 0xB8DB95A8, 0xB8DBAA3C } // size 5272 (5 kB) (0 MB) +// { 0xB8DC6A0C, 0xB8E14284 } // size 317564 (310 kB) (0 MB) +// { 0xB8E142B0, 0xB8E152B0 } // size 4100 (4 kB) (0 MB) +// { 0xB8E15554, 0xB8E16360 } // size 3600 (3 kB) (0 MB) +// { 0xB8E18548, 0xB8E19544 } // size 4096 (4 kB) (0 MB) +// { 0xB8E1A1E0, 0xB8E1C1DC } // size 8192 (8 kB) (0 MB) +// { 0xB8E1D200, 0xB8E1F1FC } // size 8192 (8 kB) (0 MB) +// { 0xB8E1FEC8, 0xB8E21EC4 } // size 8192 (8 kB) (0 MB) +// { 0xB8E21ED4, 0xB8EC8294 } // size 680900 (664 kB) (0 MB) +// { 0xB8EC82C0, 0xB8EC92C0 } // size 4100 (4 kB) (0 MB) +// { 0xB8EC9380, 0xB8ECA370 } // size 4084 (3 kB) (0 MB) +// { 0xB8ECE1F0, 0xB8ED01EC } // size 8192 (8 kB) (0 MB) +// { 0xB8ED1210, 0xB8ED320C } // size 8192 (8 kB) (0 MB) +// { 0xB8ED3ED8, 0xB8ED5ED4 } // size 8192 (8 kB) (0 MB) +// { 0xB8ED9AE8, 0xB8EDC63C } // size 11096 (10 kB) (0 MB) +// { 0xB8EDC678, 0xB8EDCF34 } // size 2240 (2 kB) (0 MB) +// { 0xB8EDDC7C, 0xB8F7C2A4 } // size 648748 (633 kB) (0 MB) +// { 0xB8F7C2D0, 0xB8F7D2D0 } // size 4100 (4 kB) (0 MB) +// { 0xB8F7D574, 0xB8F7E380 } // size 3600 (3 kB) (0 MB) +// { 0xB8F80568, 0xB8F81564 } // size 4096 (4 kB) (0 MB) +// { 0xB8F82200, 0xB8F841FC } // size 8192 (8 kB) (0 MB) +// { 0xB8F85220, 0xB8F8721C } // size 8192 (8 kB) (0 MB) +// { 0xB8F87EE8, 0xB8F89EE4 } // size 8192 (8 kB) (0 MB) +// { 0xB8F89EF4, 0xB90302B4 } // size 680900 (664 kB) (0 MB) +// { 0xB9030800, 0xB93F69FC } // size 3957248 (3864 kB) (3 MB) +// { 0xB94128D4, 0xB94179C0 } // size 20720 (20 kB) (0 MB) +// { 0xB942587C, 0xB94307FC } // size 44932 (43 kB) (0 MB) +// { 0xB96CE000, 0xB96E0A9C } // size 76448 (74 kB) (0 MB) +// { 0xB970200C, 0xB98B9C54 } // size 1801292 (1759 kB) (1 MB) +// { 0xB98E9794, 0xB98F1794 } // size 32772 (32 kB) (0 MB) +// { 0xB9F13600, 0xB9F175FC } // size 16384 (16 kB) (0 MB) +// { 0xB9F17658, 0xB9F67658 } // size 327684 (320 kB) (0 MB) +// { 0xB9F6779C, 0xB9FB779C } // size 327684 (320 kB) (0 MB) +// { 0xB9FB78E0, 0xBA0078E0 } // size 327684 (320 kB) (0 MB) +// { 0xBA007A24, 0xBA057A24 } // size 327684 (320 kB) (0 MB) +// { 0xBA057B68, 0xBA1B9578 } // size 1448468 (1414 kB) (1 MB) +// { 0xBA1BA20C, 0xBA1BBFF8 } // size 7664 (7 kB) (0 MB) +// { 0xBA1BC04C, 0xBA1BDFFC } // size 8116 (7 kB) (0 MB) +// { 0xBA1BE0DC, 0xBA1BFFFC } // size 7972 (7 kB) (0 MB) +// { 0xBA1C7028, 0xBA1C7FFC } // size 4056 (3 kB) (0 MB) +// { 0xBA1CA23C, 0xBA1CBFF8 } // size 7616 (7 kB) (0 MB) +// { 0xBA1CC044, 0xBA1CDFFC } // size 8124 (7 kB) (0 MB) +// { 0xBA1CE2E4, 0xBA1CFFFC } // size 7452 (7 kB) (0 MB) +// { 0xBA1D4028, 0xBA1D5FFC } // size 8152 (7 kB) (0 MB) +// { 0xBA1DA698, 0xBA1DBFFC } // size 6504 (6 kB) (0 MB) +// { 0xBA1E02D0, 0xBA1E1FFC } // size 7472 (7 kB) (0 MB) +// { 0xBA1E6028, 0xBA1E7FFC } // size 8152 (7 kB) (0 MB) +// { 0xBA1EC028, 0xBA1EDFFC } // size 8152 (7 kB) (0 MB) +// { 0xBA1F2028, 0xBA1F3FFC } // size 8152 (7 kB) (0 MB) +// { 0xBA1F8028, 0xBA1F9FFC } // size 8152 (7 kB) (0 MB) +// { 0xBA1FE028, 0xBA1FFFFC } // size 8152 (7 kB) (0 MB) +// { 0xBA204674, 0xBA205FFC } // size 6540 (6 kB) (0 MB) +// { 0xBA20A028, 0xBA20BFFC } // size 8152 (7 kB) (0 MB) +// { 0xBA210028, 0xBA211FFC } // size 8152 (7 kB) (0 MB) +// { 0xBA234050, 0xBA235FFC } // size 8112 (7 kB) (0 MB) +// { 0xBA2360AC, 0xBA236FFC } // size 3924 (3 kB) (0 MB) +// { 0xBA2587BC, 0xBA259FF8 } // size 6208 (6 kB) (0 MB) +// { 0xBA25A04C, 0xBA25BFFC } // size 8116 (7 kB) (0 MB) +// { 0xBA25C07C, 0xBA25CFFC } // size 3972 (3 kB) (0 MB) +// { 0xBA26109C, 0xBA261FF8 } // size 3936 (3 kB) (0 MB) +// { 0xBA262054, 0xBA263FFC } // size 8108 (7 kB) (0 MB) +// { 0xBA2643C8, 0xBA265FFC } // size 7224 (7 kB) (0 MB) +// { 0xBA26E028, 0xBA26EFFC } // size 4056 (3 kB) (0 MB) +// { 0xBA271028, 0xBA271FFC } // size 4056 (3 kB) (0 MB) +// { 0xBA274028, 0xBA2751FC } // size 4568 (4 kB) (0 MB) +// { 0xBA2752C0, 0xBA275FFC } // size 3392 (3 kB) (0 MB) +// { 0xBA276028, 0xBA277FFC } // size 8152 (7 kB) (0 MB) +// { 0xBA27C028, 0xBA27E1FC } // size 8664 (8 kB) (0 MB) +// { 0xBA282028, 0xBA282FFC } // size 4056 (3 kB) (0 MB) +// { 0xBA285028, 0xBA285FFC } // size 4056 (3 kB) (0 MB) +// { 0xBA2A0154, 0xBA2A1FFC } // size 7852 (7 kB) (0 MB) +// { 0xBA2A6504, 0xBA2A81FC } // size 7420 (7 kB) (0 MB) +// { 0xBA2AC028, 0xBA2ADFFC } // size 8152 (7 kB) (0 MB) +// { 0xBA2B249C, 0xBA2B3FF8 } // size 7008 (6 kB) (0 MB) +// { 0xBA2B4044, 0xBA2B5FFC } // size 8124 (7 kB) (0 MB) +// { 0xBA2F0AFC, 0xBA2F1FF8 } // size 5376 (5 kB) (0 MB) +// { 0xBA2F2068, 0xBA2F3FFC } // size 8088 (7 kB) (0 MB) +// { 0xBA2F412C, 0xBA2F5FFC } // size 7892 (7 kB) (0 MB) +// { 0xBA2F67FC, 0xBA2F7FF8 } // size 6144 (6 kB) (0 MB) +// { 0xBA2F804C, 0xBA2F9FFC } // size 8116 (7 kB) (0 MB) +// { 0xBA2FA2C8, 0xBA2FBFFC } // size 7480 (7 kB) (0 MB) +// { 0xBA2FC294, 0xBA2FE1FC } // size 8044 (7 kB) (0 MB) +// { 0xBA302028, 0xBA3041FC } // size 8664 (8 kB) (0 MB) +// { 0xBA318828, 0xBA319FFC } // size 6104 (5 kB) (0 MB) +// { 0xBA31E1A0, 0xBA31FFFC } // size 7776 (7 kB) (0 MB) +// { 0xBA3227F0, 0xBA323FFC } // size 6160 (6 kB) (0 MB) +// { 0xBA334828, 0xBA335FFC } // size 6104 (5 kB) (0 MB) +// { 0xBA33E048, 0xBA33FFFC } // size 8120 (7 kB) (0 MB) +// { 0xBA342F80, 0xBA3437FC } // size 2176 (2 kB) (0 MB) +// { 0xBA343828, 0xBA344044 } // size 2080 (2 kB) (0 MB) +// { 0xBA346028, 0xBA346954 } // size 2352 (2 kB) (0 MB) +// { 0xBA348828, 0xBA349124 } // size 2304 (2 kB) (0 MB) +// { 0xBA355828, 0xBA356574 } // size 3408 (3 kB) (0 MB) +// { 0xBA35E04C, 0xBA35FFFC } // size 8116 (7 kB) (0 MB) +// { 0xBA360080, 0xBA360FFC } // size 3968 (3 kB) (0 MB) +// { 0xBA361444, 0xBA361FFC } // size 3004 (2 kB) (0 MB) +// { 0xBA36423C, 0xBA365FF8 } // size 7616 (7 kB) (0 MB) +// { 0xBA3E2048, 0xBA3E3FFC } // size 8120 (7 kB) (0 MB) +// { 0xBA3E4B3C, 0xBA3E5FF8 } // size 5312 (5 kB) (0 MB) +// { 0xBA3E6054, 0xBA3E7FFC } // size 8108 (7 kB) (0 MB) +// { 0xBA3E895C, 0xBA3E9FF8 } // size 5792 (5 kB) (0 MB) +// { 0xBA3EA050, 0xBA3EBFFC } // size 8112 (7 kB) (0 MB) +// { 0xBA3EC10C, 0xBA3EDFFC } // size 7924 (7 kB) (0 MB) +// { 0xBA3F2028, 0xBA3F2FFC } // size 4056 (3 kB) (0 MB) +// { 0xBA3FF028, 0xBA3FFFFC } // size 4056 (3 kB) (0 MB) +// { 0xBA402028, 0xBA402FFC } // size 4056 (3 kB) (0 MB) +// { 0xBA406048, 0xBA407FFC } // size 8120 (7 kB) (0 MB) +// { 0xBA40B5BC, 0xBA40BFF8 } // size 2624 (2 kB) (0 MB) +// { 0xBA40C04C, 0xBA40DFFC } // size 8116 (7 kB) (0 MB) +// { 0xBA40E07C, 0xBA40EFFC } // size 3972 (3 kB) (0 MB) +// { 0xBA41521C, 0xBA415FF8 } // size 3552 (3 kB) (0 MB) +// { 0xBA416048, 0xBA417FFC } // size 8120 (7 kB) (0 MB) +// { 0xBA41807C, 0xBA418FFC } // size 3972 (3 kB) (0 MB) +// { 0xBA419300, 0xBA419FFC } // size 3328 (3 kB) (0 MB) +// { 0xBA45C89C, 0xBA45DFF8 } // size 5984 (5 kB) (0 MB) +// { 0xBA45E044, 0xBA45FFFC } // size 8124 (7 kB) (0 MB) +// { 0xBA4602E4, 0xBA461FFC } // size 7452 (7 kB) (0 MB) +// { 0xBA464DFC, 0xBA465FFC } // size 4612 (4 kB) (0 MB) +// { 0xBA466028, 0xBA4681FC } // size 8664 (8 kB) (0 MB) +// { 0xBA46AEFC, 0xBA46BFFC } // size 4356 (4 kB) (0 MB) +// { 0xBA46C028, 0xBA46E1FC } // size 8664 (8 kB) (0 MB) +// { 0xBA470EFC, 0xBA471FFC } // size 4356 (4 kB) (0 MB) +// { 0xBA472028, 0xBA472908 } // size 2276 (2 kB) (0 MB) +// { 0xBA477028, 0xBA4781FC } // size 4568 (4 kB) (0 MB) +// { 0xBA47AFFC, 0xBA47BFFC } // size 4100 (4 kB) (0 MB) +// { 0xBA47C028, 0xBA47D01C } // size 4088 (3 kB) (0 MB) +// { 0xBA47D840, 0xBA47E0A8 } // size 2156 (2 kB) (0 MB) +// { 0xBA47F028, 0xBA47FFFC } // size 4056 (3 kB) (0 MB) +// { 0xBA482CFC, 0xBA483FFC } // size 4868 (4 kB) (0 MB) +// { 0xBA484028, 0xBA485120 } // size 4348 (4 kB) (0 MB) +// { 0xBA485A40, 0xBA4862A8 } // size 2156 (2 kB) (0 MB) +// { 0xBA487598, 0xBA487FFC } // size 2664 (2 kB) (0 MB) +// { 0xBA48AFFC, 0xBA48BFFC } // size 4100 (4 kB) (0 MB) +// { 0xBA48C028, 0xBA48DFFC } // size 8152 (7 kB) (0 MB) +// { 0xBA490DFC, 0xBA491FFC } // size 4612 (4 kB) (0 MB) +// { 0xBA492B5C, 0xBA493FF8 } // size 5280 (5 kB) (0 MB) +// { 0xBA494044, 0xBA495FFC } // size 8124 (7 kB) (0 MB) +// { 0xBA49609C, 0xBA497FFC } // size 8036 (7 kB) (0 MB) +// { 0xBA49C24C, 0xBA49CFFC } // size 3508 (3 kB) (0 MB) +// { 0xBA49F23C, 0xBA49FFF8 } // size 3520 (3 kB) (0 MB) +// { 0xBA4A004C, 0xBA4A1FFC } // size 8116 (7 kB) (0 MB) +// { 0xBA4B223C, 0xBA4B3FF8 } // size 7616 (7 kB) (0 MB) +// { 0xBA4B4048, 0xBA4B5FFC } // size 8120 (7 kB) (0 MB) +// { 0xBA4DA9FC, 0xBA4DBFF8 } // size 5632 (5 kB) (0 MB) +// { 0xBA4DC04C, 0xBA4DDFFC } // size 8116 (7 kB) (0 MB) +// { 0xBA4FC19C, 0xBA4FDFF8 } // size 7776 (7 kB) (0 MB) +// { 0xBA4FE068, 0xBA4FFFFC } // size 8088 (7 kB) (0 MB) +// { 0xBA500054, 0xBA501FFC } // size 8108 (7 kB) (0 MB) +// { 0xBA5220A8, 0xBA523FFC } // size 8024 (7 kB) (0 MB) +// { 0xBA524054, 0xBA525FFC } // size 8108 (7 kB) (0 MB) +// { 0xBA5362F8, 0xBA5371E8 } // size 3828 (3 kB) (0 MB) +// { 0xBA55C91C, 0xBA55DFF8 } // size 5856 (5 kB) (0 MB) +// { 0xBA55E044, 0xBA55FFFC } // size 8124 (7 kB) (0 MB) +// { 0xBA560158, 0xBA561FFC } // size 7848 (7 kB) (0 MB) +// { 0xBA5639C0, 0xBA5644FC } // size 2880 (2 kB) (0 MB) +// { 0xBA5645BC, 0xBA565FFC } // size 6724 (6 kB) (0 MB) +// { 0xBA566028, 0xBA566FFC } // size 4056 (3 kB) (0 MB) +// { 0xBA567B98, 0xBA5683FC } // size 2152 (2 kB) (0 MB) +// { 0xBA568718, 0xBA568FFC } // size 2280 (2 kB) (0 MB) +// { 0xBA569688, 0xBA569FFC } // size 2424 (2 kB) (0 MB) +// { 0xBA56B1D0, 0xBA56C1FC } // size 4144 (4 kB) (0 MB) +// { 0xBA56C2C0, 0xBA56CFFC } // size 3392 (3 kB) (0 MB) +// { 0xBA56D23C, 0xBA56DFF8 } // size 3520 (3 kB) (0 MB) +// { 0xBA56E044, 0xBA56FFFC } // size 8124 (7 kB) (0 MB) +// { 0xBA5702BC, 0xBA572014 } // size 7516 (7 kB) (0 MB) +// { 0xBA576028, 0xBA577FFC } // size 8152 (7 kB) (0 MB) +// { 0xBA57A028, 0xBA57C3FC } // size 9176 (8 kB) (0 MB) +// { 0xBA582028, 0xBA583FFC } // size 8152 (7 kB) (0 MB) +// { 0xBA586028, 0xBA587FFC } // size 8152 (7 kB) (0 MB) +// { 0xBA58A028, 0xBA58BFFC } // size 8152 (7 kB) (0 MB) +// { 0xBA58E028, 0xBA58FFFC } // size 8152 (7 kB) (0 MB) +// { 0xBA592BBC, 0xBA593FF8 } // size 5184 (5 kB) (0 MB) +// { 0xBA594050, 0xBA595FFC } // size 8112 (7 kB) (0 MB) +// { 0xBA596298, 0xBA597FFC } // size 7528 (7 kB) (0 MB) +// { 0xBA5B0028, 0xBA5B1FFC } // size 8152 (7 kB) (0 MB) +// { 0xBA5B6028, 0xBA5B71FC } // size 4568 (4 kB) (0 MB) +// { 0xBA5B72C0, 0xBA5B7FFC } // size 3392 (3 kB) (0 MB) +// { 0xBA5B8028, 0xBA5B9FFC } // size 8152 (7 kB) (0 MB) +// { 0xBA5BE028, 0xBA5BE828 } // size 2052 (2 kB) (0 MB) +// { 0xBA5C4028, 0xBA5C4FFC } // size 4056 (3 kB) (0 MB) +// { 0xBA5C7028, 0xBA5C7FFC } // size 4056 (3 kB) (0 MB) +// { 0xBA5D0028, 0xBA5D1FFC } // size 8152 (7 kB) (0 MB) +// { 0xBA5D6028, 0xBA5D7FFC } // size 8152 (7 kB) (0 MB) +// { 0xBA5EC828, 0xBA5EE1FC } // size 6616 (6 kB) (0 MB) +// { 0xBA5F2028, 0xBA5F3FFC } // size 8152 (7 kB) (0 MB) +// { 0xBA60204C, 0xBA603FFC } // size 8116 (7 kB) (0 MB) +// { 0xBA604080, 0xBA604FFC } // size 3968 (3 kB) (0 MB) +// { 0xBA60575C, 0xBA605FFC } // size 2212 (2 kB) (0 MB) +// { 0xBA60C048, 0xBA60DFFC } // size 8120 (7 kB) (0 MB) +// { 0xBA60E07C, 0xBA60EFFC } // size 3972 (3 kB) (0 MB) +// { 0xBA60F400, 0xBA60FFFC } // size 3072 (3 kB) (0 MB) +// { 0xBA61223C, 0xBA613FF8 } // size 7616 (7 kB) (0 MB) +// { 0xBA614048, 0xBA615FFC } // size 8120 (7 kB) (0 MB) +// { 0xBA61819C, 0xBA619FF8 } // size 7776 (7 kB) (0 MB) +// { 0xBA61A04C, 0xBA61BFFC } // size 8116 (7 kB) (0 MB) +// { 0xBA61C514, 0xBA61DFFC } // size 6892 (6 kB) (0 MB) +// { 0xBA6741A8, 0xBA674FFC } // size 3672 (3 kB) (0 MB) +// { 0xBA67D36C, 0xBA67DFFC } // size 3220 (3 kB) (0 MB) +// { 0xBA68E028, 0xBA68FFFC } // size 8152 (7 kB) (0 MB) +// { 0xBA692700, 0xBA693FFC } // size 6400 (6 kB) (0 MB) +// { 0xBA6953FC, 0xBA695FFC } // size 3076 (3 kB) (0 MB) +// { 0xBA6A5680, 0xBA6A60FC } // size 2688 (2 kB) (0 MB) +// { 0xBA6A6680, 0xBA6A71FC } // size 2944 (2 kB) (0 MB) +// { 0xBA6A7680, 0xBA6A7FFC } // size 2432 (2 kB) (0 MB) +// { 0xBA6A8658, 0xBA6A9FFC } // size 6568 (6 kB) (0 MB) +// { 0xBA6AF374, 0xBA6AFBFC } // size 2188 (2 kB) (0 MB) +// { 0xBA6B0174, 0xBA6B0DFC } // size 3212 (3 kB) (0 MB) +// { 0xBA6B1374, 0xBA6B1BFC } // size 2188 (2 kB) (0 MB) +// { 0xBA6B2DFC, 0xBA6B3FF8 } // size 4608 (4 kB) (0 MB) +// { 0xBA6B4050, 0xBA6B5FFC } // size 8112 (7 kB) (0 MB) +// { 0xBA6B6C1C, 0xBA6B7FF8 } // size 5088 (4 kB) (0 MB) +// { 0xBA6EB2FC, 0xBA6EBFF8 } // size 3328 (3 kB) (0 MB) +// { 0xBA6EC04C, 0xBA6EDFFC } // size 8116 (7 kB) (0 MB) +// { 0xBA6EE1D0, 0xBA6F01FC } // size 8240 (8 kB) (0 MB) +// { 0xBA704AF8, 0xBA705FFC } // size 5384 (5 kB) (0 MB) +// { 0xBA7087F0, 0xBA709FFC } // size 6160 (6 kB) (0 MB) +// { 0xBA7128DC, 0xBA713FF8 } // size 5920 (5 kB) (0 MB) +// { 0xBA714048, 0xBA715FFC } // size 8120 (7 kB) (0 MB) +// { 0xBA716294, 0xBA717FFC } // size 7532 (7 kB) (0 MB) +// { 0xBA7181E4, 0xBA718FFC } // size 3612 (3 kB) (0 MB) +// { 0xBA71B028, 0xBA71BFFC } // size 4056 (3 kB) (0 MB) +// { 0xBA71E028, 0xBA71F1FC } // size 4568 (4 kB) (0 MB) +// { 0xBA71F2C0, 0xBA71FFFC } // size 3392 (3 kB) (0 MB) +// { 0xBA720028, 0xBA721FFC } // size 8152 (7 kB) (0 MB) +// { 0xBA726254, 0xBA726FFC } // size 3500 (3 kB) (0 MB) +// { 0xBA729028, 0xBA729FFC } // size 4056 (3 kB) (0 MB) +// { 0xBA737028, 0xBA737FFC } // size 4056 (3 kB) (0 MB) +// { 0xBA73C028, 0xBA73E1FC } // size 8664 (8 kB) (0 MB) +// { 0xBA742028, 0xBA743FFC } // size 8152 (7 kB) (0 MB) +// { 0xBA74841C, 0xBA749FF8 } // size 7136 (6 kB) (0 MB) +// { 0xBA74A04C, 0xBA74BFFC } // size 8116 (7 kB) (0 MB) +// { 0xBA74C2A4, 0xBA74DFFC } // size 7516 (7 kB) (0 MB) +// { 0xBA750028, 0xBA750FFC } // size 4056 (3 kB) (0 MB) +// { 0xBA753028, 0xBA7541FC } // size 4568 (4 kB) (0 MB) +// { 0xBA7542C0, 0xBA754FFC } // size 3392 (3 kB) (0 MB) +// { 0xBA755028, 0xBA755FFC } // size 4056 (3 kB) (0 MB) +// { 0xBA75D20C, 0xBA75DFFC } // size 3572 (3 kB) (0 MB) +// { 0xBA762254, 0xBA762FFC } // size 3500 (3 kB) (0 MB) +// { 0xBA76B028, 0xBA76BFFC } // size 4056 (3 kB) (0 MB) +// { 0xBA770028, 0xBA7721FC } // size 8664 (8 kB) (0 MB) +// { 0xBA776028, 0xBA777FFC } // size 8152 (7 kB) (0 MB) +// { 0xBA77C41C, 0xBA77DFF8 } // size 7136 (6 kB) (0 MB) +// { 0xBA77E048, 0xBA77FFFC } // size 8120 (7 kB) (0 MB) +// { 0xBA780168, 0xBA781FFC } // size 7832 (7 kB) (0 MB) +// { 0xBA78257C, 0xBA782FFC } // size 2692 (2 kB) (0 MB) +// { 0xBA785160, 0xBA785FFC } // size 3744 (3 kB) (0 MB) +// { 0xBA792800, 0xBA7942FC } // size 6912 (6 kB) (0 MB) +// { 0xBA794800, 0xBA795FFC } // size 6144 (6 kB) (0 MB) +// { 0xBA796158, 0xBA7971FC } // size 4264 (4 kB) (0 MB) +// { 0xBA7972C0, 0xBA797FFC } // size 3392 (3 kB) (0 MB) +// { 0xBA79915C, 0xBA799FF8 } // size 3744 (3 kB) (0 MB) +// { 0xBA79A04C, 0xBA79BFFC } // size 8116 (7 kB) (0 MB) +// { 0xBA79CBBC, 0xBA79DFF8 } // size 5184 (5 kB) (0 MB) +// { 0xBA79E04C, 0xBA79FFFC } // size 8116 (7 kB) (0 MB) +// { 0xBA7A007C, 0xBA7A0FFC } // size 3972 (3 kB) (0 MB) +// { 0xBA7A2DBC, 0xBA7A3FF8 } // size 4672 (4 kB) (0 MB) +// { 0xBA7A4048, 0xBA7A5FFC } // size 8120 (7 kB) (0 MB) +// { 0xBA7A607C, 0xBA7A6FFC } // size 3972 (3 kB) (0 MB) +// { 0xBA7A75B4, 0xBA7A7FFC } // size 2636 (2 kB) (0 MB) +// { 0xBA7AA23C, 0xBA7ABFF8 } // size 7616 (7 kB) (0 MB) +// { 0xBA7AC048, 0xBA7ADFFC } // size 8120 (7 kB) (0 MB) +// { 0xBA7D0F9C, 0xBA7D1FF8 } // size 4192 (4 kB) (0 MB) +// { 0xBA7D204C, 0xBA7D3FFC } // size 8116 (7 kB) (0 MB) +// { 0xBA7F25DC, 0xBA7F3FF8 } // size 6688 (6 kB) (0 MB) +// { 0xBA7F4050, 0xBA7F5FFC } // size 8112 (7 kB) (0 MB) +// { 0xBA7F6080, 0xBA7F6FFC } // size 3968 (3 kB) (0 MB) +// { 0xBA81A048, 0xBA81BFFC } // size 8120 (7 kB) (0 MB) +// { 0xBA81C15C, 0xBA81DFFC } // size 7844 (7 kB) (0 MB) +// { 0xBA81E1F8, 0xBA81EFFC } // size 3592 (3 kB) (0 MB) +// { 0xBA820780, 0xBA820FFC } // size 2176 (2 kB) (0 MB) +// { 0xBA821028, 0xBA8221FC } // size 4568 (4 kB) (0 MB) +// { 0xBA824610, 0xBA825FFC } // size 6640 (6 kB) (0 MB) +// { 0xBA8677DC, 0xBA867FF8 } // size 2080 (2 kB) (0 MB) +// { 0xBA868048, 0xBA869FFC } // size 8120 (7 kB) (0 MB) +// { 0xBA86A0D4, 0xBA86AFFC } // size 3884 (3 kB) (0 MB) +// { 0xBA86C240, 0xBA86D3FC } // size 4544 (4 kB) (0 MB) +// { 0xBA86F01C, 0xBA8703FC } // size 5092 (4 kB) (0 MB) +// { 0xBA87123C, 0xBA871FF8 } // size 3520 (3 kB) (0 MB) +// { 0xBA872048, 0xBA873FFC } // size 8120 (7 kB) (0 MB) +// { 0xBA87419C, 0xBA875FFC } // size 7780 (7 kB) (0 MB) +// { 0xBA878028, 0xBA87A3FC } // size 9176 (8 kB) (0 MB) +// { 0xBA87C20C, 0xBA87DFFC } // size 7668 (7 kB) (0 MB) +// { 0xBA880028, 0xBA881FFC } // size 8152 (7 kB) (0 MB) +// { 0xBA884BDC, 0xBA885FF8 } // size 5152 (5 kB) (0 MB) +// { 0xBA886044, 0xBA887FFC } // size 8124 (7 kB) (0 MB) +// { 0xBA88861C, 0xBA889FF8 } // size 6624 (6 kB) (0 MB) +// { 0xBA88A048, 0xBA88BFFC } // size 8120 (7 kB) (0 MB) +// { 0xBA88C75C, 0xBA88DFF8 } // size 6304 (6 kB) (0 MB) +// { 0xBA88E050, 0xBA88FFFC } // size 8112 (7 kB) (0 MB) +// { 0xBA890080, 0xBA890FFC } // size 3968 (3 kB) (0 MB) +// { 0xBA895528, 0xBA8CCA24 } // size 226560 (221 kB) (0 MB) +// { 0xBAA4E9DC, 0xBAA4FFF8 } // size 5664 (5 kB) (0 MB) +// { 0xBAA50048, 0xBAA51FFC } // size 8120 (7 kB) (0 MB) +// { 0xBAA5285C, 0xBAA53FF8 } // size 6048 (5 kB) (0 MB) +// { 0xBAA54044, 0xBAA55FFC } // size 8124 (7 kB) (0 MB) +// { 0xBAA56114, 0xBAA57FFC } // size 7916 (7 kB) (0 MB) +// { 0xBAA589E0, 0xBAA593FC } // size 2592 (2 kB) (0 MB) +// { 0xBAA5ABE0, 0xBAA5B5FC } // size 2592 (2 kB) (0 MB) +// { 0xBAA5C9E0, 0xBAA5D3FC } // size 2592 (2 kB) (0 MB) +// { 0xBAA5EBE0, 0xBAA5F5FC } // size 2592 (2 kB) (0 MB) +// { 0xBAA609E0, 0xBAA613FC } // size 2592 (2 kB) (0 MB) +// { 0xBAA62BE0, 0xBAA635FC } // size 2592 (2 kB) (0 MB) +// { 0xBAA649E0, 0xBAA653FC } // size 2592 (2 kB) (0 MB) +// { 0xBAA66BE0, 0xBAA675FC } // size 2592 (2 kB) (0 MB) +// { 0xBAA69308, 0xBAA69FFC } // size 3320 (3 kB) (0 MB) +// { 0xBAA6E374, 0xBAA6F1FC } // size 3724 (3 kB) (0 MB) +// { 0xBAA6FB98, 0xBAA705FC } // size 2664 (2 kB) (0 MB) +// { 0xBAA71998, 0xBAA723FC } // size 2664 (2 kB) (0 MB) +// { 0xBAA908BC, 0xBAA91FF8 } // size 5952 (5 kB) (0 MB) +// { 0xBAA92048, 0xBAA93FFC } // size 8120 (7 kB) (0 MB) +// { 0xBAA94384, 0xBAA95FFC } // size 7292 (7 kB) (0 MB) +// { 0xBAA9E028, 0xBAA9EFFC } // size 4056 (3 kB) (0 MB) +// { 0xBAAA1284, 0xBAAA1FFC } // size 3452 (3 kB) (0 MB) +// { 0xBAAA4154, 0xBAAA51FC } // size 4268 (4 kB) (0 MB) +// { 0xBAAA52C0, 0xBAAA5FFC } // size 3392 (3 kB) (0 MB) +// { 0xBAAA6028, 0xBAAA7FFC } // size 8152 (7 kB) (0 MB) +// { 0xBAAAD27C, 0xBAAAE1FC } // size 3972 (3 kB) (0 MB) +// { 0xBAAB22A4, 0xBAAB2FFC } // size 3420 (3 kB) (0 MB) +// { 0xBAAB5028, 0xBAAB5FFC } // size 4056 (3 kB) (0 MB) +// { 0xBAACA828, 0xBAACBFFC } // size 6104 (5 kB) (0 MB) +// { 0xBAAD0028, 0xBAAD1FFC } // size 8152 (7 kB) (0 MB) +// { 0xBAAD628C, 0xBAAD81FC } // size 8052 (7 kB) (0 MB) +// { 0xBAADC028, 0xBAADDFFC } // size 8152 (7 kB) (0 MB) +// { 0xBAAE223C, 0xBAAE3FF8 } // size 7616 (7 kB) (0 MB) +// { 0xBAAE4050, 0xBAAE5FFC } // size 8112 (7 kB) (0 MB) +// { 0xBAAE699C, 0xBAAE7FF8 } // size 5728 (5 kB) (0 MB) +// { 0xBAAE804C, 0xBAAE9FFC } // size 8116 (7 kB) (0 MB) +// { 0xBAAEB31C, 0xBAAEBFF8 } // size 3296 (3 kB) (0 MB) +// { 0xBAAEC050, 0xBAAEDFFC } // size 8112 (7 kB) (0 MB) +// { 0xBAAF8058, 0xBAAF9FFC } // size 8104 (7 kB) (0 MB) +// { 0xBAAFAC9C, 0xBAAFBFF8 } // size 4960 (4 kB) (0 MB) +// { 0xBAAFC054, 0xBAAFDFFC } // size 8108 (7 kB) (0 MB) +// { 0xBAAFE1E4, 0xBAB001FC } // size 8220 (8 kB) (0 MB) +// { 0xBAB04028, 0xBAB051FC } // size 4568 (4 kB) (0 MB) +// { 0xBAB052C0, 0xBAB05FFC } // size 3392 (3 kB) (0 MB) +// { 0xBAB06028, 0xBAB07FFC } // size 8152 (7 kB) (0 MB) +// { 0xBAB26028, 0xBAB27FFC } // size 8152 (7 kB) (0 MB) +// { 0xBAB2E828, 0xBAB301FC } // size 6616 (6 kB) (0 MB) +// { 0xBAB34028, 0xBAB35FFC } // size 8152 (7 kB) (0 MB) +// { 0xBAB3EC5C, 0xBAB3FFF8 } // size 5024 (4 kB) (0 MB) +// { 0xBAB40048, 0xBAB41FFC } // size 8120 (7 kB) (0 MB) +// { 0xBAB420A8, 0xBAB42FFC } // size 3928 (3 kB) (0 MB) +// { 0xBAB43304, 0xBAB43FFC } // size 3324 (3 kB) (0 MB) +// { 0xBAB45780, 0xBAB45FFC } // size 2176 (2 kB) (0 MB) +// { 0xBAB4623C, 0xBAB47FF8 } // size 7616 (7 kB) (0 MB) +// { 0xBAB4804C, 0xBAB49FFC } // size 8116 (7 kB) (0 MB) +// { 0xBAB4A360, 0xBAB4BFFC } // size 7328 (7 kB) (0 MB) +// { 0xBAB4C64C, 0xBAB4CFFC } // size 2484 (2 kB) (0 MB) +// { 0xBAB55028, 0xBAB55FFC } // size 4056 (3 kB) (0 MB) +// { 0xBAB5A028, 0xBAB5B1FC } // size 4568 (4 kB) (0 MB) +// { 0xBAB5B2C0, 0xBAB5BFFC } // size 3392 (3 kB) (0 MB) +// { 0xBAB5C028, 0xBAB5E1FC } // size 8664 (8 kB) (0 MB) +// { 0xBAB60710, 0xBAB61FFC } // size 6384 (6 kB) (0 MB) +// { 0xBAB62028, 0xBAB63FFC } // size 8152 (7 kB) (0 MB) +// { 0xBAB666F0, 0xBAB67FFC } // size 6416 (6 kB) (0 MB) +// { 0xBAB68028, 0xBAB69FFC } // size 8152 (7 kB) (0 MB) +// { 0xBAB6C510, 0xBAB6DFFC } // size 6896 (6 kB) (0 MB) +// { 0xBAB6E168, 0xBAB6FFFC } // size 7832 (7 kB) (0 MB) +// { 0xBAB727F0, 0xBAB73FFC } // size 6160 (6 kB) (0 MB) +// { 0xBAB7518C, 0xBAB75FFC } // size 3700 (3 kB) (0 MB) +// { 0xBAB78410, 0xBAB79FFC } // size 7152 (6 kB) (0 MB) +// { 0xBAB7A604, 0xBAB7C1FC } // size 7164 (6 kB) (0 MB) +// { 0xBAB7E610, 0xBAB7FFFC } // size 6640 (6 kB) (0 MB) +// { 0xBAB80C6C, 0xBAB821FC } // size 5524 (5 kB) (0 MB) +// { 0xBAB84028, 0xBAB85FFC } // size 8152 (7 kB) (0 MB) +// { 0xBAB88510, 0xBAB89FFC } // size 6896 (6 kB) (0 MB) +// { 0xBAB8A028, 0xBAB8BFFC } // size 8152 (7 kB) (0 MB) +// { 0xBAB8E7F0, 0xBAB8FFFC } // size 6160 (6 kB) (0 MB) +// { 0xBAB9085C, 0xBAB91FF8 } // size 6048 (5 kB) (0 MB) +// { 0xBAB92044, 0xBAB93FFC } // size 8124 (7 kB) (0 MB) +// { 0xBAB96D1C, 0xBAB97FF8 } // size 4832 (4 kB) (0 MB) +// { 0xBAB9804C, 0xBAB99FFC } // size 8116 (7 kB) (0 MB) +// { 0xBAB9AA1C, 0xBAB9BFF8 } // size 5600 (5 kB) (0 MB) +// { 0xBAB9C048, 0xBAB9DFFC } // size 8120 (7 kB) (0 MB) +// { 0xBAB9E1A0, 0xBAB9EFFC } // size 3680 (3 kB) (0 MB) +// { 0xBABBA6BC, 0xBABBBFF8 } // size 6464 (6 kB) (0 MB) +// { 0xBABBC048, 0xBABBDFFC } // size 8120 (7 kB) (0 MB) +// { 0xBABBE078, 0xBABBEFFC } // size 3976 (3 kB) (0 MB) +// { 0xBABC0C4C, 0xBACB9588 } // size 1018176 (994 kB) (0 MB) +// { 0xBACE89C8, 0xBACE9FF8 } // size 5684 (5 kB) (0 MB) +// { 0xBACEA050, 0xBACEBFFC } // size 8112 (7 kB) (0 MB) +// { 0xBACEC088, 0xBACEDFFC } // size 8056 (7 kB) (0 MB) +// { 0xBACEE330, 0xBACF01FC } // size 7888 (7 kB) (0 MB) +// { 0xBACF423C, 0xBACF5FF8 } // size 7616 (7 kB) (0 MB) +// { 0xBACF6048, 0xBACF7FFC } // size 8120 (7 kB) (0 MB) +// { 0xBACF833C, 0xBACF9FFC } // size 7364 (7 kB) (0 MB) +// { 0xBACFA1E8, 0xBACFBFFC } // size 7704 (7 kB) (0 MB) +// { 0xBAD00028, 0xBAD01FFC } // size 8152 (7 kB) (0 MB) +// { 0xBAD06028, 0xBAD07FFC } // size 8152 (7 kB) (0 MB) +// { 0xBAD0C028, 0xBAD0DFFC } // size 8152 (7 kB) (0 MB) +// { 0xBAD12028, 0xBAD12FFC } // size 4056 (3 kB) (0 MB) +// { 0xBAD19798, 0xBAD19FFC } // size 2152 (2 kB) (0 MB) +// { 0xBAD22028, 0xBAD23FFC } // size 8152 (7 kB) (0 MB) +// { 0xBAD28028, 0xBAD29FFC } // size 8152 (7 kB) (0 MB) +// { 0xBAD2E028, 0xBAD2FFFC } // size 8152 (7 kB) (0 MB) +// { 0xBAD34028, 0xBAD35FFC } // size 8152 (7 kB) (0 MB) +// { 0xBAD3A028, 0xBAD3BFFC } // size 8152 (7 kB) (0 MB) +// { 0xBAD4023C, 0xBAD41FF8 } // size 7616 (7 kB) (0 MB) +// { 0xBAD42044, 0xBAD43FFC } // size 8124 (7 kB) (0 MB) +// { 0xBAD44100, 0xBAD45FFC } // size 7936 (7 kB) (0 MB) +// { 0xBAD46620, 0xBAD47FFC } // size 6624 (6 kB) (0 MB) +// { 0xBAD54800, 0xBAD55FFC } // size 6144 (6 kB) (0 MB) +// { 0xBAD56440, 0xBAD57FFC } // size 7104 (6 kB) (0 MB) +// { 0xBAD5841C, 0xBAD59FF8 } // size 7136 (6 kB) (0 MB) +// { 0xBAD5A048, 0xBAD5BFFC } // size 8120 (7 kB) (0 MB) +// { 0xBAD5C38C, 0xBAD5DFFC } // size 7284 (7 kB) (0 MB) +// { 0xBAD62028, 0xBAD63FFC } // size 8152 (7 kB) (0 MB) +// { 0xBAD68028, 0xBAD69FFC } // size 8152 (7 kB) (0 MB) +// { 0xBAD6E028, 0xBAD6F1FC } // size 4568 (4 kB) (0 MB) +// { 0xBAD6F2C0, 0xBAD6FFFC } // size 3392 (3 kB) (0 MB) +// { 0xBAD70028, 0xBAD71FFC } // size 8152 (7 kB) (0 MB) +// { 0xBAD76028, 0xBAD77FFC } // size 8152 (7 kB) (0 MB) +// { 0xBAD7C028, 0xBAD7DFFC } // size 8152 (7 kB) (0 MB) +// { 0xBAD81828, 0xBAD82074 } // size 2128 (2 kB) (0 MB) +// { 0xBAD8C028, 0xBAD8C908 } // size 2276 (2 kB) (0 MB) +// { 0xBAD8E028, 0xBAD8EFFC } // size 4056 (3 kB) (0 MB) +// { 0xBADA0028, 0xBADA1FFC } // size 8152 (7 kB) (0 MB) +// { 0xBADA6028, 0xBADA7FFC } // size 8152 (7 kB) (0 MB) +// { 0xBADAC028, 0xBADAE1FC } // size 8664 (8 kB) (0 MB) +// { 0xBADB0528, 0xBADB21FC } // size 7384 (7 kB) (0 MB) +// { 0xBADB6028, 0xBADB7FFC } // size 8152 (7 kB) (0 MB) +// { 0xBADBC23C, 0xBADBDFF8 } // size 7616 (7 kB) (0 MB) +// { 0xBADBE04C, 0xBADBFFFC } // size 8116 (7 kB) (0 MB) +// { 0xBADC019C, 0xBADC1FFC } // size 7780 (7 kB) (0 MB) +// { 0xBADC27B4, 0xBADC3FFC } // size 6220 (6 kB) (0 MB) +// { 0xBADC82F8, 0xBADC9FFC } // size 7432 (7 kB) (0 MB) +// { 0xBADD2F00, 0xBADD44FC } // size 5632 (5 kB) (0 MB) +// { 0xBADD4D80, 0xBADD5FFC } // size 4736 (4 kB) (0 MB) +// { 0xBADD6028, 0xBADD6FFC } // size 4056 (3 kB) (0 MB) +// { 0xBADE0028, 0xBADE1FFC } // size 8152 (7 kB) (0 MB) +// { 0xBADEA23C, 0xBADEBFF8 } // size 7616 (7 kB) (0 MB) +// { 0xBADEC048, 0xBADEDFFC } // size 8120 (7 kB) (0 MB) +// { 0xBADEE6FC, 0xBADEFFF8 } // size 6400 (6 kB) (0 MB) +// { 0xBADF0050, 0xBADF1FFC } // size 8112 (7 kB) (0 MB) +// { 0xBADFAF7C, 0xBADFBFF8 } // size 4224 (4 kB) (0 MB) +// { 0xBADFC048, 0xBADFDFFC } // size 8120 (7 kB) (0 MB) +// { 0xBADFE274, 0xBADFFFFC } // size 7564 (7 kB) (0 MB) +// { 0xBAE001B8, 0xBAE01FFC } // size 7752 (7 kB) (0 MB) +// { 0xBAE0E1F8, 0xBAE0FFFC } // size 7688 (7 kB) (0 MB) +// { 0xBAE347EC, 0xBAE35020 } // size 2104 (2 kB) (0 MB) +// { 0xBAE35F40, 0xBAE36FFC } // size 4288 (4 kB) (0 MB) +// { 0xBAE3723C, 0xBAE37FF8 } // size 3520 (3 kB) (0 MB) +// { 0xBAE3804C, 0xBAE39FFC } // size 8116 (7 kB) (0 MB) +// { 0xBAF04028, 0xBAF04864 } // size 2112 (2 kB) (0 MB) +// { 0xBAF18048, 0xBAF19FFC } // size 8120 (7 kB) (0 MB) +// { 0xBAF1E71C, 0xBAF1FFF8 } // size 6368 (6 kB) (0 MB) +// { 0xBAF20044, 0xBAF21FFC } // size 8124 (7 kB) (0 MB) +// { 0xBAF226E0, 0xBAF23FFC } // size 6432 (6 kB) (0 MB) +// { 0xBAF40798, 0xBAF42FFC } // size 10344 (10 kB) (0 MB) +// { 0xBAF43028, 0xBAF43FFC } // size 4056 (3 kB) (0 MB) +// { 0xBAF66FEC, 0xBAF697FC } // size 10260 (10 kB) (0 MB) +// { 0xBAF69828, 0xBAF6A224 } // size 2560 (2 kB) (0 MB) +// { 0xBAF6AF40, 0xBAF6B7FC } // size 2240 (2 kB) (0 MB) +// { 0xBAF7A028, 0xBAF7BFFC } // size 8152 (7 kB) (0 MB) +// { 0xBAF94E98, 0xBAF95908 } // size 2676 (2 kB) (0 MB) +// { 0xBAF96D44, 0xBAF977FC } // size 2748 (2 kB) (0 MB) +// { 0xBAFA4028, 0xBAFA4FFC } // size 4056 (3 kB) (0 MB) +// { 0xBAFA6800, 0xBAFA7338 } // size 2876 (2 kB) (0 MB) +// { 0xBAFBAE14, 0xBAFBBDFC } // size 4076 (3 kB) (0 MB) +// { 0xBAFBC904, 0xBAFBD7FC } // size 3836 (3 kB) (0 MB) +// { 0xBAFCA028, 0xBAFCBFFC } // size 8152 (7 kB) (0 MB) +// { 0xBAFD8028, 0xBAFD9FFC } // size 8152 (7 kB) (0 MB) +// { 0xBAFE6028, 0xBAFE6874 } // size 2128 (2 kB) (0 MB) +// { 0xBAFE8028, 0xBAFE8838 } // size 2068 (2 kB) (0 MB) +// { 0xBAFE9340, 0xBAFE9FFC } // size 3264 (3 kB) (0 MB) +// { 0xBAFEA028, 0xBAFEA908 } // size 2276 (2 kB) (0 MB) +// { 0xBAFEC028, 0xBAFEDFFC } // size 8152 (7 kB) (0 MB) +// { 0xBAFFA028, 0xBAFFBFFC } // size 8152 (7 kB) (0 MB) +// { 0xBB008028, 0xBB009FFC } // size 8152 (7 kB) (0 MB) +// { 0xBB016028, 0xBB017FFC } // size 8152 (7 kB) (0 MB) +// { 0xBB024028, 0xBB025FFC } // size 8152 (7 kB) (0 MB) +// { 0xBB028028, 0xBB029FFC } // size 8152 (7 kB) (0 MB) +// { 0xBB037634, 0xBB037FFC } // size 2508 (2 kB) (0 MB) +// { 0xBB038028, 0xBB039FFC } // size 8152 (7 kB) (0 MB) +// { 0xBB046028, 0xBB047FFC } // size 8152 (7 kB) (0 MB) +// { 0xBB054028, 0xBB0548B8 } // size 2196 (2 kB) (0 MB) +// { 0xBB06A800, 0xBB06BBFC } // size 5120 (5 kB) (0 MB) +// { 0xBB06CB28, 0xBB06D7FC } // size 3288 (3 kB) (0 MB) +// { 0xBB090FEC, 0xBB091820 } // size 2104 (2 kB) (0 MB) +// { 0xBB092740, 0xBB0937FC } // size 4288 (4 kB) (0 MB) +// { 0xBB095724, 0xBB095FFC } // size 2268 (2 kB) (0 MB) +// { 0xBB096028, 0xBB097FFC } // size 8152 (7 kB) (0 MB) +// { 0xBB0A423C, 0xBB0A5FF8 } // size 7616 (7 kB) (0 MB) +// { 0xBB0A6044, 0xBB0A7FFC } // size 8124 (7 kB) (0 MB) +// { 0xBB0AAF3C, 0xBB0ABFF8 } // size 4288 (4 kB) (0 MB) +// { 0xBB0AC04C, 0xBB0ADFFC } // size 8116 (7 kB) (0 MB) +// { 0xBB0AE1A0, 0xBB0B01FC } // size 8288 (8 kB) (0 MB) +// { 0xBB0C490C, 0xBB0C5FFC } // size 5876 (5 kB) (0 MB) +// { 0xBB0C87F0, 0xBB0C9FFC } // size 6160 (6 kB) (0 MB) +// { 0xBB0CD23C, 0xBB0CDFF8 } // size 3520 (3 kB) (0 MB) +// { 0xBB0CE04C, 0xBB0CFFFC } // size 8116 (7 kB) (0 MB) +// { 0xBB0D0350, 0xBB0D1FFC } // size 7344 (7 kB) (0 MB) +// { 0xBB0D29E0, 0xBB0D33FC } // size 2592 (2 kB) (0 MB) +// { 0xBB0D4BE0, 0xBB0D55FC } // size 2592 (2 kB) (0 MB) +// { 0xBB0D69E0, 0xBB0D73FC } // size 2592 (2 kB) (0 MB) +// { 0xBB0D8BE0, 0xBB0D95FC } // size 2592 (2 kB) (0 MB) +// { 0xBB0DA9E0, 0xBB0DB3FC } // size 2592 (2 kB) (0 MB) +// { 0xBB0DCBE0, 0xBB0DD5FC } // size 2592 (2 kB) (0 MB) +// { 0xBB0DE9E0, 0xBB0DF3FC } // size 2592 (2 kB) (0 MB) +// { 0xBB0E0BE0, 0xBB0E15FC } // size 2592 (2 kB) (0 MB) +// { 0xBB0E3028, 0xBB0E3FFC } // size 4056 (3 kB) (0 MB) +// { 0xBB164828, 0xBB1651FC } // size 2520 (2 kB) (0 MB) +// { 0xBB165B98, 0xBB1665FC } // size 2664 (2 kB) (0 MB) +// { 0xBB167998, 0xBB1683FC } // size 2664 (2 kB) (0 MB) +// { 0xBB17E028, 0xBB17EFFC } // size 4056 (3 kB) (0 MB) +// { 0xBB18123C, 0xBB181FF8 } // size 3520 (3 kB) (0 MB) +// { 0xBB18204C, 0xBB183FFC } // size 8116 (7 kB) (0 MB) +// { 0xBB18804C, 0xBB189FFC } // size 8116 (7 kB) (0 MB) +// { 0xBB18A278, 0xBB18BFFC } // size 7560 (7 kB) (0 MB) +// { 0xBB19F468, 0xBB1A03FC } // size 3992 (3 kB) (0 MB) +// { 0xBB1A1028, 0xBB1A1FFC } // size 4056 (3 kB) (0 MB) +// { 0xBB1B2A3C, 0xBB1B3FF8 } // size 5568 (5 kB) (0 MB) +// { 0xBB1B404C, 0xBB1B5FFC } // size 8116 (7 kB) (0 MB) +// { 0xBB1B6354, 0xBB1B7FFC } // size 7340 (7 kB) (0 MB) +// { 0xBB1B89E0, 0xBB1B93FC } // size 2592 (2 kB) (0 MB) +// { 0xBB1BABE0, 0xBB1BB5FC } // size 2592 (2 kB) (0 MB) +// { 0xBB1BC9E0, 0xBB1BD3FC } // size 2592 (2 kB) (0 MB) +// { 0xBB1BEBE0, 0xBB1BF5FC } // size 2592 (2 kB) (0 MB) +// { 0xBB1C09E0, 0xBB1C13FC } // size 2592 (2 kB) (0 MB) +// { 0xBB1C2BE0, 0xBB1C35FC } // size 2592 (2 kB) (0 MB) +// { 0xBB1C49E0, 0xBB1C53FC } // size 2592 (2 kB) (0 MB) +// { 0xBB1C6BE0, 0xBB1C75FC } // size 2592 (2 kB) (0 MB) +// { 0xBB1C9028, 0xBB1C9FFC } // size 4056 (3 kB) (0 MB) +// { 0xBB24A028, 0xBB24B1FC } // size 4568 (4 kB) (0 MB) +// { 0xBB24BB98, 0xBB24C5FC } // size 2664 (2 kB) (0 MB) +// { 0xBB24D998, 0xBB24E3FC } // size 2664 (2 kB) (0 MB) +// { 0xBB26723C, 0xBB267FF8 } // size 3520 (3 kB) (0 MB) +// { 0xBB268048, 0xBB269FFC } // size 8120 (7 kB) (0 MB) +// { 0xBB26A4E4, 0xBB26BFFC } // size 6940 (6 kB) (0 MB) +// { 0xBB293028, 0xBB293FFC } // size 4056 (3 kB) (0 MB) +// { 0xBB29C7E8, 0xBB29DFFC } // size 6168 (6 kB) (0 MB) +// { 0xBB29E008, 0xBB29FFFC } // size 8184 (7 kB) (0 MB) +// { 0xBB2FC828, 0xBB2FDFFC } // size 6104 (5 kB) (0 MB) +// { 0xBB330828, 0xBB331FFC } // size 6104 (5 kB) (0 MB) +// { 0xBB33A6E8, 0xBB33C1FC } // size 6936 (6 kB) (0 MB) +// { 0xBB33C208, 0xBB33DFFC } // size 7672 (7 kB) (0 MB) +// { 0xBB35F828, 0xBB360064 } // size 2112 (2 kB) (0 MB) +// { 0xBB362028, 0xBB362864 } // size 2112 (2 kB) (0 MB) +// { 0xBB37E7E8, 0xBB3802FC } // size 6936 (6 kB) (0 MB) +// { 0xBB380308, 0xBB381FFC } // size 7416 (7 kB) (0 MB) +// { 0xBB382028, 0xBB383FFC } // size 8152 (7 kB) (0 MB) +// { 0xBB390028, 0xBB3924FC } // size 9432 (9 kB) (0 MB) +// { 0xBB394694, 0xBB3953FC } // size 3436 (3 kB) (0 MB) +// { 0xBB39A028, 0xBB39BFFC } // size 8152 (7 kB) (0 MB) +// { 0xBB3A47E8, 0xBB3A5FFC } // size 6168 (6 kB) (0 MB) +// { 0xBB3A6008, 0xBB3A7FFC } // size 8184 (7 kB) (0 MB) +// { 0xBB3A95FC, 0xBB3A9FF8 } // size 2560 (2 kB) (0 MB) +// { 0xBB3AA04C, 0xBB3ABFFC } // size 8116 (7 kB) (0 MB) +// { 0xBB3AC108, 0xBB3AE000 } // size 7932 (7 kB) (0 MB) +// { 0xBB3B2028, 0xBB3B42FC } // size 8920 (8 kB) (0 MB) +// { 0xBB3B5390, 0xBB3B5FFC } // size 3184 (3 kB) (0 MB) +// { 0xBB3B623C, 0xBB3B7FF8 } // size 7616 (7 kB) (0 MB) +// { 0xBB3B804C, 0xBB3B9FFC } // size 8116 (7 kB) (0 MB) +// { 0xBB3BA33C, 0xBB3BBFFC } // size 7364 (7 kB) (0 MB) +// { 0xBB3BD028, 0xBB3BE828 } // size 6148 (6 kB) (0 MB) +// { 0xBB3C0000, 0xBB3C083C } // size 2112 (2 kB) (0 MB) +// { 0xBB3C0FC0, 0xBB3C17FC } // size 2112 (2 kB) (0 MB) +// { 0xBB3C2000, 0xBB3C2800 } // size 2052 (2 kB) (0 MB) +// { 0xBB3C3FFC, 0xBB3C48BC } // size 2244 (2 kB) (0 MB) +// { 0xBB3C4FA0, 0xBB3C67FC } // size 6240 (6 kB) (0 MB) +// { 0xBB3C6828, 0xBB3C71FC } // size 2520 (2 kB) (0 MB) +// { 0xBB3C72C0, 0xBB3C7FFC } // size 3392 (3 kB) (0 MB) +// { 0xBB3C8028, 0xBB3C9FFC } // size 8152 (7 kB) (0 MB) +// { 0xBB3FC2B8, 0xBB3FDFFC } // size 7496 (7 kB) (0 MB) +// { 0xBB4076F0, 0xBB4081FC } // size 2832 (2 kB) (0 MB) +// { 0xBB4096F0, 0xBB409FFC } // size 2320 (2 kB) (0 MB) +// { 0xBB40A028, 0xBB40BFFC } // size 8152 (7 kB) (0 MB) +// { 0xBB410028, 0xBB4121FC } // size 8664 (8 kB) (0 MB) +// { 0xBB414028, 0xBB4161FC } // size 8664 (8 kB) (0 MB) +// { 0xBB41A028, 0xBB41BFFC } // size 8152 (7 kB) (0 MB) +// { 0xBB42023C, 0xBB421FF8 } // size 7616 (7 kB) (0 MB) +// { 0xBB422050, 0xBB423FFC } // size 8112 (7 kB) (0 MB) +// { 0xBB49953C, 0xBB499FF8 } // size 2752 (2 kB) (0 MB) +// { 0xBB49A04C, 0xBB49BFFC } // size 8116 (7 kB) (0 MB) +// { 0xBB49C2FC, 0xBB49DFFC } // size 7428 (7 kB) (0 MB) +// { 0xBB4AA394, 0xBB4ABFFC } // size 7276 (7 kB) (0 MB) +// { 0xBB4B8028, 0xBB4B9FFC } // size 8152 (7 kB) (0 MB) +// { 0xBB4C6A38, 0xBB4C7FFC } // size 5576 (5 kB) (0 MB) +// { 0xBB4D0F00, 0xBB4D24FC } // size 5632 (5 kB) (0 MB) +// { 0xBB4D2D80, 0xBB4D3FFC } // size 4736 (4 kB) (0 MB) +// { 0xBB4D4028, 0xBB4D4FFC } // size 4056 (3 kB) (0 MB) +// { 0xBB4E004C, 0xBB4E1FFC } // size 8116 (7 kB) (0 MB) +// { 0xBB4E2424, 0xBB4E3FFC } // size 7132 (6 kB) (0 MB) +// { 0xBB4E6028, 0xBB4E6FFC } // size 4056 (3 kB) (0 MB) +// { 0xBB4E9028, 0xBB4EA1FC } // size 4568 (4 kB) (0 MB) +// { 0xBB4EA2C0, 0xBB4EAFFC } // size 3392 (3 kB) (0 MB) +// { 0xBB4EB028, 0xBB4EBFFC } // size 4056 (3 kB) (0 MB) +// { 0xBB4F0028, 0xBB4F1FFC } // size 8152 (7 kB) (0 MB) +// { 0xBB4F6028, 0xBB4F81FC } // size 8664 (8 kB) (0 MB) +// { 0xBB4FC028, 0xBB4FCFFC } // size 4056 (3 kB) (0 MB) +// { 0xBB4FF028, 0xBB4FFFFC } // size 4056 (3 kB) (0 MB) +// { 0xBB504028, 0xBB504FFC } // size 4056 (3 kB) (0 MB) +// { 0xBB51ED24, 0xBB51FFFC } // size 4828 (4 kB) (0 MB) +// { 0xBB52499C, 0xBB525FFC } // size 5732 (5 kB) (0 MB) +// { 0xBB52A828, 0xBB52C1FC } // size 6616 (6 kB) (0 MB) +// { 0xBB530028, 0xBB531FFC } // size 8152 (7 kB) (0 MB) +// { 0xBB536028, 0xBB537FFC } // size 8152 (7 kB) (0 MB) +// { 0xBB53C23C, 0xBB53DFF8 } // size 7616 (7 kB) (0 MB) +// { 0xBB53E04C, 0xBB53FFFC } // size 8116 (7 kB) (0 MB) +// { 0xBB54029C, 0xBB541FFC } // size 7524 (7 kB) (0 MB) +// { 0xBB54420C, 0xBB544FFC } // size 3572 (3 kB) (0 MB) +// { 0xBB547210, 0xBB5481FC } // size 4080 (3 kB) (0 MB) +// { 0xBB5482C0, 0xBB548FFC } // size 3392 (3 kB) (0 MB) +// { 0xBB549028, 0xBB549FFC } // size 4056 (3 kB) (0 MB) +// { 0xBB54E254, 0xBB54EFFC } // size 3500 (3 kB) (0 MB) +// { 0xBB551028, 0xBB551FFC } // size 4056 (3 kB) (0 MB) +// { 0xBB55A028, 0xBB55BFFC } // size 8152 (7 kB) (0 MB) +// { 0xBB560FD4, 0xBB561FFC } // size 4140 (4 kB) (0 MB) +// { 0xBB566028, 0xBB5681FC } // size 8664 (8 kB) (0 MB) +// { 0xBB56C028, 0xBB56DFFC } // size 8152 (7 kB) (0 MB) +// { 0xBB57223C, 0xBB573FF8 } // size 7616 (7 kB) (0 MB) +// { 0xBB57404C, 0xBB575FFC } // size 8116 (7 kB) (0 MB) +// { 0xBB576450, 0xBB577FFC } // size 7088 (6 kB) (0 MB) +// { 0xBB578308, 0xBB578FFC } // size 3320 (3 kB) (0 MB) +// { 0xBB57F378, 0xBB5801FC } // size 3720 (3 kB) (0 MB) +// { 0xBB5802C0, 0xBB580FFC } // size 3392 (3 kB) (0 MB) +// { 0xBB581028, 0xBB581FFC } // size 4056 (3 kB) (0 MB) +// { 0xBB586028, 0xBB587FFC } // size 8152 (7 kB) (0 MB) +// { 0xBB58C028, 0xBB58E1FC } // size 8664 (8 kB) (0 MB) +// { 0xBB592334, 0xBB592FFC } // size 3276 (3 kB) (0 MB) +// { 0xBB59533C, 0xBB595FFC } // size 3268 (3 kB) (0 MB) +// { 0xBB59A028, 0xBB59AFFC } // size 4056 (3 kB) (0 MB) +// { 0xBB5B8028, 0xBB5B9FFC } // size 8152 (7 kB) (0 MB) +// { 0xBB5C36F0, 0xBB5C41FC } // size 2832 (2 kB) (0 MB) +// { 0xBB5C56F0, 0xBB5C5FFC } // size 2320 (2 kB) (0 MB) +// { 0xBB5C6028, 0xBB5C7FFC } // size 8152 (7 kB) (0 MB) +// { 0xBB5CC528, 0xBB5CE1FC } // size 7384 (7 kB) (0 MB) +// { 0xBB5D2028, 0xBB5D3FFC } // size 8152 (7 kB) (0 MB) +// { 0xBB5D8028, 0xBB5D9FFC } // size 8152 (7 kB) (0 MB) +// { 0xBB5DE23C, 0xBB5DFFF8 } // size 7616 (7 kB) (0 MB) +// { 0xBB5E0054, 0xBB5E1FFC } // size 8108 (7 kB) (0 MB) +// { 0xBB5E2220, 0xBB5E3FFC } // size 7648 (7 kB) (0 MB) +// { 0xBB5E4390, 0xBB5E5FFC } // size 7280 (7 kB) (0 MB) +// { 0xBB5EA028, 0xBB5EA940 } // size 2332 (2 kB) (0 MB) +// { 0xBB630028, 0xBB6323FC } // size 9176 (8 kB) (0 MB) +// { 0xBB636050, 0xBB637FFC } // size 8112 (7 kB) (0 MB) +// { 0xBB63A828, 0xBB63B944 } // size 4384 (4 kB) (0 MB) +// { 0xBB64317C, 0xBB643FF8 } // size 3712 (3 kB) (0 MB) +// { 0xBB64404C, 0xBB645FFC } // size 8116 (7 kB) (0 MB) +// { 0xBB64644C, 0xBB647FFC } // size 7092 (6 kB) (0 MB) +// { 0xBB64A028, 0xBB64AFFC } // size 4056 (3 kB) (0 MB) +// { 0xBB64D028, 0xBB64E1FC } // size 4568 (4 kB) (0 MB) +// { 0xBB64E2C0, 0xBB64EFFC } // size 3392 (3 kB) (0 MB) +// { 0xBB64F028, 0xBB64FFFC } // size 4056 (3 kB) (0 MB) +// { 0xBB654028, 0xBB65683C } // size 10264 (10 kB) (0 MB) +// { 0xBB656FC0, 0xBB6577FC } // size 2112 (2 kB) (0 MB) +// { 0xBB658000, 0xBB658800 } // size 2052 (2 kB) (0 MB) +// { 0xBB658FFC, 0xBB6597FC } // size 2052 (2 kB) (0 MB) +// { 0xBB65A000, 0xBB65A93C } // size 2368 (2 kB) (0 MB) +// { 0xBB65AE98, 0xBB65D7FC } // size 10600 (10 kB) (0 MB) +// { 0xBB65EDE0, 0xBB65FFFC } // size 4640 (4 kB) (0 MB) +// { 0xBB664028, 0xBB6661FC } // size 8664 (8 kB) (0 MB) +// { 0xBB66A028, 0xBB66AFFC } // size 4056 (3 kB) (0 MB) +// { 0xBB66D640, 0xBB66DFFC } // size 2496 (2 kB) (0 MB) +// { 0xBB672028, 0xBB672FFC } // size 4056 (3 kB) (0 MB) +// { 0xBB690028, 0xBB691FFC } // size 8152 (7 kB) (0 MB) +// { 0xBB696834, 0xBB6981FC } // size 6604 (6 kB) (0 MB) +// { 0xBB69C028, 0xBB69DFFC } // size 8152 (7 kB) (0 MB) +// { 0xBB6A233C, 0xBB6A3FFC } // size 7364 (7 kB) (0 MB) +// { 0xBB6A823C, 0xBB6A9FF8 } // size 7616 (7 kB) (0 MB) +// { 0xBB6AA04C, 0xBB6ABFFC } // size 8116 (7 kB) (0 MB) +// { 0xBB6AC424, 0xBB6ADFFC } // size 7132 (6 kB) (0 MB) +// { 0xBB6B0378, 0xBB6B0FFC } // size 3208 (3 kB) (0 MB) +// { 0xBB6B3028, 0xBB6B41FC } // size 4568 (4 kB) (0 MB) +// { 0xBB6B42C0, 0xBB6B4FFC } // size 3392 (3 kB) (0 MB) +// { 0xBB6B5028, 0xBB6B5FFC } // size 4056 (3 kB) (0 MB) +// { 0xBB6BA028, 0xBB6BBFFC } // size 8152 (7 kB) (0 MB) +// { 0xBB6C0028, 0xBB6C21FC } // size 8664 (8 kB) (0 MB) +// { 0xBB6C6028, 0xBB6C6FFC } // size 4056 (3 kB) (0 MB) +// { 0xBB6CAB1C, 0xBB6CBFFC } // size 5348 (5 kB) (0 MB) +// { 0xBB6D0028, 0xBB6D0FFC } // size 4056 (3 kB) (0 MB) +// { 0xBB6EE028, 0xBB6EFFFC } // size 8152 (7 kB) (0 MB) +// { 0xBB6F4528, 0xBB6F61FC } // size 7384 (7 kB) (0 MB) +// { 0xBB6FA028, 0xBB6FBFFC } // size 8152 (7 kB) (0 MB) +// { 0xBB700640, 0xBB701FFC } // size 6592 (6 kB) (0 MB) +// { 0xBB70623C, 0xBB707FF8 } // size 7616 (7 kB) (0 MB) +// { 0xBB708048, 0xBB709FFC } // size 8120 (7 kB) (0 MB) +// { 0xBB70A38C, 0xBB70BFFC } // size 7284 (7 kB) (0 MB) +// { 0xBB710028, 0xBB711FFC } // size 8152 (7 kB) (0 MB) +// { 0xBB716028, 0xBB717FFC } // size 8152 (7 kB) (0 MB) +// { 0xBB71C028, 0xBB71D1FC } // size 4568 (4 kB) (0 MB) +// { 0xBB71D2C0, 0xBB71DFFC } // size 3392 (3 kB) (0 MB) +// { 0xBB71E028, 0xBB71FFFC } // size 8152 (7 kB) (0 MB) +// { 0xBB724028, 0xBB725FFC } // size 8152 (7 kB) (0 MB) +// { 0xBB72B828, 0xBB72C074 } // size 2128 (2 kB) (0 MB) +// { 0xBB736028, 0xBB736908 } // size 2276 (2 kB) (0 MB) +// { 0xBB738028, 0xBB738FFC } // size 4056 (3 kB) (0 MB) +// { 0xBB741028, 0xBB741FFC } // size 4056 (3 kB) (0 MB) +// { 0xBB748A74, 0xBB749FFC } // size 5516 (5 kB) (0 MB) +// { 0xBB74E028, 0xBB74FFFC } // size 8152 (7 kB) (0 MB) +// { 0xBB754028, 0xBB755FFC } // size 8152 (7 kB) (0 MB) +// { 0xBB75A028, 0xBB75C1FC } // size 8664 (8 kB) (0 MB) +// { 0xBB75E528, 0xBB7601FC } // size 7384 (7 kB) (0 MB) +// { 0xBB764028, 0xBB765FFC } // size 8152 (7 kB) (0 MB) +// { 0xBB76EF88, 0xBB77EEB4 } // size 65328 (63 kB) (0 MB) +// { 0xBB77F7E0, 0xBB8477E4 } // size 819208 (800 kB) (0 MB) +// { 0xBB858010, 0xBB859FF8 } // size 8172 (7 kB) (0 MB) +// { 0xBB86A010, 0xBB86BFF8 } // size 8172 (7 kB) (0 MB) +// { 0xBB87C00C, 0xBB936CB8 } // size 765104 (747 kB) (0 MB) +// { 0xBB936D8C, 0xBB94918C } // size 74756 (73 kB) (0 MB) +// { 0xBB94919C, 0xBB94B18C } // size 8180 (7 kB) (0 MB) +// { 0xBB952414, 0xBB952EA0 } // size 2704 (2 kB) (0 MB) +// { 0xBB95310C, 0xBB953FAC } // size 3748 (3 kB) (0 MB) +// { 0xBB954078, 0xBB954FBC } // size 3912 (3 kB) (0 MB) +// { 0xBB954FC8, 0xBB955FC4 } // size 4096 (4 kB) (0 MB) +// { 0xBB956010, 0xBB95700C } // size 4096 (4 kB) (0 MB) +// { 0xBB9570B8, 0xBB95801C } // size 3944 (3 kB) (0 MB) +// { 0xBB958030, 0xBB959028 } // size 4092 (3 kB) (0 MB) +// { 0xBB95904C, 0xBB95A030 } // size 4072 (3 kB) (0 MB) +// { 0xBB95A080, 0xBB95B054 } // size 4056 (3 kB) (0 MB) +// { 0xBB95B388, 0xBB95C35C } // size 4056 (3 kB) (0 MB) +// { 0xBB95C670, 0xBB95D670 } // size 4100 (4 kB) (0 MB) +// { 0xBB95D67C, 0xBB95E678 } // size 4096 (4 kB) (0 MB) +// { 0xBB95E694, 0xBB95F688 } // size 4088 (3 kB) (0 MB) +// { 0xBB95F698, 0xBB960694 } // size 4096 (4 kB) (0 MB) +// { 0xBB9606A0, 0xBB9616A0 } // size 4100 (4 kB) (0 MB) +// { 0xBB9616C4, 0xBB9626A8 } // size 4072 (3 kB) (0 MB) +// { 0xBB9626C0, 0xBB9636B8 } // size 4092 (3 kB) (0 MB) +// { 0xBB9636C4, 0xBB9646C4 } // size 4100 (4 kB) (0 MB) +// { 0xBB9646D0, 0xBB9656D0 } // size 4100 (4 kB) (0 MB) +// { 0xBB9656DC, 0xBB9666DC } // size 4100 (4 kB) (0 MB) +// { 0xBB9666E8, 0xBB9676E4 } // size 4096 (4 kB) (0 MB) +// { 0xBB967704, 0xBB968704 } // size 4100 (4 kB) (0 MB) +// { 0xBB968710, 0xBB96970C } // size 4096 (4 kB) (0 MB) +// { 0xBB969728, 0xBB96A71C } // size 4088 (3 kB) (0 MB) +// { 0xBB96A72C, 0xBB96B728 } // size 4096 (4 kB) (0 MB) +// { 0xBB96B734, 0xBB96C734 } // size 4100 (4 kB) (0 MB) +// { 0xBB96C758, 0xBB96D73C } // size 4072 (3 kB) (0 MB) +// { 0xBB96D754, 0xBB96E74C } // size 4092 (3 kB) (0 MB) +// { 0xBB96E758, 0xBB96F758 } // size 4100 (4 kB) (0 MB) +// { 0xBB96F764, 0xBB970764 } // size 4100 (4 kB) (0 MB) +// { 0xBB970770, 0xBB971770 } // size 4100 (4 kB) (0 MB) +// { 0xBB97177C, 0xBB972778 } // size 4096 (4 kB) (0 MB) +// { 0xBB97ED38, 0xBB97FFF8 } // size 4804 (4 kB) (0 MB) +// { 0xBB980000, 0xBB990028 } // size 65580 (64 kB) (0 MB) +// { 0xBB9936D0, 0xBB993FF8 } // size 2348 (2 kB) (0 MB) +// { 0xBB994000, 0xBB9A4028 } // size 65580 (64 kB) (0 MB) +// { 0xBB9A8D8C, 0xBB9B8CBC } // size 65332 (63 kB) (0 MB) +// { 0xBB9B9528, 0xBB9C90F4 } // size 64464 (62 kB) (0 MB) +// { 0xBB9C9F0C, 0xBB9CB1BC } // size 4788 (4 kB) (0 MB) +// { 0xBB9CB1E4, 0xBB9DB114 } // size 65332 (63 kB) (0 MB) +// { 0xBB9DD3EC, 0xBB9ED15C } // size 64884 (63 kB) (0 MB) +// { 0xBB9EDAFC, 0xBB9F1AFC } // size 16388 (16 kB) (0 MB) +// { 0xBB9F1B40, 0xBB9F5B3C } // size 16384 (16 kB) (0 MB) +// { 0xBB9FAF24, 0xBBA00B74 } // size 23636 (23 kB) (0 MB) +// { 0xBBA00BC0, 0xBBA0EBC0 } // size 57348 (56 kB) (0 MB) +// { 0xBBA0FE1C, 0xBBA1CBBC } // size 52644 (51 kB) (0 MB) +// { 0xBBA1D144, 0xBBA1DCF0 } // size 2992 (2 kB) (0 MB) +// { 0xBBA1DD40, 0xBBA1FCBC } // size 8064 (7 kB) (0 MB) +// { 0xBBA2057C, 0xBBA21C3C } // size 5828 (5 kB) (0 MB) +// { 0xBBA22438, 0xBBA251E8 } // size 11700 (11 kB) (0 MB) +// { 0xBBA25200, 0xBBA2C1FC } // size 28672 (28 kB) (0 MB) +// { 0xBBA2C7AC, 0xBBA331FC } // size 27220 (26 kB) (0 MB) +// { 0xBBA350C8, 0xBBA3678C } // size 5832 (5 kB) (0 MB) +// { 0xBBA367C0, 0xBBA3A17C } // size 14784 (14 kB) (0 MB) +// { 0xBBA3AB1C, 0xBBA3DB3C } // size 12324 (12 kB) (0 MB) +// { 0xBBA40640, 0xBBA4120C } // size 3024 (2 kB) (0 MB) +// { 0xBBA414AC, 0xBBA41DDC } // size 2356 (2 kB) (0 MB) +// { 0xBBA44700, 0xBBA456C0 } // size 4036 (3 kB) (0 MB) +// { 0xBBA45BFC, 0xBBA4667C } // size 2692 (2 kB) (0 MB) +// { 0xBBA48290, 0xBBA48A90 } // size 2052 (2 kB) (0 MB) +// { 0xBBA722AC, 0xBBA821DC } // size 65332 (63 kB) (0 MB) +// { 0xBBA84708, 0xBBA8A0E8 } // size 23012 (22 kB) (0 MB) +// { 0xBBA8A100, 0xBBA980FC } // size 57344 (56 kB) (0 MB) +// { 0xBBA99EBC, 0xBBAA60FC } // size 49732 (48 kB) (0 MB) +// { 0xBBAAC960, 0xBBAB0480 } // size 15140 (14 kB) (0 MB) +// { 0xBBAB04C0, 0xBBABE4BC } // size 57344 (56 kB) (0 MB) +// { 0xBBAC3B5C, 0xBBACC4BC } // size 35172 (34 kB) (0 MB) +// { 0xBBACFBFC, 0xBBAD0D0C } // size 4372 (4 kB) (0 MB) +// { 0xBBAD0DEC, 0xBBAD1E1C } // size 4148 (4 kB) (0 MB) +// { 0xBBAD4434, 0xBBAD6920 } // size 9456 (9 kB) (0 MB) +// { 0xBBAD6940, 0xBBAE025C } // size 39200 (38 kB) (0 MB) +// { 0xBBAE45BC, 0xBBAE9B7C } // size 21956 (21 kB) (0 MB) +// { 0xBBAED0CC, 0xBBAEF5B8 } // size 9456 (9 kB) (0 MB) +// { 0xBBAEF600, 0xBBAF8F1C } // size 39200 (38 kB) (0 MB) +// { 0xBBAFD27C, 0xBBB0283C } // size 21956 (21 kB) (0 MB) +// { 0xBBB051BC, 0xBBB05D8C } // size 3028 (2 kB) (0 MB) +// { 0xBBB05EDC, 0xBBB0695C } // size 2692 (2 kB) (0 MB) +// { 0xBBB08900, 0xBBB094CC } // size 3024 (2 kB) (0 MB) +// { 0xBBB095AC, 0xBBB0A09C } // size 2804 (2 kB) (0 MB) +// { 0xBBB0D884, 0xBBB0F224 } // size 6564 (6 kB) (0 MB) +// { 0xBBB0F240, 0xBBB1623C } // size 28672 (28 kB) (0 MB) +// { 0xBBB196BC, 0xBBB1D23C } // size 15236 (14 kB) (0 MB) +// { 0xBBB212B4, 0xBBB22894 } // size 5604 (5 kB) (0 MB) +// { 0xBBB228C0, 0xBBB298BC } // size 28672 (28 kB) (0 MB) +// { 0xBBB2D5FC, 0xBBB308BC } // size 12996 (12 kB) (0 MB) +// { 0xBBB364A4, 0xBBB382CC } // size 7724 (7 kB) (0 MB) +// { 0xBBB38300, 0xBBB40EFC } // size 35840 (35 kB) (0 MB) +// { 0xBBB454FC, 0xBBB49AFC } // size 17924 (17 kB) (0 MB) +// { 0xBBB4E6E0, 0xBBB515BC } // size 12000 (11 kB) (0 MB) +// { 0xBBB515D4, 0xBBB52570 } // size 4000 (3 kB) (0 MB) +// { 0xBBB54F5C, 0xBBB5653C } // size 5604 (5 kB) (0 MB) +// { 0xBBB56580, 0xBBB5D57C } // size 28672 (28 kB) (0 MB) +// { 0xBBB612BC, 0xBBB6457C } // size 12996 (12 kB) (0 MB) +// { 0xBBB6A580, 0xBBB6B68C } // size 4368 (4 kB) (0 MB) +// { 0xBBB6B76C, 0xBBB6C79C } // size 4148 (4 kB) (0 MB) +// { 0xBBB70F3C, 0xBBB7251C } // size 5604 (5 kB) (0 MB) +// { 0xBBB72540, 0xBBB7953C } // size 28672 (28 kB) (0 MB) +// { 0xBBB7D27C, 0xBBB8053C } // size 12996 (12 kB) (0 MB) +// { 0xBBB83680, 0xBBB8424C } // size 3024 (2 kB) (0 MB) +// { 0xBBB8439C, 0xBBB84E1C } // size 2692 (2 kB) (0 MB) +// { 0xBBB86DC0, 0xBBB8798C } // size 3024 (2 kB) (0 MB) +// { 0xBBB87A6C, 0xBBB8855C } // size 2804 (2 kB) (0 MB) +// { 0xBBB8FD08, 0xBBB916A8 } // size 6564 (6 kB) (0 MB) +// { 0xBBB916C0, 0xBBB986BC } // size 28672 (28 kB) (0 MB) +// { 0xBBB9BB3C, 0xBBB9F6BC } // size 15236 (14 kB) (0 MB) +// { 0xBBBA2280, 0xBBBA338C } // size 4368 (4 kB) (0 MB) +// { 0xBBBA377C, 0xBBBA449C } // size 3364 (3 kB) (0 MB) +// { 0xBBBAA238, 0xBBBABBD8 } // size 6564 (6 kB) (0 MB) +// { 0xBBBABC00, 0xBBBB2BFC } // size 28672 (28 kB) (0 MB) +// { 0xBBBB607C, 0xBBBB9BFC } // size 15236 (14 kB) (0 MB) +// { 0xBBBBD380, 0xBBBBDF4C } // size 3024 (2 kB) (0 MB) +// { 0xBBBC1230, 0xBBBC1D6C } // size 2880 (2 kB) (0 MB) +// { 0xBBBC1D7C, 0xBBBC4F5C } // size 12772 (12 kB) (0 MB) +// { 0xBBBC74F8, 0xBBBCA22C } // size 11576 (11 kB) (0 MB) +// { 0xBBBCA23C, 0xBBBD513C } // size 44804 (43 kB) (0 MB) +// { 0xBBBD973C, 0xBBBE003C } // size 26884 (26 kB) (0 MB) +// { 0xBBBE1658, 0xBBBE2194 } // size 2880 (2 kB) (0 MB) +// { 0xBBBE21C0, 0xBBBE539C } // size 12768 (12 kB) (0 MB) +// { 0xBBBE8000, 0xBBBE8FBC } // size 4032 (3 kB) (0 MB) +// { 0xBBBE909C, 0xBBBE9F7C } // size 3812 (3 kB) (0 MB) +// { 0xBBBEBE78, 0xBBBED818 } // size 6564 (6 kB) (0 MB) +// { 0xBBBED840, 0xBBBF483C } // size 28672 (28 kB) (0 MB) +// { 0xBBBF7CBC, 0xBBBFB83C } // size 15236 (14 kB) (0 MB) +// { 0xBBBFD970, 0xBBC00750 } // size 11748 (11 kB) (0 MB) +// { 0xBBC00780, 0xBBC0777C } // size 28672 (28 kB) (0 MB) +// { 0xBBC07CBC, 0xBBC0E77C } // size 27332 (26 kB) (0 MB) +// { 0xBBC10478, 0xBBC11E18 } // size 6564 (6 kB) (0 MB) +// { 0xBBC11E40, 0xBBC18E3C } // size 28672 (28 kB) (0 MB) +// { 0xBBC1C2BC, 0xBBC1FE3C } // size 15236 (14 kB) (0 MB) +// { 0xBBC227BC, 0xBBC2338C } // size 3028 (2 kB) (0 MB) +// { 0xBBC234DC, 0xBBC23F5C } // size 2692 (2 kB) (0 MB) +// { 0xBBC25F00, 0xBBC26ACC } // size 3024 (2 kB) (0 MB) +// { 0xBBC26BAC, 0xBBC2769C } // size 2804 (2 kB) (0 MB) +// { 0xBBC2B3EC, 0xBBC2D0C4 } // size 7388 (7 kB) (0 MB) +// { 0xBBC2D100, 0xBBC3543C } // size 33600 (32 kB) (0 MB) +// { 0xBBC3948C, 0xBBC3D77C } // size 17140 (16 kB) (0 MB) +// { 0xBBC3E9D4, 0xBBC3F510 } // size 2880 (2 kB) (0 MB) +// { 0xBBC3F540, 0xBBC4271C } // size 12768 (12 kB) (0 MB) +// { 0xBBC49440, 0xBBC4AA20 } // size 5604 (5 kB) (0 MB) +// { 0xBBC4AA40, 0xBBC51A3C } // size 28672 (28 kB) (0 MB) +// { 0xBBC5577C, 0xBBC58A3C } // size 12996 (12 kB) (0 MB) +// { 0xBBC59C94, 0xBBC5A7D0 } // size 2880 (2 kB) (0 MB) +// { 0xBBC5A800, 0xBBC5D9DC } // size 12768 (12 kB) (0 MB) +// { 0xBBC606C0, 0xBBC617CC } // size 4368 (4 kB) (0 MB) +// { 0xBBC618AC, 0xBBC628DC } // size 4148 (4 kB) (0 MB) +// { 0xBBC69AE4, 0xBBC6B364 } // size 6276 (6 kB) (0 MB) +// { 0xBBC6B380, 0xBBC7237C } // size 28672 (28 kB) (0 MB) +// { 0xBBC75A9C, 0xBBC7937C } // size 14564 (14 kB) (0 MB) +// { 0xBBC7C4C0, 0xBBC7D08C } // size 3024 (2 kB) (0 MB) +// { 0xBBC7D1DC, 0xBBC7DC5C } // size 2692 (2 kB) (0 MB) +// { 0xBBC7FC00, 0xBBC807CC } // size 3024 (2 kB) (0 MB) +// { 0xBBC808AC, 0xBBC8139C } // size 2804 (2 kB) (0 MB) +// { 0xBBC82144, 0xBBC82C80 } // size 2880 (2 kB) (0 MB) +// { 0xBBC82CC0, 0xBBC85E9C } // size 12768 (12 kB) (0 MB) +// { 0xBBC8E4C0, 0xBBC8F08C } // size 3024 (2 kB) (0 MB) +// { 0xBBC8F1DC, 0xBBC8FC5C } // size 2692 (2 kB) (0 MB) +// { 0xBBC91C00, 0xBBC927CC } // size 3024 (2 kB) (0 MB) +// { 0xBBC928AC, 0xBBC9339C } // size 2804 (2 kB) (0 MB) +// { 0xBBC94878, 0xBBC96C38 } // size 9156 (8 kB) (0 MB) +// { 0xBBC96C80, 0xBBC9DC7C } // size 28672 (28 kB) (0 MB) +// { 0xBBC9F95C, 0xBBCA4C7C } // size 21284 (20 kB) (0 MB) +// { 0xBBCA8FB0, 0xBBCABBB0 } // size 11268 (11 kB) (0 MB) +// { 0xBBCABC00, 0xBBCB2BFC } // size 28672 (28 kB) (0 MB) +// { 0xBBCB359C, 0xBBCB9BFC } // size 26212 (25 kB) (0 MB) +// { 0xBBCBBAF0, 0xBBCBE840 } // size 11604 (11 kB) (0 MB) +// { 0xBBCBE880, 0xBBCC587C } // size 28672 (28 kB) (0 MB) +// { 0xBBCC5F0C, 0xBBCCC87C } // size 26996 (26 kB) (0 MB) +// { 0xBBCCE0E8, 0xBBCD1078 } // size 12180 (11 kB) (0 MB) +// { 0xBBCD10C0, 0xBBCD80BC } // size 28672 (28 kB) (0 MB) +// { 0xBBCD820C, 0xBBCDF0BC } // size 28340 (27 kB) (0 MB) +// { 0xBBCE02FC, 0xBBCE307C } // size 11652 (11 kB) (0 MB) +// { 0xBBCE30C0, 0xBBCEA0BC } // size 28672 (28 kB) (0 MB) +// { 0xBBCEA6DC, 0xBBCF10BC } // size 27108 (26 kB) (0 MB) +// { 0xBBCF4750, 0xBBCF66F0 } // size 8100 (7 kB) (0 MB) +// { 0xBBCF6740, 0xBBCFD73C } // size 28672 (28 kB) (0 MB) +// { 0xBBCFFDBC, 0xBBD0473C } // size 18820 (18 kB) (0 MB) +// { 0xBBD07800, 0xBBD083CC } // size 3024 (2 kB) (0 MB) +// { 0xBBD0AF00, 0xBBD0BACC } // size 3024 (2 kB) (0 MB) +// { 0xBBD10FB8, 0xBBD11830 } // size 2172 (2 kB) (0 MB) +// { 0xBBD1205C, 0xBBD1301C } // size 4036 (3 kB) (0 MB) +// { 0xBBD137FC, 0xBBD147BC } // size 4036 (3 kB) (0 MB) +// { 0xBBD158AC, 0xBBD1640C } // size 2916 (2 kB) (0 MB) +// { 0xBBD169BC, 0xBBD1751C } // size 2916 (2 kB) (0 MB) +// { 0xBBD1EE0C, 0xBBD1FB9C } // size 3476 (3 kB) (0 MB) +// { 0xBBD2006C, 0xBBD20DFC } // size 3476 (3 kB) (0 MB) +// { 0xBBD2348C, 0xBBD2405C } // size 3028 (2 kB) (0 MB) +// { 0xBBD246EC, 0xBBD252BC } // size 3028 (2 kB) (0 MB) +// { 0xBBD2786C, 0xBBD2851C } // size 3252 (3 kB) (0 MB) +// { 0xBBD28ACC, 0xBBD2977C } // size 3252 (3 kB) (0 MB) +// { 0xBBD2BAFC, 0xBBD2C9DC } // size 3812 (3 kB) (0 MB) +// { 0xBBD2CD5C, 0xBBD2DC3C } // size 3812 (3 kB) (0 MB) +// { 0xBBD301EC, 0xBBD30E9C } // size 3252 (3 kB) (0 MB) +// { 0xBBD3144C, 0xBBD320FC } // size 3252 (3 kB) (0 MB) +// { 0xBBD346AC, 0xBBD3535C } // size 3252 (3 kB) (0 MB) +// { 0xBBD3590C, 0xBBD365BC } // size 3252 (3 kB) (0 MB) +// { 0xBBD38D9C, 0xBBD3981C } // size 2692 (2 kB) (0 MB) +// { 0xBBD39FFC, 0xBBD3AA7C } // size 2692 (2 kB) (0 MB) +// { 0xBBD3EB3C, 0xBBD402F0 } // size 6072 (5 kB) (0 MB) +// { 0xBBD412FC, 0xBBD4423C } // size 12100 (11 kB) (0 MB) +// { 0xBBD451FC, 0xBBD4813C } // size 12100 (11 kB) (0 MB) +// { 0xBBD496F4, 0xBBD4A7E0 } // size 4336 (4 kB) (0 MB) +// { 0xBBD4AD3C, 0xBBD4D1FC } // size 9412 (9 kB) (0 MB) +// { 0xBBD4D73C, 0xBBD4FBFC } // size 9412 (9 kB) (0 MB) +// { 0xBBD537BC, 0xBBD5955C } // size 23972 (23 kB) (0 MB) +// { 0xBBD5A1BC, 0xBBD6757C } // size 54212 (52 kB) (0 MB) +// { 0xBBD681BC, 0xBBD7557C } // size 54212 (52 kB) (0 MB) +// { 0xBBD769EC, 0xBBD77D4C } // size 4964 (4 kB) (0 MB) +// { 0xBBD78C5C, 0xBBD7B1FC } // size 9636 (9 kB) (0 MB) +// { 0xBBD7C0DC, 0xBBD7E67C } // size 9636 (9 kB) (0 MB) +// { 0xBBD8CF0C, 0xBBD8D9FC } // size 2804 (2 kB) (0 MB) +// { 0xBBD8DECC, 0xBBD8E9BC } // size 2804 (2 kB) (0 MB) +// { 0xBBD9388C, 0xBBD9437C } // size 2804 (2 kB) (0 MB) +// { 0xBBD9484C, 0xBBD9533C } // size 2804 (2 kB) (0 MB) +// { 0xBBD9993C, 0xBBD9A73C } // size 3588 (3 kB) (0 MB) +// { 0xBBD9D140, 0xBBD9E39C } // size 4704 (4 kB) (0 MB) +// { 0xBBD9E94C, 0xBBD9F5FC } // size 3252 (3 kB) (0 MB) +// { 0xBBDA3010, 0xBBDA3AFC } // size 2800 (2 kB) (0 MB) +// { 0xBBDA3B40, 0xBBDA581C } // size 7392 (7 kB) (0 MB) +// { 0xBBDA5F1C, 0xBBDA74FC } // size 5604 (5 kB) (0 MB) +// { 0xBBDAA08C, 0xBBDAB50C } // size 5252 (5 kB) (0 MB) +// { 0xBBDAB540, 0xBBDAE9BC } // size 13440 (13 kB) (0 MB) +// { 0xBBDAF35C, 0xBBDB1E3C } // size 10980 (10 kB) (0 MB) +// { 0xBBDB3180, 0xBBDB43DC } // size 4704 (4 kB) (0 MB) +// { 0xBBDB7BDC, 0xBBDB86C8 } // size 2800 (2 kB) (0 MB) +// { 0xBBDB8700, 0xBBDBA3DC } // size 7392 (7 kB) (0 MB) +// { 0xBBDBAADC, 0xBBDBC0BC } // size 5604 (5 kB) (0 MB) +// { 0xBBDBEA88, 0xBBDC0058 } // size 5588 (5 kB) (0 MB) +// { 0xBBDC0080, 0xBBDC34FC } // size 13440 (13 kB) (0 MB) +// { 0xBBDC387C, 0xBBDC697C } // size 12548 (12 kB) (0 MB) +// { 0xBBDC8374, 0xBBDC96A4 } // size 4916 (4 kB) (0 MB) +// { 0xBBDC96C0, 0xBBDCC5FC } // size 12096 (11 kB) (0 MB) +// { 0xBBDCCB3C, 0xBBDCF53C } // size 10756 (10 kB) (0 MB) +// { 0xBBDD50A4, 0xBBDDB054 } // size 24500 (23 kB) (0 MB) +// { 0xBBDDB080, 0xBBDE907C } // size 57344 (56 kB) (0 MB) +// { 0xBBDE931C, 0xBBDF707C } // size 56676 (55 kB) (0 MB) +// { 0xBBDFABC8, 0xBBDFC388 } // size 6084 (5 kB) (0 MB) +// { 0xBBDFC3C0, 0xBBE033BC } // size 28672 (28 kB) (0 MB) +// { 0xBBE06C9C, 0xBBE0A3BC } // size 14116 (13 kB) (0 MB) +// { 0xBBE0CC2C, 0xBBE0DF94 } // size 4972 (4 kB) (0 MB) +// { 0xBBE0DFC0, 0xBBE1311C } // size 20832 (20 kB) (0 MB) +// { 0xBBE1556C, 0xBBE1827C } // size 11540 (11 kB) (0 MB) +// { 0xBBE1B698, 0xBBE1D0C4 } // size 6704 (6 kB) (0 MB) +// { 0xBBE1D100, 0xBBE22F7C } // size 24192 (23 kB) (0 MB) +// { 0xBBE2512C, 0xBBE28DFC } // size 15572 (15 kB) (0 MB) +// { 0xBBE29650, 0xBBE2B6A8 } // size 8284 (8 kB) (0 MB) +// { 0xBBE2B6C0, 0xBBE3081C } // size 20832 (20 kB) (0 MB) +// { 0xBBE30E3C, 0xBBE3597C } // size 19268 (18 kB) (0 MB) +// { 0xBBE35DF8, 0xBBE38174 } // size 9088 (8 kB) (0 MB) +// { 0xBBE381C0, 0xBBE4247C } // size 41664 (40 kB) (0 MB) +// { 0xBBE46F68, 0xBBE494D8 } // size 9588 (9 kB) (0 MB) +// { 0xBBE49500, 0xBBE504FC } // size 28672 (28 kB) (0 MB) +// { 0xBBE51DEC, 0xBBE574FC } // size 22292 (21 kB) (0 MB) +// { 0xBBE5A278, 0xBBE5BE88 } // size 7188 (7 kB) (0 MB) +// { 0xBBE5BEC0, 0xBBE62EBC } // size 28672 (28 kB) (0 MB) +// { 0xBBE65D8C, 0xBBE69EBC } // size 16692 (16 kB) (0 MB) +// { 0xBBE6C780, 0xBBE6E37C } // size 7168 (7 kB) (0 MB) +// { 0xBBE72240, 0xBBE73E3C } // size 7168 (7 kB) (0 MB) +// { 0xBBE77640, 0xBBE7923C } // size 7168 (7 kB) (0 MB) +// { 0xBBE7CA40, 0xBBE7E63C } // size 7168 (7 kB) (0 MB) +// { 0xBBE85940, 0xBBE870E0 } // size 6052 (5 kB) (0 MB) +// { 0xBBE87A7C, 0xBBE8887C } // size 3588 (3 kB) (0 MB) +// { 0xBBE8AB90, 0xBBE8BA6C } // size 3808 (3 kB) (0 MB) +// { 0xBBE8BA7C, 0xBBE8E47C } // size 10756 (10 kB) (0 MB) +// { 0xBBE8F35C, 0xBBE90E7C } // size 6948 (6 kB) (0 MB) +// { 0xBBE96240, 0xBBE9703C } // size 3584 (3 kB) (0 MB) +// { 0xBBE9711C, 0xBBE97E3C } // size 3364 (3 kB) (0 MB) +// { 0xBBE9AA40, 0xBBE9B83C } // size 3584 (3 kB) (0 MB) +// { 0xBBE9B91C, 0xBBE9C63C } // size 3364 (3 kB) (0 MB) +// { 0xBBEA0280, 0xBBEA107C } // size 3584 (3 kB) (0 MB) +// { 0xBBEA131C, 0xBBEA1E7C } // size 2916 (2 kB) (0 MB) +// { 0xBBEA4A80, 0xBBEA587C } // size 3584 (3 kB) (0 MB) +// { 0xBBEA5A3C, 0xBBEA667C } // size 3140 (3 kB) (0 MB) +// { 0xBBEA7024, 0xBBEA7F00 } // size 3808 (3 kB) (0 MB) +// { 0xBBEA7F40, 0xBBEAA940 } // size 10756 (10 kB) (0 MB) +// { 0xBBEAB81C, 0xBBEAD33C } // size 6948 (6 kB) (0 MB) +// { 0xBBEAFCC0, 0xBBEB0ABC } // size 3584 (3 kB) (0 MB) +// { 0xBBEB0D5C, 0xBBEB18BC } // size 2916 (2 kB) (0 MB) +// { 0xBBEB44C0, 0xBBEB52BC } // size 3584 (3 kB) (0 MB) +// { 0xBBEB547C, 0xBBEB60BC } // size 3140 (3 kB) (0 MB) +// { 0xBBEB6854, 0xBBEB7940 } // size 4336 (4 kB) (0 MB) +// { 0xBBEB7980, 0xBBEBA380 } // size 10756 (10 kB) (0 MB) +// { 0xBBEBA8BC, 0xBBEBCD7C } // size 9412 (9 kB) (0 MB) +// { 0xBBEC4880, 0xBBEC6410 } // size 7060 (6 kB) (0 MB) +// { 0xBBEC73CC, 0xBBEC7F9C } // size 3028 (2 kB) (0 MB) +// { 0xBBED5740, 0xBBED653C } // size 3584 (3 kB) (0 MB) +// { 0xBBED661C, 0xBBED733C } // size 3364 (3 kB) (0 MB) +// { 0xBBED9F40, 0xBBEDAD3C } // size 3584 (3 kB) (0 MB) +// { 0xBBEDAE1C, 0xBBEDBB3C } // size 3364 (3 kB) (0 MB) +// { 0xBBEDE940, 0xBBEDF900 } // size 4036 (3 kB) (0 MB) +// { 0xBBEDFB9C, 0xBBEE08BC } // size 3364 (3 kB) (0 MB) +// { 0xBBEE4300, 0xBBEE50FC } // size 3584 (3 kB) (0 MB) +// { 0xBBEE52BC, 0xBBEE5EFC } // size 3140 (3 kB) (0 MB) +// { 0xBBEE8B00, 0xBBEE98FC } // size 3584 (3 kB) (0 MB) +// { 0xBBEE9B9C, 0xBBEEA6FC } // size 2916 (2 kB) (0 MB) +// { 0xBBEEB440, 0xBBEEC400 } // size 4036 (3 kB) (0 MB) +// { 0xBBEEC69C, 0xBBEED3BC } // size 3364 (3 kB) (0 MB) +// { 0xBBEEFAB4, 0xBBEF0BA4 } // size 4340 (4 kB) (0 MB) +// { 0xBBEF0BC0, 0xBBEF385C } // size 11424 (11 kB) (0 MB) +// { 0xBBEF42DC, 0xBBEF64FC } // size 8740 (8 kB) (0 MB) +// { 0xBBEF71C0, 0xBBEF817C } // size 4032 (3 kB) (0 MB) +// { 0xBBEF83AC, 0xBBEF913C } // size 3476 (3 kB) (0 MB) +// { 0xBBF03080, 0xBBF04C7C } // size 7168 (7 kB) (0 MB) +// { 0xBBF08B40, 0xBBF0A73C } // size 7168 (7 kB) (0 MB) +// { 0xBBF0DF40, 0xBBF0FB3C } // size 7168 (7 kB) (0 MB) +// { 0xBBF13340, 0xBBF14F3C } // size 7168 (7 kB) (0 MB) +// { 0xBBF17CB0, 0xBBF195F0 } // size 6468 (6 kB) (0 MB) +// { 0xBBF19640, 0xBBF2063C } // size 28672 (28 kB) (0 MB) +// { 0xBBF23B9C, 0xBBF2763C } // size 15012 (14 kB) (0 MB) +// { 0xBBF28CC0, 0xBBF2BAA0 } // size 11748 (11 kB) (0 MB) +// { 0xBBF2BAC0, 0xBBF32ABC } // size 28672 (28 kB) (0 MB) +// { 0xBBF32FFC, 0xBBF39ABC } // size 27332 (26 kB) (0 MB) +// { 0xBC9AA154, 0xBC9ABAB8 } // size 6504 (6 kB) (0 MB) +// { 0xBC9AC81C, 0xBC9AFC9C } // size 13444 (13 kB) (0 MB) +// { 0xBC9B09BC, 0xBC9B3E3C } // size 13444 (13 kB) (0 MB) +// { 0xBC9B6E44, 0xBC9B87A8 } // size 6504 (6 kB) (0 MB) +// { 0xBC9B94DC, 0xBC9BC95C } // size 13444 (13 kB) (0 MB) +// { 0xBC9BD67C, 0xBC9C0AFC } // size 13444 (13 kB) (0 MB) +// { 0xBC9C3C98, 0xBC9C871C } // size 19080 (18 kB) (0 MB) +// { 0xBCA0F4A4, 0xBCA35ABC } // size 157212 (153 kB) (0 MB) +// { 0xBCA35AF0, 0xBCA36764 } // size 3192 (3 kB) (0 MB) +// { 0xBCA36774, 0xBCA4662C } // size 65212 (63 kB) (0 MB) +// { 0xBCA48AB0, 0xBCAE0FFC } // size 623952 (609 kB) (0 MB) +// { 0xBCAE7878, 0xBD207DB4 } // size 7472448 (7297 kB) (7 MB) +// { 0xBD3B966C, 0xBD8943C0 } // size 5090648 (4971 kB) (4 MB) +// { 0xBD894770, 0xBD8A037C } // size 48144 (47 kB) (0 MB) +// { 0xBD8A1F88, 0xBD8A2D7C } // size 3576 (3 kB) (0 MB) +// { 0xBD8A63F4, 0xBD8AD3C4 } // size 28628 (27 kB) (0 MB) +// { 0xBD8AD3D8, 0xBDFFFFFC } // size 7679016 (7499 kB) (7 MB) +// { 0xBE2F02A0, 0xBE2F217C } // size 7904 (7 kB) (0 MB) +// { 0xBE320A64, 0xBE323574 } // size 11028 (10 kB) (0 MB) +// { 0xBE324220, 0xBE32B73C } // size 29984 (29 kB) (0 MB) +// { 0xBE34A2A0, 0xBE34C0FC } // size 7776 (7 kB) (0 MB) +// { 0xBE358B80, 0xBE35CCFC } // size 16768 (16 kB) (0 MB) +// { 0xBE363020, 0xBE36407C } // size 4192 (4 kB) (0 MB) +// { 0xBE37EB98, 0xBE38172C } // size 11160 (10 kB) (0 MB) +// { 0xBE382600, 0xBE3AC4BC } // size 171712 (167 kB) (0 MB) +// { 0xBE3BF8D0, 0xBE3E24FC } // size 142384 (139 kB) (0 MB) +// { 0xBE3EB3B0, 0xBE3EE394 } // size 12264 (11 kB) (0 MB) +// { 0xBE3EFD40, 0xBE410CBC } // size 135040 (131 kB) (0 MB) +// { 0xBE41EA50, 0xBE4474FC } // size 166576 (162 kB) (0 MB) +// { 0xBE46ADC0, 0xBE46E57C } // size 14272 (13 kB) (0 MB) +// { 0xBE473BE0, 0xBE47543C } // size 6240 (6 kB) (0 MB) +// { 0xBE47EFD0, 0xBE4884BC } // size 38128 (37 kB) (0 MB) +// { 0xBE49167C, 0xBE493C2C } // size 9652 (9 kB) (0 MB) +// { 0xBE495690, 0xBE49C57C } // size 28400 (27 kB) (0 MB) +// { 0xBE4A58B0, 0xBE4B49FC } // size 61776 (60 kB) (0 MB) +// { 0xBE4DC17C, 0xBE4DF94C } // size 14292 (13 kB) (0 MB) +// { 0xBE4E0AD0, 0xBE5000BC } // size 128496 (125 kB) (0 MB) +// { 0xBE50A1A0, 0xBE53327C } // size 168160 (164 kB) (0 MB) +// { 0xBE536660, 0xBE5584FC } // size 138912 (135 kB) (0 MB) +// { 0xBE58316C, 0xBE58659C } // size 13364 (13 kB) (0 MB) +// { 0xBE586AD0, 0xBE5B86BC } // size 203760 (198 kB) (0 MB) +// { 0xBE5CFF70, 0xBE5D7FBC } // size 32848 (32 kB) (0 MB) +// { 0xBE5DE9D8, 0xBE5E0F8C } // size 9656 (9 kB) (0 MB) +// { 0xBE5E12B0, 0xBE60507C } // size 146896 (143 kB) (0 MB) +// { 0xBE605CBC, 0xBFF849BC } // size 26733828 (26107 kB) (25 MB) +// { 0xBFF869BC, 0xBFF8CA3C } // size 24708 (24 kB) (0 MB) +// { 0xBFF8DA24, 0xBFF8E600 } // size 3040 (2 kB) (0 MB) + +// { 0xC1000000, 0xC1E1FFFC } // size 14811136 (14464 kB) (14 MB) +// { 0xC1EB1380, 0xC1EB4B3C } // size 14272 (13 kB) (0 MB) +// { 0xC1FEFE7C, 0xC1FF5EFC } // size 24708 (24 kB) (0 MB) +// { 0xC1FF6E84, 0xC1FF7AC0 } // size 3136 (3 kB) (0 MB) +// { 0xC2086268, 0xC2090B3C } // size 43224 (42 kB) (0 MB) +// { 0xC20B15D8, 0xC20B97FC } // size 33320 (32 kB) (0 MB) +// { 0xC20BE2A0, 0xC20BED7C } // size 2784 (2 kB) (0 MB) +// { 0xC20CCE7C, 0xC20CEEBC } // size 8260 (8 kB) (0 MB) +// { 0xC20E5888, 0xC20E7E4C } // size 9672 (9 kB) (0 MB) +// { 0xC20E7E58, 0xC20EC73C } // size 18664 (18 kB) (0 MB) +// { 0xC20F212C, 0xC210AF3C } // size 101908 (99 kB) (0 MB) +// { 0xC2119BAC, 0xC211EEFC } // size 21332 (20 kB) (0 MB) +// { 0xC2122F30, 0xC212787C } // size 18768 (18 kB) (0 MB) +// { 0xC2131054, 0xC213C63C } // size 46572 (45 kB) (0 MB) +// { 0xC214A474, 0xC214DC3C } // size 14284 (13 kB) (0 MB) +// { 0xC21ABCA0, 0xC21AE904 } // size 11368 (11 kB) (0 MB) +// { 0xC21AE910, 0xC21C207C } // size 79728 (77 kB) (0 MB) +// { 0xC21DBB50, 0xC21DCFFC } // size 5296 (5 kB) (0 MB) +// { 0xC21DD064, 0xC21E287C } // size 22556 (22 kB) (0 MB) +// { 0xC301308C, 0xC301F0BC } // size 49204 (48 kB) (0 MB) +// { 0xC301F0C4, 0xC3023014 } // size 16212 (15 kB) (0 MB) +// { 0xC30230C4, 0xC3027014 } // size 16212 (15 kB) (0 MB) +// { 0xC30270C4, 0xC302B014 } // size 16212 (15 kB) (0 MB) +// { 0xC302B0C4, 0xC302F014 } // size 16212 (15 kB) (0 MB) +// { 0xC302F0C4, 0xC3033014 } // size 16212 (15 kB) (0 MB) +// { 0xC30330C4, 0xC3037014 } // size 16212 (15 kB) (0 MB) +// { 0xC30398E8, 0xC303A2B4 } // size 2512 (2 kB) (0 MB) +// { 0xC303B068, 0xC303BC68 } // size 3076 (3 kB) (0 MB) +// { 0xC3043150, 0xC3043C64 } // size 2840 (2 kB) (0 MB) +// { 0xC3045AF0, 0xC304E09C } // size 34224 (33 kB) (0 MB) +// { 0xC304E3D4, 0xC3050B24 } // size 10068 (9 kB) (0 MB) +// { 0xC3051940, 0xC30528D4 } // size 3992 (3 kB) (0 MB) +// { 0xC3052930, 0xC30538DC } // size 4016 (3 kB) (0 MB) +// { 0xC3053934, 0xC30548D4 } // size 4004 (3 kB) (0 MB) +// { 0xC30566EC, 0xC3058664 } // size 8060 (7 kB) (0 MB) +// { 0xC30586EC, 0xC305A664 } // size 8060 (7 kB) (0 MB) +// { 0xC305A6EC, 0xC305C664 } // size 8060 (7 kB) (0 MB) +// { 0xC305CB90, 0xC305DC78 } // size 4332 (4 kB) (0 MB) +// { 0xC305E40C, 0xC305ECF0 } // size 2280 (2 kB) (0 MB) +// { 0xC3060044, 0xC3060F8C } // size 3916 (3 kB) (0 MB) +// { 0xC3061040, 0xC306203C } // size 4096 (4 kB) (0 MB) +// { 0xC3062DB8, 0xC306EE3C } // size 49288 (48 kB) (0 MB) +// { 0xC306EE84, 0xC3070DC4 } // size 8004 (7 kB) (0 MB) +// { 0xC3070E84, 0xC3072DC4 } // size 8004 (7 kB) (0 MB) +// { 0xC3072E84, 0xC3074DC4 } // size 8004 (7 kB) (0 MB) +// { 0xC30761F0, 0xC307745C } // size 4720 (4 kB) (0 MB) +// { 0xC307F28C, 0xC307FAC0 } // size 2104 (2 kB) (0 MB) +// { 0xC307FAF8, 0xC3081350 } // size 6236 (6 kB) (0 MB) +// { 0xC3081358, 0xC30822A4 } // size 3920 (3 kB) (0 MB) +// { 0xC3082358, 0xC30832A4 } // size 3920 (3 kB) (0 MB) +// { 0xC3083358, 0xC30842A4 } // size 3920 (3 kB) (0 MB) +// { 0xC30858E4, 0xC30878C4 } // size 8164 (7 kB) (0 MB) +// { 0xC30878F8, 0xC308B8C4 } // size 16336 (15 kB) (0 MB) +// { 0xC308C240, 0xC3097744 } // size 46344 (45 kB) (0 MB) +// { 0xC3097930, 0xC30A37E4 } // size 48824 (47 kB) (0 MB) +// { 0xC30A3818, 0xC30B16BC } // size 57000 (55 kB) (0 MB) +// { 0xC30B16C4, 0xC30B262C } // size 3948 (3 kB) (0 MB) +// { 0xC30B26C0, 0xC30B3B3C } // size 5248 (5 kB) (0 MB) +// { 0xC30B4204, 0xC30B5900 } // size 5888 (5 kB) (0 MB) +// { 0xC30B5934, 0xC30B713C } // size 6156 (6 kB) (0 MB) +// { 0xC30B7190, 0xC30BC074 } // size 20200 (19 kB) (0 MB) +// { 0xC30BC138, 0xC30BD13C } // size 4104 (4 kB) (0 MB) +// { 0xC30BD144, 0xC30C1084 } // size 16196 (15 kB) (0 MB) +// { 0xC30C1144, 0xC30C5084 } // size 16196 (15 kB) (0 MB) +// { 0xC30C5144, 0xC30C9084 } // size 16196 (15 kB) (0 MB) +// { 0xC30CAE10, 0xC30CB788 } // size 2428 (2 kB) (0 MB) +// { 0xC30CC780, 0xC30CCFA4 } // size 2088 (2 kB) (0 MB) +// { 0xC30CDEC0, 0xC30CE6E4 } // size 2088 (2 kB) (0 MB) +// { 0xC30CF600, 0xC30D707C } // size 31360 (30 kB) (0 MB) +// { 0xC30D719C, 0xC30DC3FC } // size 21092 (20 kB) (0 MB) +// { 0xC30DC61C, 0xC318037C } // size 671076 (655 kB) (0 MB) +// { 0xC31804E0, 0xC31C037C } // size 261792 (255 kB) (0 MB) +// { 0xC31C07C4, 0xC321063C } // size 327292 (319 kB) (0 MB) +// { 0xC3227980, 0xC322AF34 } // size 13752 (13 kB) (0 MB) +// { 0xC322C600, 0xC3231D00 } // size 22276 (21 kB) (0 MB) +// { 0xC32327E4, 0xC3233060 } // size 2176 (2 kB) (0 MB) +// { 0xC3234080, 0xC324B340 } // size 94916 (92 kB) (0 MB) +// { 0xC324D8C0, 0xC328D880 } // size 262084 (255 kB) (0 MB) +// { 0xC329D234, 0xC32CA42C } // size 184828 (180 kB) (0 MB) +// { 0xC32CA434, 0xC32CDF68 } // size 15160 (14 kB) (0 MB) +// { 0xC32CE26C, 0xC32CF4FC } // size 4756 (4 kB) (0 MB) +// { 0xC32CF504, 0xC32D0790 } // size 4752 (4 kB) (0 MB) +// { 0xC32D34BC, 0xC32D4A3C } // size 5508 (5 kB) (0 MB) +// { 0xC32EB100, 0xC32EBC98 } // size 2972 (2 kB) (0 MB) +// { 0xC32ED180, 0xC32EFFC0 } // size 11844 (11 kB) (0 MB) +// { 0xC32F4540, 0xC32FA080 } // size 23364 (22 kB) (0 MB) +// { 0xC3302A6C, 0xC33045C0 } // size 7000 (6 kB) (0 MB) +// { 0xC331AE90, 0xC331C33C } // size 5296 (5 kB) (0 MB) +// { 0xC332B500, 0xC3340F88 } // size 88716 (86 kB) (0 MB) +// { 0xC334DB34, 0xC334EB40 } // size 4112 (4 kB) (0 MB) +// { 0xC3354284, 0xC3356354 } // size 8404 (8 kB) (0 MB) +// { 0xC33573C8, 0xC33583FC } // size 4152 (4 kB) (0 MB) +// { 0xC3358A80, 0xC335A484 } // size 6664 (6 kB) (0 MB) +// { 0xC335A4C0, 0xC35021FC } // size 1736000 (1695 kB) (1 MB) +// { 0xC350C1D4, 0xC39182CC } // size 4243708 (4144 kB) (4 MB) +// { 0xC3919AC4, 0xC39298C4 } // size 65028 (63 kB) (0 MB) +// { 0xC3929AC4, 0xC3939534 } // size 64116 (62 kB) (0 MB) +// { 0xC3939AC4, 0xC39498C4 } // size 65028 (63 kB) (0 MB) +// { 0xC3949AC0, 0xC394CFFC } // size 13632 (13 kB) (0 MB) +// { 0xC394EEB0, 0xC3954988 } // size 23260 (22 kB) (0 MB) +// { 0xC3955000, 0xC3955FFC } // size 4096 (4 kB) (0 MB) +// { 0xC395667C, 0xC395778C } // size 4372 (4 kB) (0 MB) +// { 0xC39577C0, 0xC3975C80 } // size 124100 (121 kB) (0 MB) +// { 0xC39769C8, 0xC398D320 } // size 92508 (90 kB) (0 MB) +// { 0xC398DAF8, 0xC399DC08 } // size 65812 (64 kB) (0 MB) +// { 0xC399DC78, 0xC39ABF80 } // size 58124 (56 kB) (0 MB) +// { 0xC39B1124, 0xC39C8200 } // size 94432 (92 kB) (0 MB) +// { 0xC39C966C, 0xC39CB580 } // size 7960 (7 kB) (0 MB) +// { 0xC39CC178, 0xC39D5580 } // size 37900 (37 kB) (0 MB) +// { 0xC39D5E20, 0xC39E5F34 } // size 65816 (64 kB) (0 MB) +// { 0xC39E5F84, 0xC39F6A80 } // size 68352 (66 kB) (0 MB) +// { 0xC39FBC54, 0xC3A14080 } // size 99376 (97 kB) (0 MB) +// { 0xC3A14094, 0xC3EBFFFC } // size 4898668 (4783 kB) (4 MB) +// { 0xC3F028E0, 0xC3F2477C } // size 138912 (135 kB) (0 MB) +// { 0xC3F37B10, 0xC3F5A73C } // size 142384 (139 kB) (0 MB) +// { 0xC3F69350, 0xC3F91DFC } // size 166576 (162 kB) (0 MB) +// { 0xC3F927DC, 0xC3FEE3BC } // size 375780 (366 kB) (0 MB) +// { 0xC3FF23B4, 0xC3FF643C } // size 16524 (16 kB) (0 MB) +// { 0xC3FF7274, 0xC3FF8000 } // size 3472 (3 kB) (0 MB) +// { 0xC3FFFFD4, 0xC8FFFFFC } // size 83886124 (81920 kB) (80 MB) + {0, 0} +}; + +static const memory_values_t mem_vals_532[] = +{ + // TODO: Check which of those areas are usable +// {0xB8000000 + 0x000DCC9C, 0xB8000000 + 0x00174F80}, // 608 kB +// {0xB8000000 + 0x00180B60, 0xB8000000 + 0x001C0A00}, // 255 kB +// {0xB8000000 + 0x001ECE9C, 0xB8000000 + 0x00208CC0}, // 111 kB +// {0xB8000000 + 0x00234180, 0xB8000000 + 0x0024B444}, // 92 kB +// {0xB8000000 + 0x0024D8C0, 0xB8000000 + 0x0028D884}, // 255 kB +// {0xB8000000 + 0x003A745C, 0xB8000000 + 0x004D2B68}, // 1197 kB +// {0xB8000000 + 0x004D77B0, 0xB8000000 + 0x00502200}, // 170 kB +// {0xB8000000 + 0x005B3A88, 0xB8000000 + 0x005C6870}, // 75 kB +// {0xB8000000 + 0x0061F3E4, 0xB8000000 + 0x00632B04}, // 77 kB +// {0xB8000000 + 0x00639790, 0xB8000000 + 0x00649BC4}, // 65 kB +// {0xB8000000 + 0x00691490, 0xB8000000 + 0x006B3CA4}, // 138 kB +// {0xB8000000 + 0x006D7BCC, 0xB8000000 + 0x006EEB84}, // 91 kB +// {0xB8000000 + 0x00704E44, 0xB8000000 + 0x0071E3C4}, // 101 kB +// {0xB8000000 + 0x0073B684, 0xB8000000 + 0x0074C184}, // 66 kB +// {0xB8000000 + 0x00751354, 0xB8000000 + 0x00769784}, // 97 kB +// {0xB8000000 + 0x008627DC, 0xB8000000 + 0x00872904}, // 64 kB +// {0xB8000000 + 0x008C1E98, 0xB8000000 + 0x008EB0A0}, // 164 kB +// {0xB8000000 + 0x008EEC30, 0xB8000000 + 0x00B06E98}, // 2144 kB +// {0xB8000000 + 0x00B06EC4, 0xB8000000 + 0x00B930C4}, // 560 kB +// {0xB8000000 + 0x00BA1868, 0xB8000000 + 0x00BC22A4}, // 130 kB +// {0xB8000000 + 0x00BC48F8, 0xB8000000 + 0x00BDEC84}, // 104 kB +// {0xB8000000 + 0x00BE3DC0, 0xB8000000 + 0x00C02284}, // 121 kB +// {0xB8000000 + 0x00C02FC8, 0xB8000000 + 0x00C19924}, // 90 kB +// {0xB8000000 + 0x00C2D35C, 0xB8000000 + 0x00C3DDC4}, // 66 kB +// {0xB8000000 + 0x00C48654, 0xB8000000 + 0x00C6E2E4}, // 151 kB +// {0xB8000000 + 0x00D04E04, 0xB8000000 + 0x00D36938}, // 198 kB +// {0xB8000000 + 0x00DC88AC, 0xB8000000 + 0x00E14288}, // 302 kB +// {0xB8000000 + 0x00E21ED4, 0xB8000000 + 0x00EC8298}, // 664 kB +// {0xB8000000 + 0x00EDDC7C, 0xB8000000 + 0x00F7C2A8}, // 633 kB +// {0xB8000000 + 0x00F89EF4, 0xB8000000 + 0x010302B8}, // 664 kB +// {0xB8000000 + 0x01030800, 0xB8000000 + 0x013F69A0}, // 3864 kB +// {0xB8000000 + 0x016CE000, 0xB8000000 + 0x016E0AA0}, // 74 kB +// {0xB8000000 + 0x0170200C, 0xB8000000 + 0x018B9C58}, // 1759 kB +// {0xB8000000 + 0x01F17658, 0xB8000000 + 0x01F6765C}, // 320 kB +// {0xB8000000 + 0x01F6779C, 0xB8000000 + 0x01FB77A0}, // 320 kB +// {0xB8000000 + 0x01FB78E0, 0xB8000000 + 0x020078E4}, // 320 kB +// {0xB8000000 + 0x02007A24, 0xB8000000 + 0x02057A28}, // 320 kB +// {0xB8000000 + 0x02057B68, 0xB8000000 + 0x021B957C}, // 1414 kB +// {0xB8000000 + 0x02891528, 0xB8000000 + 0x028C8A28}, // 221 kB +// {0xB8000000 + 0x02BBCC4C, 0xB8000000 + 0x02CB958C}, // 1010 kB +// {0xB8000000 + 0x0378D45C, 0xB8000000 + 0x03855464}, // 800 kB +// {0xB8000000 + 0x0387800C, 0xB8000000 + 0x03944938}, // 818 kB +// {0xB8000000 + 0x03944A08, 0xB8000000 + 0x03956E0C}, // 73 kB +// {0xB8000000 + 0x04A944A4, 0xB8000000 + 0x04ABAAC0}, // 153 kB +// {0xB8000000 + 0x04ADE370, 0xB8000000 + 0x0520EAB8}, // 7361 kB // ok +// {0xB8000000 + 0x053B966C, 0xB8000000 + 0x058943C4}, // 4971 kB // ok +// {0xB8000000 + 0x058AD3D8, 0xB8000000 + 0x06000000}, // 7499 kB +// {0xB8000000 + 0x0638D320, 0xB8000000 + 0x063B0280}, // 139 kB +// {0xB8000000 + 0x063C39E0, 0xB8000000 + 0x063E62C0}, // 138 kB +// {0xB8000000 + 0x063F52A0, 0xB8000000 + 0x06414A80}, // 125 kB +// {0xB8000000 + 0x06422810, 0xB8000000 + 0x0644B2C0}, // 162 kB +// {0xB8000000 + 0x064E48D0, 0xB8000000 + 0x06503EC0}, // 125 kB +// {0xB8000000 + 0x0650E360, 0xB8000000 + 0x06537080}, // 163 kB +// {0xB8000000 + 0x0653A460, 0xB8000000 + 0x0655C300}, // 135 kB +// {0xB8000000 + 0x0658AA40, 0xB8000000 + 0x065BC4C0}, // 198 kB // ok +// {0xB8000000 + 0x065E51A0, 0xB8000000 + 0x06608E80}, // 143 kB // ok +// {0xB8000000 + 0x06609ABC, 0xB8000000 + 0x07F82C00}, // 26084 kB // ok + +// {0xC0000000 + 0x000DCC9C, 0xC0000000 + 0x00180A00}, // 655 kB +// {0xC0000000 + 0x00180B60, 0xC0000000 + 0x001C0A00}, // 255 kB +// {0xC0000000 + 0x001F5EF0, 0xC0000000 + 0x00208CC0}, // 75 kB +// {0xC0000000 + 0x00234180, 0xC0000000 + 0x0024B444}, // 92 kB +// {0xC0000000 + 0x0024D8C0, 0xC0000000 + 0x0028D884}, // 255 kB +// {0xC0000000 + 0x003A745C, 0xC0000000 + 0x004D2B68}, // 1197 kB +// {0xC0000000 + 0x006D3334, 0xC0000000 + 0x00772204}, // 635 kB +// {0xC0000000 + 0x00789C60, 0xC0000000 + 0x007C6000}, // 240 kB +// {0xC0000000 + 0x00800000, 0xC0000000 + 0x01E20000}, // 22876 kB // ok + { 0xBE609ABC, 0xBFF82C00 }, // 26084 kB + { 0xB9030800, 0xB93F69A0 }, // 3864 kB + { 0xB88EEC30, 0xB8B06E98 }, // 2144 kB + { 0xBD3B966C, 0xBD8943C4 }, // 4971 kB + { 0xBCAE0370, 0xBD20EAB8 }, // 7361 kB + { 0xBD8AD3D8, 0xBE000000 }, // 7499 kB + + {0, 0} +}; // total : 66mB + 25mB + +static const memory_values_t mem_vals_540[] = +{ + { 0xBE609EFC, 0xBFF82BC0 }, // 26083 kB + { 0xBD8AD3D8, 0xBE000000 }, // 7499 kB + { 0xBCB56370, 0xBD1EF6B8 }, // 6756 kB + { 0xBD3B966C, 0xBD8943C4 }, // 4971 kB + { 0xB9030800, 0xB93F6A04 }, // 3864 kB + { 0xB88EEC30, 0xB8B06E98 }, // 2144 kB + { 0xB970200C, 0xB98B9C58 }, // 1759 kB + { 0xB8B06EC4, 0xB8B930C4 }, // 560 kB + + {0, 0} +}; + +//! retain container for our memory area table data +static unsigned char ucMemAreaTableBuffer[0xff]; + +s_mem_area * memoryGetAreaTable(void) +{ + return (s_mem_area *) (ucMemAreaTableBuffer); +} + +static inline void memoryAddArea(int start, int end, int cur_index) +{ + // Create and copy new memory area + s_mem_area * mem_area = memoryGetAreaTable(); + mem_area[cur_index].address = start; + mem_area[cur_index].size = end - start; + mem_area[cur_index].next = 0; + + // Fill pointer to this area in the previous area + if (cur_index > 0) + { + mem_area[cur_index - 1].next = &mem_area[cur_index]; + } +} + +/* Create memory areas arrays */ +void memoryInitAreaTable() +{ + u32 ApplicationMemoryEnd; + + asm volatile("lis %0, __CODE_END@h; ori %0, %0, __CODE_END@l" : "=r" (ApplicationMemoryEnd)); + + // This one seems to be available on every firmware and therefore its our code area but also our main RPX area behind our code + // 22876 kB - our application // ok + memoryAddArea(ApplicationMemoryEnd + 0xC0000000, 0xC1E20000, 0); + + const memory_values_t * mem_vals = NULL; + + switch(OS_FIRMWARE) + { + case 500: { + mem_vals = mem_vals_500; + break; + } + case 532: { + mem_vals = mem_vals_532; + break; + } + case 540: + case 550: { + mem_vals = mem_vals_540; + break; + } + default: + return; // no known values + } + + // Fill entries + int i = 0; + while (mem_vals[i].start_address) + { + memoryAddArea(mem_vals[i].start_address, mem_vals[i].end_address, i + 1); + i++; + } +} diff --git a/src/game/memory_area_table.h b/src/game/memory_area_table.h new file mode 100644 index 0000000..1c8af75 --- /dev/null +++ b/src/game/memory_area_table.h @@ -0,0 +1,40 @@ +/**************************************************************************** + * Copyright (C) 2015 Dimok + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + ****************************************************************************/ +#ifndef _MEMORY_AREA_TABLE_H_ +#define _MEMORY_AREA_TABLE_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +/* Struct used to organize empty memory areas */ +typedef struct _s_mem_area +{ + unsigned int address; + unsigned int size; + struct _s_mem_area* next; +} s_mem_area; + +void memoryInitAreaTable(); +s_mem_area * memoryGetAreaTable(void); + + +#ifdef __cplusplus +} +#endif + +#endif // _MEMORY_AREA_TABLE_H_ diff --git a/src/game/rpx_rpl_table.c b/src/game/rpx_rpl_table.c new file mode 100644 index 0000000..bf75620 --- /dev/null +++ b/src/game/rpx_rpl_table.c @@ -0,0 +1,210 @@ +#include +#include "rpx_rpl_table.h" +#include "kernel/kernel_functions.h" +#include "common/common.h" + +//! static container holding our retain data +static unsigned char ucRpxData[0xffff]; +static int iRpxRplCount = 0; + +void rpxRplTableInit(void) +{ + s_rpx_rpl *pRpxData = (s_rpx_rpl*)ucRpxData; + //! initialize the RPL/RPX table first entry to zero + 1 byte for name zero termination + //! just in case no RPL/RPX are found, though it wont boot then anyway + memset(pRpxData, 0, sizeof(s_rpx_rpl) + 1); + iRpxRplCount = 0; +} + +s_rpx_rpl * rpxRplTableAddEntry(const char *name, int offset, int size, int is_rpx, int entry_index, s_mem_area* area) +{ + // fill rpx/rpl entry + s_rpx_rpl * rpx_rpl_data = (s_rpx_rpl *)(ucRpxData); + // get to last entry + while(rpx_rpl_data->next) { + rpx_rpl_data = rpx_rpl_data->next; + } + + // setup next entry on the previous one (only if it is not the first entry) + if(entry_index > 0) { + rpx_rpl_data->next = (s_rpx_rpl *)( ((u32)rpx_rpl_data) + sizeof(s_rpx_rpl) + strlen(rpx_rpl_data->name) + 1 ); + rpx_rpl_data = rpx_rpl_data->next; + } + + // setup current entry + rpx_rpl_data->area = area; + rpx_rpl_data->size = size; + rpx_rpl_data->offset = offset; + rpx_rpl_data->is_rpx = is_rpx; + rpx_rpl_data->next = 0; + strcpy(rpx_rpl_data->name, name); + + iRpxRplCount++; + + return rpx_rpl_data; +} + +s_rpx_rpl* rpxRplTableGet(void) +{ + return (s_rpx_rpl*)ucRpxData; +} + +int rpxRplTableGetCount(void) +{ + return iRpxRplCount; +} + +s_mem_area *rpxRplTableGetNextFreeMemArea(u32 * mem_area_addr_start, u32 * mem_area_addr_end, u32 * mem_area_offset) +{ + s_mem_area * mem_area = memoryGetAreaTable(); + s_rpx_rpl *rpl_struct = rpxRplTableGet(); + while(rpl_struct != 0) + { + // check if this entry was loaded into memory + if(rpl_struct->size == 0) { + // see if we find entries behind this one that was pre-loaded + rpl_struct = rpl_struct->next; + // entry was not loaded into memory -> skip it + continue; + } + + // this entry has been loaded to memory, remember it's area + mem_area = rpl_struct->area; + + int rpl_size = rpl_struct->size; + int rpl_offset = rpl_struct->offset; + // find the end of the entry and switch between areas if needed + while(mem_area && (u32)(rpl_offset + rpl_size) >= mem_area->size) + { + rpl_size -= mem_area->size - rpl_offset; + rpl_offset = 0; + mem_area = mem_area->next; + } + + if(!mem_area) + return NULL; + + // set new start, end and memory area offset + *mem_area_addr_start = mem_area->address; + *mem_area_addr_end = mem_area->address + mem_area->size; + *mem_area_offset = rpl_offset + rpl_size; + + // see if we find entries behind this one that was pre-loaded + rpl_struct = rpl_struct->next; + } + return mem_area; +} + +int rpxRplCopyDataToMem(s_rpx_rpl *rpx_rpl_struct, u32 fileOffset, const u8 *data, u32 dataSize) +{ + s_mem_area *mem_area = rpx_rpl_struct->area; + u32 mem_area_addr_start = mem_area->address; + u32 mem_area_addr_end = mem_area_addr_start + mem_area->size; + u32 mem_area_offset = rpx_rpl_struct->offset; + + // add to offset + mem_area_offset += fileOffset; + + // skip position to the end of the fill + while ((mem_area_addr_start + mem_area_offset) >= mem_area_addr_end) // TODO: maybe >, not >= + { + // subtract what was in the offset left from last memory block + mem_area_offset = (mem_area_addr_start + mem_area_offset) - mem_area_addr_end; + mem_area = mem_area->next; + if(!mem_area) + return 0; + + mem_area_addr_start = mem_area->address; + mem_area_addr_end = mem_area_addr_start + mem_area->size; + } + + // copy to memory + u32 copiedBytes = 0; + while(copiedBytes < dataSize) + { + u32 blockSize = dataSize - copiedBytes; + u32 mem_area_addr_dest = mem_area_addr_start + mem_area_offset; + + if((mem_area_addr_dest + blockSize) > mem_area_addr_end) + blockSize = mem_area_addr_end - mem_area_addr_dest; + + if(blockSize == 0) + { + // Set next memory area + mem_area = mem_area->next; + if(!mem_area) + return 0; + + mem_area_addr_start = mem_area->address; + mem_area_addr_end = mem_area->address + mem_area->size; + mem_area_offset = 0; + continue; + } + + SC0x25_KernelCopyData(mem_area_addr_dest, (u32)&data[copiedBytes], blockSize); + mem_area_offset += blockSize; + copiedBytes += blockSize; + } + + return copiedBytes; +} + +int rpxRplCopyDataFromMem(s_rpx_rpl *rpx_rpl_struct, u32 fileOffset, u8 *data, u32 dataSize) +{ + s_mem_area *mem_area = rpx_rpl_struct->area; + u32 mem_area_addr_start = mem_area->address; + u32 mem_area_addr_end = mem_area_addr_start + mem_area->size; + u32 mem_area_offset = rpx_rpl_struct->offset; + + if(fileOffset > rpx_rpl_struct->size) + return 0; + + if((fileOffset + dataSize) > rpx_rpl_struct->size) + dataSize = rpx_rpl_struct->size - fileOffset; + + // add to offset + mem_area_offset += fileOffset; + + // skip position to the end of the fill + while ((mem_area_addr_start + mem_area_offset) >= mem_area_addr_end) // TODO: maybe >, not >= + { + // subtract what was in the offset left from last memory block + mem_area_offset = (mem_area_addr_start + mem_area_offset) - mem_area_addr_end; + mem_area = mem_area->next; + if(!mem_area) + return 0; + + mem_area_addr_start = mem_area->address; + mem_area_addr_end = mem_area_addr_start + mem_area->size; + } + + // copy to memory + u32 copiedBytes = 0; + while(copiedBytes < dataSize) + { + u32 blockSize = dataSize - copiedBytes; + u32 mem_area_addr_dest = mem_area_addr_start + mem_area_offset; + + if((mem_area_addr_dest + blockSize) > mem_area_addr_end) + blockSize = mem_area_addr_end - mem_area_addr_dest; + + if(blockSize == 0) + { + // Set next memory area + mem_area = mem_area->next; + if(!mem_area) + return 0; + + mem_area_addr_start = mem_area->address; + mem_area_addr_end = mem_area->address + mem_area->size; + mem_area_offset = 0; + continue; + } + + SC0x25_KernelCopyData((u32)&data[copiedBytes], mem_area_addr_dest, blockSize); + mem_area_offset += blockSize; + copiedBytes += blockSize; + } + + return copiedBytes; +} diff --git a/src/game/rpx_rpl_table.h b/src/game/rpx_rpl_table.h new file mode 100644 index 0000000..b114b70 --- /dev/null +++ b/src/game/rpx_rpl_table.h @@ -0,0 +1,37 @@ +#ifndef __RPX_ARRAY_H_ +#define __RPX_ARRAY_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include "common/common.h" +#include "memory_area_table.h" + +/* Struct used to organize rpx/rpl data in memory */ +typedef struct _s_rpx_rpl +{ + struct _s_rpx_rpl* next; + s_mem_area* area; + unsigned int offset; + unsigned int size; + unsigned char is_rpx; + char name[0]; +} s_rpx_rpl; + +void rpxRplTableInit(void); +s_rpx_rpl* rpxRplTableAddEntry(const char *name, int offset, int size, int is_rpx, int entry_index, s_mem_area* area); +s_rpx_rpl* rpxRplTableGet(void); +int rpxRplTableGetCount(void); + +s_mem_area *rpxRplTableGetNextFreeMemArea(u32 * mem_area_addr_start, u32 * mem_area_addr_end, u32 * mem_area_offset); +int rpxRplCopyDataToMem(s_rpx_rpl *rpx_rpl_struct, u32 fileOffset, const u8 *data, u32 dataSize); +int rpxRplCopyDataFromMem(s_rpx_rpl *rpx_rpl_struct, u32 fileOffset, u8 *data, u32 dataSize); + +#ifdef __cplusplus +} +#endif + + +#endif diff --git a/src/kernel/kernel_functions.c b/src/kernel/kernel_functions.c new file mode 100644 index 0000000..d143b28 --- /dev/null +++ b/src/kernel/kernel_functions.c @@ -0,0 +1,81 @@ +#include +#include "common/common.h" +#include "common/kernel_defs.h" +#include "kernel/kernel_functions.h" +#include "kernel/syscalls.h" +#include "discdumper.h" + +/* our retain data */ +ReducedCosAppXmlInfo cosAppXmlInfoStruct __attribute__((section(".data"))); +/* + * This function is a kernel hook function. It is called directly from kernel code at position 0xFFF18558. + */ +void my_PrepareTitle(CosAppXmlInfo *xmlKernelInfo) +{ + /** + * DBAT for access to our data region is setup at this point for the 0xC0000000 area. + */ + + //! Copy all data from the XML info + strncpy(cosAppXmlInfoStruct.rpx_name, xmlKernelInfo->rpx_name, FS_MAX_ENTNAME_SIZE); + + cosAppXmlInfoStruct.version_cos_xml = xmlKernelInfo->version_cos_xml; + cosAppXmlInfoStruct.os_version = xmlKernelInfo->os_version; + cosAppXmlInfoStruct.title_id = xmlKernelInfo->title_id; + cosAppXmlInfoStruct.app_type = xmlKernelInfo->app_type; + cosAppXmlInfoStruct.cmdFlags = xmlKernelInfo->cmdFlags; + cosAppXmlInfoStruct.max_size = xmlKernelInfo->max_size; + cosAppXmlInfoStruct.avail_size = xmlKernelInfo->avail_size; + cosAppXmlInfoStruct.codegen_size = xmlKernelInfo->codegen_size; + cosAppXmlInfoStruct.codegen_core = xmlKernelInfo->codegen_core; + cosAppXmlInfoStruct.max_codesize = xmlKernelInfo->max_codesize; + cosAppXmlInfoStruct.overlay_arena = xmlKernelInfo->overlay_arena; + cosAppXmlInfoStruct.default_stack0_size = xmlKernelInfo->default_stack0_size; + cosAppXmlInfoStruct.default_stack1_size = xmlKernelInfo->default_stack1_size; + cosAppXmlInfoStruct.default_stack2_size = xmlKernelInfo->default_stack2_size; + cosAppXmlInfoStruct.default_redzone0_size = xmlKernelInfo->default_redzone0_size; + cosAppXmlInfoStruct.default_redzone1_size = xmlKernelInfo->default_redzone1_size; + cosAppXmlInfoStruct.default_redzone2_size = xmlKernelInfo->default_redzone2_size; + cosAppXmlInfoStruct.exception_stack0_size = xmlKernelInfo->exception_stack0_size; + cosAppXmlInfoStruct.exception_stack1_size = xmlKernelInfo->exception_stack1_size; + cosAppXmlInfoStruct.exception_stack2_size = xmlKernelInfo->exception_stack2_size; + cosAppXmlInfoStruct.sdk_version = xmlKernelInfo->sdk_version; + cosAppXmlInfoStruct.title_version = xmlKernelInfo->title_version; + + // on title switch reset the dumper + ResetDumper(); +} + +void SetupKernelCallback(void) +{ + KernelSetupSyscalls(); +} + +void KernelSetDBATs(bat_table_t * table) +{ + SC0x36_KernelReadDBATs(table); + bat_table_t bat_table_copy = *table; + + // try to use a free slot + int iUse; + for(iUse = 0; iUse < 7; iUse++) + { + // skip position 5 as it is our main DBAT for our code data + if(iUse == 5) + continue; + + if(bat_table_copy.bat[iUse].h == 0 || bat_table_copy.bat[iUse].l == 0) + { + break; + } + } + + bat_table_copy.bat[iUse].h = 0xC0001FFF; + bat_table_copy.bat[iUse].l = 0x30000012; + SC0x37_KernelWriteDBATs(&bat_table_copy); +} + +void KernelRestoreDBATs(bat_table_t * table) +{ + SC0x37_KernelWriteDBATs(table); +} diff --git a/src/kernel/kernel_functions.h b/src/kernel/kernel_functions.h new file mode 100644 index 0000000..62df739 --- /dev/null +++ b/src/kernel/kernel_functions.h @@ -0,0 +1,22 @@ +#ifndef __KERNEL_FUNCTIONS_H_ +#define __KERNEL_FUNCTIONS_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include "common/kernel_defs.h" +#include "syscalls.h" + +extern ReducedCosAppXmlInfo cosAppXmlInfoStruct; + +void SetupKernelCallback(void); + +void KernelSetDBATs(bat_table_t * table); +void KernelRestoreDBATs(bat_table_t * table); + +#ifdef __cplusplus +} +#endif + +#endif // __KERNEL_FUNCTIONS_H_ diff --git a/src/kernel/kernel_hooks.S b/src/kernel/kernel_hooks.S new file mode 100644 index 0000000..e2ed3d5 --- /dev/null +++ b/src/kernel/kernel_hooks.S @@ -0,0 +1,135 @@ +# This stuff may need a change in different kernel versions +# This is only needed when launched directly through browser and not SD card. + +.section ".kernel_code" + .globl SaveAndResetDataBATs_And_SRs_hook +SaveAndResetDataBATs_And_SRs_hook: + # setup CTR to the position we need to return to + mflr r5 + mtctr r5 + # set link register to its original value + mtlr r7 + # setup us a nice DBAT for our code data with same region as our code + mfspr r5, 560 + mtspr 570, r5 + mfspr r5, 561 + mtspr 571, r5 + # restore the original kernel instructions that we replaced + lwz r5, 0x34(r3) + lwz r6, 0x38(r3) + lwz r7, 0x3C(r3) + lwz r8, 0x40(r3) + lwz r9, 0x44(r3) + lwz r10, 0x48(r3) + lwz r11, 0x4C(r3) + lwz r3, 0x50(r3) + isync + mtsr 7, r5 + # jump back to the position in kernel after our patch (from LR) + bctr + +.extern my_PrepareTitle + .globl my_PrepareTitle_hook +my_PrepareTitle_hook: + # store all registers on stack to avoid issues with the call to C functions + stwu r1, -0x90(r1) + # registers for our own usage + # only need r31 and rest is from tests before, just leaving it for later tests + stw r28, 0x20(r1) + stw r29, 0x24(r1) + stw r30, 0x28(r1) + stw r31, 0x2C(r1) + + stw r3, 0x30(r1) + stw r4, 0x34(r1) + stw r5, 0x38(r1) + stw r6, 0x3C(r1) + stw r7, 0x40(r1) + stw r8, 0x44(r1) + stw r9, 0x48(r1) + stw r10, 0x4C(r1) + stw r11, 0x50(r1) + stw r12, 0x54(r1) + stw r13, 0x58(r1) + stw r14, 0x5C(r1) + stw r15, 0x60(r1) + stw r16, 0x64(r1) + stw r17, 0x68(r1) + stw r18, 0x6C(r1) + stw r19, 0x70(r1) + stw r20, 0x74(r1) + stw r21, 0x78(r1) + stw r22, 0x7C(r1) + + # save original DBAT registers + mfdbatu r28, 0 + mfdbatl r29, 0 + + # setup access to our data memory range + lis r3, 0xC000 + ori r3, r3, 0x1FFF + mtdbatu 0, r3 + lis r3, 0x3000 + ori r3, r3, 0x0012 + mtdbatl 0, r3 + + # memory barrier + eieio + isync + + # save the LR from where we came + mflr r31 + + # the cos.xml/app.xml structure is at the location 0x68 of r11 + # there are actually many places that can be hooked for it + # e.g. 0xFFF16130 and r27 points to this structure + addi r3, r11, 0x68 + + bl my_PrepareTitle + + # restore original DBAT registers + mtdbatu 0, r28 + mtdbatl 0, r29 + + # memory barrier + eieio + isync + + # setup LR to jump back to kernel code + mtlr r31 + + # restore all original values of registers from stack + lwz r28, 0x20(r1) + lwz r29, 0x24(r1) + lwz r30, 0x28(r1) + lwz r31, 0x2C(r1) + + lwz r3, 0x30(r1) + lwz r4, 0x34(r1) + lwz r5, 0x38(r1) + lwz r6, 0x3C(r1) + lwz r7, 0x40(r1) + lwz r8, 0x44(r1) + lwz r9, 0x48(r1) + lwz r10, 0x4C(r1) + lwz r11, 0x50(r1) + lwz r12, 0x54(r1) + lwz r13, 0x58(r1) + lwz r14, 0x5C(r1) + lwz r15, 0x60(r1) + lwz r16, 0x64(r1) + lwz r17, 0x68(r1) + lwz r18, 0x6C(r1) + lwz r19, 0x70(r1) + lwz r20, 0x74(r1) + lwz r21, 0x78(r1) + lwz r22, 0x7C(r1) + + # restore the stack + addi r1, r1, 0x90 + + # restore original instruction that we replaced in the kernel + clrlwi r7, r12, 0 + + # jump back + blr diff --git a/src/kernel/syscalls.c b/src/kernel/syscalls.c new file mode 100644 index 0000000..7bce2b1 --- /dev/null +++ b/src/kernel/syscalls.c @@ -0,0 +1,208 @@ +#include "common/os_defs.h" +#include "common/kernel_defs.h" +#include "common/common.h" +#include "dynamic_libs/os_functions.h" +#include "utils/utils.h" +#include "syscalls.h" + +extern void my_PrepareTitle_hook(void); + +static unsigned int origPrepareTitleInstr __attribute__((section(".data"))) = 0; + +static void KernelCopyData(unsigned int addr, unsigned int src, unsigned int len) +{ + /* + * Setup a DBAT access for our 0xC0800000 area and our 0xBC000000 area which hold our variables like GAME_LAUNCHED and our BSS/rodata section + */ + register int dbatu0, dbatl0, dbatu1, dbatl1; + // save the original DBAT value + asm volatile("mfdbatu %0, 0" : "=r" (dbatu0)); + asm volatile("mfdbatl %0, 0" : "=r" (dbatl0)); + asm volatile("mfdbatu %0, 1" : "=r" (dbatu1)); + asm volatile("mfdbatl %0, 1" : "=r" (dbatl1)); + + // write our own DBATs into the array + if( ((addr & 0xFFF00000) == 0xFFF00000) || ((src & 0xFFF00000) == 0xFFF00000) ) + { + // setup kernel code access + unsigned int dbatu = 0; + unsigned int dbatl = 0; + + if((src & 0xFFF00000) == 0xFFF00000) { + dbatu = (src & 0xFFF00000) | 0x02; + dbatl = (src & 0xFFF00000) | 0x32; + } + else { + dbatu = (addr & 0xFFF00000) | 0x02; + dbatl = (addr & 0xFFF00000) | 0x32; + } + + if( ((addr & 0xFFF00000) != (dbatu0 & 0xFFF00000)) && ((src & 0xFFF00000) != (dbatu0 & 0xFFF00000)) ) + { + asm volatile("mtdbatu 0, %0" : : "r" (dbatu)); + asm volatile("mtdbatl 0, %0" : : "r" (dbatl)); + } + else + { + asm volatile("mtdbatu 1, %0" : : "r" (dbatu)); + asm volatile("mtdbatl 1, %0" : : "r" (dbatl)); + } + } + else + { + asm volatile("mtdbatu 0, %0" : : "r" (0xC0001FFF)); + asm volatile("mtdbatl 0, %0" : : "r" (0x30000012)); + asm volatile("mtdbatu 1, %0" : : "r" (0xB0801FFF)); + asm volatile("mtdbatl 1, %0" : : "r" (0x20800012)); + } + asm volatile("eieio; isync"); + + + unsigned char *src_p = (unsigned char*)src; + unsigned char *dst_p = (unsigned char*)addr; + + unsigned int i; + for(i = 0; i < len; i++) + { + dst_p[i] = src_p[i]; + } + + /* + * Restore original DBAT value + */ + asm volatile("mtdbatu 0, %0" : : "r" (dbatu0)); + asm volatile("mtdbatl 0, %0" : : "r" (dbatl0)); + asm volatile("mtdbatu 1, %0" : : "r" (dbatu1)); + asm volatile("mtdbatl 1, %0" : : "r" (dbatl1)); + asm volatile("eieio; isync"); +} + +static void KernelReadDBATs(bat_table_t * table) +{ + u32 i = 0; + + asm volatile("eieio; isync"); + + asm volatile("mfspr %0, 536" : "=r" (table->bat[i].h)); + asm volatile("mfspr %0, 537" : "=r" (table->bat[i].l)); + i++; + asm volatile("mfspr %0, 538" : "=r" (table->bat[i].h)); + asm volatile("mfspr %0, 539" : "=r" (table->bat[i].l)); + i++; + asm volatile("mfspr %0, 540" : "=r" (table->bat[i].h)); + asm volatile("mfspr %0, 541" : "=r" (table->bat[i].l)); + i++; + asm volatile("mfspr %0, 542" : "=r" (table->bat[i].h)); + asm volatile("mfspr %0, 543" : "=r" (table->bat[i].l)); + i++; + + asm volatile("mfspr %0, 568" : "=r" (table->bat[i].h)); + asm volatile("mfspr %0, 569" : "=r" (table->bat[i].l)); + i++; + asm volatile("mfspr %0, 570" : "=r" (table->bat[i].h)); + asm volatile("mfspr %0, 571" : "=r" (table->bat[i].l)); + i++; + asm volatile("mfspr %0, 572" : "=r" (table->bat[i].h)); + asm volatile("mfspr %0, 573" : "=r" (table->bat[i].l)); + i++; + asm volatile("mfspr %0, 574" : "=r" (table->bat[i].h)); + asm volatile("mfspr %0, 575" : "=r" (table->bat[i].l)); +} + +static void KernelWriteDBATs(bat_table_t * table) +{ + u32 i = 0; + + asm volatile("eieio; isync"); + + asm volatile("mtspr 536, %0" : : "r" (table->bat[i].h)); + asm volatile("mtspr 537, %0" : : "r" (table->bat[i].l)); + i++; + asm volatile("mtspr 538, %0" : : "r" (table->bat[i].h)); + asm volatile("mtspr 539, %0" : : "r" (table->bat[i].l)); + i++; + asm volatile("mtspr 540, %0" : : "r" (table->bat[i].h)); + asm volatile("mtspr 541, %0" : : "r" (table->bat[i].l)); + i++; + asm volatile("mtspr 542, %0" : : "r" (table->bat[i].h)); + asm volatile("mtspr 543, %0" : : "r" (table->bat[i].l)); + i++; + + asm volatile("mtspr 568, %0" : : "r" (table->bat[i].h)); + asm volatile("mtspr 569, %0" : : "r" (table->bat[i].l)); + i++; + asm volatile("mtspr 570, %0" : : "r" (table->bat[i].h)); + asm volatile("mtspr 571, %0" : : "r" (table->bat[i].l)); + i++; + asm volatile("mtspr 572, %0" : : "r" (table->bat[i].h)); + asm volatile("mtspr 573, %0" : : "r" (table->bat[i].l)); + i++; + asm volatile("mtspr 574, %0" : : "r" (table->bat[i].h)); + asm volatile("mtspr 575, %0" : : "r" (table->bat[i].l)); + + asm volatile("eieio; isync"); +} + +/* Write a 32-bit word with kernel permissions */ +static void __attribute__ ((noinline)) kern_write(void *addr, uint32_t value) +{ + asm volatile ( + "li 3,1\n" + "li 4,0\n" + "mr 5,%1\n" + "li 6,0\n" + "li 7,0\n" + "lis 8,1\n" + "mr 9,%0\n" + "mr %1,1\n" + "li 0,0x3500\n" + "sc\n" + "nop\n" + "mr 1,%1\n" + : + : "r"(addr), "r"(value) + : "memory", "ctr", "lr", "0", "3", "4", "5", "6", "7", "8", "9", "10", + "11", "12" + ); +} + +void KernelSetupSyscalls(void) +{ + //! assign 1 so that this variable gets into the retained .data section + static uint8_t ucSyscallsSetupRequired = 1; + if(!ucSyscallsSetupRequired) + return; + + ucSyscallsSetupRequired = 0; + + kern_write((void*)(OS_SPECIFICS->addr_KernSyscallTbl1 + (0x36 * 4)), (unsigned int)KernelReadDBATs); + kern_write((void*)(OS_SPECIFICS->addr_KernSyscallTbl2 + (0x36 * 4)), (unsigned int)KernelReadDBATs); + kern_write((void*)(OS_SPECIFICS->addr_KernSyscallTbl3 + (0x36 * 4)), (unsigned int)KernelReadDBATs); + kern_write((void*)(OS_SPECIFICS->addr_KernSyscallTbl4 + (0x36 * 4)), (unsigned int)KernelReadDBATs); + kern_write((void*)(OS_SPECIFICS->addr_KernSyscallTbl5 + (0x36 * 4)), (unsigned int)KernelReadDBATs); + + kern_write((void*)(OS_SPECIFICS->addr_KernSyscallTbl1 + (0x37 * 4)), (unsigned int)KernelWriteDBATs); + kern_write((void*)(OS_SPECIFICS->addr_KernSyscallTbl2 + (0x37 * 4)), (unsigned int)KernelWriteDBATs); + kern_write((void*)(OS_SPECIFICS->addr_KernSyscallTbl3 + (0x37 * 4)), (unsigned int)KernelWriteDBATs); + kern_write((void*)(OS_SPECIFICS->addr_KernSyscallTbl4 + (0x37 * 4)), (unsigned int)KernelWriteDBATs); + kern_write((void*)(OS_SPECIFICS->addr_KernSyscallTbl5 + (0x37 * 4)), (unsigned int)KernelWriteDBATs); + + kern_write((void*)(OS_SPECIFICS->addr_KernSyscallTbl1 + (0x25 * 4)), (unsigned int)KernelCopyData); + kern_write((void*)(OS_SPECIFICS->addr_KernSyscallTbl2 + (0x25 * 4)), (unsigned int)KernelCopyData); + kern_write((void*)(OS_SPECIFICS->addr_KernSyscallTbl3 + (0x25 * 4)), (unsigned int)KernelCopyData); + kern_write((void*)(OS_SPECIFICS->addr_KernSyscallTbl4 + (0x25 * 4)), (unsigned int)KernelCopyData); + kern_write((void*)(OS_SPECIFICS->addr_KernSyscallTbl5 + (0x25 * 4)), (unsigned int)KernelCopyData); + + //! write our hook to the + u32 addr_my_PrepareTitle_hook = ((u32)my_PrepareTitle_hook) | 0x48000003; + + SC0x25_KernelCopyData((u32)&origPrepareTitleInstr, (u32)addr_PrepareTitle_hook, 4); + SC0x25_KernelCopyData((u32)addr_PrepareTitle_hook, (u32)&addr_my_PrepareTitle_hook, 4); +} + + +void KernelRestoreInstructions(void) +{ + if(origPrepareTitleInstr != 0) + SC0x25_KernelCopyData((u32)addr_PrepareTitle_hook, (u32)&origPrepareTitleInstr, 4); +} diff --git a/src/kernel/syscalls.h b/src/kernel/syscalls.h new file mode 100644 index 0000000..e5a9dac --- /dev/null +++ b/src/kernel/syscalls.h @@ -0,0 +1,23 @@ +#ifndef __SYSCALLS_H_ +#define __SYSCALLS_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include "common/kernel_defs.h" + +void KernelSetupSyscalls(void); +void KernelRestoreInstructions(void); + +void SC0x25_KernelCopyData(unsigned int addr, unsigned int src, unsigned int len); +void SC0x36_KernelReadDBATs(bat_table_t * table); +void SC0x37_KernelWriteDBATs(bat_table_t * table); + + +#ifdef __cplusplus +} +#endif + +#endif // __KERNEL_FUNCTIONS_H_ diff --git a/src/kernel/syscalls_asm.S b/src/kernel/syscalls_asm.S new file mode 100644 index 0000000..99e2c82 --- /dev/null +++ b/src/kernel/syscalls_asm.S @@ -0,0 +1,19 @@ +# Syscalls for kernel that we use + + .globl SC0x36_KernelReadDBATs +SC0x36_KernelReadDBATs: + li r0, 0x3600 + sc + blr + + .globl SC0x37_KernelWriteDBATs +SC0x37_KernelWriteDBATs: + li r0, 0x3700 + sc + blr + + .globl SC0x25_KernelCopyData +SC0x25_KernelCopyData: + li r0, 0x2500 + sc + blr diff --git a/src/link.ld b/src/link.ld new file mode 100644 index 0000000..2f20681 --- /dev/null +++ b/src/link.ld @@ -0,0 +1,43 @@ +OUTPUT(ddd.elf); + +/* Tell linker where our application entry is so the garbage collect can work correct */ +ENTRY(__entry_menu); + +SECTIONS { + . = 0x00802000; + .text : { + *(.kernel_code*); + *(.text*); + /* Tell linker to not garbage collect this section as it is not referenced anywhere */ + KEEP(*(.kernel_code*)); + } + .rodata : { + *(.rodata*); + } + .data : { + *(.data*); + + __sdata_start = .; + *(.sdata*); + __sdata_end = .; + + __sdata2_start = .; + *(.sdata2*); + __sdata2_end = .; + } + .bss : { + __bss_start = .; + *(.bss*); + *(.sbss*); + *(COMMON); + __bss_end = .; + } + __CODE_END = .; + + /DISCARD/ : { + *(*); + } +} + +/******************************************************** FS ********************************************************/ +/* coreinit.rpl difference in addresses 0xFE3C00 */ diff --git a/src/main.c b/src/main.c new file mode 100644 index 0000000..e668085 --- /dev/null +++ b/src/main.c @@ -0,0 +1,213 @@ +#include +#include +#include +#include +#include +#include "dynamic_libs/os_functions.h" +#include "dynamic_libs/fs_functions.h" +#include "dynamic_libs/aoc_functions.h" +#include "dynamic_libs/gx2_functions.h" +#include "dynamic_libs/sys_functions.h" +#include "dynamic_libs/vpad_functions.h" +#include "dynamic_libs/padscore_functions.h" +#include "dynamic_libs/socket_functions.h" +#include "dynamic_libs/ax_functions.h" +#include "system/memory.h" +#include "utils/logger.h" +#include "common/common.h" +#include "game/rpx_rpl_table.h" +#include "game/memory_area_table.h" +#include "discdumper.h" +#include "patcher/function_hooks.h" +#include "kernel/kernel_functions.h" + +typedef union u_serv_ip +{ + uint8_t digit[4]; + uint32_t full; +} u_serv_ip; + +#define PRINT_TEXT2(x, y, ...) { snprintf(msg, 80, __VA_ARGS__); OSScreenPutFontEx(0, x, y, msg); OSScreenPutFontEx(1, x, y, msg); } + +/* Entry point */ +int Menu_Main(void) +{ + //!******************************************************************* + //! Initialize function pointers * + //!******************************************************************* + //! do OS (for acquire) and sockets first so we got logging + InitOSFunctionPointers(); + InitSocketFunctionPointers(); + InitFSFunctionPointers(); + InitVPadFunctionPointers(); + InitSysFunctionPointers(); + InitAocFunctionPointers(); + + log_init("192.168.0.181"); + log_deinit(); + log_init("192.168.0.181"); + log_printf("Started %s\n", cosAppXmlInfoStruct.rpx_name); + + if(strcasecmp("men.rpx", cosAppXmlInfoStruct.rpx_name) == 0) + { + return EXIT_RELAUNCH_ON_LOAD; + } + else if(strlen(cosAppXmlInfoStruct.rpx_name) > 0 && strcasecmp("ffl_app.rpx", cosAppXmlInfoStruct.rpx_name) != 0) + { + StartDumper(); + return EXIT_RELAUNCH_ON_LOAD; + } + + // initialize memory tables once on start + memoryInitAreaTable(); + rpxRplTableInit(); + SetupKernelCallback(); + PatchMethodHooks(); + + memoryInitialize(); + + VPADInit(); + + // Prepare screen + int screen_buf0_size = 0; + int screen_buf1_size = 0; + + // Init screen and screen buffers + OSScreenInit(); + screen_buf0_size = OSScreenGetBufferSizeEx(0); + screen_buf1_size = OSScreenGetBufferSizeEx(1); + + unsigned char *screenBuffer = MEM1_alloc(screen_buf0_size + screen_buf1_size, 0x40); + + OSScreenSetBufferEx(0, screenBuffer); + OSScreenSetBufferEx(1, (screenBuffer + screen_buf0_size)); + + OSScreenEnableEx(0, 1); + OSScreenEnableEx(1, 1); + + char msg[80]; + uint8_t sel_ip = 3; + int launchMethod = 0; + int update_screen = 1; + int vpadError = -1; + VPADData vpad_data; + u_serv_ip ip; + ip.full = GetServerIp(); + int delay = 0; + + while (1) + { + // Read vpad + VPADRead(0, &vpad_data, 1, &vpadError); + + if(update_screen) + { + OSScreenClearBufferEx(0, 0); + OSScreenClearBufferEx(1, 0); + + // Print message + PRINT_TEXT2(14, 1, "-- Saviine v1.1 by Maschell --"); + PRINT_TEXT2(0, 5, "1. Setup IP address of server application."); + + // Print ip digit selector + uint8_t x_shift = 17 + 4 * sel_ip; + PRINT_TEXT2(x_shift, 6, "vvv"); + + PRINT_TEXT2(0, 7, " Server IP: %3d.%3d.%3d.%3d", ip.digit[0], ip.digit[1], ip.digit[2], ip.digit[3]); + + PRINT_TEXT2(0, 10, "2. Press A to install Saviine and try to launch disc."); + PRINT_TEXT2(0, 11, " or Press X to install Saviine and return to system menu."); + + PRINT_TEXT2(0, 13, "3. Start the title to be dumped."); + + PRINT_TEXT2(0, 17, "Press home button to exit ..."); + + + OSScreenFlipBuffersEx(0); + OSScreenFlipBuffersEx(1); + } + + u32 pressedBtns = vpad_data.btns_d | vpad_data.btns_h; + + // Check for buttons + // Home Button + if (pressedBtns & VPAD_BUTTON_HOME) { + launchMethod = 0; + break; + } + // A Button + if (pressedBtns & VPAD_BUTTON_A) { + SetServerIp(ip.full); + launchMethod = 1; + break; + } + // A Button + if (pressedBtns & VPAD_BUTTON_X) { + SetServerIp(ip.full); + launchMethod = 2; + break; + } + // Left/Right Buttons + if (vpad_data.btns_d & VPAD_BUTTON_LEFT ) + { + if(sel_ip == 0) + sel_ip = 3; + else + --sel_ip; + } + + if (vpad_data.btns_d & VPAD_BUTTON_RIGHT) + { + sel_ip = ((sel_ip + 1) % 4); + } + + // Up/Down Buttons + if (pressedBtns & VPAD_BUTTON_UP) + { + if(--delay <= 0) { + ip.digit[sel_ip]++; + delay = (vpad_data.btns_d & VPAD_BUTTON_UP) ? 6 : 0; + } + } + else if (pressedBtns & VPAD_BUTTON_DOWN) + { + if(--delay <= 0) { + ip.digit[sel_ip]--; + delay = (vpad_data.btns_d & VPAD_BUTTON_DOWN) ? 6 : 0; + } + } + else { + delay = 0; + } + + // Button pressed ? + update_screen = (pressedBtns & (VPAD_BUTTON_LEFT | VPAD_BUTTON_RIGHT | VPAD_BUTTON_UP | VPAD_BUTTON_DOWN)) ? 1 : 0; + usleep(20000); + } + + MEM1_free(screenBuffer); + screenBuffer = NULL; + + log_deinit(); + + memoryRelease(); + + if(launchMethod == 0) + { + RestoreInstructions(); + return EXIT_SUCCESS; + } + else if(launchMethod == 1) + { + char buf_vol_odd[20]; + snprintf(buf_vol_odd, sizeof(buf_vol_odd), "%s", "/vol/storage_odd03"); + _SYSLaunchTitleByPathFromLauncher(buf_vol_odd, 18, 0); + } + else + { + SYSLaunchMenu(); + } + + return EXIT_RELAUNCH_ON_LOAD; +} + diff --git a/src/main.h b/src/main.h new file mode 100644 index 0000000..0147292 --- /dev/null +++ b/src/main.h @@ -0,0 +1,19 @@ +#ifndef _MAIN_H_ +#define _MAIN_H_ + +#include "common/types.h" +#include "dynamic_libs/os_functions.h" + +/* Main */ +#ifdef __cplusplus +extern "C" { +#endif + +//! C wrapper for our C++ functions +int Menu_Main(void); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/patcher/function_hooks.c b/src/patcher/function_hooks.c new file mode 100644 index 0000000..6e0d90a --- /dev/null +++ b/src/patcher/function_hooks.c @@ -0,0 +1,134 @@ +#include +#include +#include +#include "common/common.h" +#include "common/fs_defs.h" +#include "common/loader_defs.h" +#include "game/rpx_rpl_table.h" +#include "dynamic_libs/fs_functions.h" +#include "dynamic_libs/os_functions.h" +#include "kernel/kernel_functions.h" +#include "function_hooks.h" +#include "discdumper.h" + +#define LIB_CODE_RW_BASE_OFFSET 0xC1000000 +#define CODE_RW_BASE_OFFSET 0x00000000 + +#define USE_EXTRA_LOG_FUNCTIONS 0 + +#define DECL(res, name, ...) \ + res (* real_ ## name)(__VA_ARGS__) __attribute__((section(".data"))); \ + res my_ ## name(__VA_ARGS__) + +/* ***************************************************************************** + * Creates function pointer array + * ****************************************************************************/ +#define MAKE_MAGIC(x, lib) { (unsigned int) my_ ## x, (unsigned int) &real_ ## x, lib, # x } + +static const struct hooks_magic_t { + const unsigned int replaceAddr; + const unsigned int replaceCall; + const unsigned int library; + const char functionName[30]; +} method_hooks[] = { + // LOADER function + //MAKE_MAGIC(LiWaitOneChunk, LIB_LOADER), + +}; + +//! buffer to store our 2 instructions needed for our replacements +//! the code will be placed in the address of that buffer - CODE_RW_BASE_OFFSET +//! avoid this buffer to be placed in BSS and reset on start up +volatile unsigned int fs_method_calls[sizeof(method_hooks) / sizeof(struct hooks_magic_t) * 2] __attribute__((section(".data"))); + +void PatchMethodHooks(void) +{ + restore_instructions_t * restore = (restore_instructions_t *)(RESTORE_INSTR_ADDR); + //! check if it is already patched + if(restore->magic == RESTORE_INSTR_MAGIC) + return; + + restore->magic = RESTORE_INSTR_MAGIC; + restore->instr_count = 0; + + bat_table_t table; + KernelSetDBATs(&table); + + /* Patch branches to it. */ + volatile unsigned int *space = &fs_method_calls[0]; + + int method_hooks_count = sizeof(method_hooks) / sizeof(struct hooks_magic_t); + + for(int i = 0; i < method_hooks_count; i++) + { + unsigned int repl_addr = (unsigned int)method_hooks[i].replaceAddr; + unsigned int call_addr = (unsigned int)method_hooks[i].replaceCall; + + unsigned int real_addr = 0; + + if(strcmp(method_hooks[i].functionName, "OSDynLoad_Acquire") == 0) + { + memcpy(&real_addr, &OSDynLoad_Acquire, 4); + } + else if(strcmp(method_hooks[i].functionName, "LiWaitOneChunk") == 0) + { + memcpy(&real_addr, &addr_LiWaitOneChunk, 4); + } + else + { + OSDynLoad_FindExport(coreinit_handle, 0, method_hooks[i].functionName, &real_addr); + } + + // fill the restore instruction section + restore->data[restore->instr_count].addr = real_addr; + restore->data[restore->instr_count].instr = *(volatile unsigned int *)(LIB_CODE_RW_BASE_OFFSET + real_addr); + restore->instr_count++; + + // set pointer to the real function + *(volatile unsigned int *)(call_addr) = (unsigned int)(space) - CODE_RW_BASE_OFFSET; + DCFlushRange((void*)(call_addr), 4); + + // fill the instruction of the real function + *space = *(volatile unsigned int*)(LIB_CODE_RW_BASE_OFFSET + real_addr); + space++; + + // jump to real function skipping the first/replaced instruction + *space = 0x48000002 | ((real_addr + 4) & 0x03fffffc); + space++; + DCFlushRange((void*)(space - 2), 8); + ICInvalidateRange((unsigned char*)(space - 2) - CODE_RW_BASE_OFFSET, 8); + + unsigned int replace_instr = 0x48000002 | (repl_addr & 0x03fffffc); + *(volatile unsigned int *)(LIB_CODE_RW_BASE_OFFSET + real_addr) = replace_instr; + DCFlushRange((void*)(LIB_CODE_RW_BASE_OFFSET + real_addr), 4); + ICInvalidateRange((void*)(real_addr), 4); + } + + KernelRestoreDBATs(&table); +} + +/* ****************************************************************** */ +/* RESTORE ORIGINAL INSTRUCTIONS */ +/* ****************************************************************** */ +void RestoreInstructions(void) +{ + bat_table_t table; + KernelSetDBATs(&table); + + restore_instructions_t * restore = (restore_instructions_t *)(RESTORE_INSTR_ADDR); + if(restore->magic == RESTORE_INSTR_MAGIC) + { + for(unsigned int i = 0; i < restore->instr_count; i++) + { + *(volatile unsigned int *)(LIB_CODE_RW_BASE_OFFSET + restore->data[i].addr) = restore->data[i].instr; + DCFlushRange((void*)(LIB_CODE_RW_BASE_OFFSET + restore->data[i].addr), 4); + ICInvalidateRange((void*)restore->data[i].addr, 4); + } + + } + restore->magic = 0; + restore->instr_count = 0; + + KernelRestoreDBATs(&table); + KernelRestoreInstructions(); +} diff --git a/src/patcher/function_hooks.h b/src/patcher/function_hooks.h new file mode 100644 index 0000000..02fddfd --- /dev/null +++ b/src/patcher/function_hooks.h @@ -0,0 +1,15 @@ +#ifndef _FUNCTION_HOOKS_H_ +#define _FUNCTION_HOOKS_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +void PatchMethodHooks(void); +void RestoreInstructions(void); + +#ifdef __cplusplus +} +#endif + +#endif /* _FS_H */ diff --git a/src/system/memory.c b/src/system/memory.c new file mode 100644 index 0000000..91f5392 --- /dev/null +++ b/src/system/memory.c @@ -0,0 +1,198 @@ +/**************************************************************************** + * Copyright (C) 2015 Dimok + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + ****************************************************************************/ +#include +#include +#include "dynamic_libs/os_functions.h" +#include "common/common.h" +#include "memory.h" + +#define MEMORY_ARENA_1 0 +#define MEMORY_ARENA_2 1 +#define MEMORY_ARENA_3 2 +#define MEMORY_ARENA_4 3 +#define MEMORY_ARENA_5 4 +#define MEMORY_ARENA_6 5 +#define MEMORY_ARENA_7 6 +#define MEMORY_ARENA_8 7 +#define MEMORY_ARENA_FG_BUCKET 8 + +//!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +//! Memory functions +//! This is the only place where those are needed so lets keep them more or less private +//!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +extern unsigned int * pMEMAllocFromDefaultHeapEx; +extern unsigned int * pMEMAllocFromDefaultHeap; +extern unsigned int * pMEMFreeToDefaultHeap; + +extern int (* MEMGetBaseHeapHandle)(int mem_arena); +extern unsigned int (* MEMGetAllocatableSizeForFrmHeapEx)(int heap, int align); +extern void *(* MEMAllocFromFrmHeapEx)(int heap, unsigned int size, int align); +extern void (* MEMFreeToFrmHeap)(int heap, int mode); +extern void *(* MEMAllocFromExpHeapEx)(int heap, unsigned int size, int align); +extern int (* MEMCreateExpHeapEx)(void* address, unsigned int size, unsigned short flags); +extern void *(* MEMDestroyExpHeap)(int heap); +extern void (* MEMFreeToExpHeap)(int heap, void* ptr); + +static int mem1_heap = -1; +static int bucket_heap = -1; + +void memoryInitialize(void) +{ + int mem1_heap_handle = MEMGetBaseHeapHandle(MEMORY_ARENA_1); + unsigned int mem1_allocatable_size = MEMGetAllocatableSizeForFrmHeapEx(mem1_heap_handle, 4); + void *mem1_memory = MEMAllocFromFrmHeapEx(mem1_heap_handle, mem1_allocatable_size, 4); + if(mem1_memory) + mem1_heap = MEMCreateExpHeapEx(mem1_memory, mem1_allocatable_size, 0); + + int bucket_heap_handle = MEMGetBaseHeapHandle(MEMORY_ARENA_FG_BUCKET); + unsigned int bucket_allocatable_size = MEMGetAllocatableSizeForFrmHeapEx(bucket_heap_handle, 4); + void *bucket_memory = MEMAllocFromFrmHeapEx(bucket_heap_handle, bucket_allocatable_size, 4); + if(bucket_memory) + bucket_heap = MEMCreateExpHeapEx(bucket_memory, bucket_allocatable_size, 0); +} + +void memoryRelease(void) +{ + MEMDestroyExpHeap(mem1_heap); + MEMFreeToFrmHeap(MEMGetBaseHeapHandle(MEMORY_ARENA_1), 3); + mem1_heap = -1; + + MEMDestroyExpHeap(bucket_heap); + MEMFreeToFrmHeap(MEMGetBaseHeapHandle(MEMORY_ARENA_FG_BUCKET), 3); + bucket_heap = -1; +} + +//!------------------------------------------------------------------------------------------- +//! wraps +//!------------------------------------------------------------------------------------------- +void *__wrap_malloc(size_t size) +{ + // pointer to a function resolve + return ((void * (*)(size_t))(*pMEMAllocFromDefaultHeap))(size); +} + +void *__wrap_memalign(size_t align, size_t size) +{ + if (align < 4) + align = 4; + + // pointer to a function resolve + return ((void * (*)(size_t, size_t))(*pMEMAllocFromDefaultHeapEx))(size, align); +} + +void __wrap_free(void *p) +{ + // pointer to a function resolve + if(p != 0) + ((void (*)(void *))(*pMEMFreeToDefaultHeap))(p); +} + +void *__wrap_calloc(size_t n, size_t size) +{ + void *p = __wrap_malloc(n * size); + if (p != 0) { + memset(p, 0, n * size); + } + return p; +} + +size_t __wrap_malloc_usable_size(void *p) +{ + //! TODO: this is totally wrong and needs to be addressed + return 0x7FFFFFFF; +} + +void *__wrap_realloc(void *p, size_t size) +{ + void *new_ptr = __wrap_malloc(size); + if (new_ptr != 0) + { + memcpy(new_ptr, p, __wrap_malloc_usable_size(p) < size ? __wrap_malloc_usable_size(p) : size); + __wrap_free(p); + } + return new_ptr; +} + +//!------------------------------------------------------------------------------------------- +//! reent versions +//!------------------------------------------------------------------------------------------- +void *__wrap__malloc_r(struct _reent *r, size_t size) +{ + return __wrap_malloc(size); +} + +void *__wrap__calloc_r(struct _reent *r, size_t n, size_t size) +{ + return __wrap_calloc(n, size); +} + +void *__wrap__memalign_r(struct _reent *r, size_t align, size_t size) +{ + return __wrap_memalign(align, size); +} + +void __wrap__free_r(struct _reent *r, void *p) +{ + __wrap_free(p); +} + +size_t __wrap__malloc_usable_size_r(struct _reent *r, void *p) +{ + return __wrap_malloc_usable_size(p); +} + +void *__wrap__realloc_r(struct _reent *r, void *p, size_t size) +{ + return __wrap_realloc(p, size); +} + +//!------------------------------------------------------------------------------------------- +//! some wrappers +//!------------------------------------------------------------------------------------------- +void * MEM2_alloc(unsigned int size, unsigned int align) +{ + return __wrap_memalign(align, size); +} + +void MEM2_free(void *ptr) +{ + __wrap_free(ptr); +} + +void * MEM1_alloc(unsigned int size, unsigned int align) +{ + if (align < 4) + align = 4; + return MEMAllocFromExpHeapEx(mem1_heap, size, align); +} + +void MEM1_free(void *ptr) +{ + MEMFreeToExpHeap(mem1_heap, ptr); +} + +void * MEMBucket_alloc(unsigned int size, unsigned int align) +{ + if (align < 4) + align = 4; + return MEMAllocFromExpHeapEx(bucket_heap, size, align); +} + +void MEMBucket_free(void *ptr) +{ + MEMFreeToExpHeap(bucket_heap, ptr); +} diff --git a/src/system/memory.h b/src/system/memory.h new file mode 100644 index 0000000..59764d0 --- /dev/null +++ b/src/system/memory.h @@ -0,0 +1,42 @@ +/**************************************************************************** + * Copyright (C) 2015 Dimok + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + ****************************************************************************/ +#ifndef __MEMORY_H_ +#define __MEMORY_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +void memoryInitialize(void); +void memoryRelease(void); + +void * MEM2_alloc(unsigned int size, unsigned int align); +void MEM2_free(void *ptr); + +void * MEM1_alloc(unsigned int size, unsigned int align); +void MEM1_free(void *ptr); + +void * MEMBucket_alloc(unsigned int size, unsigned int align); +void MEMBucket_free(void *ptr); + +#ifdef __cplusplus +} +#endif + +#endif // __MEMORY_H_ diff --git a/src/utils/logger.c b/src/utils/logger.c new file mode 100644 index 0000000..f4795b4 --- /dev/null +++ b/src/utils/logger.c @@ -0,0 +1,89 @@ +#include +#include +#include +#include +#include +#include "common/common.h" +#include "dynamic_libs/os_functions.h" +#include "dynamic_libs/socket_functions.h" +#include "logger.h" + +#ifdef DEBUG_LOGGER +static int log_socket = -1; +static volatile int log_lock = 0; + + +void log_init(const char * ipString) +{ + log_socket = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP); + if (log_socket < 0) + return; + + struct sockaddr_in connect_addr; + memset(&connect_addr, 0, sizeof(connect_addr)); + connect_addr.sin_family = AF_INET; + connect_addr.sin_port = 4405; + inet_aton(ipString, &connect_addr.sin_addr); + + if(connect(log_socket, (struct sockaddr*)&connect_addr, sizeof(connect_addr)) < 0) + { + socketclose(log_socket); + log_socket = -1; + } +} + +void log_deinit(void) +{ + if(log_socket >= 0) + { + socketclose(log_socket); + log_socket = -1; + } +} + +void log_print(const char *str) +{ + // socket is always 0 initially as it is in the BSS + if(log_socket < 0) { + return; + } + + while(log_lock) + usleep(1000); + log_lock = 1; + + int len = strlen(str); + int ret; + while (len > 0) { + int block = len < 1400 ? len : 1400; // take max 1400 bytes per UDP packet + ret = send(log_socket, str, block, 0); + if(ret < 0) + break; + + len -= ret; + str += ret; + } + + log_lock = 0; +} + +void log_printf(const char *format, ...) +{ + if(log_socket < 0) { + return; + } + + char * tmp = NULL; + + va_list va; + va_start(va, format); + if((vasprintf(&tmp, format, va) >= 0) && tmp) + { + log_print(tmp); + } + va_end(va); + + if(tmp) + free(tmp); +} +#endif diff --git a/src/utils/logger.h b/src/utils/logger.h new file mode 100644 index 0000000..0e19ad3 --- /dev/null +++ b/src/utils/logger.h @@ -0,0 +1,26 @@ +#ifndef __LOGGER_H_ +#define __LOGGER_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +//#define DEBUG_LOGGER 1 + +#ifdef DEBUG_LOGGER +void log_init(const char * ip); +void log_deinit(void); +void log_print(const char *str); +void log_printf(const char *format, ...); +#else +#define log_init(x) +#define log_deinit() +#define log_print(x) +#define log_printf(x, ...) +#endif + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/saviine/client/saviine.c b/src/utils/net.c similarity index 78% rename from saviine/client/saviine.c rename to src/utils/net.c index 2760049..800fdc6 100644 --- a/saviine/client/saviine.c +++ b/src/utils/net.c @@ -1,19 +1,15 @@ -#include "main.h" +#include +#include +#include "common/common.h" +#include "dynamic_libs/os_functions.h" +#include "dynamic_libs/socket_functions.h" +#include "net.h" -static int recvwait(int sock, void *buffer, int len); -static int recvwaitlen(int sock, void *buffer, int len); - -static int recvbyte(int sock); -static int sendwait(int sock, const void *buffer, int len); -static int sendbyte(int sock, unsigned char value); -static int cafiine_handshake(int sock); +static volatile int iLock = 0; #define CHECK_ERROR(cond) if (cond) { goto error; } - - -void cafiine_connect(int *psock) { - extern unsigned int server_ip; +void cafiine_connect(int *psock,u32 server_ip) { struct sockaddr_in addr; int sock, ret; @@ -48,10 +44,12 @@ error: return; } -static int cafiine_handshake(int sock) { +int cafiine_handshake(int sock) { int ret; + unsigned char buffer[16]; + u64 title_id = OSGetTitleID(); memcpy(buffer, &title_id, 16); ret = sendwait(sock, buffer, sizeof(buffer)); @@ -65,11 +63,12 @@ error: int getMode(int sock,int * result) { - while (bss.lock) GX2WaitForVsync(); - bss.lock = 1; + while (iLock) + usleep(5000); + iLock = 1; int ret = 0; CHECK_ERROR(sock == -1); - + // create and send buffer with : [cmd id][fd][size][buffer data ...] { ret = sendbyte(sock, BYTE_G_MODE); @@ -82,14 +81,14 @@ int getMode(int sock,int * result) ret = 1; } error: - bss.lock = 0; + iLock = 0; return ret; } - int cafiine_fsetpos(int sock, int *result, int fd, int set) { - while (bss.lock) GX2WaitForVsync(); - bss.lock = 1; + while (iLock) + usleep(5000); + iLock = 1; CHECK_ERROR(sock == -1); @@ -106,18 +105,19 @@ int cafiine_fsetpos(int sock, int *result, int fd, int set) { ret = recvwait(sock, result, 4); CHECK_ERROR(ret < 0); - bss.lock = 0; + iLock = 0; return 0; error: - bss.lock = 0; + iLock = 0; return -1; } -int cafiine_send_handle(int sock, int client, const char *path, int handle) +int cafiine_send_handle(int sock, const char *path, int handle) { - while (bss.lock) GX2WaitForVsync(); - bss.lock = 1; - + while (iLock) + usleep(5000); + iLock = 1; + CHECK_ERROR(sock == -1); // create and send buffer with : [cmd id][handle][path length][path data ...] @@ -150,17 +150,20 @@ int cafiine_send_handle(int sock, int client, const char *path, int handle) int special_ret = recvbyte(sock); CHECK_ERROR(special_ret < 0); CHECK_ERROR(special_ret != BYTE_SPECIAL); - bss.lock = 0; + iLock = 0; return ret; } error: - bss.lock = 0; + iLock = 0; return -1; } + int cafiine_fopen(int sock, int *result, const char *path, const char *mode, int *handle) { - while (bss.lock) GX2WaitForVsync(); - bss.lock = 1; + while (iLock) + usleep(5000); + iLock = 1; + int final_result = -1; CHECK_ERROR(sock == -1); @@ -183,7 +186,7 @@ int cafiine_fopen(int sock, int *result, const char *path, const char *mode, int ret = sendwait(sock, buffer, 1 + 8 + len_path + len_mode); CHECK_ERROR(ret < 0); - + ret = recvbyte(sock); CHECK_ERROR(ret < 0); CHECK_ERROR(ret == BYTE_NORMAL); @@ -192,23 +195,24 @@ int cafiine_fopen(int sock, int *result, const char *path, const char *mode, int CHECK_ERROR(ret < 0); ret = recvwait(sock, handle, 4); CHECK_ERROR(ret < 0); - } + } final_result = 0; - + error: - bss.lock = 0; + iLock = 0; return final_result; } void cafiine_send_file(int sock, char *file, int size, int fd) { - while (bss.lock) GX2WaitForVsync(); - bss.lock = 1; + while (iLock) + usleep(5000); + iLock = 1; CHECK_ERROR(sock == -1); int ret; - + // create and send buffer with : [cmd id][fd][size][buffer data ...] { char buffer[1 + 4 + 4 + size]; @@ -228,43 +232,45 @@ void cafiine_send_file(int sock, char *file, int size, int fd) { } error: - bss.lock = 0; + iLock = 0; return; } + int cafiine_fread(int sock, int *result, void *ptr, int size, int fd) { - while (bss.lock) GX2WaitForVsync(); - bss.lock = 1; + while (iLock) + usleep(5000); + iLock = 1; CHECK_ERROR(sock == -1); int ret; char buffer[1 + 8]; buffer[0] = BYTE_READ; - *(int *)(buffer + 1) = size; + *(int *)(buffer + 1) = size; *(int *)(buffer + 5) = fd; - ret = sendwait(sock, buffer, 1 + 8); - CHECK_ERROR(ret < 0); - ret = recvbyte(sock); + ret = sendwait(sock, buffer, 1 + 8); + CHECK_ERROR(ret < 0); + ret = recvbyte(sock); CHECK_ERROR(ret == BYTE_NORMAL); int sz; ret = recvwait(sock, &sz, 4); CHECK_ERROR(ret < 0); ret = recvwaitlen(sock, ptr, sz); - *result = sz - ret; + *result = sz - ret; ret = sendbyte(sock, BYTE_OK); CHECK_ERROR(ret < 0); - - bss.lock = 0; + + iLock = 0; return 0; error: - bss.lock = 0; + iLock = 0; return -1; } - int cafiine_fclose(int sock, int *result, int fd,int dumpclose) { - while (bss.lock) GX2WaitForVsync(); - bss.lock = 1; + while (iLock) + usleep(5000); + iLock = 1; CHECK_ERROR(sock == -1); @@ -275,157 +281,167 @@ int cafiine_fclose(int sock, int *result, int fd,int dumpclose) { *(int *)(buffer + 1) = fd; ret = sendwait(sock, buffer, 1 + 4); CHECK_ERROR(ret < 0); - ret = recvbyte(sock); + ret = recvbyte(sock); CHECK_ERROR(ret == BYTE_NORMAL); ret = recvwait(sock, result, 4); CHECK_ERROR(ret < 0); - bss.lock = 0; + iLock = 0; return 0; error: - bss.lock = 0; + iLock = 0; return -1; } int saviine_start_injection(int sock, long persistentID,int * mask){ - while (bss.lock) GX2WaitForVsync(); - bss.lock = 1; + while (iLock) + usleep(5000); + iLock = 1; + int result = 0; - CHECK_ERROR(sock == -1); + CHECK_ERROR(sock == -1); int ret; { char buffer[1+4]; - + buffer[0] = BYTE_INJECTSTART; *(long *)(buffer + 1) = persistentID; ret = sendwait(sock, buffer, 1 + 4); CHECK_ERROR(ret < 0); - + ret = recvbyte(sock); CHECK_ERROR(ret < 0); CHECK_ERROR(ret != BYTE_SPECIAL); - - ret = recvwait(sock, mask, 4); + + ret = recvwait(sock, mask, 4); CHECK_ERROR(ret < 0); CHECK_ERROR((*mask & MASK_NORMAL) != MASK_NORMAL); - + ret = recvbyte(sock); CHECK_ERROR(ret < 0); CHECK_ERROR(ret != BYTE_SPECIAL); - result = 1; + result = 1; } error: - bss.lock = 0; + iLock = 0; return result; } int saviine_end_injection(int sock){ - while (bss.lock) GX2WaitForVsync(); - bss.lock = 1; + while (iLock) + usleep(5000); + iLock = 1; + int result = 0; - CHECK_ERROR(sock == -1); + CHECK_ERROR(sock == -1); int ret; { ret = sendbyte(sock, BYTE_INJECTEND); CHECK_ERROR(ret < 0); - + ret = recvbyte(sock); CHECK_ERROR(ret < 0); CHECK_ERROR(ret != BYTE_OK); - result = 1; + result = 1; } error: - bss.lock = 0; + iLock = 0; return result; } int saviine_start_dump(int sock, long persistentID,int * mask){ - while (bss.lock) GX2WaitForVsync(); - bss.lock = 1; + while (iLock) + usleep(5000); + iLock = 1; + int result = 0; - CHECK_ERROR(sock == -1); + CHECK_ERROR(sock == -1); int ret; { char buffer[1+4]; - + buffer[0] = BYTE_DUMPSTART; *(long *)(buffer + 1) = persistentID; ret = sendwait(sock, buffer, 1 + 4); CHECK_ERROR(ret < 0); - + ret = recvbyte(sock); CHECK_ERROR(ret < 0); CHECK_ERROR(ret != BYTE_SPECIAL); - - ret = recvwait(sock, mask, 4); + + ret = recvwait(sock, mask, 4); CHECK_ERROR(ret < 0); CHECK_ERROR((*mask & MASK_NORMAL) != MASK_NORMAL); - + ret = recvbyte(sock); CHECK_ERROR(ret < 0); CHECK_ERROR(ret != BYTE_SPECIAL); - result = 1; + result = 1; } error: - bss.lock = 0; + iLock = 0; return result; } int saviine_end_dump(int sock){ - while (bss.lock) GX2WaitForVsync(); - bss.lock = 1; + while (iLock) + usleep(5000); + iLock = 1; + int result = 0; - CHECK_ERROR(sock == -1); + CHECK_ERROR(sock == -1); int ret; { ret = sendbyte(sock, BYTE_DUMPEND); CHECK_ERROR(ret < 0); - + ret = recvbyte(sock); CHECK_ERROR(ret < 0); CHECK_ERROR(ret != BYTE_OK); - result = 1; + result = 1; } error: - bss.lock = 0; + iLock = 0; return result; } int saviine_readdir(int sock, char * path,char * resultname, int * resulttype, int * filesize){ - while (bss.lock) GX2WaitForVsync(); - bss.lock = 1; + while (iLock) + usleep(5000); + iLock = 1; + int result = 0; - CHECK_ERROR(sock == -1); + CHECK_ERROR(sock == -1); int ret; // create and send buffer with : [cmd id][len_path][path][filesize] { int size = 0; while (path[size++]); char buffer[1+4+size]; - + buffer[0] = BYTE_READ_DIR; *(int *)(buffer + 1) = size; for (ret = 0; ret < size; ret++) buffer[5 + ret] = path[ret]; - + // send buffer, wait for reply ret = sendwait(sock, buffer, 1+4+size); CHECK_ERROR(ret < 0); - + // wait reply ret = recvbyte(sock); CHECK_ERROR(ret != BYTE_OK); - + ret = recvbyte(sock); - CHECK_ERROR(ret != BYTE_FILE && ret != BYTE_FOLDER); + CHECK_ERROR(ret != BYTE_FILE && ret != BYTE_FOLDER); *resulttype = ret; size = 0; ret = recvwait(sock, &size, 4); - CHECK_ERROR(ret < 0); - - ret = recvwait(sock, resultname, size+1); CHECK_ERROR(ret < 0); - + + ret = recvwait(sock, resultname, size+1); + CHECK_ERROR(ret < 0); + size = 0; ret = recvwait(sock, &size, 4); CHECK_ERROR(ret < 0); @@ -434,17 +450,18 @@ int saviine_readdir(int sock, char * path,char * resultname, int * resulttype, i CHECK_ERROR(ret < 0); CHECK_ERROR(ret != BYTE_SPECIAL); result = 1; - + } error: - bss.lock = 0; + iLock = 0; return result; } void cafiine_send_ping(int sock, int val1, int val2) { - while (bss.lock) GX2WaitForVsync(); - bss.lock = 1; - + while (iLock) + usleep(5000); + iLock = 1; + int ret; char buffer[1 + 4 + 4]; buffer[0] = BYTE_PING; @@ -455,11 +472,11 @@ void cafiine_send_ping(int sock, int val1, int val2) { CHECK_ERROR(ret < 0); error: - bss.lock = 0; + iLock = 0; return; } -static int recvwait(int sock, void *buffer, int len) { + int recvwait(int sock, void *buffer, int len) { int ret; while (len > 0) { ret = recv(sock, buffer, len, 0); @@ -471,7 +488,8 @@ static int recvwait(int sock, void *buffer, int len) { error: return ret; } -static int recvwaitlen(int sock, void *buffer, int len) { + + int recvwaitlen(int sock, void *buffer, int len) { int ret; while (len > 0) { ret = recv(sock, buffer, len, 0); @@ -485,7 +503,7 @@ error: } -static int recvbyte(int sock) { + int recvbyte(int sock) { unsigned char buffer[1]; int ret; @@ -494,7 +512,7 @@ static int recvbyte(int sock) { return buffer[0]; } -static int sendwait(int sock, const void *buffer, int len) { + int sendwait(int sock, const void *buffer, int len) { int ret; while (len > 0) { ret = send(sock, buffer, len, 0); @@ -511,8 +529,9 @@ void log_string(int sock, const char* str, char flag_byte) { if(sock == -1) { return; } - while (bss.lock) GX2WaitForVsync(); - bss.lock = 1; + while (iLock) + usleep(5000); + iLock = 1; int i; int len_str = 0; @@ -531,11 +550,12 @@ void log_string(int sock, const char* str, char flag_byte) { sendwait(sock, buffer, 1 + 4 + len_str); } - bss.lock = 0; + iLock = 0; } -static int sendbyte(int sock, unsigned char byte) { + +int sendbyte(int sock, unsigned char byte) { unsigned char buffer[1]; buffer[0] = byte; return sendwait(sock, buffer, 1); -} \ No newline at end of file +} diff --git a/src/utils/net.h b/src/utils/net.h new file mode 100644 index 0000000..75ccb8b --- /dev/null +++ b/src/utils/net.h @@ -0,0 +1,63 @@ +#ifndef NETWORK_H_ +#define NETWORK_H_ + + +#define BYTE_NORMAL 0xff +#define BYTE_SPECIAL 0xfe +#define BYTE_OPEN 0x00 +#define BYTE_READ 0x01 +#define BYTE_CLOSE 0x02 +#define BYTE_OK 0x03 +#define BYTE_SETPOS 0x04 +#define BYTE_STATFILE 0x05 +#define BYTE_EOF 0x06 +#define BYTE_GETPOS 0x07 +#define BYTE_REQUEST 0x08 +#define BYTE_REQUEST_SLOW 0x09 +#define BYTE_HANDLE 0x0A +#define BYTE_DUMP 0x0B +#define BYTE_PING 0x0C +#define BYTE_G_MODE 0x0D +#define BYTE_MODE_D 0x0E +#define BYTE_MODE_I 0x0F +#define BYTE_CLOSE_DUMP 0x10 +#define BYTE_LOG_STR 0xfb +#define BYTE_FILE 0xC0 +#define BYTE_FOLDER 0xC1 +#define BYTE_READ_DIR 0xCC +#define BYTE_INJECTSTART 0x40 +#define BYTE_INJECTEND 0x41 +#define BYTE_DUMPSTART 0x42 +#define BYTE_DUMPEND 0x43 +#define BYTE_END 0xfd + +#define MASK_NORMAL 0x8000 +#define MASK_USER 0x0100 +#define MASK_COMMON 0x0200 +#define MASK_COMMON_CLEAN 0x0400 + +void cafiine_connect(int *psock,u32 ip); +void cafiine_disconnect(int sock); +int cafiine_handshake(int sock); +int getMode(int sock,int * result); +int cafiine_fsetpos(int sock, int *result, int fd, int set); +int cafiine_send_handle(int sock, const char *path, int handle); +int cafiine_fopen(int sock, int *result, const char *path, const char *mode, int *handle); +void cafiine_send_file(int sock, char *file, int size, int fd); +int cafiine_fread(int sock, int *result, void *ptr, int size, int fd); +int cafiine_fclose(int sock, int *result, int fd,int dumpclose); +int saviine_start_injection(int sock, long persistentID,int * mask); +int saviine_end_injection(int sock); +int saviine_start_dump(int sock, long persistentID,int * mask); +int saviine_end_dump(int sock); +int saviine_readdir(int sock, char * path,char * resultname, int * resulttype, int * filesize); +void cafiine_send_ping(int sock, int val1, int val2); + int recvwait(int sock, void *buffer, int len); + int recvwaitlen(int sock, void *buffer, int len); + int recvbyte(int sock); + int sendwait(int sock, const void *buffer, int len); +void log_string(int sock, const char* str, char flag_byte); +int sendbyte(int sock, unsigned char byte); + + +#endif diff --git a/src/utils/utils.h b/src/utils/utils.h new file mode 100644 index 0000000..c460fa2 --- /dev/null +++ b/src/utils/utils.h @@ -0,0 +1,47 @@ +#ifndef __UTILS_H_ +#define __UTILS_H_ + +#include +#include "../common/types.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#define FlushBlock(addr) asm volatile("dcbf %0, %1\n" \ + "icbi %0, %1\n" \ + "sync\n" \ + "eieio\n" \ + "isync\n" \ + : \ + :"r"(0), "r"(((addr) & ~31)) \ + :"memory", "ctr", "lr", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12" \ + ); + +#define LIMIT(x, min, max) \ + ({ \ + typeof( x ) _x = x; \ + typeof( min ) _min = min; \ + typeof( max ) _max = max; \ + ( ( ( _x ) < ( _min ) ) ? ( _min ) : ( ( _x ) > ( _max ) ) ? ( _max) : ( _x ) ); \ + }) + +#define DegToRad(a) ( (a) * 0.01745329252f ) +#define RadToDeg(a) ( (a) * 57.29577951f ) + +#define ALIGN4(x) (((x) + 3) & ~3) +#define ALIGN32(x) (((x) + 31) & ~31) + +// those work only in powers of 2 +#define ROUNDDOWN(val, align) ((val) & ~(align-1)) +#define ROUNDUP(val, align) ROUNDDOWN(((val) + (align-1)), align) + +#define le16(i) ((((u16) ((i) & 0xFF)) << 8) | ((u16) (((i) & 0xFF00) >> 8))) +#define le32(i) ((((u32)le16((i) & 0xFFFF)) << 16) | ((u32)le16(((i) & 0xFFFF0000) >> 16))) +#define le64(i) ((((u64)le32((i) & 0xFFFFFFFFLL)) << 32) | ((u64)le32(((i) & 0xFFFFFFFF00000000LL) >> 32))) + +#ifdef __cplusplus +} +#endif + +#endif // __UTILS_H_ diff --git a/www/saviine/frame.html b/www/saviine/frame.html deleted file mode 100644 index 9061fea..0000000 --- a/www/saviine/frame.html +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - diff --git a/www/saviine/index.html b/www/saviine/index.html deleted file mode 100644 index 9c7671b..0000000 --- a/www/saviine/index.html +++ /dev/null @@ -1,97 +0,0 @@ - - - - -
- - - - diff --git a/www/saviine/payload532.html b/www/saviine/payload532.html deleted file mode 100644 index e22a849..0000000 --- a/www/saviine/payload532.html +++ /dev/null @@ -1,649 +0,0 @@ - \ No newline at end of file diff --git a/www/saviine/saviine532.elf b/www/saviine/saviine532.elf deleted file mode 100644 index bdf1bca..0000000 Binary files a/www/saviine/saviine532.elf and /dev/null differ