text stringlengths 1 93.6k |
|---|
# This program is distributed in the hope that it will be useful,
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
# GNU General Public License for more details.
|
#
|
# You should have received a copy of the GNU General Public License
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
import threading
|
import time
|
import struct
|
import X86
|
import PPC
|
import Arm
|
from ElfFile import *
|
from PEFile import *
|
from MachOFile import *
|
ExeFormats = [ElfFile, PEFile, MachOFile]
|
class InstructionText:
|
def __init__(self):
|
self.lines = []
|
self.tokens = []
|
class X86Instruction:
|
def __init__(self, opcode, addr, disasm, addr_size):
|
self.opcode = opcode
|
self.addr = addr
|
self.disasm = disasm
|
self.addr_size = addr_size
|
self.plt = None
|
self.text = InstructionText()
|
if ((disasm.operation == "jmpn") or self.isCall() or self.isConditionalBranch()) and (disasm.operands[0].operand == "imm"):
|
self.target = disasm.operands[0].immediate
|
else:
|
self.target = None
|
def isConditionalBranch(self):
|
return self.disasm.operation in ["jo", "jno", "jb", "jae", "je", "jne", "jbe", "ja", "js", "jns",
|
"jpe", "jpo", "jl", "jge", "jle", "jg", "jcxz", "jecxz", "jrcxz", "loop"]
|
def isLocalJump(self):
|
if self.disasm.operation == "jmpn":
|
return True
|
if self.isConditionalBranch():
|
return True
|
return False
|
def isCall(self):
|
if self.disasm.operation == "calln":
|
return True
|
if self.disasm.operation == "callf":
|
return True
|
return False
|
def isBlockEnding(self):
|
if self.disasm.operation in ["jmpn", "jmpf", "retn", "retf"]:
|
return True
|
if self.isConditionalBranch():
|
return True
|
if self.disasm.operation == "hlt":
|
return True
|
return False
|
def isValid(self):
|
return self.disasm.operation != None
|
def length(self):
|
return self.disasm.length
|
def format_text(self, block, options):
|
old_lines = []
|
old_tokens = []
|
self.text.lines = []
|
self.text.tokens = []
|
line = []
|
tokens = []
|
x = 0
|
instr = self.disasm
|
if "address" in options:
|
string = "%.8x " % self.addr
|
line += [[string, QColor(0, 0, 128)]]
|
x += len(string)
|
if instr.operation == None:
|
line += [["??", Qt.black]]
|
self.text.lines += [line]
|
self.text.tokens += [tokens]
|
return (old_lines != self.text.lines) or (old_tokens != self.text.tokens)
|
result = ""
|
operation = ""
|
if instr.flags & X86.FLAG_LOCK:
|
operation += "lock "
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.