Showing results for History - The Old New Thing

Dec 2, 2004
Post comments count0
Post likes count1

Why did Windows 95 run the timer at 55ms?

Raymond Chen
Raymond Chen

The story behind the 55ms timer tick rate goes all the way back to the original IBM PC BIOS. The original IBM PC used a 1.19MHz crystal, and 65536 cycles at 1.19MHz equals approximately 55ms. (More accurately, it was more like 1.19318MHz and 54.92ms.) But that just pushes the question to another level. Why 1.19...MHz, then? With that clock rat...

History
Dec 1, 2004
Post comments count0
Post likes count0

What is the purpose of the bmPlanes member of the BITMAP structure?

Raymond Chen
Raymond Chen

Many bitmap-related structures in Windows have a field called "planes". For example the structure has a member (which must be set to 1). The structure has a field called . What's the deal with that field? The EGA video adapter supported 16 simultaneous colors. This was an enormous improvement over the CGA, which supported only four colors. I...

History
Nov 22, 2004
Post comments count0
Post likes count0

When people ask for security holes as features: World-writable files

Raymond Chen
Raymond Chen

If I had a nickel each time somebody asked for a feature that was a security hole... I'd have a lot of nickels. For example, "I want a file that all users can write to. My program will use it as a common database of goodies." This is a security hole. For a start, there's an obvious denial of service attack by having a user open the file in ...

HistoryWhen people ask for security holes as features
Nov 18, 2004
Post comments count0
Post likes count0

If a program and a folder have the same name, the shell prefers the program

Raymond Chen
Raymond Chen

If you have both a folder named, say, and a program named and you type into the Start.Run dialog, you get the program and not the folder. Why is that? Because it is common to have where there is a setup program in the root, as well as a setup folder containing files needed by the setup program. Before Windows 95, you couldn't open...

History
Nov 9, 2004
Post comments count0
Post likes count0

A history of GlobalLock, part 4: A peek at the implementation

Raymond Chen
Raymond Chen

On one of our internal discussion mailing lists, someone posted the following question: We have some code that was using DragQueryFile to extract file paths. The prototype for DragQueryFile appears as follows: UINT DragQueryFile( HDROP hDrop, UINT iFile, LPTSTR lpszFile, UINT cch ); In the code we have, instead of passing an ...

History
Nov 8, 2004
Post comments count0
Post likes count0

A history of GlobalLock, part 3: Transitioning to Win32

Raymond Chen
Raymond Chen

Now that you know how the 16-bit memory manager handled the global heap, it's time to see how this got transitioned to the new 32-bit world. The function continued to emulate all its previous moveability rules, but the return value of was no longer a selector since Win32 used the processor in "flat mode". This means that the old trick of ca...

History
Nov 5, 2004
Post comments count0
Post likes count0

A history of GlobalLock, part 2: Selectors

Raymond Chen
Raymond Chen

With the advent of the 80286, Windows could take advantage of that processor's "protected mode". processor. There was still no virtual memory, but you did have memory protection. Global handles turned into "descriptors", more commonly known as "selectors". Architectural note: The 80286 did have support for both a "local descriptor table" and a ...

History
Nov 4, 2004
Post comments count0
Post likes count0

A history of GlobalLock, part 1: The early years

Raymond Chen
Raymond Chen

Once upon a time, there was Windows 1.0. This was truly The Before Time. 640K. Segments. Near and far pointers. No virtual memory. Co-operative multitasking. Since there was no virtual memory, swapping had to be done with the co-operation of the application. When there was an attempt to allocate memory (either for code or data) and insuffici...

History
Nov 3, 2004
Post comments count0
Post likes count0

Why do I sometimes see redundant casts before casting to LPARAM?

Raymond Chen
Raymond Chen

If you read through old code, you will often find casts that seem redundant. SendMessage(hwndListBox, LB_ADDSTRING, 0, (LPARAM)(LPSTR)"string"); Why was "string" cast to LPSTR? It's already an LPSTR! These are leftovers from 16-bit Windows. Recall that in 16-bit Windows, pointers were near by default. Consequently, "string" was a near pointe...

History
Nov 2, 2004
Post comments count0
Post likes count0

What was the point of the GMEM_SHARE flag?

Raymond Chen
Raymond Chen

The GlobalAlloc function has a GMEM_SHARE flag. What was it for? In 16-bit Windows, the GMEM_SHARE flag controlled whether the memory should outlive the process that allocated it. By default, all memory allocated by a process was automatically freed when that process exited. Passing the GMEM_SHARE flag suppressed this automatic cleanup. That's...

History