title: Reading and writing with a DLL injection C++
body: <p>I've run into a bit of a problem and I'm not sure how to do what I am trying to do.</p>
  
  <p>I am using C++ to inject a DLL into an application and I want to alter an address. The problem is that I'm not quite sure how to target it - let me explain...</p>
  
  <p>I know how to use pointers:</p>
  
  <pre><code>int x;
  int *myPointer;
  myPointer = &amp;x;
  *myPointer = 5;
  std::cout &lt;&lt; x &lt;&lt; endl; // 5
  </code></pre>
  
  <p>And I know that you can point to pointers:</p>
  
  <pre><code>int x;
  int *myPointer;
  int **myPointer2;
  myPointer = &amp;x;
  myPointer2 = &amp;myPointer;
  **myPointer = 5;
  std::cout &lt;&lt; x &lt;&lt; endl; // 5
  </code></pre>
  
  <p>I am trying to make a basic game hack by injecting a DLL into a game, and then setting the ammo to a fixed value on a keypress. The injection is working, the keypress is working, but I get a crash whenever I try and access the memory.</p>
  
  <p>I have used Cheat Engine to get the static address for the variable I want to change, along with 3 offsets.</p>
  
  <p>The address info in Cheat Engine looks like this:</p>
  
  <pre><code>Address: 0288A520 = 19
  Type: 4 bytes
  0   [0288A520 + 0]   -&gt; 0288A520
  14  [0288A520 + 14]  -&gt; 0288A520
  384 [0288A3D0 + 384] -&gt; 02881A30
  ac_client.exe+109B74 -&gt; 0288A3D0
  </code></pre>
  
  <p>The value 19 is the one I want to modify in my DLL.</p>
  
  <p>If I close the game and re-open it, I get the correct values coming through using these pointers, but now my issue is I'm not sure how to implement this in C++. How do I represent this static address in C++?</p>
  
  <p>My main thread currently looks like this...</p>
  
  <pre><code>DWORD WINAPI Main_Thread(LPVOID lpParam)
  {
      while(1)
      {
      if(GetAsyncKeyState(VK_HOME)) {
              // Output value here???
          }
          Sleep(100);
      }
  }
  </code></pre>
  
  <p>Any help is greatly appreciated.</p>