MCPcopy Create free account
hub / github.com/PowerShell/DSC / load

Method load

resources/dism_dsc/src/dism.rs:180–212  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

178
179impl DismApi {
180 fn load() -> Result<Self, String> {
181 // Load dismapi.dll from the trusted System32 directory to avoid DLL search order hijacking.
182 // Use LoadLibraryExW with LOAD_LIBRARY_SEARCH_SYSTEM32 so the DLL location cannot be
183 // redirected via environment variables or the default DLL search order.
184 let lib_name = to_wide_null("dismapi.dll");
185 let lib = unsafe {
186 LoadLibraryExW(
187 lib_name.as_ptr(),
188 std::ptr::null_mut(),
189 LOAD_LIBRARY_SEARCH_SYSTEM32,
190 )
191 };
192 if lib.is_null() {
193 return Err(t!("dism.failedLoadLibrary").to_string());
194 }
195
196 unsafe {
197 Ok(DismApi {
198 lib,
199 close_session: load_fn(lib, b"DismCloseSession\0")?,
200 shutdown: load_fn(lib, b"DismShutdown\0")?,
201 get_features: load_fn(lib, b"DismGetFeatures\0")?,
202 get_feature_info: load_fn(lib, b"DismGetFeatureInfo\0")?,
203 enable_feature: load_fn(lib, b"DismEnableFeature\0")?,
204 disable_feature: load_fn(lib, b"DismDisableFeature\0")?,
205 delete: load_fn(lib, b"DismDelete\0")?,
206 get_capabilities: load_fn(lib, b"DismGetCapabilities\0").ok(),
207 get_capability_info: load_fn(lib, b"DismGetCapabilityInfo\0").ok(),
208 add_capability: load_fn(lib, b"DismAddCapability\0").ok(),
209 remove_capability: load_fn(lib, b"DismRemoveCapability\0").ok(),
210 })
211 }
212 }
213}
214
215impl Drop for DismApi {

Callers

nothing calls this directly

Calls 2

to_wide_nullFunction · 0.85
load_fnFunction · 0.85

Tested by

no test coverage detected