Pushok

WinAPI Flooder

Mar 25th, 2011
529
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.69 KB | None | 0 0
  1. #include <windows.h>
  2.  
  3. LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
  4.  
  5. VOID CALLBACK FloodTimer( HWND window, UINT Msg, UINT_PTR EventID, DWORD SYSTime);
  6. HWND MenuItems[4];
  7.  
  8. int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance,
  9.     LPSTR lpCmdLine, int nCmdShow )
  10. {
  11.     MSG  msg ;    
  12.     WNDCLASS wc;
  13.     ZeroMemory(&wc, sizeof(wc));
  14.  
  15.     wc.lpszClassName = TEXT( "Flooder" );
  16.     wc.hInstance     = hInstance ;
  17.     wc.hbrBackground = GetSysColorBrush(COLOR_3DFACE);
  18.     wc.lpfnWndProc   = WndProc ;
  19.     wc.hCursor       = LoadCursor(0, IDC_ARROW);
  20.  
  21.  
  22.     RegisterClass(&wc);
  23.     CreateWindow( wc.lpszClassName, TEXT("Flooder"),
  24.         WS_SYSMENU | WS_VISIBLE,
  25.         150, 150, 230, 150, 0, 0, hInstance, 0);  
  26.  
  27.     while( GetMessage(&msg, NULL, 0, 0)) {
  28.         TranslateMessage(&msg);
  29.         DispatchMessage(&msg);
  30.     }
  31.     return (int) msg.wParam;
  32. }
  33.  
  34. LRESULT CALLBACK WndProc( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam )
  35. {
  36.  
  37.  
  38.     switch(msg)  
  39.     {
  40.     case WM_CREATE:
  41.         {
  42.             MenuItems[0] = CreateWindow(TEXT("edit"), TEXT("Текст..."),    
  43.                 WS_VISIBLE | WS_CHILD | WS_BORDER,
  44.                 0, 0, 225, 25,        
  45.                 hwnd, (HMENU) 1, NULL, NULL);    
  46.  
  47.             MenuItems[1] = CreateWindow(TEXT("button"), TEXT("Флудить!"),    
  48.                 WS_VISIBLE | WS_CHILD ,
  49.                 120, 50, 80, 25,        
  50.                 hwnd, (HMENU) 2, NULL, NULL);  
  51.  
  52.             MenuItems[2] = CreateWindow(TEXT("edit"), TEXT("100"),
  53.                 WS_VISIBLE | WS_CHILD | WS_BORDER,
  54.                 25, 50, 80, 25,
  55.                 hwnd, (HMENU) 3, NULL, NULL);
  56.  
  57.             MenuItems[3] = CreateWindow(TEXT("button"), TEXT("Стоп"),    
  58.                 WS_VISIBLE | WS_CHILD ,
  59.                 120, 75, 80, 25,        
  60.                 hwnd, (HMENU) 4, NULL, NULL);
  61.             break;
  62.         }
  63.  
  64.     case WM_COMMAND:
  65.         {
  66.             if(HIWORD(wParam) == BN_CLICKED){
  67.                 if (LOWORD(wParam) == 2) {
  68.                     KillTimer(hwnd, 1);
  69.                     TCHAR speed[16];
  70.                     GetWindowText(MenuItems[2], speed, sizeof(speed));
  71.                     SetTimer(hwnd, 1, _wtoi(speed), FloodTimer);
  72.                 } else if(LOWORD(wParam) == 4)
  73.                 {
  74.                     KillTimer(hwnd, 1);
  75.                 }
  76.             }
  77.             break;
  78.         }
  79.     case WM_DESTROY:
  80.         {
  81.             KillTimer(hwnd, 1);
  82.             PostQuitMessage(0);
  83.             break;
  84.         }
  85.     }
  86.     return DefWindowProc(hwnd, msg, wParam, lParam);
  87. }
  88.  
  89. VOID CALLBACK FloodTimer( HWND window, UINT Msg, UINT_PTR EventID, DWORD SYSTime)
  90. {
  91.     TCHAR* buff = (TCHAR*)calloc(1024, sizeof(TCHAR));
  92.     GetWindowText(MenuItems[0], buff, 1024);
  93.  
  94.     KEYBDINPUT KbInput;
  95.     ZeroMemory(&KbInput, sizeof(KEYBDINPUT));
  96.     INPUT Input;
  97.     ZeroMemory(&Input, sizeof(INPUT));
  98.     TCHAR* ch = buff;
  99.  
  100.     while(*ch)
  101.     {
  102.         KbInput.wScan = *ch;
  103.         KbInput.dwFlags = KEYEVENTF_UNICODE;
  104.         Input.type = INPUT_KEYBOARD;
  105.         Input.ki = KbInput;
  106.         SendInput(1,&Input,sizeof(Input));
  107.  
  108.         KbInput.wScan = *(ch++);
  109.         KbInput.dwFlags = KEYEVENTF_UNICODE | KEYEVENTF_KEYUP;
  110.         Input.type = INPUT_KEYBOARD;
  111.         Input.ki = KbInput;
  112.         SendInput(1,&Input,sizeof(Input));
  113.     }
  114.  
  115.     keybd_event(VK_RETURN, NULL, KEYEVENTF_EXTENDEDKEY, NULL);
  116.     keybd_event(VK_RETURN, NULL, KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, NULL);
  117.  
  118.     free(buff);
  119. }
Advertisement
Add Comment
Please, Sign In to add comment