- 19
- 2
Удаление вопроса после решения проблемы
Короче решил написать свой самп клиент:
Все должно работать, но я хз почему не работает, помогите пж
C++:
BOOL Inject(DWORD pId, LPSTR dllName){
HANDLE h = OpenProcess(PROCESS_ALL_ACCESS, FALSE, pId);
if (h)
{
LPVOID LoadLibAddr = (LPVOID)GetProcAddress(GetModuleHandleA("kernel32.dll"), "LoadLibraryA");
LPVOID dereercomp = VirtualAllocEx(h, NULL, strlen(dllName), MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE);
WriteProcessMemory(h, dereercomp, dllName, strlen(dllName), NULL);
HANDLE asdc = CreateRemoteThread(h, NULL, NULL, (LPTHREAD_START_ROUTINE)LoadLibAddr, dereercomp, 0, NULL);
WaitForSingleObject(asdc, INFINITE);
VirtualFreeEx(h, dereercomp, strlen(dllName), MEM_RELEASE);
CloseHandle(asdc);
CloseHandle(h);
return TRUE;
}
return FALSE;
}
int _tmain(int argc, _TCHAR* argv[])
{
STARTUPINFOA cif; ZeroMemory(&cif, sizeof(STARTUPINFO));
PROCESS_INFORMATION pi;
if (CreateProcessA("D:\\Games\\GTA SAMP\\gta_sa.exe", "-c -n NickName -h 228.227.226.225 -p 7777", NULL, NULL, FALSE, DETACHED_PROCESS | CREATE_SUSPENDED, NULL, NULL, &cif, &pi))
{
if (pi.hProcess != NULL)
{
if (!Inject(pi.dwProcessId, "D:\\Games\\GTA SAMP\\samp.dll"))
{
TerminateProcess(pi.hProcess, 0);
ExitProcess(0);
}
ResumeThread(pi.hThread);
}
}
else MessageBoxA(NULL, "Failed to Create Process", "Error", MB_ICONERROR);
return 0;
}