I'm trying to open a directory in my file system filter driver. I'd like to open "C:\Ax\Bx\Cx\"

I don't know if this directory exists, but if it does not I'd like to create it. If it does, then I plan to write a file to it

So I've called IoCreateFile with the path = "C:\" because if it does not exist, I'll need to create this path before moving on to
"C:\Ax", etc. But I'm returning from the initial call with

#define STATUS_ACCESS_VIOLATION ((NTSTATUS)0xC0000005L)

What's going on

THE CODE:

InitializeObjectAttributes(&ObjAttrs,&Path, OBJ_KERNEL_HANDLE,NULL,NULL)
Status = IoCreateFile(&FileHandle
FILE_WRITE_ATTRIBUTES|FILE_WRITE_DATA
&ObjAttrs
&StatusBlock
0, //allocation siz
FILE_ATTRIBUTE_DIRECTORY
FILE_SHARE_WRITE, //share acces
FILE_OPEN_IF, // dispositio
FILE_DIRECTORY_FILE, // CreateOptions
0, // EaBuffer OPTIONAL
0 , // EaLengt
CreateFileTypeNone, // CreateFileTyp
NULL, // extra param
IO_FORCE_ACCESS_CHECK // Option
)

Thank
Finecat

RE: Creating/Opening a directory -- More Info by finecats

finecats
Wed Jun 02 18:41:05 CDT 2004


I've got more info about this problem.
Prior to calling this code I do another call to
Status = IoCreateFileSpecifyDeviceObjectHint()

In this call I am querying for information about a file that might / might not exist.

If I skip this call and call directly into the code that does the "offending" stuff, my stuff works.

So, is there a reset mechanism that must be done when Status comes back and is not a success? Or comes back with invalid response?

Thanks




----- finecats wrote: -----

I'm trying to open a directory in my file system filter driver. I'd like to open "C:\Ax\Bx\Cx\".

I don't know if this directory exists, but if it does not I'd like to create it. If it does, then I plan to write a file to it.

So I've called IoCreateFile with the path = "C:\" because if it does not exist, I'll need to create this path before moving on to
"C:\Ax", etc. But I'm returning from the initial call with

#define STATUS_ACCESS_VIOLATION ((NTSTATUS)0xC0000005L) .

What's going on?

THE CODE:

InitializeObjectAttributes(&ObjAttrs,&Path, OBJ_KERNEL_HANDLE,NULL,NULL);
Status = IoCreateFile(&FileHandle,
FILE_WRITE_ATTRIBUTES|FILE_WRITE_DATA,
&ObjAttrs,
&StatusBlock,
0, //allocation size
FILE_ATTRIBUTE_DIRECTORY,
FILE_SHARE_WRITE, //share access
FILE_OPEN_IF, // disposition
FILE_DIRECTORY_FILE, // CreateOptions,
0, // EaBuffer OPTIONAL,
0 , // EaLength
CreateFileTypeNone, // CreateFileType
NULL, // extra params
IO_FORCE_ACCESS_CHECK // Options
);

Thanks
Finecats



RE: Creating/Opening a directory by DougHowe

DougHowe
Wed Jun 02 18:59:11 CDT 2004

------=_NextPart_0001_B48F4837
Content-Type: text/plain
Content-Transfer-Encoding: 7bit

Hello,

I am in the process of researching possible reasons this may be failing for
you. If you could send me more of your code (to better understand the
context of the call) that would be helpful.

Which version of Windows (and Service Pack) are you running on the target
machine?

Regards,
Doug Howe
Microsoft DDK Support
doughowe@microsoft.com


This posting is provided "AS IS" with no warranties, and confers no rights
------=_NextPart_0001_B48F4837
Content-Type: text/x-rtf
Content-Transfer-Encoding: 7bit

{\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fnil\fprq2\fcharset0 MS Sans Serif;}}
\viewkind4\uc1\pard\f0\fs20 Hello,
\par
\par I am in the process of researching possible reasons this may be failing for you. If you could send me more of your code (to better understand the context of the call) that would be helpful.
\par
\par Which version of Windows (and Service Pack) are you running on the target machine?
\par
\par Regards,
\par Doug Howe
\par Microsoft DDK Support
\par doughowe@microsoft.com
\par
\par
\par This posting is provided "AS IS" with no warranties, and confers no rights
\par }
------=_NextPart_0001_B48F4837--


RE: Creating/Opening a directory -- More Info by DougHowe

DougHowe
Wed Jun 02 23:23:53 CDT 2004

------=_NextPart_0001_B5819F76
Content-Type: text/plain
Content-Transfer-Encoding: 7bit


Hello,

I would be interested in reviewing your code. If you email me a more
complete portion I will see if I find any issues. Also, the IFS Kit states
that IoCreateFileSpecifyDeviceObjectHint cannot be used to obtain a handle
to a volume, so if you are trying to open "C:\" that may be a problem.

"C:" is a Symbolic Link, and resolves to a path such as
\Device\HarddiskVolume1
You do not show how you initialize your Path variable when calling
IoCreateFile. Have you tried initializing it to a fully qualified file
name such as:

RtlInitUnicodeString(&Path, L"\\??\\C:\\");


Regards,
Doug Howe
Microsoft DDK Support
doughowe@microsoft.com


This posting is provided "AS IS" with no warranties, and confers no rights
------=_NextPart_0001_B5819F76
Content-Type: text/x-rtf
Content-Transfer-Encoding: 7bit

{\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fnil\fprq2\fcharset0 MS Sans Serif;}}
\viewkind4\uc1\pard\f0\fs20
\par Hello,
\par
\par I would be interested in reviewing your code. If you email me a more complete portion I will see if I find any issues. Also, the IFS Kit states that IoCreateFileSpecifyDeviceObjectHint cannot be used to obtain a handle to a volume, so if you are trying to open "C:\\" that may be a problem.
\par
\par "C:" is a Symbolic Link, and resolves to a path such as \\Device\\HarddiskVolume1
\par You do not show how you initialize your Path variable when calling IoCreateFile. Have you tried initializing it to a fully qualified file name such as:
\par
\par RtlInitUnicodeString(&Path, L"\\\\??\\\\C:\\\\");
\par
\par
\par Regards,
\par Doug Howe
\par Microsoft DDK Support
\par doughowe@microsoft.com
\par
\par
\par This posting is provided "AS IS" with no warranties, and confers no rights
\par
\par }
------=_NextPart_0001_B5819F76--


Re: Creating/Opening a directory by Carl

Carl
Thu Jun 03 15:00:19 CDT 2004

The error code you're getting is probably an indication that you have to add
FILE_OPEN_FOR_BACKUP_INTENT to your create options. I believe that option
is required when you're trying to open a directory as a file.

Carl

"finecats" <finecats@noemail.noemail> wrote in message
news:9B7C7076-ED31-4B45-9D86-0AD883129E54@microsoft.com...
> I'm trying to open a directory in my file system filter driver. I'd like
to open "C:\Ax\Bx\Cx\".
>
> I don't know if this directory exists, but if it does not I'd like to
create it. If it does, then I plan to write a file to it.
>
> So I've called IoCreateFile with the path = "C:\" because if it does not
exist, I'll need to create this path before moving on to
> "C:\Ax", etc. But I'm returning from the initial call with
>
> #define STATUS_ACCESS_VIOLATION ((NTSTATUS)0xC0000005L) .
>
> What's going on?
>
> THE CODE:
>
> InitializeObjectAttributes(&ObjAttrs,&Path,
OBJ_KERNEL_HANDLE,NULL,NULL);
> Status = IoCreateFile(&FileHandle,
> FILE_WRITE_ATTRIBUTES|FILE_WRITE_DATA,
> &ObjAttrs,
> &StatusBlock,
> 0, //allocation size
> FILE_ATTRIBUTE_DIRECTORY,
> FILE_SHARE_WRITE, //share access
> FILE_OPEN_IF, // disposition
> FILE_DIRECTORY_FILE, // CreateOptions,
> 0, // EaBuffer OPTIONAL,
> 0 , // EaLength
> CreateFileTypeNone, // CreateFileType
> NULL, // extra params
> IO_FORCE_ACCESS_CHECK // Options
> );
>
> Thanks
> Finecats
>
>



RE: Creating/Opening a directory by finecats

finecats
Fri Jun 04 13:21:03 CDT 2004


Doug,

I am still being stumped by this problem. What more info do you need, I'll get it to you
OS - XP, home edition, service pack

Thank


----- Doug Howe [MSFT] wrote: ----

Hello

I am in the process of researching possible reasons this may be failing for
you. If you could send me more of your code (to better understand the
context of the call) that would be helpful

Which version of Windows (and Service Pack) are you running on the target
machine

Regards
Doug How
Microsoft DDK Suppor
doughowe@microsoft.co


This posting is provided "AS IS" with no warranties, and confers no rights

RE: Creating/Opening a directory by DougHowe

DougHowe
Mon Jun 07 19:24:35 CDT 2004

------=_NextPart_0001_91FBCEFB
Content-Type: text/plain
Content-Transfer-Encoding: 7bit

Hello,

I know you are working with another DDK engineer, Bart, on this issue, and
that he has sent you sample code. Please let Bart or myself know if you
have any questions on this issue.

Regards,
Doug Howe
Microsoft DDK Support

This posting is provided "AS IS" with no warranties, and confers no rights
------=_NextPart_0001_91FBCEFB
Content-Type: text/x-rtf
Content-Transfer-Encoding: 7bit

{\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fnil\fprq2\fcharset0 MS Sans Serif;}}
\viewkind4\uc1\pard\f0\fs20 Hello,
\par
\par I know you are working with another DDK engineer, Bart, on this issue, and that he has sent you sample code. Please let Bart or myself know if you have any questions on this issue.
\par
\par Regards,
\par Doug Howe
\par Microsoft DDK Support
\par
\par This posting is provided "AS IS" with no warranties, and confers no rights
\par }
------=_NextPart_0001_91FBCEFB--