Results 1 to 3 of 3
  1. #1
    The_USDL
    The_USDL is offline
    Senior Member The_USDL's Avatar
    Join Date
    2011 Oct
    Posts
    201
    Thanks Thanks Given 
    24
    Thanks Thanks Received 
    538
    Thanked in
    47 Posts
    Rep Power
    0

    Dll Injection - Another Method

    Code:
    #include <windows.h>
    #include <tlhelp32.h>
    #include <shlwapi.h>
    
    #define PROC_NAME "target.exe"
    #define DLL_NAME "injected.dll"
    
    //Press Thanks to USDL :)
    //Press Thanks to USDL :)
    //Press Thanks to USDL :)
    
    unsigned long GetTargetProcessIdFromProcname(char *procName);
    unsigned long GetTargetThreadIdFromProcname(char *procName);
    
    __declspec(naked) loadDll(void)
    {
       _asm{
          //   Placeholder for the return address
          push 0xDEADBEEF
    
          //   Save the flags and registers
          pushfd
          pushad
    
          //   Placeholder for the string address and LoadLibrary
          push 0xDEADBEEF
          mov eax, 0xDEADBEEF
    
          //   Call LoadLibrary with the string parameter
          call eax
    
          //   Restore the registers and flags
          popad
          popfd
           
          //   Return control to the hijacked thread
          ret
       }
    }
    
    __declspec(naked) loadDll_end(void)
    {
    }
    
    int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine,int nCmdShow)
    {
       void *dllString;
       void *stub;
       unsigned long wowID, threadID, stubLen, oldIP, oldprot, loadLibAddy;
        HANDLE hProcess, hThread;
       CONTEXT ctx;
       
       stubLen = (unsigned long)loadDll_end - (unsigned long)loadDll;
       
       loadLibAddy = (unsigned long)GetProcAddress(GetModuleHandle("kernel32.dll"), "LoadLibraryA");
    
       wowID    = GetTargetProcessIdFromProcname(PROC_NAME);
       hProcess = OpenProcess((PROCESS_VM_WRITE | PROCESS_VM_OPERATION), false, wowID);
    
       dllString = VirtualAllocEx(hProcess, NULL, (strlen(DLL_NAME) + 1), MEM_COMMIT, PAGE_READWRITE);
       stub      = VirtualAllocEx(hProcess, NULL, stubLen, MEM_COMMIT, PAGE_EXECUTE_READWRITE);
       WriteProcessMemory(hProcess, dllString, DLL_NAME, strlen(DLL_NAME), NULL);
       
       threadID = GetTargetThreadIdFromProcname(PROC_NAME);
       hThread   = OpenThread((THREAD_GET_CONTEXT | THREAD_SET_CONTEXT | THREAD_SUSPEND_RESUME), false, threadID);
       SuspendThread(hThread);
    
       ctx.ContextFlags = CONTEXT_CONTROL;
       GetThreadContext(hThread, &ctx);
       oldIP   = ctx.Eip;
       ctx.Eip = (DWORD)stub;
       ctx.ContextFlags = CONTEXT_CONTROL;
    
       VirtualProtect(loadDll, stubLen, PAGE_EXECUTE_READWRITE, &oldprot);
       memcpy((void *)((unsigned long)loadDll + 1), &oldIP, 4);
       memcpy((void *)((unsigned long)loadDll + 8), &dllString, 4);
       memcpy((void *)((unsigned long)loadDll + 13), &loadLibAddy, 4);
    
        WriteProcessMemory(hProcess, stub, loadDll, stubLen, NULL);
       SetThreadContext(hThread, &ctx);
    
       ResumeThread(hThread);
    
       Sleep(8000);
    
       VirtualFreeEx(hProcess, dllString, strlen(DLL_NAME), MEM_DECOMMIT);
       VirtualFreeEx(hProcess, stub, stubLen, MEM_DECOMMIT);
       CloseHandle(hProcess);
       CloseHandle(hThread);
    
        return 0;
    }
    
    
    unsigned long GetTargetProcessIdFromProcname(char *procName)
    {
       PROCESSENTRY32 pe;
       HANDLE thSnapshot;
       BOOL retval, ProcFound = false;
    
       thSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
    
       if(thSnapshot == INVALID_HANDLE_VALUE)
       {
          MessageBox(NULL, "Error: unable to create toolhelp snapshot", "Loader", NULL);
          return false;
       }
    
       pe.dwSize = sizeof(PROCESSENTRY32);
    
        retval = Process32First(thSnapshot, &pe);
    
       while(retval)
       {
          if(StrStrI(pe.szExeFile, procName) )
          {
             ProcFound = true;
             break;
          }
    
          retval    = Process32Next(thSnapshot,&pe);
          pe.dwSize = sizeof(PROCESSENTRY32);
       }
    
       CloseHandle(thSnapshot);
       return pe.th32ProcessID;
    }
    
    unsigned long GetTargetThreadIdFromProcname(char *procName)
    {
       PROCESSENTRY32 pe;
       HANDLE thSnapshot, hProcess;
       BOOL retval, ProcFound = false;
       unsigned long pTID, threadID;
    
       thSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
    
       if(thSnapshot == INVALID_HANDLE_VALUE)
       {
          MessageBox(NULL, "Error: unable to create toolhelp snapshot", "Loader", NULL);
          return false;
       }
    
       pe.dwSize = sizeof(PROCESSENTRY32);
    
        retval = Process32First(thSnapshot, &pe);
    
       while(retval)
       {
          if(StrStrI(pe.szExeFile, procName) )
          {
             ProcFound = true;
             break;
          }
    
          retval    = Process32Next(thSnapshot,&pe);
          pe.dwSize = sizeof(PROCESSENTRY32);
       }
    
       CloseHandle(thSnapshot);
       
       _asm {
          mov eax, fs:[0x18]
          add eax, 36
          mov [pTID], eax
       }
    
       hProcess = OpenProcess(PROCESS_VM_READ, false, pe.th32ProcessID);
       ReadProcessMemory(hProcess, (const void *)pTID, &threadID, 4, NULL);
       CloseHandle(hProcess);
    
       return threadID;
    }
    PRESS THANKS!!

  2. The Following 5 Users Say Thank You to The_USDL For This Useful Post:


  3. #2
    themalikao
    themalikao is offline
    New member
    Join Date
    2012 Apr
    Posts
    30
    Thanks Thanks Given 
    4
    Thanks Thanks Received 
    45
    Thanked in
    6 Posts
    Rep Power
    0
    Good joob, i'm testing him is.

    If is works, i will thanks you.

  4. #3
    themalikao
    themalikao is offline
    New member
    Join Date
    2012 Apr
    Posts
    30
    Thanks Thanks Given 
    4
    Thanks Thanks Received 
    45
    Thanked in
    6 Posts
    Rep Power
    0
    Quote Originally Posted by luisrdp View Post
    What's This? Someone Could Explain To Me?
    Some cheats, need to inject DLL on the process game.

    It program do this. It inject some dll when are this cheats.

Similar Threads

  1. [Request] Method to move character to specific cordinate
    By psycheangel in forum Aika Online
    Replies: 0
    Last Post: 2011-12-15, 02:02 AM
  2. Xtrap crap bypass method for PT gameclient 2010 and...
    By slimj81 in forum Anti-Cheat Systems
    Replies: 2
    Last Post: 2011-07-30, 10:18 AM
  3. [Guide] Link items to chatbox(Method 2)
    By ReqHack in forum Requiem Bots, Hacks, Cheats
    Replies: 24
    Last Post: 2011-05-29, 01:10 AM
  4. [Dev] DLL Injection Possible
    By Abstract in forum Forsaken World Bots, Hacks, Cheats
    Replies: 0
    Last Post: 2011-05-08, 12:16 AM
  5. Alternative method to Code-Caves
    By Genz in forum Programming Tutorials
    Replies: 0
    Last Post: 2010-11-29, 04:07 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •