Dear Gurus,
I've created a windows service using VB 2005. This windows service will check and determine whether a dongle is attached to the computer. For your information, a dongle is a usb device which contains encrypted information. Dongle is usually used to counter software piracy problems. Usually a software which implements this kind of security measures will fail to operate if the dongle is being detached from the system.
So my windows service will check to see if the dongle is still attached to the system on a fixed interval. If the dongle is not attached, then the windows service will shut down the SQL Server database engine. By shutting down the database engine, my other software which is a point-of-sales system will not be able to connect to the database and ultimately fail to function properly. In other words, I do not want anyone to be able to use the point-of-sales system without a dongle attached to their system.
Well, my windows service is doing its job well except for a tiny problem. If the user is able to identify the name of my service, he or she can actually stop or disable my service from the Services Management Console accessible from Control Panel -> Administrative Tools. However, in order to counter this, I've added a piece of code in the OnStop() event of my windows service by instructing it to shut down the computer where the database engine resides. Although it's not elegant, but it serves its purpose.
However, this is where the main problem comes into the picture. A user can actually press CTRL+ALT+DEL to bring up the Windows Task Manager and locate the executable file which my windows service runs on, and hit the End Process button. Poof!!! My windows service is terminated without even triggering the OnStop() event. Without the windows service running, the point-of-sales system can be used even without a dongle attached. This is not something that I want. Although I must admit that it will be very difficult for a user to identify the executable file of my windows service, unless i tell him/her, but I do not want to rule out the possibility that a user will know how to shut down the security measure that I have taken in the future.
I know that there are some processes in the Windows Task Manager which belong to the operating system such as "System". This type of processes can't be "End Process". Is there anyway that I can make my windows service to behave like that? I have tried making my service running under accounts such as LocalService, NetworkService, LocalSystem and User but to no avail.
Is there anyway that I can disallow my Windows Service from stopping or being terminated? Even if that can't be helped, is there anyway for my windows service in its last attempt to shut down the whole system when being hit the "End Process" button? Please don't suggest that I implement the dongle check inside the point-of-sales system as I do not have the source codes for that system.
Please help, I'm really stranded on this one.
Start Free Trial