Advertisement
Hidend

Untitled

May 10th, 2024
745
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.78 KB | None | 0 0
  1. //hidend
  2. #include "pch.h"
  3. #include <iostream>
  4. #include <fstream>
  5. #include <cstring>
  6. #include <Shlwapi.h>
  7.  
  8. DWORD samp_base = 0;
  9. HMODULE g_hModule = NULL;
  10. bool bDetourMyself = false;
  11.  
  12. const DWORD OFFSETS[6][2]{
  13.     /*ChatInfo, AddMsg*/
  14.     {0x21A0E4, 0x645A0}, // 037-r1 - 0
  15.     {0x021A0EC, 0x64670}, // 037-r2 - 1
  16.     {0x026E8C8, 0x679F0}, // 037-r3_1 - 2
  17.     {0x026E9F8, 0x68130}, // 037-r4 - 3
  18.     {0x026E9F8, 0x68170}, // 037-r4_2 -4
  19.     {0x026EB80, 0x68170}, // 037-r5_1 - 5
  20. };
  21.  
  22. int get_samp_version_id()
  23. {
  24.     int version_current = -1;
  25.  
  26.     if (samp_base)
  27.     {
  28.         int version_id = *reinterpret_cast<int*>((char*)samp_base + 0x128);
  29.         switch (version_id) {
  30.         case 0x5542F47A: // R1
  31.             version_current = 0;
  32.             break;
  33.         case 0x59C30C94: // R2
  34.             version_current = 1;
  35.             break;
  36.         default:
  37.             version_id = *reinterpret_cast<int*>((char*)samp_base + 0x120);
  38.  
  39.             switch (version_id) {
  40.             case 0x5C0B4243: // R3
  41.                 version_current = 2;
  42.                 break;
  43.             case 0x5DD606CD: // R4 - v1
  44.                 version_current = 3;
  45.                 break;
  46.             case 0x6094ACAB: // R4 - v2
  47.                 version_current = 4;
  48.                 break;
  49.             case 0x6372C39E: // R5, ni nos interesa pero meh
  50.                 version_current = 5;
  51.                 break;
  52.             }
  53.         }
  54.     }
  55.     return version_current;
  56. }
  57.  
  58. void addMessageToChat(unsigned dwColor, const char* szMsg, ...)
  59. {
  60.     int version = get_samp_version_id();
  61.     if (version == -1)
  62.         return;
  63.  
  64.     DWORD chatInfoOffset = OFFSETS[version][0];
  65.     DWORD addMsgOffset = OFFSETS[version][1];
  66.  
  67.     unsigned char red = static_cast<unsigned char>(rand() % 256);
  68.     unsigned char green = static_cast<unsigned char>(rand() % 256);
  69.     unsigned char blue = static_cast<unsigned char>(rand() % 256);
  70.  
  71.     // Combine the color components into a single unsigned integer
  72.     unsigned newColor = (red << 16) | (green << 8) | blue;
  73.     auto addMessage = reinterpret_cast<void(__thiscall*)(void* pChat, unsigned color, const char* message)>(samp_base + addMsgOffset);
  74.     addMessage(*reinterpret_cast<void**>(samp_base + chatInfoOffset), newColor, szMsg);
  75. }
  76.  
  77. void searchStringInFile(const char* filePath, const char* searchString) {
  78.     std::ifstream file(filePath);
  79.     if (file.is_open()) {
  80.         addMessageToChat(-1, "abierto");
  81.         char line[256];
  82.         char buffer[256];
  83.         while (file.getline(line, sizeof(line))) {
  84.             addMessageToChat(-1, line);
  85.             char* pos = strstr(line, searchString);
  86.             if (pos != nullptr) {
  87.                 sprintf_s(buffer, sizeof(buffer), "Encontrado en archivo in file: %s\n", filePath);
  88.                 addMessageToChat(-1, buffer);
  89.                 sprintf_s(buffer, sizeof(buffer), "Texto encontrado: '%s'", searchString);
  90.                 addMessageToChat(-1, buffer);
  91.                 break;
  92.             }
  93.         }
  94.         file.close();
  95.     }
  96. }
  97.  
  98. int init()
  99. {
  100.     char* Directorio = reinterpret_cast<char*>(0xB71A60);
  101.     samp_base = (DWORD)LoadLibraryA("samp.dll");
  102.  
  103.     searchStringInFile("D:\\Games\\Grand Theft Auto San Andreas\\moonloader\\test.lua", "0x001eb6d4");
  104.     addMessageToChat(-1, "test2");
  105.     FreeLibraryAndExitThread(g_hModule, 0);
  106.     return 0;
  107. }
  108.  
  109. BOOL APIENTRY DllMain(HMODULE hModule, DWORD dwReasonForCall, LPVOID lpReserved)
  110. {
  111.     switch (dwReasonForCall)
  112.     {
  113.     case DLL_PROCESS_ATTACH:
  114.         g_hModule = hModule;
  115.         CreateThread(NULL, NULL, (LPTHREAD_START_ROUTINE)init, NULL, NULL, NULL);
  116.         break;
  117.     case DLL_THREAD_ATTACH:
  118.         break;
  119.     case DLL_THREAD_DETACH:
  120.         break;
  121.     case DLL_PROCESS_DETACH:
  122.         break;
  123.     }
  124.     return TRUE;
  125. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement