Re: CreateFile() returns ERROR_ACCESS_DENIED to the user

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



I solved with:

// Open driver
rv = CreateFile (
ifDetail->DevicePath,
0, // Desidered access // GENERIC_READ | GENERIC_WRITE,
0, // Share mode
NULL, // Security attrib
OPEN_EXISTING, // How to create CREATE_NEW,
FILE_ATTRIBUTE_NORMAL, // File attribute FILE_FLAG_DELETE_ON_CLOSE,
NULL // Template file
);

Thanks !
--
SteM



"Alexander Grigoriev" <alegr@xxxxxxxxxxxxx> ha scritto nel messaggio
news:u1RwdvgCHHA.4292@xxxxxxxxxxxxxxxxxxxxxxx
1. Use OPEN_EXISTING with non-file devices.
2. Don't specify DELETE_ON_CLOSE - that was requirement for VxD only.
3. Add HKR,,Security, ,<security descriptor string> to AddReg section of
your INF file.

"SteM" <xxx@xxxxxxx> wrote in message
news:umtKAF0BHHA.204@xxxxxxxxxxxxxxxxxxxxxxx
Hello,
I've written a small wdm driver for Win2000 to access an old custom hw
on
parallel port.
The accesses are via a couple of DeviceIoControl() custom commands.
It works fine, does exactly what i intended; however, it only works if I
am
logged in as Administrator (or equivalent).
If I log in as a regular user (Power User) the call to CreateFile fails
with
ACCESS_DENIED.

// Open driver
rv = CreateFile (
ifDetail->DevicePath,
0, // Desidered access
0, // Share mode
NULL, // Security attrb
CREATE_NEW, // How to create
FILE_FLAG_DELETE_ON_CLOSE, // File attribute
NULL // Template file
);

if (rv==INVALID_HANDLE_VALUE)
{
......



Thanks in advance for any pointers...
--
SteM






.



Relevant Pages

  • Secedit failing to apply FileSystem settings
    ... I am running the secedit /configure on the template file, ... Error building security descriptor for c:\pagefile.sys. ...
    (microsoft.public.windowsxp.security_admin)
  • CreateFile with security attributes in SP2??
    ... Creating a handle to a USB port does not work for the second user with SP2 ... Do I need to change the security attributes under CreateFile? ...
    (microsoft.public.development.device.drivers)