title: How do I edit opcodes or write memory or edit bytes in C++?
body: <p>I am memory editing a game called Assault Cube which can be found at: <a href="http://assault.cubers.net/" rel="nofollow">http://assault.cubers.net/</a></p>
  
  <p>I'm not sure how to describe it, so I've made a video of me doing it: <a href="http://www.youtube.com/watch?v=SS1swxQIbDI" rel="nofollow">www.youtube.com/watch?v=SS1swxQIbDI</a></p>
  
  <p>Notice that my ammo goes down before the edit. After the edit, the ammo stays constant. Basically, at 0x45B75F, I need to insert two NOPs.</p>
  
  <p>I've found the following on the internet:</p>
  
  <p>1.</p>
  
  <pre><code>BYTE NewBytes[] = { 0xXX, 0xXX, 0xXX, 0xXX, 0xXX };
  *(PBYTE)0xXXXXXXXX[0] = NewBytes;
  </code></pre>
  
  <p>So I tried doing:</p>
  
  <pre><code>BYTE NewBytes[] = { 0x90, 0x90 };
  *(PBYTE)0x45B75F[0] = NewBytes;
  </code></pre>
  
  <p>But I get this error: <code>error C2109: subscript requires array or pointer type</code></p>
  
  <p>2.</p>
  
  <pre><code>DWORD origProtect;
  VirtualProtect( ( void* )0x77D142CF, 5, PAGE_EXECUTE_READWRITE, &amp;origProtect );
  memcpy( ( void* )0x77D142CF, "\x8B\xFF\x55\x8B\xEC", 5 );
  VirtualProtect( ( void* )0x77D142CF, 5, origProtect, NULL );
  </code></pre>
  
  <p>I would prefer to not use memcpy or any method.</p>
  
  <p>3.</p>
  
  <pre><code>char val = 0x48;
  BOOL success = WriteProcessMemory(target, 0x10134CE0, &amp;val, 1, NULL);
  </code></pre>
  
  <p>Again, I would prefer to not use a method.</p>
  
  <p>4.</p>
  
  <pre><code>uint8_t* code = (uint8_t*)0x45B75F;
  *code = 0x90;
  </code></pre>
  
  <p>The above gives me these errors:</p>
  
  <pre><code>error C2065: 'uint8_t' : undeclared identifier
  error C2065: 'code' : undeclared identifier
  error C2065: 'uint8_t' : undeclared identifier
  error C2059: syntax error : ')'
  error C2065: 'code' : undeclared identifier
  </code></pre>
  
  <p>5.</p>
  
  <pre><code>*(char*)0x45B75F = 0x90;
  </code></pre>
  
  <p>This results in a crash.</p>