Last active
August 29, 2015 14:20
-
-
Save stephenfewer/12df771275ee7860b48e to your computer and use it in GitHub Desktop.
Relyze Plugin - Test instruction operand access
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Simple example to color every instruction in a function that writes to memory. | |
def run | |
result = cm.synchronize_write do | |
# Pull out the RVA of the function the user has selected in the GUI | |
func_rva = @relyze.tab_current_function_rva( cm ) || (break 'No function selected') | |
# Pull out the corresponding function object | |
func = cm.function( func_rva ) || (break 'Function not found') | |
# Iterate over every block in the function | |
func.blocks do | block | | |
# Iterate over every instruction in the block | |
block.instructions do | inst | | |
# Pull out the instruction raw decoding | |
raw = inst.to_raw | |
# Clear the instructions existing color | |
inst.color = nil | |
# Iterate over each operand looking for a memory write | |
raw[:operands].each do | operand | | |
if( operand[:write] and operand[:type] == :memory ) | |
inst.color = @relyze.rgb( 96, 255, 255 ) | |
break | |
end | |
end | |
end | |
end | |
'Finished' | |
end | |
print_message( result ) | |
@relyze.update_gui | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment