title: C++ DLL Injector not working
body: <p>I'm coding a DLL injector in c++, but it's simply not working. So all I wanna do is just inject my own DLL which should open a Message Box that says: "Hello" into a dummy program, but nothing is happening. I thought that it could be the handle, but reading and writing memory just works fine. I also tried other varients than the below shown code, but nothing worked for me, so I hope that's enough information to start with, if not just tell me and here's the code thanks already:</p>
  
  <pre><code>BOOL Inject(LPCSTR DllPath, HANDLE hProc) {
      LPVOID pDllPath = VirtualAllocEx(hProc, 0, strlen(DllPath) + 1, 
      MEM_COMMIT, PAGE_READWRITE);
  
      bool written = WriteProcessMemory(hProc, pDllPath, DllPath, 
      strlen(DllPath) + 1, 0);
  
      HANDLE hLoadThread = CreateRemoteThread(hProc, 0, 0,
      (LPTHREAD_START_ROUTINE)GetProcAddress(GetModuleHandleA("kernel32.dll"),
          "LoadLibraryA"), pDllPath, 0, 0);
  
      std::cout &lt;&lt; pDllPath &lt;&lt; std::endl;
  
      WaitForSingleObject(hLoadThread, INFINITE);
      VirtualFreeEx(hProc, pDllPath, strlen(DllPath) + 1, MEM_RELEASE);
      return written;
  }
  </code></pre>