Skip to content

Commit

Permalink
Insert docstrings
Browse files Browse the repository at this point in the history
  • Loading branch information
0x8008135 committed Sep 4, 2020
1 parent 071f351 commit a2544f3
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions diffosaurus.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
#!/usr/bin/env python3
""""
Copyright 2020 SUDKI Karim (@_Az0x_)
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
"""

import r2pipe
import subprocess
import time
Expand All @@ -10,10 +27,18 @@
registers = []

def cls():
#Clear screen
print("\x1B[2J")


def diff_strings(a, b):
#Highlight differences between registers
#Parameters:
# a (str): First string for comparison
# b (str): Second string for comparison
#Returns:
# m (boolean): Flag if modified (True)
# output (str): String with differences
output = []
m=False
for c in range(len(a)):
Expand All @@ -27,13 +52,19 @@ def diff_strings(a, b):


def filter_registers():
#Returns common registers between ESIL and DEBUG pipes
#Returns:
# regs: The list of common registers between ESIL and DEBUG pipes
regs_esl = dict(x.split(" = ") for x in r2_esl.cmd("aer").split("\n")[:-1])
regs_dbg = dict(x.split(" = ") for x in r2_dbg.cmd("dr").split("\n")[:-1])
regs=[x for x in regs_dbg.keys() if x in regs_esl.keys()]
return regs


def get_esil_registers():
#Fetch registers from ESIL pipe
#Returns:
# regs (list): List of ESIL registers
regs_esl = {}
regs_esl = dict(x.split(" = ") for x in r2_esl.cmd("aer").split("\n")[:-1])
if debug:
Expand All @@ -48,6 +79,9 @@ def get_esil_registers():


def get_debug_registers():
#Fetch registers from DEBUG pipe
#Returns:
# regs (list): List of DEBUG registers
regs_dbg = {}
regs_dbg = dict(x.split(" = ") for x in r2_dbg.cmd("dr").split("\n")[:-1])
if debug:
Expand All @@ -62,6 +96,7 @@ def get_debug_registers():


def reg_t2e_sync():
#Synchronize registers of DEBUG with ESIL pipe
regs_dbg = get_debug_registers()
for x in regs_dbg:
r2_esl.cmd(f"aer {x}={regs_dbg[x]}")
Expand All @@ -71,6 +106,7 @@ def reg_t2e_sync():


def reg_e2t_sync():
#Synchronize registers of ESIL with DEBUG pipe
regs_esl = get_esil_registers()
for x in regs_esl:
r2_dbg.cmd(f"dr {x}={regs_esl[x]}")
Expand All @@ -80,6 +116,10 @@ def reg_e2t_sync():


def print_regs(regs_dbg,regs_esl):
#Displays and perform possible actions based on the user choice
#Parameters:
# regs_dbg (dict): Contains the values of registers of DEBUG pipe
# regs_dbg (dict): Contains the values of registers of ESIL pipe
global debug
global old_c
modified = False
Expand Down Expand Up @@ -134,6 +174,7 @@ def print_regs(regs_dbg,regs_esl):


def print_logo():
#Print banner and logo
logo="\n\
@@\n\
@██@\n\
Expand Down

0 comments on commit a2544f3

Please sign in to comment.