Concurrent File Access from User/Kernel mode.

Hi all;
I have a file which is written to by a kernel mode component. using these
parameters.

/* Create the file */
Status = ZwCreateFile(&(pCjjournalFile->cjFileHandle),
GENERIC_READ | GENERIC_WRITE,
&ObjectAttributes,
&IoStatusBlock,
NULL,
0 ,
FILE_SHARE_READ,
FILE_OPEN_IF,
FILE_NON_DIRECTORY_FILE | FILE_SYNCHRONOUS_IO_NONALERT |
FILE_NO_INTERMEDIATE_BUFFERING ,
NULL,
0);

A user mode app needs to ONLY read from this file concurrently, for which i
use the following Paremeters.

/*Open the Target file for the present volume */
FileHandle = CreateFile(TargetPath,
GENERIC_READ,
FILE_SHARE_READ,
NULL,
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL | FILE_FLAG_RANDOM_ACCESS,
NULL);

if (FileHandle == INVALID_HANDLE_VALUE ) {
return GetLastError();
}

The CreateFile() in user mode fails with error code 32 (The process cannot
access the file because it is being used by another process. ).

Is there any problem with ShareAccess parameter i have passes to the 2
functions or the FILE_SYNCHRONOUS_IO_NONALERT |
FILE_NO_INTERMEDIATE_BUFFERING playing some role in file not being accesible
from user mode.

Thanks And Regards
Faraz.

You’ll have to pass SHARE_READ|SHARE_WRITE to CreateFile in user mode application.

best regards,
lu0
TTC Senior engineer
http://ttcone.com
Inside Programming
http://lu0.126.com
----- Original Message -----
From: Faraz Ahmed
To: Windows System Software Devs Interest List
Sent: Thursday, November 10, 2005 7:12 PM
Subject: [ntdev] Concurrent File Access from User/Kernel mode.

Hi all;
I have a file which is written to by a kernel mode component. using these parameters.

/* Create the file */
Status = ZwCreateFile(&(pCjjournalFile->cjFileHandle),
GENERIC_READ | GENERIC_WRITE,
&ObjectAttributes,
&IoStatusBlock,
NULL,
0 ,
FILE_SHARE_READ,
FILE_OPEN_IF,
FILE_NON_DIRECTORY_FILE | FILE_SYNCHRONOUS_IO_NONALERT | FILE_NO_INTERMEDIATE_BUFFERING ,
NULL,
0);

A user mode app needs to ONLY read from this file concurrently, for which i use the following Paremeters.

/*Open the Target file for the present volume */
FileHandle = CreateFile(TargetPath,
GENERIC_READ,
FILE_SHARE_READ,
NULL,
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL | FILE_FLAG_RANDOM_ACCESS,
NULL);

if (FileHandle == INVALID_HANDLE_VALUE ) {
return GetLastError();
}

The CreateFile() in user mode fails with error code 32 (The process cannot access the file because it is being used by another process. ).

Is there any problem with ShareAccess parameter i have passes to the 2 functions or the FILE_SYNCHRONOUS_IO_NONALERT | FILE_NO_INTERMEDIATE_BUFFERING playing some role in file not being accesible from user mode.

Thanks And Regards
Faraz.

— Questions? First check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256 You are currently subscribed to ntdev as: unknown lmsubst tag argument: ‘’ To unsubscribe send a blank email to xxxxx@lists.osr.com