This repository has been archived by the owner on Sep 1, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
98 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
[build] | ||
target = "x86_64-unknown-uefi" | ||
rustflags = ["-Z", "pre-link-args=/subsystem:efi_runtime_driver"] | ||
|
||
#[unstable] | ||
#build-std = ["core", "compiler_builtins", "alloc"] | ||
#build-std-features = ["compiler-builtins-mem"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
[package] | ||
name = "boot" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
[dependencies] | ||
log = { version = "0.4", default-features = false } | ||
uefi = {version = "0.22.0", features = ["global_allocator", "alloc"] } | ||
com_logger = "0.1.1" # https://crates.io/crates/com_logger |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
#![no_main] | ||
#![no_std] | ||
#![feature(lang_items)] | ||
#![feature(panic_info_message)] | ||
#![feature(offset_of)] | ||
|
||
use { | ||
crate::{ | ||
boot::globals::{DRIVER_IMAGE_SIZE, DRIVER_PHYSICAL_MEMORY}, | ||
mapper::get_nt_headers, | ||
}, | ||
uefi::{ | ||
prelude::*, | ||
table::boot::{AllocateType, MemoryType}, | ||
}, | ||
core::ptr::copy_nonoverlapping, | ||
log::LevelFilter, | ||
}; | ||
|
||
|
||
#[cfg(not(test))] | ||
#[panic_handler] | ||
fn panic_handler(info: &core::panic::PanicInfo) -> ! { | ||
if let Some(location) = info.location() { | ||
log::error!( | ||
"[-] Panic in {} at ({}, {}):", | ||
location.file(), | ||
location.line(), | ||
location.column() | ||
); | ||
if let Some(message) = info.message() { | ||
log::error!("[-] {}", message); | ||
} | ||
} | ||
|
||
loop {} | ||
} | ||
|
||
/* The image handle represents the currently-running executable, and the system table provides access to many different UEFI services. | ||
(Removed as it requires uefi_services::init) | ||
//#[entry] | ||
//fn main(image_handle: handle, image_handle: Handle, mut system_table: SystemTable<Boot>) { } | ||
*/ | ||
|
||
#[no_mangle] | ||
fn efi_main(image_handle: Handle, system_table: SystemTable<Boot>) -> Status { | ||
/* Setup a simple memory allocator, initialize logger, and provide panic handler. (Removed as it conflicts with com_logger) */ | ||
//uefi_services::init(&mut system_table).unwrap(); | ||
|
||
/* Clear stdout/stderr output screen */ | ||
//system_table.stdout().clear().expect("Failed to clear the stdout output screen."); | ||
//system_table.stderr().clear().expect("Failed to clear the stderr output screen."); | ||
|
||
/* Setup a logger with the default settings. The default settings is COM1 port with level filter Info */ | ||
//com_logger::init(); | ||
|
||
// Use COM2 port with level filter Info | ||
com_logger::builder() | ||
.base(0x2f8) | ||
.filter(LevelFilter::Info) | ||
.setup(); | ||
|
||
log::info!("UEFI Hypervisor (Illusion) in Rust"); | ||
|
||
/* Make the system pause for 10 seconds */ | ||
log::info!("[+] Stalling the processor for 10 seconds"); | ||
system_table.boot_services().stall(10_000_000); | ||
|
||
/* Start Windows EFI Boot Manager (bootmgfw.efi) */ | ||
log::info!("[+] Starting Windows EFI Boot Manager (bootmgfw.efi)..."); | ||
boot_services | ||
.start_image(bootmgfw_handle) | ||
.expect("[-] Failed to start Windows EFI Boot Manager"); | ||
|
||
Status::SUCCESS | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
[toolchain] | ||
channel = "nightly" | ||
channel = "nightly" | ||
targets = ["x86_64-unknown-uefi"] |