@@ -42,7 +42,7 @@ pub fn halt() {
4242 }
4343}
4444
45- #[ no_mangle]
45+ #[ unsafe ( no_mangle) ]
4646pub extern "C" fn abort ( ) -> ! {
4747 abort_with_code ( 0 )
4848}
@@ -57,17 +57,19 @@ pub fn abort_with_code(code: i32) -> ! {
5757/// # Safety
5858/// This function is unsafe because it dereferences a raw pointer.
5959pub unsafe fn abort_with_code_and_message ( code : i32 , message_ptr : * const c_char ) -> ! {
60- let peb_ptr = P_PEB . unwrap ( ) ;
61- copy_nonoverlapping (
62- message_ptr,
63- ( * peb_ptr) . guestPanicContextData . guestPanicContextDataBuffer as * mut c_char ,
64- CStr :: from_ptr ( message_ptr) . count_bytes ( ) + 1 , // +1 for null terminator
65- ) ;
66- outb ( OutBAction :: Abort as u16 , code as u8 ) ;
67- unreachable ! ( )
60+ unsafe {
61+ let peb_ptr = P_PEB . unwrap ( ) ;
62+ copy_nonoverlapping (
63+ message_ptr,
64+ ( * peb_ptr) . guestPanicContextData . guestPanicContextDataBuffer as * mut c_char ,
65+ CStr :: from_ptr ( message_ptr) . count_bytes ( ) + 1 , // +1 for null terminator
66+ ) ;
67+ outb ( OutBAction :: Abort as u16 , code as u8 ) ;
68+ unreachable ! ( )
69+ }
6870}
6971
70- extern "C" {
72+ unsafe extern "C" {
7173 fn hyperlight_main ( ) ;
7274 fn srand ( seed : u32 ) ;
7375}
@@ -76,7 +78,7 @@ static INIT: Once = Once::new();
7678
7779// Note: entrypoint cannot currently have a stackframe >4KB, as that will invoke __chkstk on msvc
7880// target without first having setup global `RUNNING_MODE` variable, which __chkstk relies on.
79- #[ no_mangle]
81+ #[ unsafe ( no_mangle) ]
8082pub extern "win64" fn entrypoint ( peb_address : u64 , seed : u64 , ops : u64 , max_log_level : u64 ) {
8183 if peb_address == 0 {
8284 panic ! ( "PEB address is null" ) ;
@@ -88,7 +90,7 @@ pub extern "win64" fn entrypoint(peb_address: u64, seed: u64, ops: u64, max_log_
8890 let peb_ptr = P_PEB . unwrap ( ) ;
8991 __security_cookie = peb_address ^ seed;
9092
91- let srand_seed = ( ( peb_address << 8 ^ seed >> 4 ) >> 32 ) as u32 ;
93+ let srand_seed = ( ( ( peb_address << 8 ) ^ ( seed >> 4 ) ) >> 32 ) as u32 ;
9294
9395 // Set the seed for the random number generator for C code using rand;
9496 srand ( srand_seed) ;
0 commit comments