Games::Hack::Patch::i686 - How to patch code sequences on i686
$bytes=GetNOP( $adr_start, $adr_end, @disass );
Not useful in itself; is used by Games::Hack::Live, and will possibly be used by Games::Hack::Offline.
Games::Hack::Live
Games::Hack::Offline
Addresses given to this library are always in integer/decimal, so that the script can simply add and subtract. (gdb returns hex values.)
gdb
Given a start and an end address, and the disassembled instructions (although normally only one) in the given range (via gdb), return a binary string that, when written at the start address, causes this part of the program to be ignored.
The easiest way is simply returning the NOP opcode (0x90 on x86), as many times as needed.
A bit better, because it's shorter, is to return a short jump, with the correct offset.
short jump
Unfortunately there are some instructions with side effects; eg. the coprocessor instructions are typically issued with the suffix pop stack, which causes this instruction to change the internal state.
Simply jumping over such sequences leaves the old values on the coprocessor stack and can cause irregular behaviour, aborts, core dumps, and other crashes.
So some care must be taken for them.
A look from someone that knows all possible instructions, along with their side-effects, would be appreciated.
Modules for other CPUs would be nice.
Patches are welcome.
Ph. Marek <pmarek@cpan.org>
Copyright (C) 2007 by Ph. Marek; licensed under the GPLv3.
To install Games::Hack::Patch::i686, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Games::Hack::Patch::i686
CPAN shell
perl -MCPAN -e shell install Games::Hack::Patch::i686
For more information on module installation, please visit the detailed CPAN module installation guide.