blob: 75942d501f9bcddf58ca8f869508b8a42bf29631 [file] [log] [blame]
Nguyen Anh Quynhe5d30e62014-04-14 16:33:04 +080011. To install pure Python binding on *nix, run the command below:
Nguyen Anh Quynh26ee41a2013-11-27 12:11:31 +08002
Nguyen Anh Quynhb2ed4dc2013-12-03 09:28:43 +08003 $ sudo make install
Nguyen Anh Quynh26ee41a2013-11-27 12:11:31 +08004
Nguyen Anh Quynh2daab252014-04-14 16:34:30 +08005 To install Python3 binding package, run the command below:
6 (Note: this requires python3 installed in your machine)
Nguyen Anh Quynhe5d30e62014-04-14 16:33:04 +08007
8 $ sudo make install3
9
Nguyen Anh Quynhea5ed832014-02-04 20:29:03 +0800102. For better Python performance, install cython-based binding with:
Nguyen Anh Quynhd35416a2014-01-10 10:37:31 +080011
12 $ sudo make install_cython
13
Nguyen Anh Quynhea5ed832014-02-04 20:29:03 +080014 Note that this requires cython installed in your machine first.
15 To install cython, see section 3 below.
dannyleatesb2a81512014-02-04 10:39:47 +000016
Nguyen Anh Quynhea5ed832014-02-04 20:29:03 +0800173. To install cython, you have to ensure that the header files
18 and the static library for Python are installed beforehand.
19
20 E.g. on Ubuntu, do:
21
dannyleatesb2a81512014-02-04 10:39:47 +000022 $ sudo apt-get install python-dev
23
Nguyen Anh Quynhea5ed832014-02-04 20:29:03 +080024 Depending on if you already have pip or easy_install
25 installed, install cython with either:
Nguyen Anh Quynh4c009c72014-01-10 11:23:51 +080026
27 $ sudo pip install cython
28 or:
dannyleatesb2a81512014-02-04 10:39:47 +000029 $ sudo easy_install cython
Nguyen Anh Quynhea5ed832014-02-04 20:29:03 +080030
31 NOTE: Depending on your distribution you might also be able to
dannyleatesb2a81512014-02-04 10:39:47 +000032 install the required cython version using your repository.
Nguyen Anh Quynhea5ed832014-02-04 20:29:03 +080033
34 E.g. on Ubuntu, do:
dannyleatesb2a81512014-02-04 10:39:47 +000035
36 $ sudo apt-get install cython
Nguyen Anh Quynhea5ed832014-02-04 20:29:03 +080037
38 However, our cython-based binding requires cython version 0.19 or newer,
39 but sometimes distributions only provide older version. Make sure to
40 verify the current installed version before going into section 2 above.
dannyleatesb2a81512014-02-04 10:39:47 +000041
Nguyen Anh Quynhea5ed832014-02-04 20:29:03 +080042 E.g, on Ubuntu, you can verify the current cython version with:
43
Nguyen Anh Quynh128124c2014-11-12 11:13:39 +080044 $ apt-cache policy cython
Nguyen Anh Quynhea5ed832014-02-04 20:29:03 +080045
dannyleatesb2a81512014-02-04 10:39:47 +000046 Which should at least print version 0.19
Nguyen Anh Quynh4c009c72014-01-10 11:23:51 +080047
Nguyen Anh Quynhb49f80d2014-01-09 15:03:01 +080048
Nguyen Anh Quynh26ee41a2013-11-27 12:11:31 +080049This directory contains some test code to show how to use Capstone API.
50
51- test.py
52 This code shows the most simple form of API where we only want to get basic
53 information out of disassembled instruction, such as address, mnemonic and
54 operand string.
55
Nguyen Anh Quynh5d0428e2014-02-21 18:06:04 +080056- test_lite.py
57 Similarly to test.py, but this code shows how to use disasm_lite(), a lighter
58 method to disassemble binary. Unlike disasm() API (used by test.py), which returns
59 CsInsn objects, this API just returns tuples of (address, size, mnemonic, op_str).
60
61 The main reason for using this API is better performance: disasm_lite() is at least
Nguyen Anh Quynhf86b21e2014-02-21 18:10:18 +080062 20% faster than disasm(). Memory usage is also less. So if you just need basic
63 information out of disassembler, use disasm_lite() instead of disasm().
Nguyen Anh Quynh5d0428e2014-02-21 18:06:04 +080064
Nguyen Anh Quynh26ee41a2013-11-27 12:11:31 +080065- test_detail.py:
66 This code shows how to access to architecture-neutral information in disassembled
67 instructions, such as implicit registers read/written, or groups of instructions
68 that this instruction belong to.
69
70- test_<arch>.py
71 These code show how to access architecture-specific information for each
72 architecture.
Kedaredf10912013-12-20 16:04:18 +053073
Kedaredf10912013-12-20 16:04:18 +053074
Nguyen Anh Quynhe76eae22013-12-20 22:23:46 +0800752. To install Python binding on Windows:
Kedaredf10912013-12-20 16:04:18 +053076
Kedar6b7b7d92013-12-20 17:00:15 +053077Recommended method:
Kedaredf10912013-12-20 16:04:18 +053078
Nguyen Anh Quynhe76eae22013-12-20 22:23:46 +080079 Use the Python module installer for 32/64 bit Windows from:
80
81 http://www.capstone-engine.org/download.html
82
Kedaredf10912013-12-20 16:04:18 +053083
Kedar6b7b7d92013-12-20 17:00:15 +053084Manual method:
85
Nguyen Anh Quynhe76eae22013-12-20 22:23:46 +080086 If the module installer fails to locate your Python install, or if you have
87 additional Python installs (e.g. Anaconda / virtualenv), run the following
88 command in command prompt:
Kedaredf10912013-12-20 16:04:18 +053089
90 C:\> C:\location_to_python\python.exe setup.py install
91
Nguyen Anh Quynhe76eae22013-12-20 22:23:46 +080092 Next, copy libcapstone.dll from the 'Core engine for Windows' package available
93 on the same Capstone download page and paste it in the path:
94
95 C:\location_to_python\Lib\site-packages\capstone\