public static Stream Add(this Stream stream, IConvertible val) { byte[] data; if (val.GetType() == typeof(string)) { data = val != null?val.GetBytes() : String.Empty.GetBytes(); var lengthBytes = data.Length.GetBytes(); stream.Write(lengthBytes, 0, lengthBytes.Length); } else { data = val.GetBytes(); } return(stream.Add(data)); }
public void Write(IntPtr address, IConvertible value) { var type = value.GetType(); if (type == typeof(string)) { value += "\0"; } var bytes = value.GetBytes(); IntPtr written; NativeMethods.WriteProcessMemory(hProc, address, bytes, bytes.Length, out written); if ((int)written != bytes.Length) { throw new MemoryException("could not write value, maybe it's protected?"); } }
public static string Hash(IConvertible val) { return(Hash(val.GetBytes()).To <string>()); }
public static string Hash(IConvertible val) { return Hash(val.GetBytes()).To<string>(); }