c++ - Windows 凭据提供程序 - 在接收凭据之前销毁
问题描述
我正在编写一个 Windows 凭据提供程序,但由于缺乏有关该程序如何工作的文档,我一直在苦苦挣扎。
我从 Windows SDK 示例 ( security/SampleCredentialProvider
) 开始并对其进行了修改,以便从 SYSTEM 服务接收凭据,该服务通过管道充当服务器。
问题是:当凭证提供者对象(实现的那个ICredentialProvider
)GetCredentialCount
被调用时,它还没有通过该管道从 SYSTEM 服务接收到凭证,因此我返回一个 0 凭证号(*pdwCount = 0;
)。
我不确定这是否是问题的原因,但此后不久就会调用对象析构函数。这反过来又破坏了我正在等待传递 SYSTEM 服务凭据的管道,并且没有任何效果。
我的问题是:为什么实现的对象ICredentialProvider
被破坏了?为了让提供者等待通过管道传递的凭据,然后通知 LogonUI 我们有新的凭据,我怎样才能避免它的破坏?
我附上了一些从 Windows 事件查看器中获取的关于我的凭据提供程序模块的事件:
- Credential provider object is created
- SetUsageScenario is called, only CPUS_LOGON is supported
- Advise is called, pcpe parameter is saved and AddRef'd
- GetCredentialCount, 0 is returned (no credential received yet)
- UnAdvise is called (this is unexpected, does this mean I can no longer pass credentials? Why is this called?)
- pipe to receive credentials is created
- Credential provider object's destructor is called -> pipe is destroyed and everything terminates
解决方案
发现问题:我卡在 Ctrl+Alt+Del 屏幕上,我正在查看的凭据提供程序日志是 RDP 的(我使用它来登录和调试问题)。
推荐阅读
- javascript - 面包屑路由器动态
- android - 使用 RecognizerIntent 语音转字符串不起作用
- angular - 无法在 Angular 7(单击)功能中创建窗口警报
- ios - iOS Swift 使用 CLLocationManager 在室内获取近似位置
- php - WooCommerce 检查订单是否已付款/处理或完成
- html - 如何在表格单元格中使用省略号?
- python - matplotlib 中的共享辅助轴
- ruby-on-rails - 在 ruby 上安装导轨时出错。请检查错误代码并告知?
- html - 溢出:自动;不适用于我的导航栏
- javascript - 正则表达式匹配不带逗号的整数