[StructLayout(LayoutKind.Sequential, Size = 280), Serializable]
public struct AESContext
{
/// int nr;
[MarshalAsAttribute(UnmanagedType.I4, SizeConst = 4)]
public int nr;
/// unsigned long *rk;
[MarshalAsAttribute(UnmanagedType.U4, SizeConst = 4)]
public uint rk;
// unsigned long buf[68];
[MarshalAsAttribute(UnmanagedType.ByValArray, SizeConst = 68)]
public uint[] buf;
}
This is C# struct I have so far. Comment above each field is type in C.
I would love if someone could verify.
It sounds like you’re trying to get the C# struct for the C struct defined in the member contents. If so then I believe you want the following
Basic changes
SizeConstinStructLayoutunless you are trying to create a struct whose size is different (typically) bigger than it’s contents. It’s not very common to do thisMarshalAsisn’t usually needed for primitive typesIntPtrorUIntPtrto PInvoke pointer types. They vary properly in size between 32 and 64 bit platforms