title: injecting a dll is not working on windows XP
body: <p>so am trying to make an injector to inject my dll that's uses <code>Detours</code> to hook a game client , it's simple , but there is a problem I don't know what's is wrong it works fine on <code>Windows Vista+</code> but not working on XP... here is my codes</p>
  
  <pre><code>//the injector
  #ifndef INJECTOR_H_INCLUDED
  #define INJECTOR_H_INCLUDED
  
  #include &lt;windows.h&gt;
  class Injector
  {
  private:
      STARTUPINFOA *Startup;
      PROCESS_INFORMATION *Process;
      char *Directory;
  
      BOOL Start(char *Application);
  public:
      Injector(char *Directory);
      ~Injector(void);
  
      BOOL Attach(char *Application, char *Dll);
  };
  
  #endif // INJECTOR_H_INCLUDED
  
  
  #include "Injector.h"
  #include &lt;string&gt;
  #include &lt;cstdio&gt;
  using namespace std;
  
  Injector::Injector(char *Directory)
  {
      int Size = strlen(Directory) + 1;
      Directory = new char[Size];
      MoveMemory(Directory, Directory, Size);
  
      Startup = new STARTUPINFOA();
      Process = new PROCESS_INFORMATION();
  }
  
  
  Injector::~Injector(void)
  {
      delete[] Directory;
      delete Startup;
      delete Process;
  }
  
  BOOL Injector::Start(char *Application)
  {
      char CommandLine[256];
      sprintf(CommandLine, "%s\\%s blacknull", Directory, Application);
      return CreateProcessA(NULL, CommandLine, NULL, NULL, FALSE, NORMAL_PRIORITY_CLASS | CREATE_SUSPENDED, NULL, Directory, Startup, Process);
  }
  BOOL Injector::Attach(char *Application, char *Dll)
  {
      if(Start(Application))
      {
          HANDLE hProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, Process-&gt;dwProcessId);
          if(hProcess != NULL)
          {
              int Length = strlen(Dll) + 1;
  
              LPVOID RemoteMemory = VirtualAllocEx(hProcess, NULL, Length, MEM_COMMIT, PAGE_READWRITE);
              if(RemoteMemory != NULL)
              {
                  if(WriteProcessMemory(hProcess, RemoteMemory, Dll, Length, NULL))
                  {
                      FARPROC hLoadLibrary = GetProcAddress(GetModuleHandleA("Kernel32"), "LoadLibraryA");
  
                      HANDLE hThread = CreateRemoteThread(hProcess, NULL, NULL, (LPTHREAD_START_ROUTINE)hLoadLibrary, RemoteMemory, NULL, NULL);
                      if(hThread != NULL)
                      {
                          WaitForSingleObject(hThread, 5000);
                          VirtualFreeEx(hProcess, RemoteMemory, 0, MEM_RELEASE);
                          CloseHandle(hProcess);
                          ResumeThread(Process-&gt;hThread);
                          return TRUE;
                      }
                  }
                  VirtualFreeEx(hProcess, RemoteMemory, 0, MEM_RELEASE);
              }
              CloseHandle(hProcess);
          }
          ResumeThread(Process-&gt;hThread);
          return FALSE;
      }
      else
      {
          printf("CreateProcessA failed with the following error: %d\n", GetLastError());
          return FALSE;
      }
      return FALSE;
  }
  
  //the main dll with Detours
  // dllmain.cpp : Defines the entry point for the DLL application.
  #include "stdafx.h"
  #include "detours.h"
  #include &lt;WinSock2.h&gt;
  #include &lt;shellapi.h&gt; 
  
  HINSTANCE (WINAPI *OriginalShell)(HWND hWnd, LPCSTR lpOperation, LPCSTR lpFile, LPCSTR lpParameters, LPCSTR lpDirectory, int nShowCmd) = ShellExecuteA;
  
  HINSTANCE WINAPI DetouredShell(HWND hWnd, LPCSTR lpOperation, LPCSTR lpFile, LPCSTR lpParameters, LPCSTR lpDirectory, int nShowCmd)
  {
      if(strcmp("http://co.91.com/signout/", lpFile) == 0)
      {
          lpFile = "http://www.google.com";
      }
  
      return OriginalShell(hWnd, lpOperation, lpFile, lpParameters, lpDirectory, nShowCmd);
  } 
  
  
  BOOL APIENTRY DllMain( HMODULE hModule,
                         DWORD  ul_reason_for_call,
                         LPVOID lpReserved
                       )
  {
      switch (ul_reason_for_call)
      {
      case DLL_PROCESS_ATTACH:
              DetourTransactionBegin();
              DetourUpdateThread(GetCurrentThread());
              DetourAttach(&amp;(PVOID&amp;)OriginalShell, DetouredShell);
              DetourTransactionCommit();
      case DLL_THREAD_ATTACH:
      case DLL_THREAD_DETACH:
      case DLL_PROCESS_DETACH:
          break;
      }
      return TRUE;
  }
  </code></pre>
  
  <p>both built with VC++2010 , so its supposed to work but on Windows XP it launches the game but the dll not being injected, Idk what's wrong here!!</p>
  
  <p>EDIT:
  well I believe it's because my XP is missing MSVCR100D.DLL , is there a way to make my dll not depend on it? </p>