Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //hidend
- #include "pch.h"
- #include <iostream>
- #include <fstream>
- #include <cstring>
- #include <Shlwapi.h>
- DWORD samp_base = 0;
- HMODULE g_hModule = NULL;
- bool bDetourMyself = false;
- const DWORD OFFSETS[6][2]{
- /*ChatInfo, AddMsg*/
- {0x21A0E4, 0x645A0}, // 037-r1 - 0
- {0x021A0EC, 0x64670}, // 037-r2 - 1
- {0x026E8C8, 0x679F0}, // 037-r3_1 - 2
- {0x026E9F8, 0x68130}, // 037-r4 - 3
- {0x026E9F8, 0x68170}, // 037-r4_2 -4
- {0x026EB80, 0x68170}, // 037-r5_1 - 5
- };
- int get_samp_version_id()
- {
- int version_current = -1;
- if (samp_base)
- {
- int version_id = *reinterpret_cast<int*>((char*)samp_base + 0x128);
- switch (version_id) {
- case 0x5542F47A: // R1
- version_current = 0;
- break;
- case 0x59C30C94: // R2
- version_current = 1;
- break;
- default:
- version_id = *reinterpret_cast<int*>((char*)samp_base + 0x120);
- switch (version_id) {
- case 0x5C0B4243: // R3
- version_current = 2;
- break;
- case 0x5DD606CD: // R4 - v1
- version_current = 3;
- break;
- case 0x6094ACAB: // R4 - v2
- version_current = 4;
- break;
- case 0x6372C39E: // R5, ni nos interesa pero meh
- version_current = 5;
- break;
- }
- }
- }
- return version_current;
- }
- void addMessageToChat(unsigned dwColor, const char* szMsg, ...)
- {
- int version = get_samp_version_id();
- if (version == -1)
- return;
- DWORD chatInfoOffset = OFFSETS[version][0];
- DWORD addMsgOffset = OFFSETS[version][1];
- unsigned char red = static_cast<unsigned char>(rand() % 256);
- unsigned char green = static_cast<unsigned char>(rand() % 256);
- unsigned char blue = static_cast<unsigned char>(rand() % 256);
- // Combine the color components into a single unsigned integer
- unsigned newColor = (red << 16) | (green << 8) | blue;
- auto addMessage = reinterpret_cast<void(__thiscall*)(void* pChat, unsigned color, const char* message)>(samp_base + addMsgOffset);
- addMessage(*reinterpret_cast<void**>(samp_base + chatInfoOffset), newColor, szMsg);
- }
- void searchStringInFile(const char* filePath, const char* searchString) {
- std::ifstream file(filePath);
- if (file.is_open()) {
- addMessageToChat(-1, "abierto");
- char line[256];
- char buffer[256];
- while (file.getline(line, sizeof(line))) {
- addMessageToChat(-1, line);
- char* pos = strstr(line, searchString);
- if (pos != nullptr) {
- sprintf_s(buffer, sizeof(buffer), "Encontrado en archivo in file: %s\n", filePath);
- addMessageToChat(-1, buffer);
- sprintf_s(buffer, sizeof(buffer), "Texto encontrado: '%s'", searchString);
- addMessageToChat(-1, buffer);
- break;
- }
- }
- file.close();
- }
- }
- int init()
- {
- char* Directorio = reinterpret_cast<char*>(0xB71A60);
- samp_base = (DWORD)LoadLibraryA("samp.dll");
- searchStringInFile("D:\\Games\\Grand Theft Auto San Andreas\\moonloader\\test.lua", "0x001eb6d4");
- addMessageToChat(-1, "test2");
- FreeLibraryAndExitThread(g_hModule, 0);
- return 0;
- }
- BOOL APIENTRY DllMain(HMODULE hModule, DWORD dwReasonForCall, LPVOID lpReserved)
- {
- switch (dwReasonForCall)
- {
- case DLL_PROCESS_ATTACH:
- g_hModule = hModule;
- CreateThread(NULL, NULL, (LPTHREAD_START_ROUTINE)init, NULL, NULL, NULL);
- break;
- case DLL_THREAD_ATTACH:
- break;
- case DLL_THREAD_DETACH:
- break;
- case DLL_PROCESS_DETACH:
- break;
- }
- return TRUE;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement