Re: NDIS5.1 driver in Vista by soviet_bloke
soviet_bloke
Fri Oct 13 04:26:57 CDT 2006
Amit,
> It shouldn't matter which way you are trying to get the handle either
> IoGetDeviceObjectPointer() or the ZwCreatefile()
In fact, unlike ZwCreateFile(), IoGetDeviceObjectPointer() returns a
pointer, rather than handle. Therefore, you can deal directly with
DEVICE_OBJECT if you have used IoGetDeviceObjectPointer(), and there is
nothing that can be done about you (apart from either deleting
DEVICE_OBJECT you have opened or blocking all "inappropriate" requests
to it). However, ZwCreateFile() opens a file that can get closed.
Therefore, IO can get easily prevented simply by closing a file - this
is why IRP_MJ_CREATE gets immediately followed by IRP_MJ_CLOSE
I just thought that NDIS may be blocking the requests to DEVICE_OBJECT
that has been opened with IoGetDeviceObjectPointer(), but, as you say,
this is not the case - even on XP
In fact, I think that you have found not so bad solution - once
NdisMRegisterDevice() is not supported on Vista, you just provided your
own implementation of it, and everything seems to work fine.....
Anton Bassov
Amit wrote:
> >I am not surprized that calls to IoCreateDeivce()
> > and IoCreateSymbolicLink() were successfull, but, in my experience, if
> > you do thing this way IRP_MJ_CREATE gets immediately followed by
> > IRP_MJ_CLOSE whenever you call ZwCreateFile()
>
> It shouldn't matter which way you are trying to get the handle either
> IoGetDeviceObjectPointer() or the ZwCreatefile()
>
> what I did was just the low level implementation of the
> NdisMRegisterDevice() does....internally it does the same functionality
> as I did...apart it takes care of all the PNP Irps which NDIS library
> handles on it own....Our Miniport drivers need not worry abt the PNP
> irp's. This workaround will work even in the WinXP...
>
> soviet_bloke@hotmail.com wrote:
> > Amit,
> >
> > > For a workaround I created the device object using the IoCreateDeivce()
> > > and further creating the Symbolic link using the
> > > IoCreateSymbolicLink(), Offcourse I am taking care abt the distach
> > > routines initialization for if not done it would crash..
> > > With this workaround I am able to get the handle and setup a normal
> > > behaviour...
> >
> > Sorry, I just overlooked the fact that you were speaking about
> > Vista..... In Vista NdisMRegisterDevice() is not supported - this is
> > why you get STATUS_NOT_SUPPORTED. This is what I can tell you for sure,
> > although, unfortunately, I am unable to offer you any workaround -all
> > my statements about Vista are based upon MSDN, rather than upon my own
> > experience.
> >
> > However, it looks like you made an interesting experiment.....
> >
> > Do you mean that you actually managed to send the request to the device
> > this way??? In fact, I am not surprized that calls to IoCreateDeivce()
> > and IoCreateSymbolicLink() were successfull, but, in my experience, if
> > you do thing this way IRP_MJ_CREATE gets immediately followed by
> > IRP_MJ_CLOSE whenever you call ZwCreateFile() , so that the whole thing
> > is, for the practical purposes, unusable (in fact, I never tried
> > IoGetDeviceObjectPointer(), just because the failure seemed to be
> > inevitable, so that there is no need to waste time on the experiment).
> > This is how it works on W2K and XP. However, as it turns out, on
> > Vista it may work differently......
> >
> > Anton Bassov
> >
> >
> >
> > Amit wrote:
> > > Hi ,
> > > I am registering my mniport driver with NDIS as below,
> > >
> > > Status = NdisMRegisterDevice(
> > > NdisWrapperHandle,
> > > &ustrDeviceName,
> > > &ustrSymbolicName,
> > > dispatch_table,
> > > &Adapter->psDeviceObj,
> > > &Adapter->NdisDeviceHandle);
> > >
> > > using this method I am unable to get the device handle. ( call from
> > > both IoGetDeviceObjectPointer() and CreateFile() FAIL) . I checked
> > > even the Symbolic link with WinObj.exe and is created.
> > >
> > > For a workaround I created the device object using the IoCreateDeivce()
> > > and further creating the Symbolic link using the
> > > IoCreateSymbolicLink(), Offcourse I am taking care abt the distach
> > > routines initialization for if not done it would crash..
> > > With this workaround I am able to get the handle and setup a normal
> > > behaviour...But this workaround is not the right way to register...So
> > > please help me to get a solution and what is the reason for such
> > > behaviour?
> > >
> > > Regards,
> > > Amit
> > > soviet_bloke@hotmail.com wrote:
> > > > Hi mate
> > > >
> > > > > I am trying to get the handle using the IoGetDeviceObjectPointer()
> > > > > function from another driver, But it always returns
> > > > > STATUS_NOT_SUPPORTED. What could be the reason for such behaviour?
> > > >
> > > > "The reason for such behaviour" is obvious-- you are just not supposed
> > > > to access miniport drivers this way. If you want someoene, apart from
> > > > NDIS library, to call your miniport driver, you have to register a
> > > > standalone device with NdisMRegisterDevice(), and forward all calls to
> > > > this device
> > > >
> > > > Anton Bassov
> > > >
> > > > Amit wrote:
> > > > > Hi All,
> > > > > I am using my NDIS 5.1 miniport driver written for WinXP prof in
> > > > > Vista Build 5600 (Vista RC1).
> > > > > The driver is running fine for it supports the backward compatibility,
> > > > > but I am unable to get the handle for my network device for the driver
> > > > > I have.
> > > > > I am trying to get the handle using the IoGetDeviceObjectPointer()
> > > > > function from another driver, But it always returns
> > > > > STATUS_NOT_SUPPORTED. What could be the reason for such behaviour?
> > > > >
> > > > > The same setup ( NDIS miniport driver and the other driver from which i
> > > > > am trying to get the NDIS handle ) works fine.
> > > > >
> > > > > Looking forward for your response.....