Advertisement
Hidend

Untitled

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