yangbo50304 2015-10-20 00:48 采纳率: 100%
浏览 3736
已采纳

Win7下如何屏蔽ctrl+alt+del键?

hook什么的已经失效了,而且将winlogon.exe挂起的方法有问题(挂起中按下ctrl+alt+del,再恢复时弹出了界面),请问还有别的方法没?不要汇编的,只要vc的

  • 写回答

5条回答 默认 最新

  • jok_219 2015-10-23 00:57
    关注

    win7下,登录页面是无法通过hook屏蔽的,因为系统登录页面会优先获取到组合键。我之前用过一个方法可以屏蔽ALT+CTRL+DEL,就是注入方式锁定登录页面管理进程**winlogon**,但是如果按了组合键只是暂时不触发,锁定解除后,还会继续触发。在某些情况下,还会造成卡登陆页面。所以我建议你通过注入方式锁定explorer进程,会好一点。进程锁定代码如下

     public static class ProcessFrozenController
        {
            private const int THREADACCESS_SUSPEND_RESUME = 0x0002;
    
            [DllImport("kernel32.dll", SetLastError = true)]
            private static extern IntPtr OpenThread(uint dwDesiredAccess, bool bInheritHandle, uint threadId);
    
            [DllImport("kernel32.dll", SetLastError = true)]
            private static extern int SuspendThread(IntPtr hThread);
    
            [DllImport("kernel32.dll", SetLastError = true)]
            private static extern int ResumeThread(IntPtr hThread);
    
            [DllImport("kernel32.dll")]
            private static extern uint GetLastError();
    
            [DllImport("kernel32.dll", CharSet = CharSet.Auto)]
            private static extern bool CloseHandle(IntPtr hobject);
    
            public static bool FreezeProcess(string processName, ref string msg)
            {
                Process[] processArray = Process.GetProcesses();
                Process operateProcess = null;
    
                foreach (Process p in processArray)
                {
                    if (p.ProcessName.ToLower().Trim() != processName) continue;
    
                    operateProcess = p;
                    break;
                }
    
                if (operateProcess == null)
                {
                    msg = "未找到进程";
                    return false;
                }
    
                List<ProcessThread> handledList = new List<ProcessThread>();
                foreach (ProcessThread pthd in operateProcess.Threads)
                {
                    if (SuspendProcessThread(pthd))
                    {
                        handledList.Add(pthd);
                        continue;
                    }
    
                    foreach (ProcessThread hpthd in handledList)
                    {
                        ResumeProcessThread(hpthd);
                    }
    
                    msg = "冻结进程失败";
                    return false;
                }
                operateProcess.Dispose();
    
                return true;
            }
    
            public static void UnfreezeProcess(string processName)
            {
                Process[] processArray = Process.GetProcesses();
                Process operateProcess = null;
    
                foreach (Process p in processArray)
                {
                    if (p.ProcessName.ToLower().Trim() != processName) continue;
    
                    operateProcess = p;
                    break;
                }
    
                if (operateProcess == null)
                {
                    return;
                }
    
                foreach (ProcessThread thd in operateProcess.Threads)
                {
                    ResumeProcessThread(thd);
                }
                operateProcess.Dispose();
            }
    
            #region 私有函数
    
            private static bool SuspendProcessThread(ProcessThread thread)
            {
                IntPtr threadHandle = OpenThread(THREADACCESS_SUSPEND_RESUME, false, (uint)thread.Id); // Open thread with required permissions
                if (threadHandle == IntPtr.Zero) // If thread pointer is zero, means that the 'OpenThread' function has failed
                {
                    return false;
                }
                if (SuspendThread(threadHandle) == -1) // If the result is -1, the funtion has failed
                {
                    CloseHandle(threadHandle);
                    return false;
                }
                CloseHandle(threadHandle);
                return true;
            }
    
            private static bool ResumeProcessThread(ProcessThread thread)
            {
                IntPtr threadHandle = OpenThread(THREADACCESS_SUSPEND_RESUME, false, (uint)thread.Id); // Open thread with required permissions
                if (threadHandle == IntPtr.Zero) // If thread pointer is zero, means that the 'OpenThread' function has failed
                {
                    return false;
                }
                if (ResumeThread(threadHandle) == -1) // If the result is -1, the funtion has failed
                {
                    CloseHandle(threadHandle);
                    return false;
                }
                CloseHandle(threadHandle); // Don't forget close thread handle
                return true;
            }
    
            #endregion
        }
    
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(4条)

报告相同问题?

悬赏问题

  • ¥15 eda:门禁系统设计
  • ¥50 如何使用js去调用vscode-js-debugger的方法去调试网页
  • ¥15 376.1电表主站通信协议下发指令全被否认问题
  • ¥15 物体双站RCS和其组成阵列后的双站RCS关系验证
  • ¥15 复杂网络,变滞后传递熵,FDA
  • ¥20 csv格式数据集预处理及模型选择
  • ¥15 部分网页页面无法显示!
  • ¥15 怎样解决power bi 中设置管理聚合,详细信息表和详细信息列显示灰色,而不能选择相应的内容呢?
  • ¥15 QTOF MSE数据分析
  • ¥15 平板录音机录音问题解决