Так. Давай я скопирую в следующем посте твой класс и будем с ним постепенно разбираться, так как там почти тысяча строк кода. Для начала я приведу в порядок форматирование, потому что в текущем виде читать его невозможно. Исходный код класса: using System;using System.Diagnostics;using System.Runtime.CompilerServices;using System.Runtime.InteropServices;using System.Text;using System.Windows.Forms; public class VAMemory{private IntPtr baseAddress;public static bool debugMode;private Process[] mainProcess;private IntPtr processHandle;private ProcessModule processModule; public VAMemory(){} public VAMemory(string pProcessName){this.processName = pProcessName;} public bool CheckProcess(){if (this.processName != null){this.mainProcess = Process.GetProcessesByName(this.processName);if (this.mainProcess.Length == 0){this.ErrorProcessNotFound(this.processName);return false;}this.processHandle = OpenProcess(0x1f0fff, false, this.mainProcess[0].Id);if (this.processHandle == IntPtr.Zero){this.ErrorProcessNotFound(this.processName);return false;}return true;}MessageBox.Show("Programmer, define process name first!");return false;} [DllImport("kernel32.dll")]private static extern bool CloseHandle(IntPtr hObject);private void ErrorProcessNotFound(string pProcessName){MessageBox.Show(this.processName + " is not running or has not been found. Please check and try again", "Process Not Found", MessageBoxButtons.OK, MessageBoxIcon.Hand);} [DllImport("kernel32.dll")]private static extern IntPtr OpenProcess(uint dwDesiredAccess, bool bInheritHandle, int dwProcessId);public bool ReadBoolean(IntPtr pOffset){if (this.processHandle == IntPtr.Zero){this.CheckProcess();}try{return BitConverter.ToBoolean(this.ReadByteArray(pOffset, 1), 0);}catch (Exception exception){if (debugMode){Console.WriteLine("Error: ReadByte" + exception.ToString());}return false;}} public byte ReadByte(IntPtr pOffset){if (this.processHandle == IntPtr.Zero){this.CheckProcess();}try{return this.ReadByteArray(pOffset, 1)[0];}catch (Exception exception){if (debugMode){Console.WriteLine("Error: ReadByte" + exception.ToString());}return 0;}} public byte[] ReadByteArray(IntPtr pOffset, uint pSize){if (this.processHandle == IntPtr.Zero){this.CheckProcess();}try{uint num;VirtualProtectEx(this.processHandle, pOffset, (UIntPtr) pSize, 4, out num);byte[] lpBuffer = new byte[pSize];ReadProcessMemory(this.processHandle, pOffset, lpBuffer, pSize, 0);VirtualProtectEx(this.processHandle, pOffset, (UIntPtr) pSize, num, out num);return lpBuffer;}catch (Exception exception){if (debugMode){Console.WriteLine("Error: ReadByteArray" + exception.ToString());}return new byte[1];}} public char ReadChar(IntPtr pOffset){if (this.processHandle == IntPtr.Zero){this.CheckProcess();}try{return BitConverter.ToChar(this.ReadByteArray(pOffset, 1), 0);}catch (Exception exception){if (debugMode){Console.WriteLine("Error: ReadChar" + exception.ToString());}return ' ';}} public double ReadDouble(IntPtr pOffset){if (this.processHandle == IntPtr.Zero){this.CheckProcess();}try{return BitConverter.ToDouble(this.ReadByteArray(pOffset, 8), 0);}catch (Exception exception){if (debugMode){Console.WriteLine("Error: ReadDouble" + exception.ToString());}return 0.0;}} public float ReadFloat(IntPtr pOffset){if (this.processHandle == IntPtr.Zero){this.CheckProcess();}try{return BitConverter.ToSingle(this.ReadByteArray(pOffset, 4), 0);}catch (Exception exception){if (debugMode){Console.WriteLine("Error: ReadFloat" + exception.ToString());}return 0f;}} public short ReadInt16(IntPtr pOffset){if (this.processHandle == IntPtr.Zero){this.CheckProcess();}try{return BitConverter.ToInt16(this.ReadByteArray(pOffset, 2), 0);}catch (Exception exception){if (debugMode){Console.WriteLine("Error: ReadInt16" + exception.ToString());}return 0;}} public int ReadInt32(IntPtr pOffset){if (this.processHandle == IntPtr.Zero){this.CheckProcess();}try{return BitConverter.ToInt32(this.ReadByteArray(pOffset, 4), 0);}catch (Exception exception){if (debugMode){Console.WriteLine("Error: ReadInt32" + exception.ToString());}return 0;}} public long ReadInt64(IntPtr pOffset){if (this.processHandle == IntPtr.Zero){this.CheckProcess();}try{return BitConverter.ToInt64(this.ReadByteArray(pOffset, 8), 0);}catch (Exception exception){if (debugMode){Console.WriteLine("Error: ReadInt64" + exception.ToString());}return 0L;}} public int ReadInteger(IntPtr pOffset){if (this.processHandle == IntPtr.Zero){this.CheckProcess();}try{return BitConverter.ToInt32(this.ReadByteArray(pOffset, 4), 0);}catch (Exception exception){if (debugMode){Console.WriteLine("Error: ReadInteger" + exception.ToString());}return 0;}} public long ReadLong(IntPtr pOffset){if (this.processHandle == IntPtr.Zero){this.CheckProcess();}try{return BitConverter.ToInt64(this.ReadByteArray(pOffset, 8), 0);}catch (Exception exception){if (debugMode){Console.WriteLine("Error: ReadLong" + exception.ToString());}return 0L;}} [DllImport("kernel32.dll", SetLastError=true)]private static extern bool ReadProcessMemory(IntPtr hProcess, IntPtr lpBaseAddress, byte[] lpBuffer, uint dwSize, uint lpNumberOfBytesRead);public short ReadShort(IntPtr pOffset){if (this.processHandle == IntPtr.Zero){this.CheckProcess();}try{return BitConverter.ToInt16(this.ReadByteArray(pOffset, 2), 0);}catch (Exception exception){if (debugMode){Console.WriteLine("Error: ReadInt16" + exception.ToString());}return 0;}} public string ReadStringASCII(IntPtr pOffset, uint pSize){if (this.processHandle == IntPtr.Zero){this.CheckProcess();}try{return Encoding.ASCII.GetString(this.ReadByteArray(pOffset, pSize), 0, (int) pSize);}catch (Exception exception){if (debugMode){Console.WriteLine("Error: ReadStringASCII" + exception.ToString());}return "";}} public string ReadStringUnicode(IntPtr pOffset, uint pSize){if (this.processHandle == IntPtr.Zero){this.CheckProcess();}try{return Encoding.Unicode.GetString(this.ReadByteArray(pOffset, pSize), 0, (int) pSize);}catch (Exception exception){if (debugMode){Console.WriteLine("Error: ReadStringUnicode" + exception.ToString());}return "";}} public ushort ReadUInt16(IntPtr pOffset){if (this.processHandle == IntPtr.Zero){this.CheckProcess();}try{return BitConverter.ToUInt16(this.ReadByteArray(pOffset, 2), 0);}catch (Exception exception){if (debugMode){Console.WriteLine("Error: ReadUInt16" + exception.ToString());}return 0;}} public uint ReadUInt32(IntPtr pOffset){if (this.processHandle == IntPtr.Zero){this.CheckProcess();}try{return BitConverter.ToUInt32(this.ReadByteArray(pOffset, 4), 0);}catch (Exception exception){if (debugMode){Console.WriteLine("Error: ReadUInt32" + exception.ToString());}return 0;}} public ulong ReadUInt64(IntPtr pOffset){if (this.processHandle == IntPtr.Zero){this.CheckProcess();}try{return BitConverter.ToUInt64(this.ReadByteArray(pOffset, 8), 0);}catch (Exception exception){if (debugMode){Console.WriteLine("Error: ReadUInt64" + exception.ToString());}return 0L;}} public uint ReadUInteger(IntPtr pOffset){if (this.processHandle == IntPtr.Zero){this.CheckProcess();}try{return BitConverter.ToUInt32(this.ReadByteArray(pOffset, 4), 0);}catch (Exception exception){if (debugMode){Console.WriteLine("Error: ReadUInteger" + exception.ToString());}return 0;}} public long ReadULong(IntPtr pOffset){if (this.processHandle == IntPtr.Zero){this.CheckProcess();}try{return (long) BitConverter.ToUInt64(this.ReadByteArray(pOffset, 8), 0);}catch (Exception exception){if (debugMode){Console.WriteLine("Error: ReadULong" + exception.ToString());}return 0L;}} public ushort ReadUShort(IntPtr pOffset){if (this.processHandle == IntPtr.Zero){this.CheckProcess();}try{return BitConverter.ToUInt16(this.ReadByteArray(pOffset, 2), 0);}catch (Exception exception){if (debugMode){Console.WriteLine("Error: ReadUShort" + exception.ToString());}return 0;}} [DllImport("kernel32.dll", SetLastError=true, ExactSpelling=true)]private static extern IntPtr VirtualAllocEx(IntPtr hProcess, IntPtr lpAddress, uint dwSize, uint flAllocationType, uint flProtect);[DllImport("kernel32.dll")]private static extern bool VirtualProtectEx(IntPtr hProcess, IntPtr lpAddress, UIntPtr dwSize, uint flNewProtect, out uint lpflOldProtect);public bool WriteBoolean(IntPtr pOffset, bool pData){if (this.processHandle == IntPtr.Zero){this.CheckProcess();}try{return this.WriteByteArray(pOffset, BitConverter.GetBytes(pData));}catch (Exception exception){if (debugMode){Console.WriteLine("Error: WriteBoolean" + exception.ToString());}return false;}} public bool WriteByte(IntPtr pOffset, byte pData){if (this.processHandle == IntPtr.Zero){this.CheckProcess();}try{return this.WriteByteArray(pOffset, BitConverter.GetBytes((short) pData));}catch (Exception exception){if (debugMode){Console.WriteLine("Error: WriteByte" + exception.ToString());}return false;}} public bool WriteByteArray(IntPtr pOffset, byte[] pBytes){if (this.processHandle == IntPtr.Zero){this.CheckProcess();}try{uint num;VirtualProtectEx(this.processHandle, pOffset, (UIntPtr) pBytes.Length, 4, out num);bool flag = WriteProcessMemory(this.processHandle, pOffset, pBytes, (uint) pBytes.Length, 0);VirtualProtectEx(this.processHandle, pOffset, (UIntPtr) pBytes.Length, num, out num);return flag;}catch (Exception exception){if (debugMode){Console.WriteLine("Error: WriteByteArray" + exception.ToString());}return false;}} public bool WriteChar(IntPtr pOffset, char pData){if (this.processHandle == IntPtr.Zero){this.CheckProcess();}try{return this.WriteByteArray(pOffset, BitConverter.GetBytes(pData));}catch (Exception exception){if (debugMode){Console.WriteLine("Error: WriteChar" + exception.ToString());}return false;}} public bool WriteDouble(IntPtr pOffset, double pData){if (this.processHandle == IntPtr.Zero){this.CheckProcess();}try{return this.WriteByteArray(pOffset, BitConverter.GetBytes(pData));}catch (Exception exception){if (debugMode){Console.WriteLine("Error: WriteDouble" + exception.ToString());}return false;}} public bool WriteFloat(IntPtr pOffset, float pData){if (this.processHandle == IntPtr.Zero){this.CheckProcess();}try{return this.WriteByteArray(pOffset, BitConverter.GetBytes(pData));}catch (Exception exception){if (debugMode){Console.WriteLine("Error: WriteFloat" + exception.ToString());}return false;}} public bool WriteInt16(IntPtr pOffset, short pData){if (this.processHandle == IntPtr.Zero){this.CheckProcess();}try{return this.WriteByteArray(pOffset, BitConverter.GetBytes(pData));}catch (Exception exception){if (debugMode){Console.WriteLine("Error: WriteInt16" + exception.ToString());}return false;}} public bool WriteInt32(IntPtr pOffset, int pData){if (this.processHandle == IntPtr.Zero){this.CheckProcess();}try{return this.WriteByteArray(pOffset, BitConverter.GetBytes(pData));}catch (Exception exception){if (debugMode){Console.WriteLine("Error: WriteInt32" + exception.ToString());}return false;}} public bool WriteInt64(IntPtr pOffset, long pData){if (this.processHandle == IntPtr.Zero){this.CheckProcess();}try{return this.WriteByteArray(pOffset, BitConverter.GetBytes(pData));}catch (Exception exception){if (debugMode){Console.WriteLine("Error: WriteInt64" + exception.ToString());}return false;}} public bool WriteInteger(IntPtr pOffset, int pData){if (this.processHandle == IntPtr.Zero){this.CheckProcess();}try{return this.WriteByteArray(pOffset, BitConverter.GetBytes(pData));}catch (Exception exception){if (debugMode){Console.WriteLine("Error: WriteInt" + exception.ToString());}return false;}} public bool WriteLong(IntPtr pOffset, long pData){if (this.processHandle == IntPtr.Zero){this.CheckProcess();}try{return this.WriteByteArray(pOffset, BitConverter.GetBytes(pData));}catch (Exception exception){if (debugMode){Console.WriteLine("Error: WriteLong" + exception.ToString());}return false;}} [DllImport("kernel32.dll")]private static extern bool WriteProcessMemory(IntPtr hProcess, IntPtr lpBaseAddress, byte[] lpBuffer, uint nSize, uint lpNumberOfBytesWritten);public bool WriteShort(IntPtr pOffset, short pData){if (this.processHandle == IntPtr.Zero){this.CheckProcess();}try{return this.WriteByteArray(pOffset, BitConverter.GetBytes(pData));}catch (Exception exception){if (debugMode){Console.WriteLine("Error: WriteShort" + exception.ToString());}return false;}} public bool WriteStringASCII(IntPtr pOffset, string pData){if (this.processHandle == IntPtr.Zero){this.CheckProcess();}try{return this.WriteByteArray(pOffset, Encoding.ASCII.GetBytes(pData));}catch (Exception exception){if (debugMode){Console.WriteLine("Error: WriteStringASCII" + exception.ToString());}return false;}} public bool WriteStringUnicode(IntPtr pOffset, string pData){if (this.processHandle == IntPtr.Zero){this.CheckProcess();}try{return this.WriteByteArray(pOffset, Encoding.Unicode.GetBytes(pData));}catch (Exception exception){if (debugMode){Console.WriteLine("Error: WriteStringUnicode" + exception.ToString());}return false;}} public bool WriteUInt16(IntPtr pOffset, ushort pData){if (this.processHandle == IntPtr.Zero){this.CheckProcess();}try{return this.WriteByteArray(pOffset, BitConverter.GetBytes(pData));}catch (Exception exception){if (debugMode){Console.WriteLine("Error: WriteUInt16" + exception.ToString());}return false;}} public bool WriteUInt32(IntPtr pOffset, uint pData){if (this.processHandle == IntPtr.Zero){this.CheckProcess();}try{return this.WriteByteArray(pOffset, BitConverter.GetBytes(pData));}catch (Exception exception){if (debugMode){Console.WriteLine("Error: WriteUInt32" + exception.ToString());}return false;}} public bool WriteUInt64(IntPtr pOffset, ulong pData){if (this.processHandle == IntPtr.Zero){this.CheckProcess();}try{return this.WriteByteArray(pOffset, BitConverter.GetBytes(pData));}catch (Exception exception){if (debugMode){Console.WriteLine("Error: WriteUInt64" + exception.ToString());}return false;}} public bool WriteUInteger(IntPtr pOffset, uint pData){if (this.processHandle == IntPtr.Zero){this.CheckProcess();}try{return this.WriteByteArray(pOffset, BitConverter.GetBytes(pData));}catch (Exception exception){if (debugMode){Console.WriteLine("Error: WriteUInt" + exception.ToString());}return false;}} public bool WriteULong(IntPtr pOffset, ulong pData){if (this.processHandle == IntPtr.Zero){this.CheckProcess();}try{return this.WriteByteArray(pOffset, BitConverter.GetBytes(pData));}catch (Exception exception){if (debugMode){Console.WriteLine("Error: WriteULong" + exception.ToString());}return false;}} public bool WriteUShort(IntPtr pOffset, ushort pData){if (this.processHandle == IntPtr.Zero){this.CheckProcess();}try{return this.WriteByteArray(pOffset, BitConverter.GetBytes(pData));}catch (Exception exception){if (debugMode){Console.WriteLine("Error: WriteShort" + exception.ToString());}return false;}} public long getBaseAddress{get{this.baseAddress = IntPtr.Zero;this.processModule = this.mainProcess[0].MainModule;this.baseAddress = this.processModule.BaseAddress;return (long) this.baseAddress;}} public string processName { get; set; } [Flags]private enum ProcessAccessFlags : uint{All = 0x1f0fff,CreateThread = 2,DupHandle = 0x40,QueryInformation = 0x400,SetInformation = 0x200,Synchronize = 0x100000,Terminate = 1,VMOperation = 8,VMRead = 0x10,VMWrite = 0x20} private enum VirtualMemoryProtection : uint{PAGE_EXECUTE = 0x10,PAGE_EXECUTE_READ = 0x20,PAGE_EXECUTE_READWRITE = 0x40,PAGE_EXECUTE_WRITECOPY = 0x80,PAGE_GUARD = 0x100,PAGE_NOACCESS = 1,PAGE_NOCACHE = 0x200,PAGE_READONLY = 2,PAGE_READWRITE = 4,PAGE_WRITECOPY = 8,PROCESS_ALL_ACCESS = 0x1f0fff}} using System;using System.Diagnostics;using System.Runtime.CompilerServices;using System.Runtime.InteropServices;using System.Text;using System.Windows.Forms;public class VAMemory{}private IntPtr baseAddress;public static bool debugMode;private Process[] mainProcess;private IntPtr processHandle;private ProcessModule processModule;public VAMemory(){}public VAMemory(string pProcessName){this.processName = pProcessName;} public bool CheckProcess(){if (this.processName != null){this.mainProcess = Process.GetProcessesByName(this.processName);if (this.mainProcess.Length == 0){this.ErrorProcessNotFound(this.processName);return false;}this.processHandle = OpenProcess(0x1f0fff, false, this.mainProcess[0].Id);if (this.processHandle == IntPtr.Zero){this.ErrorProcessNotFound(this.processName);return false;}return true;}MessageBox.Show("Programmer, define process name first!");return false;}[DllImport("kernel32.dll")]private static extern bool CloseHandle(IntPtr hObject);private void ErrorProcessNotFound(string pProcessName){MessageBox.Show(this.processName +" is not running or has not been found. Please check and try again","Process Not Found", MessageBoxButtons.OK, MessageBoxIcon.Hand);}[DllImport("kernel32.dll")]private static extern IntPtr OpenProcess(uint dwDesiredAccess,bool bInheritHandle, int dwProcessId); public bool ReadBoolean(IntPtr pOffset){if (this.processHandle == IntPtr.Zero){this.CheckProcess();}try{return BitConverter.ToBoolean(this.ReadByteArray(pOffset, 1), 0);}catch (Exception exception){if (debugMode){Console.WriteLine("Error: ReadByte" + exception.ToString());}return false;}} public byte ReadByte(IntPtr pOffset){if (this.processHandle == IntPtr.Zero){this.CheckProcess();}try{return this.ReadByteArray(pOffset, 1)[0];}catch (Exception exception){if (debugMode){Console.WriteLine("Error: ReadByte" + exception.ToString());}return 0;}}