Today I attended a code clinic about programming Windows Vista. I like attending the Microsoft learning events because they are free and the cross-section of talents are comfortable. There are some real old-timers that do Windows platform programming. They're fun people.
Anyway, one thing that I took from that talk was about how Vista handles registry access. In the past, if your application did not have permission to make registry changes, it would get an error. Now, Vista creates an isolated, virtual, registry for your application. This gives your application the impression of it working properly, and for the most part, it's correct. In my case, though, it's not.
I program middleware Windows Services that make use of .NET Remoting. To manage the services, I create a manager application that is available from the task tray. You've seen something like this with SQL Server Manager, if you do SQL Server programming.
So I figured out how to make my service run with elevated privileges, so now it runs with full-control as Local System. That was a great triumph. Alas, though, the service manager runs as the local user account. This has some unfortunate side effects.
From my service manager, I have a UI to make runtime configuration changes to the service it controls. The manager does this by writing to the registry. Because it is using LUA (local user access), it can't write to the real registry, so Vista lets it write to the "virtual" registry. So there I am thinking that I am fixing my configuration problem with the service, but darn if it just doesn't seem to work when I restart the service. That's because my service is reading its config from the real registry while my service manager reads it from the virtual registry.
The next time you develop a service manager that controls a service, remember to isolate all configuration changes in the service and not the service manager. The manager should just request changes in the process space of the service and not the manager.
I am yet to figure out how to make my service manager run as the administrator. I think it needs to be signed with my PFX file. Hopefully that solves the problem...
Anyway, one thing that I took from that talk was about how Vista handles registry access. In the past, if your application did not have permission to make registry changes, it would get an error. Now, Vista creates an isolated, virtual, registry for your application. This gives your application the impression of it working properly, and for the most part, it's correct. In my case, though, it's not.
I program middleware Windows Services that make use of .NET Remoting. To manage the services, I create a manager application that is available from the task tray. You've seen something like this with SQL Server Manager, if you do SQL Server programming.
So I figured out how to make my service run with elevated privileges, so now it runs with full-control as Local System. That was a great triumph. Alas, though, the service manager runs as the local user account. This has some unfortunate side effects.
From my service manager, I have a UI to make runtime configuration changes to the service it controls. The manager does this by writing to the registry. Because it is using LUA (local user access), it can't write to the real registry, so Vista lets it write to the "virtual" registry. So there I am thinking that I am fixing my configuration problem with the service, but darn if it just doesn't seem to work when I restart the service. That's because my service is reading its config from the real registry while my service manager reads it from the virtual registry.
The next time you develop a service manager that controls a service, remember to isolate all configuration changes in the service and not the service manager. The manager should just request changes in the process space of the service and not the manager.
I am yet to figure out how to make my service manager run as the administrator. I think it needs to be signed with my PFX file. Hopefully that solves the problem...