Unauthorized Windows 95 Update -- W16LOCK
This page last updated January 12, 1996
- W16LOCK.C -- Source code for a small
Win32 program which demonstrates the Win16Lock in Windows 95.
This version is corrected from the version that appears in Unauthorized
Windows 95, page 553.
After the book was written, KERNEL32.DLL stopped exporting the
undocumented GetpWin16Lock, _EnterSysLevel, and
_LeaveSysLevel Win32 functions by name. These functions
are still present, and are exported-but by number, not name.
(GetpWin16Lock is KERNEL32.93, _EnterSysLevel is
KERNEL32.97, and _LeaveSysLevel is KERNEL32.98.) However,
KERNEL32 does not allow imports by ordinal. To access these
functions, W16LOCK.C now uses the GetK32ProcAddress function
from K32EXP.C.
Note: The Win16Lock is definitely not a mutex, even though
Microsoft now calls it the "Win16Mutex." As can be seen
from this program, it's a single DWORD, located down in conventional
memory (below 1MB) no less. Matt Pietrek
informs me that Win16Lock is "really a critical section (KERNEL32
object type 4). It just happens to be a global critical section,
rather than task specific."
An interesting Win95 phenomenon, which I believe has to do with Win16Lock:
close all Win16 programs, so you're only running Win32 code; run some
Win32 program that updates the display frequently, such as WinBezMT or the
Win32 version of Clock; click down on any window titlebar
a titlebar and hold the mouse down (you can move the window around if you
want; just keep the mouse clicked dow); notice that all display stops
while the mouse is clicked down in the titlebar! Interesting, enabling
Control Panel | Display | Plus! | "Show window contents while dragging"
has the side effect of fixing this nasty behavior.
- W16LOCK.EXE -- A small Win32 program
which demonstrates how easy it is to grab the Win16Lock in Windows
95, and thus stop the entire system. The Win16Lock is grabbed
with the undocumented _EnterSysLevel Win32 API, and released
with _LeaveSysLevel.
The O'Reilly Windows Center
Unauthorized Windows 95 Update