File: write_before_map.py

package info (click to toggle)
unicorn-engine 2.1.4-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 23,912 kB
  • sloc: ansic: 379,830; python: 9,213; sh: 9,011; java: 8,609; ruby: 4,241; pascal: 1,805; haskell: 1,379; xml: 490; cs: 424; makefile: 348; cpp: 298; asm: 64
file content (24 lines) | stat: -rwxr-xr-x 609 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import regress
from unicorn import *
from unicorn.x86_const import *

X86_CODE64 = b"\x90"  # NOP


class WriteBeforeMap(regress.RegressTest):
    def runTest(self):
        # Initialize emulator in X86-32bit mode
        mu = Uc(UC_ARCH_X86, UC_MODE_64)

        # memory address where emulation starts
        ADDRESS = 0x1000000

        # write machine code to be emulated to memory
        with self.assertRaises(UcError) as raisedEx:
            mu.mem_write(ADDRESS, X86_CODE64)

        self.assertEqual(UC_ERR_WRITE_UNMAPPED, raisedEx.exception.errno)


if __name__ == '__main__':
    regress.main()