Undocumented Features of OS/2

By Rick Papo

Overview and Credits
This document is a collection of unofficial information gathered from a variety of sources about system API functions in OS/2 that are not officially documented for various reasons. Rick Papo built

Use this information totally at your own risk. Always test such use thoroughly for suitability in your own application and environment.

The information in this document was discovered or gathered by the following persons:
 * Carsten Arnold
 * Samuel Audet
 * Alessandro Cantatore
 * Scott Garfinkle
 * Istvan Kovacs
 * Alexander Mai
 * Bob Markle
 * Darren McBride
 * Ferenc Pal
 * Rick Papo
 * Paul Ratcliffe
 * Kai-Uwe Rommel
 * Marco G. Salvagno
 * Alexey Smirnov
 * Uri J. Stern
 * Holger Veit

API Functions

 * DosDumpProcess
 * DosForceSystemDump
 * DosProfile
 * DosQProcStat
 * DosQueryMemState
 * DosQueryModFromEIP
 * DosQuerySysState
 * DosReplaceModule
 * DosSuppressPopUps
 * WinSetTitle
 * WinSetTitleAndIcon
 * WinHSWITCHfromHAPP

The Color Selection Control
The color wheel control used by the Solid and Mixed Color Palette object is a publicly registered window class within OS/2, but is undocumented. The following notes are all that is necessary to use this control class:
 * 1) You must load the module WPCONFIG.DLL so that the publicly registered window message processor (ColorSelectWndProc) can be used without an addressing violation.
 * 2) Create your control window with WinCreateWindow or through a dialog template, using the window class name "ColorSelectClass".
 * 3) If you used WinCreateWindow you will need to reposition the control window each time the parent window is resized, as otherwise the control will reposition itself out of view. Dialogs seem to handle this automatically.
 * 4) The only control message defined -to- the control is 0x0602 under OS/2 Warp 4 or later, or (by some reports) 0x1384 on older versions of OS/2. Message parameter one must contain the RGB value to which the color wheel will be set.
 * 5) The only control message defined -from- the control is 0x0601 under OS/2 Warp 4 or later, or (by some reports) 0x130C on older versions of OS/2. Message parameter one will contain the RGB value to which the color wheel has been set.
 * 6) The control can only be sized at creation, and should be sized so that its height is approximately 60% of it.

HPFS Large Disk Access
DosRead/Write in direct-access mode will normally fail if the partition is greater than four gigabytes in size. If you wish to write an HPFS editor or other tool, you will need to know the "secret password" that unlocks the big disks. After you use DosOpen to get a handle to that volume, use FSCTL FSC_SECTORIO (0x9014) and in the parameter list, put a pointer to 0xDEADFACE. Doing so will put the handle in "sector" mode. All offsets and sizes will refer to sectors instead of bytes, allowing you to address 64Gb.

Undocumented extensions to Event Semaphores
It is possible to do a post that releases one thread at a time as of fixpak 29 for Warp 3 and fixpack 4 for Warp 4. This feature only slightly changes the API of DosCreateEventSem. Other APIs for event semaphores are kept the same, although their behaviors are changed.
 * 1) define DCE_AUTORESET 0x1000 // Auto-reset event semaphore
 * 2) define DCE_POSTONE  0x0800 // Post one flag


 * DosCreateEventSem:The flags argument can specify the new behaviors of the event semaphore: DCE_AUTORESET means the event automatically resets itself after a thread obtains it through DosWaitEventSem, and DCE_POSTONE means that DosPostEventSem only wakes up one waiting thread if there is any. When DCE_POSTONE is specified, the event always automatically resets even if DCE_AUTORESET is not specified. We can define three types of events with these two flags:
 * Neither DCE_AUTORESET nor DCE_POSTONE set: The event has default behavior, which needs manual resets and wakes up all waiters when posted.
 * DCE_AUTORESET set but not DCE_POSTONE: The event resets it after a wait is successfully executed. It wakes up all waiters when posted.
 * DCE_POSTONE set: The event resets it automatically after a wait is successfully executed. But it only wakes up one waiter when posted.


 * DosWaitEventSem:For an AUTORESET event, it automatically resets itself after this is successfully executed. Otherwise, it leaves the event in signalled (posted) state.
 * DosPostEventSem:For a POSTONE event, it wakes up only one waiter if there is any thread waiting for the event. Otherwise, it wakes up all events.

How to reset the Physical Palette
Getting the 256-color mode palette manager to set itself up is not too hard, but getting it to reset itself to the default palette is not documented well. In the header file 'DIVE.H' is a nice piece of explanation: Neither DiveSetSourcePalette nor DiveSetDestinationPalette API's will set the physical palette. If your application MUST set the PHYSICAL palette, try using no more than 236 entries (the middle 236: 10-245, thus leaving the top and bottom 10 entries for the Workplace Shell). If your application MUST use ALL 256 entries, it must do so as a full-screen (i.e. maximized) application. Remember, No WM_REALIZEPALETTE message will be sent to other running applications, meaning they will not redraw and their colors will be all wrong. It is not recommended that a developer use these commands:

To set physical palette, do the following:

hps = WinGetPS ( HWND_DESKTOP ); hdc = GpiQueryDevice ( hps ); GpiCreateLogColorTable ( hps, LCOL_PURECOLOR | LCOL_REALIZABLE,     LCOLF_CONSECRGB, 0, 256, (PLONG)plRGB2Entries ); DiveSetPhysicalPalette ( hDiveInst, hdc ); GreRealizeColorTable ( hdc ) ; WinInvalidateRect ( HWND_DESKTOP, (PRECTL)NULL, TRUE ); WinReleasePS ( hps );

To reset physical palette, do the following:

hps = WinGetPS ( HWND_DESKTOP ) ; hdc = GpiQueryDevice ( hps ) ; GreUnrealizeColorTable ( hdc ) ; WinInvalidateRect ( HWND_DESKTOP, (PRECTL)NULL, TRUE ); WinReleasePS ( hps ) ; I have altered these examples slightly for clarity, replacing the Gre32Entry3 function calls with macros defined in 'PMDDIM.H'.

Extensions to WinQuerySysValue and WinSetSysValue
Several new system values have been defined in the Warp 4.0 (and possibly in the newer fixpaks to Warp 3.0). They are: The definition names given here are not official, and are not included in PMWIN.H.

Extensions to WinDrawBorder
There are at least two undocumented option flags for the WinDrawBorder function which appear to have been provided to help in drawing pushbutton controls. They are: The definition names given here are not official, and are not included in PMWIN.H.

Environment Variables
There are a number of undocumented environment variables that change the behaviour of the system. These are a few of them:
 * COPYFROMFLOPPY=1 - You have replaced one or more of the files on the installation floppies, and you have successfully booted the installer in spite of your strange hardware. The installation proceeds, but it pulls in replacements to what you just replaced from either the later compressed diskettes, or from the CD. When the first phase of installation completes and the system reboots from the hard drive, you find that you no longer are using the replacement drivers. If you add this line to the CONFIG.SYS on install diskette 1 (before Warp 4.0) or on install diskette 2 (Warp 4.0 or later), then the installer will reload the replacement files from the early floppies before rebooting.
 * KILLCONFIRMDISABLED=ON - Avoid the "Are you sure ..." dialog if using the WarpCenter kill feature. You must also have the SET SCKILLFEATUREENABLED variable installed.
 * KILLFEATUREENABLED=ON - This enables the display of the full process list from WarpCenter by clicking on the task list button while pressing the Control key. Selecting a program from the list pops up a message box to confirm the killing of the process.
 * MENUSFOLLOWPOINTER=ON - This makes the WarpCenter menus (but no others) behave more like the Start menu of Windows, in that once you open the menu, the menu selection will follow the mouse without your needing to keep the mouse button pressed down. Submenus will automatically open as you move the mouse pointer over them. This function only works on Warp 4.0 with fixpack 5 or later.
 * SCCANBENUKED=ON - Allows the WarpCenter to have a Delete option on its context menu.
 * SCFINDUTILITY=c:\os2\apps\pmseek.exe - This changes the function of the Find button on the WarpCenter to use PMSEEK instead of the limited-function default file finder.
 * SCKILLCONFIRMDISABLED=ON - This is the same as KILLCONFIRMDISABLED=ON.
 * SCKILLFEATUREENABLED=ON</tt> - This is the same as KILLFEATUREENABLED=ON</tt>.
 * SCPRETTYCLOCK=1</tt> - This changes the appearance of the WarpCenter clock, giving it a fancier border, a black background and green numbers.
 * SHELLHANDLESINC=</tt> - This environment variable increments the number of file handles available to the Shell process (protshell). Users who need more file handles can add this statement to CONFIG.SYS. The maximum file handles will be incremented by the amount specified in the statement. The system defaults to 20 file handles in the Shell process. Therefore, if the statement specifies a 10, then the total would be incremented to 30.