-
Автор темы
- #1
Помогите пожалуйста решить ошибки
C++:
#include <Windows.h>
#include <TlHelp32.h>
#include <iostream>
#include <io.h>
DWORD GetProcessByName(char* process_name) {
HANDLE snapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
PROCESSENTRY32 process;
DWORD proc_id = 0;
DWORD pCount = 0;
if(Process32First(snapshot, &process)) {
while(Process32Next(snapshot, &process)) {
if(_stricmp(process.szExeFile, process_name) == 0) {
pCount++;
if(pCount == 1)
Sleep(1000);
if(pCount == 2) {
proc_id = process.th32ProcessID;
break;
}
}
}
}
CloseHandle(snapshot);
return proc_id;
}
DWORD GetProcessByTitle(char* process_title) {
HWND hwnd;
DWORD proc_id = 0;
hwnd = FindWindow(NULL, process_title);
GetWindowThreadProcessId(hwnd, &proc_id);
return proc_id;
}
BOOL FileExist(char* name) {
return _access(name, 0) != -1;
}
/*
* Функция инжекта dll
*/
BOOL Inject(DWORD pID, char* path) {
HANDLE proc_handle;
LPVOID RemoteString;
LPVOID LoadLibAddy;
if(pID == 0) return false;
proc_handle = OpenProcess(PROCESS_ALL_ACCESS, false, pID);
if(proc_handle == 0) return false;
LoadLibAddy = GetProcAddress(GetModuleHandle("kernel32.dll"), ("LoadLibraryA"));
RemoteString = VirtualAllocEx(proc_handle, NULL, strlen(path), MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE);
WriteProcessMemory(proc_handle, RemoteString, path, strlen(path), NULL);
CreateRemoteThread(proc_handle, NULL, NULL, (LPTHREAD_START_ROUTINE)LoadLibAddy, RemoteString, NULL, NULL);
CloseHandle(proc_handle);
return true;
}
int main() {
char process_title[33] = "HCS Minecraft DayZ Client Legacy";
//char process_name[9] = "java.exe"; //unused
#if _WIN64
char dll_name[11] = "HCSH64.dll";
#else
char dll_name[11] = "HCSH32.dll";
#endif
char path[249];
system("color a");
printf("###########################\n## HCS: DayZ ##\n## Developed by McHacked ##\n## [vk.com/mchacked] ##\n###########################\n\n");
DWORD pID = GetProcessByTitle(process_title); //GetProcessByName(process_name);
printf("> Search process...\n");
for(;; Sleep(50)) {
if(pID == 0)
pID = GetProcessByTitle(process_title); //GetProcessByName(process_name);
else {
printf("> Process found.\n");
break;
}
}
GetFullPathName(dll_name, sizeof(path), path, NULL);
if(!FileExist(path)) {
system("color 4");
#if _WIN64
printf("> HCSH64.dll not found.\n");
#else
printf("> HCSH32.dll not found.\n");
#endif
system("pause");
exit(1);
}
printf("> Inject...\n");
if(Inject(pID, path)) { //инжект длл
printf("> Successfully.\n");
exit(1);
} else {
system("color 4");
printf("> ERROR.\n");
system("pause");
exit(1);
}
}