title: getting base address from an exe c++
body: <p>I tried to get the base starting address from this exe with openprocess, but I keep crashing when I run the code and I don't really see anything wrong with it.</p>
  
  <pre><code>HMODULE GetModule(HANDLE han)
  {
      HMODULE hMods[1024];
      int i;
      DWORD cbNeeded;
      char szProcessName[MAX_PATH] = "Minesweeper.exe";
      EnumProcessModules(han, hMods, sizeof(hMods), &amp;cbNeeded);
      for (i = 0; i &lt; (cbNeeded / sizeof(HMODULE)); i++)
      {
          TCHAR szModName[MAX_PATH];
          GetModuleFileNameEx(han, hMods[i], szProcessName, sizeof(szModName));
          //printf(TEXT("\t%s (0x%08X)\n"), szModName, hMods[i]);
          if (szModName == szProcessName)
          {
              cout &lt;&lt; "FOUND" &lt;&lt; endl;
          }
      }
      return 0;
  }
  </code></pre>