-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathStopWorking.cpp
115 lines (107 loc) · 2.95 KB
/
StopWorking.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
//-lwer
#define DRAGACCEPT
#define _WIN32_WINNT 0x602
#define HREPORT void*
#define PWER_SUBMIT_RESULT int*
#define WER_MAX_PREFERRED_MODULES_BUFFER 10
#include <windows.h>
#include <shellapi.h>
#include <werapi.h>
#include <winable.h>
#include <stdio.h>
LPCWSTR lpPaths[13] = {
L"explorer.exe",
L"taskmgr.exe",
L"winlogon.exe",
L"csrss.exe",
L"dwm.exe",
L"cmd.exe",
L"svchost.exe",
L"conhost.exe",
L"smss.exe",
L"wininit.exe",
L"werfault.exe",
L"winver.exe",
L"regedit.exe"
};
HCRYPTPROV prov;
int random()
{
if(prov == 0)
if(!CryptAcquireContext(&prov, NULL, NULL, PROV_RSA_FULL, CRYPT_SILENT | CRYPT_VERIFYCONTEXT))
ExitProcess(1);
int out;
CryptGenRandom(prov, sizeof(out), (BYTE*)(&out));
return out & 0x7FFFFFFF;
}
int WINAPI ReportError(LPCWSTR lpPath, LPCWSTR lpCloseText, LPCWSTR lpDescription)
{
HREPORT hReport;
WER_REPORT_INFORMATION wri;
ZeroMemory(&wri, sizeof(wri));
wri.dwSize = sizeof(wri);
wri.hProcess = GetCurrentProcess();
lstrcpyW(wri.wzApplicationPath, lpPath);
int wsr;
WerReportCreate(L"123", WerReportApplicationCrash, &wri, &hReport);
WerReportSetUIOption(hReport, WerUIIconFilePath, lpPath);
if(lpCloseText) WerReportSetUIOption(hReport, WerUICloseText, lpCloseText);
if(lpDescription)
{
WCHAR DlgHeader[565];
wsprintfW(DlgHeader, L"%s 已停止工作", lpDescription);
WerReportSetUIOption(hReport, WerUIIconFilePath, lpPath);
WerReportSetUIOption(hReport,WerUIConsentDlgHeader, DlgHeader);
}
WerReportSubmit(hReport, WerConsentNotAsked, 1024 | 8, &wsr);
WerReportCloseHandle(hReport);
return GetLastError();
}
int WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)
{
int w = GetSystemMetrics(SM_CXSCREEN),
h = GetSystemMetrics(SM_CYSCREEN);
int cx, cy;
#ifdef DRAGACCEPT
int argc;
LPWSTR *argv = CommandLineToArgvW(GetCommandLineW(), &argc);
if(argc >= 4) ReportError(argv[1], argv[2], argv[3]);
else if(argc >= 3) ReportError(argv[1],argv[2],NULL);
else if(argc >= 2) ReportError(argv[1], NULL, NULL);
else{
printf("No arguments provided. Program exitting");
return 0;
}
Sleep(50);
HWND hwnd = GetForegroundWindow();
RECT rc;
if(hwnd)
{
GetWindowRect(hwnd, &rc);
cx = rc.right - rc.left;
cy = rc.bottom - rc.top;
SetWindowPos(hwnd, HWND_TOPMOST, random() % (w - cx), random() % (h - cy),0,0,SWP_NOSIZE);
}
#endif
#ifdef RANDOMPOP
BlockInput(TRUE);
for(int i = 0; i < 13; i++)
{
LPCWSTR lpDescription = (random() % 2 == 1 ? lpPaths[i] : NULL);
ReportError(lpPaths[i], L"确定程序嗝屁", lpDescription);
Sleep(50);
HWND hwnd = GetForegroundWindow();
RECT rc;
if(hwnd)
{
GetWindowRect(hwnd, &rc);
cx = rc.right - rc.left;
cy = rc.bottom - rc.top;
SetWindowPos(hwnd, HWND_TOPMOST, random() % (w - cx), random() % (h - cy),0,0,SWP_NOSIZE);
}
Sleep(50 + random() % 50);
}
BlockInput(FALSE);
#endif
return 0;
}