"Access denied" error when calling CreateFile from UMDF driver (C ++)

I am creating a UMDF driver that should change the brightness of the LCD backlight.

The following line of code works in the console application and successfully returns the device descriptor:

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 same code snippet in my driver, it returns INVALID_HANDLE_VALUE, and GetLastError () gives code 5, which is "Access denied"

The driver is debugged remotely on an x64 Windows 7 machine using the standard WDKRemoteUser profile.

Does anyone know what the problem is? Do I need to set permissions and, if so, how?

+4
source share
1 answer

It sounds like you need to impersonate a driver client.

UMDF drivers usually run under the LocalService account and cannot access files or resources that require user credentials, such as protected files or other protected resources. Typically, the UMDF driver works with commands and data that flow between the client application and the device. Therefore, most UMDF drivers do not have access to protected resources.

The framework provides an impersonation capability that allows drivers to impersonate a client driver and gain client access to protected resources.

+1
source

Source: https://habr.com/ru/post/1441850/


All Articles