IlDivinoGlade

GTA V 1.27 – Random Stuff 3

Jul 17th, 2025 (edited)
205
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 9.28 KB | None | 0 0
  1. thanks to TheRouletteBoi: https://pastebin.com/VCfMb46E
  2. void PatchInJump(int Address, int Destination, bool Linked) {
  3.  
  4.     // use this data to copy over the address
  5.     int FuncBytes[4];
  6.  
  7.     // Get the actual destination address
  8.     Destination = *(int *)Destination;
  9.  
  10.     FuncBytes[0] = 0x3D600000 + ((Destination >> 16) & 0xFFFF); // lis     %r11, dest>>16
  11.     if (Destination & 0x8000) // If bit 16 is 1
  12.         FuncBytes[0] += 1;
  13.  
  14.     FuncBytes[1] = 0x396B0000 + (Destination & 0xFFFF); // addi    %r11, %r11, dest&0xFFFF
  15.     FuncBytes[2] = 0x7D6903A6; // mtctr    %r11
  16.  
  17.     FuncBytes[3] = 0x4E800420; // bctr
  18.  
  19.     if (Linked)
  20.         FuncBytes[3] += 1; // bctrl
  21.  
  22.     write_process((void*)Address, FuncBytes, 4 * 4);
  23. }
  24.  
  25.  
  26. void branch_link(uint32_t branchTo, uint32_t branchFrom)
  27. {
  28.     uint32_t branch;
  29.     if (branchTo > branchFrom)
  30.     {
  31.         branch = 0x48000001 + (branchTo - branchFrom);
  32.     }
  33.     else
  34.     {
  35.         branch = 0x4C000001 - (branchFrom - branchTo);
  36.     }
  37.     write_process((void*)branchFrom, &branch, 4);
  38. }
  39.  
  40.  
  41. void PatchInBranch(uint32_t* address, uint32_t destination, bool linked)
  42. {
  43.     uint32_t inst_branch = 0x48000000 + ((destination - (uint32_t)address) & 0x3FFFFFF); // b Destination
  44.  
  45.     if (linked)
  46.         inst_branch += 1; // bl Destination
  47.  
  48.     write_process(address, &inst_branch, sizeof(inst_branch));
  49. }
  50.  
  51.  
  52. void PatchInVmt(uint32_t* address, uint32_t destination)
  53. {
  54.     uint64_t raw = GetRawDestination(uint64_t, destination);
  55.     write_process(address, &raw, sizeof(raw));
  56. }
  57.  
  58.  
  59. other class: https://github.com/Mr-X-GTA/GTAV-Classes-1/tree/master
  60.  
  61. #define MAX_PLAYERS 64
  62. #define NAME_LENGTH 32
  63.  
  64.  
  65. typedef struct {
  66.     char playerName[NAME_LENGTH];  // Nome del giocatore (buffer statico)
  67. } NetworkedPlayer;
  68.  
  69. NetworkedPlayer Players[MAX_PLAYERS];
  70. int PlayersCount = 0;
  71. int NetworkedPlayersIndex = 0;
  72.  
  73. uint32_t hashString(const char* str) {
  74.     uint32_t hash = 5381;
  75.     int c;
  76.     while ((c = *str++)) {
  77.         hash = ((hash << 5) + hash) + c;
  78.     }
  79.     return hash % MAX_PLAYERS;
  80. }
  81.  
  82.  
  83. int findPlayer(const char* name) {
  84.     uint32_t hash = hashString(name);
  85.     for (int i = 0; i < PlayersCount; i++) {
  86.         if (hashString(Players[i].playerName) == hash && strcmp(Players[i].playerName, name) == 0) {
  87.             return i;
  88.         }
  89.     }
  90.     return -1;
  91. }
  92.  
  93.  
  94.  
  95. void addPlayer(const char* name) {
  96.     if (findPlayer(name) != -1) return; // already saved...
  97.  
  98.     if (PlayersCount < MAX_PLAYERS) {
  99.         strncpy(Players[PlayersCount].playerName, name, NAME_LENGTH - 1);
  100.         Players[PlayersCount].playerName[NAME_LENGTH - 1] = '\0';
  101.         PlayersCount++;
  102.         printf("Aggiunto: %s\n", name);
  103.     }
  104.     else {
  105.         printf("The list is full! You can't add more players.\n");
  106.     }
  107. }
  108.  
  109.  
  110. void removePlayer(const char* name) {
  111.     int index = findPlayer(name);
  112.     if (index != -1) {
  113.         for (int i = index; i < PlayersCount - 1; i++) {
  114.             Players[i] = Players[i + 1];  // Shift elements
  115.         }
  116.         PlayersCount--;
  117.         printf("Removed: %s\n", name);
  118.     }
  119. }
  120.  
  121.  
  122.  
  123. void clearPlayers() {
  124.     PlayersCount = 0;
  125.     printf("Player list cleared.\n");
  126. }
  127.  
  128.  
  129. //in any your hook
  130. /*
  131.  
  132.  char* playerName = (char*)(*(int*)(dwNetPlayer + 0x78) + 0x10);
  133.  
  134.  addPlayer(playerName);
  135.  
  136. */
  137.  
  138.  
  139. //Classic menu base:
  140.  
  141. /*
  142. tip: add clearPlayers to "Networked Players" list.
  143. */
  144.  
  145. case YourNetPlayers:
  146. addTitle("Networked Players");
  147. for (int i = 0; i < PlayersCount; i++) {
  148.     if (Players[i].playerName == NULL) continue;
  149.  
  150.     char displayText[64];
  151.     snprintf(displayText, sizeof(displayText), "%s", Players[i].playerName);
  152.     addOption(displayText);
  153. }
  154.  
  155. if (optionPress && currentOption - 1 >= 0)
  156. {
  157.     NetworkedPlayersIndex = currentOption - 1;
  158.     changeSubmenu(NetworkedPlayersIndexOpt);
  159. }
  160. break;
  161.  
  162.  
  163.  
  164. case NetworkedPlayersIndexOpt:
  165. addTitle("Networked Players Index");
  166. addOption("Send Invite");
  167. addOption("Remove Player"); // remove player from your array
  168. switch (getOption())
  169. {
  170. case 1:
  171.     SendGameInvite(PLAYER::GET_PLAYER_NAME(NetworkedPlayersIndex));
  172.     break;
  173. case 2:
  174.     removePlayer(PLAYER::GET_PLAYER_NAME(NetworkedPlayersIndex));
  175.     break;
  176. }
  177. break;
  178.  
  179.  
  180.  
  181.  
  182. // I have not tested, but with this shit you can send invalid info to session (like your model hash). I dont write this shit for you. I have releasing this just for give ability to ppl how work desync and protections
  183.  
  184. //0xA076FC UpdateNetworkObject aka SendCloneSync
  185.  
  186. void hook::SendCloneSync(void* netSendData, void* netObject, void* syncTree, void* unk, int sendImmediately)
  187. {
  188.     NetObject* obj = (NetObject*)netObject;
  189.  
  190.     printf("SendCloneSync | Count: %X\n", obj->syncCount);
  191.  
  192.     if (CloneCrashSpoof)
  193.     {
  194.         printf("[CRASH TEST] Overflowing sync buffer...\n");
  195.  
  196.         if (obj->syncBuffer)
  197.         {
  198.             for (int i = 0; i < 0x100; i++)
  199.             {
  200.                 obj->syncBuffer[i] = 0xDE; // buffer overflow
  201.             }
  202.         }
  203.  
  204.         obj->timestamp = 0xFFFFFFFF;
  205.         obj->syncCount = 0xFFFF;
  206.     }
  207.  
  208.     Original Send Clone Sync = (netSendData, netObject, syncTree, unk, sendImmediately);
  209. }
  210.  
  211.  
  212.  
  213.  
  214. void vehicle::SetVehicleLight(float value) // visible to other player
  215. {
  216.     int vehAddr = GetEntityAddress(PED::GET_VEHICLE_PED_IS_IN(PLAYER::PLAYER_PED_ID(), false));
  217.     if (vehAddr)
  218.         *(float*)(vehAddr + 0x520) = value;
  219. }
  220.  
  221.  
  222. void vehicle::SetDirtyLevel(float level) // visible to other player
  223. {
  224.     int vehAddr = GetEntityAddress(PED::GET_VEHICLE_PED_IS_IN(PLAYER::PLAYER_PED_ID(), false));
  225.     if (vehAddr)
  226.         *(float*)(vehAddr + 0x50C) = level;
  227. }
  228.  
  229.  
  230. void vehicle::SetWheelType(int wheelType) // im not sure if it work
  231. {
  232.     int vehAddr = GetEntityAddress(PED::GET_VEHICLE_PED_IS_IN(PLAYER::PLAYER_PED_ID(), false));
  233.     if (vehAddr)
  234.         *(int*)(vehicleAddress + 0x664) = wheelType;
  235. }
  236.  
  237. // pseudo code - gadgetId is hash - so, do you think if you set to another hash (like car), can freeze ppl? wtf R*
  238. void ped::SetGadget(int scriptHandle, uint32_t gadgetId, uint8_t flag) // flag always true
  239. {
  240.     uint32_t* pedAddress = GetEntityAddress(scriptHandle); // debug it
  241.     if (pedAddress == NULL)
  242.         return;
  243.  
  244.     uint32_t** vtable = *(uint32_t***)pedAddress;
  245.     if (vtable == NULL)
  246.         return;
  247.  
  248.     if (call<int>(0x152060C)(pedAddress, gadgetId) == 0) // seems like check if pedAddress and gadgetId is valid
  249.         return;
  250.  
  251.     int valBD4 = *(int*)((char*)pedAddress + 0xBD4);
  252.     if (valBD4 == 0)
  253.         return;
  254.  
  255.     int valBD8 = *(int*)((char*)pedAddress + 0xBD8);
  256.     if (valBD8 == 0)
  257.         return;
  258.  
  259.     // something for set it
  260.     call<void>(0xFDA134)(pedAddress, gadgetId, -1, flag, 0, 0);
  261. }
  262.  
  263. //this is just a pseudo code
  264. void ChangePedSyncTreeType(unsigned short newType) {
  265.  
  266.     //nah, it freeze all mod menu
  267. }
  268.  
  269.  
  270. struct CSyncDataWriter {
  271.     uint8_t* buffer;
  272.     size_t size;
  273.     size_t pos;
  274.  
  275.  
  276.     void Init(size_t bufferSize) {
  277.         if (buffer) delete[] buffer;
  278.         buffer = new uint8_t[bufferSize];
  279.         size = bufferSize;
  280.         pos = 0;
  281.         memset(buffer, 0, size);
  282.     }
  283.  
  284.     bool Write(const void* data, size_t dataSize) {
  285.         if (pos + dataSize > size) return false; // overflow buffer
  286.         memcpy(buffer + pos, data, dataSize);
  287.         pos += dataSize;
  288.         return true;
  289.     }
  290.  
  291.     bool WriteUint64(uint64_t value) {
  292.         return Write(&value, sizeof(value));
  293.     }
  294.  
  295.     bool WriteUint32(uint32_t value) {
  296.         return Write(&value, sizeof(value));
  297.     }
  298.  
  299.     bool WriteByte(uint8_t value) {
  300.         return Write(&value, sizeof(value));
  301.     }
  302.  
  303.     void Reset() {
  304.         pos = 0;
  305.         if (buffer) memset(buffer, 0, size);
  306.     }
  307.  
  308.     ~CSyncDataWriter() {
  309.         if (buffer) {
  310.             delete[] buffer;
  311.             buffer = nullptr;
  312.         }
  313.     }
  314. };
  315.  
  316. struct ConnectionType {
  317.     int connectionId;
  318.     bool isValid;
  319. };
  320.  
  321. struct CLocalPlayerMgr {
  322.     uint32_t playerId;
  323.     char playerName[32];
  324.     bool isConnected;
  325. };
  326.  
  327. // Function to send a kick command
  328. void SendKick_v1(CNetGamePlayer* target, ConnectionType* connection, CLocalPlayerMgr* localPlayerMgr) {
  329.     // 1. Prepare writer (initialize struct, then call function to setup)
  330.     CSyncDataWriter writer = {}; // zero initialize
  331.     call<void>(0xA8B814, &writer);  // Assume function fills writer, returns void
  332.  
  333.     // 2. Buffer to hold the packet to send
  334.     uint8_t extraData[0x3D6] = {};
  335.  
  336.     // 3. Prepare extra data from writer into extraData buffer
  337.     call<void>(0xA8B908, &writer, extraData, sizeof(extraData));
  338.  
  339.     // 4. Write Kick message ID
  340.     static const uint32_t MsgKickPlayer_AutoIdDesc = 0x1888B90;
  341.     call<void>(0x1626844, &MsgKickPlayer_AutoIdDesc, &writer);
  342.  
  343.     // 5. Write hostToken (player UUID) of target player (64 bits)
  344.     call<void>(0xA8BF68, &writer, target->playerInfo->uuid, 0x40);
  345.  
  346.     // 6. Serialize data into final buffer
  347.     call<uint32_t>(0xA8B5FC, &writer);
  348.  
  349.     // 7. Optionally deserialize for checks
  350.     call<uint32_t>(0xA8BBBC, &writer);
  351.  
  352.     // 8. Get final bit flag (state flags or similar)
  353.     uint64_t bitFlag = call<uint64_t>(0xA8B978, &writer);
  354.  
  355.     // 9. Send reliable command with the prepared data
  356.     call<uint32_t>(0xD11D0C, connection, localPlayerMgr, extraData, 1, bitFlag);
  357. }
  358.  
  359.  
  360. // I have not tested, if work... enjoy lol
  361. void SendKick(int selectedPlayer)
  362. {
  363.     CNetGamePlayer* targetPlayer = CNetGamePlayerfn(selectedPlayer);
  364.     if (!targetPlayer) {
  365.         // handle error
  366.         return;
  367.     }
  368.  
  369.     ConnectionType connection = { true, 42 };
  370.     CLocalPlayerMgr localPlayer = { 1, "" }; // i'm not sure
  371.     strncpy(localPlayer.playerName, "LocalPlayer", sizeof(localPlayer.playerName)); // maybe use another name like
  372. get_player_name(selectedPlayer)...
  373.    
  374.     localPlayer.isConnected = true;
  375.  
  376.     SendKick_v1(targetPlayer, &connection, &localPlayer);
  377. }
  378.  
Advertisement
Add Comment
Please, Sign In to add comment