So its pretty simple issue
[StructLayout(LayoutKind.Sequential)]
public struct test
{
public uint a;
}
^ This marshals to size of 4
[StructLayout(LayoutKind.Sequential)]
public struct test
{
public IntPtr b;
}
^ This marshals to size of 8
[StructLayout(LayoutKind.Sequential)]
public struct test
{
public uint a;
public IntPtr b;
}
^ This marshals to size of 16
Now I'm not sure if my calculator is broken or something but I'm pretty sure 8+4 isnt 16..... Is there any reason this nonsense is taking place?
I need it to produce the correct size for use with windows API calls
Well I'm trying to call "NtQueryInformationThread" and my struct is invalid for that here is the structure:
[StructLayout(LayoutKind.Sequential)]
public struct TbiClientId
{
public IntPtr UniqueProcess;
public IntPtr UniqueThread;
}
[StructLayout(LayoutKind.Sequential)]
public struct ThreadBasicInformation
{
public uint ExitStatus;
public IntPtr TebBaseAdress;
public int ProcessId;
public TbiClientId ClientId;
public UIntPtr AffinityMask;
public uint Priority;
public uint BasePriority;
}
Under marshal.sizeof this comes out as 56 yet the API only accepts 48 if I pass 48 to the API it returns a success and fills the struct....