title: The procedure entry point could not be located in the dynamic link library
body: <p>I'm trying to proxy ddraw.dll for a game I'm working on (Not for cheating purposes), There are two functions called by the main game in order for it to start:</p>
  
  <p>DirectDrawEnumerateExA</p>
  
  <p>DirectDrawCreateEx</p>
  
  <p>I've added both of these to my C++ project plus done countless amount of research online and I've have got nowhere so far, I've tried various tutorials and various methods such as using a  .def file, I can't seem to figure out what is wrong.</p>
  
  <p>When launching the game I get "The procedure entry point DirectDrawEnumerateExA could not be located in the dynamic link library DDRAW.dll"</p>
  
  <p>Here is the code base I'm currently using:</p>
  
  <pre><code>#include &lt;windows.h&gt;
  #include &lt;ddraw.h&gt;
  
  typedef HRESULT (WINAPI* DirectDrawEnumerateExA_td)(LPDDENUMCALLBACKEXA lpCallback, LPVOID lpContext, DWORD dwFlags);
  typedef HRESULT (WINAPI* DirectDrawCreateEx_td)(GUID FAR *lpGuid, LPVOID *lplpDD, REFIID iid, IUnknown FAR *pUnkouter);
  
  static struct
  {
      HMODULE hGameDLL;
      char* pGameDLL;
  
      // entry points
      DirectDrawEnumerateExA_td OldDirectDrawEnumerateExA;
      DirectDrawCreateEx_td OldDirectDrawCreateEx;
  
  } g_state;
  
  extern "C" HRESULT __declspec(dllexport) OldDirectDrawEnumerateExA(LPDDENUMCALLBACKEXA lpCallback, LPVOID lpContext, DWORD dwFlags)
  {
      return g_state.OldDirectDrawEnumerateExA(lpCallback, lpContext, dwFlags);
  }
  
  extern "C" HRESULT __declspec(dllexport) WINAPI OldDirectDrawCreateEx(GUID FAR *lpGuid, LPVOID *lplpDD, REFIID iid, IUnknown FAR *pUnkouter)
  {
      return g_state.OldDirectDrawCreateEx(lpGuid, lplpDD, iid, pUnkouter);
  }
  
  BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
  {
      if(fdwReason == DLL_PROCESS_ATTACH)
      {
              char infoBuf[MAX_PATH];
              GetSystemDirectory(infoBuf, MAX_PATH);
              strcat_s(infoBuf, MAX_PATH, "\\ddraw.dll");
  
              g_state.hGameDLL = LoadLibrary(infoBuf); 
              g_state.pGameDLL = (char*)g_state.hGameDLL;
  
              if(!g_state.hGameDLL)
              {
                  MessageBox(NULL, "Unable to load ddraw.dll", "Error", MB_OK | MB_ICONEXCLAMATION);
                  ExitProcess(0);
              }
  
              g_state.OldDirectDrawEnumerateExA = (DirectDrawEnumerateExA_td)GetProcAddress(g_state.hGameDLL, "DirectDrawEnumerateExA");
  
              if(!g_state.OldDirectDrawEnumerateExA)
              {
                  MessageBox(NULL, "Unable to find entry point: DirectDrawEnumerateExA", "Error", MB_OK | MB_ICONEXCLAMATION);
                  ExitProcess(0);
              }
  
              g_state.OldDirectDrawCreateEx = (DirectDrawCreateEx_td)GetProcAddress(g_state.hGameDLL, "DirectDrawCreateEx");
  
              if(!g_state.OldDirectDrawCreateEx)
              {
                  MessageBox(NULL, "Unable to find entry point: DirectDrawCreateEX", "Error", MB_OK | MB_ICONEXCLAMATION);
              }
  
              MessageBox(NULL, "Test.", "Test Box", MB_OK | MB_ICONEXCLAMATION);
      }
      else if(fdwReason == DLL_PROCESS_DETACH)
      {
          if (g_state.hGameDLL)
          {
              FreeLibrary(g_state.hGameDLL);
          }
      }
  
      return TRUE;
  }
  </code></pre>