joxeankoret icon

Simple script to patch any appearance of a specific call

joxeankoret | PRO | 02/19/21 02:59:17 PM UTC (Edited) | 0 ⭐ | 638 👁️ | Never ⏰ | []
Python |

750 B

|

None

|

0 👍

/

0 👎

#
# Simple script to patch any appearance of a specific call
# The script was used in the following Youtube video:
#
# https://www.youtube.com/watch?v=mlEcfRlw9rU
#
# By Joxean Koret
#
# Public Domain
#
 
import idc
import idaapi
import ida_idp
 
text_to_search = "call    CreateMenu"
start_ea = idc.get_inf_attr(idc.INF_MIN_EA)
end_ea   = idc.get_inf_attr(idc.INF_MAX_EA)
 
ea = start_ea
while ea < end_ea and ea != BADADDR:
  ea = idc.find_text(ea+1, idc.SEARCH_DOWN, 0, 0, text_to_search)
  if ea != BADADDR:
    size = idc.get_item_size(ea)
    if size == 5:
      ida_idp.assemble(ea, 0, ea, True, "mov eax, 1")
 
      # Alternatively, you can NOP the whole instruction by uncommenting this
      #idaapi.patch_bytes(ea, b"\x90"*size)
 

Comments