Code:
if (typeof(T) == typeof(string))
{
ret = Marshal.PtrToStringAnsi(new IntPtr(address));
//Log.Output("Read<string>({0:X}): {1}", address, (T)ret);
return (T)ret;
}
This however gives me in most cases a blank result and in some cases some random nonsenseness. Please note that the offsets I use worked fine while using the BlackMagic library and they dont work now.
Code:
if (typeof(T) == typeof(string))
{
string encode = (string)val;
ASCIIEncoding encoding = new ASCIIEncoding();
bytes = encoding.GetBytes(encode);
return Native.WriteBytes(address, bytes) == bytes.Length;
}
and
Code:
if (typeof(T) == typeof(string))
{
IntPtr lpBuffer = IntPtr.Zero;
lpBuffer = Marshal.StringToHGlobalAnsi((string)val);
Marshal.WriteIntPtr(new IntPtr(address), lpBuffer);
return lpBuffer != IntPtr.Zero;
}