I'm writing a Windows kernel driver and i'm trying to implement the following.
Suppose the driver has been called from user mode via DeviceIoControl function with a specific IOCTL code. How can driver unload itself in this situation? In other words, how to achieve the same behavior as running net stop command?
More precisely, what should i write when implementing DispatchDeviceControl callback
NTSTATUS IoctlDeviceControl(PDEVICE_OBJECT pDeviceObject, PIRP pIrp) {
// some code...
switch (ioctlCode) {
case IOCTL_MY_UNLOAD: <---
...
}
return Status;
}
IoDeleteDevice(), but this functionality highly depends upon type of your driver. If you have a usermode app, you can use WIN32 apis to stop the service similar tonet stop, but done programatically. - Rohan