title: C++ BaseAddress and entry point address
body: <p>I know that in c# I can do:</p>
  
  <pre><code>Process currentProcess  = System.Diagnostics.Process.GetCurrentProcess();
  
  currentProcess.Modules[0].BaseAddress
  currentProcess.Modules[0].EntryPointAddress
  </code></pre>
  
  <p>How would I get this information in C++?</p>
  
  <p>Taking a look I have:</p>
  
  <pre><code>void
  get_module_name_for_address(LPVOID address,
                              TCHAR *buf, int buf_size)
  {
      HANDLE process;
      HMODULE modules[256];
      DWORD bytes_needed, num_modules;
      unsigned int i;
  
      buf[0] = '\0';
  
      process = GetCurrentProcess();
  
      if (EnumProcessModules(process, (HMODULE *) &amp;modules,
                             sizeof(modules), &amp;bytes_needed) == 0)
      {
          return;
      }
  
      if (bytes_needed &gt; sizeof(modules))
          bytes_needed = sizeof(modules);
  
      num_modules = bytes_needed / sizeof(HMODULE);
  
      for (i = 0; i &lt; num_modules; i++)
      {
          MODULEINFO mi;
  
          if (GetModuleInformation(process, modules[i], &amp;mi, sizeof(mi)) != 0)
          {
              LPVOID start, end;
  
              start = mi.lpBaseOfDll;
              end = (char *) start + mi.SizeOfImage;
  
              if (address &gt;= start &amp;&amp; address &lt;= end)
              {
                  GetModuleBaseName(process, modules[i], buf, buf_size);
                  return;
              }
          }
      }
  }
  </code></pre>