Ok, ich habe zum ersten mal einen Injector in C++ gemacht. Nur leider funktioniert er nicht.
Ich will meine .dll in das Spiel injizieren. Die .dll hat aber auch noch ne Konfigurationsdatei, liegt es villeicht daran ?
Oder liegt das ich beim Namen des Spiels den Process Namen angeben soll oder doch einfach den Window name ?
Naja hier ist der Code, ich hoffe auf eure hilfe =)
Ich will meine .dll in das Spiel injizieren. Die .dll hat aber auch noch ne Konfigurationsdatei, liegt es villeicht daran ?
Oder liegt das ich beim Namen des Spiels den Process Namen angeben soll oder doch einfach den Window name ?
Naja hier ist der Code, ich hoffe auf eure hilfe =)
Code:
#include "stdafx.h"
#include "windows.h"
#include <iostream>
using namespace std;
char const Path[]="Aimbot.dll";
void SetDebugPrivilege()
{
HANDLE hProcess=GetCurrentProcess(), hToken;
TOKEN_PRIVILEGES priv;
LUID luid;
OpenProcessToken(hProcess, TOKEN_ADJUST_PRIVILEGES, &hToken);
priv.PrivilegeCount = 1;
priv.Privileges[0].Luid = luid;
priv.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
AdjustTokenPrivileges(hToken, false, &priv, 0, 0, 0);
CloseHandle(hToken);
}
int main(int argc, char* argv)
{
HANDLE hWnd, hProcess, AllocAdresse, hRemoteThread;
DWORD PID;
hWnd = FindWindow(0, L"Counter-Strike"); //oder soll da hl stehen ? Da es der Process Name hl.exe ist
GetWindowThreadProcessId((HWND)hWnd, &PID);
hProcess = OpenProcess(PROCESS_ALL_ACCESS, false, PID);
AllocAdresse = VirtualAllocEx(hProcess, 0, sizeof(Path), MEM_COMMIT, PAGE_EXECUTE_READWRITE);
WriteProcessMemory(hProcess, (void*)AllocAdresse, (void*)Path, sizeof(Path), 0);
hRemoteThread=CreateRemoteThread(hProcess, 0, 0, (LPTHREAD_START_ROUTINE) GetProcAddress(GetModuleHandle(L"kernel32.dll"),"LoadLibraryA"), AllocAdresse, 0, 0);
WaitForSingleObject(hRemoteThread, INFINITE);
VirtualFreeEx(hProcess, AllocAdresse, sizeof(Path), MEM_DECOMMIT);
CloseHandle(hProcess);
}