Inyector
Код: Выделить всё
#include
#include
#include
#include // Para enumerar módulos en el proceso remoto
// Función para obtener el handle del módulo cargado remotamente
HMODULE GetRemoteModuleHandle(HANDLE hProcess, const wchar_t* moduleName) {
HMODULE hModule = nullptr;
MODULEENTRY32 me = { sizeof(me) };
HANDLE hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, GetProcessId(hProcess));
if (hSnapshot == INVALID_HANDLE_VALUE)
return nullptr;
if (Module32First(hSnapshot, &me)) {
do {
if (_wcsicmp(me.szModule, moduleName) == 0) {
hModule = me.hModule;
break;
}
} while (Module32Next(hSnapshot, &me));
}
CloseHandle(hSnapshot);
return hModule;
}
int main(int argc, const char* argv[]) {
if (argc < 3) {
printf("Usage: Inyector
\n");
return 0;
}
auto pid = atoi(argv[1]);
// Abrir el proceso objetivo
HANDLE hProcess = OpenProcess(PROCESS_VM_WRITE | PROCESS_VM_OPERATION | PROCESS_CREATE_THREAD, FALSE, pid);
if (!hProcess) {
printf("Error opening process (%u)\n", GetLastError());
return 1;
}
// Reservar memoria en el proceso objetivo
auto p = VirtualAllocEx(hProcess, nullptr, 1
Подробнее здесь: [url]https://stackoverflow.com/questions/79281072/c-injection-dll-export-function[/url]