Pushok

Bunny Hop Source Code

Aug 2nd, 2011
1,748
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 7.52 KB | None | 0 0
  1. #include <windows.h>
  2. #include <Tlhelp32.h>
  3. #include "resource.h"
  4. #include <process.h>
  5.  
  6. #include "COffset.h"
  7.  
  8. #define VIP_Version
  9.  
  10. //#define HWID_Scan
  11. //#define HWID_Text L"{f7da1740-0aad-11e0-8ad9-806d6172696f}"
  12.  
  13. #define WM_APP_NCALLBACK WM_USER + 1
  14.  
  15. #define WM_TRAY_EXIT WM_USER + 2
  16. #define WM_TRAY_ABOUT WM_USER + 3
  17.  
  18. #define ABOUT_MESSAGE L"Programm by Push.\nMy steam: http://steamcommunity.com/id/pushad"
  19. #define ABOUT_CAPTION L"About"
  20.  
  21. inline void DoJump(DWORD Delay)
  22. {
  23.     keybd_event(VK_SPACE, 0x39, KEYEVENTF_EXTENDEDKEY, VIRTUAL_KEY);
  24.     Sleep(Delay);
  25.     keybd_event(VK_SPACE, 0x39, KEYEVENTF_EXTENDEDKEY|KEYEVENTF_KEYUP, VIRTUAL_KEY);
  26. }
  27.  
  28. struct OFFSETS
  29. {
  30.     DWORD Offset;
  31.     LPWSTR szModuleName;
  32. } sOffsetData[] = {
  33.  
  34.     {0x5B8C38, L"client.dll"}, // On Ground
  35.     {0x570250, L"client.dll"}, // In Game
  36.     {0x5B6234, L"client.dll"}, // In Water // Obsolete
  37.     {0x4DCA0, L"vgui2.dll"}, // Chat overlay
  38.     {0x5BC088, L"client.dll"} // Server
  39.  
  40. };
  41.  
  42. HINSTANCE g_hInst = nullptr;
  43. HHOOK Hook =        nullptr;
  44. HWND hThisWindow =  nullptr;
  45. HWND hCSWindow =    nullptr;
  46. HANDLE hCSProc =    nullptr;
  47. DWORD dwProcID =    NULL;
  48. static volatile bool KeyState =     false;
  49.  
  50. COffset *OnGround, *InGame, *InWater, *ChatOverlay;
  51. CStringOffset *IpAddress;
  52.  
  53. bool IsIpInBlackList(const char* szServerIP)
  54. {
  55.     return strstr(szServerIP, "77.220.180.246")
  56.         || strstr(szServerIP, "77.220.182.59")
  57.         || strstr(szServerIP, "77.220.182.57")
  58.         || strstr(szServerIP, "77.220.182.71")
  59.         || strstr(szServerIP, "77.220.182.73")
  60.         || strstr(szServerIP, "77.220.182.58")
  61.         || strstr(szServerIP, "77.220.180.58")
  62.         || strstr(szServerIP, "77.220.182.70")
  63.         || strstr(szServerIP, "77.220.180.217")
  64.         || strstr(szServerIP, "77.220.180.17")
  65.         || strstr(szServerIP, "77.220.180.132")
  66.         || strstr(szServerIP, "77.220.180.236")
  67.         || strstr(szServerIP, "77.220.180.243")
  68.         || strstr(szServerIP, "77.220.182.75")
  69.         || strstr(szServerIP, "77.220.180.247")
  70.         || strstr(szServerIP, "77.220.180.227")
  71.         || strstr(szServerIP, "77.220.180.220")
  72.         || strstr(szServerIP, "77.220.180.225")
  73.         || strstr(szServerIP, "77.220.180.123")
  74.         || strstr(szServerIP, "77.220.180.100")
  75.         || strstr(szServerIP, "77.220.182.211");
  76. }
  77.  
  78. DWORD WINAPI KBThread( LPVOID lParam )
  79. {
  80.     static bool bJumpDone = false;
  81.  
  82.     while(KeyState)
  83.     {
  84.  
  85.         if(!bJumpDone && OnGround->ReadThis() != -1)
  86.         {
  87.             DoJump(2);
  88.  
  89.             bJumpDone = true;
  90.         }
  91.  
  92.         if(OnGround->ReadThis() == -1)
  93.         {
  94.             bJumpDone = false;
  95.         }
  96.  
  97.         Sleep(5);
  98.     }
  99.  
  100.     return 0;
  101. }
  102.  
  103. LRESULT CALLBACK HookKBD(int nCode, WPARAM wParam, LPARAM lParam)
  104. {
  105.     if(!FindWindow(0, L"Counter-Strike Source") || hCSWindow != FindWindow(0, L"Counter-Strike Source"))
  106.     {
  107.         MessageBox(nullptr, L"Open or reboot CS:S", nullptr, MB_OK);
  108.  
  109.         SendMessage(hThisWindow, WM_DESTROY, NULL, NULL);
  110.         return 0;
  111.     }
  112.  
  113.     if(InGame->ReadThis() && !ChatOverlay->ReadThis())
  114.     {
  115. #ifndef VIP_Version
  116.         if (IsIpInBlackList(IpAddress->ReadString()))
  117.         {
  118.             SendMessage(hThisWindow, WM_DESTROY, NULL, NULL);
  119.             return 0;
  120.         }
  121. #endif
  122.  
  123.         if (wParam == WM_KEYDOWN || wParam == WM_SYSKEYDOWN)
  124.         {
  125.             if(reinterpret_cast<PKBDLLHOOKSTRUCT>(lParam)->vkCode == VK_SPACE && reinterpret_cast<PKBDLLHOOKSTRUCT>(lParam)->dwExtraInfo != VIRTUAL_KEY && !KeyState)
  126.             {
  127.                 KeyState = true;
  128.                 HANDLE hThread = CreateThread(0, 0, KBThread, 0, CREATE_SUSPENDED, 0);
  129.                  
  130.                 SetPriorityClass(hThread, HIGH_PRIORITY_CLASS);
  131.                 ResumeThread(hThread);
  132.             }
  133.         }
  134.         else if (wParam == WM_KEYUP || wParam == WM_SYSKEYUP)
  135.         {
  136.             if(reinterpret_cast<PKBDLLHOOKSTRUCT>(lParam)->vkCode == VK_SPACE && reinterpret_cast<PKBDLLHOOKSTRUCT>(lParam)->dwExtraInfo != VIRTUAL_KEY)
  137.             {
  138.                 if(KeyState)
  139.                 {
  140.                     KeyState = false;
  141.                 }
  142.             }
  143.         }
  144.     }
  145.  
  146.     //return  0;
  147.     return CallNextHookEx(NULL, nCode, wParam, lParam);
  148. }
  149.  
  150. LRESULT CALLBACK WndProc( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam )
  151. {
  152.     switch(msg)
  153.     {
  154.     case WM_CREATE:
  155.         {
  156. #ifdef HWID_Scan
  157.             HW_PROFILE_INFO hwProfile;
  158.  
  159.             if(GetCurrentHwProfile(&hwProfile) != NULL)
  160.             {
  161.                 if(wcscmp(HWID_Text, hwProfile.szHwProfileGuid))
  162.                 {
  163.                     SendMessage(hwnd, WM_DESTROY, 0, 0);
  164.                 }
  165.             }
  166.             else
  167.             {
  168.                 SendMessage(hwnd, WM_DESTROY, 0, 0);
  169.             }
  170. #endif
  171.  
  172.             NOTIFYICONDATA l_nfData;
  173.  
  174.             l_nfData.cbSize = sizeof(l_nfData.cbSize);
  175.             l_nfData.hWnd = hwnd;
  176.             l_nfData.hIcon = LoadIcon(g_hInst, MAKEINTRESOURCE(IDI_BUNNY));
  177.             l_nfData.uID = 1;
  178.             l_nfData.uFlags = NIF_ICON|NIF_MESSAGE|NIF_TIP;
  179.             l_nfData.uCallbackMessage = WM_APP_NCALLBACK;
  180.             wcscpy_s(l_nfData.szTip, L"Bunny Hop programm by Push.");
  181.  
  182.             Shell_NotifyIcon(NIM_ADD, &l_nfData);
  183.  
  184.             hCSWindow = FindWindow(0, L"Counter-Strike Source");
  185.  
  186.             if(!hCSWindow)
  187.             {
  188.                 MessageBox(0, L"First open CS:S!", 0, MB_OK);
  189.                 SendMessage(hwnd, WM_DESTROY, 0, 0);
  190.                 break;
  191.             }
  192.            
  193.             GetWindowThreadProcessId( hCSWindow, &dwProcID );
  194.             hCSProc = OpenProcess( PROCESS_VM_READ, false, dwProcID);
  195.  
  196.             if(!hCSProc)
  197.             {
  198.                 MessageBox(0, L"Can't open CS:S process!", 0, MB_OK);
  199.                 SendMessage(hwnd, WM_DESTROY, 0, 0);
  200.                 break;
  201.             }
  202.  
  203.             OnGround = new COffset(hCSProc, dwProcID, sOffsetData[0].szModuleName, sOffsetData[0].Offset);
  204.             InGame = new COffset(hCSProc, dwProcID, sOffsetData[1].szModuleName, sOffsetData[1].Offset);
  205.             InWater = new COffset(hCSProc, dwProcID, sOffsetData[2].szModuleName, sOffsetData[2].Offset);
  206.             ChatOverlay = new COffset(hCSProc, dwProcID, sOffsetData[3].szModuleName, sOffsetData[3].Offset);
  207.  
  208.             IpAddress = new CStringOffset(hCSProc, dwProcID, sOffsetData[4].szModuleName, sOffsetData[4].Offset);
  209.  
  210.             hThisWindow = hwnd;
  211.             break;
  212.         }
  213.     case WM_COMMAND:
  214.         {
  215.             switch(LOWORD(wParam))
  216.             {
  217.             case WM_TRAY_ABOUT:
  218.                 {
  219.                     MessageBox(0, ABOUT_MESSAGE, ABOUT_CAPTION, MB_OK);
  220.  
  221.                     break;
  222.                 }
  223.             case WM_TRAY_EXIT:
  224.                 {
  225.                     if(MessageBox(0, L"Are you sure?", L"Exit", MB_OKCANCEL) == IDOK)
  226.                     {
  227.                         PostQuitMessage(0);
  228.                     }
  229.  
  230.                     break;
  231.                 }
  232.             }
  233.  
  234.             break;
  235.         }
  236.     case WM_APP_NCALLBACK:
  237.         {
  238.             switch( lParam )
  239.             {
  240.             case WM_RBUTTONDOWN:
  241.                 {
  242.                     POINT pt;
  243.                     GetCursorPos(&pt);
  244.  
  245.                     HMENU hPopupMenu = CreatePopupMenu();
  246.                     InsertMenu(hPopupMenu, 0, MF_BYPOSITION | MF_STRING, WM_TRAY_EXIT, L"Exit");
  247.                     InsertMenu(hPopupMenu, 0, MF_BYPOSITION | MF_STRING, WM_TRAY_ABOUT, L"About");
  248.  
  249.                     TrackPopupMenu(hPopupMenu, TPM_BOTTOMALIGN | TPM_LEFTALIGN, pt.x, pt.y, 0, hwnd, NULL);
  250.                     DestroyMenu(hPopupMenu);
  251.                    
  252.                     break;
  253.                 }
  254.             }
  255.  
  256.             break;
  257.         }
  258.     case WM_DESTROY:
  259.         {
  260.             delete OnGround;
  261.             delete InGame;
  262.             delete InWater;
  263.             delete ChatOverlay;
  264.  
  265.             delete IpAddress;
  266.  
  267.             PostQuitMessage(0);
  268.             break;
  269.         }
  270.     default:
  271.         return DefWindowProc(hwnd, msg, wParam, lParam);
  272.     }
  273. }
  274.  
  275. int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd) {
  276.  
  277.     g_hInst = hInstance;
  278.  
  279.     //Hook = SetWindowsHookEx(WH_GETMESSAGE, HookKBD, g_hInst, 0);
  280.     Hook = SetWindowsHookEx(WH_KEYBOARD_LL, HookKBD, hInstance, 0);
  281.  
  282.  
  283.     MSG  msg;
  284.     WNDCLASS wc = {0};
  285.  
  286.     wc.lpszClassName = L"Bunny Hop";
  287.     wc.hInstance     = hInstance ;
  288.     wc.hbrBackground = GetSysColorBrush(COLOR_3DFACE);
  289.     wc.lpfnWndProc   = WndProc ;
  290.     wc.hCursor       = LoadCursor(0, IDC_ARROW);
  291.     wc.lpszMenuName  = MAKEINTRESOURCE(IDR_MENU1);
  292.     wc.hIcon         = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_BUNNY));
  293.  
  294.     RegisterClass(&wc);
  295.     HWND hWnd = CreateWindow( wc.lpszClassName, L"Bunny Hop",
  296.         WS_OVERLAPPEDWINDOW ^ ~WS_VISIBLE,
  297.         0, 0, 0, 0, 0, 0, hInstance, 0);
  298.  
  299.     while (GetMessage(&msg,NULL,0,0))
  300.     {
  301.         TranslateMessage( &msg );
  302.         DispatchMessage( &msg );
  303.     }
  304.  
  305.     UnhookWindowsHookEx(Hook);
  306.  
  307.     return 0;
  308. }
Advertisement
Add Comment
Please, Sign In to add comment