Nguyen Anh Quynh | e5d30e6 | 2014-04-14 16:33:04 +0800 | [diff] [blame] | 1 | 1. To install pure Python binding on *nix, run the command below: |
Nguyen Anh Quynh | 26ee41a | 2013-11-27 12:11:31 +0800 | [diff] [blame] | 2 | |
Nguyen Anh Quynh | b2ed4dc | 2013-12-03 09:28:43 +0800 | [diff] [blame] | 3 | $ sudo make install |
Nguyen Anh Quynh | 26ee41a | 2013-11-27 12:11:31 +0800 | [diff] [blame] | 4 | |
Nguyen Anh Quynh | 2daab25 | 2014-04-14 16:34:30 +0800 | [diff] [blame] | 5 | To install Python3 binding package, run the command below: |
| 6 | (Note: this requires python3 installed in your machine) |
Nguyen Anh Quynh | e5d30e6 | 2014-04-14 16:33:04 +0800 | [diff] [blame] | 7 | |
| 8 | $ sudo make install3 |
| 9 | |
Nguyen Anh Quynh | ea5ed83 | 2014-02-04 20:29:03 +0800 | [diff] [blame] | 10 | 2. For better Python performance, install cython-based binding with: |
Nguyen Anh Quynh | d35416a | 2014-01-10 10:37:31 +0800 | [diff] [blame] | 11 | |
| 12 | $ sudo make install_cython |
| 13 | |
Nguyen Anh Quynh | ea5ed83 | 2014-02-04 20:29:03 +0800 | [diff] [blame] | 14 | Note that this requires cython installed in your machine first. |
| 15 | To install cython, see section 3 below. |
dannyleates | b2a8151 | 2014-02-04 10:39:47 +0000 | [diff] [blame] | 16 | |
Nguyen Anh Quynh | ea5ed83 | 2014-02-04 20:29:03 +0800 | [diff] [blame] | 17 | 3. 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 | |
dannyleates | b2a8151 | 2014-02-04 10:39:47 +0000 | [diff] [blame] | 22 | $ sudo apt-get install python-dev |
| 23 | |
Nguyen Anh Quynh | ea5ed83 | 2014-02-04 20:29:03 +0800 | [diff] [blame] | 24 | Depending on if you already have pip or easy_install |
| 25 | installed, install cython with either: |
Nguyen Anh Quynh | 4c009c7 | 2014-01-10 11:23:51 +0800 | [diff] [blame] | 26 | |
| 27 | $ sudo pip install cython |
| 28 | or: |
dannyleates | b2a8151 | 2014-02-04 10:39:47 +0000 | [diff] [blame] | 29 | $ sudo easy_install cython |
Nguyen Anh Quynh | ea5ed83 | 2014-02-04 20:29:03 +0800 | [diff] [blame] | 30 | |
| 31 | NOTE: Depending on your distribution you might also be able to |
dannyleates | b2a8151 | 2014-02-04 10:39:47 +0000 | [diff] [blame] | 32 | install the required cython version using your repository. |
Nguyen Anh Quynh | ea5ed83 | 2014-02-04 20:29:03 +0800 | [diff] [blame] | 33 | |
| 34 | E.g. on Ubuntu, do: |
dannyleates | b2a8151 | 2014-02-04 10:39:47 +0000 | [diff] [blame] | 35 | |
| 36 | $ sudo apt-get install cython |
Nguyen Anh Quynh | ea5ed83 | 2014-02-04 20:29:03 +0800 | [diff] [blame] | 37 | |
| 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. |
dannyleates | b2a8151 | 2014-02-04 10:39:47 +0000 | [diff] [blame] | 41 | |
Nguyen Anh Quynh | ea5ed83 | 2014-02-04 20:29:03 +0800 | [diff] [blame] | 42 | E.g, on Ubuntu, you can verify the current cython version with: |
| 43 | |
Nguyen Anh Quynh | 128124c | 2014-11-12 11:13:39 +0800 | [diff] [blame^] | 44 | $ apt-cache policy cython |
Nguyen Anh Quynh | ea5ed83 | 2014-02-04 20:29:03 +0800 | [diff] [blame] | 45 | |
dannyleates | b2a8151 | 2014-02-04 10:39:47 +0000 | [diff] [blame] | 46 | Which should at least print version 0.19 |
Nguyen Anh Quynh | 4c009c7 | 2014-01-10 11:23:51 +0800 | [diff] [blame] | 47 | |
Nguyen Anh Quynh | b49f80d | 2014-01-09 15:03:01 +0800 | [diff] [blame] | 48 | |
Nguyen Anh Quynh | 26ee41a | 2013-11-27 12:11:31 +0800 | [diff] [blame] | 49 | This 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 Quynh | 5d0428e | 2014-02-21 18:06:04 +0800 | [diff] [blame] | 56 | - 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 Quynh | f86b21e | 2014-02-21 18:10:18 +0800 | [diff] [blame] | 62 | 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 Quynh | 5d0428e | 2014-02-21 18:06:04 +0800 | [diff] [blame] | 64 | |
Nguyen Anh Quynh | 26ee41a | 2013-11-27 12:11:31 +0800 | [diff] [blame] | 65 | - 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. |
Kedar | edf1091 | 2013-12-20 16:04:18 +0530 | [diff] [blame] | 73 | |
Kedar | edf1091 | 2013-12-20 16:04:18 +0530 | [diff] [blame] | 74 | |
Nguyen Anh Quynh | e76eae2 | 2013-12-20 22:23:46 +0800 | [diff] [blame] | 75 | 2. To install Python binding on Windows: |
Kedar | edf1091 | 2013-12-20 16:04:18 +0530 | [diff] [blame] | 76 | |
Kedar | 6b7b7d9 | 2013-12-20 17:00:15 +0530 | [diff] [blame] | 77 | Recommended method: |
Kedar | edf1091 | 2013-12-20 16:04:18 +0530 | [diff] [blame] | 78 | |
Nguyen Anh Quynh | e76eae2 | 2013-12-20 22:23:46 +0800 | [diff] [blame] | 79 | Use the Python module installer for 32/64 bit Windows from: |
| 80 | |
| 81 | http://www.capstone-engine.org/download.html |
| 82 | |
Kedar | edf1091 | 2013-12-20 16:04:18 +0530 | [diff] [blame] | 83 | |
Kedar | 6b7b7d9 | 2013-12-20 17:00:15 +0530 | [diff] [blame] | 84 | Manual method: |
| 85 | |
Nguyen Anh Quynh | e76eae2 | 2013-12-20 22:23:46 +0800 | [diff] [blame] | 86 | 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: |
Kedar | edf1091 | 2013-12-20 16:04:18 +0530 | [diff] [blame] | 89 | |
| 90 | C:\> C:\location_to_python\python.exe setup.py install |
| 91 | |
Nguyen Anh Quynh | e76eae2 | 2013-12-20 22:23:46 +0800 | [diff] [blame] | 92 | 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\ |