Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions resources/dism_dsc/locales/en-us.toml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ failedSerializeOutput = "Failed to serialize output: %{err}"
failedLoadLibrary = "Failed to load dismapi.dll. Ensure DISM is available on this system."
functionNotFound = "Failed to find function '%{name}' in dismapi.dll"
initializeFailed = "DismInitialize failed: HRESULT %{hr}"
notSupportedAppx = "This resource currently is not supported when installed via Appx"
openSessionFailed = "DismOpenSession failed: HRESULT %{hr}"
getFeatureInfoFailed = "DismGetFeatureInfo failed for '%{name}': HRESULT %{hr}"
enableFeatureFailed = "DismEnableFeature failed for '%{name}': HRESULT %{hr}"
Expand Down
8 changes: 8 additions & 0 deletions resources/dism_dsc/src/dism.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const DISM_PACKAGE_NONE: i32 = 0;
const ERROR_SUCCESS_REBOOT_REQUIRED: i32 = 3010;
const DISMAPI_E_UNKNOWN_FEATURE: i32 = 0x800F080Cu32 as i32;
const DISMAPI_E_CAPABILITY_NOT_APPLICABLE: i32 = 0x800F0825u32 as i32;
const REGDB_E_CLASSNOTREG: i32 = 0x80040154u32 as i32;
const LOAD_LIBRARY_SEARCH_SYSTEM32: u32 = 0x0000_0800;

#[link(name = "kernel32")]
Expand Down Expand Up @@ -243,6 +244,9 @@ impl DismSessionHandle {

unsafe {
let hr = dism_initialize(DISM_LOG_ERRORS, std::ptr::null(), std::ptr::null());
if hr == REGDB_E_CLASSNOTREG {
return Err(t!("dism.notSupportedAppx").to_string());
}
if hr < 0 {
return Err(t!("dism.initializeFailed", hr = format!("0x{:08X}", hr as u32)).to_string());
}
Expand All @@ -255,6 +259,10 @@ impl DismSessionHandle {
std::ptr::null(),
&mut session,
);
if hr == REGDB_E_CLASSNOTREG {
(api.shutdown)();
return Err(t!("dism.notSupportedAppx").to_string());
}
if hr < 0 {
(api.shutdown)();
return Err(t!("dism.openSessionFailed", hr = format!("0x{:08X}", hr as u32)).to_string());
Expand Down
Loading