Exemple #1
0
		/// <summary> Writes the given buffer at the specified memory address </summary>
		/// <returns> The number of bytes written </returns>
		public unsafe int WriteMemory(ulong address, byte[] buffer)
		{
			if (buffer.Length == 0) return 0;
			int written;
			fixed(byte* pBuffer = buffer) {
				written = (int)corProcess.WriteMemory(address, (uint)buffer.Length, new IntPtr(pBuffer));
			}
			return written;
		}
        public void WriteMemory(ulong address, byte[] bytes)
        {
            uint   size     = (uint)bytes.Length;
            IntPtr bytesPtr = Marshal.AllocHGlobal((int)size);

            Marshal.Copy(bytes, 0, bytesPtr, (int)size);

            try
            {
                _comProcess.WriteMemory(address, size, bytesPtr, out size);
            }
            finally
            {
                Marshal.FreeHGlobal(bytesPtr);
            }
        }