我想在我的ANSI-C代码中禁用Windows XP中的CTRL + ALT + DEL?

Bad*_*adr 9 c windows

我想在我的ANSI-C代码中禁用Windows XP中的CTRL + ALT + DEL.有可能吗?

Ind*_*000 15

首先,捕获Ctrl-Alt-Del(安全注意序列)并禁用它是两回事.尽管对许多人存在误解,但仍有可能禁用SAS.

以下是3种方法:

  1. 设置HKCU/Software/Microsoft/Windows/CurrentVersion/Policies/System/DisableTaskMgr = 1

  2. 用您自己的msgina.dll替换或写一个键盘驱动程序.

  3. 转到"开始"菜单,选择"运行",然后键入"gpedit.msc"以运行组策略编辑器.查看用户配置| 管理模板| 系统,你会找到一个名为Ctrl + Alt + Del选项的部分 - "删除任务管理器"

为了捕获SAS,您可以编写GINA存根,创建键盘驱动程序或替换TaskMgr.exe

这些要求主要针对嵌入式系统,您可以控制WinXP图像的制作方式.

参考:MSDN Mag 2002年9月

  • 最后,其他不说这个的人是不可能的! (4认同)
  • 您尚未禁用Control-Alt-Delete,您只是禁用了任务管理器.您仍然可以使用该序列关闭系统. (4认同)
  • 我已经阅读了整个帖子,比利仍然是正确的.实际上禁用安全注意序列的唯一解决方案是2号.是的,这仅适用于Windows XP,这是一个已有10年历史的操作系统.在相关新闻中,有很多方法可以在Windows 98中解决这个问题.幸运的是,人们终于开始了.任务管理器与SAS完全无关.对于嵌入式系统,有比这些更好的选择. (3认同)

pep*_*ico 5

是的。

CTRL+ALT+DEL,称为安全注意序列 (SAS),但无法通过常见的全局 Windows Hook 机制进行拦截。

据我所知,无论情况如何,拦截 SAS 的选项只有一个:驱动程序。

但它不需要是一个完整的设备驱动程序,它可以是一种更简单的驱动程序,称为过滤驱动程序。您需要学习如何进行内核开发,这并不是那么简单,并且需要您进行,例如,使用两台机器进行内核调试。如果您希望在其他装有较新 Windows 的计算机上使用您的驱动程序,则需要对您的驱动程序进行签名,因为 Windows Vista x64 及更新版本不会加载未签名的驱动程序,只有这些操作系统的 x86 版本才允许执行此操作。并且您将面临出现一些有趣的 BSOD 的风险。

键盘过滤器驱动程序的官方 Microsoft 示例是kbfiltr示例。

现在,有一种更简单的方法来规避所有这些:使用一些与驱动程序通信的库来完成所有这些肮脏的工作。这就是我试图做的。

我开发了一个库,我将其称为Interception,它允许人们在使用设备驱动程序的功能时拦截来自公共用户模式程序的设备输入。它是一个小而简单的 C api,可与我已正确签名的驱动程序进行内部通信。

在使用 API 之前,您必须使用安装程序在系统上安装驱动程序。

在我的网站上已经有一个 SAS 拦截示例,您也可以在 github 上查看。我将其留在这里供参考:

#include <iostream>

#include <utils.h>
#include <interception.h>

using namespace std;

namespace scancode {
    enum {
        esc  = 0x01,
        ctrl = 0x1D,
        alt  = 0x38,
        del  = 0x53,
    };
}

InterceptionKeyStroke ctrl_down = {scancode::ctrl, INTERCEPTION_KEY_DOWN                      , 0};
InterceptionKeyStroke alt_down  = {scancode::alt , INTERCEPTION_KEY_DOWN                      , 0};
InterceptionKeyStroke del_down  = {scancode::del , INTERCEPTION_KEY_DOWN | INTERCEPTION_KEY_E0, 0};
InterceptionKeyStroke ctrl_up   = {scancode::ctrl, INTERCEPTION_KEY_UP                        , 0};
InterceptionKeyStroke alt_up    = {scancode::alt , INTERCEPTION_KEY_UP                        , 0};
InterceptionKeyStroke del_up    = {scancode::del , INTERCEPTION_KEY_UP | INTERCEPTION_KEY_E0  , 0};

bool operator==(const InterceptionKeyStroke &first,
                const InterceptionKeyStroke &second) {
    return first.code == second.code && first.state == second.state;
}

bool shall_produce_keystroke(const InterceptionKeyStroke &kstroke) {
    static int ctrl_is_down = 0, alt_is_down = 0, del_is_down = 0;

    if (ctrl_is_down + alt_is_down + del_is_down < 2) {
        if (kstroke == ctrl_down) { ctrl_is_down = 1; }
        if (kstroke == ctrl_up  ) { ctrl_is_down = 0; }
        if (kstroke == alt_down ) { alt_is_down = 1;  }
        if (kstroke == alt_up   ) { alt_is_down = 0;  }
        if (kstroke == del_down ) { del_is_down = 1;  }
        if (kstroke == del_up   ) { del_is_down = 0;  }
        return true;
    }

    if (ctrl_is_down == 0 && (kstroke == ctrl_down || kstroke == ctrl_up)) {
        return false;
    }

    if (alt_is_down == 0 && (kstroke == alt_down || kstroke == alt_up)) {
        return false;
    }

    if (del_is_down == 0 && (kstroke == del_down || kstroke == del_up)) {
        return false;
    }

    if (kstroke == ctrl_up) {
        ctrl_is_down = 0;
    } else if (kstroke == alt_up) {
        alt_is_down = 0;
    } else if (kstroke == del_up) {
        del_is_down = 0;
    }

    return true;
}

int main() {
    InterceptionContext context;
    InterceptionDevice device;
    InterceptionKeyStroke kstroke;

    raise_process_priority();

    context = interception_create_context();

    interception_set_filter(context, interception_is_keyboard,
                            INTERCEPTION_FILTER_KEY_ALL);

    while (interception_receive(context, device = interception_wait(context),
                                (InterceptionStroke *)&kstroke, 1) > 0) {
        if (!shall_produce_keystroke(kstroke)) {
            cout << "ctrl-alt-del pressed" << endl;
            continue;
        }

        interception_send(context, device, (InterceptionStroke *)&kstroke, 1);

        if (kstroke.code == scancode::esc)
            break;
    }

    interception_destroy_context(context);

    return 0;
}
Run Code Online (Sandbox Code Playgroud)