Skip to content
This repository was archived by the owner on Sep 1, 2024. It is now read-only.

Commit 19d9802

Browse files
committed
Start from scratch
1 parent 08a5759 commit 19d9802

Some content is hidden

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

44 files changed

+118
-4761
lines changed

.vscode/tasks.json

-32
This file was deleted.

Cargo.toml

+1-2
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@
22
resolver = "2"
33

44
members = [
5-
"boot",
5+
"driver",
66
"hypervisor",
7-
"xtask",
87
]
98

109
[profile.release]

boot/.cargo/config.toml

-7
This file was deleted.

boot/src/main.rs

-118
This file was deleted.

driver/.cargo/config.toml

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[build]
2+
target = "x86_64-unknown-uefi"
3+
rustflags = ["-Z", "pre-link-args=/subsystem:efi_runtime_driver"]

boot/Cargo.toml driver/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ edition = "2021"
77

88
[dependencies]
99
uefi = {version = "0.26.0", features = ["global_allocator", "alloc"] } # https://crates.io/crates/uefi
10+
uefi-services = { version = "0.23.0", default-features = false, features = ["panic_handler"] }
1011
log = { version = "0.4.20", default-features = false } # https://crates.io/crates/log
1112
com_logger = "0.1.1" # https://crates.io/crates/com_logger
1213

driver/src/main.rs

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#![no_main]
2+
#![no_std]
3+
4+
use log::*;
5+
use uefi::prelude::*;
6+
7+
#[entry]
8+
fn main(_image_handle: Handle, mut system_table: SystemTable<Boot>) -> Status {
9+
com_logger::builder().filter(LevelFilter::Debug).setup();
10+
11+
uefi_services::init(&mut system_table).unwrap();
12+
13+
info!("Hello, world!");
14+
15+
system_table.boot_services().stall(10_000_000);
16+
17+
Status::SUCCESS
18+
}

hypervisor/Cargo.toml

+9-4
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,23 @@ edition = "2021"
55

66
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
77

8+
[features]
9+
default = []
10+
#secondary-ept = [] # If this feature is enabled, two nested page tables will be created.
11+
#shellcode-hook = [] # Enables unstable inline hooks (currently not recommended)
12+
813
[dependencies]
9-
uefi = {version = "0.26.0", features = ["global_allocator", "alloc"] } # https://crates.io/crates/uefi
1014
x86 = "0.52.0" # https://crates.io/crates/x86
1115
x86_64 = "0.14.11" # https://crates.io/crates/x86_64
1216
thiserror-no-std = "2.0.2" # https://crates.io/crates/thiserror-no-std
1317
bitfield = "0.14.0" # https://crates.io/crates/bitfield
1418
bit_field = "0.10.2" # https://crates.io/crates/bit_field
15-
bitflags = "2.3.3" # https://crates.io/crates/bitflags
19+
bitflags = "2.4.1" # https://crates.io/crates/bitflags
1620
elain = "0.3.0" # https://crates.io/crates/elain
1721
lazy_static = { version = "1.4.0", features = ["spin_no_std"] } # https://crates.io/crates/lazy_static
1822
obfstr = "0.4.3" # https://crates.io/crates/obfstr/
1923
static_assertions = "1.1.0" # https://crates.io/crates/static_assertions
2024
log = "0.4.20" # https://crates.io/crates/log
21-
kernel-log = "0.1.2" # https://crates.io/crates/kernel-log
22-
com_logger = "0.1.1" # https://crates.io/crates/com_logger
25+
com_logger = "0.1.1" # https://crates.io/crates/com_logger
26+
iced-x86 = { version = "1.20.0", default-features = false, features = ["no_std", "decoder", "block_encoder", "instr_info", "no_d3now", "no_evex", "no_vex", "no_xop"] } # https://crates.io/crates/iced-x86
27+
bstr = { version = "1.9.0", default-features = false}

hypervisor/src/error.rs

+85
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
use alloc::ffi::NulError;
12
use thiserror_no_std::Error;
23

34
#[derive(Error, Debug)]
@@ -70,4 +71,88 @@ pub enum HypervisorError {
7071

7172
#[error("Failed to resolve memory type for given physical address range")]
7273
MemoryTypeResolutionError,
74+
75+
#[error("Invalid CR3 base address")]
76+
InvalidCr3BaseAddress,
77+
78+
#[error("Failed to parse bytes of original function")]
79+
InvalidBytes,
80+
81+
#[error("Couldn't find enough space for the jump shellcode")]
82+
NotEnoughBytes,
83+
84+
#[error("Failed to find original instructions")]
85+
NoInstructions,
86+
87+
#[error("Failed to encode trampoline")]
88+
EncodingFailed,
89+
90+
#[error("Found rip-relative instruction which is not supported")]
91+
RelativeInstruction,
92+
93+
#[error("Found unsupported instruction")]
94+
UnsupportedInstruction,
95+
96+
#[error("VMX is not initialized")]
97+
VmxNotInitialized,
98+
99+
#[error("Hook error")]
100+
HookError,
101+
102+
#[error("Primary EPT not provided")]
103+
PrimaryEPTNotProvided,
104+
105+
#[error("Secondary EPT not provided")]
106+
SecondaryEPTNotProvided,
107+
108+
#[error("Invalid PML4 entry")]
109+
InvalidPml4Entry,
110+
111+
#[error("Invalid PML3 entry")]
112+
InvalidPdptEntry,
113+
114+
#[error("Invalid PML2 entry")]
115+
InvalidPdEntry,
116+
117+
#[error("Invalid PML1 entry")]
118+
InvalidPml1Entry,
119+
120+
#[error("Invalid Permission Character")]
121+
InvalidPermissionCharacter,
122+
123+
#[error("Unaligned address error")]
124+
UnalignedAddressError,
125+
126+
#[error("Already split error")]
127+
AlreadySplitError,
128+
129+
#[error("Out of memory")]
130+
OutOfMemory,
131+
132+
#[error("Page already split")]
133+
PageAlreadySplit,
134+
135+
#[error("Hook manager not provided")]
136+
HookManagerNotProvided,
137+
138+
#[error("NtQuerySystemInformation failed")]
139+
NtQuerySystemInformationFailed,
140+
141+
#[error("ExAllocatePoolFailed failed")]
142+
ExAllocatePoolFailed,
143+
144+
#[error("Pattern not found")]
145+
PatternNotFound,
146+
147+
#[error("SSDT not found")]
148+
SsdtNotFound,
149+
150+
#[error("Failed create a C String")]
151+
FailedToCreateCString(#[from] NulError),
152+
153+
#[error("Failed to get kernel base")]
154+
GetKernelBaseFailed,
155+
156+
#[error("Failed to parse hexadecimal string")]
157+
HexParseError,
73158
}

hypervisor/src/intel/controls.rs

-53
This file was deleted.

0 commit comments

Comments
 (0)