• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1This documentation explains how to compile Capstone on Windows using
2Microsoft Visual Studio version 2010 or newer.
3
4To compile Capstone on *nix, see COMPILE.TXT
5
6To compile Capstone with CMake, see COMPILE_CMAKE.TXT
7
8                        *-*-*-*-*-*
9
10Capstone 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.
13
14NOTE: This requires Visual Studio 2010 or newer versions.
15
16If 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
19
20(0) Tailor Capstone to your need.
21
22  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",
25  then directly editing the projects "capstone_static" & "capstone_dll" for static
26  and dynamic libraries, respectively. This must be done before going to the next
27  steps.
28
29  In VisualStudio interface, modify the preprocessor definitions via
30  "Project Properties" -> "Configuration Properties" -> "C/C++" -> "Preprocessor"
31  to customize Capstone library, as followings.
32
33  - CAPSTONE_HAS_ARM: support ARM. Delete this to remove ARM support.
34  - CAPSTONE_HAS_ARM64: support ARM64. Delete this to remove ARM64 support.
35  - CAPSTONE_HAS_M68K: support M68K. Delete this to remove M68K support.
36  - CAPSTONE_HAS_MIPS: support Mips. Delete this to remove Mips support.
37  - CAPSTONE_HAS_POWERPC: support PPC. Delete this to remove PPC support.
38  - 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.
41  - CAPSTONE_HAS_XCORE: support XCore. Delete this to remove XCore support.
42
43  By default, all 9 architectures are compiled in.
44
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.
49  - 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.
51  - CAPSTONE_X86_ATT_DISABLE_NO: rename this to "CAPSTONE_X86_ATT_DISABLE" to disable
52    AT&T syntax on x86.
53
54  By default, Capstone use system dynamic memory management, and both DIET and X86_REDUCE
55  modes are disable.
56
57
58  For each option, refer to docs/README for more details.
59
60
61
62(1) Compile from source on Windows with Visual Studio
63
64  - 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.
66  - "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.
70
71
72
73(2) You can make sure the prior steps successfully worked by launching one of the
74  testing binary (test*.exe).
75
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
109
110
111
112(3) Installing and building capstone via vcpkg
113
114  You can download and install capstone using the vcpkg(https://github.com/Microsoft/vcpkg) dependency manager:
115
116    git clone https://github.com/Microsoft/vcpkg.git
117    cd vcpkg
118    ./bootstrap-vcpkg.sh
119    ./vcpkg integrate install
120    vcpkg install capstone
121
122  The capstone port in vcpkg is kept up to date by Microsoft team members and community contributors. If the version is out of date, please create an issue or pull request on the vcpkg repository(https://github.com/Microsoft/vcpkg).