@@ -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
@@ -525,11 +531,20 @@ impl Hypervisor for HypervWindowsDriver {
525531 regs[ 25 ] = unsafe { sregs. fs . Segment . Selector } as u64 ; // fs
526532 regs[ 26 ] = unsafe { sregs. gs . Segment . Selector } as u64 ; // gs
527533
534+ // Get the filename from the metadata
535+ let filename = self . metadata . binary_path . clone ( ) . and_then ( |path| {
536+ Path :: new ( & path)
537+ . file_name ( )
538+ . and_then ( |name| name. to_os_string ( ) . into_string ( ) . ok ( ) )
539+ } ) ;
540+
528541 Ok ( crashdump:: CrashDumpContext :: new (
529542 & self . mem_regions ,
530543 regs,
531544 xsave,
532545 self . entrypoint ,
546+ self . metadata . binary_path . clone ( ) ,
547+ filename,
533548 ) )
534549 }
535550}
0 commit comments