Lobsters - 03 Dec 2026
Page 4 of 10
Explorer still answers to the name Program Manager, because Windows 3.1 installers created their icons by talking to Progman over DDE (the desktop window is still called Program Manager in Windows 11), and its table of workarounds is a list of 1993 software: WinFax Pro, cc:Mail, Discis's children's books, Alone in the Dark 2, which compares "PROGMAN" case-sensitively so the name is registered in capitals just for it, and "The Journeyman Project. This app causes damage to space-time. We fix it by generating a small HS-field around their installer." The kernel has a similar list. When you run an old .exe that isn't a Windows program, the memory manager decides where to send it partly by looking for other companies' copyright notices inside it, "Phar Lap Software, Inc.", "Copyright (C) Rational Systems, Inc." and "1-2-3 Preloader" for Lotus, all DOS programs dressed up as OS/2 ones, which go to the DOS box.
NT also had a more general idea of compatibility. The same kernel could present itself to a program as one of several quite different operating systems, and one of those personalities was a little Unix environment implementing POSIX. If you're familiar with Unix, have a look at ttyname. You give it a file descriptor and it should tell you the name of the terminal the descriptor refers to.
char *
__cdecl
ttyname(int fildes)
{
static char s[7];
s[0] = 0;
return NULL;
}
Give ttyname any descriptor you like and you get NULL. There's a contemporary account of why that mattered. Stephen Walli, then at Softway Systems working on a fuller Unix environment, picked this very function for his 1997 USENIX paper. The standard permitted NULL if the system couldn't determine the terminal's name. This implementation was in the position of never being able to determine it. For a federal purchase that specified these interfaces, FIPS 151-2 required POSIX conformance. Walli could see how the purchasing requirement had been met. Someone trying to find out which terminal they had open still had a problem.
Turn from ttyname to forksup.c in the memory manager and you get some idea of the work Microsoft did put into Unix. Calling fork gives the child what looks like a copy of its parent's address space. For a page that both processes only read, one physical copy will do. The memory manager has to give them separate copies when one writes to the page.
This routine stands on its head to produce a copy of the specified
process's address space in the process to initialize. This
is done by examining each virtual address descriptor's inherit
attributes. If the pages described by the VAD should be inherited,
each PTE is examined and copied into the new address space.
For private pages, fork prototype PTEs are constructed and the pages
become shared, copy-on-write, between the two processes.
Softway's Unix was Interix. Microsoft acquired it when it bought Softway's assets in September 1999. Even the announcement encouraged customers eventually to move their programs to Win32. By the time XP went on sale the original POSIX subsystem was gone from the product. Its source is here, though, and the memory manager still includes forksup.c in the build. You can follow the federal requirement into the first implementation, the acquisition of a more useful one, and the survival of some of the work after the first one went away.
Dan Lovinger put a small cache into NTFS in August 1995 for programs that expected the file system to "hold onto" information about a file even after its directory entry had gone. Take an editor saving yesterday's document. It writes a temporary file and replaces the old one with it. The new file can pick up the old creation date and DOS short name if it appears soon enough, under the same name in the same directory. This also works after a rename. NTFS calls it tunneling. Looking in that cache for yesterday's document would be a disappointment. All it kept was the metadata.
// Information is retained in the tunnel cache for a fixed period of time. MarkZ would
// assume that a value of 10 seconds would satisfy the vast majority of situations. This
// could be controlled by the registry or could be a compilation constant.
//
// Change: W95 times out at 15 seconds. Would be a registry value initialized at tunnel
// creation time, with a proposed default of 15 seconds.
There are 256 entries on a workstation volume with the defaults. The original proposal gave it ten seconds. Further on someone records what 95 did, and the fifteen comes from there. On a create, NTFS looks for that remembered name before it sets the file's creation time. A fresh date means it didn't find tunneled data. You can lose an entry before the fifteen seconds are out, you can set other limits in the registry, and a case-sensitive POSIX open doesn't look in that cache at all.
The compatibility database I mentioned earlier is searchable in the blog post. The testers' descriptions are quoted directly, with their names left out.
dbu.xml, with the fixes each one gets and the testers' notes (their names left out). Try RollerCoaster Tycoon, Quicken or SimCity, or the Blocked filter, which lists what XP refused to install or run at all; seven of those 46 are Microsoft's products, Windows Media Player 7 among them.
, with the fixes each one gets and the testers' notes (their names left out). Try RollerCoaster Tycoon, Quicken or SimCity, or the Blocked filter, which lists what XP refused to install or run at all; seven of those 46 are Microsoft's products, Windows Media Player 7 among them.
Kernel32 hack for a children's game
The compatibility database fixes most badly behaved programs from outside, with shims. These are fixed from inside Windows, usually by name. Even Kernel32, a library that ordinary Win32 programs load, has code for one children's game, Elmo's Preschool Deluxe. Its 16-bit helper wants to know how much memory there is, physical and virtual. Windows gives the helper an answer the game can live with.
// Sure, we could have checked this on a compat bit instead, but the ISV is the
// Children's Television Workshop people and if they do this silliness in any
// of their other apps, we'll get those fixed "for free".
if ( 0 == lstrcmpi( lpszDll16, (LPCSTR)"mem16.dll" ) &&
0 == lstrcmpi( lpszThunkFunc, (LPCSTR)"GetMemory" ) )
{
//
// Elmo's Preschool Deluxe calls to a 16bit dll they ship just
// to get physical and virtual mem. Let's give 'em a pointer to our routine that
// will give it numbers that makes it happy.
//
*ppfnThunk32Func = ReturnMem16Data;
return(TRUE);
}
// Stub this function for King's Quest and Bodyworks 5.0 and other random Win 95 apps.
Office 95 also had trouble with the heap. Consider just the case of starting Word 95 from a shortcut on the desktop. Depending on how that went, the heap could be asked to free a stray pointer. In amongst the code practically every program needed for its memory there is a check for this one Office mistake. Then there's a comment a few lines farther down for people who leave perfectly readable ASCII or Unicode text in the place reserved for the heap header. Somebody would like the record to show that these people are "dorks".
// Also refuse to free blocks that are not eight-byte aligned.
// The specific mistake in this case is Office95, which likes
// to free a random pointer when you start Word95 from a desktop
// shortcut.
//
// As further insurance against mistakes, check the segment index
// to make sure it is less than HEAP_MAXIMUM_SEGMENTS (16). This
// should fix all the dorks who have ASCII or Unicode where the
// heap header is supposed to be.
Quattro Pro for Windows programmed the VGA card directly whenever it found one, which made it crawl on NT, where every such access is trapped and emulated, so NT's 16-bit layer tells every Windows 3.x program that asks that there's no monitor at all: "So we lie to them here bl = 0 No monitor. That way they don't do direct VGA programming and run fast." You can also find a Windows 9x list view clearing a kilobyte of stack for an accounting program. Sage had been lucky with a value it never bothered to set. It used to come out zero and you could maximize the window. So the list view gives Sage its zeros back.
// Crappy hack for Sage, which passes unitialized memory to SetWindowPlacement.
// They used to get lucky and get zeros for the max position, but now they end
// up with non-zero stack trash that causes bad things to happen when sage is
// maximized. Thus, zero a bunch of stack to save their tail...
void ZeroSomeStackForSage()
{
BYTE aByte[1024];
memset(aByte, 0, sizeof(aByte));
aByte;
}
Paste a link in old CorelDraw and 16-bit OLE would spoil some memory. CorelDraw actually needed that to happen. This left the people doing 32-bit OLE with a peculiar little identification problem. How do you tell it's CorelDraw and you can go ahead and spoil the memory? CorelDraw sends a file moniker and gives its class ID as the path.
#define OACF_CORELTRASHMEM 0x10000000 // CorelDraw relies on the fact that
// OLE16 trashed memory during paste-
// link. Therefore, we'll go ahead
// and trash it for them if this
// flag is on.
The Outlook Today page in Outlook 98 has an accommodation in IE, down to the column on the page. If the script error is at column 35 of line 36, IE doesn't put up the error dialog. The other place that gets the same treatment is column 28 of line 51.
BOOL OutLook98HackReqd(CMarkup * pMarkup, ULONG uLine, ULONG uCol)
{
if (((36 == uLine) && (35 == uCol) ||
(51 == uLine) && (28 == uCol)) &&
!_tcsicmp( (TCHAR *)CMarkup::GetUrl(pMarkup), _T("outday://")))
return TRUE;
If a program crashed in a common dialog, it wasn't even necessarily that program that needed fixing. Hijaak, for example, was an image program that interfered with Explorer. The casualties could be other people's applications opening their common dialogs. Explorer had to supply a decoy that Hijaak would leave alone.
// We return no attributes (specifically, Hijaak looks for
// SFGAO_FILESYSTEM) and Hijaak will say, "Whoa, I don't know
// how to patch this guy; I'll leave it alone."
STDAPI FakeHijaak_GetAttributesOf(void *_this, UINT cidl, LPCITEMIDLIST *apidl, ULONG *rgfInOut)
{
*rgfInOut = 0; // Move along, nothing to see here
return S_OK;
}
Word 2.0 left a rectangle out of a call. At run time the 16-bit multimedia OLE handler retrieved the missing rectangle from three stack frames up. The Cirrus Logic display driver that came with XP also knows things about the program calling it that seem a little outside its line of work. One such thing is the dimensions of the pause box in WinBench 97. From that little window the driver could tell when the benchmark was between tests. Now the interesting bit is when to allocate memory. Do it early and PowerPoint gets a better score, but Access gets a worse one. The driver recognises the 300-by-150 pause bitmap, counts ten during Access and reserves space for eight full-screen bitmaps while the timing is paused.
WinBench 97 uses 300x150 size bitmaps for its pause box. The pause box is
showed when WinBench 97 has disabled timing and is loading more playback
data from the hard disk. So here we have a way to do some stuff when which
will not be timed. What we will do is allocate enough heap memory for 8
full-screen device bitmaps. This will make the PowerPoint test very happy
since it is allocating these 8 full-screen device bitmaps during the slide
show. The only drawback is that NT will swap memory to hard disk in the
background. This will lower the Access score which we don't want. That is
why we have added a counter. The Access test uses 10 300x150 bitmaps so we
count down until Access has passed. Then we will start pre-allocating heap
space during each 300x150 bitmap request.
But this will drop the CorelDRAW test a little which *will* show up in the
overall score. So one extra allocation is requested. We will pre-allocate
the heap memory during every full-screen device bitmap (see SWAT2) when the
count down counter has reached zero.
One of the GDI printer classes is dated 1991. Somebody called a variable in it ptlPrinterHackDiesAfterTheBeta. Here it is in the XP tree, ten years down the road.
Minesweeper's hundred-slot queue
Minesweeper ("by Robert Donner and Curt Johnson", and in its file header "WinMine (a.k.a. Mines, BombSquad, MineSweeper...)") has the best find in this article, but the well-known stuff first.
The xyzzy cheat is defined in the code, and named after the magic word in Colossal Cave Adventure. Type X, Y, Z, Z, Y, hold Ctrl, and the top-left pixel of your screen turns black when the mouse is over a mine and white when it isn't. The pixel is set from the mouse-move handler in winmine.c.
//
// This is the cheat:
// If you hold down the shift key and type 'XYZZY'
// then when you hold down the control key, to upper
// left hand corner pixel will show the state of the
// mine field under the mouse. Oh. joy. I can win.
//
else if (iXYZZY != 0)
if (((iXYZZY == cchXYZZY) && (wParam & MK_CONTROL))
||(iXYZZY > cchXYZZY))
{
xCur = xBoxFromXpos(LOWORD(lParam));
yCur = yBoxFromYpos(HIWORD(lParam));
if (fInRange(xCur, yCur))
{
HDC hDC = GetDC(NULL);
SetPixel(hDC, 0, 0, fISBOMB(xCur, yCur) ? 0L : 0x00FFFFFFL);
ReleaseDC(NULL, hDC);
}
}#ifdef XYZZY
case VK_SHIFT:
if (iXYZZY >= cchXYZZY)
iXYZZY ^= 20;
break;
default:
if (iXYZZY < cchXYZZY)
iXYZZY = (szXYZZY[iXYZZY] == (TCHAR) wParam) ? iXYZZY+1 : 0;
break;
The definitions at the top of the file sit inside #ifndef DEBUG, as if the cheat were meant to stay out of some builds, but NT's build system calls its debug flag DBG, so every NT build of Minesweeper has the cheat compiled in.
The first click has a couple of oddities. You can actually click where there's a mine, in which case the game looks across from the top left until it has an empty square to put it in. So in practice that mine tends to go to the corner. The clock goes to 1 when you let go of the button. Somebody even explained the choice to do it on release ("If we had started it earlier, the interval between tick 1 and 2 is not correct"). Another small thing about the first board is that you have at most 65,536 possible ones. The random generator only gets seeded at launch, with the low sixteen bits of the number of milliseconds since boot.
The thing I found more interesting was in shell/osshell/ep/winmine/rtns.c. If you click a blank, the game opens the squares around it and it has to do the same for any of those that turn out to be blank. This is just a breadth-first flood fill. StepXY is the part that actually opens a square and puts it in the queue if the number of mines next to it is zero. In StepBox the entire working queue is an array of a hundred places (iStepMax), used as a ring so writing the next one after the last brings you back to position 0.
if (cBombs != 0)
return;
rgStepX[iStepMac] = x;
rgStepY[iStepMac] = y;
if (++iStepMac == iStepMax)
iStepMac = 0;
}
=StepBox= reads a square from the other end of that queue and visits all eight squares round it. It keeps at it until the read position is the same as the write position.
VOID StepBox(INT x, INT y)
{
INT iStepCur = 0;
iStepMac = 1;
StepXY(x,y);
if (++iStepCur != iStepMac)
while (iStepCur != iStepMac)
{
x = rgStepX[iStepCur];
y = rgStepY[iStepCur];
StepXY(x-1, --y);
StepXY(x, y);
StepXY(x+1, y);
StepXY(x-1, ++y);
StepXY(x+1, y);
StepXY(x-1, ++y);
StepXY(x, y);
StepXY(x+1, y);
if (++iStepCur == iStepMax)
iStepCur = 0;
}
How often do you think Minesweeper has a hundred zeros waiting to be looked at? In simulated Expert games the number got up to about 18 at most. An almost empty Custom board is quite a different game. The dialog lets you have just 10 mines for a board 30 squares across and 24 down. The queue can get so long that its two positions meet with a whole ring of work left to do. To the game that looks just like an empty ring, or it can start writing over squares still waiting for their turn. You can tell when this has happened just by looking at the board. There's an open zero with a square beside it that the game didn't open.
The nice thing about this bug is it can't cost you a game. Anybody can see there's no mine next to that zero and uncover the neighbour for themselves, which might explain the lack of complaints. I couldn't find a description of it. The simulation gave about two cases in a million first clicks on random boards of this shape. It depends where the ten mines are, so I put a board in the post where it happens every time. There are 710 safe squares. From the marked one my faithful port opens 612 and leaves 30 zeros with a neighbour still closed. An ordinary correct fill from that very same square gets 706. People who've reverse-engineered the game have found the hundred-entry ring. In fact there's a reimplementation published this month that sets aside one entry per square, with a comment saying the ring "can never lap itself and drop a pending square".
The boot screen is a black picture
The first thing XP showed you was a black screen with the Windows flag, "Microsoft Windows XP Professional" (or Home Edition), and under it a thin rounded track. The three squares crawling through it were blue on Professional and green on Home Edition in this tree. They didn't measure anything. They looped for as long as it took to reach the logon screen.
The obvious place to look for that picture is the kernel's base/ntos/init/boot.bmp. It's the right size, 640 by 480 in sixteen colours, run-length compressed to 14 kilobytes. Open it and there's absolutely nothing to see. Whoever made the bitmap set all sixteen colours to black. Twelve of the nineteen bitmaps in the kernel's resource script are like that. The colours you remember are in MainPalette in base/ntos/init/anim.c, which the header dates to August 2000 and attributes to Peter Alschitz.
RGBQUAD MainPalette [FULL_PALETTE_SIZE] = { {0,0,0,0}, {21,26,32,0}, {70,70,70,0}, {210,62,45,0},
{1,101,83,0}, {5,53,178,0}, {126,126,126,0}, {0,146,137,0},
{252,127,94,0}, {32,107,247,0}, {255,166,141,0}, {4,220,142,0},
{27,188,243,0}, {188,188,188,0}, {252,252,252,0}, {255,255,255,0} };
Next page | Previous page | More Lobsters | Headlines
Original: https://lr0.org/blog/p/winxp/