home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 10 / 10.iso / l / l430 / 1.ddi / CHAP5.ZIP / BASEMOVE.C < prev    next >
Encoding:
C/C++ Source or Header  |  1992-06-10  |  1.5 KB  |  53 lines

  1. /*
  2.     BASEMOVE.C -- Uses GetSelectorBase to show segment movement
  3.     within the linear address space
  4.  
  5.     From Chapter 5 of "Undocumented Windows" (Addison-Wesley 1992)
  6.     by Andrew Schulman, Dave Maxey and Matt Pietrek
  7.  
  8.     Build using: WINIOBC BASEMOVE (for Borland C++ v3.00)
  9.                  WINIOMS BASEMOVE (for Microsoft C/SDK)
  10. */
  11.  
  12. #include <windows.h>
  13. #include "winio.h"
  14. #include "wmhandlr.h"
  15.  
  16. /* undocumented function */
  17. DWORD FAR PASCAL GetSelectorBase(WORD sel);
  18.  
  19. DWORD prevcode = -1, prevdata = -1;
  20. WORD code, data;
  21.  
  22. long on_time(HWND hwnd, unsigned message, WORD wParam, LONG lParam)
  23. {
  24.     DWORD basecode, basedata;
  25.     basecode = GetSelectorBase(code);
  26.     basedata = GetSelectorBase(data);
  27.     if (basecode != prevcode || basedata != prevdata)
  28.         printf("CS (%04x) = %08lx\tDS (%04x) = %08lx\n",
  29.             code, basecode, data, basedata);
  30.     prevcode = basecode;
  31.     prevdata = basedata;
  32.     return 0;
  33. }
  34.  
  35. main()
  36. {
  37.     winio_about("BASEMOVE"
  38.         "\nUses GetSelectorBase to show segment movement"
  39.         "\nwithin the linear address space"
  40.         "\n\nFrom Chapter 5 of"
  41.         "\n\"Undocumented Windows\" (Addison-Wesley, 1992)"
  42.         "\nby Andrew Schulman, David Maxey and Matt Pietrek"
  43.         );
  44.     
  45.     _asm mov code, cs
  46.     _asm mov data, ds
  47.         
  48.     wmhandler_set(__hMainWnd, WM_TIMER, on_time);
  49.     if (! SetTimer(__hMainWnd, 1, 1000, NULL)) // once a second
  50.         fail("can't create timer");
  51.     return 0;
  52. }
  53.