Installing MyTomTom (TomTom HOME) on Windows XP x64

April 27, 2012

For my sins, I run Windows XP x64 on my main desktop.  One day I’ll jump on the Windows 7 bandwagon, I promise.  While recent improvements with Windows 7’s x64 editions (and the removal of x86 versions from the Windows Server range) has led to more hardware/software vendors writing with x64 in mind, from time to time I’m still left with devices that are not supported.

Case in point, my TomTom GPS device recently decided to pack up and stop working, thanks to a leap-year bug which prevented it getting a GPS signal (really? We’ve only had leap years for about 2,050 years, now).  And so a mandatory update was forced on me, which required me to connect it to my computer for the first time in—er—ever.  And would their updating software install?  Would it bollocks.

Four hours later, I’ve got a working Vista x86 VM running (it was the only 32-bit DVD I had! I’m amazed it still worked with all those coffee cup rings on it), and am installing the TomTom software, when I notice it take a lot longer on one particular step than it did before.  And that step was the running of DriverPreInstall.exe.  Which was in a folder named win32 (in particular, %PROGRAMFILES%\MyTomTom 3\Driver\win32\DriverPreInstall.exe).  This got me wondering, was there a matching win64 folder?  So I went looking and, lo and behold, there was (specifically, %PROGRAMFILES(x86)%\MyTomTom 3\Driver\x64\DriverPreInstall64.exe).

So I ran that DriverPreInstall64.exe file and it told me that it was missing a DLL.  That DLL was DIFxAPI.dll, and it’s part of the Windows Driver Kit (freely downloadable from Microsoft). 

This comes down as a 600MB ISO file, which you can open with most compression tools (like 7-zip).  Open that ISO file and navigate to the WDK folder, then open the dfx_x64fre_cab001.cab file (also in 7-Zip). There, in that archive, there is a file called _DIFxAPI.dll_00000. Drag that file into the %PROGRAMFILES(x86)%\MyTomTom 3\Driver\x64 folder and rename it to DIFxAPI.dll.

Now, run the DriverPreInstall64.exe file and the driver will install. You’ll get the standard warning about the driver not being certified, but you can continue anyway without issue. Now you can connect the TomTom up to the computer by the USB cable and it should install properly. If not, open Device Manager, right-click the TomTom node (it will probably have a question mark against it) and choose Update Driver. The driver should install (it may prompt you again with the certification warning).

Now you should be able to open the MyTomTom3 software (either via the Start Menu or by running the MyTomTomSA.exe directly), and Robert’s your mother’s brother.

Alternative to %RANDOM% in Windows batch files

January 3, 2012

So, it turns out, the %RANDOM% environment variable isn’t random. It’s very much time based. On my XP box, it appears to generate a number that changes every second. What’s worse is that it’s very much deterministic — in most cases, the generated number will be 13 greater than the last number generated.

Not that I was using it for anything crypto-related, you understand, but the time-based thing does present a problem if you are using it in Scheduled Tasks. Particularly if you are using it to create unique, random temporary file names in two Scheduled Tasks that run at the same time.

Of course, this isn’t news. It’s an old new thing. But it was new to me and caused me to screw something up that I shouldn’t have and so on and so forth

Instead, we should pull random data from the system entropy, akin to *NIX’s /dev/random device. After doing some digging, it appears that what *NIX ‘stores’ in /dev/random, Windows ‘stores’ in the registry, a binary Seed value in the HKEY_LOCAL_MACHINE\Software\Microsoft\Cryptography\RNG key. Of course it does.

We can get to that in Windows batch files, with the REG.EXE command-line utility, usually found in the C:\Windows\system32 folder):

"%SYSTEMROOT%\system32\reg.exe" query HKLM\Software\Microsoft\Cryptography\RNG /v Seed

That gets us some version info and the binary data, in some nicely-formatted table, e.g…

! REG.EXE VERSION 3.0

HKEY_LOCAL_MACHINE\software\microsoft\cryptography\rng
    Seed        REG_BINARY      CC577B9D245DB08D34EC20C75B80CDF36822ACFB13F3FAD640F426948F5A05F1E9C956A8DB58F565CC6A1D2A947F93B38DA425D02D49BF30622FD8E7CFDBF63366A2357361C76ABA68720A04F28E7C4D

…which we can parse with FOR /f and convert to a similar 0-32767, like so:

FOR /f "usebackq tokens=3 skip=4" %%A IN (`"%SYSTEMROOT%\system32\reg.exe" query HKLM\Software\Microsoft\Cryptography\RNG /v Seed`) DO SET RND=%%A
SET /a RND=0x%RND:~0,4% %% 32768

The environment variable %RND% now contains a random number.

If you need a large quantity of random numbers, you may be concerned with repeated calls depleting the system entropy pool. This is a possibility, of course, but may be mitigated by keeping the last retrieved entropy data in an environment variable, extracting the first two bytes when you need to, removing those bytes from the data and refilling the entropy variable when it is empty. Something like this should do the trick

:get_random
IF NOT DEFINED ENTROPY FOR /f "usebackq tokens=3 skip=4" %%A IN (`"%SYSTEMROOT%\system32\reg.exe" query HKLM\Software\Microsoft\Cryptography\RNG /v Seed`) DO SET ENTROPY=%%A
SET /a RND=0x%ENTROPY:~0,4% %% 32768
SET ENTROPY=%ENTROPY:~4%
GOTO :EOF

Of course, this doesn’t seem to work on Windows Server 2008 R2 (surprise, surprise), as the HKLM...RNG\Seed value does not seem to exist in the registry (or at least cannot be read by REG.EXE), so I expect that means it doesn’t work in Vista or Win7, either. The closest alternative is the Seed value in the HKLM\System\RNG key, but that does not seem to update after reading, so is next to useless for this purpose.

The only alternative I have in Windows Server 2008 R2 is to invoke PowerShell (which is installed by default on our builds) to get a similar binary value, instead of REG.EXE. While you could instantiate an RNGCryptoServiceProvider object and call GetBytes on a suitably large byte array, it may just be sufficient to invoke Guid.NewGuid one or more times, instead (remembering to escape parentheses properly):

FOR /f "usebackq" %%A IN (`"%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\powershell.exe" -Command [System.Guid]::NewGuid^(^).ToString^('N'^)`) DO SET RND=%%A

That said, if you have PowerShell, you might want to consider doing your script in that instead, if you can get past its awful, awful syntax…

Uninstalling SQL Server 2008 fails with “Value cannot be null. Parameter name: sddlForm”

August 15, 2011

I came across this annoying error while trying to remove SQL Server 2008 from our Windows XP desktop Sysprep image.  I found a Microsoft Connect article which gave some brief but ultimately unhelpful advice relating to an error reading the Group SID when uninstalling FileStream.

That said, it did get me on to FileStream.  Looking through the Detail.txt file in the relevant dated subfolder of the C:\Program Files\Microsoft SQL Server\100\Setup Bootstrap\Log folder, I could see that the error was due to the uninstaller trying to remove permissions on the FileStream share that was created when I installed SQL Server 2008, originally.  From Administrative Tools >> Computer Management >> Shared Folders >> Shares, I tried to add the correct group permissions to the {INSTANCENAME} FileStream share, but it didn’t seem to make any difference to the uninstaller.

In the end, I got around it by editing the registry.  Opening regedit.exe from the Start >> Run window, I browsed to my instance’s registry branch, at HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server\MSSQL10.{INSTANCENAME}\MSSQLServer and renamed the FileStream key to something arbitrary (I used “__FileStream“, but I expect you could use anything the installer wasn’t expecting).

Now when I ran the uninstaller, it couldn’t find the necessary registry branch, so assumed FileStream was uninstalled, skipped right over the step and completed successfully.  Then, I right-clicked the {INSTANCENAME} share in Computer Manager and clicked “Stop Sharing”.

I will post if I experience any issues with the desktop image, having performed this workaround.  In the meantime, hope this helps someone out there.

Redirection of command output — a scrollable alternative to |more

July 30, 2009

I’m sure many Linux people already know this, but I discovered it today and figured I’d keep it on hand for when I need it again (that’s what this blog is for, after all).  I knew it was possible to redirect output to a file using >, redirect input from a file using < and chain the output of one command as the input of another using | but I didn’t know it was possible to redirect the output of a command (or series of commands) using <(...) too.

I’m used to doing things like ls -lrt | more to page the results of a directory listing, for example, but as a Windows user, I’m too used to being able to scroll my terminal (or command prompt) output to go back and forward and you just can’t do that in a pure terminal like I have been dealing with recently.

Enter the <(...) construct:

vi <(ls -lrt)

Now the output of ls -lrt is redirected to the vi editor as some kind of pseudo-file.  I can page up and down to my heart’s content.

I also discovered the du and comm utilities today (told you I was new) and using a combination of all of them can now compare the size of folders under two separate parents:

vi <(comm <(cd /dir1; du .) <(cd /dir2; du .))

This changes the current directory to /dir1, spools the size of all subfolders to a pseudo-file, changes the current directory to /dir2, spools the size of all subfolders to another pseudo-file, spools the comparison of the two pseudo-files to a third pseudo-file and shows that file in vi, for me to look around.

Perfect for eyeballing the results of a local rsync.  It took a whole batch file to do the same last time I tried in Windows.

Database Project Deployment — An introduction to the DependencyList

September 26, 2008

Recently, I have been working with Database Projects within Visual Studio 2005 (yes, I’m set in my ways — I haven’t got around to VS2008 yet!!).  I like the ability to source control my creation scripts and stored procedures and I’m happy to use the VS IDE to write my SQL code and running individual scripts against multiple development Database References is a breeze.

However, deploying the finished scripts to a production database is a bit of a nightmare.  Essentially, if each script file represents a single database object, you have to ensure that you run them all in the correct order — especially if you have foreign key constraints (you do have foreign key constraints, don’t you?!).  Ordering all these scripts manually is a royal pain.

After the second or third time of being stuck in this situation, I decided enough is enough and set about writing a small app to do the job for me.  The results of this formed the mighty DependencyList.

Read the rest of this entry »

Oracle service crashes on OracleConnection.Open()

March 4, 2008

We recently had a situation here where the opening of a .NET connection to an Oracle 10g database caused the entire database to crash. This was indicated by the Event Log entry:

The OracleService<SID> service terminated unexpectedly.  
It has done this <n> time(s).

For more information, see Help and Support Center at 
http://go.microsoft.com/fwlink/events.asp.

This was using some library code that we had developed and used successfully on numerous occasions, so it had us truly stumped.

After much soul-searching, one of my colleagues eventually narrowed it down to the length of the .NET project name. The project, when compiled, created a EXE file that had a really long name, which caused Oracle to shit bricks.

Wonderful. I hate how Oracle has such a problem with large object names.

Also, I’d love to know how an Oracle DBA would approach such a failure. How would it even be recorded? There are so many different log files in a standard Oracle installation that I really wonder where you might begin?

Service configuration error – Event ID 5000 (ioibmurhynrxkw0zxkyrvfn0boyyufow)

September 26, 2007

I was recently bugged by an error in a Windows Service I was developing that, when deployed an started, immediately stopped. My log files showed nothing, which suggested that the exception was happening before my logging and exception handlers started.

Examining the Application Event Log, I found the following error:

Event Type: ErrorEvent
Source: .NET Runtime 2.0 Error Reporting
Event Category: None
Event ID: 5000
Date: 26/09/2007
Time: 20:17:53
User: N/A
Computer: theDeploymentServer
Description:
EventType clr20r3, P1 theService.exe, P2 1.0.0.0, P3 46fa9f5d, P4 system.configuration, P5 2.0.0.0, P6 4333ae78, P7 1a2, P8 136, P9 ioibmurhynrxkw0zxkyrvfn0boyyufow, P10 NIL.
For more information, see Help and Support Center at
http://go.microsoft.com/fwlink/events.asp.

Not the most helpful of errors, but I could see the system.configuration entry, so I started with the theService.exe.config file, emptying the file of any meaningful data and adding it back in piece by piece until I recreated the error.

The error occurred on the following appSetting entry:

<add key="PluginsFolder" value="C:\Program Files (x86)\A&B\theService\" />

I realised that the appSetting contained an ampersand (&) witin its value, I realised that ampersand is a reserved character in XML and so the .NET configuration parser couldn’t validate the .config file.

To resolve this I replaced the ampersand with its XML-compliant counterpart (&amp;), so the key now read:

<add key="PluginsFolder" value="C:\Program Files (x86)\A&amp;B Company\theService\" />

Granted this looks a little weird but it solved the problem!

Excessive recompilations when using VirtualPathProvider

September 20, 2007

This is a quick pointer for anyone implementing a VirtualPathProvider in their ASP.NET applications. I’ve read a number of tutorials on VPPs but none really touched on this issue.

If you do not implement a method for VirtualPathProvider.GetFileHash(...), calls to this method will return null/Nothing.

If this happens, ASP.NET’s build/compile system doesn’t remember that it has already compiled the file and attempts to do so again. After 15 compiles, the AppDomain is unloaded and the application restarts. This can cause major irritation, particularly with performance, as the recompiles take time.

To get around it in my app, I am overriding GetFileHash to return a string concatenation of the VirtualFile’s name and Last Modified Date. If anyone knows of a better hash, then please let me know.

Reinstating the GUI login page

September 20, 2007

Having just completed a 5-hour install process I, spent another two hours trying to fix up an issue I had with the login screen.

Having messed about with the options on the Login Screen, I inadvertently configured the X Server to try to login to a XDMCP server, by setting the startup server to Chooser.

When I rebooted, I couldn’t find any XDMCP servers, so I couldn’t login. I thought I’d try booting to a terminal mode, only to find that the kboot loader loaded Fedora if I left the keyboard idle for too long (about three seconds0).

Eventually I found out that I could get to a terminal from the XDMCP screen by pressing CTRL+ALT+F1. After that, I could log in as root and edit the GDM config file with VIM:
vi /etc/gdm/custom.conf
allowed me to edit the file, so I scrolled down to the [servers] section and changed the entry from:

[servers]
0=Chooser

to:

[servers]
0=Standard

After rebooting, the regular login screen was displayed.

I’ve learned two things from this:

  1. CTRL+ALT+F1 opens a terminal from the login screen
  2. I’m not going to mess with the startup screen again (I don’t even know what an XDMCP server is, let alone why I might want one!)