@@ -70,24 +70,40 @@ pub fn call_host_function(
70
70
71
71
push_shared_output_data ( host_function_call_buffer) ?;
72
72
73
- outb ( OutBAction :: CallFunction as u16 , 0 ) ;
73
+ outb ( OutBAction :: CallFunction as u16 , & [ 0 ] ) ;
74
74
75
75
Ok ( ( ) )
76
76
}
77
77
78
- pub fn outb ( port : u16 , value : u8 ) {
78
+ pub fn outb ( port : u16 , data : & [ u8 ] ) {
79
79
unsafe {
80
80
match RUNNING_MODE {
81
81
RunMode :: Hypervisor => {
82
- hloutb ( port, value) ;
82
+ for chunk in data. chunks ( 4 ) {
83
+ let val = match chunk {
84
+ [ a, b, c, d] => u32:: from_le_bytes ( [ * a, * b, * c, * d] ) ,
85
+ [ a, b, c] => u32:: from_le_bytes ( [ * a, * b, * c, 0 ] ) ,
86
+ [ a, b] => u32:: from_le_bytes ( [ * a, * b, 0 , 0 ] ) ,
87
+ [ a] => u32:: from_le_bytes ( [ * a, 0 , 0 , 0 ] ) ,
88
+ [ ] => break ,
89
+ _ => unreachable ! ( ) ,
90
+ } ;
91
+
92
+ hloutd ( val, port) ;
93
+ }
83
94
}
84
95
RunMode :: InProcessLinux | RunMode :: InProcessWindows => {
85
96
if let Some ( outb_func) = OUTB_PTR_WITH_CONTEXT {
86
97
if let Some ( peb_ptr) = P_PEB {
87
- outb_func ( ( * peb_ptr) . pOutbContext , port, value) ;
98
+ outb_func (
99
+ ( * peb_ptr) . pOutbContext ,
100
+ port,
101
+ data. as_ptr ( ) ,
102
+ data. len ( ) as u64 ,
103
+ ) ;
88
104
}
89
105
} else if let Some ( outb_func) = OUTB_PTR {
90
- outb_func ( port, value ) ;
106
+ outb_func ( port, data . as_ptr ( ) , data . len ( ) as u64 ) ;
91
107
} else {
92
108
panic ! ( "Tried to call outb without hypervisor and without outb function ptrs" ) ;
93
109
}
@@ -100,7 +116,7 @@ pub fn outb(port: u16, value: u8) {
100
116
}
101
117
102
118
extern "win64" {
103
- fn hloutb ( port : u16 , value : u8 ) ;
119
+ fn hloutd ( value : u32 , port : u16 ) ;
104
120
}
105
121
106
122
pub fn print_output_as_guest_function ( function_call : & FunctionCall ) -> Result < Vec < u8 > > {
@@ -120,13 +136,15 @@ pub fn print_output_as_guest_function(function_call: &FunctionCall) -> Result<Ve
120
136
}
121
137
}
122
138
123
- // port: RCX(cx), value: RDX(dl)
139
+ pub fn debug_print ( msg : & str ) {
140
+ outb ( OutBAction :: DebugPrint as u16 , msg. as_bytes ( ) ) ;
141
+ }
142
+
124
143
global_asm ! (
125
- ".global hloutb
126
- hloutb:
127
- xor rax, rax
128
- mov al, dl
129
- mov dx, cx
130
- out dx, al
131
- ret"
144
+ ".global hloutd
145
+ hloutd:
146
+ mov eax, ecx
147
+ mov dx, dx
148
+ out dx, eax
149
+ ret"
132
150
) ;
0 commit comments