Advertisement
Guest User

gta

a guest
Apr 27th, 2015
686
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.42 KB | None | 0 0
  1. /*
  2. THIS FILE IS A PART OF GTA V SCRIPT HOOK SDK
  3. http://dev-c.com
  4. (C) Alexander Blade 2015
  5. */
  6. #pragma warning(disable:4996)
  7. #include <windows.h>
  8. #include <stdio.h>
  9. #include <string>
  10. #include <psapi.h>
  11. #include <stdint.h>
  12.  
  13. #include "..\..\inc\main.h"
  14. #include "script.h"
  15.  
  16. using namespace std;
  17. DWORD64 GetModuleBase(HANDLE hProc, string &sModuleName)
  18. {
  19.  
  20.  
  21.  
  22. HMODULE *hModules;
  23. hModules = 0;
  24. char szBuf[50];
  25. DWORD cModules = 0;
  26. DWORD64 dwBase = 0;
  27.  
  28. EnumProcessModules(hProc, hModules, 0, &cModules);
  29. hModules = new HMODULE[cModules / sizeof(HMODULE)];
  30.  
  31. if (EnumProcessModules(hProc, hModules, cModules / sizeof(HMODULE), &cModules)) {
  32. for (int i = 0; i < cModules / sizeof(HMODULE); i++) {
  33. if (GetModuleBaseName(hProc, hModules[i], szBuf, sizeof(szBuf))) {
  34. if (sModuleName.compare(szBuf) == 0) {
  35. dwBase = (DWORD64)hModules[i];
  36. break;
  37. }
  38. }
  39. }
  40. }
  41.  
  42. delete[] hModules;
  43.  
  44. return dwBase;
  45. }
  46.  
  47. void bypass_online()
  48. {
  49. __int64 Address = GetModuleBase(GetCurrentProcess(), string("GTA5.exe"));
  50. INT i, p;
  51. CHAR *MemoryBuff = new CHAR[512];
  52. int ok = 0;
  53. HANDLE hProcess = GetCurrentProcess();
  54. BYTE bytes[] = { 0x48, 0x8B, 0x88, 0x10, 0x01, 0x00, 0x00 };
  55. BYTE bytes2[] = { 0x4C, 0x8D, 0x8A, 0xC4, 0x00, 0x00, 0x00 };
  56. BYTE jmp[] = { 0xEB, 0x1B };
  57. BYTE nop2[] = { 0x90, 0x90 };
  58. int count = 0;
  59. int adc = 0;
  60. for (int i = 0; i < 0x9FFF9840; i++)
  61. {
  62. ReadProcessMemory(hProcess, (LPVOID)Address, (LPVOID)MemoryBuff, 512, NULL);
  63. for (p = 0; p < 512; p++)
  64. {
  65. Address++;
  66. MemoryBuff++;
  67. if (ok == 0)
  68. {
  69. if (memcmp(MemoryBuff, bytes, 7) == 0)
  70. {
  71. count++;
  72. if (count == 2)
  73. {
  74. WriteProcessMemory(hProcess, (LPVOID)(Address + 0x2D), nop2, 2, 0);
  75. ok = 1;
  76. count = 0;
  77. }
  78. }
  79. }
  80. if (ok == 1)
  81. {
  82. if (adc == 0)
  83. {
  84. Address = GetModuleBase(GetCurrentProcess(), string("GTA5.exe"));
  85. adc = 1;
  86. }
  87.  
  88. if (memcmp(MemoryBuff, bytes2, 7) == 0)
  89. {
  90. count++;
  91. if (count == 4)
  92. {
  93. WriteProcessMemory(hProcess, (LPVOID)(Address - 0x278), jmp, 2, 0);
  94. goto endfunc;
  95. }
  96. }
  97. }
  98.  
  99. }
  100. MemoryBuff = MemoryBuff - 512;
  101. }
  102. endfunc:;
  103. }
  104.  
  105. BOOL APIENTRY DllMain(HMODULE hInstance, DWORD reason, LPVOID lpReserved)
  106. {
  107. switch (reason)
  108. {
  109. case DLL_PROCESS_ATTACH:
  110. scriptRegister(hInstance, ScriptMain);
  111. bypass_online();
  112. break;
  113. }
  114. return TRUE;
  115. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement