Question

I am creating a UMDF driver which needs to change the brightness of the LCD back light.

The following line of code works in a Console App and successfully returns a handle to the device:

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'

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

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

No correct solution

OTHER TIPS

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. 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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top