Skip to content
This repository was archived by the owner on Jan 28, 2023. It is now read-only.

Commit 43b3e4f

Browse files
authored
Merge pull request #113 from kryptoslogic/reorganization
Restructuring codebase
2 parents 19092bb + 3e21ff4 commit 43b3e4f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+376
-677
lines changed

.gitignore

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,2 @@
1-
# Visual Studio
2-
.vs/
3-
packages/
4-
*.suo
5-
*.vcxproj.user
6-
7-
# Windows
8-
/obj/
9-
Debug/
10-
Release/
11-
Win7Debug/
12-
Win7Release/
13-
Win8Debug/
14-
Win8Release/
15-
Win8.1Debug/
16-
Win8.1Release/
17-
181
# macOS
19-
/darwin/hax_driver/com_intel_hax/build/
202
.DS_Store

README.md

Lines changed: 4 additions & 211 deletions
Original file line numberDiff line numberDiff line change
@@ -10,206 +10,11 @@ extension (_kext_) for macOS. If you are interested in building HAXM from the
1010
source code, please read on. If you are just looking for the latest HAXM
1111
release, you can get it [here][github-haxm-latest-release].
1212

13-
## Building for Windows
14-
### Prerequisites
13+
## Usage
1514

16-
**Option A (Visual Studio)**
17-
* [Visual Studio 2017][visualstudio]
18-
* Install at least the following components:
19-
_Universal Windows Platform development_, _Desktop development with C++_.
20-
* [Windows SDK for Windows 10][sdk10]
21-
* [Windows Driver Kit (WDK) for Windows 10][wdk10]
22-
23-
Note that the version/build number of Windows SDK must match that of WDK.
24-
In particular, the Windows 10 SDK installed by Visual Studio 2017 (version 1709,
25-
build 10.0.16299 as of this writing) may not be the latest version. If you want
26-
to use the latest WDK (version 1803 as of this writing), you may need to
27-
download and install the latest Windows 10 SDK (version 1803, build 10.0.17134
28-
as of this writing).
29-
30-
**Option B (EWDK)**
31-
* [Enterprise WDK (EWDK) 10][ewdk10] with Visual Studio Build Tools 15.6
32-
* Install the downloaded ISO image by mounting it or extracting it to an empty
33-
folder.
34-
* [NuGet CLI tool][nuget] (`nuget.exe`) version 4.x or later
35-
36-
### Build steps
37-
**Option A (Visual Studio)**
38-
1. Open `HaxmDriver.sln` in Visual Studio 2017.
39-
1. Select either `Debug` or `Release` configuration.
40-
* The `Debug` configuration also signs the driver with a test certificate.
41-
The `Release` configuration does not do that.
42-
1. Select either `x64` or `Win32` platform.
43-
1. Build solution.
44-
45-
**Option B (EWDK)**
46-
1. `cd X:\path\to\EWDK\`
47-
1. `LaunchBuildEnv.cmd`
48-
1. `cd X:\path\to\haxm\`
49-
1. `X:\path\to\nuget.exe restore`
50-
1. `msbuild HaxmDriver.sln /p:Configuration="Debug" /p:Platform="x64"`
51-
* Use `Release` instead of `Debug` to build an optimized driver that is
52-
suitable for release. Note that the `Release` configuration does not sign the
53-
driver with a test certificate.
54-
* Use `Win32` instead of `x64` to build a 32-bit driver that works on 32-bit
55-
Windows.
56-
* Add `/t:rebuild` for a clean rebuild instead of an incremental build.
57-
58-
If successful, the driver binary (`IntelHaxm.sys`) will be generated in
59-
`X:\path\to\haxm\obj\out\Win7\x64\` (or `X:\path\to\haxm\obj\out\Win7\x86\` if
60-
`Platform="Win32"`), and will be able to run on Windows 7 and later.
61-
62-
## Testing on Windows
63-
### System requirements
64-
Note that these are requirements for the _test_ environment, which does not
65-
have to be the same as the _build_ environment.
66-
67-
1. An Intel CPU that supports Intel VT-x with _Extended Page Tables_ (EPT).
68-
* [Here][intel-ept-cpus] is a list of CPUs that meet this requirement. As a
69-
rule of thumb, if you have an Intel Core i3, i5, i7 or i9 (any generation), you
70-
are good to go.
71-
* EPT is an advanced feature of Intel VT-x. CPUs that support EPT also
72-
support _Unrestricted Guest_ (UG), which is another advanced feature of VT-x.
73-
It may still be possible to run HAXM on very old (pre-2010) CPUs, e.g.
74-
Intel Core 2 Duo, which implement an earlier version of VT-x that does not
75-
include either EPT or UG. However, the legacy code that enables HAXM to work in
76-
non-EPT and non-UG modes may be removed soon.
77-
1. Windows 7 or later; both 32-bit and 64-bit Windows are supported.
78-
* Running HAXM in a nested virtualization setup, where Windows itself runs as
79-
a guest OS on another hypervisor, may be possible, but this use case is not well
80-
tested.
81-
82-
### One-time setup
83-
The following steps prepare the test environment for installing a test-signed
84-
`IntelHaxm.sys`, i.e. one that is built using the `Debug` configuration. For
85-
more details, please read [this article][windows-test-driver-install].
86-
87-
1. Disable Hyper-V and enable _Test Mode_:
88-
1. Open an **elevated** (i.e. _Run as administrator_) Command Prompt.
89-
1. `bcdedit /set hypervisorlaunchtype off`
90-
1. `bcdedit /set testsigning on`
91-
1. Reboot.
92-
1. Install the test certificate:
93-
1. Copy `IntelHaxm.cer` from the build environment to the test environment
94-
(if the two are not the same). This file is generated alongside `IntelHaxm.sys`
95-
by the `Debug` build configuration.
96-
1. In the test environment, open an **elevated** Command Prompt and run
97-
`certmgr /add X:\path\to\IntelHaxm.cer /s /r localMachine root`
98-
1. Optionally, install [DebugView][debugview] to capture HAXM debug output.
99-
100-
### Loading and unloading the test driver
101-
`HaxmLoader` is a small tool that can load and unload a test-signed driver
102-
without using an INF file. You can download it from the
103-
[Releases][github-haxm-releases] page, or building `HaxmLoader/HaxmLoader.sln`
104-
yourself using Visual Studio or EWDK.
105-
106-
Basically, kernel-mode drivers like HAXM are managed by Windows Service Control
107-
Manager as services. Each such service has a unique name, a corresponding driver
108-
file, and a state. For example, when the HAXM installer installs the
109-
release-signed driver to `C:\Windows\System32\drivers\IntelHaxm.sys`, it also
110-
creates a service for it. This service is named `intelhaxm` and is started at
111-
boot time. `HaxmLoader` works in a similar manner: when loading a test driver,
112-
it creates a temporary service and starts it; when unloading the test driver, it
113-
stops and then deletes the service.
114-
115-
To load the test driver:
116-
1. Open an **elevated** Command Prompt.
117-
1. Make sure no other HAXM driver is loaded.
118-
1. If `sc query intelhaxm` shows the `intelhaxm` service as `RUNNING`, you
119-
must stop it first: `sc stop intelhaxm`
120-
1. Otherwise, unload the previously loaded test driver, if any:
121-
`HaxmLoader.exe -u`
122-
1. Load the test driver: `HaxmLoader.exe -i X:\path\to\IntelHaxm.sys`
123-
* Note that `HaxmLoader` can load a driver from any folder, so there is no
124-
need to copy the test driver to `C:\Windows\System32\drivers\` first.
125-
126-
To unload the test driver:
127-
1. Open an **elevated** Command Prompt.
128-
1. `HaxmLoader.exe -u`
129-
1. Optionally, you may want to restore the original, release-signed driver
130-
(i.e. `C:\Windows\System32\drivers\IntelHaxm.sys`): `sc start intelhaxm`
131-
132-
### Capturing driver logs
133-
1. Launch DebugView (`Dbgview.exe`) as administrator.
134-
1. In the _Capture_ menu, select everything except _Log Boot_. DebugView will
135-
now start capturing debug output from all kernel-mode drivers.
136-
1. In order to filter out non-HAXM logs, go to _Edit_ > _Filter/Highlight..._,
137-
enter `hax*` for _Include_, and click on _OK_.
138-
139-
## Building for macOS
140-
### Prerequisites
141-
* Xcode 7.2.1 or later
142-
* OS X 10.10 SDK (archived [here][osx-sdks])
143-
* Use `xcodebuild -showsdks` to list installed SDKs.
144-
* It is also possible to build HAXM using a newer version of macOS SDK.
145-
However, using an older SDK ensures that the generated kext is compatible with
146-
older versions of macOS.
147-
* NASM 2.11 or later
148-
* Install to `/usr/local/bin/` using Homebrew: `brew install nasm`
149-
* Note that Apple NASM (`/usr/bin/nasm`) cannot be used.
150-
151-
### Build steps
152-
1. `cd /path/to/haxm/`
153-
1. `cd darwin/hax_driver/com_intel_hax/`
154-
1. `xcodebuild -configuration Debug`
155-
* Use `-sdk` to override the default macOS SDK version (10.10), e.g.
156-
`-sdk macosx10.12` (to select SDK 10.12) or even `-sdk macosx` (to select the
157-
latest SDK installed).
158-
* Use `Release` instead of `Debug` to build an optimized kext that is
159-
suitable for release.
160-
161-
If successful, the kext (`intelhaxm.kext/`) will be generated in
162-
`/path/to/haxm/darwin/hax_driver/com_intel_hax/build/Debug/`.
163-
164-
## Testing on macOS
165-
### System requirements
166-
Note that these are requirements for the _test_ environment, which does not
167-
have to be the same as the _build_ environment.
168-
169-
1. Hardware requirements are the same as those for Windows.
170-
1. OS X 10.10 or later.
171-
172-
### Loading and unloading the test kext
173-
The `intelhaxm.kext` generated by the `Debug` and `Release` build configurations
174-
is not signed. Unless you can sign it using a special kind of Apple Developer ID
175-
Certificate, you must configure your test Mac to allow unsigned kexts to load:
176-
* For OS X 10.10, the solution is to add the `kext-dev-mode=1` _boot-arg_. More
177-
details can be found [here][macos-kext-dev-mode].
178-
* For macOS 10.11 and later, the solution is to turn off System Integrity
179-
Protection (SIP). More details can be found [here][macos-sip-disable].
180-
181-
To load the test kext:
182-
1. Make sure no other HAXM kext is loaded. If the output of
183-
`kextstat | grep intelhaxm` is not empty, you must unload the existing HAXM kext
184-
first: `sudo kextunload -b com.intel.kext.intelhaxm`
185-
1. `sudo chown -R root:wheel /path/to/intelhaxm.kext`
186-
1. `sudo chmod -R 755 /path/to/intelhaxm.kext`
187-
1. `sudo kextload /path/to/intelhaxm.kext`
188-
* Note that `kextload` can load a kext from any folder, so there is no need
189-
to copy the test kext to `/Library/Extensions/` first.
190-
191-
To unload the test kext:
192-
1. `sudo kextunload /path/to/intelhaxm.kext`
193-
1. Optionally, you may want to restore the original HAXM kext, which is usually
194-
the signed one installed to `/Library/Extensions/`:
195-
`sudo kextload /Library/Extensions/intelhaxm.kext`
196-
197-
### Viewing kext logs
198-
On macOS, HAXM debug output goes to the system log database, and can be
199-
retrieved at almost any time.
200-
201-
* On OS X 10.10, HAXM log messages are written immediately to
202-
`/var/log/system.log`. You can monitor this file for real-time updates using
203-
_Console.app_ or the `syslog -w` command.
204-
* On macOS 10.11 or later, HAXM log messages are no longer written to
205-
`/var/log/system.log`, and there is no good way to capture them in real time.
206-
However, you can still retrieve them at a later time using one of the following
207-
methods:
208-
1. `log show --predicate 'sender == "intelhaxm"' --style syslog --last 1h`,
209-
which is complex but very flexible. In this example, `--last 1h` indicates the
210-
past hour, and can be replaced with other queries.
211-
1. `sudo dmesg | grep hax`, which is simple, but does not show the timestamp
212-
of each message.
15+
Detailed instructions for building and testing HAXM can be found at:
16+
* [Manual for macOS](docs/manual-macos.md)
17+
* [Manual for Windows](docs/manual-windows.md)
21318

21419
## Reporting an Issue
21520
You are welcome to file a GitHub issue if you discover a general HAXM bug or
@@ -226,16 +31,4 @@ sensitive information.
22631
[android-studio]: https://developer.android.com/studio/index.html
22732
[qemu]: https://www.qemu.org/
22833
[github-haxm-latest-release]: https://github.com/intel/haxm/releases/latest
229-
[visualstudio]: https://www.visualstudio.com/downloads/
230-
[ewdk10]: https://docs.microsoft.com/en-us/windows-hardware/drivers/develop/using-the-enterprise-wdk
231-
[sdk10]: https://developer.microsoft.com/en-us/windows/downloads/windows-10-sdk
232-
[wdk10]: https://docs.microsoft.com/en-us/windows-hardware/drivers/download-the-wdk
233-
[nuget]: https://www.nuget.org/downloads
234-
[intel-ept-cpus]: https://ark.intel.com/Search/FeatureFilter?productType=processors&ExtendedPageTables=true
235-
[windows-test-driver-install]: https://docs.microsoft.com/en-us/windows-hardware/drivers/install/installing-test-signed-driver-packages
236-
[debugview]: https://docs.microsoft.com/en-us/sysinternals/downloads/debugview
237-
[github-haxm-releases]: https://github.com/intel/haxm/releases
238-
[osx-sdks]: https://github.com/phracker/MacOSX-SDKs
239-
[macos-kext-dev-mode]: https://developer.apple.com/library/archive/documentation/Security/Conceptual/System_Integrity_Protection_Guide/KernelExtensions/KernelExtensions.html
240-
[macos-sip-disable]: https://developer.apple.com/library/archive/documentation/Security/Conceptual/System_Integrity_Protection_Guide/ConfiguringSystemIntegrityProtection/ConfiguringSystemIntegrityProtection.html
24134
[intel-security-email]: mailto:[email protected]

core/include/emulate.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,7 @@
3131
#ifndef HAX_CORE_EMULATE_H_
3232
#define HAX_CORE_EMULATE_H_
3333

34-
#ifdef HAX_TESTS
35-
#include <stdint.h>
36-
#else
3734
#include "../../include/hax_types.h"
38-
#endif
3935

4036
#include "emulate_ops.h"
4137

core/sources

Lines changed: 0 additions & 31 deletions
This file was deleted.

core/sources.props

Lines changed: 0 additions & 12 deletions
This file was deleted.

darwin/hax_driver/com_intel_hax/readme

Lines changed: 0 additions & 6 deletions
This file was deleted.

dirs

Lines changed: 0 additions & 3 deletions
This file was deleted.

0 commit comments

Comments
 (0)