LUDIX-BoT Forum
 
HomeHome  CalendarCalendar  FAQFAQ  SearchSearch  MemberlistMemberlist  UsergroupsUsergroups  RegisterRegister  Log inLog in  

Share | 
 

 Inject Into a Running Process

Go down 
AuthorMessage
Shagrath



Posts : 57
Join date : 2009-10-10
Location : Istanbul/Turkey

PostSubject: Inject Into a Running Process   Mon Oct 26, 2009 12:18 pm

I like my injector to inject into a running process, it means the injector can work in a background thread and inject whenever the user starts the game from anywhere (ie ASE).

So here's my injection code:
Code:
BOOL InjectIntoProcess(TCHAR* szExeName, TCHAR* szDllName)
{
    TCHAR szProcessName[MAX_PATH];
    TCHAR szDllNameAndPath[MAX_PATH];
    DWORD aProcesses[1024], cb, cProcesses;
    HANDLE hProcess = NULL;
    HMODULE hMod = NULL;
    UINT i = 0;

    // Get the full path to the DLL for later use
    GetCurrentDirectory(MAX_PATH, szDllNameAndPath);
    wcscat(szDllNameAndPath, _T("\\"));
    wcscat(szDllNameAndPath, szDllName);

    // Get the list of process identifiers
    if(!EnumProcesses(aProcesses, sizeof(aProcesses), &cb))
        return FALSE;

    // Calculate how many process identifiers were returned
    cProcesses = cb / sizeof(DWORD);

    // Get the name and process identifier for each process
    for(i = 0; i < cProcesses; i++)
    {
        hProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, aProcesses[i]);

        if(hProcess)
        {
            if(EnumProcessModules(hProcess, &hMod, sizeof(hMod), &cb))
            {
                GetModuleBaseNameW(hProcess, hMod, szProcessName, sizeof(szProcessName)/sizeof(TCHAR));
            }

            if(wcscmp(wcslwr(szProcessName), szExeName) == 0)
            {
                // We found the process, inject our DLL
                if(DetourContinueProcessWithDllW(hProcess, szDllNameAndPath))
                {
                    return TRUE;
                }
            }
        }
       
        CloseHandle(hProcess);
    }

    return FALSE;
}

Now we can inject a DLL as easily as this:
Code:
  if(InjectIntoProcess(_T("et.exe"), _T("hax.dll")))
    {
        _tprintf(_T("Injection successful!\n"));
    }
    else {
        _tprintf(_T("Injection failed.\n"));
    }

Thanks to Sinner
Back to top Go down
View user profile
 
Inject Into a Running Process
Back to top 
Page 1 of 1
 Similar topics
-
» Need a running track
» running light...
» my fravortie song.......lolololol
» IvanHoe 999946f x64 vs. IvanHoe B46fB x64, 2.800 games, still running
» The Tennison's Deliria ...

Permissions in this forum:You cannot reply to topics in this forum
LUDIX-BoT Forum :: Coding :: General Coding-
Jump to: