<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>modding &#8211; Saki&#039;s Romhacking Shenanigans</title>
	<atom:link href="https://sakimotor.github.io/tag/modding/feed/" rel="self" type="application/rss+xml" />
	<link>https://sakimotor.github.io</link>
	<description>It is what it is!</description>
	<lastBuildDate>Wed, 01 Feb 2023 00:58:21 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.2.2</generator>
	<item>
		<title>Modding The Silver Case (Part 3): Replacing &#038; Distributing the mod</title>
		<link>https://sakimotor.github.io/2023/01/30/modding-the-silver-case-part-3-replacing-distributing-the-mod/</link>
					<comments>https://sakimotor.github.io/2023/01/30/modding-the-silver-case-part-3-replacing-distributing-the-mod/#disqus_thread</comments>
		
		<dc:creator><![CDATA[sakicore]]></dc:creator>
		<pubDate>Mon, 30 Jan 2023 21:11:29 +0000</pubDate>
				<category><![CDATA[Modding]]></category>
		<category><![CDATA[Repacking]]></category>
		<category><![CDATA[afr]]></category>
		<category><![CDATA[modding]]></category>
		<category><![CDATA[patching]]></category>
		<category><![CDATA[ps4]]></category>
		<category><![CDATA[xdelta]]></category>
		<guid isPermaLink="false">https://sakimotor.github.io/?p=67</guid>

					<description><![CDATA[The final step into modding the game: replace the files on the console!]]></description>
										<content:encoded><![CDATA[
<p>Welcome to the final part of my series of post focused on the modding of a <em>PS4 </em>game!</p>



<p>Since we&#8217;re approaching the end, allow me to rant a bit about a detail that would&#8217;ve saved me a fair amount of time if I knew about it beforehand.</p>



<p>As I already noticed in <a href="https://twitter.com/SakiMeguro/status/1342147956343005186" data-type="URL" data-id="https://twitter.com/SakiMeguro/status/1342147956343005186">2020</a>, <em>PS4 </em>games are encrypted inside .<em>PKG </em>files even once they are installed, and the only way to decrypt them is by booting the game up on the console. </p>



<figure class="wp-block-image size-full"><img decoding="async" width="833" height="126" src="https://sakimotor.github.io/wp-content/uploads/2023/01/EqBEVFFXAAA0vib.png" alt="" class="wp-image-69" srcset="https://sakimotor.github.io/wp-content/uploads/2023/01/EqBEVFFXAAA0vib.png 833w, https://sakimotor.github.io/wp-content/uploads/2023/01/EqBEVFFXAAA0vib-300x45.png 300w, https://sakimotor.github.io/wp-content/uploads/2023/01/EqBEVFFXAAA0vib-768x116.png 768w" sizes="(max-width: 833px) 100vw, 833px" /><figcaption class="wp-element-caption"><em>The game&#8217;s folder on the PS4, as seen by connecting through FTP. The whole game is encrypted and gets decrypted only on runtime.</em></figcaption></figure>



<p>As such, one would think that, in order to mod a <em>PS4 </em>game, we would need to repack the whole <em>Fake PKG </em>and reinstall it each time we modify a file. That&#8217;s what I did for my first dozen of tries, and the process was <strong><em>TEDIOUS</em></strong>! Imagine doing the whole process of <a href="https://sakimotor.github.io/2023/01/26/modding-the-silver-case-ps4-part-1-dumping-reinstalling/" data-type="post" data-id="23">Part 1</a> each time a mere file was modified, the waste of time was absolute between the <em>PKG </em>repacking (about 30 minutes), the transfer to USB (5-10 minutes), the actual installation (10 minutes) and finally booting the game up: a whole hour of <strong><em>NOTHING</em></strong>, urgh. </p>



<p>I thought I could finally seek salvation after finding out about <a href="https://www.psxhax.com/threads/ps4-patch-builder-for-building-modded-update-pkgs-by-modded-warfare.7112/page-11" data-type="URL" data-id="https://www.psxhax.com/threads/ps4-patch-builder-for-building-modded-update-pkgs-by-modded-warfare.7112/page-11">PS4 Patch Builder</a> but nope, it was the same, perhaps even worse. In order to use the program I needed a <strong>backup </strong>of the whole game as a <em>PKG</em> and an <em>Image0</em> folder with all my <strong>modded files</strong>, and, for some reason, the program didn&#8217;t function if said folder didn&#8217;t also have all the other files, which means that I know had the equivalent of two backups occupying my space for nothing! After hitting that <em>Build Package</em> button it would take around half an hour to generate the &#8220;Update&#8221; <em>PKG</em> so really there wasn&#8217;t much benefit to using that method, if not to generate a <em>slightly</em> tinier <em>PKG </em>than before, at the expense of having 3 copies of the game lying on my Hard Drive with no benefits.</p>



<figure class="wp-block-image size-full"><img decoding="async" width="901" height="521" src="https://sakimotor.github.io/wp-content/uploads/2023/01/FXdPyzVXgAMq_t4.jpg" alt="" class="wp-image-70" srcset="https://sakimotor.github.io/wp-content/uploads/2023/01/FXdPyzVXgAMq_t4.jpg 901w, https://sakimotor.github.io/wp-content/uploads/2023/01/FXdPyzVXgAMq_t4-300x173.jpg 300w, https://sakimotor.github.io/wp-content/uploads/2023/01/FXdPyzVXgAMq_t4-768x444.jpg 768w" sizes="(max-width: 901px) 100vw, 901px" /><figcaption class="wp-element-caption"><em>A screenshot of the program, provided by its creator, <strong>MODDED WARFARE.</strong></em></figcaption></figure>



<p></p>



<p>Now that this is out of my way, allow me to introduce you to the actual way of modding a <em>PS4</em> game, the Holy Grail of modding, a technique similar to the Switch&#8217;s <em><a href="https://yuzu-emu.org/help/feature/game-modding/" data-type="URL" data-id="https://yuzu-emu.org/help/feature/game-modding/">LayeredFS</a></em> file replacement: <em><strong><a href="https://www.psxhax.com/threads/ps4-frame4-afr-application-file-redirector-tutorial-by-deathrgh.13356/" data-type="URL" data-id="https://www.psxhax.com/threads/ps4-frame4-afr-application-file-redirector-tutorial-by-deathrgh.13356/">AFR</a></strong></em> (<em>Application File Redirector)</em>! I will speak exclusively about <em><strong>GoldHEN</strong></em>&#8216;s implementation of it (as a <em>plugin)</em>, but it was originally made by  <strong><em>theorywrong</em></strong> for the <em><a href="https://github.com/OpenOrbis/mira-project" data-type="URL" data-id="https://github.com/OpenOrbis/mira-project">Mira Project</a></em>.</p>



<figure class="wp-block-image size-large"><img decoding="async" width="1024" height="573" src="https://sakimotor.github.io/wp-content/uploads/2023/01/ps4-goldhen-v23-avec-ps4-homebrew-enabler-game-patches-et-afr-plugins-1024x573.png" alt="" class="wp-image-72" srcset="https://sakimotor.github.io/wp-content/uploads/2023/01/ps4-goldhen-v23-avec-ps4-homebrew-enabler-game-patches-et-afr-plugins-1024x573.png 1024w, https://sakimotor.github.io/wp-content/uploads/2023/01/ps4-goldhen-v23-avec-ps4-homebrew-enabler-game-patches-et-afr-plugins-300x168.png 300w, https://sakimotor.github.io/wp-content/uploads/2023/01/ps4-goldhen-v23-avec-ps4-homebrew-enabler-game-patches-et-afr-plugins-768x430.png 768w, https://sakimotor.github.io/wp-content/uploads/2023/01/ps4-goldhen-v23-avec-ps4-homebrew-enabler-game-patches-et-afr-plugins.png 1425w" sizes="(max-width: 1024px) 100vw, 1024px" /><figcaption class="wp-element-caption"><em>GoldHEN&#8217;s plugins usage guide.</em></figcaption></figure>



<p></p>



<p>As its name indicates, while the game is running, <em>AFR </em>replaces the games files with the ones we&#8217;ve put in a custom folder, eliminating all needs from repacking the <em>PKG</em> each time we want to edit a file. This method <strong>works with disc copies and legit PKGs</strong>!</p>



<p>The first thing we need to do is to download the<em> GoldHEN plugins</em> from the <strong><em><a href="https://github.com/GoldHEN/GoldHEN_Plugins_Repository" data-type="URL" data-id="https://github.com/GoldHEN/GoldHEN_Plugins_Repository">GitHub</a></em></strong> repository. Once downloaded, we need to edit the <strong><em>plugins.ini</em> </strong>file to enable the <em>plugins </em>we are going to use, and to tell which games we are going to load the <em>plugins</em> for. As I want to apply the <em>plugins</em> to any game, the file would look like this: </p>



<div class="hcb_wrap"><pre class="prism line-numbers lang-plain"><code>; Note: lines starting with semicolon are for comments.
; Load plugins for any title.

[default]
; Load the AFR plugin 
/data/GoldHEN/plugins/afr.prx

; Load plugins only for Playroom.

[CUSA00001]
/data/GoldHEN/plugins/afr.prx
/data/GoldHEN/plugins/no_share_watermark.prx</code></pre></div>



<p></p>



<p>With the  .ini file modified, it&#8217;s time to put the <em>plugins.ini</em> file and the <em>plugins </em>folder in your<em> PS4</em>, into the <em><code><strong>/data/GoldHEN/plugins/</strong></code>  </em>folder (we can do that by USB or by FTP).</p>



<p>Now, we can run <em>GoldHEN</em> and enable the plugins in the <em>Settings &gt; Debug Settings &gt; Plugins &gt; Enable Plugins Loader </em> section.</p>


<div class="wp-block-image">
<figure class="aligncenter size-full"><img decoding="async" width="655" height="367" src="https://sakimotor.github.io/wp-content/uploads/2023/01/image-4.png" alt="" class="wp-image-75" srcset="https://sakimotor.github.io/wp-content/uploads/2023/01/image-4.png 655w, https://sakimotor.github.io/wp-content/uploads/2023/01/image-4-300x168.png 300w" sizes="(max-width: 655px) 100vw, 655px" /><figcaption class="wp-element-caption"><em>Enabling the Plugins Loader.</em></figcaption></figure></div>


<p></p>



<p>For each game we want to modify, we simply need to create a folder bearing the game&#8217;s <em><strong>TitleID</strong></em> inside of <em><code><strong>/data/GoldHEN/plugins/AFR</strong></code></em>, and place all of our modified files here.</p>



<p>If everything was done correctly, we  will see the difference each time we boot up the games with <em>AFR </em>enabled.</p>



<p></p>


<div class="wp-block-image">
<figure class="aligncenter size-large"><img decoding="async" width="1024" height="576" src="https://sakimotor.github.io/wp-content/uploads/2023/01/3-PS4-TheSilverCase-20230126232619-YouTube-0-18-1024x576.jpeg" alt="" class="wp-image-76" srcset="https://sakimotor.github.io/wp-content/uploads/2023/01/3-PS4-TheSilverCase-20230126232619-YouTube-0-18-1024x576.jpeg 1024w, https://sakimotor.github.io/wp-content/uploads/2023/01/3-PS4-TheSilverCase-20230126232619-YouTube-0-18-300x169.jpeg 300w, https://sakimotor.github.io/wp-content/uploads/2023/01/3-PS4-TheSilverCase-20230126232619-YouTube-0-18-768x432.jpeg 768w, https://sakimotor.github.io/wp-content/uploads/2023/01/3-PS4-TheSilverCase-20230126232619-YouTube-0-18.jpeg 1280w" sizes="(max-width: 1024px) 100vw, 1024px" /><figcaption class="wp-element-caption"><em>The Silver Case&#8217;s intro, replaced with Andrea Bruno&#8217;s </em><a href="https://twitter.com/baronunread/status/1318294022885093378">Sumio Mondo THUG Pro Mod Trailer</a>.</figcaption></figure></div>


<p></p>



<p>There are a few ways of distributing our modded data to the public, each with their pros and cons:</p>



<ul>
<li>The most <em><strong>user-friendly</strong></em> way would be by <strong>repackaging the whole game</strong> and <strong>uploading the PKG</strong> on the internet: anyone with a jailbroken console could install it, but it&#8217;s not only expensive in terms of space usage (we upload the whole game), but also obviously clearly illegal (<em>we upload the whole game</em>). I would not recommend using that as an option, especially if you want your mod project to be publicly available.</li>
</ul>



<ul>
<li>Another way would be by <strong>generating a custom update<em> </em></strong>so we would only need to distribute the files that we modified through a <em>Fake PKG</em>. Unfortunately, this method requires the user to dump their game and reinstall it as a <em>Fake PKG</em>, which isn&#8217;t optimal.</li>
</ul>



<ul>
<li>The best <em><strong>compromise between legality and ease of use</strong></em> would be the <strong>AFR </strong>we mentionted before: we only need to distribute the edited files, which the user can then copy to their console in the <em><code><strong>/data/GoldHEN/plugins/AFR/CUSAXXXX</strong></code></em>folder. </li>
</ul>



<ul>
<li>Even <em><strong>better </strong></em>legally, by using <em>Delta Patching</em> tools, such as <strong><em><a href="https://www.romhacking.net/utilities/598/">xdelta </a></em></strong>or <strong><em><a href="https://github.com/Moodkiller/xdelta3-gui-2.0" data-type="URL" data-id="https://github.com/Moodkiller/xdelta3-gui-2.0">xdelta3</a></em></strong>, instead of distributing the files directly, you can distribute patches that will <strong>modify the original files</strong> with the new data, which means the user would have to own their own dump, and that we don&#8217;t technically upload any (usable as a standalone) illegal content. </li>
</ul>



<ul>
<li>Another advantage is is that by only distributing the patched part of a file, we can drastically reduce the size of the patch we are going to share! Be warned though, this method requires the user to apply the patches <strong>by themselves</strong> before obtaining the modded file, and that an xdelta patch (to my knowledge) is applied to a <strong>single file</strong>, which, in case of a patch that modifies a lot of files,would make us generate the patches <strong>one by one</strong>, and the user would also need to apply them<strong> one by one</strong>!  (<em><strong>these cons could be solved by making Bash/Powershell/Python&#8230; scripts that handle the patching for the user, as xdelta handles CLI with no problem.)</strong></em></li>
</ul>



<p></p>


<div class="wp-block-image">
<figure class="aligncenter size-full"><img decoding="async" width="599" height="47" src="https://sakimotor.github.io/wp-content/uploads/2023/01/image-5.png" alt="" class="wp-image-78" srcset="https://sakimotor.github.io/wp-content/uploads/2023/01/image-5.png 599w, https://sakimotor.github.io/wp-content/uploads/2023/01/image-5-300x24.png 300w" sizes="(max-width: 599px) 100vw, 599px" /><figcaption class="wp-element-caption"><em>The difference speaks for itself</em>!</figcaption></figure></div>


<p></p>



<p>And thus, our long guide finally comes to an end. Now, we are able to jailbreak a ps4 console, dump any game we want, modify its contents (<em>we covered the case of a Unity game)</em> and run the patched contents on the console as easily as possible. Thank you for reading this blog, I will come back for more <em>Sony</em>-oriented romhacking articles soon!</p>
]]></content:encoded>
					
					<wfw:commentRss>https://sakimotor.github.io/2023/01/30/modding-the-silver-case-part-3-replacing-distributing-the-mod/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
