Sunstorm Labs Blog

March 20, 2008

Vista SP1 “Unauthorized Changes”

Filed under: Windows — Tags: — admin @ 4:59 pm

I left Windows Update installing Vista SP1 today, however, instead of a nice and upgraded system, I got locked out of my computer with this lovely message:

[Window Title]<br />
Windows software protection</p>
<p>[Main Instruction]<br />
An unauthorized change was made to Windows.</p>
<p>[Content]<br />
Windows has discovered a change that will result in limited Windows functionality. Use the link below to find out how to fix Windows.</p>
<p>[Learn more online] [Close]

Vista screwed itself over

Clicking on Learn More Online took me Microsoft’s Genuine Advantage validation site, which happily reported that my copy of Vista isn’t genuine, with error code 0xc004d401. It was convinced that I had some kind of incompatible software that was interfering with validation, and gave me a list of anti-virus and malware checker programs that have been known to cause this problem. Obviously, I had none of them, or at all, ever.

It turns out that this was caused by Vista hosing itself while trying to update to SP1. I’m not sure if it’s caused specifically by SP1, or any of the updates that I installed before SP1, but actually getting SP1 to install fixes the problem. Microsoft’s suggestion to reboot into safe mode won’t help, because you can run neither WGA, or Windows Update from there. Luckily, It doesn’t take much to circumvent the lockout.

  1. Click on Learn More Online
  2. Type in “file:///c:”, without the quotes. This will get you into Explorer.
  3. Use the Folders pane to navigate to the Control Panel, at the bottom.
  4. Use the little arrow to expand it, and open Windows Update.
  5. Check for updates. If you have SP1 waiting for you, download and install.

If that doesn’t work for you, or SP1 doesn’t show up as an update, then you likely have a different problem. You can still make life easier for yourself by navigating to the Windows directory and from there launching Explorer.exe, which will give you your desktop back. Some things will be disabled, and you’ll have a memory quota that’ll only allow you to launch two or three programs at a time, but it’ll make troubleshooting a bit less painful.

I installed SP1 and the problem went away, and Windows validates fine now. I was tipped off to a failed SP1 install being the culprit, because there was a task in the Task Scheduler that called for a “HitmanSp1.exe” (which didn’t exist) to be launched. Microsoft, your killers fail again!

March 14, 2008

register_shutdown_function after all the other register_shutdown_functions

Filed under: PHP — Tags: — admin @ 4:35 pm

PHP’s register_shutdown_function lets me run code after it finishes running the script, be that naturally or forcibly. This makes it a perfect fit for a whole bunch of things, like running maintenance database queries or showing debugging information.

function do_maintenance()
{
  $db-&gt;doSomeQueries();
}
 
function debug_write()
{
  echo 'some debugging information';
}
 
// Last things to execute
register_shutdown_function( 'do_maintenance' );
register_shutdown_function( 'debug_write' );

There’s one caveat, and it’s explained in the PHP documentation:

Multiple calls to register_shutdown_function() can be made, and each will be called in the same order as they were registered.

(more…)

March 7, 2008

How to get a (non-visual) ComponentModel.Component’s parent Form or Control

Filed under: C# — Tags: , — admin @ 10:40 am

I recently ran into the need to get the reference of the parent form of a Component that I was creating. The problem is that Components, unlike Controls, don’t have a Parent property, nor any other simple way of getting it. I’ve browsed around for solutions, but I could only find vague references to what needed to be done. Most solutions simply suggested that I simply create a public property, that I then set manually in the parent Control. One article came close, but it didn’t work. It did however point me towards looking into the ErrorProvider component, which does exactly this.

I found the solution by looking through it’s source code. We still expose a public property, however, instead of setting it manually, we can simply instruct Visual Studio to set the property for us, when it generates the designer code for any component we put it into.

private ContainerControl parentControl;
public ContainerControl ParentControl
{
    get { return parentControl; }
    set { parentControl = value; }
}
 
public override ISite Site
{
    set
    {
        base.Site = value;
        if (value == null)
            return;
 
        IDesignerHost host = (IDesignerHost)value.GetService( typeof( IDesignerHost ) );
        if (host != null)
        {
            IComponent baseComp = host.RootComponent;
 
            if (baseComp is ContainerControl)
                this.ContainerControl = (ContainerControl)baseComp;
        }
    }
}

(more…)

Powered by WordPress