1. [Flags]
  2.         public enum ProcessAccessType
  3.         {
  4.             PROCESS_TERMINATE = (0x0001),
  5.             PROCESS_CREATE_THREAD = (0x0002),
  6.             PROCESS_SET_SESSIONID = (0x0004),
  7.             PROCESS_VM_OPERATION = (0x0008),
  8.             PROCESS_VM_READ = (0x0010),
  9.             PROCESS_VM_WRITE = (0x0020),
  10.             PROCESS_DUP_HANDLE = (0x0040),
  11.             PROCESS_CREATE_PROCESS = (0x0080),
  12.             PROCESS_SET_QUOTA = (0x0100),
  13.             PROCESS_SET_INFORMATION = (0x0200),
  14.             PROCESS_QUERY_INFORMATION = (0x0400)
  15.         }
  16.         [DllImport("kernel32.dll")]
  17.         public static extern IntPtr OpenProcess(UInt32 dwDesiredAccess, Int32 bInheritHandle, UInt32 dwProcessId);
  18.         [DllImport("kernel32.dll")]
  19.         public static extern Int32 CloseHandle(IntPtr hObject);
  20.         [DllImport("kernel32.dll")]
  21.         public static extern Int32 ReadProcessMemory(IntPtr hProcess, IntPtr lpBaseAddress, [In, Out] byte[] buffer, UInt32 size, out IntPtr lpNumberOfBytesRead);
  22.         [DllImport("kernel32.dll")]
  23.         public static extern Int32 WriteProcessMemory(IntPtr hProcess, IntPtr lpBaseAddress, [In, Out] byte[] buffer, UInt32 size, out IntPtr lpNumberOfBytesWritten);
  24.  
  25.  
  26.         public bool StartHacking(string ApplicationX)
  27.         {
  28.             Process[] pArray = Process.GetProcessesByName(ApplicationX);
  29.             if (pArray.Length == 0) { return false; }
  30.             ReadProcess = pArray[0];
  31.             Open();
  32.             return true;
  33.         }
  34.         public void StopHacking()
  35.         {
  36.             try
  37.             {
  38.                 int iRetValue;
  39.                 iRetValue = CloseHandle(m_hProcess);
  40.                 if (iRetValue == 0)
  41.                     iRetValue = 0;
  42.  
  43.             }
  44.             catch { }
  45.         }
  46.         public void WriteInt(int Address, int Value, int bytes)
  47.         {
  48.             int byteswritten;
  49.             WriteFix((IntPtr)Address, BitConverter.GetBytes(Value), bytes, out byteswritten);
  50.         }
  51.         public void WriteBytes(int Address, byte[] Value, int bytes)
  52.         {
  53.             int byteswritten;
  54.             WriteFix((IntPtr)Address, Value, bytes, out byteswritten);
  55.         }
  56.         public void WriteNOP(int Address)
  57.         {
  58.             byte[] nop = { 0x90, 0x90, 0x90, 0x90, 0x90 };
  59.             WriteBytes(Address, nop, 5);
  60.         }
  61.  
  62.         private Process ReadProcess
  63.         {
  64.             get
  65.             {
  66.                 return m_ReadProcess;
  67.             }
  68.             set
  69.             {
  70.                 m_ReadProcess = value;
  71.             }
  72.         }
  73.         private Process m_ReadProcess = null;
  74.         private IntPtr m_hProcess = IntPtr.Zero;
  75.         private void Open()
  76.         {
  77.             ProcessAccessType access;
  78.             access = ProcessAccessType.PROCESS_VM_READ
  79.             | ProcessAccessType.PROCESS_VM_WRITE
  80.             | ProcessAccessType.PROCESS_VM_OPERATION;
  81.             m_hProcess = OpenProcess((uint)access, 1, (uint)m_ReadProcess.Id);
  82.         }
  83.         private void WriteFix(IntPtr MemoryAddress, byte[] bytesToWrite, int BytesToWrite, out int bytesWritten)
  84.         {
  85.             IntPtr ptrBytesWritten;
  86.             WriteProcessMemory(m_hProcess, MemoryAddress, bytesToWrite, (uint)BytesToWrite, out ptrBytesWritten);
  87.             bytesWritten = ptrBytesWritten.ToInt32();
  88.         }
  89.     }
  90.  
  91.     public class Extra
  92.     {
  93.         [DllImport("user32.dll")]
  94.         public static extern short GetAsyncKeyState(Keys vKey);
  95.  
  96.         public bool HotKey(Keys HotKey)
  97.         {
  98.             bool HotKeyX = Convert.ToBoolean(GetAsyncKeyState(HotKey));
  99.             if (HotKeyX)
  100.                 return true;
  101.             else
  102.                 return false;
  103.         }
  104.     }