public void Write <T>(IntPtr address, T[] values, bool relative = false) { var type = typeof(T); int size; if (type == typeof(IntPtr)) { size = this.Is64 ? 8 : 4; } else { size = MarshalType <T> .Size; } var bytes = new byte[size * values.Length]; for (var i = 0; i < values.Length; i++) { var offset = size * i; Buffer.BlockCopy(MarshalType <T> .ObjectToByteArray(values[i], this.Is64), 0, bytes, offset, size); } this.WriteBytes(address, bytes, relative); }
/// <summary> /// Writes the value of a type in the remote process memory. /// </summary> /// <param name="address"> /// Address to write at. /// </param> /// <param name="value"> /// Value to write. /// </param> /// <param name="relative"> /// Address is relative to the main module. /// </param> /// <typeparam name="T"> /// Type of the value. /// </typeparam> public void Write <T>(IntPtr address, T value, bool relative = false) { this.WriteBytes(address, MarshalType <T> .ObjectToByteArray(value, this.Is64), relative); }