禁用Ctrl+Alt+Del最有效的方法

禁用Ctrl+Alt+Del最有效的方法

Ctrl+Alt+Del可以打开任务管理器(Ctrl+Shift+Esc也可以)。如何禁用这个热键,网上有很多方法:

  1. 通过注册表禁用,网上大多数用此方法,打开任务管理器就会提示被禁用;
  2. 监视窗口或进程,一发现就Kill掉;
  3. 键盘Hook(任务管理器出来后,才能检测到组合键;其实没用…);
  4. Open Environ$(“WinDir”)&"\system32\taskmgr.exe" ForBinary As #1(占用了文件,自然打不开)
  5. Ctrl+Alt+Del由winlogon管的,直接杀死winlogon!(XP系统蓝屏…)
  6. 在Win7/Win10下winlogon杀死后不会蓝屏,Ctrl+Alt+Del也可以成功屏蔽,不过桌面会空空如也(Explorer死了?!)
    以上的方法,在实际操作中,都是不能用的!下面介绍一个确实有用的方法:
    在WIN7/WIN10环境下,采用挂起winlogon.exe的方法,实际测试确实可行!操作步骤如下:
    Step1:进程提权(不然OpenProcess返回0);
    SetPrivilege();
    Step2:OpenProcess,
    LoadNtDllFun();
    Step3:挂起NtSuspendProcess,要恢复就用NtResumeProcess。
    SuspendProcess();
    Step4:退出恢复系统,NtResumeProcess。
    ResumeProcess();
    UnloadNtDllFun();

一。进程提权,代码如下:

int SetPrivilege(void)//进程提权
{
	HANDLE token_handle;
	//打开访问令牌
	if (!OpenProcessToken(GetCurrentProcess(),       //要修改权限的进程句柄
		TOKEN_ALL_ACCESS,          //要对令牌进行何种操作
		&token_handle              //访问令牌
	))
	{
		printf("openProcessToken error");
		return -1;
	}

	LUID luid;
	if (!LookupPrivilegeValue(NULL,                 //查看的系统,本地为NULL
		SE_DEBUG_NAME,        //要查看的特权名称
		&luid                 //用来接收标识符
	))
	{
		printf("lookupPrivilegevalue error");
		return -2;
	}

	TOKEN_PRIVILEGES tkp;
	tkp.PrivilegeCount = 1;
	tkp.Privileges[0].Luid = luid;
	tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
	//调整访问令牌权限
	if (!AdjustTokenPrivileges(token_handle,    //令牌句柄
		FALSE,           //是否禁用权限
		&tkp,            //新的特权的权限信息
		sizeof(tkp),     //特权信息大小
		NULL,            //用来接收特权信息当前状态的buffer
		NULL             //缓冲区大小
	))
	{
		printf("adjust error");
		return -3;
	}

	printf("sucessful");
	return 0;
}

二。 OpenProcess 获取winlogon.exe的句柄的代码如下:

`#include <windows.h>
#include <Psapi.h>
#include <iostream>
#include <tchar.h>
using std::cout;
using std::endl;\
const LPCTSTR lpszProcessName = _T("winlogon.exe");
HANDLE hDesProcess = NULL;
//根据进程的名字(image name)来查找该进程是否是打开的
bool FindProcess(LPCTSTR lpszProcessName)
{
	DWORD dwProcessIdentify[MAX_PATH] = { 0 };
	DWORD dwTrueBytes = 0;
	HANDLE hProcess = NULL;
	if (!EnumProcesses(dwProcessIdentify, MAX_PATH * sizeof(DWORD), &dwTrueBytes))
	{
		cout << "enum process fail " << endl;
		return false;
	}
	int nProcessNum = dwTrueBytes / sizeof(DWORD);
	HMODULE hModuleInProcess[MAX_PATH] = { 0 };
	DWORD dwModuleBytes = 0;
	TCHAR moduleBaseName[MAX_PATH] = { 0 };
	for (int nIndex = 0; nIndex < nProcessNum; ++nIndex)
	{
		hProcess = OpenProcess(PROCESS_ALL_ACCESS, false, dwProcessIdentify[nIndex]);
		memset(moduleBaseName, 0, MAX_PATH * sizeof(TCHAR));
		//for ( int nModuleIndex = 0; nModuleIndex < nModulesNumInProcess; ++nModuleIndex )
		{
			GetModuleBaseName(hProcess, NULL, moduleBaseName, MAX_PATH);
			if (!_tcscmp(moduleBaseName, lpszProcessName))
			{
				cout << "查找的进程存在" << endl;
				hDesProcess = hProcess;
				return true;
			}
		}
	}
	return false;
}

三。 加载ntdll.dll,获取系统函数NtSuspendProcess,挂起/恢复winlogon.exe的代码如下:

```handlebars
DWORD(WINAPI* NtResumeProcess_p)(HANDLE hProcess);//暂停
DWORD(WINAPI* NtSuspendProcess_p)(HANDLE hProcess);//恢复
HMODULE dllhandle=NULL;
 
void LoadNtDllFun()
{
	dllhandle = LoadLibrary(_T("ntdll.dll"));
	if (dllhandle != 0)
	{
		NtResumeProcess_p = (DWORD(__stdcall*)(HANDLE))GetProcAddress(dllhandle, "NtResumeProcess");
		NtSuspendProcess_p = (DWORD(__stdcall*)(HANDLE))GetProcAddress(dllhandle, "NtSuspendProcess");
	}
	else {
		NtSuspendProcess_p = NULL;
		NtResumeProcess_p = NULL;
	}

	//CloseHandle(dllhandle);
}
void UnloadNtDllFun()
{
	if (dllhandle != NULL) {
		FreeLibrary(dllhandle);
		dllhandle = NULL;
		NtSuspendProcess_p = NULL;
		NtResumeProcess_p = NULL;
	}
}
int SuspendProcess()
{
	if (!FindProcess(lpszProcessName))
	{
		cout << "进程不存在" << endl;
		return -1;
	}
	if (NtSuspendProcess_p == NULL)
		return -2;

	//挂起目标进程
	UINT unExitCode = 0;
	if (hDesProcess == NULL)
		return -3;
	{
		BOOL bRet = NtSuspendProcess_p(hDesProcess);
		if (!bRet)
		{
			DWORD dwErrorCode = GetLastError();
			cout << "进程挂起失败" << endl;
			return -10;
		}
	}
	return 0;
}
int ResumeProcess()
{
	if (!FindProcess(lpszProcessName))
	{
		cout << "进程不存在" << endl;
		return -1;
	}
	if (NtResumeProcess_p == NULL)
		return -2;

	//挂起目标进程
	UINT unExitCode = 0;
	if (hDesProcess == NULL)
		return -3;
	{
		BOOL bRet = NtResumeProcess_p(hDesProcess);
		if (!bRet)
		{
			DWORD dwErrorCode = GetLastError();
			cout << "进程恢复失败" << endl;
			return -10;
		}
	}
	return 0;
}
这些代码在VS2019 , Win10-64bit系统下编译测试通过。

后续问题: 按了Ctrl+Alt+Del组合键只是暂时不触发,winlogo恢复后,还会继续触发。如果你的APP的寿命和系统一样,这就不是问题了!

  • 1
    点赞
  • 17
    收藏
    觉得还不错? 一键收藏
  • 10
    评论
在Python中,你可以使用pandas库的read_excel()函数来导入.xlsx文件。以下是几种常见的导入xlsx文件的方法方法一:使用绝对路径导入xlsx文件 ```python import pandas as pd df = pd.read_excel(r'G:\test.xlsx') print(df) ``` 这种方法中,你需要提供xlsx文件的绝对路径。 方法二:使用相对路径导入xlsx文件 ```python import pandas as pd df = pd.read_excel('example.xlsx') print(df.head()) ``` 这种方法中,你只需要提供xlsx文件的相对路径即可。 方法三:导入部分行数据 如果你的文件很大,你可能只需要导入前几行进行分析。你可以使用nrows参数来指定导入的行数。例如,以下代码将只导入xlsx文件的前两行数据: ```python import pandas as pd df = pd.read_excel(r'G:\test.xlsx', sheet_name=0, nrows=2) print(df) ``` 在这个例子中,我们使用了sheet_name参数来指定要导入的工作表,nrows参数来指定要导入的行数。 希望这些方法能够帮助到你! #### 引用[.reference_title] - *1* *3* [Python使用pandas导入xlsx格式的excel文件内容](https://blog.csdn.net/hubing_hust/article/details/128412197)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control_2,239^v3^insert_chatgpt"}} ] [.reference_item] - *2* [用python导入excel表格](https://blog.csdn.net/weixin_35755434/article/details/129068182)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control_2,239^v3^insert_chatgpt"}} ] [.reference_item] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 10
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值