title: Using Base Pointers with Offset to Read Process Memory
body: <p>I have searched all over the web for hours, and cannot for the life of me understand why the below code is not working. </p>
  
  <p><strong>The base address that is pulled for the process seems to be wrong</strong>. If I hard-code the end-address directly into the <code>ReadMemory</code>, i get the desired value out (so i know i have the correct process and all).</p>
  
  <p>I have not posted the <code>MemoryHandler</code> class, as that is working as it should</p>
  
  <p>Might it have something to do with the fact that I am on a 64-bit windows? The game is 32-bit (installed in the "Program Files (x86)" folder).</p>
  
  <pre><code>public partial class MainForm : Form
  {
  
      Process myProcess = Process.GetProcessesByName("ffxiv").FirstOrDefault();
  
      public MainForm()
      {
          InitializeComponent();
      }
  
      private void startButton_Click(object sender, EventArgs e)
      {
          IntPtr baseAddress = myProcess.MainModule.BaseAddress;
          Console.WriteLine("Base Address: " + baseAddress.ToString("X"));
  
          IntPtr newAddr = IntPtr.Add(baseAddress, 0xF8BEFC);
          IntPtr finalAddr = IntPtr.Add(newAddr, 0x1690);
  
          int bytesRead;
          byte[] memoryOutput = MemoryHandler.ReadMemory(myProcess, finalAddr, 4, out bytesRead);
  
          int value = BitConverter.ToInt32(memoryOutput, 0);
          Console.WriteLine("Read Value: " + value);
      }
  }
  </code></pre>
  
  <p>EDIT: Base Address was right, my code-logic around pointers were wrong, see full answer below.</p>