Debugging LoadPackage

Well this one is a complete pain in the ass. I’ve been trying to debug plugins in Delphi. It looks like the use of LoadPackage isn’t allowing us to debug the plugin. This is really annoying; it makes work difficult.

Annoying installations

This one is a real pain in the ass.
For some reason the installation of the Visual Fox Pro 8 SP1 OLEDB provider left all the registry keys installed were not readable by ordinary users, so when I tried to execute my application as an ordinary user didn’t work as the ‘provider wasn’t installed‘, whereas it’s just permissions.

Registry Keys that needed permission changes:
HKCR\CLSID\{50BAEED9-ED25-11D2-B97B-000000000000}
HKCR\CLSID\{50BAEEDA-ED25-11D2-B97B-000000000000}
HKCR\CLSID\{50BAEEDB-ED25-11D2-B97B-000000000000}
HKCR\VFPOLEDB
HKCR\VFPOLEDB.1
HKCR\Vfpoledb.ConnectionPage
HKCR\Vfpoledb.ConnectionPage.1
HKCR\VFPOLEDB.ConnectionPage
HKCR\VFPOLEDB.ConnectionPage.1

and the SOB still won’t work. Permissions on the files in OLDEB directory seem OK.
Then I had to copy registry information into the user’s environment:

Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\Software\Classes]
[HKEY_CURRENT_USER\Software\Classes\CLSID]
[HKEY_CURRENT_USER\Software\Classes\CLSID\{50BAEED9-ED25-11D2-B97B-000000000000}]
"OLEDB_SERVICES"=dword:ffffffff
@="VFPOLEDB"
[HKEY_CURRENT_USER\Software\Classes\CLSID\{50BAEED9-ED25-11D2-B97B-000000000000}\ExtendedErrors]
@="Extended Error Service"
[HKEY_CURRENT_USER\Software\Classes\CLSID\{50BAEED9-ED25-11D2-B97B-000000000000}\ExtendedErrors\{50BAEEDA-ED25-11D2-B97B-000000000000}]
@="VFPOLEDB Error Lookup"
[HKEY_CURRENT_USER\Software\Classes\CLSID\{50BAEED9-ED25-11D2-B97B-000000000000}\Implemented Categories]
[HKEY_CURRENT_USER\Software\Classes\CLSID\{50BAEED9-ED25-11D2-B97B-000000000000}\Implemented Categories\{D267E19A-0B97-11D2-BB1C-00C04FC9B532}]
@=""
[HKEY_CURRENT_USER\Software\Classes\CLSID\{50BAEED9-ED25-11D2-B97B-000000000000}\InprocServer32]
"ThreadingModel"="Both"
@="C:\\Program Files\\Common Files\\System\\ole db\\vfpoledb.dll"
[HKEY_CURRENT_USER\Software\Classes\CLSID\{50BAEED9-ED25-11D2-B97B-000000000000}\OLE DB Provider]
@="Microsoft OLE DB Provider for Visual FoxPro"
[HKEY_CURRENT_USER\Software\Classes\CLSID\{50BAEED9-ED25-11D2-B97B-000000000000}\ProgID]
@="VFPOLEDB.1"
[HKEY_CURRENT_USER\Software\Classes\CLSID\{50BAEED9-ED25-11D2-B97B-000000000000}\TypeLib]
@="{50BAEECA-ED25-11D2-B97B-000000000000}"
[HKEY_CURRENT_USER\Software\Classes\CLSID\{50BAEED9-ED25-11D2-B97B-000000000000}\VersionIndependentProgID]
@="VFPOLEDB"
[HKEY_CURRENT_USER\Software\Classes\CLSID\{50BAEEDA-ED25-11D2-B97B-000000000000}]
@="VFPOLEDB Error Lookup"
[HKEY_CURRENT_USER\Software\Classes\CLSID\{50BAEEDA-ED25-11D2-B97B-000000000000}\InprocServer32]
"ThreadingModel"="both"
@="C:\\Program Files\\Common Files\\System\\ole db\\vfpoledb.dll"
[HKEY_CURRENT_USER\Software\Classes\CLSID\{50BAEEDA-ED25-11D2-B97B-000000000000}\ProgID]
@="VFPOLEDB.ErrorLookup.1"
[HKEY_CURRENT_USER\Software\Classes\CLSID\{50BAEEDA-ED25-11D2-B97B-000000000000}\VersionIndependentProgID]
@="VFPOLEDB.ErrorLookup"
[HKEY_CURRENT_USER\Software\Classes\CLSID\{50BAEEDB-ED25-11D2-B97B-000000000000}]
@="VfpOLEDBConnectionPage Class"
[HKEY_CURRENT_USER\Software\Classes\CLSID\{50BAEEDB-ED25-11D2-B97B-000000000000}\InprocServer32]
"ThreadingModel"="Both"
@="C:\\Program Files\\Common Files\\System\\ole db\\vfpoledb.dll"
[HKEY_CURRENT_USER\Software\Classes\CLSID\{50BAEEDB-ED25-11D2-B97B-000000000000}\Programmable]
@=""
[HKEY_CURRENT_USER\Software\Classes\TypeLib]
[HKEY_CURRENT_USER\Software\Classes\TypeLib\{50BAEECA-ED25-11D2-B97B-000000000000}]
[HKEY_CURRENT_USER\Software\Classes\TypeLib\{50BAEECA-ED25-11D2-B97B-000000000000}\1.0]
@="Microsoft OLE DB Provider for Visual FoxPro 7.0 Type Library"
[HKEY_CURRENT_USER\Software\Classes\TypeLib\{50BAEECA-ED25-11D2-B97B-000000000000}\1.0\0]
[HKEY_CURRENT_USER\Software\Classes\TypeLib\{50BAEECA-ED25-11D2-B97B-000000000000}\1.0\0\win32]
@="C:\\Program Files\\Common Files\\System\\ole db\\vfpoledb.dll"
[HKEY_CURRENT_USER\Software\Classes\TypeLib\{50BAEECA-ED25-11D2-B97B-000000000000}\1.0\FLAGS]
@="0"
[HKEY_CURRENT_USER\Software\Classes\TypeLib\{50BAEECA-ED25-11D2-B97B-000000000000}\1.0\HELPDIR]
@="C:\\Program Files\\Common Files\\System\\ole db\\"
[HKEY_CURRENT_USER\Software\Classes\VFPOLEDB]
@="Microsoft OLE DB Provider for Visual FoxPro"
[HKEY_CURRENT_USER\Software\Classes\VFPOLEDB\CLSID]
@="{50BAEED9-ED25-11D2-B97B-000000000000}"
[HKEY_CURRENT_USER\Software\Classes\VFPOLEDB\CurVer]
@="VFPOLEDB.1"
[HKEY_CURRENT_USER\Software\Classes\VFPOLEDB.1]
@="Microsoft OLE DB Provider for Visual FoxPro"
[HKEY_CURRENT_USER\Software\Classes\VFPOLEDB.1\CLSID]
@="{50BAEED9-ED25-11D2-B97B-000000000000}"
[HKEY_CURRENT_USER\Software\Classes\Vfpoledb.ConnectionPage]
@="VfpOLEDBConnectionPage Class"
[HKEY_CURRENT_USER\Software\Classes\Vfpoledb.ConnectionPage\CLSID]
@="{50BAEEDB-ED25-11D2-B97B-000000000000}"
[HKEY_CURRENT_USER\Software\Classes\Vfpoledb.ConnectionPage\CurVer]
@="vfpOLEDBDLink.ConnectionPage.1"
[HKEY_CURRENT_USER\Software\Classes\Vfpoledb.ConnectionPage.1]
@="VfpOLEDBConnectionPage Class"
[HKEY_CURRENT_USER\Software\Classes\Vfpoledb.ConnectionPage.1\CLSID]
@="{50BAEEDB-ED25-11D2-B97B-000000000000}"
[HKEY_CURRENT_USER\Software\Classes\VFPOLEDB.ErrorLookup]
@="VFPOLEDB Error Lookup"
[HKEY_CURRENT_USER\Software\Classes\VFPOLEDB.ErrorLookup\CLSID]
@="{50BAEEDA-ED25-11D2-B97B-000000000000}"
[HKEY_CURRENT_USER\Software\Classes\VFPOLEDB.ErrorLookup.1]
@="VFPOLEDB Error Lookup"
[HKEY_CURRENT_USER\Software\Classes\VFPOLEDB.ErrorLookup.1\CLSID]
@="{50BAEEDA-ED25-11D2-B97B-000000000000}"

Of course, if you’ve installed it somewhere else then you should not use the C: prefix, but whatever the installation drive is (e.g. j:).

It’s really not C++, is it?

If I want to find out about anything in Windows, you have to go through one of the bazillion Enum functions. These creatures take a callback function which they invoke with information on what is being enumerated, along with a variable (typically a void *) that contains data where you can put the results of the information (for example putting it on a list).
Interestingly, there are a few exceptions to the rule. File I/O tends to be of a different character – FindFirstFile(Ex), FindNextFile, FindClose. Of course the person writing the API could have added the word ‘File’ to the end of ‘FindClose’. That way they would all have a matching function style. But there’s no accounting for taste.
We wander over to the C++ (or practically all OO languages) and the design immediately changes to an enumerator. For C++ it’s the iterator, You get an enumerator in Java (and C#). The Enumerator doesn’t look like the old create another stub function to implement this handler trick, the handling code is inside a set of braces ({}).
I presume it’s the vagaries of the different teams working on the solutions to the problem and the fact that at the time people were designing the solutions they didn’t think there was a better way. With the enumerator, the caller keeps the state of the enumeration to themselves, they pass the current item and a pointer to the handling function. When the enumeration is finished you are guaranteed that there is no remaining state left over and that all the handles are cleaned up before you return to the caller.
It seems to be more of a caller vs. callee cleanup exercise. Nowadays we have scoped destruction of objects and garbage collection to deal with the state destruction. What’s more it means that you still aren’t depending on the potential binary instability of the oo function call definition. The typical OO implementation uses an implied this parameter passed to methods to carry the object information. It allows clever developers to create functions that mimic OO methods without actually being functions of the objects themselves.
If you’re clever, you can replace VMT entries with functions of your own creation that can be written in C. Convenient that.
An annoyance of programming Windows is that WinMain must be a static function. If you want to have a WinMain method, you need to perform trickery. One of the most regular methods of doing this is to use SetWindowLongPtr and store the address of the object in the private window information. This has the potential of being quite expensive. Every time you invoke the method you have to issue a GetWindowLongPtr call to extract the pointer, and then indirectly invoke the object’s implementation of WinMain.
There is a more evil mechanism that uses self rewriting code. But that’s for another time.

Curses: E1026

I keep getting this bloody error in the Delphi IDE: E1026 file not found: ‘importcore.drf’
The .drf file varies depending on the project being built. It seems to work itself out after a while (I went looking for bugs).

Upgrade duration

Not technically programming, but computers in general. We were upgrading from one server to another last night. Microsoft SBS 2000 -> SBS 2003. The issues were security related. Most of the shares were naïvely configured, so a tightening of the security was on order. All the accounts were changed to Domain Users, from the domain administrators that they had been before. New security groups were added to keep data separate.
The problem was the machines themselves. Currently the machines are running with the account of the login as an administrator of the computer. This should be changable to an ordinary user, as I’ve put the respective privileges into the registry for the BDE.
Long and short of it. The upgrade was scheduled to take 1 hour. It took 2. Reasons – machines upgraded to XP service pack 2 along the way, unforseen security issues as some files within the shares were owned by a domain admin, not by the owner of the containing folder; caused by copying files from one dorectory to another – which brings along the privilege information (NTFS->NTFS). The security is really worth it! honest!
Of course, wireless is not enabled on the network.
Handy link for the day: RunAs with Explorer.

[Listening to: Born Slippy – Underworld – Trainspotting (9:44)]

Slow on the uptake

Ok. I presume other people have a similar problem to me with their iTunes. It takes about a minute to shut down. This is, of course, because it’s rebuilding the music library, which it a pair of files; one XML and one binary; which contain all the information on the music I have; play counts and the likes.
Maybe it’s my slow hard drive; I don’t know, but it’s really irritating. I only have about 22,000 songs in my library. My addition rate is about 1 album a week (there’s nothing good out there). The biggest update is the play counts.
Suggestions for performance improvements. Make the binary file be a bunch of binary files. One file contains the file information, one contains the individual song information, one contains the play information, and then one per playlist. At a guess, the XML doc is being created by building a huge ass DOM and walking it off to the hard-drive. It’s only a guess, but how many entries and playlists did they make for the performance testing? My iPod can’t take all my music, so I’ve a large number of playlists. Could this be the issue? Could any of the engineers at Apple tell me? I’d be very interested to know. Act now before I get tied into another NDA 🙂
enough of the rantage, I need to get suited up.

[Listening to: Love Is Rare – Morcheeba – Fragments Of Freedom (4:04)]

Upgrade time

The time has come, I believe to upgrade my site from the 2.6 version of Movable type to the 3.2 version. I’ve made a few personalizations to the 2.6 code base so support my specific features. I just wonder how difficult they will be to integrate into the new code base.
Features I added were not huge – inline comments (via a bit of AJAX), and a small HasComments tag.
Why am I upgrading? I’m the only author, and the free ediiton supports that. I want to do a little more theme work, and I’d like to get my added features out there in the community – I think they would be appreciated.
Not much else to talk about. I’m expecting job offers in the post any day now 🙂

Slow on the pickup

While I was nosing around the Adobe Updater software (just getting to the program), I notices that it was using the boost thread library. Boost is a collection of peer-reviewed, portable C++ libraries. They have a threads library that works for several several platforms, helping hiding some of the yuckiness of the platform specific issues (and believe me there are quite a few).

[Listening to: Comedy in Music, Part II, Requests (a-j) – Victor Borge – Live (!) (14:25)]

Softice Detection

Short, C code:

bool
IsSoftIceLoaded() {
HANDLE fh;
fh = CreateFileA("\\\\.\\NTICE", GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE,
NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0);
if (fh != INVALID_HANDLE_VALUE) {
CloseHandle(fh);
return (TRUE);
}
return (FALSE);
}

If you want to detect a regular debugger, then you can use IsDebuggerPresent(), it’s part of the PSDK.