home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / magazine / drdobbs / 1991 / 01 / winthere.asc < prev    next >
Text File  |  1990-12-07  |  4KB  |  97 lines

  1. _WINTHERE_
  2. by Ben Myers
  3.  
  4.  
  5. [LISTING ONE]
  6.  
  7.        page   58,132
  8.        title  WINTHERE, A program to test for the presence of Windows 3.0
  9.        subttl (C)Copyright 1990 Spirit of Performance, Inc.
  10. ;          All Rights Reserved.
  11.        .list
  12. ; You may use any portion of this program for any purpose whatsoever, but
  13. ; you must include the above copyright in any program into which portions of
  14. ; this program are incorporated.
  15. ; Use Microsoft MASM 5.1 or later and Borland TLINK to build WINTHERE.COM.
  16. ;     masm %1,%1.obj;
  17. ;     tlink /x /t %1.obj,%1.com
  18. ; You may also use LINK and EXE2BIN to build WINTHERE.COM. MASM local 
  19. ; reference operators @f, @b, and @@ are not handled correctly by Borland TASM.
  20.  
  21. ; Equates used in this program
  22. Multiplexor equ  2Fh            ; DOS multiplexor interrupt
  23. KbdIO       equ  16h            ; BIOS Keyboard interrupt
  24. DOS         equ  21h            ; DOS function call interrupt
  25. Terminate   equ  4Ch            ; DOS terminate function
  26. PrintString equ  09h            ; DOS print string function
  27. CR          equ  0dh            ; Carriage Return.
  28. LF          equ  0ah            ; Line Feed.
  29.  
  30. ; Simple macro to display a text string with the DOS print string function
  31. Display  macro    message
  32.      local    amsg,around
  33.      mov      dx,offset amsg ; Load offset of message
  34.      mov      ah,PrintString ; DOS function code
  35.      int      DOS
  36.      jmp      short around   ; jump around message text
  37. amsg:
  38.      .errb    <message>     ; generate assembler error if no message
  39.      irp      y,<message>   ; repeat for each of y args in message list
  40.      db       y
  41.      endm
  42.      db       '$'           ; terminate message with '$' as required
  43. around:
  44.      endm
  45. cseg      segment public 'code'
  46.       assume cs:cseg
  47.  
  48.       org    100h
  49. Begin:
  50.     Display <"WINTHERE - (C)Copyright 1990 Spirit of Performance, Inc.",CR,LF>
  51.  
  52. ; See if being executed from Windows 3.0 in enhanced mode.
  53.       mov    ax,1600h           ; Enhanced Windows multiplex signature.
  54.       int    Multiplexor
  55.       test   al,7fh             ; Windows 386?
  56.       jnz    Win_Enhanced       ; Yes.
  57.  
  58. ; See if being executed from Windows 3.0 in real or standard mode.
  59.       mov    ax,4680h           ; Multiplex signature...
  60.       int    Multiplexor        ; apparently when Win3 is not enhanced.
  61.       or     ax,ax              ; Windows 3.0 /r or /s?
  62.       jz     @f            ; Yes.
  63.       jmp    Not_Enhanced_Win   ; No.
  64. @@:
  65. Display <"WINTHERE has been run from Windows real or standard mode.",CR,LF>
  66.       jmp    WrapUp
  67.  
  68. Win_Enhanced:
  69.  Display <"WINTHERE has been run from within Windows in enhanced mode.",CR,LF>
  70. WrapUp:
  71.       Display <"Press any key to continue. . .",CR,LF>
  72.       xor    ah,ah              ; Read a keystroke.
  73.       int    KbdIO
  74.       or     ah,ah              ; Extended scan code?
  75.       jnz    @f                 ; No.
  76.       int    KbdIO              ; Read second half of extended character.
  77. @@:
  78.       mov    ah,Terminate       ; Quit.
  79.       mov    al,1               ; DOS exit code 1 to indicate error.
  80.       int     DOS
  81. Not_Enhanced_Win:
  82.       Display <"WINTHERE has not been run from within MS Windows.",CR,LF>
  83.       mov    ah,Terminate       ; Quit.
  84.       xor    al,al              ; Exit code 0, no error.
  85.       int     DOS
  86.  
  87. ; The interrupt mux call with ax=4680h is the one that Microsoft refuses to
  88. ; acknowledge, but it sure is there every time Windows is run in real or 
  89. ; standard mode, and the mux interrupt vector points dead square in the middle
  90. ; of the Windows kernel, which then chains the mux interrupt elsewhere.
  91. cseg      ends
  92.       end    Begin
  93.  
  94.  
  95.  
  96.  
  97.