home *** CD-ROM | disk | FTP | other *** search
- /*
- BASEMOVE.C -- Uses GetSelectorBase to show segment movement
- within the linear address space
-
- From Chapter 5 of "Undocumented Windows" (Addison-Wesley 1992)
- by Andrew Schulman, Dave Maxey and Matt Pietrek
-
- Build using: WINIOBC BASEMOVE (for Borland C++ v3.00)
- WINIOMS BASEMOVE (for Microsoft C/SDK)
- */
-
- #include <windows.h>
- #include "winio.h"
- #include "wmhandlr.h"
-
- /* undocumented function */
- DWORD FAR PASCAL GetSelectorBase(WORD sel);
-
- DWORD prevcode = -1, prevdata = -1;
- WORD code, data;
-
- long on_time(HWND hwnd, unsigned message, WORD wParam, LONG lParam)
- {
- DWORD basecode, basedata;
- basecode = GetSelectorBase(code);
- basedata = GetSelectorBase(data);
- if (basecode != prevcode || basedata != prevdata)
- printf("CS (%04x) = %08lx\tDS (%04x) = %08lx\n",
- code, basecode, data, basedata);
- prevcode = basecode;
- prevdata = basedata;
- return 0;
- }
-
- main()
- {
- winio_about("BASEMOVE"
- "\nUses GetSelectorBase to show segment movement"
- "\nwithin the linear address space"
- "\n\nFrom Chapter 5 of"
- "\n\"Undocumented Windows\" (Addison-Wesley, 1992)"
- "\nby Andrew Schulman, David Maxey and Matt Pietrek"
- );
-
- _asm mov code, cs
- _asm mov data, ds
-
- wmhandler_set(__hMainWnd, WM_TIMER, on_time);
- if (! SetTimer(__hMainWnd, 1, 1000, NULL)) // once a second
- fail("can't create timer");
- return 0;
- }
-