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

Commit

Permalink
Start from scratch
Browse files Browse the repository at this point in the history
  • Loading branch information
memN0ps committed Feb 13, 2024
1 parent 08a5759 commit 19d9802
Show file tree
Hide file tree
Showing 44 changed files with 118 additions and 4,761 deletions.
32 changes: 0 additions & 32 deletions .vscode/tasks.json

This file was deleted.

3 changes: 1 addition & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@
resolver = "2"

members = [
"boot",
"driver",
"hypervisor",
"xtask",
]

[profile.release]
Expand Down
7 changes: 0 additions & 7 deletions boot/.cargo/config.toml

This file was deleted.

118 changes: 0 additions & 118 deletions boot/src/main.rs

This file was deleted.

3 changes: 3 additions & 0 deletions driver/.cargo/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build]
target = "x86_64-unknown-uefi"
rustflags = ["-Z", "pre-link-args=/subsystem:efi_runtime_driver"]
1 change: 1 addition & 0 deletions boot/Cargo.toml → driver/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ edition = "2021"

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

Expand Down
18 changes: 18 additions & 0 deletions driver/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#![no_main]
#![no_std]

use log::*;
use uefi::prelude::*;

#[entry]
fn main(_image_handle: Handle, mut system_table: SystemTable<Boot>) -> Status {
com_logger::builder().filter(LevelFilter::Debug).setup();

uefi_services::init(&mut system_table).unwrap();

info!("Hello, world!");

system_table.boot_services().stall(10_000_000);

Status::SUCCESS
}
13 changes: 9 additions & 4 deletions hypervisor/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,23 @@ edition = "2021"

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

[features]
default = []
#secondary-ept = [] # If this feature is enabled, two nested page tables will be created.
#shellcode-hook = [] # Enables unstable inline hooks (currently not recommended)

[dependencies]
uefi = {version = "0.26.0", features = ["global_allocator", "alloc"] } # https://crates.io/crates/uefi
x86 = "0.52.0" # https://crates.io/crates/x86
x86_64 = "0.14.11" # https://crates.io/crates/x86_64
thiserror-no-std = "2.0.2" # https://crates.io/crates/thiserror-no-std
bitfield = "0.14.0" # https://crates.io/crates/bitfield
bit_field = "0.10.2" # https://crates.io/crates/bit_field
bitflags = "2.3.3" # https://crates.io/crates/bitflags
bitflags = "2.4.1" # https://crates.io/crates/bitflags
elain = "0.3.0" # https://crates.io/crates/elain
lazy_static = { version = "1.4.0", features = ["spin_no_std"] } # https://crates.io/crates/lazy_static
obfstr = "0.4.3" # https://crates.io/crates/obfstr/
static_assertions = "1.1.0" # https://crates.io/crates/static_assertions
log = "0.4.20" # https://crates.io/crates/log
kernel-log = "0.1.2" # https://crates.io/crates/kernel-log
com_logger = "0.1.1" # https://crates.io/crates/com_logger
com_logger = "0.1.1" # https://crates.io/crates/com_logger
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
bstr = { version = "1.9.0", default-features = false}
85 changes: 85 additions & 0 deletions hypervisor/src/error.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use alloc::ffi::NulError;
use thiserror_no_std::Error;

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

#[error("Failed to resolve memory type for given physical address range")]
MemoryTypeResolutionError,

#[error("Invalid CR3 base address")]
InvalidCr3BaseAddress,

#[error("Failed to parse bytes of original function")]
InvalidBytes,

#[error("Couldn't find enough space for the jump shellcode")]
NotEnoughBytes,

#[error("Failed to find original instructions")]
NoInstructions,

#[error("Failed to encode trampoline")]
EncodingFailed,

#[error("Found rip-relative instruction which is not supported")]
RelativeInstruction,

#[error("Found unsupported instruction")]
UnsupportedInstruction,

#[error("VMX is not initialized")]
VmxNotInitialized,

#[error("Hook error")]
HookError,

#[error("Primary EPT not provided")]
PrimaryEPTNotProvided,

#[error("Secondary EPT not provided")]
SecondaryEPTNotProvided,

#[error("Invalid PML4 entry")]
InvalidPml4Entry,

#[error("Invalid PML3 entry")]
InvalidPdptEntry,

#[error("Invalid PML2 entry")]
InvalidPdEntry,

#[error("Invalid PML1 entry")]
InvalidPml1Entry,

#[error("Invalid Permission Character")]
InvalidPermissionCharacter,

#[error("Unaligned address error")]
UnalignedAddressError,

#[error("Already split error")]
AlreadySplitError,

#[error("Out of memory")]
OutOfMemory,

#[error("Page already split")]
PageAlreadySplit,

#[error("Hook manager not provided")]
HookManagerNotProvided,

#[error("NtQuerySystemInformation failed")]
NtQuerySystemInformationFailed,

#[error("ExAllocatePoolFailed failed")]
ExAllocatePoolFailed,

#[error("Pattern not found")]
PatternNotFound,

#[error("SSDT not found")]
SsdtNotFound,

#[error("Failed create a C String")]
FailedToCreateCString(#[from] NulError),

#[error("Failed to get kernel base")]
GetKernelBaseFailed,

#[error("Failed to parse hexadecimal string")]
HexParseError,
}
53 changes: 0 additions & 53 deletions hypervisor/src/intel/controls.rs

This file was deleted.

Loading

0 comments on commit 19d9802

Please sign in to comment.