Example #1
0
    def test_i386_stdcall_concretize(self):
        cpu = self._cpu_x86

        bwidth = cpu.address_bit_size // 8
        self.assertEqual(cpu.read_int(cpu.ESP), 0x80)

        cpu.push(0x1234, cpu.address_bit_size)

        eip = 0xDEADBEEF
        base = cpu.ESP
        cpu.EIP = eip

        def test(one, two, three, four, five):
            raise ConcretizeArgument(cpu, 2)

        abi = I386StdcallAbi(cpu)
        with self.assertRaises(ConcretizeMemory) as cr:
            abi.invoke(test)

        # Make sure ESP hasn't changed if exception was raised
        self.assertEqual(base, cpu.ESP)
        # Make sure EIP hasn't changed (i.e. return value wasn't popped)
        self.assertEqual(cpu.EIP, eip)
Example #2
0
    def test_i386_stdcall(self):
        cpu = self._cpu_x86

        base = cpu.ESP

        bwidth = cpu.address_bit_size // 8
        self.assertEqual(cpu.read_int(cpu.ESP), 0x80)

        cpu.push(0x1234, cpu.address_bit_size)

        def test(one, two, three, four, five):
            self.assertEqual(one, 0x80)
            self.assertEqual(two, 0x84)
            self.assertEqual(three, 0x88)
            self.assertEqual(four, 0x8c)
            self.assertEqual(five, 0x90)
            return 3

        abi = I386StdcallAbi(cpu)
        abi.invoke(test)

        self.assertEqual(cpu.EAX, 3)
        self.assertEqual(base + bwidth * 5, cpu.ESP)
        self.assertEqual(cpu.EIP, 0x1234)
Example #3
0
    def test_i386_stdcall(self):
        cpu = self._cpu_x86

        base = cpu.ESP

        bwidth = cpu.address_bit_size // 8
        self.assertEqual(cpu.read_int(cpu.ESP), 0x80)

        cpu.push(0x1234, cpu.address_bit_size)

        def test(a0, a1, a2, a3, a4):
            self.assertEqual(a0, 0x80)
            self.assertEqual(a1, 0x84)
            self.assertEqual(a2, 0x88)
            self.assertEqual(a3, 0x8C)
            self.assertEqual(a4, 0x90)
            return 3

        abi = I386StdcallAbi(cpu)
        abi.invoke(test)

        self.assertEqual(cpu.EAX, 3)
        self.assertEqual(base + bwidth * 5, cpu.ESP)
        self.assertEqual(cpu.EIP, 0x1234)