Advertisement
Guest User

Untitled

a guest
May 12th, 2011
578
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.84 KB | None | 0 0
  1. #include <windows.h>
  2. #include <iostream>
  3. #include <conio.h>
  4. #include "tlhelp32.h"
  5. #include <tchar.h>
  6.  
  7. DWORD GetProcId( char *szProcName )
  8. {
  9.    PROCESSENTRY32   pe32;
  10.    HANDLE         hSnapshot = NULL;
  11.  
  12.    pe32.dwSize = sizeof( PROCESSENTRY32 );
  13.    hSnapshot = CreateToolhelp32Snapshot( TH32CS_SNAPPROCESS, 0 );
  14.  
  15.    if( Process32First( hSnapshot, &pe32 ) )
  16.    {
  17.       do{
  18.          if( strcmp( pe32.szExeFile, szProcName ) == 0 )
  19.             break;
  20.       }while( Process32Next( hSnapshot, &pe32 ) );
  21.    }
  22.  
  23.    if( hSnapshot != INVALID_HANDLE_VALUE )
  24.       CloseHandle( hSnapshot );
  25.  
  26.    return (strcmp( pe32.szExeFile, szProcName ) == 0) ? pe32.th32ProcessID : 0;
  27. }
  28.  
  29. BYTE* GetModuleBase( DWORD dwProcId, char *szModuleName )
  30. {
  31.    MODULEENTRY32 me32;
  32.    HANDLE hSnapshot = NULL;
  33.  
  34.  
  35.  
  36.    me32.dwSize = sizeof(MODULEENTRY32);
  37.    hSnapshot = CreateToolhelp32Snapshot( TH32CS_SNAPMODULE, dwProcId );
  38.  
  39.    if( Module32First( hSnapshot, &me32 ) )
  40.    {
  41.       do{
  42.          if( strcmp( me32.szModule, szModuleName ) == 0 )
  43.             break;
  44.       }while( Module32Next( hSnapshot, &me32 ) );
  45.    }
  46.  
  47.    if( hSnapshot != INVALID_HANDLE_VALUE )
  48.       CloseHandle( hSnapshot );
  49.  
  50.    return (strcmp( me32.szModule, szModuleName ) == 0) ? me32.modBaseAddr : 0;
  51. }
  52.  
  53.  
  54.  
  55. int main()
  56. {
  57.     system("@echo off");
  58.     system("title LS Crasher");
  59.     system("@TASKKILL /F /IM Student.exe");
  60.     system("cls");
  61.     system("color 0F");
  62.  
  63.     printf("LanSchool Student Crasher\n");
  64.     printf("-------------------------\n\n");
  65.    
  66.     printf("Closing all instances of Student.exe...\n");
  67.    
  68.     printf("Finding Student.exe process id...\n");
  69.  
  70.     bool found = false;
  71.  
  72.     HWND AllWindows = ::GetTopWindow(0);
  73.  
  74.     while (AllWindows)
  75.     {
  76.         DWORD pid;
  77.         DWORD dwTheardId = ::GetWindowThreadProcessId(AllWindows, &pid);
  78.  
  79.         if (pid == GetProcId("Student.exe"))
  80.         {
  81.             printf("Looking for Student.exe windows...\n");
  82.            
  83.             // printf("STUDENT PID:%d HWND: %d\n", pid, h);
  84.             // DestroyWindow(h);
  85.  
  86.             printf("Sending crash message...\n\n");
  87.  
  88.             PostMessage(AllWindows, WM_QUIT, 0,0);
  89.             SendMessage(AllWindows, WM_QUIT, 0, 0);
  90.  
  91.             // SendMessageTimeout(h, WM_QUIT, 0, 0, SMTO_ABORTIFHUNG, 3000, 0);
  92.             // SendMessageTimeout(h, WM_QUIT, 0, 0, SMTO_BLOCK, 3000, 0);
  93.             // SendMessageTimeout(h, WM_QUIT, 0, 0, SMTO_NORMAL, 3000, 0);
  94.             // SendMessageTimeout(h, WM_QUIT, 0, 0, SMTO_NOTIMEOUTIFNOTHUNG, 3000, 0);
  95.             // SendMessageTimeout(h, WM_QUIT, 0, 0, SMTO_ERRORONEXIT, 3000, 0);
  96.             // printf("Finished");
  97.             found = true;
  98.            
  99.         }
  100.  
  101.  
  102.          AllWindows = ::GetNextWindow(AllWindows, GW_HWNDNEXT);
  103.     }
  104.  
  105.     if (!found) {
  106.         printf("LanSchool Student does not seem to be running on this computer!");
  107.     } else {
  108.    
  109.     printf("LanSchool Student has been crashed, you are not monitored anymore!");
  110.     }
  111.     // printf( "%x\n", GetModuleBase(GetProcId("winmine.exe"), "kernel32.dll"));
  112.     _getch();
  113. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement