I'm using IoGetDeviceObjectPointer to open \??\PhysicalDrive0. This works
fine, unless my application opens it before calling the driver. In which
case I get STATUS_SHARING_VIOLATION (0xC0000043).

I open it from my application using:

CreateFile("\\\\.\\PhysicalDrive0", GENERIC_READ | GENERIC_WRITE,
FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL);

From within my driver I open it using:

IoGetDeviceObjectPointer(L"\\??\\PhysicalDrive0", FILE_READ_DATA, &fileObj,
&deviceObj);

Is this not allowed? I can call CreateFile multiple times from my
application to open the device and that seems to work fine, but using
IoGetDeviceObjectPointer doesn't work.

Thanks,
Josh

Re: IoGetDeviceObjectPointer getting STATUS_SHARING_VIOLATION? by Mark

Mark
Thu Oct 23 18:59:02 CDT 2003

On Thu, 23 Oct 2003 09:55:37 -0700, "Josh Dahlby" <n/a> wrote:

>I'm using IoGetDeviceObjectPointer to open \??\PhysicalDrive0. This works
>fine, unless my application opens it before calling the driver. In which
>case I get STATUS_SHARING_VIOLATION (0xC0000043).
>
>I open it from my application using:
>
>CreateFile("\\\\.\\PhysicalDrive0", GENERIC_READ | GENERIC_WRITE,
>FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL);
>
>From within my driver I open it using:
>
>IoGetDeviceObjectPointer(L"\\??\\PhysicalDrive0", FILE_READ_DATA, &fileObj,
>&deviceObj);
>
>Is this not allowed? I can call CreateFile multiple times from my
>application to open the device and that seems to work fine, but using
>IoGetDeviceObjectPointer doesn't work.
>

The share access implied by IoGetDeviceObjectPointer is incompatible
with that requested by your application. Essentially
IoGetDeviceObjectPointer is opening the device exclusive (share
nothing) and that can't happen if it is already opened by the
application for share read/write. You could implement your own version
of IoGetDeviceObjectPointer by using ZwOpenFile and specifying
appropriate share access. (Use IoGetRelatedDeviceObject to get the
device object.)




=====================
Mark Roddy
Windows XP/2000/NT Consulting, Microsoft DDK MVP
Hollis Technology Solutions 603-321-1032
www.hollistech.com
markr@hollistech.com
For Windows Device Driver Training: see www.azius.com

Re: IoGetDeviceObjectPointer getting STATUS_SHARING_VIOLATION? by Josh

Josh
Fri Oct 24 11:35:47 CDT 2003

That did it. Thanks a lot Mark. I was wondering why
IoGetDeviceObjectPointer didn't have a share access parameter...

"Mark Roddy" <mroddy@tellink.net> wrote in message
news:19qgpvcj4ju8c08fvc0hdla9jevthlspuv@4ax.com...
> On Thu, 23 Oct 2003 09:55:37 -0700, "Josh Dahlby" <n/a> wrote:
>
> >I'm using IoGetDeviceObjectPointer to open \??\PhysicalDrive0. This
works
> >fine, unless my application opens it before calling the driver. In which
> >case I get STATUS_SHARING_VIOLATION (0xC0000043).
> >
> >I open it from my application using:
> >
> >CreateFile("\\\\.\\PhysicalDrive0", GENERIC_READ | GENERIC_WRITE,
> >FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL);
> >
> >From within my driver I open it using:
> >
> >IoGetDeviceObjectPointer(L"\\??\\PhysicalDrive0", FILE_READ_DATA,
&fileObj,
> >&deviceObj);
> >
> >Is this not allowed? I can call CreateFile multiple times from my
> >application to open the device and that seems to work fine, but using
> >IoGetDeviceObjectPointer doesn't work.
> >
>
> The share access implied by IoGetDeviceObjectPointer is incompatible
> with that requested by your application. Essentially
> IoGetDeviceObjectPointer is opening the device exclusive (share
> nothing) and that can't happen if it is already opened by the
> application for share read/write. You could implement your own version
> of IoGetDeviceObjectPointer by using ZwOpenFile and specifying
> appropriate share access. (Use IoGetRelatedDeviceObject to get the
> device object.)
>
>
>
>
> =====================
> Mark Roddy
> Windows XP/2000/NT Consulting, Microsoft DDK MVP
> Hollis Technology Solutions 603-321-1032
> www.hollistech.com
> markr@hollistech.com
> For Windows Device Driver Training: see www.azius.com