MCPcopy Index your code
hub / github.com/keystone-engine/keypatch / patch_raw

Method patch_raw

keypatch.py:608–628  ·  view source on GitHub ↗
(address, patch_data, len)

Source from the content-addressed store, hash-verified

606 # this process can fail in some cases
607 @staticmethod
608 def patch_raw(address, patch_data, len):
609 ea = address
610 orig_data = ''
611
612 while ea < (address + len):
613
614 if not idc.hasValue(idc.GetFlags(ea)):
615 print("Keypatch: FAILED to read data at 0x{0:X}".format(ea))
616 break
617
618 orig_byte = idc.Byte(ea)
619 orig_data += chr(orig_byte)
620 patch_byte = ord(patch_data[ea - address])
621
622 if patch_byte != orig_byte:
623 # patch one byte
624 if idaapi.patch_byte(ea, patch_byte) != 1:
625 print("Keypatch: FAILED to patch byte at 0x{0:X} [0x{1:X}]".format(ea, patch_byte))
626 break
627 ea += 1
628 return (ea - address, orig_data)
629
630 # patch at address, return the number of written bytes & original data
631 # on patch failure, we revert to the original code, then return (None, None)

Callers 1

patchMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected