Debian Codegraph @

COMPILE_MSVC.TXT

raw
1 This documentation explains how to compile Capstone on Windows using
2 Microsoft Visual Studio version 2010 or newer.
3
4 To compile Capstone on *nix, see COMPILE.TXT
5
6 To compile Capstone with CMake, see COMPILE_CMAKE.TXT
7
8 *-*-*-*-*-*
9
10 Capstone requires no prerequisite packages with default configurations, so it is
11 easy to compile & install. Open the Visual Studio solution "msvc/capstone.sln"
12 and follow the instructions below.
13
14 NOTE: This requires Visual Studio 2010 or newer versions.
15
16 If you wish to embed Capstone in a kernel driver, Visual Studio 2013 or newer
17 versions, 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 - CAPSTONE_HAS_TRICORE: support TriCore. Delete this to remove TriCore support.
43
44 By default, all 9 architectures are compiled in.
45
46
47 Besides, Capstone also allows some more customization via following macros.
48
49 - CAPSTONE_USE_SYS_DYN_MEM: delete this to use your own dynamic memory management.
50 - CAPSTONE_DIET_NO: rename this to "CAPSTONE_DIET" to make the binaries more compact.
51 - CAPSTONE_X86_REDUCE_NO: rename this to "CAPSTONE_X86_REDUCE" to make X86 binary smaller.
52 - CAPSTONE_X86_ATT_DISABLE_NO: rename this to "CAPSTONE_X86_ATT_DISABLE" to disable
53 AT&T syntax on x86.
54
55 By default, Capstone use system dynamic memory management, and both DIET and X86_REDUCE
56 modes are disable.
57
58
59 For each option, refer to docs/README for more details.
60
61
62
63 (1) Compile from source on Windows with Visual Studio
64
65 - Choose the configuration and the platform you want: Release/Debug & Win32/Win64.
66 - Build only the libraries, or the libraries along with all the tests.
67 - "capstone_static_winkernel" is for compiling Capstone for a driver and
68 "test_winkernel" is a test for a driver, and those are excluded from build by
69 default. To compile them, open the Configuration Manager through the [Build]
70 menu and check "Build" check boxes for those project.
71
72
73
74 (2) You can make sure the prior steps successfully worked by launching one of the
75 testing binary (test*.exe).
76
77 The testing binary for a driver "test_winkernel.sys" is made up of all tests for
78 supported architectures configured with the step (0) along side its own tests.
79 Below explains a procedure to run the test driver and check test results.
80
81 On the x64 platform, the test signing mode has to be enabled to install the test
82 driver. To do it, open the command prompt with the administrator privileges and
83 type the following command, and then restart the system to activate the change:
84
85 >bcdedit /set testsigning on
86
87 Test results from the test driver is sent to kernel debug buffer. In order to
88 see those results, download DebugView and run it with the administrator
89 privileges, then check [Capture Kernel] through the [Capture] menu.
90
91 DebugView: https://technet.microsoft.com/en-us/sysinternals/debugview.aspx
92
93 To install and uninstall the driver, use the 'sc' command. For installing and
94 executing test_winkernel.sys, execute the following commands with the
95 administrator privileges:
96
97 >sc create test_winkernel type= kernel binPath= <full path to test_winkernel.sys>
98 [SC] CreateService SUCCESS
99
100 >sc start test_winkernel
101 [SC] StartService FAILED 995:
102
103 The I/O operation has been aborted because of either a thread exit or an application request.
104
105 To uninstall the driver, execute the following commands with the administrator
106 privileges:
107
108 >sc delete test_winkernel
109 >bcdedit /deletevalue testsigning
110
111
112
113 (3) Installing and building capstone via vcpkg
114
115 You can download and install capstone using the vcpkg(https://github.com/Microsoft/vcpkg) dependency manager:
116
117 git clone https://github.com/Microsoft/vcpkg.git
118 cd vcpkg
119 ./bootstrap-vcpkg.sh
120 ./vcpkg integrate install
121 vcpkg install capstone
122
123 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).