gpt4 book ai didi

c++ - 从 UMDF 驱动程序 (C++) 调用 CreateFile 时出现“访问被拒绝”错误

转载 作者:塔克拉玛干 更新时间:2023-11-03 02:18:57 27 4
gpt4 key购买 nike

我正在创建一个需要更改 LCD 背光亮度的 UMDF 驱动程序。

以下代码行在控制台应用程序中运行并成功返回设备句柄:

HANDLE hDevice = CreateFile(L"\\\\.\\LCD", GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, 0);

但是,当我在我的驱动程序中使用完全相同的一段代码时,它返回 INVALID_HANDLE_VALUE 并且 GetLastError() 给出代码 5,即“访问被拒绝”

正在使用标准 WDKRemoteUser 配置文件在 x64 Windows 7 计算机上远程调试驱动程序。

有人知道问题出在哪里吗?我是否需要设置权限,如果需要,如何设置?

最佳答案

听起来好像你需要 impersonate the drivers client.

UMDF drivers typically run under the LocalService account and cannot access files or resources that require user credentials, such as protected files or other protected resources. A UMDF driver typically operates on commands and data that flow between a client application and a device. Therefore, most UMDF drivers do not access protected resources.

The framework provides an impersonation capability that allows drivers to impersonate the driver's client and obtain the client's access rights to protected resources.

关于c++ - 从 UMDF 驱动程序 (C++) 调用 CreateFile 时出现“访问被拒绝”错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13052684/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com