Advertisement
Guest User

Untitled

a guest
Feb 27th, 2015
184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.36 KB | None | 0 0
  1. #include <Windows.h>
  2. #include <iostream>
  3. #include <TlHelp32.h>
  4.  
  5. int i;
  6. int junkjumps;
  7.  
  8. HANDLE GetProcessHandleByName( const char* pImageName )
  9. {
  10. PROCESSENTRY32 pe32;
  11. HANDLE hSnapShot = NULL;
  12. DWORD dwPID = 0;
  13.  
  14. if( !pImageName )
  15. return INVALID_HANDLE_VALUE;
  16.  
  17. hSnapShot = CreateToolhelp32Snapshot( TH32CS_SNAPPROCESS, 0 );
  18.  
  19. if( hSnapShot != INVALID_HANDLE_VALUE )
  20. {
  21. pe32.dwSize = sizeof( PROCESSENTRY32 );
  22.  
  23. if( Process32First( hSnapShot, &pe32 ) )
  24. {
  25. do
  26. {
  27. if( !strcmp( pe32.szExeFile, pImageName ) )
  28. {
  29. dwPID = pe32.th32ProcessID;
  30.  
  31. if( dwPID != 0 )
  32. {
  33. hSnapShot = OpenProcess( PROCESS_ALL_ACCESS, false, dwPID );
  34.  
  35. return hSnapShot;
  36. }
  37. }
  38.  
  39. }while( Process32Next( hSnapShot, &pe32 ) );
  40. }
  41. }
  42.  
  43. return INVALID_HANDLE_VALUE;
  44. }
  45.  
  46. DWORD GetModuleBaseAddress( HANDLE hProcess, const char* pModuleName )
  47. {
  48. if( hProcess == INVALID_HANDLE_VALUE || !pModuleName )
  49. return 0;
  50.  
  51. DWORD dwPID = 0;
  52. HANDLE hSnapShot = NULL;
  53. MODULEENTRY32 moduleEntry32;
  54.  
  55. dwPID = GetProcessId( hProcess );
  56.  
  57. if( dwPID == 0 )
  58. return 0;
  59.  
  60. hSnapShot = CreateToolhelp32Snapshot( TH32CS_SNAPMODULE, dwPID );
  61.  
  62. if( hSnapShot == INVALID_HANDLE_VALUE )
  63. return 0;
  64.  
  65. moduleEntry32.dwSize = sizeof( moduleEntry32 );
  66.  
  67. if( Module32First( hSnapShot, &moduleEntry32 ) )
  68. {
  69. do
  70. {
  71. if( !strcmp( moduleEntry32.szModule, pModuleName ) )
  72. {
  73. return ( DWORD )moduleEntry32.modBaseAddr;
  74. CloseHandle( hSnapShot );
  75. }
  76.  
  77. }while( Module32Next( hSnapShot, &moduleEntry32 ) );
  78. }
  79.  
  80. return 0;
  81. }
  82.  
  83. template<class T> T ReadMemory( HANDLE hProcess, PVOID pBaseAddress )
  84. {
  85. if( hProcess == INVALID_HANDLE_VALUE )
  86. return 0;
  87.  
  88. T buffer;
  89. if( ReadProcessMemory( hProcess, pBaseAddress, &buffer, sizeof( T ), NULL ) )
  90. return buffer;
  91. else
  92. return 0;
  93. }
  94.  
  95. int ranjumps()
  96. {
  97. int junkjumps;
  98. int min = 4;
  99. int max = 8;
  100.  
  101. junkjumps = min + (rand() % (int)(max - min + 1));
  102. return junkjumps;
  103. }
  104.  
  105.  
  106.  
  107. int main( )
  108. {
  109. HANDLE hProcess = NULL;
  110. HWND hWindow = nullptr;
  111.  
  112.  
  113.  
  114. hProcess = GetProcessHandleByName( "csgo.exe" );
  115.  
  116. if( hProcess == INVALID_HANDLE_VALUE )
  117. {
  118. printf( "Couldnt get handle huso!\n" );
  119. return ( int )( 0x13376077 | ( ~0xDEADBEEF ) );
  120. }
  121.  
  122. hWindow = FindWindowA( "Valve001", NULL );
  123.  
  124. if( !hWindow )
  125. {
  126. printf( "Couldnt get window!\n" );
  127. return ( int )( 0x13376077 | ( ~0xDEADBEEF ) );
  128. }
  129.  
  130. DWORD dwClientBase = 0;
  131.  
  132. dwClientBase = GetModuleBaseAddress( hProcess, "client.dll" );
  133.  
  134. if( dwClientBase == 0 )
  135. {
  136. printf( "Couldnt get client.dll!\n" );
  137. return ( int )( 0x13376077 | ( ~0xDEADBEEF ) );
  138. }
  139.  
  140.  
  141.  
  142. while( 1 )
  143. {
  144. if( GetAsyncKeyState( VK_XBUTTON1) )
  145. {
  146. DWORD dwLocalPlayer = 0;
  147.  
  148. dwLocalPlayer = ReadMemory< DWORD >( hProcess, ( PVOID )( dwClientBase + 0xA6D91C ) );
  149.  
  150. if( dwLocalPlayer != 0 )
  151. {
  152. int iFlags = 0;
  153.  
  154. iFlags = ReadMemory< int >( hProcess, ( PVOID )( dwLocalPlayer + 0x100 ) );
  155.  
  156. if( iFlags & ( 1 << 0 ) )
  157. {
  158. SendMessage( hWindow, WM_KEYDOWN, 0x5A, 0x150000 );
  159. SendMessage( hWindow, WM_KEYUP, 0x5A, 0x150000 );
  160. ranjumps();
  161.  
  162. for(i = 0; i < junkjumps; i++)
  163. {
  164. SendMessage( hWindow, WM_KEYDOWN, 0x5A, 0x150000 );
  165. SendMessage( hWindow, WM_KEYUP, 0x5A, 0x150000 );
  166. Sleep(30);
  167. }
  168.  
  169.  
  170.  
  171. }
  172. }
  173. }
  174. Sleep( 3 );
  175. }
  176.  
  177. return 0;
  178. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement