Exemplo n.º 1
0
    def test_sext(self):
        mem = ReilMemoryEx(self.__address_size)
        cpu = ReilCpu(mem)

        instr = self.__parser.parse(["sext [DWORD t0, EMPTY, QWORD t1]"])[0]
        instr.address = 0xcafecafe00

        t0 = 0x12345678

        cpu.registers['t0'] = -t0 & 2**32 - 1

        cpu.execute(instr)

        self.assertEquals(-t0 & 2**64 - 1, cpu.registers['t1'])
Exemplo n.º 2
0
    def test_bisz(self):
        mem = ReilMemoryEx(self.__address_size)
        cpu = ReilCpu(mem)

        instr = self.__parser.parse(["BISZ [DWORD t0, EMPTY, BIT t1]"])[0]
        instr.address = 0xcafecafe00

        t0 = 0x12345678

        cpu.registers['t0'] = t0

        cpu.execute(instr)

        self.assertEquals(1 if t0 == 0 else 0, cpu.registers['t1'])
Exemplo n.º 3
0
    def test_div(self):
        mem = ReilMemoryEx(self.__address_size)
        cpu = ReilCpu(mem)

        instr = self.__parser.parse(["div [DWORD t0, DWORD t1, DWORD t2]"])[0]
        instr.address = 0xcafecafe00

        t0 = 0x12345678
        t1 = 0x1234

        cpu.registers['t0'] = t0
        cpu.registers['t1'] = t1

        cpu.execute(instr)

        self.assertEquals(t0 // t1, cpu.registers['t2'])
Exemplo n.º 4
0
    def test_stm(self):
        mem = ReilMemoryEx(self.__address_size)
        cpu = ReilCpu(mem)

        instr = self.__parser.parse(["stm [DWORD t0, EMPTY, DWORD t1]"])[0]
        instr.address = 0xcafecafe00

        t0 = 0x12345678
        t1 = 0x1234

        cpu.registers['t0'] = t0
        cpu.registers['t1'] = t1

        cpu.execute(instr)

        self.assertEquals(t0, cpu.memory.read(t1, 4))
Exemplo n.º 5
0
    def test_bsh_left(self):
        mem = ReilMemoryEx(self.__address_size)
        cpu = ReilCpu(mem)

        instr = self.__parser.parse(["bsh [DWORD t0, DWORD t1, DWORD t2]"])[0]
        instr.address = 0xcafecafe00

        t0 = 0x12345678
        t1 = 0x8

        cpu.registers['t0'] = t0
        cpu.registers['t1'] = t1

        cpu.execute(instr)

        self.assertEquals((t0 << t1) & 2**32 - 1, cpu.registers['t2'])
Exemplo n.º 6
0
    def test_jcc(self):
        mem = ReilMemoryEx(self.__address_size)
        cpu = ReilCpu(mem)

        instr = self.__parser.parse(["jcc [BIT t0, EMPTY, POINTER t1]"])[0]
        instr.address = 0xcafecafe00

        t0 = 0x1
        t1 = 0x1234567800

        cpu.registers['t0'] = t0
        cpu.registers['t1'] = t1

        next_ip = cpu.execute(instr)

        self.assertEquals(t1, next_ip)