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

            try
            {
                uint flNewProtect;
                MemManager.VirtualProtectEx(this.processHandle, pOffset, (UIntPtr)((ulong)((long)pBytes.Length)), 4u, out flNewProtect);
                bool flag = MemManager.WriteProcessMemory(this.processHandle, pOffset, pBytes, (uint)pBytes.Length, 0u);
                MemManager.VirtualProtectEx(this.processHandle, pOffset, (UIntPtr)((ulong)((long)pBytes.Length)), flNewProtect, out flNewProtect);
                result = flag;
            }
            catch (Exception ex)
            {
                if (MemManager.debugMode)
                {
                    Console.WriteLine("Error: WriteByteArray" + ex.ToString());
                }
                result = false;
            }
            return(result);
        }
Exemplo n.º 2
0
        public bool CheckProcess()
        {
            if (this.ProcessName == null)
            {
                Debugger.Log(1, "setting", "Programmer, define process name first!");
                return(false);
            }

            if (MainProcess.HasExited)
            {
                this.MainProcess = Process.GetProcessesByName(this.ProcessName).FirstOrDefault();
                if (this.MainProcess == null)
                {
                    this.ErrorProcessNotFound(this.ProcessName);
                    return(false);
                }
            }

            this.processHandle = MemManager.OpenProcess(2035711u, false, this.MainProcess.Id);
            if (this.processHandle == IntPtr.Zero)
            {
                this.ErrorProcessNotFound(this.ProcessName);
                return(false);
            }
            return(true);
        }
Exemplo n.º 3
0
 public byte[] ReadByteArray(IntPtr pOffset, uint pSize)
 {
     if (this.processHandle == IntPtr.Zero)
     {
         this.CheckProcess();
     }
     byte[] result;
     try
     {
         uint flNewProtect;
         MemManager.VirtualProtectEx(this.processHandle, pOffset, (UIntPtr)pSize, 4u, out flNewProtect);
         byte[] array = new byte[pSize];
         MemManager.ReadProcessMemory(this.processHandle, pOffset, array, pSize, 0u);
         MemManager.VirtualProtectEx(this.processHandle, pOffset, (UIntPtr)pSize, flNewProtect, out flNewProtect);
         result = array;
     }
     catch (Exception ex)
     {
         if (MemManager.debugMode)
         {
             Console.WriteLine("Error: ReadByteArray" + ex.ToString());
         }
         result = new byte[1];
     }
     return(result);
 }