Add __mul__ on Instruction + x64 on test_code

This commit is contained in:
Clement Rouault
2016-06-29 15:07:14 +02:00
parent 56b8264ffd
commit 2526727931
3 changed files with 25 additions and 1 deletions
+3 -1
View File
@@ -85,7 +85,6 @@ class CodeTesteur(dbg.Debugger):
exc_code = x.ExceptionRecord.ExceptionCode
exc_addr = x.ExceptionRecord.ExceptionAddress
if not self.init_breakpoint and exc_code == EXCEPTION_BREAKPOINT:
print("Init breakpoint")
self.init_breakpoint = True
return
ctx = self.current_thread.context
@@ -161,6 +160,9 @@ if len(sys.argv) < 2:
if sys.argv[1] == "-x64":
sys.argv.remove("-x64")
test_code_x64()
elif sys.argv[1] == "--raw":
sys.argv.remove("--raw")
pass
else:
test_code_x86()
+8
View File
@@ -735,6 +735,14 @@ class Instruction(object):
prefix_opcode = b"".join(chr(p.PREFIX_VALUE) for p in self.prefix)
return prefix_opcode + bytes(self.value.dump())
def __mul__(self, value):
if not isinstance(value, (int, long)):
return NotImplemented
res = MultipleInstr()
for i in range(value):
res += self
return res
class DelayedJump(object):
def __init__(self, type, label):
+14
View File
@@ -529,6 +529,20 @@ class Instruction(object):
prefix_opcode = b"".join(chr(p.PREFIX_VALUE) for p in self.prefix)
return prefix_opcode + bytes(self.value.dump())
#def __add__(self, other):
# res = MultipleInstr()
# res += self
# res += other
# return res
def __mul__(self, value):
if not isinstance(value, (int, long)):
return NotImplemented
res = MultipleInstr()
for i in range(value):
res += self
return res
# Jump helpers
class DelayedJump(object):