From 7aa2ce17fc9fd04a33fdac0ee174726e9fdc1560 Mon Sep 17 00:00:00 2001 From: kyleatlast Date: Tue, 27 Mar 2018 18:07:43 +0000 Subject: [PATCH] Initial commit. --- .gitignore | 4 + CHANGELOG | 29 + Makefile | 22 + README.TXT | 12 + gpl-3.0.txt | 674 ++++++++++++++++++++ loader/Makefile | 29 + loader/libs/libpspkubridge.a | Bin 0 -> 17186 bytes loader/libs/libpspsystemctrl_kernel.a | Bin 0 -> 56426 bytes loader/src/exports.exp | 17 + loader/src/imports.S | 42 ++ loader/src/lib.c | 88 +++ loader/src/lib.h | 72 +++ loader/src/main.c | 256 ++++++++ loader/src/pgd.c | 188 ++++++ loader/src/pgd.h | 54 ++ loader/src/sctrl.h | 81 +++ loader/src/setk1.S | 12 + np9660_patch/Makefile | 29 + np9660_patch/libs/libpspkubridge.a | Bin 0 -> 17186 bytes np9660_patch/libs/libpspsystemctrl_kernel.a | Bin 0 -> 56426 bytes np9660_patch/src/exports.exp | 17 + np9660_patch/src/imports.S | 54 ++ np9660_patch/src/iofilemgr_kernel.h | 203 ++++++ np9660_patch/src/lib.c | 155 +++++ np9660_patch/src/lib.h | 88 +++ np9660_patch/src/license.h | 280 ++++++++ np9660_patch/src/main.c | 397 ++++++++++++ np9660_patch/src/pgd.c | 233 +++++++ np9660_patch/src/pgd.h | 57 ++ np9660_patch/src/sctrl.h | 87 +++ np9660_patch/src/setk1.S | 12 + 31 files changed, 3192 insertions(+) create mode 100644 .gitignore create mode 100644 CHANGELOG create mode 100644 Makefile create mode 100644 README.TXT create mode 100644 gpl-3.0.txt create mode 100644 loader/Makefile create mode 100644 loader/libs/libpspkubridge.a create mode 100644 loader/libs/libpspsystemctrl_kernel.a create mode 100644 loader/src/exports.exp create mode 100644 loader/src/imports.S create mode 100644 loader/src/lib.c create mode 100644 loader/src/lib.h create mode 100644 loader/src/main.c create mode 100644 loader/src/pgd.c create mode 100644 loader/src/pgd.h create mode 100644 loader/src/sctrl.h create mode 100644 loader/src/setk1.S create mode 100644 np9660_patch/Makefile create mode 100644 np9660_patch/libs/libpspkubridge.a create mode 100644 np9660_patch/libs/libpspsystemctrl_kernel.a create mode 100644 np9660_patch/src/exports.exp create mode 100644 np9660_patch/src/imports.S create mode 100644 np9660_patch/src/iofilemgr_kernel.h create mode 100644 np9660_patch/src/lib.c create mode 100644 np9660_patch/src/lib.h create mode 100644 np9660_patch/src/license.h create mode 100644 np9660_patch/src/main.c create mode 100644 np9660_patch/src/pgd.c create mode 100644 np9660_patch/src/pgd.h create mode 100644 np9660_patch/src/sctrl.h create mode 100644 np9660_patch/src/setk1.S diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..1919e92 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +*.o +*.elf +*.prx +np9660_patch.h diff --git a/CHANGELOG b/CHANGELOG new file mode 100644 index 0000000..ffa28e5 --- /dev/null +++ b/CHANGELOG @@ -0,0 +1,29 @@ +v6.3: + Fixed the crashes when resuming from sleep. + +v6.2: + Creates ms0:/PSP/LICENSE folder if it's missing. + +v6.1: + Fixed the issue from v6 with launching ISO/CSO games from the XMB. + +v6: + Added a patch to allow boot mode 2 (BOOTABLE in PARAM.SFO) to run. + +v5.1: + Fixed some checks to prevent this plugin from running on non-PSN games (crashed on ISO/CSO games). + +v5: + Fixed issues with 6.20 compatibility. + +v4: + Added 6.20 compatibility and support for licensed DLC (no SPRX support yet). + +v3: + Added support for licensed game software manuals in the VSH. + +v2: + Added a patch to create a fake flash2:/act.dat for PSPs without one. + +v1: + Initial release. diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..45b37b4 --- /dev/null +++ b/Makefile @@ -0,0 +1,22 @@ +ifeq ($(CONFIG_620), 1) +FW_FLAG = CONFIG_620=1 +endif + +ifeq ($(CONFIG_660), 1) +FW_FLAG = CONFIG_660=1 +endif + +ifeq ($(CONFIG_661), 1) +FW_FLAG = CONFIG_661=1 +endif + +all: + @cd np9660_patch; make $(FW_FLAG); \ + bin2c npdrm_free.prx np9660_patch.h np9660_patch; \ + mv np9660_patch.h ../loader/src/np9660_patch.h; + @cd loader; make $(FW_FLAG); mv npdrm_free.prx ../npdrm_free.prx; + +clean: + @cd np9660_patch; make clean; + @cd loader; make clean; + rm -rf npdrm_free.prx diff --git a/README.TXT b/README.TXT new file mode 100644 index 0000000..98a2e6b --- /dev/null +++ b/README.TXT @@ -0,0 +1,12 @@ +Place npdrm_free.prx in ms0:/seplugins/ and enable it in vsh.txt. +Restart VSH, now you can launch any official EBOOT.PBP without a license. + +If a license is not found then a fake one will be created, otherwise the official license will be left alone. + +If flash2:/act.dat is not found then a fake one will be created. + +To allow PC Engine games to run, either enable the nodrm engine in Pro CFW or install nploader.prx and enable in game.txt. + +Game software manuals that require a license will now work without a license using this plugin enabled in vsh.txt. + +Licensed DLC should now work and should now be 6.20 compatible. \ No newline at end of file diff --git a/gpl-3.0.txt b/gpl-3.0.txt new file mode 100644 index 0000000..94a9ed0 --- /dev/null +++ b/gpl-3.0.txt @@ -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. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 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: + + Copyright (C) + 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/loader/Makefile b/loader/Makefile new file mode 100644 index 0000000..c060453 --- /dev/null +++ b/loader/Makefile @@ -0,0 +1,29 @@ +TARGET = npdrm_free +OBJS = src/main.o src/exports.o src/lib.o src/setk1.o src/imports.o src/pgd.o + +LIBDIR = libs +LIBS = -lpspsystemctrl_kernel -lpspkubridge + +CFLAGS = -Wall -Wextra -O2 -G0 +ASFLAGS = $(CFLAGS) + +USE_KERNEL_LIBC = 1 +USE_KERNEL_LIBS = 1 + +ifeq ($(CONFIG_620), 1) +CFLAGS += -DCONFIG_620=1 +PSP_FW_VERSION=620 +endif + +ifeq ($(CONFIG_660), 1) +CFLAGS += -DCONFIG_660=1 +PSP_FW_VERSION=660 +endif + +ifeq ($(CONFIG_661), 1) +CFLAGS += -DCONFIG_661=1 +PSP_FW_VERSION=661 +endif + +PSPSDK=$(shell psp-config --pspsdk-path) +include $(PSPSDK)/lib/build_prx.mak diff --git a/loader/libs/libpspkubridge.a b/loader/libs/libpspkubridge.a new file mode 100644 index 0000000000000000000000000000000000000000..ac36055a75457bcc39aa55ca55d92e897e7fce45 GIT binary patch literal 17186 zcmeI4O>7%Q6o6miq$Po(B&yU(m0*LQAOudF#Ezr#)1+-s6en1uRjLwdukA^)_-CWt zb%~Ks5l0TF;(!oRL{%=8Dgg&nA&!UxCsdU)H%=T7Ck~u=Z+B-s-Z=55S}Wb`zT|mk z-i+VQOy--}pV^GQCTqpbHwMR~R!K}IXQmVBL~>k`@E1k=l%y%jFeN_-03!gs#{l~O z0~q)m;6w^w=r@3q>j0m&^GlmK>9ksxxWG4{4|%- zjd~$hRZH~>%Pn4+)0EN%gK~Y5X*E{KsB&q^%xhy>RgBHqEyZYTu?Z)8p{5wNvBfs8 zRM@gyZMvRQRbyULt1YD#S>u9QTURz5>s!pYqBAYSZm^1DTw%t=lD5REs@BMAs=%HD8EpYi<@krc0;ZxCD~xJm8P#OW91K=uV&RUYo_oB#jS>uIj_|0-k58& zwB>>`@uw1zm@@#x|7Nx{48%tZ}`_-eI~@Vl^zMu}Zw66wpt-ARb`<_!-Qm z_TdmV#cG$Gz`&|Az$nJ4T+GgLm*ai(BIZ+%bSn1>mce6g+3tY+o#qJ)>A2)GX@|WS zl4MYa%$W7T>$ikSD$mQUVf>_3#Qfyt7BDp+*l%M+>9}O0KA>_`|6x?#28@~&U8RUE zyuIQvDeGgbz-U-Tzo;v=+i;r@7Sjon!&5mixqwf6TR4}R3{2KXT*HM1M}%rbH?w){9Qc8L73P6dLcuK zOz+8dTdI*@M0y1QwtKnB`La^t&F>hVqxzzDVw$th$K_s3kD@OxOw(AyV{Tz!%3e%Q zVy;*}Vw(JO;p1@(4a5zX%UDq=M>d*6sT`$eQOO@?|1!q84~#l-H`7-!FG~e%As-~7 zFG}ap@huEHG5rsgE6^8g;r@7mCJkpxUAU> zP$2Rrm|N^elFOD$3ajOAMkl>6+QqeV_58KZNFzr5Wi$wDXHkGLWQ>Z}^=2=)xtuy= zE^`;>PLW1jhL20}$|HnaI``HHOgEQFFI*;5p6@Rm^qltFAO6UbMqK*KWi|lkw0U!- zus%Y@rE`0mTJL5u<%LPQ@oP$c(C_;{%b)!CJ!!^yKrT5u^Sx8eMBX){Hv)o!YFM2`~GL(y4UU zt~DS2xid-{G3hUpYXP{{EDLK|$nO8N+j403hHK4Cc-jlp#WnN#@$84B5ug6@8H6?S zz3}pBZTq#`?`G1|KA*RFjh<5>!i0mKizwdxiLJkNE$KeFOxxdj=3qoC$cA) zk1CV9-b14{yV>-%@27iv*?0cU-y)6J^q0*{0Pg$HyKP)T#-{lyD7D?q<6-al`RVn_ z8fnC%zdQzEt=!-+Vi-am#kaA|o^Z2y*n587z4qV%X~d?#YzAS^Pl(^g6#gTEH9--V F{{#Dm1@8a= literal 0 HcmV?d00001 diff --git a/loader/libs/libpspsystemctrl_kernel.a b/loader/libs/libpspsystemctrl_kernel.a new file mode 100644 index 0000000000000000000000000000000000000000..95228a508650b642621ecb99323fd3dd5f9b212f GIT binary patch literal 56426 zcmeI5dyL$~8Nk0JghBu{L_kp~^nyf4q3oUaak(o96p}p>$X&zjB~VIp+1vHymh7%i zw)b>LTk%j8(Uzh}&;mh46%vmYB2bHHp$No7NDYrdD-fz^rO^IEEAgmWsT7I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Y%5A5(>~cFQVKftRdfl8+{s~g`eMYZc zdCxf{no+fk>i1n@(Pu<&i`E?1stBJI^&U~omS#fEuRF=<>xVDiO`*4h|4Msg%8iNUPtGB0*e^UGviRM%-r*Rk~y^h0(OOZz*Iuzf9 Q{kx3Q@qCrfk|RF<4@`6V)c^nh literal 0 HcmV?d00001 diff --git a/loader/src/exports.exp b/loader/src/exports.exp new file mode 100644 index 0000000..cedc026 --- /dev/null +++ b/loader/src/exports.exp @@ -0,0 +1,17 @@ +PSP_BEGIN_EXPORTS + +PSP_EXPORT_START(syslib, 0, 0x8000) +PSP_EXPORT_FUNC(module_start) +PSP_EXPORT_FUNC(module_stop) +PSP_EXPORT_VAR(module_info) +PSP_EXPORT_END + +PSP_EXPORT_START(sceNpDrmFree, 0x0011, 0x4001) +PSP_EXPORT_FUNC(sceNpDrmFreeEdataSetupKey) +PSP_EXPORT_FUNC(sceNpDrmFreeEdataGetDataSize) +PSP_EXPORT_FUNC(sceNpDrmFreeOpen) +PSP_EXPORT_FUNC(sceNpDrmFreeRead) +PSP_EXPORT_FUNC(vshCheckBootable) +PSP_EXPORT_END + +PSP_END_EXPORTS diff --git a/loader/src/imports.S b/loader/src/imports.S new file mode 100644 index 0000000..d861a7b --- /dev/null +++ b/loader/src/imports.S @@ -0,0 +1,42 @@ + .set noreorder + +#include "pspstub.s" + + STUB_START "SystemCtrlForKernel",0x00090000,0x00020005 + STUB_FUNC 0x1C90BECB,sctrlHENSetStartModuleHandler + STUB_FUNC 0xCE0A654E,sctrlHENLoadModuleOnReboot + STUB_END + + STUB_START "StdioForKernel",0x00010000,0x00010005 + STUB_FUNC 0xCAB439DF,printf + STUB_END + + STUB_START "scePspNpDrm_driver",0x00090000,0x00020005 + STUB_FUNC 0x08D98894,sceNpDrmEdataSetupKey + STUB_FUNC 0x219EF5CC,sceNpDrmEdataGetDataSize + STUB_END + + STUB_START "InterruptManagerForKernel",0x00090000,0x00020005 + STUB_FUNC 0xF153B371,sceKernelQuerySystemCall_660 + STUB_FUNC 0xAC9306F0,sceKernelQuerySystemCall_620 + STUB_END + + STUB_START "sceAmctrl_driver",0x00090000,0x00090005 + STUB_FUNC 0x0785C974,sceDrmBBCipherUpdate + STUB_FUNC 0x1CCB66D2,sceDrmBBCipherInit + STUB_FUNC 0x525B8218,sceDrmBBMacInit + STUB_FUNC 0x58163FBE,sceDrmBBMacUpdate + STUB_FUNC 0x9227EA79,sceAmctrl_driver_9227EA79 + STUB_FUNC 0x9951C50F,sceDrmBBCipherFinal + STUB_FUNC 0xE04ADD4C,sceAmctrl_driver_E04ADD4C + STUB_FUNC 0xEF95A213,sceDrmBBMacFinal + STUB_FUNC 0xF5186D8E,sceDrmBBMacFinal2 + STUB_END + + STUB_START "semaphore",0x00090000,0x00010005 + STUB_FUNC 0x4C537C72,sceUtilsBufferCopyWithRange + STUB_END + + STUB_START "SysMemUserForUser",0x00090000,0x00010005 + STUB_FUNC 0x3FC9AE6A,sceKernelDevkitVersionForUser + STUB_END diff --git a/loader/src/lib.c b/loader/src/lib.c new file mode 100644 index 0000000..1885a85 --- /dev/null +++ b/loader/src/lib.c @@ -0,0 +1,88 @@ +/* + * Copyright (C) 2014 qwikrazor87 + * + * 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 "lib.h" + +void ClearCaches(void) +{ + sceKernelDcacheWritebackInvalidateAll(); + sceKernelIcacheInvalidateAll(); +} + +u32 FindTextAddrByName(const char *module) +{ + u32 kaddr; + for (kaddr = 0x88000000; kaddr < 0x88400000; kaddr += 4) { + if (strcmp((const char *)kaddr, module) == 0) { + if ((*(u32*)(kaddr + 0x64) == *(u32*)(kaddr + 0x78)) && \ + (*(u32*)(kaddr + 0x68) == *(u32*)(kaddr + 0x88))) { + if (*(u32*)(kaddr + 0x64) && *(u32*)(kaddr + 0x68)) + return *(u32*)(kaddr + 0x64); + } + } + } + return 0; +} + +u32 FindExport(const char *module, const char *library, u32 nid) +{ + u32 addr = FindTextAddrByName(module); + + if (addr) { + u32 maxaddr = 0x88400000; + + if (addr >= 0x08800000 && addr < 0x0A000000) + maxaddr = 0x0A000000; + else if (addr >= 0x08400000 && addr < 0x08800000) + maxaddr = 0x08800000; + + for (; addr < maxaddr; addr += 4) { + if (strcmp(library, (const char *)addr) == 0) { + u32 libaddr = addr; + + while (*(u32*)(addr -= 4) != libaddr); + + u32 exports = (u32)(*(u16*)(addr + 10) + *(u8*)(addr + 9)); + u32 jump = exports * 4; + + addr = *(u32*)(addr + 12); + + while (exports--) { + if (*(u32*)addr == nid) + return *(u32*)(addr + jump); + + addr += 4; + } + + return 0; + } + } + } + + return 0; +} + +void fillvram(u32 color) +{ + u32 vram; + + for (vram = 0x44000000; vram < 0x44200000; vram += 4) + _sw(color, vram); +} diff --git a/loader/src/lib.h b/loader/src/lib.h new file mode 100644 index 0000000..30b3a17 --- /dev/null +++ b/loader/src/lib.h @@ -0,0 +1,72 @@ +/* + * Copyright (C) 2014 qwikrazor87 + * + * 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 LIB_H_ +#define LIB_H_ + +#include + +void fillvram(u32 color); + +void ClearCaches(void); + +u32 FindTextAddrByName(const char *module); +u32 FindExport(const char *module, const char *library, u32 nid); +u32 pspSdkSetK1(u32 k1); + +#define U_EXTRACT_IMPORT(x) ((((u32)_lw((u32)x)) & ~0x08000000) << 2) +#define K_EXTRACT_IMPORT(x) (((((u32)_lw((u32)x)) & ~0x08000000) << 2) | 0x80000000) +#define U_EXTRACT_CALL(x) ((((u32)_lw((u32)x)) & ~0x0C000000) << 2) +#define K_EXTRACT_CALL(x) (((((u32)_lw((u32)x)) & ~0x0C000000) << 2) | 0x80000000) + +#define MAKE_JUMP(f) (0x08000000 | (((u32)(f) >> 2) & 0x03FFFFFF)) +#define MAKE_CALL(f) (0x0C000000 | (((u32)(f) >> 2) & 0x03FFFFFF)) + +#define MAKE_JUMP_PATCH(a, f) _sw(0x08000000 | (((u32)(f) & 0x0FFFFFFC) >> 2), a); + +#define HIJACK_FUNCTION(a, f, ptr) \ +{ \ + u32 func = a; \ + static u32 patch_buffer[3]; \ + _sw(_lw(func), (u32)patch_buffer); \ + _sw(_lw(func + 4), (u32)patch_buffer + 8);\ + MAKE_JUMP_PATCH((u32)patch_buffer + 4, func + 8); \ + _sw(0x08000000 | (((u32)(f) >> 2) & 0x03FFFFFF), func); \ + _sw(0, func + 4); \ + ptr = (void *)patch_buffer; \ +} + +int printf(const char *fmt, ...); + +typedef struct { + u16 label_offset; + u16 type; + u32 size; + u32 size_padded; + u32 data_offset; +} SFOtable; + +typedef struct { + u32 magic; + u32 version; + u32 label; + u32 data; + int entries; + SFOtable sfotable[]; +} SFO; + +#endif /* LIB_H_ */ diff --git a/loader/src/main.c b/loader/src/main.c new file mode 100644 index 0000000..8f9ee3a --- /dev/null +++ b/loader/src/main.c @@ -0,0 +1,256 @@ +/* + * Copyright (C) 2014 qwikrazor87 + * + * 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 +#include "lib.h" +#include "sctrl.h" +#include "np9660_patch.h" +#include "pgd.h" + +PSP_MODULE_INFO("npdrm_free", PSP_MODULE_KERNEL, 1, 0); +PSP_HEAP_SIZE_KB(0); + +#if defined(CONFIG_661) || defined(CONFIG_660) + +#define sceKernelQuerySystemCall sceKernelQuerySystemCall_660 +#define GAME_PATCH1_OFFSET1 0x2ADE4 +#define GAME_PATCH1_OFFSET2 0x2ADEC +#define GAME_PATCH2_OFFSET1 0x159E8 +#define GAME_PATCH2_OFFSET2 0x159E4 +#define GAME_PATCH3_OFFSET1 0x15A74 +#define GAME_PATCH3_OFFSET2 0x15A70 +#define VSH_PATCH_OFFSET1 0x12000 +#define VSH_PATCH_OFFSET2 0x11FFC + +#elif defined(CONFIG_620) + +#define sceKernelQuerySystemCall sceKernelQuerySystemCall_620 +#define GAME_PATCH1_OFFSET1 0x28E68 +#define GAME_PATCH1_OFFSET2 0x28E70 +#define GAME_PATCH2_OFFSET1 0x146C4 +#define GAME_PATCH2_OFFSET2 0x146C0 +#define GAME_PATCH3_OFFSET1 0x14750 +#define GAME_PATCH3_OFFSET2 0x1474C +#define VSH_PATCH_OFFSET1 0x11A1C +#define VSH_PATCH_OFFSET2 0x11A18 + +#else + +#error "Please specify your firmware version with CONFIG_6xx" + +#endif + +static STMOD_HANDLER previous = NULL; + +char g_drmpath[256]; +u8 g_drmkey[8]; +u8 g_pgdbuf[0xC0]; +SceUID g_fd; +int g_drmsize; + +int sceNpDrmEdataSetupKey(SceUID); +int sceNpDrmEdataGetDataSize(SceUID); +int sceKernelQuerySystemCall_660(void *); +int sceKernelQuerySystemCall_620(void *); +int sceKernelDevkitVersionForUser(void); + +int sceKernelStoreSyscall(void *func, u32 addr) +{ + int ret = sceKernelQuerySystemCall(func); + + if (ret > 0) { + _sw(0x03E00008, addr); + _sw(((ret << 6) | 12) & 0x03FFFFFF, addr + 4); + + sceKernelDcacheWritebackInvalidateRange((const void *)addr, 8); + sceKernelIcacheInvalidateRange((const void *)addr, 8); + } + + return ret; +} + +int sceNpDrmFreeEdataSetupKey(SceUID fd) +{ + int ret = sceNpDrmEdataSetupKey(fd); + + if (ret < 0) { + u32 k1 = pspSdkSetK1(0); + + g_fd = sceIoOpen(g_drmpath, PSP_O_RDONLY, 0777); + + u8 header[8]; + + sceIoRead(g_fd, header, 8); + + if (!memcmp(header, "\0PSPEDAT", 8)) { + sceIoLseek(g_fd, 0x80, PSP_SEEK_SET); + + sceIoRead(g_fd, header, 4); + + if (!memcmp(header, "\0PGD", 4)) { + sceIoLseek(g_fd, 0x80, PSP_SEEK_SET); + + sceIoRead(g_fd, g_pgdbuf, 0xC0); + + g_drmsize = pgd_decrypt(g_pgdbuf, 0xC0, 2, NULL); + + if (g_drmsize > 0) { + memcpy(g_drmkey, g_pgdbuf + 0x90, 8); + + ret = 0; + } + } + } + + sceIoClose(g_fd); + + pspSdkSetK1(k1); + } + + return ret; +} + +int sceNpDrmFreeEdataGetDataSize(SceUID fd) +{ + int ret = sceNpDrmEdataGetDataSize(fd); + + if (ret < 0) + ret = g_drmsize; + + return ret; +} + +int sceNpDrmFreeOpen(const char *path, int flags, SceMode mode) +{ + strcpy(g_drmpath, path); + + return sceIoOpen(path, flags, mode); +} + +int sceNpDrmFreeRead(SceUID fd, void *data, SceSize size) +{ + int ret = sceIoRead(fd, data, size); + + if (ret < 0) { + memcpy(data, g_drmkey, 8); + + ret = 8; + } + + return ret; +} + +void patch_game_plugin_module(u32 text_addr) +{ + sceKernelStoreSyscall(sceNpDrmFreeEdataSetupKey, text_addr + GAME_PATCH1_OFFSET1); + sceKernelStoreSyscall(sceNpDrmFreeEdataGetDataSize, text_addr + GAME_PATCH1_OFFSET2); + + int syscall = sceKernelQuerySystemCall(sceNpDrmFreeOpen); + + _sw(_lw(text_addr + GAME_PATCH2_OFFSET1), text_addr + GAME_PATCH2_OFFSET2); + _sw(((syscall << 6) | 12) & 0x03FFFFFF, text_addr + GAME_PATCH2_OFFSET1); + + sceKernelDcacheWritebackInvalidateRange((const void *)(text_addr + GAME_PATCH2_OFFSET2), 8); + sceKernelIcacheInvalidateRange((const void *)(text_addr + GAME_PATCH2_OFFSET2), 8); + + syscall = sceKernelQuerySystemCall(sceNpDrmFreeRead); + + _sw(_lw(text_addr + GAME_PATCH3_OFFSET1), text_addr + GAME_PATCH3_OFFSET2); + _sw(((syscall << 6) | 12) & 0x03FFFFFF, text_addr + GAME_PATCH3_OFFSET1); + + sceKernelDcacheWritebackInvalidateRange((const void *)(text_addr + GAME_PATCH3_OFFSET2), 8); + sceKernelIcacheInvalidateRange((const void *)(text_addr + GAME_PATCH3_OFFSET2), 8); +} + +void *vshCheckBootable(void *dst, const void *src, int size) +{ + SFO *sfo = (SFO *)src; + + int i; + + for (i = 0; i < sfo->entries; i++) { + if (!strcmp((char *)((u32)src + sfo->label + sfo->sfotable[i].label_offset), "BOOTABLE")) { + if (_lw((u32)src + sfo->data + sfo->sfotable[i].data_offset) == 2) + _sw(1, (u32)src + sfo->data + sfo->sfotable[i].data_offset); + + break; + } + } + + return memcpy(dst, src, size); +} + +void patch_vsh_module(u32 text_addr) +{ + int syscall = sceKernelQuerySystemCall(vshCheckBootable); + + _sw(_lw(text_addr + VSH_PATCH_OFFSET1), text_addr + VSH_PATCH_OFFSET2); + _sw(((syscall << 6) | 12) & 0x03FFFFFF, text_addr + VSH_PATCH_OFFSET1); + + sceKernelDcacheWritebackInvalidateRange((const void *)(text_addr + VSH_PATCH_OFFSET2), 8); + sceKernelIcacheInvalidateRange((const void *)(text_addr + VSH_PATCH_OFFSET2), 8); +} + +int module_start_handler(SceModule2 * module) +{ + int ret = previous ? previous(module) : 0; + + if (!strcmp(module->modname, "game_plugin_module")) + patch_game_plugin_module(module->text_addr); + else if (!strcmp(module->modname, "vsh_module")) + patch_vsh_module(module->text_addr); + + return ret; +} + +int thread_start(SceSize args __attribute__((unused)), void *argp __attribute__((unused))) +{ + previous = sctrlHENSetStartModuleHandler(module_start_handler); + + SceUID blockid = sceKernelAllocPartitionMemory(1, "kernel_module", PSP_SMEM_Low, size_np9660_patch, NULL); + void *modbuf = sceKernelGetBlockHeadAddr(blockid); + + if (blockid >= 0) { + memcpy(modbuf, np9660_patch, size_np9660_patch); + sctrlHENLoadModuleOnReboot("/kd/np9660.prx", modbuf, size_np9660_patch, BOOTLOAD_UMDEMU); + } + + SceIoStat stat; + + if (sceIoGetstat("ms0:/PSP/LICENSE", &stat) < 0) + sceIoMkdir("ms0:/PSP/LICENSE", 0777); + + return 0; +} + +int module_start(SceSize args, void *argp) +{ + SceUID thid = sceKernelCreateThread("npdrm_free", thread_start, 0x22, 0x2000, 0, NULL); + + if (thid >= 0) + sceKernelStartThread(thid, args, argp); + + return 0; +} + +int module_stop(SceSize args __attribute__((unused)), void *argp __attribute__((unused))) +{ + return 0; +} diff --git a/loader/src/pgd.c b/loader/src/pgd.c new file mode 100644 index 0000000..8cbc5a2 --- /dev/null +++ b/loader/src/pgd.c @@ -0,0 +1,188 @@ +/* + * dnas.c -- Reverse engineering of iofilemgr_dnas.prx + * written by tpu. + */ + +#include +#include +#include + +#include "pgd.h" + +/*************************************************************/ + +u8 dnas_key1A90[16] = { 0xED, 0xE2, 0x5D, 0x2D, 0xBB, 0xF8, 0x12, 0xE5, 0x3C, 0x5C, 0x59, 0x32, 0xFA, 0xE3, 0xE2, 0x43 }; +u8 dnas_key1AA0[16] = { 0x27, 0x74, 0xFB, 0xEB, 0xA4, 0xA0, 0x01, 0xD7, 0x02, 0x56, 0x9E, 0x33, 0x8C, 0x19, 0x57, 0x83 }; + +PGD_DESC g_pgd; +u8 kirk_buf[0x814]; + +int kirk7(u8 *buf, int size, int type) +{ + int retv; + u32 *header = (u32*)buf; + + header[0] = 5; + header[1] = 0; + header[2] = 0; + header[3] = type; + header[4] = size; + + retv = sceUtilsBufferCopyWithRange(buf, size + 0x14, buf, size, 7); + + if (retv) + return 0x80510311; + + return 0; +} + +int bbmac_getkey(MAC_KEY *mkey, u8 *bbmac, u8 *vkey) +{ + int i, retv, type, code; + u8 *kbuf, tmp[16], tmp1[16]; + + type = mkey->type; + retv = sceDrmBBMacFinal((u8 *)mkey, tmp, NULL); + + if (retv) + return retv; + + kbuf = kirk_buf + 0x14; + + // decrypt bbmac + if (type == 3) { + memcpy(kbuf, bbmac, 0x10); + kirk7(kirk_buf, 0x10, 0x63); + } else + memcpy(kirk_buf, bbmac, 0x10); + + memcpy(tmp1, kirk_buf, 16); + memcpy(kbuf, tmp1, 16); + + code = (type == 2) ? 0x3A : 0x38; + kirk7(kirk_buf, 0x10, code); + + for (i = 0; i < 0x10; i++) + vkey[i] = tmp[i] ^ kirk_buf[i]; + + return 0; +} + +PGD_DESC *pgd_open(u8 *pgd_buf, int pgd_flag, u8 *pgd_vkey) +{ + PGD_DESC *pgd; + MAC_KEY mkey; + CIPHER_KEY ckey; + u8 *fkey; + int retv; + + pgd = &g_pgd; + memset(pgd, 0, sizeof(PGD_DESC)); + + pgd->buf = pgd_buf; + pgd->key_index = *(u32*)(pgd_buf + 4); + pgd->drm_type = *(u32*)(pgd_buf + 8); + + if (pgd->drm_type == 1) { + pgd->mac_type = 1; + pgd_flag |= 4; + + if (pgd->key_index > 1) { + pgd->mac_type = 3; + pgd_flag |= 8; + } + + pgd->cipher_type = 1; + } else { + pgd->mac_type = 2; + pgd->cipher_type = 2; + } + + pgd->open_flag = pgd_flag; + + // select fixed key + fkey = NULL; + + if (pgd_flag & 2) + fkey = dnas_key1A90; + + if (pgd_flag & 1) + fkey = dnas_key1AA0; + + if (fkey == NULL) + return NULL; + + // MAC_0x80 check + sceDrmBBMacInit((u8 *)&mkey, pgd->mac_type); + sceDrmBBMacUpdate((u8 *)&mkey, pgd_buf, 0x80); + retv = sceDrmBBMacFinal2((u8 *)&mkey, pgd_buf + 0x80, fkey); + + if (retv) + return NULL; + + // MAC_0x70 + sceDrmBBMacInit((u8 *)&mkey, pgd->mac_type); + sceDrmBBMacUpdate((u8 *)&mkey, pgd_buf, 0x70); + + if (pgd_vkey) { + // use given vkey + retv = sceDrmBBMacFinal2((u8 *)&mkey, pgd_buf + 0x70, pgd_vkey); + + if (retv) + return NULL; + else + memcpy(pgd->vkey, pgd_vkey, 16); + } else { + // get vkey from MAC_70 + bbmac_getkey(&mkey, pgd_buf + 0x70, pgd->vkey); + } + + // decrypt PGD_DESC + sceDrmBBCipherInit((u8 *)&ckey, pgd->cipher_type, 2, pgd_buf + 0x10, pgd->vkey, 0); + sceDrmBBCipherUpdate((u8 *)&ckey, pgd_buf + 0x30, 0x30); + sceDrmBBCipherFinal((u8 *)&ckey); + + pgd->data_size = *(u32*)(pgd_buf + 0x44); + pgd->block_size = *(u32*)(pgd_buf + 0x48); + pgd->data_offset = *(u32*)(pgd_buf + 0x4C); + + pgd->align_size = (pgd->data_size + 15) & ~15; + pgd->table_offset = pgd->data_offset + pgd->align_size; + pgd->block_nr = (pgd->align_size + pgd->block_size - 1) & ~(pgd->block_size - 1); + pgd->block_nr = pgd->block_nr / pgd->block_size; + + return pgd; +} + +int pgd_decrypt(u8 *pgd_buf, int pgd_size, int pgd_flag, u8 *pgd_vkey) +{ + PGD_DESC *pgd; + MAC_KEY mkey; + CIPHER_KEY ckey; + int retv; + + + pgd = pgd_open(pgd_buf, pgd_flag, pgd_vkey); + + if (pgd == NULL) + return -1; + + if ((pgd->align_size + pgd->block_nr * 16) > pgd_size) + return -3; + + + // table MAC check + sceDrmBBMacInit((u8 *)&mkey, pgd->mac_type); + sceDrmBBMacUpdate((u8 *)&mkey, pgd_buf + pgd->table_offset, pgd->block_nr * 16); + retv = sceDrmBBMacFinal2((u8 *)&mkey, pgd_buf + 0x60, pgd->vkey); + + if (retv) + return -4; + + // decrypt data + sceDrmBBCipherInit((u8 *)&ckey, pgd->cipher_type, 2, pgd_buf + 0x30, pgd->vkey, 0); + sceDrmBBCipherUpdate((u8 *)&ckey, pgd_buf + 0x90, pgd->align_size); + sceDrmBBCipherFinal((u8 *)&ckey); + + return pgd->data_size; +} diff --git a/loader/src/pgd.h b/loader/src/pgd.h new file mode 100644 index 0000000..76a17e0 --- /dev/null +++ b/loader/src/pgd.h @@ -0,0 +1,54 @@ +#ifndef _PGD_H +#define _PGD_H + +#include + +typedef struct { + int type; + u8 key[16]; + u8 pad[16]; + int pad_size; +} MAC_KEY; + +typedef struct +{ + u32 type; + u32 seed; + u8 key[16]; +} CIPHER_KEY; + +typedef struct { + u8 vkey[16]; + + int open_flag; + int key_index; + int drm_type; + int mac_type; + int cipher_type; + + int data_size; + int align_size; + int block_size; + int block_nr; + int data_offset; + int table_offset; + + u8 *buf; +} PGD_DESC; + +int sceDrmBBMacInit(u8 *mac_key, int type); +int sceDrmBBMacUpdate(u8 *mac_key, u8 *buf, int size); +int sceAmctrl_driver_9227EA79(u8 *mac_key, u8 *buf, int size); +int sceDrmBBMacFinal(u8 *mac_key, u8 *buf, u8 *version_key); +int sceDrmBBMacFinal2(u8 *mac_key, u8 *buf, u8 *version_key); + +int sceDrmBBCipherInit(u8 *cipher_key, int type, int mode, u8 *header_key, u8 *version_key, int seed); +int sceDrmBBCipherUpdate(u8 *cipher_key, u8 *buf, int size); +int sceAmctrl_driver_E04ADD4C(u8 *cipher_key, u8 *buf, int size); +int sceDrmBBCipherFinal(u8 *cipher_key); + +int sceUtilsBufferCopyWithRange(u8 *outbuf, int outlen, u8 *inbuf, int inlen, int cmd); + +int pgd_decrypt(u8 *pgd_buf, int pgd_size, int pgd_flag, u8 *pgd_vkey); + +#endif /* _PGD_H */ diff --git a/loader/src/sctrl.h b/loader/src/sctrl.h new file mode 100644 index 0000000..4ac0643 --- /dev/null +++ b/loader/src/sctrl.h @@ -0,0 +1,81 @@ +/* + * Copyright (C) 2014 qwikrazor87 + * + * 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 _SCTRL_H +#define _SCTRL_H + +#include + +typedef struct SceModule2 +{ + struct SceModule2* next; //0, 0x00 + u16 attribute; //4, 0x04 + u8 version[2]; //6, 0x06 + char modname[27]; //8, 0x08 + char terminal; //35, 0x23 + u16 status; //36, 0x24 (Used in modulemgr for stage identification) + u16 padding; //38, 0x26 + u32 unk_28; //40, 0x28 + SceUID modid; //44, 0x2C + SceUID usermod_thid; //48, 0x30 + SceUID memid; //52, 0x34 + SceUID mpidtext; //56, 0x38 + SceUID mpiddata; //60, 0x3C + void * ent_top; //64, 0x40 + u32 ent_size; //68, 0x44 + void * stub_top; //72, 0x48 + u32 stub_size; //76, 0x4C + int (* module_start)(SceSize, void *); //80, 0x50 + int (* module_stop)(SceSize, void *); //84, 0x54 + int (* module_bootstart)(SceSize, void *); //88, 0x58 + int (* module_reboot_before)(void *); //92, 0x5C + int (* module_reboot_phase)(SceSize, void *); //96, 0x60 + u32 entry_addr; //100, 0x64(seems to be used as a default address) + u32 gp_value; //104, 0x68 + u32 text_addr; //108, 0x6C + u32 text_size; //112, 0x70 + u32 data_size; //116, 0x74 + u32 bss_size; //120, 0x78 + u8 nsegment; //124, 0x7C + u8 padding2[3]; //125, 0x7D + u32 segmentaddr[4]; //128, 0x80 + u32 segmentsize[4]; //144, 0x90 + int module_start_thread_priority; //160, 0xA0 + SceSize module_start_thread_stacksize; //164, 0xA4 + SceUInt module_start_thread_attr; //168, 0xA8 + int module_stop_thread_priority; //172, 0xAC + SceSize module_stop_thread_stacksize; //176, 0xB0 + SceUInt module_stop_thread_attr; //180, 0xB4 + int module_reboot_before_thread_priority; //184, 0xB8 + SceSize module_reboot_before_thread_stacksize; //188, 0xBC + SceUInt module_reboot_before_thread_attr; //192, 0xC0 +} SceModule2; + +enum BootLoadFlags +{ + BOOTLOAD_VSH = 1, + BOOTLOAD_GAME = 2, + BOOTLOAD_UPDATER = 4, + BOOTLOAD_POPS = 8, + BOOTLOAD_UMDEMU = 64, /* for original NP9660 */ +}; + +typedef int (* STMOD_HANDLER)(SceModule2 *); +STMOD_HANDLER sctrlHENSetStartModuleHandler(STMOD_HANDLER handler); +void sctrlHENLoadModuleOnReboot(char *module_before, void *buf, int size, int flags); + +#endif /* _SCTRL_H */ diff --git a/loader/src/setk1.S b/loader/src/setk1.S new file mode 100644 index 0000000..e2be14b --- /dev/null +++ b/loader/src/setk1.S @@ -0,0 +1,12 @@ + .set noreorder + + .global pspSdkSetK1 + + .ent pspSdkSetK1 +pspSdkSetK1: + move $v0, $k1 + jr $ra + move $k1, $a0 + .end pspSdkSetK1 + + .set reorder diff --git a/np9660_patch/Makefile b/np9660_patch/Makefile new file mode 100644 index 0000000..3f6daa8 --- /dev/null +++ b/np9660_patch/Makefile @@ -0,0 +1,29 @@ +TARGET = npdrm_free +OBJS = src/main.o src/exports.o src/lib.o src/pgd.o src/setk1.o src/imports.o + +LIBDIR = libs +LIBS = -lpspsystemctrl_kernel -lpspkubridge + +CFLAGS = -Wall -Wextra -O2 -G0 +ASFLAGS = $(CFLAGS) + +USE_KERNEL_LIBC = 1 +USE_KERNEL_LIBS = 1 + +ifeq ($(CONFIG_620), 1) +CFLAGS += -DCONFIG_620=1 +PSP_FW_VERSION=620 +endif + +ifeq ($(CONFIG_660), 1) +CFLAGS += -DCONFIG_660=1 +PSP_FW_VERSION=660 +endif + +ifeq ($(CONFIG_661), 1) +CFLAGS += -DCONFIG_661=1 +PSP_FW_VERSION=661 +endif + +PSPSDK=$(shell psp-config --pspsdk-path) +include $(PSPSDK)/lib/build_prx.mak diff --git a/np9660_patch/libs/libpspkubridge.a b/np9660_patch/libs/libpspkubridge.a new file mode 100644 index 0000000000000000000000000000000000000000..ac36055a75457bcc39aa55ca55d92e897e7fce45 GIT binary patch literal 17186 zcmeI4O>7%Q6o6miq$Po(B&yU(m0*LQAOudF#Ezr#)1+-s6en1uRjLwdukA^)_-CWt zb%~Ks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EDLK|$nO8N+j403hHK4Cc-jlp#WnN#@$84B5ug6@8H6?S zz3}pBZTq#`?`G1|KA*RFjh<5>!i0mKizwdxiLJkNE$KeFOxxdj=3qoC$cA) zk1CV9-b14{yV>-%@27iv*?0cU-y)6J^q0*{0Pg$HyKP)T#-{lyD7D?q<6-al`RVn_ z8fnC%zdQzEt=!-+Vi-am#kaA|o^Z2y*n587z4qV%X~d?#YzAS^Pl(^g6#gTEH9--V F{{#Dm1@8a= literal 0 HcmV?d00001 diff --git a/np9660_patch/libs/libpspsystemctrl_kernel.a b/np9660_patch/libs/libpspsystemctrl_kernel.a new file mode 100644 index 0000000000000000000000000000000000000000..95228a508650b642621ecb99323fd3dd5f9b212f GIT binary patch literal 56426 zcmeI5dyL$~8Nk0JghBu{L_kp~^nyf4q3oUaak(o96p}p>$X&zjB~VIp+1vHymh7%i zw)b>LTk%j8(Uzh}&;mh46%vmYB2bHHp$No7NDYrdD-fz^rO^IEEAgmWsT7I!`#c`+ z__Chei)OWWcjok+?V0h|{?Y2uW!Ih694!0 z8R_&O+hg}C02l^1aSC9y4RFe70AF|>;0#><@)rTl#`SgA0i3r6;DV75;1qC^t!L*;?#|p6F>0HYFJ|Y>0!D8xIR#15j@e?~HSLHT zqmB`ol8i{nPDiDTI;n_#MxAs-%2g$IX5(zhU6?h+968h7;h6R|b1tk4jNfd|?L~!{ zwo|gIY@aRJv8_%nD{Nq<8Oz!m#9U?`u?I$tma3M$xTKL%wYb?X&2gn+;S@Des}@}G zi1ZtbdOzUTtK;UBWx2u8w&&f#4F0NxeA)jcv5?jy@gj3>-ga5(Tk_Rnx!K9!E~93} zvKPQICo6bZt5B+z-1-)+P1~kfkHNd5QmW$3!A?7uMTP9B6h}(sAclSgKSo$>nD0`& z{!LbOns(n>Et>N}sgY?|s4R`jEA7dOMJjMGQ4ZUNGxqr&2g=YaF?;82iHDUDvq0uRSqa% zDdTuA0`xC_#D^dFM{F6H;ou41;8{00fFWV^uZl=BBxy-WT1t|ZmZW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fb7m{%l*$g2VNo3T&m?#kF~^N&I0@PGGkmR>ck_^#avVt5=AKe@+M<Fh<&3W_>Xj_zz zBF9Ri_nY7m+;HVWjHPGuv3_cLQLbbB?K5ym`Ox)`7Z&H^&-b;MdK^l#eCsd|9&^?! z4F6Gir}GV5(s8NGqxHe5+n%xDleImsteN&gZozTQ%BFld_#`s3rKyl}>!z%>asJ<# zk6f~nMB7retj1yfUsZTE@n@Y7<*kbG-Bri+#zh&cG+B4Vwz$6-pV5$0>!yshvA+BJ z7Y|L5XhzjCs_VP4u&3UKmPV~&Ej-qe3anyF?a?5&`u^MOjr-0c(R`}qQ`^v3@X64e zzy{mKV$t?15X^?ALr$%m+R!#KdeUhx86=v~-eZ*4>*&@L>$Co?>Mg|hF0AKz?|N@8 zIfV&6u?Vl)XEfy8x|59F^SuuqCee&)MnyLHde<|G@3}-U8gg{qNk(ry;f5U~n$g~4 zRDbukjD*q*-Ed{sx1%Aa*PUdvdf=ZniDpzY%5A5(>~cFQVKftRdfl8+{s~g`eMYZc zdCxf{no+fk>i1n@(Pu<&i`E?1stBJI^&U~omS#fEuRF=<>xVDiO`*4h|4Msg%8iNUPtGB0*e^UGviRM%-r*Rk~y^h0(OOZz*Iuzf9 Q{kx3Q@qCrfk|RF<4@`6V)c^nh literal 0 HcmV?d00001 diff --git a/np9660_patch/src/exports.exp b/np9660_patch/src/exports.exp new file mode 100644 index 0000000..4042962 --- /dev/null +++ b/np9660_patch/src/exports.exp @@ -0,0 +1,17 @@ +PSP_BEGIN_EXPORTS + +PSP_EXPORT_START(syslib, 0, 0x8000) +PSP_EXPORT_FUNC(module_start) +PSP_EXPORT_FUNC(module_stop) +PSP_EXPORT_VAR(module_info) +PSP_EXPORT_END + +PSP_EXPORT_START(sceNpDrmFree, 0x0011, 0x4001) +PSP_EXPORT_FUNC(sceNpDrmFreeEdataSetupKey) +PSP_EXPORT_FUNC(sceNpDrmFreeEdataGetDataSize) +PSP_EXPORT_FUNC(sceNpDrmFreeOpen) +PSP_EXPORT_FUNC(sceNpDrmFreeRead) +PSP_EXPORT_FUNC(sceNpDrmFreeClose) +PSP_EXPORT_END + +PSP_END_EXPORTS diff --git a/np9660_patch/src/imports.S b/np9660_patch/src/imports.S new file mode 100644 index 0000000..1ac11c6 --- /dev/null +++ b/np9660_patch/src/imports.S @@ -0,0 +1,54 @@ + .set noreorder + +#include "pspstub.s" + + STUB_START "SystemCtrlForKernel",0x00090000,0x00020005 + STUB_FUNC 0x1C90BECB,sctrlHENSetStartModuleHandler + STUB_FUNC 0xCE0A654E,sctrlHENLoadModuleOnReboot + STUB_END + + STUB_START "StdioForKernel",0x00090000,0x00010005 + STUB_FUNC 0xCAB439DF,printf + STUB_END + + STUB_START "sceAmctrl_driver",0x00090000,0x00090005 + STUB_FUNC 0x0785C974,sceDrmBBCipherUpdate + STUB_FUNC 0x1CCB66D2,sceDrmBBCipherInit + STUB_FUNC 0x525B8218,sceDrmBBMacInit + STUB_FUNC 0x58163FBE,sceDrmBBMacUpdate + STUB_FUNC 0x9227EA79,sceAmctrl_driver_9227EA79 + STUB_FUNC 0x9951C50F,sceDrmBBCipherFinal + STUB_FUNC 0xE04ADD4C,sceAmctrl_driver_E04ADD4C + STUB_FUNC 0xEF95A213,sceDrmBBMacFinal + STUB_FUNC 0xF5186D8E,sceDrmBBMacFinal2 + STUB_END + + STUB_START "sceDdrdb_driver",0x00090000,0x00020005 + STUB_FUNC 0x40CB752A,sceDdrdbHash + STUB_FUNC 0xE27CE4CB,sceDdrdbSigvry + STUB_END + + STUB_START "scePspNpDrm_driver",0x00090000,0x00040005 + STUB_FUNC 0x00AD67F8,sceNpDrmGetFixedKey + STUB_FUNC 0x0F9547E6,sceNpDrmGetVersionKey + STUB_FUNC 0x08D98894,sceNpDrmEdataSetupKey + STUB_FUNC 0x219EF5CC,sceNpDrmEdataGetDataSize + STUB_END + + STUB_START "semaphore",0x00090000,0x00040005 + STUB_FUNC 0x00EEC06A,sceUtilsBufferCopy + STUB_FUNC 0x4C537C72,sceUtilsBufferCopyWithRange + STUB_FUNC 0x77E97079,sceUtilsBufferCopyByPollingWithRange + STUB_FUNC 0x8EEB7BF2,sceUtilsBufferCopyByPolling + STUB_END + + STUB_START "LoadCoreForKernel",0x00090000,0x00040005 + STUB_FUNC 0xBC99C625,_sceKernelFindModuleByAddress_660 + STUB_FUNC 0xF6B1BF0F,_sceKernelFindModuleByName_660 + STUB_FUNC 0x452C5524,_sceKernelFindModuleByAddress_620 + STUB_FUNC 0xBEF0A05E,_sceKernelFindModuleByName_620 + STUB_END + + STUB_START "SysMemUserForUser",0x00090000,0x00010005 + STUB_FUNC 0x3FC9AE6A,sceKernelDevkitVersionForUser + STUB_END diff --git a/np9660_patch/src/iofilemgr_kernel.h b/np9660_patch/src/iofilemgr_kernel.h new file mode 100644 index 0000000..185107a --- /dev/null +++ b/np9660_patch/src/iofilemgr_kernel.h @@ -0,0 +1,203 @@ +/* Copyright (C) 2011, 2012 The uOFW team + See the file COPYING for copying permission. +*/ + +#define SCE_O_RDONLY 0x0001 +#define SCE_O_WRONLY 0x0002 +#define SCE_O_RDWR (SCE_O_RDONLY | SCE_O_WRONLY) +#define SCE_O_NBLOCK 0x0004 +#define SCE_O_DIROPEN 0x0008 // Internal use for dopen +#define SCE_O_APPEND 0x0100 +#define SCE_O_CREAT 0x0200 +#define SCE_O_TRUNC 0x0400 +#define SCE_O_EXCL 0x0800 +#define SCE_O_NOWAIT 0x8000 +#define SCE_O_UNKNOWN0 0x04000000 + +/** user read/write/execute permission. */ +#define SCE_STM_RWXU 00700 +/** user read permission. */ +#define SCE_STM_RUSR 00400 +/** user write permission. */ +#define SCE_STM_WUSR 00200 +/** user execute permission. */ +#define SCE_STM_XUSR 00100 + +/** group read/write/execute permission. */ +#define SCE_STM_RWXG 00070 +/** group read permission. */ +#define SCE_STM_RGRP 00040 +/** group write permission. */ +#define SCE_STM_WGRP 00020 +/** group execute permission. */ +#define SCE_STM_XGRP 00010 + +/** other read/write/execute permission. */ +#define SCE_STM_RWXO 00007 +/** other read permission. */ +#define SCE_STM_ROTH 00004 +/** other write permission. */ +#define SCE_STM_WOTH 00002 +/** other execute permission. */ +#define SCE_STM_XOTH 00001 + +/** user/group/other - read/write/execute. */ +#define SCE_STM_RWXUGO (SCE_STM_RWXU|SCE_STM_RWXG|SCE_STM_RWXO) +/** user/group/other - read. */ +#define SCE_STM_RUGO (SCE_STM_RUSR|SCE_STM_RGRP|SCE_STM_ROTH) +/** user/group/other - write. */ +#define SCE_STM_WUGO (SCE_STM_WUSR|SCE_STM_WGRP|SCE_STM_WOTH) +/** user/group/other - execute. */ +#define SCE_STM_XUGO (SCE_STM_XUSR|SCE_STM_XGRP|SCE_STM_XOTH) + +#define SCE_SEEK_SET 0 +#define SCE_SEEK_CUR 1 +#define SCE_SEEK_END 2 + +struct SceIoDeviceArg; +typedef struct SceIoDeviceArg SceIoDeviceArg; +struct SceIoIob; +typedef struct SceIoIob SceIoIob; + +typedef struct +{ + int (*IoInit)(SceIoDeviceArg *dev); + int (*IoExit)(SceIoDeviceArg *dev); + int (*IoOpen)(SceIoIob *iob, char *file, int flags, SceMode mode); + int (*IoClose)(SceIoIob *iob); + int (*IoRead)(SceIoIob *iob, char *data, int len); + int (*IoWrite)(SceIoIob *iob, const char *data, int len); + SceOff (*IoLseek)(SceIoIob *iob, SceOff ofs, int whence); + int (*IoIoctl)(SceIoIob *iob, unsigned int cmd, void *indata, int inlen, void *outdata, int outlen); + int (*IoRemove)(SceIoIob *iob, const char *name); + int (*IoMkdir)(SceIoIob *iob, const char *name, SceMode mode); + int (*IoRmdir)(SceIoIob *iob, const char *name); + int (*IoDopen)(SceIoIob *iob, const char *dirname); + int (*IoDclose)(SceIoIob *iob); + int (*IoDread)(SceIoIob *iob, SceIoDirent *dir); + int (*IoGetstat)(SceIoIob *iob, const char *file, SceIoStat *stat); + int (*IoChstat)(SceIoIob *iob, const char *file, SceIoStat *stat, int bits); + int (*IoRename)(SceIoIob *iob, const char *oldname, const char *newname); + int (*IoChdir)(SceIoIob *iob, const char *dir); + int (*IoMount)(SceIoIob *iob, const char *fs, const char *blockDev, int mode, void *unk1, int unk2); + int (*IoUmount)(SceIoIob *iob, const char *blockDev); + int (*IoDevctl)(SceIoIob *iob, const char *devname, unsigned int cmd, void *indata, int inlen, void *outdata, int outlen); + int (*IoCancel)(SceIoIob *iob); +} SceIoDrvFuncs; + +typedef struct +{ + const char *name; + u32 dev_type; + u32 unk2; + const char *name2; + SceIoDrvFuncs *funcs; +} SceIoDrv; + +struct SceIoDeviceArg +{ + SceIoDrv *drv; + void *argp; + int openedFiles; +}; + +struct SceIoHookType; +typedef struct SceIoHookType SceIoHookType; + +struct SceIoHook; +typedef struct SceIoHook SceIoHook; + +typedef struct +{ + void (*Add)(SceIoHookType **hook); + int unused4; + int (*Preobe)(SceIoHook *hook, char *file, int flags, SceMode mode); + int (*Open)(SceIoHook *hook, char *file, int flags, SceMode mode); + int (*Close)(SceIoHook *hook); + int (*Read)(SceIoHook *hook, void *data, SceSize size); + int (*Write)(SceIoHook *hook, const void *data, SceSize size); + SceOff (*Lseek)(SceIoHook *hook, SceOff ofs, int whence); + int (*Ioctl)(SceIoHook *iob, unsigned int cmd, void *indata, int inlen, void *outdata, int outlen); +} SceIoHookFuncs; + +struct SceIoHookType +{ + char *name; + int unk4; + int unk8; + char *name2; + SceIoHookFuncs *funcs; +}; + +typedef struct +{ + int size; // 0 + char name[32]; // 4 + int attribute; // 36 + int unk40; // 40 + const char *drvName; // 44 + int fsNum; // 48 + char *newPath; // 52 + int retAddr; // 56 + int curThread; // 60 + int asyncThread; // 64 + int isAsync; // 68 + int asyncCmd; // 72 + SceIoIob *iob; // 76 + int unk80; // 80 + int unk84; // 84 +} SceIoFdDebugInfo; + +typedef struct +{ + SceIoHookType *hook; + void *argp; +} SceIoHookArg; + +struct SceIoHook +{ + SceIoHookArg *arg; + SceIoIob *iob; + SceIoDrvFuncs *funcs; +}; + +struct SceIoIob +{ + int unk000; // some ID + int fsNum; // 4 + SceIoDeviceArg *dev; // 8 + int dev_type; // 12 + int unk016; // 16 + int unk020; // 20 + int unk024; // 24 + int unk028; // 28 + int unk032; // 32 + int unk036; // 36 + int unk040; // 40 + SceUID curThread; // 44 + char userMode; // 48 + char powerLocked; // 49 + char unk050; + char asyncPrio; // 51 + SceUID asyncThread; // 52 + SceUID asyncSema; // 56 + SceUID asyncEvFlag; // 60 + SceUID asyncCb; // 64 + void *asyncCbArgp; // 68 + int unused72; // 72 + int k1; // 76 + s64 asyncRet; // 80 + int asyncArgs[6]; // 88 + int asyncCmd; // 112 + int userLevel; // 116 + SceIoHook hook; // 120 + int unk132; // 132 + char *newPath; // 136 + int retAddr; // 140 +}; + +/* IO-Assign mount mode flags. */ +#define SCE_MT_RDWR 0x00 /** Mount as read/write enabled. */ +#define SCE_MT_RDONLY 0x01 /** Mount as read-only. */ +#define SCE_MT_ROBUST 0x02 /** Mount in ROBUST mode. */ +#define SCE_MT_ERRCHECK 0x04 /** Set an error if there is anythign abnormal in the file system when mounting. */ diff --git a/np9660_patch/src/lib.c b/np9660_patch/src/lib.c new file mode 100644 index 0000000..b4f0ac6 --- /dev/null +++ b/np9660_patch/src/lib.c @@ -0,0 +1,155 @@ +/* + * Copyright (C) 2014 qwikrazor87 + * + * 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 +#include "lib.h" +#include "sctrl.h" + + +static char logbuf[256]; +static u32 g_log_level; + +static void logstr(const char *str) +{ + SceUID fd = sceIoOpen("ms0:/npdrmlog.txt", 0x302, 0777); + sceIoWrite(fd, str, strlen(str)); + sceIoClose(fd); +} + +void init_log(u32 log_level) +{ + g_log_level = log_level; + if (log_level > NF_LOG_DISABLED) { + SceUID fd = sceIoOpen("ms0:/npdrmlog.txt", 0x602, 0777); + sceIoClose(fd); + } +} + +void _lprintf(const u32 log_level, const char *fmt, u32 a2, u32 a3, u32 t0, u32 t1, u32 t2, u32 t3, u32 t4, u32 t5, u32 t6, u32 t7) +{ + if (log_level <= g_log_level) { + sprintf(logbuf, fmt, a2, a3, t0, t1, t2, t3, t4, t5, t6, t7); + logstr(logbuf); + } +} + +void (* lprintf)(const u32 log_level, const char *, ...) = (void *)&_lprintf; + +void ClearCaches(void) +{ + sceKernelDcacheWritebackInvalidateAll(); + sceKernelIcacheInvalidateAll(); +} + +u32 FindTextAddrByName(const char *module) +{ + u32 kaddr; + for (kaddr = 0x88000000; kaddr < 0x88400000; kaddr += 4) { + if (strcmp((const char *)kaddr, module) == 0) { + if ((*(u32*)(kaddr + 0x64) == *(u32*)(kaddr + 0x78)) && \ + (*(u32*)(kaddr + 0x68) == *(u32*)(kaddr + 0x88))) { + if (*(u32*)(kaddr + 0x64) && *(u32*)(kaddr + 0x68)) + return *(u32*)(kaddr + 0x64); + } + } + } + return 0; +} + +u32 FindExport(const char *module, const char *library, u32 nid) +{ + u32 addr = FindTextAddrByName(module); + + if (addr) { + u32 maxaddr = 0x88400000; + + if (addr >= 0x08800000 && addr < 0x0A000000) + maxaddr = 0x0A000000; + else if (addr >= 0x08400000 && addr < 0x08800000) + maxaddr = 0x08800000; + + for (; addr < maxaddr; addr += 4) { + if (strcmp(library, (const char *)addr) == 0) { + u32 libaddr = addr; + + while (*(u32*)(addr -= 4) != libaddr); + + u32 exports = (u32)(*(u16*)(addr + 10) + *(u8*)(addr + 9)); + u32 jump = exports * 4; + + addr = *(u32*)(addr + 12); + + while (exports--) { + if (*(u32*)addr == nid) + return *(u32*)(addr + jump); + + addr += 4; + } + + return 0; + } + } + } + + return 0; +} + +void fillvram(u32 color) +{ + u32 vram; + + for (vram = 0x44000000; vram < 0x44200000; vram += 4) + _sw(color, vram); +} + +void dumpfile(const char *path, const void *data, SceSize size) +{ + SceUID fd = sceIoOpen(path, PSP_O_CREAT | PSP_O_WRONLY | PSP_O_TRUNC, 0777); + sceIoWrite(fd, data, size); + sceIoClose(fd); +} + +u32 FindImportByModule(const char *module, const char *lib, u32 nid) +{ + SceModule2 *mod = _sceKernelFindModuleByName(module); + + if (mod) { + u32 i, j, k; + + for (i = mod->text_addr; i < (mod->text_addr + mod->text_size); i += 4) { + j = _lw(i); + + if (((j & 3) == 0) && (j > mod->text_addr) && (j < (mod->text_addr + mod->text_size))) { + if (!strcmp((char *)j, lib)) { + SceLibStubTable *stub = (SceLibStubTable *)i; + + if (stub->stubtable) { + for (k = 0; k < stub->stubcount; k++) { + if (stub->nidtable[k] == nid) + return (u32)&stub->stubtable[k * 2]; + } + } + } + } + } + } + + return 0; +} diff --git a/np9660_patch/src/lib.h b/np9660_patch/src/lib.h new file mode 100644 index 0000000..7b3d85c --- /dev/null +++ b/np9660_patch/src/lib.h @@ -0,0 +1,88 @@ +/* + * Copyright (C) 2014 qwikrazor87 + * + * 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 LIB_H_ +#define LIB_H_ + +#include +#include + +#define NF_LOG_DISABLED 0 +#define NF_LOG_LITE 1 +#define NF_LOG_FULL 2 + +void init_log(u32 log_level); +void (* lprintf)(const u32 log_level, const char *, ...); + +void fillvram(u32 color); +void dumpfile(const char *path, const void *data, SceSize size); +void ClearCaches(void); + +u32 FindTextAddrByName(const char *module); +u32 FindExport(const char *module, const char *library, u32 nid); +u32 FindImportByModule(const char *module, const char *lib, u32 nid); +u32 pspSdkSetK1(u32 k1); + +#define U_EXTRACT_IMPORT(x) ((((u32)_lw((u32)x)) & ~0x08000000) << 2) +#define K_EXTRACT_IMPORT(x) (((((u32)_lw((u32)x)) & ~0x08000000) << 2) | 0x80000000) +#define U_EXTRACT_CALL(x) ((((u32)_lw((u32)x)) & ~0x0C000000) << 2) +#define K_EXTRACT_CALL(x) (((((u32)_lw((u32)x)) & ~0x0C000000) << 2) | 0x80000000) + +#define MAKE_JUMP(f) (0x08000000 | (((u32)(f) >> 2) & 0x03FFFFFF)) +#define MAKE_CALL(f) (0x0C000000 | (((u32)(f) >> 2) & 0x03FFFFFF)) + +#define MAKE_JUMP_PATCH(a, f) _sw(0x08000000 | (((u32)(f) & 0x0FFFFFFC) >> 2), a); + +#define HIJACK_FUNCTION(a, f, ptr) \ +{ \ + u32 func = a; \ + static u32 patch_buffer[3]; \ + _sw(_lw(func), (u32)patch_buffer); \ + _sw(_lw(func + 4), (u32)patch_buffer + 8);\ + MAKE_JUMP_PATCH((u32)patch_buffer + 4, func + 8); \ + _sw(0x08000000 | (((u32)(f) >> 2) & 0x03FFFFFF), func); \ + _sw(0, func + 4); \ + ptr = (void *)patch_buffer; \ +} + +static inline u32 pspGetRa(void) +{ + volatile u32 ra; + __asm("move %0, $ra" : "=r" (ra)); + return ra; +} + +int printf(const char *fmt, ...); + +int sceNpDrmGetFixedKey(u8 *version_key, u8 *name, u32 type); +int sceNpDrmGetVersionKey(u8 *version_key, u8 *act_buf, u8 *rif_buf, u32 type); + +int sceDdrdbHash(u8 *buf, int size, u8 *hash); +int sceDdrdbSigvry(u8 *pubkey, u8 *hash, u8 *sig); + +typedef struct { + const char *libname; + u8 version[2]; + u16 attribute; + u8 len; + u8 vstubcount; + u16 stubcount; + u32 *nidtable; + u32 *stubtable; +} SceLibStubTable; + +#endif /* LIB_H_ */ diff --git a/np9660_patch/src/license.h b/np9660_patch/src/license.h new file mode 100644 index 0000000..2097d3e --- /dev/null +++ b/np9660_patch/src/license.h @@ -0,0 +1,280 @@ +#ifndef _LICENSE_H +#define _LICENSE_H + +static unsigned char psp_license[] = { + 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x02, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0x55, 0x50, 0x39, 0x39, 0x39, 0x39, 0x2D, 0x41, 0x42, 0x43, 0x44, 0x39, 0x38, 0x37, 0x36, 0x35, + 0x5F, 0x30, 0x30, 0x2D, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, + 0x4D, 0x4E, 0x4F, 0x50, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0x00, 0x00, 0x01, 0x4A, 0xA5, 0x73, 0x75, 0x58, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, +}; + +static unsigned char fake_act_dat[] = { + 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xF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FF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, +}; + +#endif /* _LICENSE_H */ diff --git a/np9660_patch/src/main.c b/np9660_patch/src/main.c new file mode 100644 index 0000000..c54c0f5 --- /dev/null +++ b/np9660_patch/src/main.c @@ -0,0 +1,397 @@ +/* + * Copyright (C) 2014 qwikrazor87 + * + * 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 +#include +#include +#include "lib.h" +#include "license.h" +#include "sctrl.h" +#include "iofilemgr_kernel.h" +#include "pgd.h" + +PSP_MODULE_INFO("npdrm_free", PSP_MODULE_KERNEL, 1, 0); +PSP_HEAP_SIZE_KB(0); + +int sceNpDrmEdataSetupKey(SceUID); +int sceNpDrmEdataGetDataSize(SceUID); +int sceKernelQuerySystemCall(void *); +int sceKernelDevkitVersionForUser(void); + +#if defined(CONFIG_661) || defined(CONFIG_660) + +#define EBOOT_CALL 0x1D0 +#define LICENSE_CALL 0xED8 +#define ACT_CALL 0x1028 +#define WUT_OFFSET 0xC8 +#define FIND_MODULE_BY_ADDRESS _sceKernelFindModuleByAddress_660 +#define FIND_MODULE_BY_NAME _sceKernelFindModuleByName_660 +#define SUB_000000C8_PATCH_OFFSET 0x40 +#define STRCMP_PATCH_OFFSET 0xF2C + +#elif defined(CONFIG_620) + +#define EBOOT_CALL 0x1B8 +#define LICENSE_CALL 0xEB4 +#define ACT_CALL 0x1004 +#define WUT_OFFSET 0xB0 +#define FIND_MODULE_BY_ADDRESS _sceKernelFindModuleByAddress_620 +#define FIND_MODULE_BY_NAME _sceKernelFindModuleByName_620 +#define SUB_000000C8_PATCH_OFFSET 0x38 +#define STRCMP_PATCH_OFFSET 0xF08 + +#else + +#error "Please specify your firmware version with CONFIG_6xx" + +#endif + +static STMOD_HANDLER previous = NULL; +u32 np_text_addr = 0, np_text_size = 0; +int attempt = 0; +SceCtrlData pad; +char g_drmpath[256]; +u8 g_drmkey[256]; +u32 g_drmsize; +u8 g_pgdbuf[1024]; +SceUID g_main_fd = -1; +int load_flag = 0; +char g_main_name[32]; +u32 UserNpDrmEdataSetupKey = 0; +u32 UserNpDrmEdataGetDataSize = 0; +u32 UserIoOpen = 0; +u32 UserIoRead = 0; +u32 UserIoClose = 0; +int sceNp9660_driver_loaded = 0; + +u32 g_has_version_key = 0; +u8 g_version_key[0x10]; + +int sceKernelStoreSyscall(void *func, u32 addr) +{ + int ret = sceKernelQuerySystemCall(func); + + if (ret > 0) { + _sw(0x03E00008, addr); + _sw(((ret << 6) | 12) & 0x03FFFFFF, addr + 4); + + sceKernelDcacheWritebackInvalidateRange((const void *)addr, 8); + sceKernelIcacheInvalidateRange((const void *)addr, 8); + } + + return ret; +} + +void logracall(u32 ra) +{ + lprintf(NF_LOG_FULL, "\nsceNp9660_driver + 0x%08X\n", ra - np_text_addr - 8); +} + +int npNpDrmGetVersionKey(u8 *version_key, u8 *act_buf, u8 *rif_buf, u32 type) +{ + logracall(pspGetRa()); + + memcpy(rif_buf + 8, act_buf + 8, 8); + + int ret = sceNpDrmGetVersionKey(version_key, act_buf, rif_buf, type); + + if (g_has_version_key) { + memcpy(version_key, g_version_key, 0x10); + } + + lprintf(NF_LOG_FULL, "sceNpDrmGetVersionKey(0x%08X, 0x%08X, 0x%08X, 0x%08X);\nret: 0x%08X\n", version_key, act_buf, rif_buf, type, ret); + + return 0; +} + +SceUID npIoOpen(const char *path, int flags, SceMode mode) +{ + u32 ra = pspGetRa(); + + logracall(ra); + + SceUID ret = sceIoOpen(path, flags, mode); + + if ((ret >= 0) && ((ra - np_text_addr - 8) == EBOOT_CALL)) { + SceUID ebootfd = ret; + + u32 psar_offset; + sceIoLseek32(ebootfd, 0x24, PSP_SEEK_SET); + sceIoRead(ebootfd, &psar_offset, 4); + + u8 buffer[0xC0]; + sceIoLseek32(ebootfd, psar_offset, PSP_SEEK_SET); + sceIoRead(ebootfd, buffer, 0xC0); + sceIoLseek32(ebootfd, 0, PSP_SEEK_SET); + + MAC_KEY mkey; + u8 *mkey_p = (u8*) &mkey; + sceDrmBBMacInit(mkey_p, 3); + sceDrmBBMacUpdate(mkey_p, buffer, 0xC0); + get_version_key(ebootfd, mkey_p, g_version_key); + g_has_version_key = 1; + } + + if ((u32)ret == 0x80010002) { + u32 license_call = 0, act_call = 0; + + license_call = LICENSE_CALL; + act_call = ACT_CALL; + + if ((ra - np_text_addr - 8) == license_call) { //.rif license + ret = sceIoOpen(path, PSP_O_CREAT | PSP_O_WRONLY | PSP_O_TRUNC, 0777); + sceIoWrite(ret, psp_license, sizeof(psp_license)); + sceIoClose(ret); + + ret = sceIoOpen(path, flags, mode); + } else if ((ra - np_text_addr - 8) == act_call) { //act.dat + sceIoUnassign("flash2:"); + sceIoAssign("flash2:", "lflash0:0,2", "flashfat2:", IOASSIGN_RDWR, NULL, 0); + + ret = sceIoOpen("flash2:/act.dat", PSP_O_CREAT | PSP_O_WRONLY | PSP_O_TRUNC | 0x04000000, 0777); + sceIoWrite(ret, fake_act_dat, sizeof(fake_act_dat)); + sceIoClose(ret); + + sceIoUnassign("flash2:"); + sceIoAssign("flash2:", "lflash0:0,2", "flashfat2:", IOASSIGN_RDONLY, NULL, 0); + + ret = sceIoOpen(path, flags, mode); + } + } + + lprintf(NF_LOG_FULL, "sceIoOpen(\"%s\", 0x%X, 0x%X);\nret: 0x%08X\n", path, flags, mode, ret); + + return ret; +} + +int sub_000000C8(const char *eboot, u32 a1) +{ + logracall(pspGetRa()); + + int (* wut)(const char *, u32) = (void *)0; + + wut = (void *)(np_text_addr + WUT_OFFSET); + + int ret = wut(eboot, a1); + + lprintf(NF_LOG_FULL, "sub_000000C8(\"%s\", 0x%08X);\nret: 0x%08X\n", eboot, a1, ret); + + return ret; +} + +void patch_np9660(u32 text_addr, u32 text_size) +{ + sceNp9660_driver_loaded = 1; + + _sceKernelFindModuleByAddress = (void *)FIND_MODULE_BY_ADDRESS ; + _sceKernelFindModuleByName = (void *)FIND_MODULE_BY_NAME ; + + sceCtrlPeekBufferPositive(&pad, 1); + + init_log(NF_LOG_DISABLED); + //if (pad.Buttons & PSP_CTRL_CROSS) { + // init_log(NF_LOG_FULL); + //} else { + // init_log(NF_LOG_DISABLED); + //} + + np_text_addr = text_addr; + np_text_size = text_size; + + const char *sceNp9660_driver = "sceNp9660_driver"; + + u32 _IoOpen = FindImportByModule(sceNp9660_driver, "IoFileMgrForKernel", 0x109F50BC); + _sw(MAKE_JUMP(npIoOpen), _IoOpen); + u32 _NpDrmGetVersionKey = FindImportByModule(sceNp9660_driver, "scePspNpDrm_driver", 0x0F9547E6); + _sw(MAKE_JUMP(npNpDrmGetVersionKey), _NpDrmGetVersionKey); + + _sw(MAKE_CALL(sub_000000C8), np_text_addr + SUB_000000C8_PATCH_OFFSET); + + //patch strcmp check on license name + _sw(0x24020000, np_text_addr + STRCMP_PATCH_OFFSET); //li $v0, 0 + + ClearCaches(); +} + +int sceNpDrmFreeEdataSetupKey(SceUID fd) +{ + int ret = sceNpDrmEdataSetupKey(fd); + + if (ret < 0) { + u32 k1 = pspSdkSetK1(0); + + SceUID g_fd = sceIoOpen(g_drmpath, PSP_O_RDONLY, 0777); + + u8 header[8]; + + sceIoRead(g_fd, header, 8); + + if (!memcmp(header, "\0PSPEDAT", 8)) { + sceIoLseek(g_fd, 0x80, PSP_SEEK_SET); + + sceIoRead(g_fd, header, 4); + + if (!memcmp(header, "\0PGD", 4)) { + u32 size = sceIoLseek(g_fd, 0, PSP_SEEK_END) - 0x80; + + sceIoLseek(g_fd, 0x80, PSP_SEEK_SET); + + sceIoRead(g_fd, g_pgdbuf, size); + + g_drmsize = pgd_decrypt(g_pgdbuf, size, 2, NULL); + + if (g_drmsize > 0) { + memcpy(g_drmkey, g_pgdbuf + 0x90, g_drmsize); + + ret = 0; + } + } + } + + sceIoClose(g_fd); + + pspSdkSetK1(k1); + } + + return ret; +} + +int sceNpDrmFreeEdataGetDataSize(SceUID fd) +{ + int ret = sceNpDrmEdataGetDataSize(fd); + + if (ret < 0) + ret = g_drmsize; + + return ret; +} + +SceUID sceNpDrmFreeOpen(const char *path, int flags, SceMode mode) +{ + SceUID fd = sceIoOpen(path, flags, mode); + + if ((flags & 0x40000000) && (fd > 0)) { + strcpy(g_drmpath, path); + g_main_fd = fd; + } + + return fd; +} + +int sceNpDrmFreeRead(SceUID fd, void *data, SceSize size) +{ + int ret = sceIoRead(fd, data, size); + + if ((ret < 0) && (fd == g_main_fd)) { + memcpy(data, g_drmkey, g_drmsize); + + ret = g_drmsize; + } + + return ret; +} + +int sceNpDrmFreeClose(SceUID fd) +{ + if (fd == g_main_fd) + g_main_fd = -1; + + return sceIoClose(fd); +} + +void patch_main_module() +{ + if (!UserNpDrmEdataSetupKey) + UserNpDrmEdataSetupKey = FindImportByModule(g_main_name, "scePspNpDrm_user", 0x08D98894); + + if (UserNpDrmEdataSetupKey) + sceKernelStoreSyscall(sceNpDrmFreeEdataSetupKey, UserNpDrmEdataSetupKey); + + if (!UserNpDrmEdataGetDataSize) + UserNpDrmEdataGetDataSize = FindImportByModule(g_main_name, "scePspNpDrm_user", 0x219EF5CC); + + if (UserNpDrmEdataGetDataSize) + sceKernelStoreSyscall(sceNpDrmFreeEdataGetDataSize, UserNpDrmEdataGetDataSize); + + if (UserNpDrmEdataSetupKey) { + if (!UserIoOpen) + UserIoOpen = FindImportByModule(g_main_name, "IoFileMgrForUser", 0x109F50BC); + + if (UserIoOpen) + sceKernelStoreSyscall(sceNpDrmFreeOpen, UserIoOpen); + + if (!UserIoRead) + UserIoRead = FindImportByModule(g_main_name, "IoFileMgrForUser", 0x6A638D83); + + if (UserIoRead) + sceKernelStoreSyscall(sceNpDrmFreeRead, UserIoRead); + + if (!UserIoClose) + UserIoClose = FindImportByModule(g_main_name, "IoFileMgrForUser", 0x810C4BC3); + + if (UserIoClose) + sceKernelStoreSyscall(sceNpDrmFreeClose, UserIoClose); + } + + ClearCaches(); +} + +int module_start_handler(SceModule2 * module) +{ + int ret = previous ? previous(module) : 0; + + if (load_flag >= 1) { + if (load_flag == 1) { + strcpy(g_main_name, module->modname); + load_flag = 2; + } + + patch_main_module(); + } + + if (!strcmp(module->modname, "sceNp9660_driver")) + patch_np9660(module->text_addr, module->text_size); + else if ((sceNp9660_driver_loaded == 1) && !strcmp(module->modname, "sceKernelLibrary")) + load_flag = 1; + + return ret; +} + +int thread_start(SceSize args __attribute__((unused)), void *argp __attribute__((unused))) +{ + previous = sctrlHENSetStartModuleHandler(module_start_handler); + + return 0; +} + +int module_start(SceSize args, void *argp) +{ + SceUID thid = sceKernelCreateThread("npdrm_free", thread_start, 0x22, 0x2000, 0, NULL); + + if (thid >= 0) + sceKernelStartThread(thid, args, argp); + + return 0; +} + +int module_stop(SceSize args __attribute__((unused)), void *argp __attribute__((unused))) +{ + return 0; +} diff --git a/np9660_patch/src/pgd.c b/np9660_patch/src/pgd.c new file mode 100644 index 0000000..4f05ee8 --- /dev/null +++ b/np9660_patch/src/pgd.c @@ -0,0 +1,233 @@ +/* + * dnas.c -- Reverse engineering of iofilemgr_dnas.prx + * written by tpu. + */ + +#include +#include +#include + +#include "pgd.h" + +/*************************************************************/ + +u8 dnas_key1A90[16] = { 0xED, 0xE2, 0x5D, 0x2D, 0xBB, 0xF8, 0x12, 0xE5, 0x3C, 0x5C, 0x59, 0x32, 0xFA, 0xE3, 0xE2, 0x43 }; +u8 dnas_key1AA0[16] = { 0x27, 0x74, 0xFB, 0xEB, 0xA4, 0xA0, 0x01, 0xD7, 0x02, 0x56, 0x9E, 0x33, 0x8C, 0x19, 0x57, 0x83 }; + +extern SceUID ebootfd; + +PGD_DESC g_pgd; +u8 kirk_buf[0x814]; + +int kirk7(u8 *buf, int size, int type) +{ + int retv; + u32 *header = (u32*)buf; + + header[0] = 5; + header[1] = 0; + header[2] = 0; + header[3] = type; + header[4] = size; + + retv = sceUtilsBufferCopyWithRange(buf, size + 0x14, buf, size, 7); + + if (retv) + return 0x80510311; + + return 0; +} + +int get_version_key(SceUID ebootfd, u8 *mac_key, u8 *version_key) +{ + int i, retv, type, code; + u8 *kbuf, tmp[16], tmp1[16]; + + MAC_KEY *mkey = (MAC_KEY *)mac_key; + u32 psar; + u8 bbmac[16]; + + SceOff pos = sceIoLseek32(ebootfd, 0, PSP_SEEK_CUR); + sceIoLseek32(ebootfd, 0x24, PSP_SEEK_SET); + sceIoRead(ebootfd, &psar, 4); + sceIoLseek32(ebootfd, psar + 0xC0, PSP_SEEK_SET); + sceIoRead(ebootfd, bbmac, 16); + sceIoLseek32(ebootfd, pos, PSP_SEEK_SET); + + type = mkey->type; + retv = sceDrmBBMacFinal(mac_key, tmp, NULL); + + if (retv) + return retv; + + kbuf = kirk_buf + 0x14; + + // decrypt bbmac + if (type == 3) { + memcpy(kbuf, bbmac, 0x10); + kirk7(kirk_buf, 0x10, 0x63); + } else + memcpy(kirk_buf, bbmac, 0x10); + + memcpy(tmp1, kirk_buf, 16); + memcpy(kbuf, tmp1, 16); + + code = (type == 2) ? 0x3A : 0x38; + kirk7(kirk_buf, 0x10, code); + + for (i = 0; i < 0x10; i++) + version_key[i] = tmp[i] ^ kirk_buf[i]; + + return 0; +} + +int bbmac_getkey(MAC_KEY *mkey, u8 *bbmac, u8 *vkey) +{ + int i, retv, type, code; + u8 *kbuf, tmp[16], tmp1[16]; + + type = mkey->type; + retv = sceDrmBBMacFinal((u8 *)mkey, tmp, NULL); + + if (retv) + return retv; + + kbuf = kirk_buf + 0x14; + + // decrypt bbmac + if (type == 3) { + memcpy(kbuf, bbmac, 0x10); + kirk7(kirk_buf, 0x10, 0x63); + } else + memcpy(kirk_buf, bbmac, 0x10); + + memcpy(tmp1, kirk_buf, 16); + memcpy(kbuf, tmp1, 16); + + code = (type == 2) ? 0x3A : 0x38; + kirk7(kirk_buf, 0x10, code); + + for (i = 0; i < 0x10; i++) + vkey[i] = tmp[i] ^ kirk_buf[i]; + + return 0; +} + +PGD_DESC *pgd_open(u8 *pgd_buf, int pgd_flag, u8 *pgd_vkey) +{ + PGD_DESC *pgd; + MAC_KEY mkey; + CIPHER_KEY ckey; + u8 *fkey; + int retv; + + pgd = &g_pgd; + memset(pgd, 0, sizeof(PGD_DESC)); + + pgd->buf = pgd_buf; + pgd->key_index = *(u32*)(pgd_buf + 4); + pgd->drm_type = *(u32*)(pgd_buf + 8); + + if (pgd->drm_type == 1) { + pgd->mac_type = 1; + pgd_flag |= 4; + + if (pgd->key_index > 1) { + pgd->mac_type = 3; + pgd_flag |= 8; + } + + pgd->cipher_type = 1; + } else { + pgd->mac_type = 2; + pgd->cipher_type = 2; + } + + pgd->open_flag = pgd_flag; + + // select fixed key + fkey = NULL; + + if (pgd_flag & 2) + fkey = dnas_key1A90; + + if (pgd_flag & 1) + fkey = dnas_key1AA0; + + if (fkey == NULL) + return NULL; + + // MAC_0x80 check + sceDrmBBMacInit((u8 *)&mkey, pgd->mac_type); + sceDrmBBMacUpdate((u8 *)&mkey, pgd_buf, 0x80); + retv = sceDrmBBMacFinal2((u8 *)&mkey, pgd_buf + 0x80, fkey); + + if (retv) + return NULL; + + // MAC_0x70 + sceDrmBBMacInit((u8 *)&mkey, pgd->mac_type); + sceDrmBBMacUpdate((u8 *)&mkey, pgd_buf, 0x70); + + if (pgd_vkey) { + // use given vkey + retv = sceDrmBBMacFinal2((u8 *)&mkey, pgd_buf + 0x70, pgd_vkey); + + if (retv) + return NULL; + else + memcpy(pgd->vkey, pgd_vkey, 16); + } else { + // get vkey from MAC_70 + bbmac_getkey(&mkey, pgd_buf + 0x70, pgd->vkey); + } + + // decrypt PGD_DESC + sceDrmBBCipherInit((u8 *)&ckey, pgd->cipher_type, 2, pgd_buf + 0x10, pgd->vkey, 0); + sceDrmBBCipherUpdate((u8 *)&ckey, pgd_buf + 0x30, 0x30); + sceDrmBBCipherFinal((u8 *)&ckey); + + pgd->data_size = *(u32*)(pgd_buf + 0x44); + pgd->block_size = *(u32*)(pgd_buf + 0x48); + pgd->data_offset = *(u32*)(pgd_buf + 0x4C); + + pgd->align_size = (pgd->data_size + 15) & ~15; + pgd->table_offset = pgd->data_offset + pgd->align_size; + pgd->block_nr = (pgd->align_size + pgd->block_size - 1) & ~(pgd->block_size - 1); + pgd->block_nr = pgd->block_nr / pgd->block_size; + + return pgd; +} + +int pgd_decrypt(u8 *pgd_buf, int pgd_size, int pgd_flag, u8 *pgd_vkey) +{ + PGD_DESC *pgd; + MAC_KEY mkey; + CIPHER_KEY ckey; + int retv; + + + pgd = pgd_open(pgd_buf, pgd_flag, pgd_vkey); + + if (pgd == NULL) + return -1; + + if ((pgd->align_size + pgd->block_nr * 16) > pgd_size) + return -3; + + + // table MAC check + sceDrmBBMacInit((u8 *)&mkey, pgd->mac_type); + sceDrmBBMacUpdate((u8 *)&mkey, pgd_buf + pgd->table_offset, pgd->block_nr * 16); + retv = sceDrmBBMacFinal2((u8 *)&mkey, pgd_buf + 0x60, pgd->vkey); + + if (retv) + return -4; + + // decrypt data + sceDrmBBCipherInit((u8 *)&ckey, pgd->cipher_type, 2, pgd_buf + 0x30, pgd->vkey, 0); + sceDrmBBCipherUpdate((u8 *)&ckey, pgd_buf + 0x90, pgd->align_size); + sceDrmBBCipherFinal((u8 *)&ckey); + + return pgd->data_size; +} diff --git a/np9660_patch/src/pgd.h b/np9660_patch/src/pgd.h new file mode 100644 index 0000000..6ed2b8a --- /dev/null +++ b/np9660_patch/src/pgd.h @@ -0,0 +1,57 @@ +#ifndef _PGD_H +#define _PGD_H + +#include + +typedef struct { + int type; + u8 key[16]; + u8 pad[16]; + int pad_size; +} MAC_KEY; + +typedef struct +{ + u32 type; + u32 seed; + u8 key[16]; +} CIPHER_KEY; + +typedef struct { + u8 vkey[16]; + + int open_flag; + int key_index; + int drm_type; + int mac_type; + int cipher_type; + + int data_size; + int align_size; + int block_size; + int block_nr; + int data_offset; + int table_offset; + + u8 *buf; +} PGD_DESC; + +int sceDrmBBMacInit(u8 *mac_key, int type); +int sceDrmBBMacUpdate(u8 *mac_key, u8 *buf, int size); +int sceAmctrl_driver_9227EA79(u8 *mac_key, u8 *buf, int size); +int sceDrmBBMacFinal(u8 *mac_key, u8 *buf, u8 *version_key); +int sceDrmBBMacFinal2(u8 *mac_key, u8 *buf, u8 *version_key); + +int sceDrmBBCipherInit(u8 *cipher_key, int type, int mode, u8 *header_key, u8 *version_key, int seed); +int sceDrmBBCipherUpdate(u8 *cipher_key, u8 *buf, int size); +int sceAmctrl_driver_E04ADD4C(u8 *cipher_key, u8 *buf, int size); +int sceDrmBBCipherFinal(u8 *cipher_key); + +int sceUtilsBufferCopyWithRange(u8 *outbuf, int outlen, u8 *inbuf, int inlen, int cmd); + +int kirk7(u8 *buf, int size, int type); + +int pgd_decrypt(u8 *pgd_buf, int pgd_size, int pgd_flag, u8 *pgd_vkey); +int get_version_key(SceUID ebootfd, u8 *mac_key, u8 *version_key); + +#endif /* _PGD_H */ diff --git a/np9660_patch/src/sctrl.h b/np9660_patch/src/sctrl.h new file mode 100644 index 0000000..d527e3e --- /dev/null +++ b/np9660_patch/src/sctrl.h @@ -0,0 +1,87 @@ +/* + * Copyright (C) 2014 qwikrazor87 + * + * 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 _SCTRL_H +#define _SCTRL_H + +#include + +typedef struct SceModule2 +{ + struct SceModule2* next; //0, 0x00 + u16 attribute; //4, 0x04 + u8 version[2]; //6, 0x06 + char modname[27]; //8, 0x08 + char terminal; //35, 0x23 + u16 status; //36, 0x24 (Used in modulemgr for stage identification) + u16 padding; //38, 0x26 + u32 unk_28; //40, 0x28 + SceUID modid; //44, 0x2C + SceUID usermod_thid; //48, 0x30 + SceUID memid; //52, 0x34 + SceUID mpidtext; //56, 0x38 + SceUID mpiddata; //60, 0x3C + void * ent_top; //64, 0x40 + u32 ent_size; //68, 0x44 + void * stub_top; //72, 0x48 + u32 stub_size; //76, 0x4C + int (* module_start)(SceSize, void *); //80, 0x50 + int (* module_stop)(SceSize, void *); //84, 0x54 + int (* module_bootstart)(SceSize, void *); //88, 0x58 + int (* module_reboot_before)(void *); //92, 0x5C + int (* module_reboot_phase)(SceSize, void *); //96, 0x60 + u32 entry_addr; //100, 0x64(seems to be used as a default address) + u32 gp_value; //104, 0x68 + u32 text_addr; //108, 0x6C + u32 text_size; //112, 0x70 + u32 data_size; //116, 0x74 + u32 bss_size; //120, 0x78 + u8 nsegment; //124, 0x7C + u8 padding2[3]; //125, 0x7D + u32 segmentaddr[4]; //128, 0x80 + u32 segmentsize[4]; //144, 0x90 + int module_start_thread_priority; //160, 0xA0 + SceSize module_start_thread_stacksize; //164, 0xA4 + SceUInt module_start_thread_attr; //168, 0xA8 + int module_stop_thread_priority; //172, 0xAC + SceSize module_stop_thread_stacksize; //176, 0xB0 + SceUInt module_stop_thread_attr; //180, 0xB4 + int module_reboot_before_thread_priority; //184, 0xB8 + SceSize module_reboot_before_thread_stacksize; //188, 0xBC + SceUInt module_reboot_before_thread_attr; //192, 0xC0 +} SceModule2; + +enum BootLoadFlags +{ + BOOTLOAD_VSH = 1, + BOOTLOAD_GAME = 2, + BOOTLOAD_UPDATER = 4, + BOOTLOAD_POPS = 8, + BOOTLOAD_UMDEMU = 64, /* for original NP9660 */ +}; + +typedef int (* STMOD_HANDLER)(SceModule2 *); +STMOD_HANDLER sctrlHENSetStartModuleHandler(STMOD_HANDLER handler); +void sctrlHENLoadModuleOnReboot(char *module_before, void *buf, int size, int flags); +SceModule2 *(* _sceKernelFindModuleByAddress)(u32); +SceModule2 *(* _sceKernelFindModuleByName)(const char *); +SceModule2 *_sceKernelFindModuleByAddress_620(u32); +SceModule2 *_sceKernelFindModuleByAddress_660(u32); +SceModule2 *_sceKernelFindModuleByName_620(const char *); +SceModule2 *_sceKernelFindModuleByName_660(const char *); + +#endif /* _SCTRL_H */ diff --git a/np9660_patch/src/setk1.S b/np9660_patch/src/setk1.S new file mode 100644 index 0000000..e2be14b --- /dev/null +++ b/np9660_patch/src/setk1.S @@ -0,0 +1,12 @@ + .set noreorder + + .global pspSdkSetK1 + + .ent pspSdkSetK1 +pspSdkSetK1: + move $v0, $k1 + jr $ra + move $k1, $a0 + .end pspSdkSetK1 + + .set reorder