I have a structure definition in C++ as below
typedef struct { unsigned __int32 SetCommonPOP:1; unsigned __int32 SetCommonSVP:1; unsigned __int32 SetCommonUHDP:1; unsigned __int32 SetCommonMHDP:1; unsigned __int32 MinPwdLength:8; unsigned __int32 MaxPwdLength:8; unsigned __int32 StoredHdpBackups:8; } HPM_PWD_CONSTRAINTS; I translated that to c# as below
[StructLayout(LayoutKind.Explicit, Size=28, CharSet=CharSet.Ansi)] public struct HPM_PWD_CONSTRAINTS { [FieldOffset(0)] public uint SetCommonPOP; [FieldOffset(1)] public uint SetCommonSVP; [FieldOffset(2)] public uint SetCommonUHDP; [FieldOffset(3)] public uint SetCommonMHDP; [FieldOffset(4)] public uint MinPwdLength; [FieldOffset(12)] public uint MaxPwdLength; [FieldOffset(20)] public uint StoredHdpBackups; }; The code in c++ which I am converting to c# defines an object PWD of this structure and passes the value of an int x to this object.
*((uint*)&PWD) = x; How does this work? What would be the value of the structure object after this? How do I convert this to C#?
uints in the struct should probably bebytes.