Function
load_fn
(lib: *mut c_void, name: &[u8])
Source from the content-addressed store, hash-verified
| 151 | } |
| 152 | |
| 153 | unsafe fn load_fn<T>(lib: *mut c_void, name: &[u8]) -> Result<T, String> { |
| 154 | unsafe { |
| 155 | let ptr = GetProcAddress(lib, name.as_ptr()); |
| 156 | if ptr.is_null() { |
| 157 | let fn_name = std::str::from_utf8(&name[..name.len() - 1]).unwrap_or("?"); |
| 158 | return Err(t!("dism.functionNotFound", name = fn_name).to_string()); |
| 159 | } |
| 160 | Ok(std::mem::transmute_copy(&ptr)) |
| 161 | } |
| 162 | } |
| 163 | |
| 164 | struct DismApi { |
| 165 | lib: *mut c_void, |
Tested by
no test coverage detected