Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -696,6 +696,7 @@ internal static class WldpNativeMethods
[DefaultDllImportSearchPathsAttribute(DllImportSearchPath.System32)]
[DllImportAttribute("wldp.dll", EntryPoint = "WldpCanExecuteFile")]
internal static extern int WldpCanExecuteFile(
[MarshalAs(UnmanagedType.LPStruct)]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we add a comment here that this is needed because the first argument is a REFGUID?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I figured it out, so can anyone else. The signature of the native function isn't secret, after all. On the other hand, I would quite like it if all declarations of native functions had their full signature next to them.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The docs for LPStruct DO indicate that this should ONLY be used for REFGUID, but someone not familiar with that may not understand the connection between this type and GUID.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have made a suggestion to use the in modifier instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To allow anyone not familiar with the subject to understand why the attribute is there, you'd have to include a treatise on calling conventions and how C weirdly came up with the idea of passing structs on the stack. Anything less than that just ends up as a string of the same words you are trying to explain.

Link to https://learn.microsoft.com/en-us/dotnet/standard/native-interop/best-practices#guids ? That is what you are referring to above, I believe. That sentence doesn't say "the only type in the whole world that LPStruct should ever be used with is Guid", but "of the various ways of declaring a Guid argument, LPStruct should be used only with the ref kind". (If I find the time, I'll try and improve the Guid section of that page. I find it very confusing.)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have made a suggestion to use the in modifier instead.

Doesn't in just mean the argument is effectively const on the receiving end? I admit I have never used it, but it does not look to me like it also means to pass the thing as a pointer.

Copy link
Contributor Author

@chrullrich chrullrich Nov 14, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't in just mean the argument is effectively const on the receiving end? I admit I have never used it, but it does not look to me like it also means to pass the thing as a pointer.

Oh, I take that back.

I'll leave it to the experts to decide whether it's correct, though. My C# is far from good enough.

Guid host,
Comment on lines +699 to 700
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
[MarshalAs(UnmanagedType.LPStruct)]
Guid host,
in Guid host,

WLDP_EXECUTION_EVALUATION_OPTIONS options,
IntPtr fileHandle,
Expand Down