title: How to call function with parameters in the injected dll in windows
body: <p>I want to inject my simple dll into a third-party application.
  After that I want to call a function in the dll from my own process, not the process in the third-party application.</p>
  
  <p>the first part in the following shows that the whole dll I test:</p>
  
  <pre><code>// dllmain.cpp
  #include "pch.h"
  
  
  
  extern "C" __declspec(dllexport) int add(int a, int b)
  {
      return a + b;
  }
  
  
  BOOL APIENTRY DllMain( HMODULE hModule,
                         DWORD  ul_reason_for_call,
                         LPVOID lpReserved
                       )
  {
      switch (ul_reason_for_call)
      {
      case DLL_PROCESS_ATTACH:
      case DLL_THREAD_ATTACH:
      case DLL_THREAD_DETACH:
      case DLL_PROCESS_DETACH:
          break;
      }
      return TRUE;
  }
  </code></pre>
  
  <p>the second part shows the caller function in my process:</p>
  
  <pre><code>    // hProcess is the process in the third-party application
  
      // Call our exported function
      lpReturn = NULL;
  
      ***// I don't know how to pass parameter a and b into the exported function add in my simple dll***
      HANDLE hThread = CreateRemoteThread(hProcess, NULL, 0, (LPTHREAD_START_ROUTINE)lpFunctionAddress, lpRemoteParams, NULL, NULL);
  
      DWORD dwOut = 0;
      while (GetExitCodeThread(hThread, &amp;dwOut)) {
          if (dwOut != STILL_ACTIVE) {
              *ppReturn = (PVOID)dwOut;
              break;
          }
      }
  
  </code></pre>
  
  <p><strong>I don't know how to pass parameter a and b into the exported function add in my simple dll(please refers to the second part above)</strong></p>
  
  <p>Anyone can give me a hint, or a complete example shows how to call function with parameters in the injected dll in windows ? Thx:-)</p>