Advertisement
Guest User

Untitled

a guest
Mar 31st, 2015
1,037
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 4.56 KB | None | 0 0
  1. #include "Websockets.h"
  2. #include <thread>
  3. #include <iostream>
  4. #include "ProcMem.h"
  5. #include <string.h>
  6. #include <windows.h>
  7. #include <windowsx.h>
  8. #include <d3d9.h>
  9. #include <d3dx9.h>
  10. #include <Dwmapi.h>
  11.  
  12. #pragma comment (lib, "winmm.lib") // Needed to play a sound
  13. #pragma comment (lib, "d3d9.lib")
  14. #pragma comment (lib, "d3dx9.lib")
  15.  
  16. using namespace std;
  17.  
  18. boost::mutex mtx;
  19.  
  20. LPDIRECT3D9 d3d;
  21. LPDIRECT3DDEVICE9 d3ddev;
  22. LPD3DXFONT pFont;
  23. HWND hWnd;
  24. WNDCLASSEX wc;
  25.  
  26. LRESULT CALLBACK WindowProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
  27. void hackFeaturesOne(svrtCSGO *hack);
  28. void hackFeaturesTwo(svrtCSGO *hack);
  29. void initD3D(HWND hWnd);
  30. void render_frame(void);
  31. void cleanD3D(void);
  32. void DrawString(int x, int y, DWORD color, LPD3DXFONT g_pFont, const char *fmt);
  33.  
  34. int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
  35. {
  36.     ZeroMemory(&wc, sizeof(WNDCLASSEX));
  37.  
  38.     wc.cbSize = sizeof(WNDCLASSEX);
  39.     wc.style = CS_HREDRAW | CS_VREDRAW;
  40.     wc.lpfnWndProc = WindowProc;
  41.     wc.hInstance = hInstance;
  42.     wc.hCursor = LoadCursor(NULL, IDC_ARROW);
  43.     wc.hbrBackground = (HBRUSH)RGB(0, 0, 0);
  44.     wc.lpszClassName = L"WindowClass1";
  45.  
  46.     RegisterClassEx(&wc);
  47.  
  48.     hWnd = CreateWindowEx(NULL,
  49.         L"WindowClass1", // name of the window class
  50.         L"D3D Overlay", // title of the window
  51.         WS_EX_TOPMOST | WS_POPUP, // window style
  52.         0, // x-position of the window
  53.         0, // y-position of the window
  54.         500, // width of the window
  55.         400, // height of the window
  56.         NULL, // we have no parent window, NULL
  57.         NULL, // we aren't using menus, NULL
  58.         hInstance, // application handle
  59.         NULL // used with multiple windows, NULL
  60.     );
  61.  
  62.     SetWindowLong(hWnd, GWL_EXSTYLE, (int)GetWindowLong(hWnd, GWL_EXSTYLE) | WS_EX_LAYERED | WS_EX_TRANSPARENT);
  63.     SetLayeredWindowAttributes(hWnd, RGB(0, 0, 0), 0, ULW_COLORKEY);
  64.     SetLayeredWindowAttributes(hWnd, RGB(0, 0, 0), 255, LWA_ALPHA);
  65.  
  66.     ShowWindow(hWnd, nCmdShow); // display the window on the screen
  67.  
  68.     initD3D(hWnd);
  69.  
  70.     ::SetWindowPos(FindWindow(NULL, L"Counter-Strike: Global Offensive"), HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
  71.  
  72.     MSG msg;
  73.  
  74.     while (TRUE)
  75.     {
  76.         ::SetWindowPos(hWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
  77.  
  78.         while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
  79.         {
  80.             TranslateMessage(&msg);
  81.  
  82.             DispatchMessage(&msg);
  83.         }
  84.  
  85.         if (msg.message == WM_QUIT)
  86.             break;
  87.  
  88.         render_frame();
  89.  
  90.         svrtCSGO hack; // Hack Object
  91.  
  92.         cout << "Waiting for CS:GO process..." << endl;
  93.  
  94.         while (!hack.isProcessRunning("csgo.exe"))
  95.         {
  96.             Sleep(500);
  97.         }
  98.  
  99.         system("cls");
  100.  
  101.         if (hack.silentState == 1)
  102.         {
  103.             //ShowWindow(FindWindowA("ConsoleWindowClass", NULL), false);
  104.         }
  105.  
  106.         hack.mem.Process("csgo.exe");
  107.  
  108.         PlaySound(TEXT("recycle.wav"), NULL, SND_FILENAME);
  109.  
  110.         // Run infinite loop for hacking actions
  111.         while (1)
  112.         {
  113.             if (!hack.isProcessRunning("csgo.exe"))
  114.             {
  115.                 exit(0);
  116.             }
  117.  
  118.             // Exit cheat on F11
  119.             if (GetKeyState(VK_F11) & 0x80)
  120.             {
  121.                 Sleep(300);
  122.                 PlaySound(TEXT("recycle.wav"), NULL, SND_FILENAME);
  123.  
  124.                 exit(0);
  125.             }
  126.  
  127.             Sleep(0);
  128.         }
  129.     }
  130.  
  131.     cleanD3D();
  132.  
  133.     return msg.wParam;
  134. }
  135.  
  136. LRESULT CALLBACK WindowProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
  137. {
  138.     switch (message)
  139.     {
  140.         case WM_DESTROY:
  141.         {
  142.             PostQuitMessage(0);
  143.             return 0;
  144.         } break;
  145.     }
  146.  
  147.     return DefWindowProc(hWnd, message, wParam, lParam);
  148. }
  149.  
  150. void initD3D(HWND hWnd)
  151. {
  152.     d3d = Direct3DCreate9(D3D_SDK_VERSION);
  153.  
  154.     D3DPRESENT_PARAMETERS d3dpp;
  155.  
  156.     ZeroMemory(&d3dpp, sizeof(d3dpp));
  157.     d3dpp.Windowed = TRUE;
  158.     d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
  159.     d3dpp.hDeviceWindow = hWnd;
  160.  
  161.     d3d->CreateDevice(D3DADAPTER_DEFAULT,
  162.         D3DDEVTYPE_HAL,
  163.         hWnd,
  164.         D3DCREATE_SOFTWARE_VERTEXPROCESSING,
  165.         &d3dpp,
  166.         &d3ddev
  167.     );
  168.  
  169.     D3DXCreateFont(d3ddev, 50, 0, FW_BOLD, 1, 0, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE, L"Arial", &pFont);
  170. }
  171.  
  172. void render_frame(void)
  173. {
  174.     d3ddev->Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_ARGB(0, 0, 0, 0), 1.0f, 0);
  175.  
  176.     d3ddev->BeginScene();
  177.  
  178.     DrawString(20, 20, D3DCOLOR_ARGB(158, 80, 210, 0), pFont, "Test");
  179.  
  180.     d3ddev->EndScene();
  181.  
  182.     d3ddev->Present(NULL, NULL, NULL, NULL);
  183. }
  184.  
  185. void cleanD3D(void)
  186. {
  187.     d3ddev->Release();
  188.     d3d->Release();
  189. }
  190.  
  191. void DrawString(int x, int y, DWORD color, LPD3DXFONT g_pFont, const char *fmt)
  192. {
  193.     RECT FontPos = { x, y, x + 120, y + 16 };
  194.     char buf[1024] = { '\0' };
  195.     va_list va_alist;
  196.  
  197.     va_start(va_alist, fmt);
  198.     vsprintf_s(buf, fmt, va_alist);
  199.     va_end(va_alist);
  200.     g_pFont->DrawText(NULL, L"TEST", -1, &FontPos, DT_NOCLIP, color);
  201. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement