home *** CD-ROM | disk | FTP | other *** search
- /*
- OEMLAYER.C -- Character mode Windows using the OEM Layer?
-
- From Chapter 6 of "Undocumented Windows" (Addison-Wesley 1992)
- by Andrew Schulman, Dave Maxey and Matt Pietrek
-
- Build using: WINIOBC OEMLAYER (for Borland C++ v3.00)
- WINIOMS OEMLAYER (for Microsoft C/SDK)
- */
-
- #include <windows.h>
- #include <dos.h>
- #include "winio.h"
-
- /* undocumented functions */
- extern void FAR PASCAL EnableOEMLayer(void);
- extern void FAR PASCAL DisableOEMLayer(void);
-
- #include "checkord.c"
-
- #ifndef __BORLANDC__
- #define MK_FP(a,b) ((void far *)(((unsigned long)(a) << 16) | (b)))
- #endif
-
- void b800display(char *szDisplay)
- {
- unsigned lineofs = 0, charofs = 0, scrsel;
-
- printf("Screen Selector is %04x\n",
- scrsel = LOWORD((DWORD)
- GetProcAddress(GetModuleHandle("KERNEL"), "__B800h")));
-
- for (; *szDisplay; szDisplay++)
- switch (*szDisplay) {
- case '\r' : charofs = 0; break;
- case '\n' : lineofs += 160; break;
- default :
- *(WORD FAR *) MK_FP(scrsel, lineofs+charofs) =
- 0xe00 | *szDisplay;
- charofs += 2;
- }
- }
-
-
- int main()
- {
- // Ord/name check
- if (! (CheckOrdName("EnableOEMLayer", "USER", 3)) &&
- (CheckOrdName("DisableOEMLayer", "USER", 4)))
- return 0;
-
- winio_about("OEMLAYER"
- "\nUses DisableOEMLayer/EnableOEMLayer to temporarily"
- "\nenter text mode while still in Windows"
- "\n\nFrom Chapter 6 of"
- "\n\"Undocumented Windows\" (Addison-Wesley, 1992)"
- "\nby Andrew Schulman, David Maxey and Matt Pietrek"
- );
-
- DisableOEMLayer();
- b800display("\n"
- "The OEM layer has been disabled, and normal Windows\r\n"
- "keyboard and display handling have been suspended.\r\n"
- "Direct writes to b800:0 are being used to display this,\r\n"
- "and a call to Int 16h will be used to get your keystroke.\r\n"
- "\r\n"
- "Press a key to return");
-
- _asm {
- mov ah, 0
- int 16h
- }
-
- EnableOEMLayer();
-
- printf("\n\nProgram terminated");
- return 0;
- }
-