Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <windows.h>
- #include <iostream>
- #include <conio.h>
- #include "tlhelp32.h"
- #include <tchar.h>
- DWORD GetProcId( char *szProcName )
- {
- PROCESSENTRY32 pe32;
- HANDLE hSnapshot = NULL;
- pe32.dwSize = sizeof( PROCESSENTRY32 );
- hSnapshot = CreateToolhelp32Snapshot( TH32CS_SNAPPROCESS, 0 );
- if( Process32First( hSnapshot, &pe32 ) )
- {
- do{
- if( strcmp( pe32.szExeFile, szProcName ) == 0 )
- break;
- }while( Process32Next( hSnapshot, &pe32 ) );
- }
- if( hSnapshot != INVALID_HANDLE_VALUE )
- CloseHandle( hSnapshot );
- return (strcmp( pe32.szExeFile, szProcName ) == 0) ? pe32.th32ProcessID : 0;
- }
- BYTE* GetModuleBase( DWORD dwProcId, char *szModuleName )
- {
- MODULEENTRY32 me32;
- HANDLE hSnapshot = NULL;
- me32.dwSize = sizeof(MODULEENTRY32);
- hSnapshot = CreateToolhelp32Snapshot( TH32CS_SNAPMODULE, dwProcId );
- if( Module32First( hSnapshot, &me32 ) )
- {
- do{
- if( strcmp( me32.szModule, szModuleName ) == 0 )
- break;
- }while( Module32Next( hSnapshot, &me32 ) );
- }
- if( hSnapshot != INVALID_HANDLE_VALUE )
- CloseHandle( hSnapshot );
- return (strcmp( me32.szModule, szModuleName ) == 0) ? me32.modBaseAddr : 0;
- }
- int main()
- {
- system("@echo off");
- system("title LS Crasher");
- system("@TASKKILL /F /IM Student.exe");
- system("cls");
- system("color 0F");
- printf("LanSchool Student Crasher\n");
- printf("-------------------------\n\n");
- printf("Closing all instances of Student.exe...\n");
- printf("Finding Student.exe process id...\n");
- bool found = false;
- HWND AllWindows = ::GetTopWindow(0);
- while (AllWindows)
- {
- DWORD pid;
- DWORD dwTheardId = ::GetWindowThreadProcessId(AllWindows, &pid);
- if (pid == GetProcId("Student.exe"))
- {
- printf("Looking for Student.exe windows...\n");
- // printf("STUDENT PID:%d HWND: %d\n", pid, h);
- // DestroyWindow(h);
- printf("Sending crash message...\n\n");
- PostMessage(AllWindows, WM_QUIT, 0,0);
- SendMessage(AllWindows, WM_QUIT, 0, 0);
- // SendMessageTimeout(h, WM_QUIT, 0, 0, SMTO_ABORTIFHUNG, 3000, 0);
- // SendMessageTimeout(h, WM_QUIT, 0, 0, SMTO_BLOCK, 3000, 0);
- // SendMessageTimeout(h, WM_QUIT, 0, 0, SMTO_NORMAL, 3000, 0);
- // SendMessageTimeout(h, WM_QUIT, 0, 0, SMTO_NOTIMEOUTIFNOTHUNG, 3000, 0);
- // SendMessageTimeout(h, WM_QUIT, 0, 0, SMTO_ERRORONEXIT, 3000, 0);
- // printf("Finished");
- found = true;
- }
- AllWindows = ::GetNextWindow(AllWindows, GW_HWNDNEXT);
- }
- if (!found) {
- printf("LanSchool Student does not seem to be running on this computer!");
- } else {
- printf("LanSchool Student has been crashed, you are not monitored anymore!");
- }
- // printf( "%x\n", GetModuleBase(GetProcId("winmine.exe"), "kernel32.dll"));
- _getch();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement