Skip to content

Instantly share code, notes, and snippets.

@Jasemalsadi
Created September 12, 2024 08:47
Show Gist options
  • Select an option

  • Save Jasemalsadi/00ec2277b1972023d7a8282c395f8bc8 to your computer and use it in GitHub Desktop.

Select an option

Save Jasemalsadi/00ec2277b1972023d7a8282c395f8bc8 to your computer and use it in GitHub Desktop.
Remove "/" affect from IDA’s decompiler & disassembler overlap
import ida_funcs
import idc
import re
# Get the current address (cursor position)
ea = idc.get_screen_ea()
idaapi.msg_clear()
# Define the regex pattern to match comments that start with "; " followed by multiple digits and a colon
pattern = re.compile(r"^; \d+:")
# Get the function object at the current address
func = ida_funcs.get_func(ea)
if func is None:
print("No function found at the current address.")
else:
# Get the end address of the function
end_ea = func.end_ea
print(f"Function starts at {hex(func.start_ea)} and ends at {hex(end_ea)}")
# Iterate through each address from the current cursor position to the end of the function
while ea < end_ea:
# Get the anterior extra comment at the current address (type 0 is for anterior comments)
comment = idc.get_extra_cmt(ea, E_PREV)
# Check if the comment exists and matches the pattern
if comment and pattern.match(comment):
print(f"Deleting..matching comment at {hex(ea)}: {comment}")
idc.del_extra_cmt(ea, E_PREV)
# Move to the next instruction
ea = idc.next_head(ea, end_ea)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment