Facebook
From Sexy Frog, 7 Months ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 154
  1. //CHLClient::WriteUsercmdDeltaToBuffer index == 23
  2.  
  3. bool __stdcall HookedWriteUsercmdDeltaToBuffer(int slot, void* buf, int from, int to, bool isnewcommand)
  4. {
  5. int* pBackupCommands = reinterpret_cast(reinterpret_cast(buf) - 0x30);
  6. int* pNewCommands = reinterpret_cast(reinterpret_cast(buf) - 0x2C);
  7.  
  8. int cl_cmdbackup = 0;
  9. *pBackupCommands = cl_cmdbackup;
  10.  
  11. static bool firstcmd = false;
  12. if (from == -1) firstcmd = true;
  13.  
  14. if (to > g_pClientState->lastoutgoingcommand - cl_cmdbackup)
  15. {
  16. if (firstcmd) from = -1;
  17. firstcmd = false;
  18.  
  19. CUserCmd nullCmd;
  20. CUserCmd* cmdFrom;
  21. CUserCmd* cmdTo;
  22.  
  23. if (from == -1)
  24. {
  25. cmdFrom = &nullCmd;
  26. }
  27. else
  28. {
  29. cmdFrom = g_pInput->GetUserCmd(from);
  30. }
  31.  
  32. if (to == -1)
  33. {
  34. cmdTo = &nullCmd;
  35. }
  36. else
  37. {
  38. cmdTo = g_pInput->GetUserCmd(to);
  39. }
  40.  
  41. static auto WriteUsercmd = reinterpret_cast((uintptr_t)GetModuleHandleA("client.dll") + 0x34FA10);
  42.  
  43. __asm
  44. {
  45. mov ecx, buf;
  46. mov edx, cmdTo;
  47. push cmdFrom;
  48. call WriteUsercmd;
  49. add esp, 4h;
  50. }
  51. }
  52.  
  53. return true;
  54. }