home *** CD-ROM | disk | FTP | other *** search
/ Microsoft Programmer's Library 1.3 / Microsoft-Programers-Library-v1.3.iso / sampcode / advos2 / ch18 / snap.asm next >
Encoding:
Assembly Source File  |  1988-12-12  |  27.9 KB  |  715 lines

  1.         title   SNAP -- Sample OS/2 Device Monitor
  2.         page    55,132
  3.         .286    
  4.  
  5. ;
  6. ; SNAP.ASM
  7. ;
  8. ; A sample OS/2 device monitor that captures the current display into
  9. ; the file SNAPxx.IMG, where xx is the session number.  SNAP works in
  10. ; character mode only and may not be used in a PM window.  The
  11. ; following keys are defined as defaults:
  12. ;
  13. ; Alt-F10   hot key to capture a screen
  14. ; Ctrl-F10  hot key to deinstall SNAP.EXE
  15. ;
  16. ; Assemble with:  C> masm snap.asm;
  17. ; Link with:  C> link snap,,,os2,snap
  18. ;
  19. ; Usage is:  C> snap
  20. ;
  21. ; Copyright (C) 1988 Ray Duncan
  22. ;
  23.  
  24. cr      equ     0dh                     ; ASCII character codes
  25. lf      equ     0ah
  26.  
  27.                     ; hot key definitions:
  28. snapkey equ     71h                     ; snapshot   Alt-F10
  29. exitkey equ     67h                     ; exit       Ctrl-F10
  30.  
  31. stksize equ     2048                    ; stack size for threads
  32.  
  33.         extrn   DosAllocSeg:far
  34.         extrn   DosBeep:far
  35.         extrn   DosBufReset:far
  36.         extrn   DosClose:far
  37.         extrn   DosCloseSem:far
  38.         extrn   DosCreateSem:far
  39.         extrn   DosCreateThread:far     
  40.         extrn   DosExecPgm:far
  41.         extrn   DosExit:far
  42.         extrn   DosGetInfoSeg:far       
  43.         extrn   DosOpenSem:far          
  44.         extrn   DosMonClose:far
  45.         extrn   DosMonOpen:far          
  46.         extrn   DosMonRead:far
  47.         extrn   DosMonReg:far
  48.         extrn   DosMonWrite:far
  49.         extrn   DosOpen:far             
  50.         extrn   DosSemClear:far
  51.         extrn   DosSemSet:far
  52.         extrn   DosSemWait:far
  53.         extrn   DosSetPrty:far
  54.         extrn   DosSleep:far
  55.         extrn   DosSuspendThread:far
  56.         extrn   DosWrite:far
  57.         extrn   VioEndPopUp:far
  58.         extrn   VioGetMode:far
  59.         extrn   VioPopUp:far
  60.         extrn   VioReadCharStr:far      
  61.         extrn   VioWrtCharStr:far
  62.  
  63. jerr    macro   p1,p2,p3                ;; Macro to test return code
  64.     local    zero            ;; in AX and jump if nonzero
  65.         or      ax,ax                   ;; Uses JMP DISP16 to avoid
  66.         jz      zero                    ;; branch out of range errors
  67.         mov     dx,offset DGROUP:p2     ;; p2 = message address
  68.         mov     cx,p3                   ;; p3 = message length
  69.         jmp     p1                      ;; routine p1 displays message
  70. zero:
  71.         endm
  72.  
  73. DGROUP  group   _DATA
  74.  
  75. _DATA   segment word public 'DATA'
  76.  
  77. exitsem dd      0                       ; semaphore for final exit
  78. snapsem dd      0                       ; semaphore for 'snap' thread
  79.  
  80. sname   db      '\SEM\SNAP'             ; system semaphore name
  81. sname1  db      'nn.LCK',0
  82. shandle dd      0                       ; system semaphore handle
  83.  
  84. pflags  dw      0                       ; VioPopUp flags
  85.  
  86. wlen    dw      ?                       ; receives length written
  87. action  dw      ?                       ; receives DosOpen action
  88.  
  89. watchID dw      ?                       ; keyboard thread ID
  90. snapID  dw      ?                       ; snapshot thread ID
  91.  
  92. sel     dw      ?                       ; selector from DosAllocSeg
  93.  
  94. kname   db      'KBD$',0                ; keyboard device name
  95. khandle dw      0                       ; keyboard monitor handle
  96.                                 
  97. fname   db      '\SNAP'                 ; name of snapshot file
  98. fname1  db      'nn.IMG',0
  99. fhandle dw      0                       ; handle for snapshot file
  100.  
  101. scrbuf  db      80 dup (0)              ; receives screen data
  102. slen    dw      $-scrbuf                ; length of screen buffer       
  103.  
  104. newline db      cr,lf                   ; carriage return-linefeed
  105. nl_len  equ     $-newline
  106.  
  107. gseg    dw    ?            ; global info segment selector
  108. lseg    dw    ?            ; local info segment selector
  109.  
  110. obuff    db    64 dup (0)        ; receives name of dynlink
  111. obuff_len equ   $-obuff                 ; causing DosExecPgm to fail
  112.  
  113. kbdin   dw      128,64 dup (0)          ; input and output buffers
  114. kbdout  dw      128,64 dup (0)          ; for keyboard monitor
  115.  
  116. kbdpkt  db      128 dup (0)             ; keyboard data packet
  117. kpktlen dw      ?                       ; length of buffer/packet
  118.  
  119. pname   db      'SNAP.EXE',0            ; child process name
  120. retcode dd      0                       ; child process info
  121.  
  122. vioinfo label   byte                    ; receives display mode
  123.         dw      8                       ; length of structure
  124.         db      0                       ; display mode type
  125.         db      0                       ; colors
  126. cols    dw      0                       ; number of columns
  127. rows    dw      0                       ; number of rows
  128.  
  129. msg1    db      'SNAP utility installed!'
  130. msg1_len equ    $-msg1
  131.  
  132. msg2    db      'Alt-F10 to capture screen into file SNAP.IMG,'
  133. msg2_len equ    $-msg2
  134.  
  135. msg3    db      'Ctrl-F10 to shut down SNAP.'
  136. msg3_len equ    $-msg3
  137.  
  138. msg4    db      'SNAP utility deactivated.'
  139. msg4_len equ    $-msg4
  140.  
  141. msg5    db      'Error detected during SNAP installation:'
  142. msg5_len equ    $-msg5
  143.  
  144. msg6    db      'Can''t create SNAP system semaphore.'
  145. msg6_len equ    $-msg6
  146.  
  147. msg7    db      'Can''t start child copy of SNAP.'
  148. msg7_len equ    $-msg7
  149.  
  150. msg8    db      'SNAP is already loaded.'
  151. msg8_len equ    $-msg8
  152.  
  153. msg9    db      'Can''t open KBD$ monitor connection.'
  154. msg9_len equ    $-msg9
  155.  
  156. msg10   db      'Can''t register as KBD$ monitor.'
  157. msg10_len equ   $-msg10
  158.  
  159. msg11   db      'Can''t allocate thread stack.'
  160. msg11_len equ   $-msg11
  161.  
  162. msg12   db      'Can''t create keyboard thread.'
  163. msg12_len equ   $-msg12
  164.  
  165. msg13   db      'Can''t create snapshot thread.'
  166. msg13_len equ   $-msg13
  167.  
  168. msg14   db      'Can''t create snapshot file.'
  169. msg14_len equ   $-msg14
  170.  
  171. divider db      79 dup ('-'),cr,lf
  172. divider_len equ $-divider
  173.  
  174. _DATA   ends
  175.  
  176.  
  177. _TEXT   segment word public 'CODE'
  178.  
  179.         assume  cs:_TEXT,ds:DGROUP
  180.  
  181. main    proc    far                     ; entry point from OS/2
  182.  
  183.                     ; get info segment selectors
  184.     push    ds            ; receives global info selector
  185.         push    offset DGROUP:gseg
  186.     push    ds            ; receives local info selector
  187.         push    offset DGROUP:lseg
  188.         call    DosGetInfoSeg           ; transfer to OS/2
  189.  
  190.                                         ; build system semaphore
  191.                                         ; and snapshot file names
  192.         mov     es,gseg                 ; get foreground screen group
  193.         mov     al,es:[0018h]
  194.         aam                             ; convert to ASCII
  195.         add     ax,'00'
  196.         xchg    ah,al
  197.         mov     word ptr fname1,ax      ; store into filename
  198.         mov     word ptr sname1,ax      ; store into semaphore name
  199.  
  200.                                         ; does SNAPxx.LCK exist?
  201.         push    ds                      ; receives semaphore handle
  202.         push    offset DGROUP:shandle
  203.         push    ds
  204.         push    offset DGROUP:sname     ; semaphore name
  205.         call    DosOpenSem              ; transfer to OS/2
  206.         or      ax,ax                   ; was open successful?
  207.         jz      main1                   ; jump, we're child SNAP
  208.  
  209.                                         ; we're the parent SNAP,
  210.                                         ; create system semaphore
  211.     push    1            ; make it nonexclusive
  212.         push    ds                      ; receives semaphore handle
  213.         push    offset DGROUP:shandle
  214.         push    ds                      ; system semaphore name
  215.         push    offset DGROUP:sname
  216.         call    DosCreateSem            ; transfer to OS/2
  217.         jerr    error,msg6,msg6_len     ; jump if create failed
  218.  
  219.                                         ; set the semaphore...
  220.         push    word ptr shandle+2      ; semaphore handle
  221.         push    word ptr shandle
  222.         call    DosSemSet               ; transfer to OS/2
  223.  
  224.                                         ; launch child SNAP...
  225.         push    ds                      ; object name buffer
  226.         push    offset DGROUP:obuff     ; receives failed dynlink
  227.         push    obuff_len               ; length of buffer
  228.         push    4                       ; child detached
  229.         push    0                       ; NULL argument pointer
  230.         push    0
  231.         push    0                       ; NULL environment pointer
  232.         push    0
  233.         push    ds                      ; receives child info
  234.         push    offset DGROUP:retcode
  235.         push    ds                      ; pathname for child
  236.         push    offset DGROUP:pname
  237.         call    DosExecPgm              ; request launch of child
  238.         jerr    error,msg7,msg7_len     ; jump if launch failed
  239.  
  240.                                         ; wait for child to load
  241.         push    word ptr shandle+2      ; semaphore handle
  242.         push    word ptr shandle
  243.         push    -1                      ; timeout = indefinite
  244.         push    -1
  245.         call    DosSemWait              ; transfer to OS/2
  246.  
  247.                                         ; close the semaphore...
  248.         push    word ptr shandle+2      ; semaphore handle
  249.         push    word ptr shandle
  250.         call    DosCloseSem             ; transfer to OS/2
  251.  
  252.         jmp     main3                   ; now exit
  253.  
  254. main1:                                  ; come here if child SNAP...
  255.                                         ; check if already resident
  256.         push    word ptr shandle+2      ; semaphore handle
  257.         push    word ptr shandle
  258.         push    0                       ; timeout = 0 
  259.         push    0                 
  260.         call    DosSemWait              ; transfer to OS/2
  261.         or      ax,ax                   ; is semaphore clear?
  262.         jnz     main2                   ; no, proceed
  263.  
  264.                                         ; yes, don't load again
  265.         mov     dx,offset DGROUP:msg8   ; address of warning message
  266.         mov     cx,msg8_len             ; length of message
  267.         jmp     error                   ; display message and exit
  268.  
  269. main2:                                  ; initialize semaphores...
  270.         push    ds                      ; address of exit semaphore
  271.         push    offset DGROUP:exitsem           
  272.         call    DosSemSet               ; transfer to OS/2
  273.  
  274.         push    ds                      ; address of snapshot semaphore
  275.         push    offset DGROUP:snapsem           
  276.         call    DosSemSet               ; transfer to OS/2
  277.  
  278.                                         ; open monitor connection ...
  279.         push    ds                      ; address of device name
  280.         push    offset DGROUP:kname
  281.         push    ds                      ; receives monitor handle
  282.         push    offset DGROUP:khandle
  283.         call    DosMonOpen              ; transfer to OS/2
  284.         jerr    error,msg9,msg9_len     ; jump if open failed
  285.  
  286.                                         ; register as keyboard monitor
  287.         push    khandle                 ; handle from DosMonOpen
  288.         push    ds                      ; monitor input buffer address
  289.         push    offset DGROUP:kbdin
  290.         push    ds                      ; monitor output buffer address
  291.         push    offset DGROUP:kbdout
  292.         push    1                       ; position = front of list
  293.         mov     es,gseg                 ; foreground session number
  294.         mov     al,byte ptr es:[0018h]  ; from global info segment
  295.         xor     ah,ah
  296.         push    ax
  297.         call    DosMonReg               ; transfer to OS/2
  298.         jerr    error,msg10,msg10_len   ; jump if register failed
  299.  
  300.         push    stksize                 ; allocate stack for WATCH thread
  301.         push    ds                      ; variable to receive selector
  302.         push    offset DGROUP:sel
  303.     push    0            ; not shareable
  304.         call    DosAllocSeg             ; transfer to OS/2
  305.         jerr    error,msg11,msg11_len   ; jump, can't allocate stack
  306.  
  307.                                         ; create keyboard thread
  308.         push    cs                      ; initial execution address
  309.         push    offset _TEXT:watch
  310.         push    ds                      ; receives thread ID
  311.         push    offset DGROUP:watchID
  312.         push    sel                     ; address of thread's stack
  313.         push    stksize
  314.         call    DosCreateThread         ; transfer to OS/2
  315.         jerr    error,msg12,msg12_len   ; jump, can't create thread
  316.  
  317.                                         ; promote keyboard thread
  318.         push    2                       ; scope = single thread
  319.         push    3                       ; class = time critical
  320.         push    0                       ; delta = 0
  321.         push    watchID                 ; thread ID
  322.         call    DosSetPrty              ; transfer to OS/2
  323.  
  324.         push    stksize                 ; allocate stack for SNAP thread
  325.         push    ds                      ; variable to receive selector
  326.         push    offset DGROUP:sel
  327.     push    0            ; not shareable
  328.         call    DosAllocSeg             ; transfer to OS/2
  329.         jerr    error,msg11,msg11_len   ; jump, can't allocate stack
  330.  
  331.                                         ; create snapshot thread
  332.         push    cs                      ; initial execution address
  333.         push    offset _TEXT:snap
  334.         push    ds                      ; receives thread ID
  335.         push    offset DGROUP:snapID
  336.         push    sel                     ; address of thread's stack
  337.         push    stksize
  338.         call    DosCreateThread         ; transfer to OS/2
  339.         jerr    error,msg13,msg13_len   ; jump, can't create thread
  340.  
  341.         call    signon                  ; announce installation
  342.  
  343.                                         ; tell parent we are running
  344.         push    word ptr shandle+2      ; semaphore handle
  345.         push    word ptr shandle
  346.         call    DosSemClear             ; transfer to OS/2      
  347.  
  348.                                         ; block on exit semaphore...
  349.         push    ds                      ; semaphore handle
  350.         push    offset DGROUP:exitsem
  351.         push    -1                      ; timeout = indefinite
  352.         push    -1
  353.         call    DosSemWait              ; transfer to OS/2
  354.  
  355.         push    watchID                 ; suspend keyboard thread
  356.         call    DosSuspendThread        ; transfer to OS/2      
  357.  
  358.         push    snapID                  ; suspend snapshot thread
  359.         call    DosSuspendThread        ; transfer to OS/2
  360.  
  361.                                         ; close monitor connection
  362.         push    khandle                 ; monitor handle
  363.         call    DosMonClose             ; transfer to OS/2
  364.  
  365.                                         ; close system semaphore
  366.         push    word ptr shandle+2      ; semaphore handle
  367.         push    word ptr shandle
  368.         call    DosCloseSem             ; transfer to OS/2
  369.  
  370.                                         ; close snapshot file
  371.         push    fhandle                 ; file handle
  372.         call    DosClose                ; transfer to OS/2
  373.  
  374.     call    signoff         ; announce deinstallation
  375.  
  376. main3:  push    1                       ; terminate all threads
  377.         push    0                       ; return success code
  378.         call    DosExit                 ; final exit to OS/2
  379.  
  380. main    endp
  381.  
  382.  
  383. error   proc    near                    ; fatal error encountered
  384.                     ; DS:DX = message, CX = length
  385.  
  386.         test    khandle,-1              ; monitor active?
  387.         jz      error1                  ; no, jump
  388.  
  389.                                         ; yes, shut it down
  390.         push    khandle                 ; monitor handle
  391.         call    DosMonClose             ; transfer to OS/2
  392.  
  393. error1: mov     ax,word ptr shandle     ; system semaphore open?
  394.         or      ax,word ptr shandle+2
  395.         jz      error2                  ; no, jump
  396.  
  397.                                         ; clear semaphore, in case
  398.                                         ; we're the child SNAP
  399.         push    word ptr shandle+2      ; semaphore handle
  400.         push    word ptr shandle
  401.         call    DosSemClear             ; transfer to OS/2
  402.  
  403.                                         ; close the semaphore
  404.         push    word ptr shandle+2      ; semaphore handle
  405.         push    word ptr shandle
  406.         call    DosCloseSem             ; transfer to OS/2
  407.  
  408. error2: mov     ax,1                    ; get popup window
  409.         call    popup
  410.  
  411.                                         ; display title...
  412.         push    ds                      ; message address
  413.         push    offset DGROUP:msg5
  414.         push    msg5_len                ; message length
  415.         push    10                      ; Y
  416.         push    (80-msg5_len)/2         ; X (center it)
  417.     push    0            ; Vio handle
  418.         call    VioWrtCharStr           ; transfer to OS/2
  419.  
  420.                                         ; display error message...
  421.         push    ds                      ; message address
  422.         push    dx
  423.         push    cx                      ; message length
  424.         push    12                      ; Y
  425.         mov     ax,80                   ; X (center it)
  426.         sub     ax,cx
  427.         shr     ax,1
  428.         push    ax
  429.     push    0            ; Vio handle
  430.         call    VioWrtCharStr           ; transfer to OS/2
  431.  
  432.     push    0            ; pause for 3 seconds
  433.     push    3000
  434.         call    DosSleep                ; transfer to OS/2
  435.  
  436.         call    unpop                   ; release popup window
  437.  
  438.         push    1                       ; terminate all threads
  439.         push    1                       ; return error code
  440.         call    DosExit                 ; exit program
  441.  
  442. error   endp
  443.  
  444.  
  445. watch   proc    far                     ; keyboard thread, monitors
  446.                     ; for snapshot or exit hot keys
  447.  
  448.         mov     kpktlen,kpktlen-kbdpkt  ; max buffer length for read
  449.  
  450.                                         ; get keyboard data packet...
  451.         push    ds                      ; monitor input buffer address
  452.         push    offset DGROUP:kbdin
  453.         push    0                       ; wait until data available
  454.         push    ds
  455.         push    offset DGROUP:kbdpkt    ; receives keyboard data packet
  456.         push    ds
  457.         push    offset DGROUP:kpktlen   ; contains/receives length
  458.         call    DosMonRead              ; transfer to OS/2
  459.  
  460.         cmp     kbdpkt+2,0              ; is this extended code?
  461.         jnz     watch1                  ; no, pass it on
  462.  
  463.     cmp    kbdpkt+3,exitkey    ; is it exit hot key?
  464.         jz      watch2                  ; jump if exit key
  465.  
  466.     cmp    kbdpkt+3,snapkey    ; is it snapshot hot key?
  467.         jnz     watch1                  ; no, jump
  468.  
  469.         cmp     word ptr kbdpkt+12,0    ; is it break packet?
  470.         jnz     watch                   ; yes, ignore it
  471.  
  472.                     ; snapshot hot key detected
  473.                                         ; clear snapshot semaphore...
  474.         push    ds                      ; semaphore handle
  475.         push    offset DGROUP:snapsem
  476.         call    DosSemClear             ; transfer to OS/2
  477.     jmp    watch            ; discard this hot key
  478.  
  479. watch1:                 ; not hot key, pass character
  480.         push    ds                      ; monitor output buffer address
  481.         push    offset DGROUP:kbdout
  482.         push    ds                      ; keyboard data packet address
  483.         push    offset DGROUP:kbdpkt    
  484.         push    kpktlen                 ; length of data packet
  485.         call    DosMonWrite             ; transfer to OS/2
  486.         
  487.         jmp     watch                   ; get another packet
  488.  
  489. watch2:                 ; exit hot key detected...
  490.         cmp     word ptr kbdpkt+12,0    ; is it break packet?
  491.         jnz     watch                   ; yes, ignore it
  492.  
  493.                                         ; clear exit semaphore...
  494.         push    ds                      ; semaphore handle
  495.         push    offset DGROUP:exitsem
  496.         call    DosSemClear             ; transfer to OS/2
  497.  
  498.         jmp     watch                   ; let thread 1 shut down
  499.  
  500. watch   endp
  501.  
  502.  
  503. snap    proc    far                     ; This thread blocks on the 
  504.                                         ; snapshot semaphore, then
  505.                                         ; dumps the screen contents
  506.                     ; to the file SNAPxx.IMG.
  507.         
  508.                                         ; open/create snapshot file
  509.         push    ds                      ; address of filename
  510.         push    offset DGROUP:fname
  511.         push    ds                      ; variable to receive file handle
  512.         push    offset DGROUP:fhandle
  513.         push    ds                      ; variable to receive action taken
  514.         push    offset DGROUP:action    
  515.         push    0                       ; initial file size
  516.         push    0
  517.         push    0                       ; normal file attribute 
  518.         push    12h                     ; create or replace file
  519.         push    21h                     ; write access, deny write
  520.         push    0                       ; DWORD reserved
  521.         push    0
  522.         call    DosOpen                 ; transfer to OS/2
  523.         jerr    error,msg14,msg14_len   ; jump if can't create
  524.  
  525. snap1:                                  ; write divider line 
  526.         push    fhandle                 ; file handle
  527.         push    ds                      ; address of divider string
  528.         push    offset DGROUP:divider
  529.         push    divider_len             ; length of string
  530.         push    ds                      ; receives bytes written
  531.         push    offset DGROUP:wlen
  532.         call    DosWrite                ; transfer to OS/2
  533.  
  534.                                         ; force disk update...
  535.         push    fhandle                 ; file handle
  536.         call    DosBufReset             ; transfer to OS/2
  537.  
  538.                                         ; wait on snapshot semaphore
  539.         push    ds                      ; semaphore handle
  540.         push    offset DGROUP:snapsem
  541.         push    -1                      ; timeout = indefinite
  542.         push    -1
  543.         call    DosSemWait              ; transfer to OS/2
  544.  
  545.     mov    ax,3            ; pop-up in transparent mode
  546.         call    popup                   ; to read screen contents
  547.  
  548.                                         ; get screen dimensions...
  549.         push    ds                      ; receives video mode info
  550.         push    offset DGROUP:vioinfo
  551.     push    0            ; Vio handle
  552.         call    VioGetMode              ; transfer to OS/2
  553.  
  554.         mov     bx,0                    ; BX := initial screen row 
  555.  
  556. snap2:                                  ; read line from screen...
  557.         mov     ax,cols                 ; width to read
  558.         mov     slen,ax
  559.         push    ds                      ; address of screen buffer
  560.         push    offset DGROUP:scrbuf
  561.         push    ds                      ; contains/receives length
  562.         push    offset DGROUP:slen
  563.         push    bx                      ; screen row
  564.         push    0                       ; screen column
  565.     push    0            ; Vio handle
  566.         call    VioReadCharStr          ; transfer to OS/2
  567.  
  568.         push    ds                      ; scan backwards from end
  569.         pop     es                      ; of line to find last 
  570.     mov    cx,slen         ; nonblank character
  571.         mov     di,offset DGROUP:scrbuf
  572.         add     di,slen
  573.         dec     di
  574.         mov     al,20h
  575.         std     
  576.         repe scasb
  577.         cld     
  578.         jz      snap3                   ; if Z = True, line was empty
  579.         inc     cx                      ; otherwise correct the length
  580.  
  581. snap3:                                  ; write line to file...
  582.         push    fhandle                 ; file handle
  583.         push    ds                      ; address of data
  584.         push    offset DGROUP:scrbuf
  585.         push    cx                      ; clipped line length
  586.         push    ds                      ; receives bytes written
  587.         push    offset DGROUP:wlen
  588.         call    DosWrite                ; transfer to OS/2
  589.  
  590.                     ; write newline (CR-LF)
  591.         push    fhandle                 ; file handle
  592.         push    ds
  593.     push    offset DGROUP:newline    ; address of newline
  594.     push    nl_len            ; length of newline
  595.         push    ds                      ; receives bytes written
  596.         push    offset DGROUP:wlen
  597.         call    DosWrite                ; transfer to OS/2      
  598.  
  599.         inc     bx                      ; bump screen row counter
  600.         cmp     bx,rows                 ; whole screen done yet?
  601.         jne     snap2                   ; no, write another
  602.  
  603.         push    440                     ; reward user with some
  604.         push    200                     ; audible feedback
  605.         call    DosBeep                 ; transfer to OS/2
  606.  
  607.         call    unpop                   ; release the screen
  608.  
  609.                                         ; done with screen capture,
  610.                                         ; reset snapshot semaphore
  611.         push    ds                      ; semaphore handle
  612.         push    offset DGROUP:snapsem
  613.         call    DosSemSet               ; transfer to OS/2
  614.  
  615.         jmp     snap1                   ; go wait on semaphore
  616.         
  617. snap    endp
  618.  
  619.  
  620. signon  proc    near                    ; announce installation,
  621.                                         ; display help message
  622.  
  623.         mov     ax,1                    ; put up popup window
  624.     call    popup            ; mode = wait, nontransparent
  625.  
  626.         push    ds                      ; message address
  627.         push    offset DGROUP:msg1
  628.         push    msg1_len                ; message length
  629.         push    10                      ; Y
  630.         push    (80-msg1_len)/2         ; X (center it)
  631.     push    0            ; Vio handle
  632.         call    VioWrtCharStr           ; transfer to OS/2
  633.  
  634.         push    ds                      ; message address
  635.         push    offset DGROUP:msg2
  636.         push    msg2_len                ; message length
  637.         push    13                      ; Y
  638.         push    (80-msg2_len)/2         ; X (center it)
  639.     push    0            ; Vio handle
  640.         call    VioWrtCharStr           ; transfer to OS/2
  641.  
  642.         push    ds                      ; message address
  643.         push    offset DGROUP:msg3
  644.         push    msg3_len                ; message length
  645.         push    15                      ; Y
  646.         push    (80-msg3_len)/2         ; X (center it)
  647.     push    0            ; Vio handle
  648.         call    VioWrtCharStr           ; transfer to OS/2
  649.  
  650.     push    0            ; pause for 4 seconds
  651.     push    4000            ; so user can read message
  652.         call    DosSleep                ; transfer to OS/2      
  653.  
  654.         call    unpop                   ; take down popup window
  655.         ret                             ; back to caller
  656.  
  657. signon  endp
  658.  
  659.  
  660. signoff proc    near            ; announce deinstallation
  661.  
  662.         mov     ax,1                    ; put up popup window
  663.     call    popup            ; mode = wait, nontransparent
  664.  
  665.         push    ds                      ; message address
  666.         push    offset DGROUP:msg4
  667.         push    msg4_len                ; message length
  668.         push    12                      ; Y
  669.         push    (80-msg4_len)/2         ; X (center it)
  670.         push    0                       ; VIO handle
  671.         call    VioWrtCharStr
  672.  
  673.     push    0            ; pause for 2 seconds
  674.     push    2000            ; so user can read message
  675.         call    DosSleep                ; transfer to OS/2
  676.  
  677.         call    unpop                   ; take down popup window
  678.         ret                             
  679.  
  680. signoff endp
  681.  
  682.  
  683. popup   proc    near                    ; put up popup window
  684.                                         ; AX = VioPopUp flags
  685.                                         ; bit 0 = 0 no wait
  686.                     ;      1 wait for pop-up
  687.                     ; bit 1 = 0 nontransparent
  688.                                         ;         1 transparent
  689.  
  690.     mov    pflags,ax        ; set pop-up mode
  691.  
  692.     push    ds            ; address of popup flags
  693.         push    offset DGROUP:pflags
  694.     push    0            ; Vio handle
  695.         call    VioPopUp                ; transfer to OS/2
  696.         ret                             ; back to caller
  697.  
  698. popup   endp
  699.  
  700.  
  701. unpop   proc    near                    ; take down popup window
  702.  
  703.     push    0            ; Vio handle
  704.         call    VioEndPopUp             ; transfer to OS/2
  705.         ret                             ; back to caller
  706.  
  707. unpop   endp
  708.  
  709. _TEXT   ends
  710.  
  711.         end     main
  712.  
  713. 
  714.  
  715.