An experimental attempt to add PCSX2 Fork With Plugins plugin functionality on a real PlayStation 2.
Plugins allow to expand game code with new C functions that either replace originals or add ot them, this allows for more advanced mods and more!
A new section is added to the ELF executable containing plugin code, then the first EI call is replaced with a jump to the invoker function of the injected plugin.
Due to the fact that PS2 has a limited amount of ram (32MB), some games might be already using it all and leave no place for any new code to be injected! Keep that in mind that "supported" games might be few.
Run the executable without any params to get argument list
ps2plugininjector -i MKDHookPS2.elf -o modded_mkd.elf SLUS_208.81
MKDHookPS2 - a plugin for MK Deception
RandomLaddersMKA - a plugin for MK Armageddon
Plugins can only be written in pure C, C++ is not recommended and will definitely break your game.
You need to find empty/unused space in memory and set that address as base address in the plugin make file, usually end of original executable + 0x10000 or 0x20000 should be just about enough - to be sure, check with PCSX2 memory view if your selected address is truly unused.
Every variable needs to be initialized, do not leave uninitialized variables.
Static arrays have been tested and will work, any memory allocations have not been tested yet and theres a high chance they will break games, do it at your own risk
Basically you need to write plugins with code that only resides in .text section, that's the only section used for injecting - other sections are simply nullified/ignored on the PS2.
A simple list of games that were tested and can (or not) have injected code - doesn't mean the amount of it is infinite.
Name | Serial | Status |
---|---|---|
Mortal Kombat Deception | SLUS-20881 | ✅ Works |
Mortal Kombat Armageddon | SLUS-21410 | ✅ Works |
Mortal Kombat Shaolin Monks | SLUS-21087 | ✅ Works |