Need Restarting System after installation of driver??

Dear all,

I am new bee to these lists.
Now I am writing a driver which has just dummy “DriverEntry”,
“DriverUnload” and “AddDevice” functions.

When each time I add/remove driver, system is asking for restart.
Is it compulsory to restart my system each and every time when I do
Add/Remove my driver?
Is there any other way to do this without restating?

Thanks in advance,
Regards,
Ramya

The answer is: bad INF file.

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

----- Original Message -----
From: “Ramya Desai”
To: “Windows System Software Devs Interest List”
Sent: Thursday, February 10, 2005 12:44 PM
Subject: [ntdev] Need Restarting System after installation of driver??

> Dear all,
>
> I am new bee to these lists.
> Now I am writing a driver which has just dummy “DriverEntry”,
> “DriverUnload” and “AddDevice” functions.
>
> When each time I add/remove driver, system is asking for restart.
> Is it compulsory to restart my system each and every time when I do
> Add/Remove my driver?
> Is there any other way to do this without restating?
>
> Thanks in advance,
> Regards,
> Ramya
>
> —
> Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256
>
> You are currently subscribed to ntdev as: xxxxx@storagecraft.com
> To unsubscribe send a blank email to xxxxx@lists.osr.com

Did you implement a PNP dispatch routine? Do you handle
IRP_MN_QUERY_REMOVE_DEVICE and IRP_MN_REMOVE_DEVICE pnp irps? You must
handle these to be able todo a no reboot restart.

d

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Ramya Desai
Sent: Thursday, February 10, 2005 1:45 AM
To: Windows System Software Devs Interest List
Subject: [ntdev] Need Restarting System after installation of driver??

Dear all,

I am new bee to these lists.
Now I am writing a driver which has just dummy “DriverEntry”,
“DriverUnload” and “AddDevice” functions.

When each time I add/remove driver, system is asking for restart.
Is it compulsory to restart my system each and every time when I do
Add/Remove my driver?
Is there any other way to do this without restating?

Thanks in advance,
Regards,
Ramya


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: xxxxx@windows.microsoft.com
To unsubscribe send a blank email to xxxxx@lists.osr.com

yes there is a way to get around this - implement support for
IRP_MJ_PNP/IRP_MN_REMOVE_DEVICE.

In AddDevice you’re attaching a device object to the device stack.
However you haven’t yet provided any code that PNP can call to remove
you from that device stack. When you try to disable or uninstall the
device, PNP can’t tear down the device stack because of this and tells
you that you’ll need to reboot to get the device out of the system.

-p

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Ramya Desai
Sent: Thursday, February 10, 2005 1:45 AM
To: Windows System Software Devs Interest List
Subject: [ntdev] Need Restarting System after installation of driver??

Dear all,

I am new bee to these lists.
Now I am writing a driver which has just dummy “DriverEntry”,
“DriverUnload” and “AddDevice” functions.

When each time I add/remove driver, system is asking for restart.
Is it compulsory to restart my system each and every time
when I do Add/Remove my driver?
Is there any other way to do this without restating?

Thanks in advance,
Regards,
Ramya


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as:
xxxxx@windows.microsoft.com To unsubscribe send a blank
email to xxxxx@lists.osr.com

Dear all,
Thanq for the response I got for my mail.

I haven’t implemented any PNP in my driver.
Here I am attaching my driver code with this mail.

One more thing I want to ask you is, when I am giving device type as
“unknown” in inf file, windows (2000) is not asking for restart. But I
can not see the driver in device manager. Is it a strange behavior???

I am attaching my inf file along with driver file.

Thanks n regards,
Ramya.

$$$$$$$$$ Driver code $$$$$$$$$$$$$$$$

#include <wdm.h>
NTSTATUS MyAddDevice(IN PDRIVER_OBJECT DriverObject, IN PDEVICE_OBJECT pdo);
VOID DriverUnload(IN PDRIVER_OBJECT fdo);
///Driver Entery

NTSTATUS DriverEntry( IN PDRIVER_OBJECT DriverObject, IN
PUNICODE_STRING RegistryPath )
{

DbgPrint (“MyDrv: Entered Driver Entry\n”);
DbgPrint (“MyNDrv: Entered Driver Entry2\n”);

// Initialize Function Pointers

DriverObject->DriverUnload = DriverUnload;
DriverObject->DriverExtension->AddDevice = ESNAddDevice;

return STATUS_SUCCESS;
}
// DriverUnload

VOID DriverUnload(IN PDRIVER_OBJECT DriverObject)
{ DbgPrint (“MyDrv: Entered Driver Unload\n”);
} // DriverUnload

// AddDevice
NTSTATUS MyAddDevice(IN PDRIVER_OBJECT DriverObject, IN PDEVICE_OBJECT
DeviceObject)
{
// PAGED_CODE();

NTSTATUS status;
UNICODE_STRING ntDeviceName;
PDEVICE_OBJECT DeviceObject1 = NULL;

// Create a functional device object to represent the hardware we’re managing.

DbgPrint (“MyDrv: Entered Add Device\n”);
DbgPrint (“MyDrv: Entered Add Device2\n”);

RtlInitUnicodeString(&ntDeviceName, L"\Device\MyDummy");

status = IoCreateDevice(DriverObject,
1,
&ntDeviceName,
FILE_DEVICE_UNKNOWN,
0,
FALSE,
&DeviceObject1
);

if(!NT_SUCCESS(status))
DbgPrint (“MyDrv: IoCreateDevice() fails %x \n”,status);
else
DbgPrint (“MyDrv: IoCreateDevice() success\n”);

return status;

}
$$$$$$$$$$$$ End of driver code $$$$$$$$$$$$$$$$$$$$$

$$$$$$$$$$$$$$ inf code starts$$$$$$$$$$$$$$$$$$$$$$$$$$

; Driver.inf
;
; Installation file (.inf) for the Example Driver to Test device.
;
; (c) Copyright 2005 My Tech
;

[Version]
Signature=“$Windows NT$”
Provider=%My%
;ClassGUID={4d36e978-e325-11ce-bfc1-08002be10888}
Class=unknown ;if I gave some other name (like…myDDrv) windows is
asking for reboot.
DriverVer=02/08/2005

[DestinationDirs]
DefaultDestDir = 12

;
; Driver information
;

[Manufacturer]
%My% = My.Mfg

[My.Mfg]
%My.DeviceDesc0% = Driver,

;
; General installation section
;

[Driver]

;
; File sections
;

;
; Service Installation
;

[Driver.Services]
AddService = Driver, 0x00000002 , Driver_Service_Inst, Driver_EventLog_Inst

[Driver_Service_Inst]
ServiceType = 1 ; SERVICE_KERNEL_DRIVER
StartType = 3 ; SERVICE_DEMAND_START
ErrorControl = SERVICE_ERROR_NORMAL ; SERVICE_ERROR_IGNORE
ServiceBinary = %10%\System32\Drivers\Driver.sys

[Driver_EventLog_Inst]
AddReg = Driver_EventLog_AddReg

[Driver_EventLog_AddReg]
HKR,EventMessageFile,0x00020000,“%SystemRoot%\System32\IoLogMsg.dll;%SystemRoot%\System32\drivers\Driver.sys”
HKR,TypesSupported,0x00010001,7

[ClassInstall32]
AddReg=My_addreg

[My_addreg]
HKR,%My%
HKR,Installer32,“Desk.Cpl,DisplayClassInstaller”
HKR,Icon,“-1”

;
; Source file information
;

[SourceDisksNames]
1=“Driverexample build directory”,

[SourceDisksFiles]
driver.sys=1,objchk\i386<br>
[Driver]
CopyFiles=@Driver.sys,%COPYFLG_NOSKIP%
CopyFiles=@Driver.cat

[Strings]

;
; Non-Localizable Strings
;

REG_SZ = 0x00000000
REG_MULTI_SZ = 0x00010000
REG_EXPAND_SZ = 0x00020000
REG_BINARY = 0x00000001
REG_DWORD = 0x00010001
SERVICEROOT = “System\CurrentControlSet\Services”

;
; Localizable Strings
;

My.DeviceDesc0 = “Example Driver to Test”
DiskId1 = “My Tech Installation Disk #1 (My)”
My = “My Tech”</wdm.h>

Ramya.

To get started, Pls Check out CD Samples and explanations from
“Programming the Microsoft windows driver model” by Walter oney, which
has Good examples on how pnp works…Chapter on Inf is also
given…Reading this will clear most of your doubts…

Thanks,

Shiva P

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Ramya Desai
Sent: Friday, February 11, 2005 10:52 AM
To: Windows System Software Devs Interest List
Subject: Re: [ntdev] Need Restarting System after installation of
driver??

Dear all,
Thanq for the response I got for my mail.

I haven’t implemented any PNP in my driver.
Here I am attaching my driver code with this mail.

One more thing I want to ask you is, when I am giving device type as
“unknown” in inf file, windows (2000) is not asking for restart. But I
can not see the driver in device manager. Is it a strange behavior???

I am attaching my inf file along with driver file.

Thanks n regards,
Ramya.

$$$$$$$$$ Driver code $$$$$$$$$$$$$$$$

#include <wdm.h>
NTSTATUS MyAddDevice(IN PDRIVER_OBJECT DriverObject, IN PDEVICE_OBJECT
pdo);
VOID DriverUnload(IN PDRIVER_OBJECT fdo);
///Driver Entery

NTSTATUS DriverEntry( IN PDRIVER_OBJECT DriverObject, IN
PUNICODE_STRING RegistryPath )
{

DbgPrint (“MyDrv: Entered Driver Entry\n”);
DbgPrint (“MyNDrv: Entered Driver Entry2\n”);

// Initialize Function Pointers

DriverObject->DriverUnload = DriverUnload;
DriverObject->DriverExtension->AddDevice = ESNAddDevice;

return STATUS_SUCCESS;
}
// DriverUnload

VOID DriverUnload(IN PDRIVER_OBJECT DriverObject)
{ DbgPrint
(“MyDrv: Entered Driver Unload\n”);
} //
DriverUnload

// AddDevice
NTSTATUS MyAddDevice(IN PDRIVER_OBJECT DriverObject, IN PDEVICE_OBJECT
DeviceObject)
{

// PAGED_CODE();

NTSTATUS status;
UNICODE_STRING ntDeviceName;
PDEVICE_OBJECT DeviceObject1 = NULL;

// Create a functional device object to represent the hardware
we’re managing.

DbgPrint (“MyDrv: Entered Add Device\n”);
DbgPrint (“MyDrv: Entered Add Device2\n”);

RtlInitUnicodeString(&ntDeviceName, L"\Device\MyDummy");

status = IoCreateDevice(DriverObject,
1,
&ntDeviceName,

FILE_DEVICE_UNKNOWN,
0,
FALSE,
&DeviceObject1
);

if(!NT_SUCCESS(status))
DbgPrint (“MyDrv: IoCreateDevice() fails %x
\n”,status);
else
DbgPrint (“MyDrv: IoCreateDevice() success\n”);

return status;

}
$$$$$$$$$$$$ End of driver code $$$$$$$$$$$$$$$$$$$$$

$$$$$$$$$$$$$$ inf code starts$$$$$$$$$$$$$$$$$$$$$$$$$$

; Driver.inf
;
; Installation file (.inf) for the Example Driver to Test device.
;
; (c) Copyright 2005 My Tech
;

[Version]
Signature=“$Windows NT$”
Provider=%My%
;ClassGUID={4d36e978-e325-11ce-bfc1-08002be10888}
Class=unknown ;if I gave some other name (like…myDDrv) windows is
asking for reboot.
DriverVer=02/08/2005

[DestinationDirs]
DefaultDestDir = 12

;
; Driver information
;

[Manufacturer]
%My% = My.Mfg

[My.Mfg]
%My.DeviceDesc0% = Driver,

;
; General installation section
;

[Driver]

;
; File sections
;

;
; Service Installation
;

[Driver.Services]
AddService = Driver, 0x00000002 , Driver_Service_Inst,
Driver_EventLog_Inst

[Driver_Service_Inst]
ServiceType = 1 ; SERVICE_KERNEL_DRIVER
StartType = 3 ; SERVICE_DEMAND_START
ErrorControl = SERVICE_ERROR_NORMAL ; SERVICE_ERROR_IGNORE
ServiceBinary = %10%\System32\Drivers\Driver.sys

[Driver_EventLog_Inst]
AddReg = Driver_EventLog_AddReg

[Driver_EventLog_AddReg]
HKR,EventMessageFile,0x00020000,“%SystemRoot%\System32\IoLogMsg.dll;%Sy
stemRoot%\System32\drivers\Driver.sys”
HKR,TypesSupported,0x00010001,7

[ClassInstall32]
AddReg=My_addreg

[My_addreg]
HKR,%My%
HKR,Installer32,“Desk.Cpl,DisplayClassInstaller”
HKR,Icon,“-1”

;
; Source file information
;

[SourceDisksNames]
1=“Driverexample build directory”,

[SourceDisksFiles]
driver.sys=1,objchk\i386<br>
[Driver]
CopyFiles=@Driver.sys,%COPYFLG_NOSKIP%
CopyFiles=@Driver.cat

[Strings]

;
; Non-Localizable Strings
;

REG_SZ = 0x00000000
REG_MULTI_SZ = 0x00010000
REG_EXPAND_SZ = 0x00020000
REG_BINARY = 0x00000001
REG_DWORD = 0x00010001
SERVICEROOT = “System\CurrentControlSet\Services”

;
; Localizable Strings
;

My.DeviceDesc0 = “Example Driver to Test”
DiskId1 = “My Tech Installation Disk #1 (My)”
My = “My Tech”


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: xxxxx@wipro.com
To unsubscribe send a blank email to xxxxx@lists.osr.com</wdm.h>

(1) One more thing. When Windows completely removes your Device you get
your Unload callback in your driver called as the last thing. You then have
handled all the Pnp stuff, have no outstanding irps. Also after the Unload
you can then install a new version of your driver without a reboot.
(2) Also checkout your setupapi.log in the %systemroot% subdir.
(3) Also their is a way to make the logging verbose for installation and
removal of drivers and hence showing more in setupapi.log

Thanks
Mike Jones

“Ramya Desai” wrote in message news:xxxxx@ntdev…
> Dear all,
>
> I am new bee to these lists.
> Now I am writing a driver which has just dummy “DriverEntry”,
> “DriverUnload” and “AddDevice” functions.
>
> When each time I add/remove driver, system is asking for restart.
> Is it compulsory to restart my system each and every time when I do
> Add/Remove my driver?
> Is there any other way to do this without restating?
>
> Thanks in advance,
> Regards,
> Ramya
>