About CreateFile on vista?

Posted: 11-07-2007, 03:31 AM
My code :
hHandle = CreateFile( pSpDevIntfsDetData->DevicePath,
GENERIC_READ|GENERIC_WRITE,
FILE_SHARE_READ|FILE_SHARE_WRITE, NULL,
CREATE_NEW, FILE_ATTRIBUTE_NORMAL, NULL);
and i run this code in vista ,it return the lasterror 5. tell me no
Privileges. why i can get the Privileges to run creatfile?

Reply With Quote

Responses to "About CreateFile on vista?"

Jesper
Guest
Posts: n/a
 
RE: About CreateFile on vista?
Posted: 11-10-2007, 05:23 PM
What does pSpDevIntfsDetData->DevicePath point to?

There are two reasons this might fail. First, you could be trying to open a
file that you do not have read or write permissions to. Second, you could be
trying to open a file that already exists.

Try modifying the flags to see what happens. Change CREATE_NEW to
OPEN_EXISTING and see what happens. If that works the file exists and you
need to use OPEN_ALWAYS instead. Also, change the dwDesiredAccess to
MAXIMUM_ALLOWED and check the permissions you get back on the handle to see
what perms you have (or, easier still, just look at the permissions on the
file). You don't want to use MAXIMUM_ALLOWED in production code, but it is
useful for testing like this.
---
Your question may already be answered in Windows Vista Security:
http://www.amazon.com/gp/product/047...otectyourwi-20


"李海滨" wrote:
> My code :
> hHandle = CreateFile( pSpDevIntfsDetData->DevicePath,
> GENERIC_READ|GENERIC_WRITE,
> FILE_SHARE_READ|FILE_SHARE_WRITE, NULL,
> CREATE_NEW, FILE_ATTRIBUTE_NORMAL, NULL);
> and i run this code in vista ,it return the lasterror 5. tell me no
> Privileges. why i can get the Privileges to run creatfile?
>
Reply With Quote
 
LinkBack Thread Tools Display Modes
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


Similar Threads
Thread Thread Starter Forum Replies Last Post
Can I Use Windows Vista To Restore My PC Backup Without A Vista Partition But With A Vista DVD? Guest Windows Vista 0 04-16-2008 12:00 PM
Vista Ulitimate 64 ~ Media Center works with Hauppauge HVR 1600, or Vista has 4MB memory . Not both. Robert Windows Vista Hardware & Devices 0 04-14-2007 09:29 PM
IRP_MJ_CREATE is called twice with one createfile call from application zyx Windows XP Device Drivers 1 02-22-2007 06:10 AM
CreateFile() and usb mike Windows XP Device Drivers 0 09-16-2006 06:14 PM
Difference between CreateFile & Com_Open Arsalan Ahmad Windows XP Device Drivers 1 05-27-2005 04:53 PM