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

Commit 3627895

Browse files
committed
Added anything lib to provide flexibility for modification.
1 parent 873c106 commit 3627895

File tree

7 files changed

+202
-4
lines changed

7 files changed

+202
-4
lines changed

logs.txt

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
vcpu-0 INFO: The Matrix is an illusion
2+
vcpu-0 DEBUG: Setting up the hypervisor
3+
vcpu-0 DEBUG: Loaded image base: 0xa062000..0xe0f1000
4+
vcpu-0 DEBUG: Starting hypervisor on all processors
5+
vcpu-0 INFO: Total processors: 1
6+
vcpu-0 INFO: Enabled processors: 1
7+
vcpu-0 INFO: Found only one processor, virtualizing it
8+
vcpu-0 DEBUG: Is virtualized: false
9+
vcpu-0 DEBUG: Virtualizing the system
10+
vcpu-0 DEBUG: Allocating stack space for host
11+
vcpu-0 DEBUG: Zeroing stack space for host
12+
vcpu-0 DEBUG: Starting hypervisor
13+
vcpu-0 INFO: CPU is Intel
14+
vcpu-0 INFO: Virtual Machine Extension (VMX) technology is supported
15+
vcpu-0 INFO: Memory Type Range Registers (MTRRs) are supported
16+
vcpu-0 INFO: Extended Page Tables (EPT) are supported
17+
vcpu-0 DEBUG: CPU is supported
18+
vcpu-0 DEBUG: Building identity map for page tables
19+
vcpu-0 DEBUG: Identity map built successfully
20+
vcpu-0 DEBUG: VM initialized
21+
vcpu-0 DEBUG: VMX enabled
22+
vcpu-0 DEBUG: Creating a new GDT with TSS for guest
23+
vcpu-0 DEBUG: New GDT with TSS created for guest successfully!
24+
vcpu-0 DEBUG: Creating a new GDT with TSS for host
25+
vcpu-0 DEBUG: New GDT with TSS and IDT created for host successfully!
26+
vcpu-0 DEBUG: Setting up Guest Registers State
27+
vcpu-0 DEBUG: Guest Registers State setup successfully!
28+
vcpu-0 DEBUG: Setting up Host Registers State
29+
vcpu-0 DEBUG: Host Registers State setup successfully!
30+
vcpu-0 DEBUG: Setting up VMCS Control Fields
31+
vcpu-0 DEBUG: VMCS Control Fields setup successfully!
32+
vcpu-0 DEBUG: VMCS activated
33+
vcpu-0 DEBUG: Hiding hypervisor memory... (NOTE: EPT HOOKS WON'T WORK IF THIS IS ENABLED UNLESS SHADOW PAGES ARE EXCLUDED)
34+
vcpu-0 DEBUG: Memory Range: Start = 0xa062000, Size = 0x408f000
35+
vcpu-0 DEBUG: Memory Range: Start = 0x8c59000, Size = 0x1408000
36+
vcpu-0 DEBUG: Hypervisor memory hidden
37+
vcpu-0 INFO: Launching the VM until a vmexit occurs...
38+
vcpu-0 DEBUG: Is virtualized: true
39+
vcpu-0 INFO: The hypervisor has been installed successfully!
40+
vcpu-0 DEBUG: VM exit reason: Xsetbv
41+
vcpu-0 DEBUG: Handling XSETBV VM VM exit...
42+
vcpu-0 DEBUG: XSETBV VM exit handled successfully!
43+
vcpu-0 DEBUG: VM exit reason: Xsetbv
44+
vcpu-0 DEBUG: Handling XSETBV VM VM exit...
45+
vcpu-0 DEBUG: XSETBV VM exit handled successfully!
46+
vcpu-0 DEBUG: VM exit reason: Xsetbv
47+
vcpu-0 DEBUG: Handling XSETBV VM VM exit...
48+
vcpu-0 DEBUG: XSETBV VM exit handled successfully!
49+
vcpu-0 DEBUG: VM exit reason: Rdmsr
50+
vcpu-0 DEBUG: Handling MSR VM exit...
51+
vcpu-0 DEBUG: MSR VMEXIT handled successfully.
52+
vcpu-0 DEBUG: VM exit reason: Xsetbv
53+
vcpu-0 DEBUG: Handling XSETBV VM VM exit...
54+
vcpu-0 DEBUG: XSETBV VM exit handled successfully!
55+
vcpu-0 DEBUG: VM exit reason: Rdmsr
56+
vcpu-0 DEBUG: Handling MSR VM exit...
57+
vcpu-0 DEBUG: MSR VMEXIT handled successfully.
58+
vcpu-0 DEBUG: VM exit reason: Wrmsr
59+
vcpu-0 DEBUG: Handling MSR VM exit...
60+
vcpu-0 DEBUG: MSR VMEXIT handled successfully.
61+
vcpu-0 DEBUG: VM exit reason: Xsetbv
62+
vcpu-0 DEBUG: Handling XSETBV VM VM exit...
63+
vcpu-0 DEBUG: XSETBV VM exit handled successfully!
64+
vcpu-0 DEBUG: VM exit reason: ControlRegisterAccesses
65+
vcpu-0 DEBUG: VM exit reason: ControlRegisterAccesses

xtask/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ version = "0.1.0"
44
edition = "2021"
55

66
[dependencies]
7-
anything = { git = "https://github.com/Azvanzed/anything-rs.git" }
87
env_logger = "0.11.3"
98
log = "0.4.22"
109
dunce = "1.0.4"

xtask/src/anything/mod.rs

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
extern crate alloc;
2+
3+
use {
4+
alloc::{boxed::Box, format, string::String},
5+
core::{
6+
any::Any,
7+
fmt::{Debug, Display, Formatter},
8+
panic::Location,
9+
},
10+
};
11+
12+
pub mod nothing;
13+
14+
pub type Result<T> = core::result::Result<T, Anything>;
15+
pub type Exception<T> = core::result::Result<T, Anything>;
16+
17+
pub auto trait NotAnything {}
18+
impl !NotAnything for Anything {}
19+
impl<T> NotAnything for Box<T> {}
20+
21+
pub struct Anything {
22+
error: Box<dyn DynError>,
23+
24+
#[cfg(debug_assertions)]
25+
origin: &'static Location<'static>,
26+
}
27+
28+
impl Anything {
29+
#[cfg_attr(debug_assertions, track_caller)]
30+
pub fn new<T: DynError + 'static>(error: T) -> Anything {
31+
Anything {
32+
error: Box::new(error),
33+
#[cfg(debug_assertions)]
34+
origin: Location::caller(),
35+
}
36+
}
37+
38+
#[cfg_attr(debug_assertions, track_caller)]
39+
pub fn new_error<T: DynError + 'static>(error: T) -> Result<()> {
40+
Err(Anything {
41+
error: Box::new(error),
42+
#[cfg(debug_assertions)]
43+
origin: Location::caller(),
44+
})
45+
}
46+
47+
#[cfg_attr(debug_assertions, track_caller)]
48+
pub fn assert<T: DynError + 'static>(error_if_false: bool, error: T) -> Result<()> {
49+
if error_if_false {
50+
return Ok(());
51+
}
52+
Err(Anything {
53+
error: Box::new(error),
54+
#[cfg(debug_assertions)]
55+
origin: Location::caller(),
56+
})
57+
}
58+
59+
pub fn get_error(&self) -> &dyn Any {
60+
self.error.as_any()
61+
}
62+
63+
pub fn get_origin(&self) -> Option<Location<'static>> {
64+
#[cfg(debug_assertions)]
65+
return Some(self.origin.clone());
66+
#[cfg(not(debug_assertions))]
67+
return None;
68+
}
69+
}
70+
71+
impl Display for Anything {
72+
fn fmt(&self, f: &mut Formatter<'_>) -> core::fmt::Result {
73+
#[cfg(debug_assertions)]
74+
let v = write!(f, "[{}:{}:{}] {:?}", self.origin.file(), self.origin.line(), self.origin.column(), self.error.format());
75+
#[cfg(not(debug_assertions))]
76+
let v = write!(f, "{:?}", self.error.format());
77+
v
78+
}
79+
}
80+
81+
impl Debug for Anything {
82+
fn fmt(&self, f: &mut Formatter<'_>) -> core::fmt::Result {
83+
#[cfg(debug_assertions)]
84+
let v = write!(f, "'{:?}'\n at {}:{}:{}", self.error.format(), self.origin.file(), self.origin.line(), self.origin.column());
85+
#[cfg(not(debug_assertions))]
86+
let v = write!(f, "{:?}", self.error.format());
87+
v
88+
}
89+
}
90+
91+
impl<T: DynError + 'static> From<T> for Anything {
92+
#[cfg_attr(debug_assertions, track_caller)]
93+
fn from(value: T) -> Self {
94+
Anything {
95+
error: Box::new(value),
96+
#[cfg(debug_assertions)]
97+
origin: Location::caller(),
98+
}
99+
}
100+
}
101+
102+
pub trait DynError {
103+
fn as_any(&self) -> &dyn Any;
104+
fn format(&self) -> String;
105+
}
106+
107+
impl<T: Any + NotAnything + Debug> DynError for T {
108+
fn as_any(&self) -> &dyn Any {
109+
self as &dyn Any
110+
}
111+
112+
fn format(&self) -> String {
113+
format!("{:?}", self)
114+
}
115+
}

xtask/src/anything/nothing.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
extern crate alloc;
2+
3+
pub auto trait NotNothing {}
4+
impl !NotNothing for Nothing {}
5+
impl<T> NotNothing for Box<T> {}
6+
7+
#[derive(Debug)]
8+
pub struct Nothing;
9+
10+
impl<T: NotNothing> From<T> for Nothing {
11+
fn from(_: T) -> Self {
12+
Nothing
13+
}
14+
}

xtask/src/main.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![feature(negative_impls, auto_traits, const_type_id)]
2+
13
use {
24
crate::vmware::{
35
vmrun::{VMRun, VmState},
@@ -11,11 +13,12 @@ use {
1113
},
1214
};
1315

16+
pub mod anything;
1417
pub mod vmware;
1518

1619
const ROOT: &'static str = "E:";
17-
// const VMX_PATH: &'static str = r"C:\Users\memN0ps\Documents\Virtual Machines\Hv\Hv.vmx";
18-
const VMX_PATH: &'static str = r"C:\Users\memN0ps\Documents\Virtual Machines\WinDev2404Eval.VMWare\Dev.vmx";
20+
const VMX_PATH: &'static str = r"C:\Users\memN0ps\Documents\Virtual Machines\Hv\Hv.vmx";
21+
// const VMX_PATH: &'static str = r"C:\Users\memN0ps\Documents\Virtual Machines\WinDev2404Eval.VMWare\Dev.vmx";
1922
const LOG_PATH: &'static str = r"C:\Users\memN0ps\Documents\GitHub\illusion-rs\logs.txt";
2023
const BOOT_PATH: &'static str = r"\EFI\Boot";
2124
const LOADER_PATH: &'static str = r"C:\Users\memN0ps\Documents\GitHub\illusion-rs\target\x86_64-unknown-uefi\debug\loader.efi";

xtask/src/vmware/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use std::path::PathBuf;
1+
use {crate::anything, std::path::PathBuf};
22

33
pub mod vmrun;
44

xtask/src/vmware/vmrun.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
use crate::anything;
2+
13
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
24
pub enum VmState {
35
Running,

0 commit comments

Comments
 (0)