We can declare 1 bit fields for structs so it should be doable to have the flags declared.
On a side note, CsWin32 could create a SafeStructHandle class to assist on void* passes where the type of struct is not known (assuming not going the overload route). Just wrapping the marshal calls below.
3. Any of your own code that should be shared?
```csharp
private unsafe void SetRedirectionPolicy() {
var polStruct = new PROCESS_MITIGATION_REDIRECTION_TRUST_POLICY();
polStruct.Anonymous.Flags = 1 << 1;
var sSize = Marshal.SizeOf(polStruct);
IntPtr ptr = Marshal.AllocHGlobal(sSize);
Marshal.StructureToPtr(polStruct, ptr, false);
if (!PInvoke.SetProcessMitigationPolicy(Windows.Win32.System.Threading.PROCESS_MITIGATION_POLICY.ProcessRedirectionTrustPolicy, ptr.ToPointer(), (nuint)sSize))
throw new Win32Exception();
Marshal.DestroyStructure(ptr,polStruct.GetType());
Marshal.FreeHGlobal(ptr);
}
Granted for my use case I still got access denied but I think the code is sound.
Actual behavior
A struct declared as:
Expected behavior
Officially it is
We can declare 1 bit fields for structs so it should be doable to have the flags declared.
On a side note, CsWin32 could create a SafeStructHandle class to assist on void* passes where the type of struct is not known (assuming not going the overload route). Just wrapping the marshal calls below.
Repro steps
NativeMethods.txt
content:NativeMethods.json
content (if present):Granted for my use case I still got access denied but I think the code is sound.
Context
net472
<PackageReference Include="Microsoft.Windows.CsWin32" Version="0.3.49-beta">