title: C++ get 64-bit baseAddress of exe
body: <p>I am trying to get the base Adress of an exe.
  This is working well with x86 applications but it delivers me the wrong start address with x64 processes.
  I am using VS2012 compiled to 64-bit running on W7 x64.</p>
  
  <pre><code>    static uintptr_t dwGetModuleBaseAddress(DWORD dwProcessIdentifier, TCHAR *lpszModuleName)
      {
          HANDLE hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, dwProcessIdentifier);
          BYTE* dwModuleBaseAddress = 0;
          if(hSnapshot != INVALID_HANDLE_VALUE)
          {               
              MODULEENTRY32 ModuleEntry32 = {0};
              ModuleEntry32.dwSize = sizeof(MODULEENTRY32);
  
              if(Module32First(hSnapshot, &amp;ModuleEntry32))
              {
                  do
                  { 
                      if(_tcsicmp(ModuleEntry32.szModule, lpszModuleName) == 0)
                      {                           
                          dwModuleBaseAddress = (BYTE*) ModuleEntry32.modBaseAddr;
                          printf("ModuleEntry32.szModule= %S\n", ModuleEntry32.szModule);
                          printf("dwModuleBaseAddress= %p\n", dwModuleBaseAddress);
  
                          break;
                      }
                  }
                  while(Module32Next(hSnapshot, &amp;ModuleEntry32));
              }
              CloseHandle(hSnapshot);
          }else{              
              std::cout &lt;&lt; "CreateToolhelp32Snapshot Error: " &lt;&lt; GetLastError() &lt;&lt; std::endl;
          }
          return (uintptr_t) dwModuleBaseAddress;
      }
  </code></pre>
  
  <p>This is giving me 137000000 as the baseAdress, which is wrong as stated from CheatEngine.</p>
  
  <p>What am i doing wrong?
  The return values and the BYTE* type should be right for ModuleEntry32.modBaseAddr.</p>
  
  <p>Any help kindly appreciated!</p>
  
  <p>Regards</p>