1*9a0e4156SSadaf EbrahimiThis documentation explains how to compile Capstone for: 2*9a0e4156SSadaf Ebrahimi- Windows CE 7, a.k.a, [Windows Embedded Compact 7](https://www.microsoft.com/windowsembedded/en-us/windows-embedded-compact-7.aspx), on [ARMv7](http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.ddi0406c/index.html). 3*9a0e4156SSadaf Ebrahimi- Windows CE 8, a.k.a, [Windows Embedded Compact 2013](https://www.microsoft.com/windowsembedded/en-us/windows-embedded-compact-2013.aspx), on [ARMv7](http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.ddi0406c/index.html). 4*9a0e4156SSadaf Ebrahimi 5*9a0e4156SSadaf EbrahimiTo build Capstone for a different platform, please refer to `COMPILE.TXT`. 6*9a0e4156SSadaf Ebrahimi 7*9a0e4156SSadaf Ebrahimi# Prerequisites 8*9a0e4156SSadaf Ebrahimi 9*9a0e4156SSadaf EbrahimiWe support the following scenario regarding the build machine: 10*9a0e4156SSadaf Ebrahimi- Build running on Microsoft Windows. 11*9a0e4156SSadaf Ebrahimi- The C Software Develepment Kit of the target Windows CE **device** installed. 12*9a0e4156SSadaf Ebrahimi- Only for Windows CE 7: 13*9a0e4156SSadaf Ebrahimi - C compiler toolchain installed, targetting **Windows Embedded Compact 7** on **ARMv7**. We recommend the toolchain provided with [Windows Embedded Compact 7 toolkit](https://msdn.microsoft.com/en-us/library/jj200349%28v=winembedded.70%29.aspx), as the toolchain originally provided with **Visual Studio 2008** is relatively old. 14*9a0e4156SSadaf Ebrahimi 15*9a0e4156SSadaf EbrahimiBefore building Capstone for Windows CE 7 (respectively, Windows CE 8), the build script `windowsce/make_windowsce7-armv7.bat` (respectively, `windowsce/make_windowsce8-armv7.bat`) needs to be modified. The variables specified in the rest of this section are set in this script file. 16*9a0e4156SSadaf Ebrahimi 17*9a0e4156SSadaf Ebrahimi# Toolchain specification 18*9a0e4156SSadaf Ebrahimi 19*9a0e4156SSadaf EbrahimiThe following information need to be specified in the build script in order to perform the build: 20*9a0e4156SSadaf Ebrahimi- `set WINCE_TOOLCHAIN_ROOT=` is the path of the root directory of the Windows CE toolchain. To build for Windows CE 7, this should be set to the Windows Embedded Compact 7 toolchain. To build for Windows CE 8, this should be set to the device toolchain. 21*9a0e4156SSadaf EbrahimiExamples: 22*9a0e4156SSadaf Ebrahimi - For Windows CE 7: 23*9a0e4156SSadaf Ebrahimi ```bat 24*9a0e4156SSadaf Ebrahimi set WINCE_TOOLCHAIN_ROOT=C:\WINCE700\sdk 25*9a0e4156SSadaf Ebrahimi ``` 26*9a0e4156SSadaf Ebrahimi - For Windows CE 8: 27*9a0e4156SSadaf Ebrahimi ```bat 28*9a0e4156SSadaf Ebrahimi set WINCE_TOOLCHAIN_ROOT=C:\Windows_CE_Tools\SDKs\SDK_HW90270\Sdk 29*9a0e4156SSadaf Ebrahimi ``` 30*9a0e4156SSadaf Ebrahimi 31*9a0e4156SSadaf Ebrahimi- `set TOOLCHAIN=` is a semicolon-separated list of the paths of the directories containing the binaries of the Windows CE toolchain. 32*9a0e4156SSadaf EbrahimiFor example: 33*9a0e4156SSadaf Ebrahimi```bat 34*9a0e4156SSadaf Ebrahimiset TOOLCHAIN=%WINCE_TOOLCHAIN_ROOT%\Bin\i386\Arm;%WINCE_TOOLCHAIN_ROOT%\Bin\i386 35*9a0e4156SSadaf Ebrahimi``` 36*9a0e4156SSadaf Ebrahimi 37*9a0e4156SSadaf Ebrahimi- `set INCLUDE=` is a semicolon-separated list of the paths of the directories containing the C header files of the Windows CE device SDK. To build for Windows CE 7, this should also include the directories containing the C header files of the Windows Embedded Compact 7 toolchain. 38*9a0e4156SSadaf EbrahimiExamples: 39*9a0e4156SSadaf Ebrahimi - For Windows CE 7: 40*9a0e4156SSadaf Ebrahimi ```bat 41*9a0e4156SSadaf Ebrahimi set INCLUDE=C:\Program Files (x86)\Windows CE Tools\SDKs\Symbol MC3200c70 Windows CE 7.0 PSDK\Include\Armv4i;C:\WINCE700\public\common\sdk\inc 42*9a0e4156SSadaf Ebrahimi ``` 43*9a0e4156SSadaf Ebrahimi - For Windows CE 8: 44*9a0e4156SSadaf Ebrahimi ```bat 45*9a0e4156SSadaf Ebrahimi set INCLUDE=%WINCE_TOOLCHAIN_ROOT%\Inc;%WINCE_TOOLCHAIN_ROOT%\crt\Include 46*9a0e4156SSadaf Ebrahimi ``` 47*9a0e4156SSadaf Ebrahimi 48*9a0e4156SSadaf Ebrahimi- `set LIBPATH=` is a semicolon-separated list of the paths of the directories containing the library (i.e., `.LIB`) files of the Windows CE 7 device SDK. 49*9a0e4156SSadaf EbrahimiExamples: 50*9a0e4156SSadaf Ebrahimi - For Windows CE 7: 51*9a0e4156SSadaf Ebrahimi ```bat 52*9a0e4156SSadaf Ebrahimi set LIBPATH=C:\Program Files (x86)\Windows CE Tools\SDKs\Symbol MC3200c70 Windows CE 7.0 PSDK\Lib\ARMv4I 53*9a0e4156SSadaf Ebrahimi ``` 54*9a0e4156SSadaf Ebrahimi - For Windows CE 8: 55*9a0e4156SSadaf Ebrahimi ```bat 56*9a0e4156SSadaf Ebrahimi set LIBPATH=%WINCE_TOOLCHAIN_ROOT%\Lib\ARMV7\retail;%WINCE_TOOLCHAIN_ROOT%\Crt\Lib\ARM 57*9a0e4156SSadaf Ebrahimi ``` 58*9a0e4156SSadaf Ebrahimi 59*9a0e4156SSadaf Ebrahimi- `set LIBS=` is a space-separated list of linker directives controlling library search. 60*9a0e4156SSadaf EbrahimiExamples: 61*9a0e4156SSadaf Ebrahimi - For Windows CE 7: 62*9a0e4156SSadaf Ebrahimi ```bat 63*9a0e4156SSadaf Ebrahimi set LIBS=-nodefaultlib:oldnames.lib -nodefaultlib:libcmtd.lib -nodefaultlib:libcmt.lib coredll.lib corelibc.lib 64*9a0e4156SSadaf Ebrahimi ``` 65*9a0e4156SSadaf Ebrahimi - For Windows CE 8: 66*9a0e4156SSadaf Ebrahimi ```bat 67*9a0e4156SSadaf Ebrahimi set LIBS=coredll.lib 68*9a0e4156SSadaf Ebrahimi ``` 69*9a0e4156SSadaf Ebrahimi 70*9a0e4156SSadaf Ebrahimi# Capstone binary format 71*9a0e4156SSadaf Ebrahimi 72*9a0e4156SSadaf EbrahimiBy default, the build script produces a **dynamic link library** (i.e., `.DLL`). In order to produce a **static library** (i.e., `.LIB`) instead, the `SHARED` variable needs to be set to `0`, i.e.: 73*9a0e4156SSadaf Ebrahimi```bat 74*9a0e4156SSadaf Ebrahimiset SHARED=0 75*9a0e4156SSadaf Ebrahimi``` 76*9a0e4156SSadaf Ebrahimi 77*9a0e4156SSadaf Ebrahimi# Architectures supported at runtime 78*9a0e4156SSadaf Ebrahimi 79*9a0e4156SSadaf EbrahimiCapstone supports the following architectures: ARM, ARM64 (AArch64), M68K, MIPS, PowerPC, Sparc, SystemZ, x86 and XCore. However, Capstone can be configured in order to select which architectures need to be supported **at runtime**. This is controlled via the variable `DISASM_ARCH_LIST`, which is a space-separated list that is a combination of the following names: 80*9a0e4156SSadaf Ebrahimi- `ARM` 81*9a0e4156SSadaf Ebrahimi- `ARM64` 82*9a0e4156SSadaf Ebrahimi- `M68K` 83*9a0e4156SSadaf Ebrahimi- `MIPS` 84*9a0e4156SSadaf Ebrahimi- `POWERPC` 85*9a0e4156SSadaf Ebrahimi- `SPARC` 86*9a0e4156SSadaf Ebrahimi- `SYSZ` 87*9a0e4156SSadaf Ebrahimi- `X86` 88*9a0e4156SSadaf Ebrahimi- `XCORE`. 89*9a0e4156SSadaf Ebrahimi 90*9a0e4156SSadaf EbrahimiBy default, `DISASM_ARCH_LIST` includes support for **all** architectures supported by Capstone. 91*9a0e4156SSadaf EbrahimiFor example: 92*9a0e4156SSadaf Ebrahimi```bat 93*9a0e4156SSadaf Ebrahimiset DISASM_ARCH_LIST=ARM ARM64 X86 94*9a0e4156SSadaf Ebrahimi``` 95*9a0e4156SSadaf Ebrahimiwill produce a Capstone binary that supports the following architectures: ARM, ARM64 and x86. 96*9a0e4156SSadaf Ebrahimi 97*9a0e4156SSadaf Ebrahimi## Features customization 98*9a0e4156SSadaf Ebrahimi 99*9a0e4156SSadaf EbrahimiCapstone has a list of features that can be controlled when needed. Each feature is controlled through setting a variable from the following list: 100*9a0e4156SSadaf Ebrahimi 101*9a0e4156SSadaf Ebrahimi- In order to produce a smaller binary that provides a **subset** of the features of Capstone, but still supports all the selected architectures, please specify the following: 102*9a0e4156SSadaf Ebrahimi ```bat 103*9a0e4156SSadaf Ebrahimi set DIET_MODE=1 104*9a0e4156SSadaf Ebrahimi ``` 105*9a0e4156SSadaf Ebrahimi By default, this variable is set to `0`. 106*9a0e4156SSadaf Ebrahimi 107*9a0e4156SSadaf Ebrahimi- By default, Capstone uses the default system-provided **dynamic memory management** functions (e.g., `malloc()`, `realloc()`, `free()`) for its internal memory management. However, Capstone can instead be configured to call **custom** memory management functions provided by client applications. In order to enable this behavior, set the following: 108*9a0e4156SSadaf Ebrahimi ```bat 109*9a0e4156SSadaf Ebrahimi set USE_SYS_DYN_MEM=0 110*9a0e4156SSadaf Ebrahimi ``` 111*9a0e4156SSadaf Ebrahimi 112*9a0e4156SSadaf Ebrahimi- In order to produce a **smaller** Capstone binary, support for the `x86` architecture can be more **limited**. In order to do so, set the following: 113*9a0e4156SSadaf Ebrahimi ```bat 114*9a0e4156SSadaf Ebrahimi set X86_REDUCE=1 115*9a0e4156SSadaf Ebrahimi ``` 116*9a0e4156SSadaf Ebrahimi By default, this is set to `0`. 117*9a0e4156SSadaf Ebrahimi 118*9a0e4156SSadaf Ebrahimi- If the **AT&T** disassembly style of the `x86` architecture is never needed at runtime, then disabling support for it can produce a **smaller** Capstone binary. To do this, please set the following: 119*9a0e4156SSadaf Ebrahimi ```bat 120*9a0e4156SSadaf Ebrahimi set X86_ATT_DISABLE=1 121*9a0e4156SSadaf Ebrahimi ``` 122*9a0e4156SSadaf Ebrahimi By default, this is set to `0`. 123*9a0e4156SSadaf Ebrahimi 124*9a0e4156SSadaf EbrahimiPlease refer to `docs/README` for more details on these features. 125