My PKB

Entries from January 2008

How to programmatically set the processor affinity of an application - Updated

January 8, 2008 · 1 Comment

A few months back I wrote a post explaining how to set the processor affinity of an application using a little free utility called process.exe. Soon after, our new antivirus software (NOD32) flagged process.exe as a threat, removed it, and prevented me from reinstalling it. I had to look for another solution and discovered Microsoft Application Compatibility Toolkit 5.0.

As an example, I’ll show you how to set the processor affinity of Microsoft Word to force it to use only 1 processor on a dual core system:

1. Download and install Microsoft Application Compatibility Toolkit 5.0 (you need Application Compatibility Toolkit.msi)

2. Go to Start>Programs>Microsoft Application Compatibility Toolkit 5.0 and click on Compatibility Administrator. The following window appears (click to enlarge):

Compatibility Administrator window

 

3. Right-click on New Database(1)[Untitled_1] and select Create New>Application Fix:

Application Fix

 

4. Complete the Program information page and click Next. Note that the name of the program and the name of the vendor can be anything you want, only the path to the exe has to be exact:

Create new Application Fix

 

5. Because we are only interested in setting the processor affinity, select None on the Compatibility Modes page and then click Next:

Compatibility Modes

 

6. This is the page we are interested in. Scroll down to select SingleProcAffinity in the list of compatibility fixes, then click Next:

Create new Application Fix

 

7. Do not change any settings on the last page unless you know what you are doing. Just click Finish:

Create new Application Fix

 

8. Click on File>Save. First give a name to your database:

Save Database

Then save the actual database file:

Save Database file

 

9. Finally, install the fix by right-clicking the name of your database and selecting Install:

Install Fix

 

10. Done! You can now close the Compatibility Administrator. Next time you launch Word, it will only use one CPU.

Categories: Fix · Software
Tagged: , ,

How to add SATA drivers offline to a WIM image of Windows XP

January 7, 2008 · 6 Comments

I have been using ImageX to create WIM images of Windows XP for some time now. After imaging a Toshiba A9 laptop with an image created on a Toshiba A8, Windows XP failed to boot, displaying instead the dreaded Stop Error 0×0000007B INACCESSIBLE_BOOT_DEVICE. To quote the Microsoft knowledge base article: “This error may occur if the registry entries and the drivers for the mass storage controller hardware in the backup computer are not installed in Windows XP.” In other words, Windows doesn’t have the SATA drivers needed to communicate with the hard disk. The next step is usually to:

  1. Download the necessary drivers
  2. Copy the drivers to a floppy disk
  3. Run a repair install of XP
  4. Press F6 when prompted during Setup to install the drivers
  5. Run Sysprep
  6. Recapture an image that will now have the necessary drivers installed

This time however, I decided to take advantage of ImageX’s ability to easily mount a WIM image for offline editing. So here is what I did (be aware that this is a hack, it worked for me but there’s no guarantee that it’ll work for you):

  1. Downloaded and extracted the needed SATA drivers from the Toshiba website. The archive contains 6 files: iaahci.cat, iaahci.inf, iastor.cat, iastor.inf, iaStor.sys, and TXTSETUP.OEM.
  2. Mounted the WIM image of Windows XP to an empty folder (C:\Mount) using the command:
    imagex /mountrw C:\PathToYourWIMImage\WindowsXP.wim 1 C:\Mount
  3. Followed the instructions on this thread to copy the driver files where they belong:
    • Copied the .inf files (iaahci.inf and iastor.inf) to C:\Mount\Windows\inf
    • Copied the .sys file (iaStor.sys) to C:\Mount\Windows\system32\drivers
    • Copied all remaining files (iaahci.cat, iastor.cat, iaStor.sys, and TXTSETUP.OEM) to C:\Mount\Windows\system32

    • Loaded the HKEY_LOCAL_MACHINE\SYSTEM hive of the mounted image in the registry:
      • Opened the Registry Editor (type regedit at the command prompt)
      • Selected the HKEY_LOCAL_MACHINE hive
      • Clicked on File>Load Hive and selected C:\Mount\Windows\system32\config\system
      • Named the loaded hive Temp (it can be named anything you want)
    • In Notepad, created a .reg file (SATA_Keys.reg for example) to import the appropriate settings into the mounted hive (click on the picture to download SATA_Keys.doc that you’ll have to rename SATA_Keys.reg):
    Registry File

    How do you come up with this file? Well again, this thread helped a lot, as did that one.  Basically you have to open the .inf files (iaahci.inf and iastor.inf) and locate:

    • the ClassGUID entry in the [version] section.
    • the PCI\VEN entries in the [ControlFlags] section
    • the AddService value in the [iaStor_Inst.Services] section in this case.

    If you look back at the .reg file, you’ll notice that the first 6 keys, derived from iaahci.inf, all have the same ClassGUID, only the PCI\VEN values change. The next 6, derived from the other .inf file (iastor.inf), share a different ClassGUID. Finally, both .inf files refer to the same service (iaStor) which has to be added. Note that in this example, the hexadecimal value of ImagePath means “system32\drivers\iaStor.sys”.

    6.   Double-clicked the .reg file to merge the settings in the registry

    7.   Unloaded the Temp hive (File>Unload Hive)

    8.   Unmounted the WIM image without forgetting the /commit switch (or all the changes would be lost):

    imagex /unmount C:\Mount /commit

    9.   Reimaged the laptop which booted just fine and installed the SATA drivers from within the OS to ensure proper installation.

    Categories: Imaging · Software
    Tagged: , , , ,