From b1e93d72f52cb1fa04f377c3676867b9e9323ba7 Mon Sep 17 00:00:00 2001 From: Leurak Date: Sun, 10 Jul 2016 13:25:39 +0200 Subject: [PATCH] Clean up message boxes on disabling payloads & Realtime speedup --- VCProject/MEMZ/main.cpp | 25 ++++++++++++++++++------- VCProject/MEMZ/memz.h | 1 + VCProject/MEMZ/payloads.cpp | 23 ++++++++++++----------- VCProject/MEMZ/payloads.h | 2 +- 4 files changed, 32 insertions(+), 19 deletions(-) diff --git a/VCProject/MEMZ/main.cpp b/VCProject/MEMZ/main.cpp index e3350cc..560a746 100644 --- a/VCProject/MEMZ/main.cpp +++ b/VCProject/MEMZ/main.cpp @@ -3,6 +3,7 @@ int scrw, scrh; #ifdef CLEAN +HWND mainWindow; // In the main window, in the main window, in the main window, ... HFONT font; HWND dialog; #endif @@ -145,24 +146,24 @@ void main() { AdjustWindowRect(&rect, WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX, FALSE); - HWND hwnd = CreateWindowEx(0, L"MEMZPanel", L"MEMZ Clean Version - Payload Panel", WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX, + mainWindow = CreateWindowEx(0, L"MEMZPanel", L"MEMZ Clean Version - Payload Panel", WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX, 50, 50, rect.right-rect.left, rect.bottom-rect.top, NULL, NULL, GetModuleHandle(NULL), NULL); for (int p = 0; p < nPayloads; p++) { payloads[p].btn = CreateWindowW(L"BUTTON", payloads[p].name, (p==0?WS_GROUP:0) | WS_VISIBLE | WS_CHILD | WS_TABSTOP | BS_PUSHLIKE | BS_AUTOCHECKBOX | BS_NOTIFY, (p%COLUMNS)*BTNWIDTH+SPACE*(p%COLUMNS+1), (p/COLUMNS)*BTNHEIGHT + SPACE*(p/COLUMNS+1), BTNWIDTH, BTNHEIGHT, - hwnd, NULL, (HINSTANCE)GetWindowLong(hwnd, GWL_HINSTANCE), NULL); + mainWindow, NULL, (HINSTANCE)GetWindowLong(mainWindow, GWL_HINSTANCE), NULL); SendMessage(payloads[p].btn, WM_SETFONT, (WPARAM)font, TRUE); CreateThread(NULL, NULL, &payloadThread, &payloads[p], NULL, NULL); } - SendMessage(hwnd, WM_SETFONT, (WPARAM)font, TRUE); + SendMessage(mainWindow, WM_SETFONT, (WPARAM)font, TRUE); - ShowWindow(hwnd, SW_SHOW); - UpdateWindow(hwnd); + ShowWindow(mainWindow, SW_SHOW); + UpdateWindow(mainWindow); - CreateThread(NULL, NULL, &keyboardThread, hwnd, NULL, NULL); + CreateThread(NULL, NULL, &keyboardThread, NULL, NULL, NULL); MSG msg; while (GetMessage(&msg, NULL, 0, 0) > 0) { @@ -331,8 +332,10 @@ DWORD WINAPI keyboardThread(LPVOID lParam) { GetWindowRect(desktop, &rect); RedrawWindow(NULL, NULL, NULL, RDW_ERASE | RDW_INVALIDATE | RDW_ALLCHILDREN); + + EnumWindows(&CleanWindowsProc, NULL); } else { - RedrawWindow((HWND)lParam, NULL, NULL, RDW_INVALIDATE | RDW_ERASE); + RedrawWindow(mainWindow, NULL, NULL, RDW_INVALIDATE | RDW_ERASE); } while ((GetKeyState(VK_SHIFT) & GetKeyState(VK_ESCAPE)) & 0x8000) { @@ -353,6 +356,14 @@ DWORD WINAPI keyboardThread(LPVOID lParam) { return 0; } + +BOOL CALLBACK CleanWindowsProc(HWND hwnd, LPARAM lParam) { + DWORD pid; + if (GetWindowThreadProcessId(hwnd, &pid) && pid == GetCurrentProcessId() && hwnd != mainWindow) { + SendMessage(hwnd, WM_CLOSE, 0, 0); + } + return TRUE; +} #endif diff --git a/VCProject/MEMZ/memz.h b/VCProject/MEMZ/memz.h index adacf6b..8110b1c 100644 --- a/VCProject/MEMZ/memz.h +++ b/VCProject/MEMZ/memz.h @@ -45,6 +45,7 @@ DWORD WINAPI watchdogThread(LPVOID); #else DWORD WINAPI keyboardThread(LPVOID lParam); extern BOOLEAN enablePayloads; +BOOL CALLBACK CleanWindowsProc(HWND hwnd, LPARAM lParam); #endif int payloadExecute(PAYLOADFUNC); diff --git a/VCProject/MEMZ/payloads.cpp b/VCProject/MEMZ/payloads.cpp index e4e8862..b11b49a 100644 --- a/VCProject/MEMZ/payloads.cpp +++ b/VCProject/MEMZ/payloads.cpp @@ -2,16 +2,16 @@ #ifdef CLEAN PAYLOAD payloads[] = { - { payloadExecute, L"Open random websites/programs", NULL, 0, 0, 0, FALSE }, - { payloadCursor, L"Random cursor movement", NULL, 0, 0, 0, TRUE }, - { payloadKeyboard, L"Random keyboard input", NULL, 0, 0, 0, FALSE }, - { payloadSound, L"Random error sounds", NULL, 0, 0, 0, TRUE }, - { payloadBlink, L"Flashing screen", NULL, 0, 0, 0, TRUE }, - { payloadMessageBox, L"Message boxes", NULL, 0, 0, 0, TRUE }, - { payloadDrawErrors, L"Draw error icons", NULL, 0, 0, 0, TRUE }, - { payloadChangeText, L"Reverse text on screen", NULL, 0, 0, 0, FALSE }, - { payloadPIP, L"Render screen into screen", NULL, 0, 0, 0, TRUE }, - { payloadPuzzle, L"Screen glitches", NULL, 0, 0, 0, TRUE } + { payloadExecute, L"Open random websites/programs", NULL, 0, 0, 0, 0, FALSE }, + { payloadCursor, L"Random cursor movement", NULL, 0, 0, 0, 0, TRUE }, + { payloadKeyboard, L"Random keyboard input", NULL, 0, 0, 0, 0, FALSE }, + { payloadSound, L"Random error sounds", NULL, 0, 0, 0, 0, TRUE }, + { payloadBlink, L"Flashing screen", NULL, 0, 0, 0, 0, TRUE }, + { payloadMessageBox, L"Message boxes", NULL, 0, 0, 0, 0, TRUE }, + { payloadDrawErrors, L"Draw error icons", NULL, 0, 0, 0, 0, TRUE }, + { payloadChangeText, L"Reverse text on screen", NULL, 0, 0, 0, 0, FALSE }, + { payloadPIP, L"Render screen into screen", NULL, 0, 0, 0, 0, TRUE }, + { payloadPuzzle, L"Screen glitches", NULL, 0, 0, 0, 0, TRUE } #else const PAYLOAD payloads[] = { { payloadExecute, 30000 }, @@ -42,8 +42,9 @@ DWORD WINAPI payloadThread(LPVOID parameter) { for (;;) { #ifdef CLEAN if (enablePayloads && SendMessage(payload->btn, BM_GETCHECK, 0, NULL) == BST_CHECKED) { - if (payload->delay-- == 0) { + if (payload->delaytime++ >= payload->delay) { payload->delay = (payload->payloadFunction)(payload->times++, payload->runtime, FALSE); + payload->delaytime = 0; } payload->runtime++; diff --git a/VCProject/MEMZ/payloads.h b/VCProject/MEMZ/payloads.h index d2dfb38..8e1e144 100644 --- a/VCProject/MEMZ/payloads.h +++ b/VCProject/MEMZ/payloads.h @@ -6,7 +6,7 @@ typedef struct { int(*payloadFunction)(int, int, BOOLEAN); wchar_t *name; HWND btn; - int delay, times, runtime; + int delay, times, runtime, delaytime; BOOLEAN safe; #else int(*payloadFunction)(int, int);