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(2) abi = I386StdcallAbi(cpu) with self.assertRaises(ConcretizeMemory) as cr: abi.invoke(test) # Make sure ESP hasn't changed if exception was raised self.assertEquals(base, cpu.ESP) # Make sure EIP hasn't changed (i.e. return value wasn't popped) self.assertEquals(cpu.EIP, eip)
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.assertEquals(cpu.EAX, 3) self.assertEquals(base + bwidth * 5, cpu.ESP) self.assertEquals(cpu.EIP, 0x1234)