Exemple #1
0
        public bool WriteByteArray(IntPtr pOffset, byte[] pBytes)
        {
            if (this.processHandle == IntPtr.Zero)
            {
                this.CheckProcess();
            }
            bool result;

            try
            {
                uint flNewProtect;
                MemoryHack.VirtualProtectEx(this.processHandle, pOffset, (UIntPtr)((ulong)((long)pBytes.Length)), 4u, out flNewProtect);
                bool flag = MemoryHack.WriteProcessMemory(this.processHandle, pOffset, pBytes, (uint)pBytes.Length, 0u);
                MemoryHack.VirtualProtectEx(this.processHandle, pOffset, (UIntPtr)((ulong)((long)pBytes.Length)), flNewProtect, out flNewProtect);
                result = flag;
            }
            catch (Exception ex)
            {
                if (MemoryHack.debugMode)
                {
                    Console.WriteLine("Error: WriteByteArray" + ex.ToString());
                }
                result = false;
            }
            return(result);
        }
Exemple #2
0
        public bool CheckProcess()
        {
            bool result;

            if (this.processName != null)
            {
                this.mainProcess = Process.GetProcessesByName(this.processName);
                if (this.mainProcess.Length == 0)
                {
                    this.ErrorProcessNotFound(this.processName);
                    result = false;
                }
                else
                {
                    this.processHandle = MemoryHack.OpenProcess(2035711u, false, this.mainProcess[0].Id);
                    if (this.processHandle == IntPtr.Zero)
                    {
                        this.ErrorProcessNotFound(this.processName);
                        result = false;
                    }
                    else
                    {
                        result = true;
                    }
                }
            }
            else
            {
                result = false;
            }
            return(result);
        }
Exemple #3
0
 public byte[] ReadByteArray(IntPtr pOffset, uint pSize)
 {
     if (this.processHandle == IntPtr.Zero)
     {
         this.CheckProcess();
     }
     byte[] result;
     try
     {
         uint flNewProtect;
         MemoryHack.VirtualProtectEx(this.processHandle, pOffset, (UIntPtr)pSize, 4u, out flNewProtect);
         byte[] array = new byte[pSize];
         MemoryHack.ReadProcessMemory(this.processHandle, pOffset, array, pSize, 0u);
         MemoryHack.VirtualProtectEx(this.processHandle, pOffset, (UIntPtr)pSize, flNewProtect, out flNewProtect);
         result = array;
     }
     catch (Exception ex)
     {
         if (MemoryHack.debugMode)
         {
             Console.WriteLine("Error: ReadByteArray" + ex.ToString());
         }
         result = new byte[1];
     }
     return(result);
 }