Advertisement
Hidend

Untitled

May 6th, 2024
2,846
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.92 KB | None | 0 0
  1. //hidend
  2. #include <Windows.h>
  3. #include <d3d9.h>
  4. #include <cstdio>
  5. #include <iostream>
  6.  
  7. uint32_t samp_base = 0;
  8.  
  9. const DWORD OFFSETS[6][2]{
  10.     /*ChatInfo, AddMsg*/
  11.     {0x21A0E4, 0x645A0}, // 037-r1 - 0
  12.     {0x021A0EC, 0x64670}, // 037-r2 - 1
  13.     {0x026E8C8, 0x679F0}, // 037-r3_1 - 2
  14.     {0x026E9F8, 0x68130}, // 037-r4 - 3
  15.     {0x026E9F8, 0x68170}, // 037-r4_2 -4
  16.     {0x026EB80, 0x68170}, // 037-r5_1 - 5
  17. };
  18.  
  19. int get_samp_version_id()
  20. {
  21.     int version_current = -1;
  22.  
  23.     if (samp_base)
  24.     {
  25.         std::cout << "Dentro!" << std::endl;
  26.         int* x = reinterpret_cast<int*>((char*)samp_base + 0x128);
  27.         int version_id = *x;  // Directly dereference the pointer
  28.         std::cout << "Version1: " << version_id << std::endl;
  29.         switch (version_id) {
  30.         case 0x5542F47A: //
  31.             std::cout << "Hit!" << version_id << std::endl;
  32.             version_current = 0;
  33.             break;
  34.         case 0x59C30C94: // R2
  35.             version_current = 1;
  36.             break;
  37.  
  38.             version_id = *(DWORD*)(samp_base + 0x120);
  39.  
  40.             switch (version_id) {
  41.             case 0x5C0B4243: // R3
  42.                 version_current = 2;
  43.                 break;
  44.             case 0x5DD606CD: // R4 - v1
  45.                 version_current = 3;
  46.                 break;
  47.             case 0x6094ACAB: // R4 - v2
  48.                 version_current = 4;
  49.                 break;
  50.             case 0x6372C39E: // R5, ni nos interesa pero meh
  51.                 version_current = 5;
  52.                 break;
  53.             }
  54.  
  55.         }
  56.     }
  57.     return version_current;
  58. }
  59.  
  60. void addMessageToChat(D3DCOLOR dwColor, const char* szMsg, ...)
  61. {
  62.     int version = get_samp_version_id();
  63.     std::cout << "Version2: " << version << std::endl;
  64.     if (version == -1)
  65.         return;
  66.  
  67.     DWORD chatInfoOffset = OFFSETS[version][0];
  68.     DWORD addMsgOffset = OFFSETS[version][1];
  69.  
  70.     std::cout << "chatInfoOffset: " << chatInfoOffset << std::endl;
  71.     std::cout << "addMsgOffset: " << addMsgOffset << std::endl;
  72.     auto addMessage = reinterpret_cast<void(__thiscall*)(void* pChat, unsigned color, const char* message)>(samp_base + addMsgOffset);
  73.     addMessage(*reinterpret_cast<void**>(samp_base + chatInfoOffset), dwColor, szMsg);
  74. }
  75.  
  76.  
  77. int init()
  78. {
  79.     std::cout << "init" << std::endl;
  80.     samp_base  = (DWORD)LoadLibraryA("samp.dll");
  81.     while (true)
  82.     {
  83.         addMessageToChat(-1, "Hidend // Shaarawy // <3");
  84.         Sleep(5000);
  85.     }
  86.     return true;
  87. }
  88.  
  89. BOOL APIENTRY DllMain(HMODULE hModule, DWORD dwReasonForCall, LPVOID lpReserved)
  90. {
  91.     switch (dwReasonForCall)
  92.     {
  93.     case DLL_PROCESS_ATTACH:
  94.         AllocConsole();
  95.         freopen("CONOUT$", "w", stdout);
  96.         std::cout << "injected" << std::endl;
  97.         CreateThread(NULL, NULL, (LPTHREAD_START_ROUTINE)init, NULL, NULL, NULL);
  98.         break;
  99.     case DLL_THREAD_ATTACH:
  100.     case DLL_THREAD_DETACH:
  101.     case DLL_PROCESS_DETACH:
  102.         break;
  103.     }
  104.     return TRUE;
  105. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement