@@ -27,9 +27,9 @@ use windows::Win32::System::Hypervisor::{
2727 WHV_MEMORY_ACCESS_TYPE , WHV_PARTITION_HANDLE , WHV_REGISTER_VALUE , WHV_RUN_VP_EXIT_CONTEXT ,
2828 WHV_RUN_VP_EXIT_REASON , WHV_X64_SEGMENT_REGISTER , WHV_X64_SEGMENT_REGISTER_0 ,
2929} ;
30-
3130#[ cfg( crashdump) ]
32- use super :: crashdump;
31+ use { super :: crashdump, crate :: sandbox:: uninitialized:: SandboxMetadata , std:: path:: Path } ;
32+
3333use super :: fpu:: { FP_TAG_WORD_DEFAULT , MXCSR_DEFAULT } ;
3434#[ cfg( gdb) ]
3535use super :: handlers:: DbgMemAccessHandlerWrapper ;
@@ -58,6 +58,8 @@ pub(crate) struct HypervWindowsDriver {
5858 entrypoint : u64 ,
5959 orig_rsp : GuestPtr ,
6060 mem_regions : Vec < MemoryRegion > ,
61+ #[ cfg( crashdump) ]
62+ metadata : SandboxMetadata ,
6163}
6264/* This does not automatically impl Send/Sync because the host
6365 * address of the shared memory region is a raw pointer, which are
@@ -68,6 +70,7 @@ unsafe impl Send for HypervWindowsDriver {}
6870unsafe impl Sync for HypervWindowsDriver { }
6971
7072impl HypervWindowsDriver {
73+ #[ allow( clippy:: too_many_arguments) ]
7174 #[ instrument( err( Debug ) , skip_all, parent = Span :: current( ) , level = "Trace" ) ]
7275 pub ( crate ) fn new (
7376 mem_regions : Vec < MemoryRegion > ,
@@ -77,6 +80,7 @@ impl HypervWindowsDriver {
7780 entrypoint : u64 ,
7881 rsp : u64 ,
7982 mmap_file_handle : HandleWrapper ,
83+ #[ cfg( crashdump) ] metadata : SandboxMetadata ,
8084 ) -> Result < Self > {
8185 // create and setup hypervisor partition
8286 let mut partition = VMPartition :: new ( 1 ) ?;
@@ -104,6 +108,8 @@ impl HypervWindowsDriver {
104108 entrypoint,
105109 orig_rsp : GuestPtr :: try_from ( RawPtr :: from ( rsp) ) ?,
106110 mem_regions,
111+ #[ cfg( crashdump) ]
112+ metadata,
107113 } )
108114 }
109115
@@ -524,11 +530,20 @@ impl Hypervisor for HypervWindowsDriver {
524530 regs[ 25 ] = unsafe { sregs. fs . Segment . Selector } as u64 ; // fs
525531 regs[ 26 ] = unsafe { sregs. gs . Segment . Selector } as u64 ; // gs
526532
533+ let filename = self . metadata . binary_path . clone ( ) . map ( |path| {
534+ Path :: new ( & path)
535+ . file_name ( )
536+ . map ( |name| name. to_os_string ( ) . into_string ( ) . unwrap ( ) )
537+ . unwrap ( )
538+ } ) ;
539+
527540 Ok ( crashdump:: CrashDumpContext :: new (
528541 & self . mem_regions ,
529542 regs,
530543 xsave,
531544 self . entrypoint ,
545+ self . metadata . binary_path . clone ( ) ,
546+ filename,
532547 ) )
533548 }
534549}
0 commit comments