Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Harden reg-free class activation #3365

Merged
merged 1 commit into from
Dec 9, 2024
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 crates/libs/core/src/imp/com_bindings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -240,5 +240,6 @@ impl IWeakReferenceSource_Vtbl {
}
impl windows_core::RuntimeName for IWeakReferenceSource {}
pub const JSCRIPT_E_CANTEXECUTE: windows_core::HRESULT = windows_core::HRESULT(0x89020001_u32 as _);
pub const REGDB_E_CLASSNOTREG: windows_core::HRESULT = windows_core::HRESULT(0x80040154_u32 as _);
pub const RPC_E_DISCONNECTED: windows_core::HRESULT = windows_core::HRESULT(0x80010108_u32 as _);
pub const TYPE_E_TYPEMISMATCH: windows_core::HRESULT = windows_core::HRESULT(0x80028CA0_u32 as _);
18 changes: 11 additions & 7 deletions crates/libs/core/src/imp/factory_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,14 +106,18 @@ pub fn factory<C: crate::RuntimeName, I: Interface>() -> crate::Result<I> {
// can ultimately return this error information if all else fails.
let original: crate::Error = code.into();

// Now attempt to find the factory's implementation heuristically.
if let Some(i) = search_path(C::NAME, |library| unsafe {
get_activation_factory(library, &name)
}) {
i.cast()
} else {
Err(original)
// Reg-free activation should only be attempted if the class is not registered.
// It should not be attempted if the class is registered but fails to activate.
if code == REGDB_E_CLASSNOTREG {
// Now attempt to find the factory's implementation heuristically.
if let Some(i) = search_path(C::NAME, |library| unsafe {
get_activation_factory(library, &name)
}) {
return i.cast();
}
}

Err(original)
}

// Remove the suffix until a match is found appending `.dll\0` at the end
Expand Down
1 change: 1 addition & 0 deletions crates/tools/bindings/src/core_com.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

--filter
Windows.Win32.Foundation.CO_E_NOTINITIALIZED
Windows.Win32.Foundation.REGDB_E_CLASSNOTREG
Windows.Win32.Foundation.E_BOUNDS
Windows.Win32.Foundation.E_INVALIDARG
Windows.Win32.Foundation.E_NOINTERFACE
Expand Down
Loading