Im working towards a dll file for a software's SDK and i'm trying to call a function to get information about the host of the software.
there are two unsigned char variables(HostMachineAddress, HostProgramVersion) in the struct the function wants and it seems like i "loose" the last byte when i try to call it from c#... if I change the SizeConst in the c# struct below to 5 i do get the missing byte, however it causes the other variable looses data.
Could someone help me find a way to solve this issue? also trying to use a class instead of struct causes system.stackoverflow error
C# Struct
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
public struct sHostInfo
{
public int bFoundHost;
public int LatestConfirmationTime;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 128)]
public string szHostMachineName;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 4)]
public string HostMachineAddress;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 128)]
public string szHostProgramName;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 4)]
public string HostProgramVersion;
}
C#
[DllImport("Cortex_SDK.dll")]
public static extern int GetHostInfo(out sHostInfo pHostInfo);