title: How can I read process memory in chunks and scan for exact address of Values?
body: <p>I have written a simple memory scanner in C++, but it is slow and someone said, that reading chunks of memory would speed it up, but how do I get every correct address ?</p>
  <p>Here is a sample source code :</p>
  <pre><code>#include &lt;iostream&gt;
  #include &lt;Windows.h&gt;
  #include &lt;string&gt;
  
  #define CHUNK_SIZE 0x80000
  #define MAX_ADDRESS 0x7ffffff
  
  using namespace std;
  
  int main()
  {
      DWORD pid;
      char buffer[CHUNK_SIZE];
      std::cin &gt;&gt; pid;
      int something;
      int someValue = 0;
      HANDLE process = OpenProcess(PROCESS_ALL_ACCESS, FALSE, pid);
      SIZE_T numberRead;
      if (process)
          printf(&quot;opened process.\n&quot;);
      else
          printf(&quot;could not open process.\n&quot;);
  
      for (DWORD i = 0; i &lt; MAX_ADDRESS; i += CHUNK_SIZE) {
          if (ReadProcessMemory(process, (void*)i, &amp;buffer, sizeof(buffer), 
     &amp;numberRead)) {
          
          for (int j = 0; j &lt; sizeof(buffer); j++)
          {
                  someValue = (int)buffer[i];
                  if (someValue == 220)
                  {
                      printf(&quot;found value %d at 0x%x.\n&quot;, someValue, i + j);
                  }
              }
  
          }
      }
  
  }
  </code></pre>