@@ -27,9 +27,9 @@ use windows::Win32::System::Hypervisor::{
27
27
WHV_MEMORY_ACCESS_TYPE , WHV_PARTITION_HANDLE , WHV_REGISTER_VALUE , WHV_RUN_VP_EXIT_CONTEXT ,
28
28
WHV_RUN_VP_EXIT_REASON , WHV_X64_SEGMENT_REGISTER , WHV_X64_SEGMENT_REGISTER_0 ,
29
29
} ;
30
-
31
30
#[ cfg( crashdump) ]
32
- use super :: crashdump;
31
+ use { super :: crashdump, crate :: sandbox:: uninitialized:: SandboxMetadata , std:: path:: Path } ;
32
+
33
33
use super :: fpu:: { FP_TAG_WORD_DEFAULT , MXCSR_DEFAULT } ;
34
34
#[ cfg( gdb) ]
35
35
use super :: handlers:: DbgMemAccessHandlerWrapper ;
@@ -58,6 +58,8 @@ pub(crate) struct HypervWindowsDriver {
58
58
entrypoint : u64 ,
59
59
orig_rsp : GuestPtr ,
60
60
mem_regions : Vec < MemoryRegion > ,
61
+ #[ cfg( crashdump) ]
62
+ metadata : SandboxMetadata ,
61
63
}
62
64
/* This does not automatically impl Send/Sync because the host
63
65
* address of the shared memory region is a raw pointer, which are
@@ -68,6 +70,7 @@ unsafe impl Send for HypervWindowsDriver {}
68
70
unsafe impl Sync for HypervWindowsDriver { }
69
71
70
72
impl HypervWindowsDriver {
73
+ #[ allow( clippy:: too_many_arguments) ]
71
74
#[ instrument( err( Debug ) , skip_all, parent = Span :: current( ) , level = "Trace" ) ]
72
75
pub ( crate ) fn new (
73
76
mem_regions : Vec < MemoryRegion > ,
@@ -77,6 +80,7 @@ impl HypervWindowsDriver {
77
80
entrypoint : u64 ,
78
81
rsp : u64 ,
79
82
mmap_file_handle : HandleWrapper ,
83
+ #[ cfg( crashdump) ] metadata : SandboxMetadata ,
80
84
) -> Result < Self > {
81
85
// create and setup hypervisor partition
82
86
let mut partition = VMPartition :: new ( 1 ) ?;
@@ -104,6 +108,8 @@ impl HypervWindowsDriver {
104
108
entrypoint,
105
109
orig_rsp : GuestPtr :: try_from ( RawPtr :: from ( rsp) ) ?,
106
110
mem_regions,
111
+ #[ cfg( crashdump) ]
112
+ metadata,
107
113
} )
108
114
}
109
115
@@ -525,11 +531,20 @@ impl Hypervisor for HypervWindowsDriver {
525
531
regs[ 25 ] = unsafe { sregs. fs . Segment . Selector } as u64 ; // fs
526
532
regs[ 26 ] = unsafe { sregs. gs . Segment . Selector } as u64 ; // gs
527
533
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
+
528
541
Ok ( crashdump:: CrashDumpContext :: new (
529
542
& self . mem_regions ,
530
543
regs,
531
544
xsave,
532
545
self . entrypoint ,
546
+ self . metadata . binary_path . clone ( ) ,
547
+ filename,
533
548
) )
534
549
}
535
550
}
0 commit comments