title: Dll injection. Execute CreateRemoteThread with parameter
body: <p>I wrote dll injection program that works just fine. It loads dll into remote process and calls some function. Now i want to pass argument to that function. CreateRemoteThread has lpParameter for that, but how to get that passed argument inside dll to use it in function?</p>
  
  <p><strong>Update</strong>:
  dll entry point is common:<br/></p>
  
  <pre><code>BOOL APIENTRY DllMain( HANDLE hModule, DWORD  ul_reason_for_call, LPVOID lpReserved)
  </code></pre>
  
  <p>Dll contains only one function with following prototype:<br/></p>
  
  <pre><code>void TestFunction(const char* ua);
  </code></pre>
  
  <p>Code that calls that function is:<br/></p>
  
  <pre><code>CreateRemoteThread(hProcess, NULL, 0, (LPTHREAD_START_ROUTINE)((void*)codecaveExecAddr), (LPVOID)argumentAddress, 0, NULL);
  </code></pre>
  
  <p>As you can see i try to pass "test" string inside TestFunction. But then i check ua argument inside TestFunction it contains some trash.</p>
  
  <p>Here are the whole project files:<br/>
  <a href="http://pastebin.com/gh4SnhmV" rel="nofollow">http://pastebin.com/gh4SnhmV</a><br/>
  <a href="http://pastebin.com/Sq7hpSVx" rel="nofollow">http://pastebin.com/Sq7hpSVx</a><br/>
  <a href="http://pastebin.com/dvgXpUYz" rel="nofollow">http://pastebin.com/dvgXpUYz</a></p>
  
  <p>UPDATE 2<br/>
  Should TestFunction have some specific propotype or i can use any as long as it has only one parameter of LPVOID type? I'm confused. Can anyone give me an example of how to call injected dll's function with some argument?</p>