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

Fix incorrect marshalling spec #4632

Merged
merged 1 commit into from
Jun 7, 2021
Merged

Conversation

kant2002
Copy link
Contributor

@kant2002 kant2002 commented Jun 5, 2021

DeactivateActCtx do not have HRESULT as returning type, so PreserveSig == false is no op.
SHCreateItemFromParsingName will always throw in case of error,
and error handling in

HRESULT hr = NativeMethods2.SHCreateItemFromParsingName(path, null, ref iidShellItem2, out unk);
// Silently absorb errors such as ERROR_FILE_NOT_FOUND, ERROR_PATH_NOT_FOUND.
// Let others pass through
if (hr == (HRESULT)Win32Error.ERROR_FILE_NOT_FOUND || hr == (HRESULT)Win32Error.ERROR_PATH_NOT_FOUND)
{
hr = HRESULT.S_OK;
unk = null;
}

would never works.

Discovered as part of attempt to compile WPF in Native AOT in dotnet/runtimelab#1183
Also apologize for style correction, seems to be editorconfig picked up.

DeactivateActCtx do not have HRESULT as returning type, so PreserveSig == false is no op.
SHCreateItemFromParsingName will always throw in case of error,
and error handling in
https://github.com/dotnet/wpf/blob/d26eaaca20aa2f5de768e4053593f50a30776380/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/AppModel/ShellProvider.cs#L901-L909
would never works.
@kant2002 kant2002 requested a review from a team as a code owner June 5, 2021 10:34
@ghost ghost added the PR metadata: Label to tag PRs, to facilitate with triage label Jun 5, 2021
@ghost ghost requested review from fabiant3, ryalanms and SamBent June 5, 2021 10:34
@jkotas
Copy link
Member

jkotas commented Jun 5, 2021

so PreserveSig == false is no op.

PreserveSig == false is plain wrong for these PInvokes. It is mismatched PInvoke signature that can lead to unpredictable behavior at runtime.

@ryalanms ryalanms merged commit 96b6c11 into dotnet:main Jun 7, 2021
@kant2002 kant2002 deleted the kant/marshal-fix branch June 8, 2021 02:39
@ghost ghost locked as resolved and limited conversation to collaborators Apr 8, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
PR metadata: Label to tag PRs, to facilitate with triage
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants