Hi,

I am trying to write an unloadable driver, to achieve that I have created a
minimal, presumably unloadable driver, Loading and initializing the driver
succeeds BUT unloading ( using 'ControlService(SERVICE_CONTROL_STOP)' ) fails
with the following error: "The requested control is not valid for this
service.", What may cause such an error? I have added the required
DeviceCreate and DeviceClose ICTL Handlers but it had no effectâ?¦

// The CreateClose IOCTL I have added...
NTSTATUS DispatchCreateClose(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
{
Irp->IoStatus.Status = STATUS_SUCCESS;
Irp->IoStatus.Information=0;
IoCompleteRequest(Irp, IO_NO_INCREMENT);
return STATUS_SUCCESS;
}

Any help, pointers or samples would be appreciatedâ?¦

Following is the short code with which I am experiancing the problem:

The Driver:
**********
#pragma code_seg("INIT")
// This handler is NEVER called...
VOID __stdcall Unload(IN PDRIVER_OBJECT DriverObject) {
UNICODE_STRING uszDeviceString;
DbgPrint("Simple C++ Driver - Unload.\n");
IoDeleteDevice(DriverObject->DeviceObject);
RtlInitUnicodeString(&uszDeviceString, L"\\DosDevices\\ProcDrv");
IoDeleteSymbolicLink(&uszDeviceString);
TerminateCppRunTime();
}

NTSTATUS __stdcall DriverEntry(IN PDRIVER_OBJECT DriverObject
, IN PUNICODE_STRING
RegistryPath) {
DbgPrint("Simple C++ Driver - DriverEntry\nCompiled at " __TIME__ "
on " __DATE__ "\n");
NTSTATUS Status = InitializeCppRunTime();
if (STATUS_SUCCESS != Status)
goto ErrorExit;
UNICODE_STRING uszDriverString, uszDeviceString;
RtlInitUnicodeString(&uszDriverString, L"\\Device\\ProcDrv");
RtlInitUnicodeString(&uszDeviceString, L"\\DosDevices\\ProcDrv");
DbgPrint("C++ runtime was initialized successfuly...\n");
PDEVICE_OBJECT pDeviceObject = NULL;
Status = IoCreateDevice(DriverObject, 0, &uszDriverString,
FILE_DEVICE_UNKNOWN, 0, FALSE,
&pDeviceObject);
if (STATUS_SUCCESS != Status)
goto ErrorExit;
DbgPrint("Device created successfuly...\n");
Status = IoCreateSymbolicLink(&uszDeviceString, &uszDriverString);
if(Status != STATUS_SUCCESS) {
Unload(DriverObject);
goto ErrorExit;
}
DbgPrint("Link created successfuly...\n");
DriverObject->DriverUnload = Unload;
goto SafeExit;
ErrorExit:
TerminateCppRunTime();
SafeExit:
DbgPrint("DriverEntry retruns 0x%.8x\n", Status);
return Status;
}
#pragma code_seg()


The driver Loading/Unloading routine
*******************************
BOOL WaitForState(SC_HANDLE hDriver,
DWORD dwDesiredState,
SERVICE_STATUS* pss) {
while (1) {
if(FALSE == ::QueryServiceStatus(hDriver, pss))
return FALSE;
// If the driver reaches the desired state
if (pss->dwCurrentState == dwDesiredState)
break;
DWORD dwWaitHint = pss->dwWaitHint / 10;
if (dwWaitHint < 1000) dwWaitHint = 1000; // At most once a second
if (dwWaitHint > 10000) dwWaitHint = 10000; // At least every 10 seconds
::Sleep(dwWaitHint);
} // while
return TRUE;
}

int _tmain(int argc, _TCHAR* argv[]) {
// Start the driver
SC_HANDLE hSCM = ::OpenSCManager(NULL, NULL,

SC_MANAGER_ALL_ACCESS);
SC_HANDLE hDriver= ::CreateService(hSCM, "ProcDrv", "ProcDrv",
SERVICE_ALL_ACCESS,

SERVICE_KERNEL_DRIVER,
SERVICE_DEMAND_START,

SERVICE_ERROR_NORMAL,
argv[1], NULL,
NULL, NULL,
NULL, NULL);
if(0 == hDriver && (::GetLastError() == ERROR_SERVICE_EXISTS ||
::GetLastError() == ERROR_SERVICE_MARKED_FOR_DELETE) &&
(0 == (hDriver = ::OpenService(hSCM, "ProcDrv", SERVICE_ALL_ACCESS))))
return 0;
SERVICE_STATUS serviceStatus = { 0 };
BOOL bResult = ::StartService(hDriver, 0, NULL);
if (bResult)
bResult = WaitForState(hDriver, SERVICE_RUNNING, &serviceStatus);
else
bResult = (::GetLastError() == ERROR_SERVICE_ALREADY_RUNNING);
if (!bResult) {
::DeleteService(hDriver);
::CloseServiceHandle(hDriver);
} else {
// Stop the driver, returns "The requested control is not valid for this
service."
if(TRUE == (bResult = ::ControlService(hDriver,

SERVICE_CONTROL_STOP,

&serviceStatus)))
bResult = WaitForState(hDriver, SERVICE_STOPPED, &serviceStatus);
::DeleteService(hDriver);
::CloseServiceHandle(hDriver);
}
::CloseServiceHandle(hSCM);
return 0;
}

Nadav.
http://www.sophin.com

Re: Problems unloading a driver by Maxim

Maxim
Wed Mar 16 07:01:06 CST 2005

> I am trying to write an unloadable driver, to achieve that I have created a
> minimal, presumably unloadable driver, Loading and initializing the driver
> succeeds BUT unloading ( using 'ControlService(SERVICE_CONTROL_STOP)' ) fails
> with the following error: "The requested control is not valid for this
> service.", What may cause such an error? I have added the required

This means that you have no Unload function in your driver.

--
Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
maxim@storagecraft.com
http://www.storagecraft.com



Re: Problems unloading a driver by Nadav

Nadav
Wed Mar 16 07:11:43 CST 2005

Thanks for your immediate responce, Well, as shown in my original post the
problematic driver has an Unload function addgioned to
DriverObject->DriverUnload, So I guess this is not the problem, how ever, I
have tried using Numegas driver monitor to load and unload the driver AND...
unloading the driver resulted the following error message: "The driver is not
in a state to accept this command.", What state should me driver be at? it
doesn't handle any IRP... what may cause such a problem?

"Maxim S. Shatskih" wrote:

> > I am trying to write an unloadable driver, to achieve that I have created a
> > minimal, presumably unloadable driver, Loading and initializing the driver
> > succeeds BUT unloading ( using 'ControlService(SERVICE_CONTROL_STOP)' ) fails
> > with the following error: "The requested control is not valid for this
> > service.", What may cause such an error? I have added the required
>
> This means that you have no Unload function in your driver.
>
> --
> Maxim Shatskih, Windows DDK MVP
> StorageCraft Corporation
> maxim@storagecraft.com
> http://www.storagecraft.com
>
>
>

Re: Problems unloading a driver by Eliyas

Eliyas
Wed Mar 16 09:05:04 CST 2005

Have you set an AddDevice routine in the DriverObject? Why don't you post
your DriverEntry function?

--
--
-Eliyas
This posting is provided "AS IS" with no warranties, and confers no rights.
http://www.microsoft.com/whdc/driver/default.mspx
http://www.microsoft.com/whdc/driver/kernel/KB-drv.mspx



Re: Problems unloading a driver by Nadav

Nadav
Wed Mar 16 10:09:06 CST 2005

Thanks for your immediate responce, the original DriverEntry could be seen in
my original post, however, indeed the AddDevice routine wasn't set, I have
set the AddDevice routine and still the problem persist, I keep getting the
same "The requested control is not valid for this service"...
following is a snap of my updated DriverEntry as you requested:

NTSTATUS
DriverEntry(IN PDRIVER_OBJECT DriverObject,
IN PUNICODE_STRING RegistryPath) {
NTSTATUS Status = STATUS_SUCCESS;
PDEVICE_OBJECT pDeviceObject = NULL;
Status = IoCreateDevice(DriverObject, 0, NULL,
FILE_DEVICE_UNKNOWN,
0, FALSE, &pDeviceObject);
if (STATUS_SUCCESS != Status)
goto SafeExit;
DbgPrint("Link created successfuly...\n");
DriverObject->DriverExtension->AddDevice= AddDeviceDispatch;
DriverObject->DriverUnload = UnloadDriver;
DriverObject->MajorFunction[IRP_MJ_SHUTDOWN]=
DriverObject->MajorFunction[IRP_MJ_CREATE] =
DriverObject->MajorFunction[IRP_MJ_CLOSE] =
DriverObject->MajorFunction[IRP_MJ_CLEANUP]=
DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL] = DefaultDispatch;
IoRegisterShutdownNotification( pDeviceObject );
SafeExit:
DbgPrint("DriverEntry retruns 0x%.8x\n", Status);
return Status;
}

NTSTATUS
AddDeviceDispatch(PDRIVER_OBJECT DriverObject,
PDEVICE_OBJECT PhysicalDeviceObject)
{
PDEVICE_OBJECT pSysDev;
for(pSysDev = DriverObject->DeviceObject;
pSysDev!= NULL;
pSysDev = pSysDev->NextDevice)
pSysDev->Flags &= ~DO_DEVICE_INITIALIZING;
return STATUS_SUCCESS;
}

NTSTATUS
DefaultDispatch(
IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp
)
{
Irp->IoStatus.Status = STATUS_SUCCESS;
Irp->IoStatus.Information = 0;
IoCompleteRequest( Irp, IO_NO_INCREMENT );
return STATUS_SUCCESS;
}


"Eliyas Yakub [MSFT]" wrote:

> Have you set an AddDevice routine in the DriverObject? Why don't you post
> your DriverEntry function?
>
> --
> --
> -Eliyas
> This posting is provided "AS IS" with no warranties, and confers no rights.
> http://www.microsoft.com/whdc/driver/default.mspx
> http://www.microsoft.com/whdc/driver/kernel/KB-drv.mspx
>
>
>

Re: Problems unloading a driver by Ray

Ray
Wed Mar 16 11:29:06 CST 2005

At shot in the dark:

You don't have a PnP driver here (at least it looks that way), and so as
far as I know, your AddDevice routine isn't going to be called (is it?).

As a result, your device's DO_DEVICE_INITIALIZING flag isn't being
cleared, and the service manager won't unload the driver if any if it's
devices are still initializing.

Nadav wrote:
> Thanks for your immediate responce, the original DriverEntry could be seen in
> my original post, however, indeed the AddDevice routine wasn't set, I have
> set the AddDevice routine and still the problem persist, I keep getting the
> same "The requested control is not valid for this service"...
> following is a snap of my updated DriverEntry as you requested:
>
> NTSTATUS
> DriverEntry(IN PDRIVER_OBJECT DriverObject,
> IN PUNICODE_STRING RegistryPath) {
> NTSTATUS Status = STATUS_SUCCESS;
> PDEVICE_OBJECT pDeviceObject = NULL;
> Status = IoCreateDevice(DriverObject, 0, NULL,
> FILE_DEVICE_UNKNOWN,
> 0, FALSE, &pDeviceObject);
> if (STATUS_SUCCESS != Status)
> goto SafeExit;
> DbgPrint("Link created successfuly...\n");
> DriverObject->DriverExtension->AddDevice= AddDeviceDispatch;
> DriverObject->DriverUnload = UnloadDriver;
> DriverObject->MajorFunction[IRP_MJ_SHUTDOWN]=
> DriverObject->MajorFunction[IRP_MJ_CREATE] =
> DriverObject->MajorFunction[IRP_MJ_CLOSE] =
> DriverObject->MajorFunction[IRP_MJ_CLEANUP]=
> DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL] = DefaultDispatch;
> IoRegisterShutdownNotification( pDeviceObject );
> SafeExit:
> DbgPrint("DriverEntry retruns 0x%.8x\n", Status);
> return Status;
> }
>
> NTSTATUS
> AddDeviceDispatch(PDRIVER_OBJECT DriverObject,
> PDEVICE_OBJECT PhysicalDeviceObject)
> {
> PDEVICE_OBJECT pSysDev;
> for(pSysDev = DriverObject->DeviceObject;
> pSysDev!= NULL;
> pSysDev = pSysDev->NextDevice)
> pSysDev->Flags &= ~DO_DEVICE_INITIALIZING;
> return STATUS_SUCCESS;
> }
>
> NTSTATUS
> DefaultDispatch(
> IN PDEVICE_OBJECT DeviceObject,
> IN PIRP Irp
> )
> {
> Irp->IoStatus.Status = STATUS_SUCCESS;
> Irp->IoStatus.Information = 0;
> IoCompleteRequest( Irp, IO_NO_INCREMENT );
> return STATUS_SUCCESS;
> }
>
>
> "Eliyas Yakub [MSFT]" wrote:
>
>
>>Have you set an AddDevice routine in the DriverObject? Why don't you post
>>your DriverEntry function?
>>
>>--
>>--
>>-Eliyas
>>This posting is provided "AS IS" with no warranties, and confers no rights.
>>http://www.microsoft.com/whdc/driver/default.mspx
>>http://www.microsoft.com/whdc/driver/kernel/KB-drv.mspx
>>
>>
>>

--
../ray\..

Re: Problems unloading a driver by Eliyas

Eliyas
Wed Mar 16 12:10:00 CST 2005

1) For non pnp drivers, you shouldn't set AddDevice routine. If you do, you
wouldn't be able to load or unload the driver using ServiceControl manager
APIs.

2) Make sure you call IoUnregisterShutdownNotification in your unload
routine. IoRegisterShutdownNotification takes a reference on the
DeviceObject. If you don't unregister, it will prevent the device from being
deleted and consequently prevent driver unload.

3) Make sure you clear the DO_DEVICE_INITIALIZING before you return from
DriverEntry. If you don't it will prevent others from opening handle to the
device or prevent other devices from attaching to you. I don't think it
really has any affect on driver load.

4) Before you unload, set a bp on Unload routine and see it gets invoked. If
it doesn't then most probably some body has a open handle to your device.

There are few non pnp samples such as cancel, ioctl, event under src\general
directory. Please follow that.

--
-Eliyas
This posting is provided "AS IS" with no warranties, and confers no rights.
http://www.microsoft.com/whdc/hwdev/driver/kb-drv.mspx
"Ray Trent" <ratrent@nospam.nospam> wrote in message
news:OXNUZ2kKFHA.1176@TK2MSFTNGP12.phx.gbl...
> At shot in the dark:
>
> You don't have a PnP driver here (at least it looks that way), and so as
> far as I know, your AddDevice routine isn't going to be called (is it?).
>
> As a result, your device's DO_DEVICE_INITIALIZING flag isn't being
> cleared, and the service manager won't unload the driver if any if it's
> devices are still initializing.
>
> Nadav wrote:
>> Thanks for your immediate responce, the original DriverEntry could be
>> seen in my original post, however, indeed the AddDevice routine wasn't
>> set, I have set the AddDevice routine and still the problem persist, I
>> keep getting the same "The requested control is not valid for this
>> service"...
>> following is a snap of my updated DriverEntry as you requested:
>>
>> NTSTATUS DriverEntry(IN PDRIVER_OBJECT DriverObject, IN PUNICODE_STRING
>> RegistryPath) {
>> NTSTATUS Status = STATUS_SUCCESS;
>> PDEVICE_OBJECT pDeviceObject = NULL;
>> Status = IoCreateDevice(DriverObject, 0, NULL, FILE_DEVICE_UNKNOWN, 0,
>> FALSE, &pDeviceObject);
>> if (STATUS_SUCCESS != Status)
>> goto SafeExit;
>> DbgPrint("Link created successfuly...\n");
>> DriverObject->DriverExtension->AddDevice= AddDeviceDispatch;
>> DriverObject->DriverUnload = UnloadDriver;
>> DriverObject->MajorFunction[IRP_MJ_SHUTDOWN]=
>> DriverObject->MajorFunction[IRP_MJ_CREATE] =
>> DriverObject->MajorFunction[IRP_MJ_CLOSE] =
>> DriverObject->MajorFunction[IRP_MJ_CLEANUP]=
>> DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL] = DefaultDispatch;
>> IoRegisterShutdownNotification( pDeviceObject );
>> SafeExit:
>> DbgPrint("DriverEntry retruns 0x%.8x\n", Status);
>> return Status;
>> }
>>
>> NTSTATUS AddDeviceDispatch(PDRIVER_OBJECT DriverObject, PDEVICE_OBJECT
>> PhysicalDeviceObject)
>> {
>> PDEVICE_OBJECT pSysDev;
>> for(pSysDev = DriverObject->DeviceObject; pSysDev!= NULL; pSysDev =
>> pSysDev->NextDevice)
>> pSysDev->Flags &= ~DO_DEVICE_INITIALIZING;
>> return STATUS_SUCCESS;
>> }
>>
>> NTSTATUS DefaultDispatch( IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp )
>> {
>> Irp->IoStatus.Status = STATUS_SUCCESS;
>> Irp->IoStatus.Information = 0;
>> IoCompleteRequest( Irp, IO_NO_INCREMENT );
>> return STATUS_SUCCESS; }
>>
>>
>> "Eliyas Yakub [MSFT]" wrote:
>>
>>
>>>Have you set an AddDevice routine in the DriverObject? Why don't you post
>>>your DriverEntry function?
>>>
>>>--
>>>--
>>>-Eliyas
>>>This posting is provided "AS IS" with no warranties, and confers no
>>>rights.
>>>http://www.microsoft.com/whdc/driver/default.mspx
>>>http://www.microsoft.com/whdc/driver/kernel/KB-drv.mspx
>>>
>>>
>
> --
> ../ray\..



Re: Problems unloading a driver by Maxim

Maxim
Wed Mar 16 14:03:34 CST 2005

> 3) Make sure you clear the DO_DEVICE_INITIALIZING before you return from
> DriverEntry. If you don't it will prevent others from opening handle to the

IIRC the OS itself clears DO_DEVICE_INITIALIZING on all DOs hanging off the
driver just after successful DriverEntry.

So, clearing DO_DEVICE_INITIALIZING is needed only in non-DriverEntry places
like PnP AddDevice.

--
Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
maxim@storagecraft.com
http://www.storagecraft.com



Re: Problems unloading a driver by Eliyas

Eliyas
Wed Mar 16 16:26:43 CST 2005

You are right.

--
-Eliyas
This posting is provided "AS IS" with no warranties, and confers no rights.
http://www.microsoft.com/whdc/hwdev/driver/kb-drv.mspx



Re: Problems unloading a driver by Doron

Doron
Wed Mar 16 22:54:13 CST 2005

also, if you registered for a shutdown notificatoin and you delete the
device object, the OS will automaticaly unregister you from that
notification.

d

--
Please do not send e-mail directly to this alias. this alias is for
newsgroup purposes only.
This posting is provided "AS IS" with no warranties, and confers no rights.


"Eliyas Yakub [MSFT]" <eliyasy@online.microsoft.com> wrote in message
news:uSE%23tcnKFHA.2716@TK2MSFTNGP15.phx.gbl...
> You are right.
>
> --
> -Eliyas
> This posting is provided "AS IS" with no warranties, and confers no
> rights.
> http://www.microsoft.com/whdc/hwdev/driver/kb-drv.mspx
>



Re: Problems unloading a driver by Nadav

Nadav
Thu Mar 17 08:49:03 CST 2005

Hi,

As Eliyas advised I referred to the 'src\general' sample provided with the
DDK (2600), I have choped and cut the Driver and left only the 'DriverEntry'
and 'DriverUnload' functions, surprisingly the driver worked, there was no
problem stopping it...
The driver I was previosly working on ( which didn't stop ) was created
using Numegas DriverWorks ( version 3.0 ) and was build as a Cpp project (
with exactly the same functions ).
Taking in mind what was just said, there must be some differences between
the two driver versions ( the one created by DriverWorks doesn't stop while
the one based on the cancel sample does stop ).
The only difference I have noticed was that the C++ Project generated by
DriverWorks included 'vdw.h' where common C++ collections are defined...
Does anyone encountered such a problem? Any resolution?
Is there anything that may be related to SP2 upgrades?

Any help comments or remarks would be appreciated.


FOLLOWING IS THE SRC\CACEL BASED DRIVER (STOPPABLE DRIVER)...

#include <ntddk.h>

VOID
CsampUnload(
IN PDRIVER_OBJECT DriverObject
)
{
PDEVICE_OBJECT deviceObject = DriverObject->DeviceObject;
DbgPrint("CsampUnload Enter\n");
IoDeleteDevice( deviceObject );
DbgPrint("CsampUnload Exit\n");
return;
}

NTSTATUS
DriverEntry(
IN PDRIVER_OBJECT DriverObject,
IN PUNICODE_STRING RegistryPath
)
{
NTSTATUSstatus = STATUS_SUCCESS;
PDEVICE_OBJECTdeviceObject;
DbgPrint("DriverEntry Enter\n");
status = IoCreateDevice(
DriverObject,
0,
NULL,
FILE_DEVICE_UNKNOWN,
0,
(BOOLEAN) FALSE,
&deviceObject
);
if (!NT_SUCCESS(status))
return status;
DbgPrint("DeviceObject %p\n", deviceObject);
DriverObject->DriverUnload = CsampUnload;
DbgPrint("DriverEntry Exit = %x\n", status);
return status;
}

ThanX in advance,
Nadav
http://www.sophin.com

"Eliyas Yakub [MSFT]" wrote:

> 1) For non pnp drivers, you shouldn't set AddDevice routine. If you do, you
> wouldn't be able to load or unload the driver using ServiceControl manager
> APIs.
>
> 2) Make sure you call IoUnregisterShutdownNotification in your unload
> routine. IoRegisterShutdownNotification takes a reference on the
> DeviceObject. If you don't unregister, it will prevent the device from being
> deleted and consequently prevent driver unload.
>
> 3) Make sure you clear the DO_DEVICE_INITIALIZING before you return from
> DriverEntry. If you don't it will prevent others from opening handle to the
> device or prevent other devices from attaching to you. I don't think it
> really has any affect on driver load.
>
> 4) Before you unload, set a bp on Unload routine and see it gets invoked. If
> it doesn't then most probably some body has a open handle to your device.
>
> There are few non pnp samples such as cancel, ioctl, event under src\general
> directory. Please follow that.
>
> --
> -Eliyas
> This posting is provided "AS IS" with no warranties, and confers no rights.
> http://www.microsoft.com/whdc/hwdev/driver/kb-drv.mspx
> "Ray Trent" <ratrent@nospam.nospam> wrote in message
> news:OXNUZ2kKFHA.1176@TK2MSFTNGP12.phx.gbl...
> > At shot in the dark:
> >
> > You don't have a PnP driver here (at least it looks that way), and so as
> > far as I know, your AddDevice routine isn't going to be called (is it?).
> >
> > As a result, your device's DO_DEVICE_INITIALIZING flag isn't being
> > cleared, and the service manager won't unload the driver if any if it's
> > devices are still initializing.
> >
> > Nadav wrote:
> >> Thanks for your immediate responce, the original DriverEntry could be
> >> seen in my original post, however, indeed the AddDevice routine wasn't
> >> set, I have set the AddDevice routine and still the problem persist, I
> >> keep getting the same "The requested control is not valid for this
> >> service"...
> >> following is a snap of my updated DriverEntry as you requested:
> >>
> >> NTSTATUS DriverEntry(IN PDRIVER_OBJECT DriverObject, IN PUNICODE_STRING
> >> RegistryPath) {
> >> NTSTATUS Status = STATUS_SUCCESS;
> >> PDEVICE_OBJECT pDeviceObject = NULL;
> >> Status = IoCreateDevice(DriverObject, 0, NULL, FILE_DEVICE_UNKNOWN, 0,
> >> FALSE, &pDeviceObject);
> >> if (STATUS_SUCCESS != Status)
> >> goto SafeExit;
> >> DbgPrint("Link created successfuly...\n");
> >> DriverObject->DriverExtension->AddDevice= AddDeviceDispatch;
> >> DriverObject->DriverUnload = UnloadDriver;
> >> DriverObject->MajorFunction[IRP_MJ_SHUTDOWN]=
> >> DriverObject->MajorFunction[IRP_MJ_CREATE] =
> >> DriverObject->MajorFunction[IRP_MJ_CLOSE] =
> >> DriverObject->MajorFunction[IRP_MJ_CLEANUP]=
> >> DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL] = DefaultDispatch;
> >> IoRegisterShutdownNotification( pDeviceObject );
> >> SafeExit:
> >> DbgPrint("DriverEntry retruns 0x%.8x\n", Status);
> >> return Status;
> >> }
> >>
> >> NTSTATUS AddDeviceDispatch(PDRIVER_OBJECT DriverObject, PDEVICE_OBJECT
> >> PhysicalDeviceObject)
> >> {
> >> PDEVICE_OBJECT pSysDev;
> >> for(pSysDev = DriverObject->DeviceObject; pSysDev!= NULL; pSysDev =
> >> pSysDev->NextDevice)
> >> pSysDev->Flags &= ~DO_DEVICE_INITIALIZING;
> >> return STATUS_SUCCESS;
> >> }
> >>
> >> NTSTATUS DefaultDispatch( IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp )
> >> {
> >> Irp->IoStatus.Status = STATUS_SUCCESS;
> >> Irp->IoStatus.Information = 0;
> >> IoCompleteRequest( Irp, IO_NO_INCREMENT );
> >> return STATUS_SUCCESS; }
> >>
> >>
> >> "Eliyas Yakub [MSFT]" wrote:
> >>
> >>
> >>>Have you set an AddDevice routine in the DriverObject? Why don't you post
> >>>your DriverEntry function?
> >>>
> >>>--
> >>>--
> >>>-Eliyas
> >>>This posting is provided "AS IS" with no warranties, and confers no
> >>>rights.
> >>>http://www.microsoft.com/whdc/driver/default.mspx
> >>>http://www.microsoft.com/whdc/driver/kernel/KB-drv.mspx
> >>>
> >>>
> >
> > --
> > ../ray\..
>
>
>