[P4G PC] Aemulus (Formerly P4G Exe Editor)

Programs that will help with modding various Persona games.
Post Reply
Posts: 10
Joined: Wed Jul 15, 2020 4:18 pm
Been thanked: 5 times

[P4G PC] Aemulus (Formerly P4G Exe Editor)

Post by Tekka » Mon Sep 14, 2020 5:19 pm

Gamebanana Page for Download: https://gamebanana.com/tools/6872

Aemulus means "Rival" in Latin. It uses .patch files (basically raw hex data with .patch extension) from your mods/patches folder in your Steam game directory to patch the exe at startup. It also now uses .tblpatch files (also raw hex data) from your mods/patches folder to edit your mods/data00004/init_free.bin at startup. I wanted to make it so that you can merge .tbl files so that the average end user doesn't have to open up a hex editor and merge it themselves.


All you need for Aemulus to work is to already have Reloaded II setup for mod loading following this tutorial (if you already mod Persona 4 Golden through Reloaded II you should be good to go).

Also if you're somehow still on Version 1.0 (REV: 2008), you'll need to patch P4G.exe with this tool in order to not get a AccessOutOfMemory error. All other versions don't need to have the 4GB Patch.

Also note that if you're using Tbl Patcher that it won't edit anything if it can't find init_free.bin in your mods/data00004 folder.

How To Install

- Extract the p4gpc.aemulus folder from the download and place it in your Reloaded II 'Mods' folder. ('Release' is my Reloaded II folder)


- Enable 'Aemulus' in your Reloaded II Launcher by making sure the icon next to it is a red plus like so.


- Take your .patch and/or .tblpatch files (none provided with this tool) and place it in your 'mods/patches' folder in your Steam game directory. Just create a 'patches' folder if you don't have one already. Also, if you launch the game with the mod enabled and don't have the directory, it'll create one for you.


- Now when you launch the game, P4G.exe and init_free.bin's tbl files should be modified by the patch files at startup.

Structure of .patch Files used for Exe Patcher (For Modders)

Read this if you want to create .patch files to modify P4G.exe yourself. This would be especially useful for people who want to translate the game since there's a lot of the game's text found inside P4G.exe. You can also modify any other part of the exe if you wish to do so (and know how to). Do note that you should have a hex editor if you want to create your own. Before creating a .patch file, you want to look inside P4G.exe with a hex editor to see which part you want to modify.

First two bytes of the .patch file - Length of the search pattern in hex
You can use a decimal to hex converter like this one.

In this example, we can see that the length is 00 05 or 5.

The Exe Patcher then uses that length to get the Search Pattern from the .patch file. For example, if the first two bytes indicated a length of 10, the patcher then reads 10 bytes after the first two bytes as the Search Pattern. This Search Pattern is then used to search for in P4G.exe. Do note that it'll stop at the first instance it finds since this is a simple patcher. Do make sure your search pattern is unique so that you'll be modifying the right part of the exe. I usually make sure that it's unique by just ctrl+f'ing the pattern in a hex editor and seeing if it's the only one that pops up.

In this example, we can see that the search pattern is "Sorry" since it's the next 5 bytes that follow the length indicated by the previous image.

Finally, right after the search pattern is the hex data you want to use for replacing the original hex data starting at which the Search Pattern was found. This part of the .patch file can be any length you want as the patcher just grabs the rest of the hex that follows the search pattern.

In this example, we can see the contents we're replacing is "UwU 00 00 00 00 00 We made a fucky wucky!!" as it is just the remaining hex data of the .patch file.

Structure of .tblpatch Files used for Tbl Patcher (For Modders)

If you want to edit .tbl files in init_free.bin, you would need to make .tblpatch files which have a slightly different structure.

First three bytes of the .tblpatch file is the tbl id, or 3 letters that indicate which tbl file it is.

In this example, we can see that MSG is the tbl id. So this .tblpatch will be editing MSG.TBL.

Next 8 bytes indicates the offset at which you want to start overwriting the hex. This will also be in hex rather than decimal. The offsets will be found in the individual .TBL file you identified in the first three bytes.

Here we can see that the offset is 00 00 00 00 00 00 02 50 (or 592 in decimal).

Finally, the rest of the bytes will be used to overwrite the hex starting at the specified contents.

In this case we'll just be using 57 65 65 62 00 00 00 00 (Weeb 00 00 00 00) to overwrite the hex found at the previously stated offset of 592 in MSG.TBL.

I recommend for you to use 010 Editor and these templates if you want to mess with .tbl files to create .tblpatches. Do note that my examples are really small to easily fit in this description but you can overwrite as much bytes as you want so that you don't need to create too many .tblpatch files.


If you click on 'Configure Mod' in the Reloaded II Launcher you will see there's multiple configurations that you can edit.


You have the option to enable/disable Exe Patcher and/or Tbl Patcher if you wish to use only one of them. Both of them are enabled by default and nothing wrong happens if you leave one enabled with no files for it in your mods/patches folder.

You can also enable debug mode to print out more stuff to the console. This is useful for modders creating their own .patch/.tblpatch files to use with this simple patcher. I would use it to make sure I setup my .patch files correctly. It'll print out the info it grabbed from the .patch/.tblpatch files onto the console like so.

For .patch files:
For .tblpatch files:

The last option is an optional priority system to make sure which patches are done last. In order to utilize this you should create folders with .patch/.tblpatch files inside your mods/patches folder. Then simply add the folder names to the Patch Folder Priority Collection by clicking on the drop down menu. Priority is given to the top of the list and descends to the bottom. Any other folder names not provided are given priority in alphabetical order. The least priority is given to patch files simply inside mods/patches and not any other folders. The highest priority patches will overwrite the bytes last so all of their changes should show up. However, it won't work for Exe Patcher if the lower priority patch files change the unique search pattern of higher priority patch files.

In this example, epname_kuma.patch will be loaded first, then the patch files inside 'Kechi,' and finally the patch files inside 'Weeb.'

Future Plans

Right now the Tbl Patcher only needs to run once after changing init_free.bin or the patches since it permanently saves over your init_free.bin and doesn't just edit it at runtime. To cope with that you can disable Tbl Patcher in the config after it merges it the first time, although it doesn't matter if you do or don't. If I ever learn about hooking, I'll just edit it at runtime but for the time being this method works.

I also plan on making this tool able to merge your bin files at startup before the modloader redirects them so that end users don't have to manually merge it themselves.

Any Questions?

If anything isn't working or you need help with using this tool please let me know through here or through my Discord at Tekka#0975. I'm also pretty active on the Discord server listed on GameBanana for Persona 4 Golden if you wish to talk with me there. Also let me know if you have any suggestions on what to add or improve to this tool. I also haven't messed with .tbl files for my own mods so let me know how this works out.


Be sure to check out some of my mods that use this tool (only involves using the Exe Patcher part):
- Rename Teddie to Kuma
- Nani?!
- OwOvewhauw

Post Reply