Skip to content

Commit fed5e56

Browse files
committed
protocol/device_path: add append_device_node
1 parent 9a441d0 commit fed5e56

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

src/protocol/device_path.rs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,7 @@ impl DevicePathFromTextProtocol {
258258
str_to_utf16_ptr(path)
259259
.map(|utf16_str| {
260260
let out = unsafe { &*((self.text_to_device_path_node)(utf16_str)) };
261+
// FIXME(csssuf)
261262
// Ideally, at this point, we'd free utf16_str. However, free_pool(utf16_str) seems
262263
// to hang here for unknown reasons. So we leak it.
263264
out
@@ -268,6 +269,7 @@ impl DevicePathFromTextProtocol {
268269
str_to_utf16_ptr(path)
269270
.map(|utf16_str| {
270271
let out = unsafe { &*((self.text_to_device_path)(utf16_str)) };
272+
// FIXME(csssuf)
271273
// Ideally, at this point, we'd free utf16_str. However, free_pool(utf16_str) seems
272274
// to hang here for unknown reasons. So we leak it.
273275
out
@@ -280,7 +282,7 @@ pub struct DevicePathUtilitiesProtocol {
280282
get_device_path_size: *const CVoid,
281283
duplicate_device_path: *const CVoid,
282284
append_device_path: unsafe extern "win64" fn(src1: *const DevicePathProtocol, src2: *const DevicePathProtocol) -> *const DevicePathProtocol,
283-
append_device_node: *const CVoid,
285+
append_device_node: unsafe extern "win64" fn(path: *const DevicePathProtocol, node: *const DevicePathProtocol) -> *const DevicePathProtocol,
284286
append_device_path_instance: *const CVoid,
285287
get_next_device_path_instance: *const CVoid,
286288
is_device_path_multi_instance: *const CVoid,
@@ -309,6 +311,17 @@ impl DevicePathUtilitiesProtocol {
309311
}
310312
}
311313

314+
pub fn append_device_node(&self, path: *const DevicePathProtocol, node: *const DevicePathProtocol) -> Result<*const DevicePathProtocol, Status> {
315+
unsafe {
316+
let out = (self.append_device_node)(path, node);
317+
if out == 0 as *const DevicePathProtocol {
318+
// See comment in append_device_path.
319+
return Err(Status::OutOfResources);
320+
}
321+
Ok(out)
322+
}
323+
}
324+
312325
pub fn create_device_node<T: Into<u8>, U: Into<u8>>(&self, node_type: T, node_subtype: U, node_length: u16) -> Result<*const DevicePathProtocol, Status> {
313326
unsafe {
314327
let out = (self.create_device_node)(node_type.into(), node_subtype.into(), node_length);

0 commit comments

Comments
 (0)