2026-01-06 19:12:21 +01:00
|
|
|
|
#include <windows.h>
|
|
|
|
|
|
#include <vector>
|
|
|
|
|
|
#include <string>
|
|
|
|
|
|
#include <iostream>
|
|
|
|
|
|
#include "../Base/Logger.h"
|
|
|
|
|
|
#include "../Base/Protocol.h"
|
|
|
|
|
|
|
|
|
|
|
|
// --- UTILIDAD DE ESCANEO DE PATRONES (Para Next-Gen) ---
|
|
|
|
|
|
namespace Scanner {
|
|
|
|
|
|
uintptr_t FindPattern(const char* signature) {
|
|
|
|
|
|
static auto pattern_to_byte = [](const char* pattern) {
|
|
|
|
|
|
auto bytes = std::vector<int>{};
|
|
|
|
|
|
auto start = const_cast<char*>(pattern);
|
|
|
|
|
|
auto end = const_cast<char*>(pattern) + strlen(pattern);
|
|
|
|
|
|
for (auto current = start; current < end; ++current) {
|
|
|
|
|
|
if (*current == '?') {
|
|
|
|
|
|
++current;
|
|
|
|
|
|
if (*current == '?') ++current;
|
|
|
|
|
|
bytes.push_back(-1);
|
|
|
|
|
|
} else {
|
|
|
|
|
|
bytes.push_back(strtoul(current, ¤t, 16));
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
return bytes;
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
uintptr_t base = (uintptr_t)GetModuleHandle(NULL);
|
|
|
|
|
|
IMAGE_NT_HEADERS* ntHeaders = (IMAGE_NT_HEADERS*)(base + ((IMAGE_DOS_HEADER*)base)->e_lfanew);
|
|
|
|
|
|
DWORD size = ntHeaders->OptionalHeader.SizeOfImage;
|
|
|
|
|
|
auto patternBytes = pattern_to_byte(signature);
|
|
|
|
|
|
uint8_t* scanBytes = reinterpret_cast<uint8_t*>(base);
|
|
|
|
|
|
|
|
|
|
|
|
for (unsigned long i = 0; i < size - patternBytes.size(); ++i) {
|
|
|
|
|
|
bool found = true;
|
|
|
|
|
|
for (unsigned long j = 0; j < patternBytes.size(); ++j) {
|
|
|
|
|
|
if (scanBytes[i + j] != patternBytes[j] && patternBytes[j] != -1) {
|
|
|
|
|
|
found = false;
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
if (found) return reinterpret_cast<uintptr_t>(&scanBytes[i]);
|
|
|
|
|
|
}
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// --- L<>GICA PRINCIPAL ---
|
|
|
|
|
|
void InitializeF4MP() {
|
|
|
|
|
|
Logger::Log("F4MP: Buscando Singleton del Jugador (Next-Gen)...");
|
|
|
|
|
|
|
|
|
|
|
|
// Este es un ejemplo de un patr<74>n para encontrar el Player Singleton en Next-Gen
|
|
|
|
|
|
// Nota: El patr<74>n real puede variar seg<65>n el parche, pero esta es la t<>cnica correcta.
|
|
|
|
|
|
uintptr_t playerAddr = Scanner::FindPattern("48 8B 05 ? ? ? ? 48 8B D1 48 8b 48 08");
|
|
|
|
|
|
|
|
|
|
|
|
if (playerAddr) {
|
|
|
|
|
|
Logger::Log("F4MP: Patron encontrado en: " + std::to_string(playerAddr));
|
|
|
|
|
|
// Aqu<71> seguir<69>a la l<>gica para calcular el offset relativo (RIP-relative)
|
|
|
|
|
|
} else {
|
|
|
|
|
|
Logger::Log("F4MP: No se pudo encontrar el patron del jugador.");
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
DWORD WINAPI MainThread(LPVOID lpParam) {
|
|
|
|
|
|
Logger::Log("=== F4MP CLIENTE CARGADO ===");
|
|
|
|
|
|
|
|
|
|
|
|
InitializeF4MP();
|
|
|
|
|
|
|
|
|
|
|
|
// Bucle para mantener la DLL viva. Pulsa FIN para descargarla.
|
|
|
|
|
|
while (!(GetAsyncKeyState(VK_END) & 0x8000)) {
|
|
|
|
|
|
Sleep(500);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Logger::Log("F4MP: Descargando...");
|
|
|
|
|
|
FreeLibraryAndExitThread((HMODULE)lpParam, 0);
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) {
|
|
|
|
|
|
if (ul_reason_for_call == DLL_PROCESS_ATTACH) {
|
|
|
|
|
|
DisableThreadLibraryCalls(hModule);
|
|
|
|
|
|
CreateThread(NULL, 0, MainThread, hModule, 0, NULL);
|
|
|
|
|
|
}
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
|
}
|