RE: Re[2]: open files which are already opened in exclusi ve shared mode

//Desired Access
set it to SYNCHRONIZE only. The failure is because of FILE_READ_DATA.
From hFile you can get PFILE_OBJECT and roll your own (read, …) IRPs with
it. Don’t forget to DereferenceObject it.
WBR Primoz

-----Original Message-----
From: Roman Kudinov [mailto:xxxxx@rbcmail.ru]
Sent: Friday, September 03, 2004 12:12 PM
To: Windows File Systems Devs Interest List
Subject: Re[2]: [ntfsd] open files which are already opened in exclusive
shared mode

Hello Tony,

I tried to do like you say, but got shared access violation error (I
try to open L"C:\WINDOWS\system32\config\default" which is always
opened in exclusive mode). Other files are opened successfully

Here is my code, it is executed in IRP_MJ_DEVICE_CONTROL

RtlInitEmptyUnicodeString(&strFilename, szBuffer,
sizeof(szBuffer));
RtlAppendUnicodeToString(&strFilename, L"\??\“);
RtlAppendUnicodeToString(&strFilename, InputBuffer);
//InputBuffer =
L"C:\WINDOWS\system32\config\default”

//I tried both with and without OBJ_KERNEL_HANDLE
InitializeObjectAttributes(&Attributes,
&strFilename,
OBJ_KERNEL_HANDLE |
OBJ_CASE_INSENSITIVE,
//Attributes,
NULL,
//RootDirectory
NULL);
//SecurityDescriptor

IoStatus->Status = ZwCreateFile(&hFile,
//Output handle
FILE_READ_DATA |
SYNCHRONIZE,
//DesiredAccess
&Attributes,
//ObjectAttributes
&IoStatusBlock,
&AllocationSize,
//AllocationSize
FILE_ATTRIBUTE_NORMAL,
//FileAttributes
FILE_SHARE_READ |
FILE_SHARE_WRITE |
FILE_SHARE_DELETE,
FILE_OPEN,
FILE_SYNCHRONOUS_IO_ALERT,
//CreateOptions
NULL,
NULL);
if( !NT_SUCCESS(IoStatus->Status) )
{
break;
}

I get error code 32 (shared access violation). Do I do something
wrong?


Best regards,
Roman mailto:xxxxx@rbcmail.ru

Friday, August 6, 2004, 9:53:07 PM, you wrote:

TM> In a filter driver, open the file for some minimal access and then roll
TM> your own IRPs. Access check is done above the level of the filter (not
TM> in the FSD) so this will work.

TM> You could use a filter driver to bypass share access checks as well.

TM> Regards,

TM> Tony

TM> Tony Mason
TM> Consulting Partner
TM> OSR Open Systems Resources Inc.
TM> http://www.osr.com

TM> -----Original Message-----
TM> From: xxxxx@lists.osr.com
TM> [mailto:xxxxx@lists.osr.com] On Behalf Of Roman Kudinov
TM> Sent: Friday, August 06, 2004 1:35 PM
TM> To: ntfsd redirect
TM> Subject: [ntfsd] open files which are already opened in exclusive shared
TM> mode

TM> Hello all,

TM> What is the best approach to open a file alredy opened in exclusive
TM> shared mode by another process?

TM> I have an idea to emulate sharing in my filter driver, are there any
TM> other easier solutions?

TM> P.S. I’d prefer to open and work with files in user space application
TM> but
TM> filter driver is also acceptable


Questions? First check the IFS FAQ at
https://www.osronline.com/article.cfm?id=17

You are currently subscribed to ntfsd as: xxxxx@hermes.si
To unsubscribe send a blank email to xxxxx@lists.osr.com