MountainCloudBoysFix using patternies instead of a hardcoded offset

This commit is contained in:
Silent 2017-04-27 02:19:27 +02:00
parent 2e19ee6ac5
commit 396f013961

View file

@ -632,20 +632,15 @@ static void SweetsGirlFix()
static void MountainCloudBoysFix() static void MountainCloudBoysFix()
{ {
static const uint8_t bOldCode[22] = { auto pattern = hook::range_pattern( uintptr_t(ScriptSpace+ScriptFileSize), uintptr_t(ScriptSpace+ScriptFileSize+ScriptMissionSize),
0xD6, 0x00, 0x04, 0x00, 0x39, 0x00, 0x03, 0xEF, 0x00, 0x04, 0x02, 0x4D, "D6 00 04 00 39 00 03 EF 00 04 02 4D 00 01 90 F2 FF FF D6 00 04 01" ).count_hint(1);
0x00, 0x01, 0x90, 0xF2, 0xFF, 0xFF, 0xD6, 0x00, 0x04, 0x01 if ( pattern.size() == 1 ) // Faulty code lies under offset 3367 - replace it if it matches
};
// Faulty code lies under offset 3367 - replace it if it matches
if ( memcmp( ScriptSpace+ScriptFileSize+3367, bOldCode, sizeof(bOldCode) ) == 0 )
{ {
const uint8_t bNewCode[22] = { const uint8_t bNewCode[22] = {
0x00, 0x00, 0x00, 0x00, 0xD6, 0x00, 0x04, 0x03, 0x39, 0x00, 0x03, 0x2B, 0x00, 0x00, 0x00, 0x00, 0xD6, 0x00, 0x04, 0x03, 0x39, 0x00, 0x03, 0x2B,
0x00, 0x04, 0x0B, 0x39, 0x00, 0x03, 0xEF, 0x00, 0x04, 0x02 0x00, 0x04, 0x0B, 0x39, 0x00, 0x03, 0xEF, 0x00, 0x04, 0x02
}; };
memcpy( pattern.get(0).get<void>(), bNewCode, sizeof(bNewCode) );
memcpy( ScriptSpace+ScriptFileSize+3367, bNewCode, sizeof(bNewCode) );
} }
} }