captmicro

Untitled

Mar 3rd, 2010
245
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.74 KB | None | 0 0
  1.  
  2. /*Inject code*/
  3. int Method1(DWORD ProcessID, char *dllstr)
  4. {
  5.    HANDLE Proc;
  6.    char buf[50]={0};
  7.    LPVOID RemoteString, LoadLibAddy;
  8.  
  9.    if (!ProcessID) { return 1; }
  10.  
  11.    Proc = OpenProcess(PROCESS_CREATE_THREAD, FALSE, ProcessID);
  12.  
  13.    if (!Proc) { return 1; }
  14.  
  15.    LoadLibAddy = (LPVOID)GetProcAddress(GetModuleHandle("kernel32.dll"), "LoadLibraryA");
  16.  
  17.    RemoteString = (LPVOID)VirtualAllocEx(Proc, NULL, strlen(dllstr), MEM_RESERVE|MEM_COMMIT, PAGE_READWRITE);
  18.    WriteProcessMemory(Proc, (LPVOID)RemoteString, dllstr, strlen(dllstr), NULL);
  19.    CreateRemoteThread(Proc, NULL, NULL, (LPTHREAD_START_ROUTINE)LoadLibAddy, (LPVOID)RemoteString, NULL, NULL);    
  20.    
  21.    CloseHandle(Proc);
  22.  
  23.    return 0;
  24. } /*Method1*/
Add Comment
Please, Sign In to add comment