blob: 24705ed36335153fb144b1e1637dfcd85ac3d7d2 [file] [log] [blame]
Nguyen Anh Quynh6f9b1132014-05-19 17:06:44 +08001This documentation explains how to compile Capstone on Windows using
2Microsoft Visual Studio version 2010 or newer.
Nguyen Anh Quynh61882e52014-05-18 00:39:49 +08003
Nguyen Anh Quynhf1c3acb2014-05-28 22:39:23 +08004To compile Capstone on *nix, see COMPILE.TXT
5
6To compile Capstone with CMake, see COMPILE_CMAKE.TXT
7
Axel 0vercl0k Souchet27e9cc42014-05-10 14:41:45 +01008 *-*-*-*-*-*
9
tandasat45e5eab2016-05-11 21:48:32 -070010Capstone requires no prerequisite packages with default configurations, so it is
11easy to compile & install. Open the Visual Studio solution "msvc/capstone.sln"
12and follow the instructions below.
Nguyen Anh Quynh61882e52014-05-18 00:39:49 +080013
14NOTE: This requires Visual Studio 2010 or newer versions.
Axel 0vercl0k Souchet27e9cc42014-05-10 14:41:45 +010015
tandasat45e5eab2016-05-11 21:48:32 -070016If you wish to embed Capstone in a kernel driver, Visual Studio 2013 or newer
17versions, and Windows Driver Kit 8.1 Update 1 or newer versions are required.
18
Axel 0vercl0k Souchet27e9cc42014-05-10 14:41:45 +010019
20(0) Tailor Capstone to your need.
21
Nguyen Anh Quynh74a114e2015-10-05 16:14:19 +080022 Out of 9 archtitectures supported by Capstone (Arm, Arm64, M68K, Mips, PPC,
23 Sparc, SystemZ, X86 & XCore), if you just need several selected archs, choose
24 the ones you want to compile in by opening Visual Studio solution "msvc\capstone.sln",
Nguyen Anh Quynhc80d8402014-05-26 23:02:48 +080025 then directly editing the projects "capstone_static" & "capstone_dll" for static
Nguyen Anh Quynh01f48392014-05-15 11:06:43 +080026 and dynamic libraries, respectively. This must be done before going to the
27 next steps.
Axel 0vercl0k Souchet27e9cc42014-05-10 14:41:45 +010028
Nguyen Anh Quynhba37f332014-05-14 07:48:50 +080029 In VisualStudio interface, modify the preprocessor definitions via
Satoshi Tanda565b6c32016-09-27 07:39:51 -070030 "Project Properties" -> "Configuration Properties" -> "C/C++" -> "Preprocessor"
Nguyen Anh Quynhba37f332014-05-14 07:48:50 +080031 to customize Capstone library, as followings.
Axel 0vercl0k Souchet27e9cc42014-05-10 14:41:45 +010032
Nguyen Anh Quynhba37f332014-05-14 07:48:50 +080033 - CAPSTONE_HAS_ARM: support ARM. Delete this to remove ARM support.
Nguyen Anh Quynh01f48392014-05-15 11:06:43 +080034 - CAPSTONE_HAS_ARM64: support ARM64. Delete this to remove ARM64 support.
Nguyen Anh Quynh74a114e2015-10-05 16:14:19 +080035 - CAPSTONE_HAS_M68K: support M68K. Delete this to remove M68K support.
Nguyen Anh Quynh01f48392014-05-15 11:06:43 +080036 - CAPSTONE_HAS_MIPS: support Mips. Delete this to remove Mips support.
37 - CAPSTONE_HAS_PPC: support PPC. Delete this to remove PPC support.
Nguyen Anh Quynhba37f332014-05-14 07:48:50 +080038 - CAPSTONE_HAS_SPARC: support Sparc. Delete this to remove Sparc support.
39 - CAPSTONE_HAS_SYSZ: support SystemZ. Delete this to remove SystemZ support.
40 - CAPSTONE_HAS_X86: support X86. Delete this to remove X86 support.
Nguyen Anh Quynhc80d8402014-05-26 23:02:48 +080041 - CAPSTONE_HAS_XCORE: support XCore. Delete this to remove XCore support.
Axel 0vercl0k Souchet27e9cc42014-05-10 14:41:45 +010042
Nguyen Anh Quynh74a114e2015-10-05 16:14:19 +080043 By default, all 9 architectures are compiled in.
Nguyen Anh Quynhba37f332014-05-14 07:48:50 +080044
45
46 Besides, Capstone also allows some more customization via following macros.
47
48 - CAPSTONE_USE_SYS_DYN_MEM: delete this to use your own dynamic memory management.
Nguyen Anh Quynh01f48392014-05-15 11:06:43 +080049 - CAPSTONE_DIET_NO: rename this to "CAPSTONE_DIET" to make the binaries more compact.
50 - CAPSTONE_X86_REDUCE_NO: rename this to "CAPSTONE_X86_REDUCE" to make X86 binary smaller.
obscb8e40c2014-08-17 21:07:13 +020051 - CAPSTONE_X86_ATT_DISABLE_NO: rename this to "CAPSTONE_X86_ATT_DISABLE" to disable
52 AT&T syntax on x86.
Nguyen Anh Quynhba37f332014-05-14 07:48:50 +080053
Nguyen Anh Quynh01f48392014-05-15 11:06:43 +080054 By default, Capstone use system dynamic memory management, and both DIET and X86_REDUCE
55 modes are disable.
Nguyen Anh Quynhba37f332014-05-14 07:48:50 +080056
Axel 0vercl0k Souchet27e9cc42014-05-10 14:41:45 +010057
58 For each option, refer to docs/README for more details.
59
Nguyen Anh Quynh9c02b272014-05-14 08:00:22 +080060
61
Axel 0vercl0k Souchet27e9cc42014-05-10 14:41:45 +010062(1) Compile from source on Windows with Visual Studio
63
Nguyen Anh Quynh9c02b272014-05-14 08:00:22 +080064 - Choose the configuration and the platform you want: Release/Debug & Win32/Win64.
65 - Build only the libraries, or the libraries along with all the tests.
tandasat45e5eab2016-05-11 21:48:32 -070066 - "capstone_static_winkernel" is for compiling Capstone for a driver and
67 "test_winkernel" is a test for a driver, and those are excluded from build by
68 default. To compile them, open the Configuration Manager through the [Build]
69 menu and check "Build" check boxes for those project.
Nguyen Anh Quynh9c02b272014-05-14 08:00:22 +080070
71
Axel 0vercl0k Souchet27e9cc42014-05-10 14:41:45 +010072
Nguyen Anh Quynh726f99c2014-05-10 23:22:59 +080073(2) You can make sure the prior steps successfully worked by launching one of the
Nguyen Anh Quynh9c02b272014-05-14 08:00:22 +080074 testing binary (test*.exe).
tandasat45e5eab2016-05-11 21:48:32 -070075
76 The testing binary for a driver "test_winkernel.sys" is made up of all tests for
77 supported architectures configured with the step (0) along side its own tests.
78 Below explains a procedure to run the test driver and check test results.
79
80 On the x64 platform, the test signing mode has to be enabled to install the test
81 driver. To do it, open the command prompt with the administrator privileges and
82 type the following command, and then restart the system to activate the change:
83
84 >bcdedit /set testsigning on
85
86 Test results from the test driver is sent to kernel debug buffer. In order to
87 see those results, download DebugView and run it with the administrator
88 privileges, then check [Capture Kernel] through the [Capture] menu.
89
90 DebugView: https://technet.microsoft.com/en-us/sysinternals/debugview.aspx
91
92 To install and uninstall the driver, use the 'sc' command. For installing and
93 executing test_winkernel.sys, execute the following commands with the
94 administrator privileges:
95
96 >sc create test_winkernel type= kernel binPath= <full path to test_winkernel.sys>
97 [SC] CreateService SUCCESS
98
99 >sc start test_winkernel
100 [SC] StartService FAILED 995:
101
102 The I/O operation has been aborted because of either a thread exit or an application request.
103
104 To uninstall the driver, execute the following commands with the administrator
105 privileges:
106
107 >sc delete test_winkernel
108 >bcdedit /deletevalue testsigning