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

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

通过注册表禁用,网上大多数用此方法,打开任务管理器就会提示被禁用;监视窗口或进程,一发现就Kill掉;键盘Hook(任务管理器出来后,才能检测到组合键;其实没用…);Open Environ$(“WinDir”)&"\system32\taskmgr.exe" ForBinary As #1(占用了文件,自然打不开)Ctrl+Alt+Del由winlogon管的,直接杀死winlogon!(XP系统蓝屏…)在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

#include

#include

#include

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的寿命和系统一样,这就不是问题了!