Example #1
0
        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));
        }
Example #2
0
        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?");
            }
        }
Example #3
0
 public static string Hash(IConvertible val)
 {
     return(Hash(val.GetBytes()).To <string>());
 }
Example #4
0
 public static string Hash(IConvertible val)
 {
     return Hash(val.GetBytes()).To<string>();
 }