hrydgard / ppsspp

A PSP emulator for Android, Windows, Mac and Linux, written in C++. Want to contribute? Join us on Discord at https://discord.gg/5NJB6dD or just send pull requests / issues. For discussion use the forums at forums.ppsspp.org.
https://www.ppsspp.org
Other
11.14k stars 2.16k forks source link

[Suggestion] Pattern-based CWCheat patches implementation #12341

Open TAbdiukov opened 5 years ago

TAbdiukov commented 5 years ago

Currently, what we may have for cheats is,

0xE(some check value at some hardcoded address)
0x2(some hardcoded  address, some val)

Aside from checking limitations (able to, in a really confusing way, check against a halfword at a time); Notice the following. Many games come in multiple regions, among which there are minimal differences. Yet due to the minimal differences, most of the time, the addresses in cheats just get slightly off-set. The code mostly remains the same,

I've been thinking about this, and what struck me is, unrelatedly, there is an Android hack-tool called "Lucky Patcher". Because Android apps get recompiled from version to version, let alone the Android obscurification policies, Lucky Patcher patches are pattern-based in their core. For instance, you can take a look at this repo, https://github.com/AndroidAppz/LuckyPatcherCustomPatches ; but in essence, they kinda look this nice and elegant syntax

[LIB]
{"name":"libcocos2dcpp.so"}

{"original":"54 4F 55 43 48 20 20 20 20 53 54 41 52 54 00 00 4C 4F 41 44 49 4E 47"}
{"replaced":"4B 55 4C 44 49 50 20 20 20 4B 4D 4F 44 53 00 00 4B 55 4C 44 49 50 50"}

{"original":"CC D4 FF FF 52 A3 5C 00 10 B5 86 B0 01 90 FB F7"} 
{"replaced":"CC D4 FF FF 52 A3 5C 00 01 20 70 47 01 90 FB F7"}

{"original":"7E 90 56 00 52 90 56 00 10 B5 86 B0 01 90 FF F7"} 
{"replaced":"7E 90 56 00 52 90 56 00 01 20 70 47 01 90 FF F7"}

{"original":"02 B0 70 47 82 B0 01 90 01 9B D3 F8 B4 31 18 46"}
{"replaced":"02 B0 70 47 82 B0 01 90 01 9B D3 F8 B4 31 04 20"}

Assuming you think it is a good idea, can we have something similar in the PPSSPP cheats? Possibly integrated with the pre-existing CWCheats?

Cheers

LunaMoo commented 5 years ago

"Pattern search", typically called AOB scan(array of bytes scan) as it's called in most popular cheating tool out there(Cheat Engine) is a great way of making cheats that doesn't have to be updated between game versions, but patterns only work with code, it's mostly useless to look for patterns in variable values stored somewhere and as such completely impossible to do anything to those commonly not working variable-changing cheats made for PSP which doesn't work due to differences in memory allocation.

AOB scan, if PPSSPP would ever end up with anything alike is very unfitting for CWCheat format. It's possible we will support some scripting language like LUA in the future, and that's much more fitting there, but again, forget about finding any patterns to fix existing PSP cheats. It's impossible and I think you don't understand much about cheats if you even suggested that. Think about it, you have an existing not working cwcheat that changes some values, for example in game's inventory. The pattern you have in the existing cheat will be the pattern existing AFTER applying it, not before, otherwise nobody would ever have use for such cheat. As such, what you're thinking, is impossible/useless.

Also I think you got wrong impression about what we support for CWCheat format. We have almost all cwcheat code types supported(missing is 0xB type that's useless ~ some kind of a delay from game boot). I do commonly say those you listed are the only really useful ones because both, to make very basic cheats and to make your own assembly scripts, those two are enough, in fact just 0x2 is enough, I use 0xE for safety, to stop people from breaking their games by trying in unsupported game version for example:]. Other code types are kind of useless to me and pretty much to anyone else that understanding assembly and that's the way I always recommend making cheats, doesn't matter if it's some crazy modern Denuvo(very complex anti-tamper, people confuse with DRM) protected PC game or some outdated console game. Those more "complicated" code types were made to avoid learning assembly and are just awful, slow, confusing, limited etc. they exist purely for people that are scared to learn assembly or even learn how games work in general, because of that historically they are the source of some of the biggest noobs in cheating communities that spread lies and missinformation to anyone willing to listen, stopped many to learn how to cheat properly and really not much else.