title: C# ReadInt32, ReadMemoryPointerInt, WriteMemoryPointerInt
body: <pre><code>using System;
  using System.Collections.Generic;
  using System.ComponentModel;
  using System.Diagnostics;
  using System.Drawing;
  using System.Globalization;
  using System.IO;
  using System.Net;
  using System.Reflection;
  using System.Runtime.InteropServices;
  using System.Text;
  using System.Threading;
  using System.Windows.Forms;
  using System.Windows.Input;
  using System.Management;
  using System.Linq;
  using DZEThaitro.Classes;
  using DZEThaitro.Properties;
  using Hotkeys;
  
  
  namespace DZEThaitro
  {
      public partial class MainForm : Form
      {
  
  
          protected override void WndProc(ref Message m)
          {
              bool flag = m.Msg == 786 &amp;&amp; !this.started;
              if (flag)
              {
                  this.Starting();
              }
              else
              {
                  bool flag2 = m.Msg == 786 &amp;&amp; this.started;
                  if (flag2)
                  {
                      this.Stopped();
                  }
              }
              base.WndProc(ref m);
          }
  
          public MainForm()
          {
              this.InitializeComponent();
              this.SeedHotkeys();
          }
           [DllImport("kernel32.dll")]
          private static extern IntPtr OpenProcess(uint dwDesiredAccess, bool bInheritHandle, int dwProcessId);
  
          [DllImport("kernel32.dll")]
          static extern bool VirtualProtectEx(IntPtr hProcess, IntPtr lpAddress, UIntPtr dwSize, uint flNewProtect, out uint lpflOldProtect);
  
          [DllImport("kernel32.dll", SetLastError = true)]
          static extern bool ReadProcessMemory(IntPtr hProcess, IntPtr lpBaseAddress, byte[] lpBuffer, uint dwSize, uint lpNumberOfBytesRead);
  
          [DllImport("kernel32.dll")]
          static extern bool WriteProcessMemory(IntPtr hProcess, IntPtr lpBaseAddress, byte[] lpBuffer, uint nSize, uint lpNumberOfBytesWritten);
  
          private IntPtr processHandle;
  
          public MainForm(int current_id)
          {
              this.processHandle = MainForm.OpenProcess(2035711u, false, current_id);
          }
  
          public byte[] ReadByteArray(IntPtr pOffset, uint pSize)
          {
              byte[] result;
              try
              {
                  uint flNewProtect;
                  MainForm.VirtualProtectEx(this.processHandle, pOffset, (UIntPtr)pSize, 4u, out flNewProtect);
                  byte[] array = new byte[pSize];
                  MainForm.ReadProcessMemory(this.processHandle, pOffset, array, pSize, 0u);
                  MainForm.VirtualProtectEx(this.processHandle, pOffset, (UIntPtr)pSize, flNewProtect, out flNewProtect);
                  result = array;
              }
              catch
              {
                  result = new byte[1];
              }
              return result;
          }
  
          public bool WriteByteArray(IntPtr pOffset, byte[] pBytes)
          {
              bool result;
              try
              {
                  uint flNewProtect;
                  MainForm.VirtualProtectEx(this.processHandle, pOffset, (UIntPtr)((ulong)((long)pBytes.Length)), 4u, out flNewProtect);
                  bool flag = MainForm.WriteProcessMemory(this.processHandle, pOffset, pBytes, (uint)pBytes.Length, 0u);
                 MainForm.VirtualProtectEx(this.processHandle, pOffset, (UIntPtr)((ulong)((long)pBytes.Length)), flNewProtect, out flNewProtect);
                  result = flag;
              }
              catch
              {
                  result = false;
              }
              return result;
          }
  
          public int ReadInt32(IntPtr pOffset)
          {
              int result;
              try
              {
                  result = BitConverter.ToInt32(this.ReadByteArray(pOffset, 4u), 0);
              }
              catch
              {
                  result = 0;
              }
              return result;
          }
  
          public float ReadFloat(IntPtr pOffset)
          {
              float result;
              try
              {
                  result = BitConverter.ToSingle(this.ReadByteArray(pOffset, 4u), 0);
              }
              catch
              {
                  result = 0f;
              }
              return result;
          }
  
          public bool WriteInt32(IntPtr pOffset, int pData)
          {
              bool result;
              try
              {
                  result = this.WriteByteArray(pOffset, BitConverter.GetBytes(pData));
              }
              catch
              {
                  result = false;
              }
              return result;
          }
  
          public bool WriteFloat(IntPtr pOffset, float pData)
          {
              bool result;
              try
              {
                  result = this.WriteByteArray(pOffset, BitConverter.GetBytes(pData));
              }
              catch
              {
                  result = false;
              }
              return result;
          }
  
          public bool WriteByte(IntPtr pOffset, byte pData)
          {
              bool result;
              try
              {
                  result = this.WriteByteArray(pOffset, BitConverter.GetBytes((short)pData));
              }
              catch
              {
                  result = false;
              }
              return result;
          }
  
  
          public int ReadMemoryPointerInt(long lpBaseAddress, int[] offsets)
          {
              foreach (int offset in offsets)
              {
                  lpBaseAddress = this.ReadInt32((IntPtr)lpBaseAddress);
                  lpBaseAddress += offset;
              }
              return this.ReadInt32((IntPtr)lpBaseAddress);
          }
  
          public float ReadMemoryPointerFloat(long lpBaseAddress, int[] offsets)
          {
              foreach (int offset in offsets)
              {
                  lpBaseAddress = this.ReadInt32((IntPtr)lpBaseAddress);
                  lpBaseAddress += offset;
              }
              return this.ReadFloat((IntPtr)lpBaseAddress);
          }
  
          public bool WriteMemoryPointerInt(long lpBaseAddress, int[] offsets, int value)
          {
              foreach (int offset in offsets)
              {
                  lpBaseAddress = this.ReadInt32((IntPtr)lpBaseAddress);
                  lpBaseAddress += offset;
              }
              return this.WriteInt32((IntPtr)lpBaseAddress, value);
          }
  
          public bool WriteMemoryPointerFloat(long lpBaseAddress, int[] offsets, float value)
          {
              foreach (int offset in offsets)
              {
                  lpBaseAddress = this.ReadInt32((IntPtr)lpBaseAddress);
                  lpBaseAddress += offset;
              }
              return this.WriteFloat((IntPtr)lpBaseAddress, value);
          }
          private void SeedHotkeys()
          {
              this.GLOBAL_HOTKEY = new GlobalHotkey(0, Keys.Tab, this);
              this.GLOBAL_HOTKEY.Register();
              List&lt;Hotkey&gt; dataSource = new List&lt;Hotkey&gt;
              {
                  new Hotkey("--", Keys.None),
                  new Hotkey("F1", Keys.F1),
                  new Hotkey("F2", Keys.F2),
                  new Hotkey("F3", Keys.F3),
                  new Hotkey("F4", Keys.F4),
                  new Hotkey("F5", Keys.F5),
                  new Hotkey("F6", Keys.F6),
                  new Hotkey("F7", Keys.F7),
                  new Hotkey("F8", Keys.F8),
                  new Hotkey("F9", Keys.F9),
                  new Hotkey("A", Keys.A),
                  new Hotkey("B", Keys.B),
                  new Hotkey("C", Keys.C),
                  new Hotkey("D", Keys.D),
                  new Hotkey("E", Keys.E),
                  new Hotkey("F", Keys.F),
                  new Hotkey("G", Keys.G),
                  new Hotkey("H", Keys.H),
                  new Hotkey("I", Keys.I),
                  new Hotkey("J", Keys.J),
                  new Hotkey("K", Keys.K),
                  new Hotkey("L", Keys.L),
                  new Hotkey("M", Keys.M),
                  new Hotkey("N", Keys.N),
                  new Hotkey("O", Keys.O),
                  new Hotkey("P", Keys.P),
                  new Hotkey("Q", Keys.Q),
                  new Hotkey("R", Keys.R),
                  new Hotkey("S", Keys.S),
                  new Hotkey("T", Keys.T),
                  new Hotkey("U", Keys.U),
                  new Hotkey("V", Keys.V),
                  new Hotkey("W", Keys.W),
                  new Hotkey("X", Keys.X),
                  new Hotkey("Y", Keys.Y),
                  new Hotkey("Z", Keys.Z)
              };
              this.SpamSKILL1ComboBox.DisplayMember = "Name";
              this.SpamSKILL1ComboBox.ValueMember = "Code";
              this.SpamSKILL1ComboBox.DataSource = dataSource;
          }
          private static void Sleep(int millisecond)
          {
              Thread.Sleep(millisecond);
          }
          public void readProcess()
          {
              Process[] processesByName = Process.GetProcessesByName(this.processname);
              Process[] array = processesByName;
              checked
              {
                  for (int i = 0; i &lt; array.Length; i++)
                  {
                      Process process = array[i];
                      this.hWnd = process.MainWindowHandle;
  
                  }
                  IntPtr intptr_ = this.hWnd;
                  string text = "GepardBypass";
                  WindowsAPI.SetWindowText(intptr_, ref text);
              }
          }
  
          private void Starting()
          {
              this.started = true;
              this.MacroSKILLTimer.Enabled = true;
              this.StatusValueLabel.Text = "Connected";
              this.StatusValueLabel.ForeColor = Color.DarkGreen;
          }
          private void Stopped()
          {
              this.started = false;
              this.MacroSKILLTimer.Enabled = false;
              this.StatusValueLabel.Text = "Disconnected";
              this.StatusValueLabel.ForeColor = Color.FromArgb(192, 0, 0);
          }
          private void AutopotCheckedChanged(object sender, EventArgs e)
          {
              CheckBox checkBox = sender as CheckBox;
              bool @checked = checkBox.Checked;
              if (@checked)
              {
                  string name = checkBox.Name;
                  if (!(name == "HPCheckBox"))
                  {
                      if (!(name == "SPCheckBox"))
                      {
                          if (name == "StatusPlayerCheckBox")
                          {
                              this.spt = true;
                          }
                      }
                      else
                      {
                          this.sp = true;
                      }
                  }
                  else
                  {
                      this.hp = true;
                  }
              }
              else
              {
                  string name2 = checkBox.Name;
                  if (!(name2 == "HPCheckBox"))
                  {
                      if (!(name2 == "SPCheckBox"))
                      {
                          if (name2 == "StatusPlayerCheckBox")
                          {
                              this.spt = false;
                          }
                      }
                      else
                      {
                          this.sp = false;
                      }
                  }
                  else
                  {
                      this.hp = false;
                  }
              }
          }
  
          private void HPHotkeyComboBox_SelectedIndexChanged(object sender, EventArgs e)
          {
              int num;
              int.TryParse(this.HPHotkeyComboBox.SelectedValue.ToString(), out num);
              this.hp_keycode = num;
              this.hpindex = this.HPHotkeyComboBox.SelectedIndex;
          }
          private void SPHotkeyComboBox_SelectedIndexChanged(object sender, EventArgs e)
          {
              int num;
              int.TryParse(this.SPHotkeyComboBox.SelectedValue.ToString(), out num);
              this.sp_keycode = num;
              this.spindex = this.SPHotkeyComboBox.SelectedIndex;
          }
          private void PercenValueChanged(object sender, EventArgs e)
          {
              NumericUpDown numericUpDown = sender as NumericUpDown;
              string name = numericUpDown.Name;
              if (!(name == "PerHPNumeric"))
              {
                  if (name == "PerSPNumeric")
                  {
                      this._persp = (int)numericUpDown.Value;
                  }
              }
              else
              {
                  this._perhp = (int)numericUpDown.Value;
              }
          }
          private void StatusPlayerHotkeyComboBox_SelectedIndexChanged(object sender, EventArgs e)
          {
  
          }
  
          private void MacroSKILLTimer_Tick(object sender, EventArgs e)
          {
              int mouse_x = ReadInt32((IntPtr)0x00C6FA30);
              int mouse_y = ReadInt32((IntPtr)0x00C6FA2C);
              int skill_ID = ReadMemoryPointerInt(BASE_ADDRESS, new int[] { 0x3F0 });
              int skilltypes = ReadMemoryPointerInt(BASE_ADDRESS, new int[] { 0x3EC });
              int skill_Lvl = ReadMemoryPointerInt(BASE_ADDRESS, new int[] { 0x3F8 });
              int aid_mouse = ReadMemoryPointerInt(BASE_ADDRESS, new int[] { 0x2EC });
  
  
              if (GetAsyncKeyState(HotkeyTypes.Hotkey1) &amp;&amp; Setting.IsMacro1)
              {
                  if (skilltypes == 1)
                  {
  
                     WriteMemoryPointerInt(BASE_ADDRESS, new int[] { 0xCC, 0x2C, 0x4BC }, skill_ID);  //4
                      WriteMemoryPointerInt(BASE_ADDRESS, new int[] { 0xCC, 0x2C, 0x4C0 }, skill_Lvl); //4
                      WriteMemoryPointerInt(BASE_ADDRESS, new int[] { 0xCC, 0x2C, 0x4C4 }, mouse_x);  //4
                     WriteMemoryPointerInt(BASE_ADDRESS, new int[] { 0xCC, 0x2C, 0x4C8 }, mouse_y); //38
                      WriteMemoryPointerInt(BASE_ADDRESS, new int[] { 0xCC, 0x2C, 0x490 }, 4);
                  }
                  else if (skilltypes == 0)
                  {
                      WriteMemoryPointerInt(BASE_ADDRESS, new int[] { 0xCC, 0x2C, 0x4BC }, skill_ID); // 4
                      WriteMemoryPointerInt(BASE_ADDRESS, new int[] { 0xCC, 0x2C, 0x4C0 }, skill_Lvl); // 18
                      WriteMemoryPointerInt(BASE_ADDRESS, new int[] { 0xCC, 0x2C, 0x4A8 }, 123123); // 18
                      WriteMemoryPointerInt(BASE_ADDRESS, new int[] { 0xCC, 0x2C, 0x490 }, 3);
                  }
                  Thread.Sleep(300);
                  return;
              }
              if(GetAsyncKeyState(Keys.LButton))
              {
                  WriteMemoryPointerInt(BASE_ADDRESS, new int[] { 0xCC, 0x2C, 0x4BC }, 0); // 18
                  WriteMemoryPointerInt(BASE_ADDRESS, new int[] { 0xCC, 0x2C, 0x4C0 }, 0); // 18
                  WriteMemoryPointerInt(BASE_ADDRESS, new int[] { 0xCC, 0x2C, 0x4A8 }, 0);
              }
          }
  
          private void MainForm_Load(object sender, EventArgs e)
          {
  
          }
          private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
          {
  
          }
  
          private GlobalHotkey GLOBAL_HOTKEY;
  
  
          private bool status;
  
          private bool started;
  
  
          private readonly string processname = "iPlayRO";
  
          private IntPtr hWnd;
  
  
          private bool hp;
  
          private bool sp;
  
  
          private bool spt;
  
          private int _perhp;
  
  
          private int _persp;
  
  
          private double perhp;
  
  
          private double persp;
  
  
          private int hp_keycode;
  
  
          private int sp_keycode;
  
  
          private int spt_keycode;
  
  
          private int hpindex;
  
  
          private int spindex;
  
  
          private int sptindex;
  
  
          private int sptvalue;
  
  
  
          private int mc1index;
  
  
          private int mc2index;
  
  
          private int ground = 1;
  
          private int enemy;
  
          [DllImport("User32.dll")]
          public static extern bool GetAsyncKeyState(Keys vKey);
  
          public static int BASE_ADDRESS = 0xB8DEDC;
  
          private void AutopotTab_Click(object sender, EventArgs e)
          {
  
          }
  
          private void FunctionsTab_Click(object sender, EventArgs e)
          {
  
          }
  
          private void statusStrip1_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
          {
  
          }
  
          private void button1_Click(object sender, EventArgs e)
          {
              MacroSKILLTimer.Enabled = true;
              Starting();
              readProcess();
          }
  
          private void SpamSKILL1ComboBox_SelectedIndexChanged(object sender, EventArgs e)
          {
              HotkeyTypes.Hotkey1 = (Keys)this.SpamSKILL1ComboBox.SelectedValue;
              Setting.IsMacro1Hotkey = (Keys)this.SpamSKILL1ComboBox.SelectedValue;
          }
  
          private void SpamSKILL1CheckBox_CheckedChanged(object sender, EventArgs e)
          {
              CheckBox checkBox = sender as CheckBox;
              CheckState checkState = checkBox.CheckState;
              if (checkState != CheckState.Unchecked)
              {
                  if (checkState == CheckState.Checked)
                  {
                      this.SpamSKILL1ComboBox.Enabled = checkBox.Checked;
  
                  }
              }
              else
              {
                  this.SpamSKILL1ComboBox.Enabled = checkBox.Checked;
  
              }
              Setting.IsMacro1 = checkBox.Checked;
          }
      }
  }
  </code></pre>
  
  <p>ReadInt32, ReadMemoryPointerInt and  WriteMemoryPointerInt not work my address and my pointers is correct and it's updated i already try <code>MessageBox.Show(mouse_x.To.String());</code> but its 0 and in CE its different i think the <code>ReadInt32</code> not work same as in ReadMemoryPointerInt, WriteMemoryPointerInt sorry  for my bad English i hope you understand what I said :-))</p>