View Single Post
Old 12-15-2018, 12:10 AM   #273
geek1011
Wizard
geek1011 ought to be getting tired of karma fortunes by now.geek1011 ought to be getting tired of karma fortunes by now.geek1011 ought to be getting tired of karma fortunes by now.geek1011 ought to be getting tired of karma fortunes by now.geek1011 ought to be getting tired of karma fortunes by now.geek1011 ought to be getting tired of karma fortunes by now.geek1011 ought to be getting tired of karma fortunes by now.geek1011 ought to be getting tired of karma fortunes by now.geek1011 ought to be getting tired of karma fortunes by now.geek1011 ought to be getting tired of karma fortunes by now.geek1011 ought to be getting tired of karma fortunes by now.
 
Posts: 2,736
Karma: 6990705
Join Date: May 2016
Location: Ontario, Canada
Device: Kobo Mini, Aura Edition 2 v1, Clara HD
kobopatch v0.12.0 released with major new instructions for assembly manipulation

I have released a new version of kobopatch (along with patches v35) with some really nice instructions for assembly manipulation. I have decided to do what I did with the zlib stuff, but for assembly this time. The patches should be twice as fast to update now, and a lot more readable.

I have tested all these features, and the output matches byte-for-byte. In addition, the BLX-related instructions are designed in a fail-safe way. If something is broken about the assembler (or it can't match the output of the original compiler), it will refuse to even try to replace stuff to do with it. Note that this cannot protect you from putting in bad branch offsets (no different than before). The NOP replacements also have a check to make sure it is aligned properly.

This release allows me to simplify and speed up the update time for many patches. With this method, there is less typing I need to do for patches which do many branches to the same location from different offsets, less calculations to do manually, and a few other things like that.


The new features in this release are:

- New ReplaceBytesNOP instruction: This replaces assembly instruction bytes with as many NOPs as needed. The usage is the same as ReplaceBytes, just without the Replace.

- New ReplaceBLX instruction: This instruction takes branch addresses, calculates the offset, and assembles the instructions to make it easier to replace one branch instruction with another.

- New FindBLX shorthand option for ReplaceBytes and ReplaceBytesNOP: This option takes a branch address, calculates the offset, and assembles it automatically to make it easier to update and read than FindH or Find. Note that a BLX instruction is always 4 bytes long.

- Improved tests: The unit tests are now more comprehensive.


Examples:

Code:
# The 10 line spacing values patch
  - ReplaceBytes: {Offset: 0x658D3C, FindH: C0 F5 44 EE, ReplaceH: 00 46 00 46}
  - ReplaceBytes: {Offset: 0x658D92, FindH: C0 F5 1A EE, ReplaceH: 00 46 00 46}
  - ReplaceBytes: {Offset: 0x658DBC, FindH: C0 F5 04 EE, ReplaceH: 00 46 00 46}
  - ReplaceBytes: {Offset: 0x658DF8, FindH: C0 F5 E6 ED, ReplaceH: 00 46 00 46}
  - ReplaceBytes: {Offset: 0x658E5E, FindH: C0 F5 B4 ED, ReplaceH: 00 46 00 46}
# Becomes:
  - ReplaceBytesNOP: {Offset: 0x658D3C, FindBLX: 0x4199C8}
  - ReplaceBytesNOP: {Offset: 0x658D92, FindBLX: 0x4199C8}
  - ReplaceBytesNOP: {Offset: 0x658DBC, FindBLX: 0x4199C8}
  - ReplaceBytesNOP: {Offset: 0x658DF8, FindBLX: 0x4199C8}
  - ReplaceBytesNOP: {Offset: 0x658E5E, FindBLX: 0x4199C8}
Code:
# The both page turn sides go next patch
  - ReplaceBytes: {Offset: 0x83EDE8, FindH: D0 F7 AA E0, ReplaceH: DB F7 5A E3}
  - ReplaceBytes: {Offset: 0x83D426, FindH: D1 F7 8C E5, ReplaceH: DD F7 3C E0}
  - ReplaceBytes: {Offset: 0x83D432, FindH: D6 F7 D6 E6, ReplaceH: DC F7 5E E4}
# Becomes:
  - ReplaceBLX: {Offset: 0x83EDE8, Find: 0x40EF40, Replace: 0x41A4A0}
  - ReplaceBLX: {Offset: 0x83D426, Find: 0x40EF40, Replace: 0x41A4A0}
  - ReplaceBLX: {Offset: 0x83D432, Find: 0x4141E0, Replace: 0x419CF0}
Code:
# The always show upgrade confirmation patch:
  - ReplaceBytes: {Offset: 0xACE2CA, FindH: 46 F5 FA E3, ReplaceH: 4F F0 00 00}
# Becomes:
  - ReplaceBytes: {Offset: 0xACE2CA, FindBLX: 0x414AC0, ReplaceH: 4F F0 00 00}
And many more like this.

Last edited by geek1011; 12-15-2018 at 12:59 AM.
geek1011 is offline   Reply With Quote