简体   繁体   English

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

[英]'Access is denied' error when calling CreateFile from a UMDF driver (C++)

I am creating a UMDF driver which needs to change the brightness of the LCD back light. 我正在创建一个UMDF驱动程序,需要改变LCD背光的亮度。

The following line of code works in a Console App and successfully returns a handle to the device: 以下代码行在Console App中工作,并成功返回设备的句柄:

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

However, when I use the exact same piece of code in my driver it returns INVALID_HANDLE_VALUE and GetLastError() gives code 5 which is 'Access is denied' 但是,当我在驱动程序中使用完全相同的代码时,它返回INVALID_HANDLE_VALUE,GetLastError()给出代码5,即“访问被拒绝”

The driver is being debugged remotely on an x64 Windows 7 machine using the standard WDKRemoteUser profile. 使用标准WDKRemoteUser配置文件在x64 Windows 7计算机上远程调试驱动程序。

Does anyone know what the problem might be? 有谁知道问题可能是什么? Do I need to set permissions and, if so, how? 我是否需要设置权限,如果是,如何设置权限?

It sounds as though you need to 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. UMDF驱动程序通常在LocalService帐户下运行,无法访问需要用户凭据的文件或资源,例如受保护文件或其他受保护资源。 A UMDF driver typically operates on commands and data that flow between a client application and a device. UMDF驱动程序通常对在客户端应用程序和设备之间流动的命令和数据进行操作。 Therefore, most UMDF drivers do not access protected resources. 因此,大多数UMDF驱动程序不访问受保护的资源。

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. 该框架提供了一种模拟功能,允许驱动程序模拟驱动程序的客户端并获取客户端对受保护资源的访问权限。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM