From:	CRDGW2::CRDGW2::MRGATE::"SMTP::CRVAX.SRI.COM::RELAY-INFO-VAX" 28-AUG-1989 20:55
To:	MRGATE::"ARISIA::EVERHART"
Subj:	SNAP, part 1 of 8

Message-Id:  <8908290043.AA14914@crdgw1.ge.com>
Received: From KL.SRI.COM by CRVAX.SRI.COM with TCP; Mon, 28 AUG 89 13:51:24 PDT
Received: from drcvax.af.mil by KL.SRI.COM with TCP; Mon, 28 Aug 89 05:28:37 PDT
Date: 28 Aug 89 08:23:00 EST
From: "Daniel J. Graham" <graham@drcvax.af.mil>
Subject: SNAP, part 1 of 8
To: "info-vax" <info-vax@kl.sri.com>

Here it is gang.  SNAP & WATCH in 8 parts.  Clip 'em, concatonate 'em and @ 
'em.  Read the AAAREADME.TXT for complete documentation.

Have fun,

Dan Graham
--------------------------------------------------------------
$! ------------------ CUT HERE -----------------------
$ v='f$verify(f$trnlnm("SHARE_VERIFY"))'
$!
$! This archive created by VMS_SHARE Version 7.1-004  3-AUG-1989
$!   On 25-AUG-1989 10:51:19.52   By user DGRAHAM 
$!
$! This VMS_SHARE Written by:
$!    Andy Harper, Kings College London UK
$!
$! Acknowledgements to:
$!    James Gray       - Original VMS_SHARE
$!    Michael Bednarek - Original Concept and implementation
$!
$!+ THIS PACKAGE DISTRIBUTED IN 8 PARTS, TO KEEP EACH PART
$!  BELOW 30 BLOCKS
$!
$! TO UNPACK THIS SHARE FILE, CONCATENATE ALL PARTS IN ORDER
$! AND EXECUTE AS A COMMAND PROCEDURE  (  @name  )
$!
$! THE FOLLOWING FILE(S) WILL BE CREATED AFTER UNPACKING:
$!       1. AAAREADME.TXT;2
$!       2. BUILD.COM;3
$!       3. LIB_DEFAULT_DIR.MAR;1
$!       4. SNAP.FOR;15
$!       5. VIEW.COM;1
$!       6. WATCH.MAR;2
$!
$set="set"
$set symbol/scope=(nolocal,noglobal)
$f=f$parse("SHARE_TEMP","SYS$SCRATCH:.TMP_"+f$getjpi("","PID"))
$e="write sys$error  ""%UNPACK"", "
$w="write sys$output ""%UNPACK"", "
$ if f$trnlnm("SHARE_LOG") then $ w = "!"
$ if f$getsyi("version") .ges. "V4.4" then $ goto START
$ e "-E-OLDVER, Must run at least VMS 4.4"
$ v=f$verify(v)
$ exit 44
$UNPACK: SUBROUTINE ! P1=filename, P2=checksum
$ if f$search(P1) .eqs. "" then $ goto file_absent
$ e "-W-EXISTS, File ''P1' exists. Skipped."
$ delete/nolog 'f'*
$ exit
$file_absent:
$ if f$parse(P1) .nes. "" then $ goto dirok
$ dn=f$parse(P1,,,"DIRECTORY")
$ w "-I-CREDIR, Creating directory ''dn'."
$ create/dir 'dn'
$ if $status then $ goto dirok
$ e "-E-CREDIRFAIL, Unable to create ''dn'. File skipped."
$ delete/nolog 'f'*
$ exit
$dirok:
$ w "-I-PROCESS, Processing file ''P1'."
$ define/user sys$output nl:
$ EDIT/TPU/NOSEC/NODIS/COM=SYS$INPUT 'f'/OUT='P1'
PROCEDURE Unpacker ON_ERROR ENDON_ERROR;SET(FACILITY_NAME,"UNPACK");SET(
SUCCESS,OFF);SET(INFORMATIONAL,OFF);f:=GET_INFO(COMMAND_LINE,"file_name");
buff:=CREATE_BUFFER(f,f);p:=SPAN(" ")@r&LINE_END;POSITION(BEGINNING_OF(buff))
;LOOP EXITIF SEARCH(p,FORWARD)=0;POSITION(r);ERASE(r);ENDLOOP;POSITION(
BEGINNING_OF(buff));g:=0;LOOP EXITIF MARK(NONE)=END_OF(buff);x:=
ERASE_CHARACTER(1);IF g = 0 THEN IF x="X" THEN MOVE_VERTICAL(1);ENDIF;IF x=
"V" THEN APPEND_LINE;MOVE_HORIZONTAL(-CURRENT_OFFSET);MOVE_VERTICAL(1);ENDIF;
IF x="+" THEN g:=1;ERASE_LINE;ENDIF;ELSE IF x="-" THEN g:=0;ENDIF;ERASE_LINE;
ENDIF;ENDLOOP;p:="`";POSITION(BEGINNING_OF(buff));LOOP r:=SEARCH(p,FORWARD);
EXITIF r=0;POSITION(r);ERASE(r);COPY_TEXT(ASCII(INT(ERASE_CHARACTER(3))));
ENDLOOP;o:=GET_INFO(COMMAND_LINE,"output_file");WRITE_FILE(buff,o);
ENDPROCEDURE;Unpacker;EXIT;
$ delete/nolog 'f'*
$ CHECKSUM 'P1'
$ IF CHECKSUM$CHECKSUM .eqs. P2 THEN $ EXIT
$ e "-E-CHKSMFAIL, Checksum of ''P1' failed."
$ ENDSUBROUTINE
$START:
$ create/nolog 'f'
X                          DOCUMENTATION FOR
X
X                                 snap
X
X                                  BY
X
X                           DANIEL J. GRAHAM
X
XSNAP is a process control program for the system manager.  It allows`032
Xmany different kinds of viewing and manipulations on user or system`032
Xprocesses. `032
X
XSNAP is a very fancy SHOW USERS.  it gives a useful screen of`032
Xinformation about each user process on the system.  (Optionally, it`032
Xalso gives the same stuff about system processes.)  You can get a`032
Xbunch of statistics on the process, you can view what is going on on a`032
Xterminal or write to that terminal's buffer, you can delete a process,`032
Xforce an image exit on a process, change priority, suspend or resume a`032
Xprocess.
X
X        WARNING:  Do not install this program with privs.  It is very`032
X        dangerous and could seriously compromise your system's`032
X        security if used by someone with intent to do damage.  Do not`032
X        make it available to any but trusted systems people.
X
X
XBuilding SNAP:
X
XThere are some parts of the program SNAP.FOR which will need editing`032
Xbefore you build the image.
X
X        - SNAP will see up to 200 processes.  If you anticipate`032
X        viewing more, modify the MAX_PROCESS parameter at the top`032
X        of the program SNAP.FOR.`032
X       `032
X        - The usernames that are skipped in a non-system view`032
X        `091what normally happens`093 are SYSTEM, DECNET, MRMANAGER,`032
X        MRTIDY and ORACLE.  The last one is because we run that`032
X        product.  If you wish to alter that list, simply modify
X        the appropriate IF statement a few lines beyond label 10`032
X        in SNAP.FOR.`032
X       `032
X        - The VIEW function depends on the LIB$DO_COMMAND call. A`032
X        small command file is executed to run the program that`032
X        can't be a part of the SNAP image, then SNAP is rerun. `032
X        In this instances, you must edit SNAP.FOR to tell the
X        program where the VIEW.COM file is located.  Do a search`032
X        within your editor for the string DCLCMD.  You will find`032
X        the place.  Note that the string is defined as a`032
X        CHARACTER*49.  If your string is longer, extend that
X        definition.  You will also want to edit VIEW.COM to`032
X        indicate the proper location of WATCH.EXE, the program`032
X        activated by the VIEW function.
X
XExecute the BUILD.COM file to make everything happen correctly. `032
XDefine a foreign symbol like so:
X
X  $ SNAP := $DISK:`091DIRECTORY`093SNAP.EXE
X
XThen to run SNAP, just enter the command SNAP, or SNAP S if you want`032
Xto see all system processes too.
X
X      NOTE -- When BUILD.COM is compiling the MACRO modules and`032
X      programs, you will see some generated warnings about the code`032
X      not being fit for multiprocessor systems.  Ignore this.  We`032
X      haven't been able to find the reason for the warnings, but the`032
X      package does seem to run just fine on SMP systems.
X
X
XUsing SNAP:
X
XSNAP uses SMG$ screens and key capture commands to make operation`032
Xeasy.  First, a screen is painted with one line for each process and`032
Xthe commands at the bottom.  The first 18 processes are displayed upon`032
Xinitialization.  Pressing the DOWN ARROW will display the next 18. `032
XPressing the UP ARROW will revert to the previous 18.  Pressing the`032
Xkeypad comma will take the display to the last 18 processes, the`032
Xkeypad minus will display the first 18.
X
XThe various actions work on specific processes.  To select an action,`032
Xyou may enter the first letter of that action and press return; you`032
Xmay use the right and left arrows to highlight the word of the action`032
Xyou desire at the bottom of the display and press return or you may`032
Xpress the appropriate keypad key and not bother pressing return.
X
XIt is necessary to have the process you wish to act upon in the`032
Xprocess scroll window BEFORE you choose an action type.
X
XEntering "A" will simply update the basic information again.  Entering`032
Xan "E" will cause an exit, as will a "Q," a control Z or PF4.  A`032
XControl W or PF3 will refresh the screen in case of broadcast message`032
Xfoul-ups.`032
X
XThe A (again) command redisplays the processes that are not system`032
Xones.  A keypad 9 will change the display to include all system`032
Xprocesses too.  Using A after this will again revert the display to`032
Xnon-system processes only.
X
XBy default, SNAP sees only user processes, omitting system usernames`032
Xas mentioned earlier.  To view all processes on the system, invoke`032
XSNAP with a parameter of "S",  $ SNAP S, or use the keypad as`032
Xmentioned above.
X
XActions:
X
XAgain - This does not act upon a process, but regathers the process`032
Xinformation and displays it.  The window is shifted to the first 18`032
Xprocesses, non-system ones only are shown.
X
XDelete - This will Delete the selected process.
X
XForce - This will force an image exit on the selected process, using`032
Xthe FORCEX system service.
X
XStats - This will gather some statistics about the processes,`032
Xincluding their current directory and their LAT server and port if you`032
Xare using those items.
X
XCont - This does a SHOW PROCESS/CONTINUOUS on a process.  It does this`032
Xby running an external command file and rerunning the program, kludgy`032
Xbut the only way I could find to do it.
X
XView - This executes the WATCH program which allows you to view a`032
Xterminal and, optionally, force input to it.  This is the really`032
Xdangerous one and should be given out carefully.  DO NOT ATTEMPT TO`032
XVIEW an RTA device, it will crash the system.  Leave View with a`032
Xcontrol-z.  Toggle input mode to the Viewed terminal with a`032
Xcontrol-backslash.  Toggle input mode off before exiting, or you will`032
Xinput a control-z to the viewed terminal.
X
XModify - This presents a small menu with three choices, modify a`032
Xprocess's priority, suspend a process or resume one.
X
XUAF - This will select some data from the System Authorization file`032
Xand display it.
X
XExit - This exits the program.  At almost every point in the program`032
Xan E, Q or CTRL/Z will cause an exit.
X
XRefresh Screen - In case of broadcasts screwing up the screen, the`032
Xstandard CTRL/W screen refresh is implemented.
X
X
XKeypad Mode:
X
XHere is a picture of the keypad commands:
X
X            +------+------+------+------+
X            `124      `124 This `124Redraw`124 Exit `124
X            `124      `124 Help `124Screen`124Screen`124
X            +------+------+------+------+
X            `124Modify`124 UAF  `124Again/`124Top of`124
X            `124 Proc `124 Info `124system`124 List `124
X            +------+------+------+------+
X            `124 View `124 Proc `124 Show `124End of`124
X            `124 Term `124Stats `124 Cont `124 List `124
X            +------+------+------+------+
X            `124  Do  `124Delete`124Force `124      `124
X            `124Again `124Proc  `124  `094Y  `124Press `124
X            +------+------+------+ for  +
X            `124             `124      `124action`124
X            `124             `124      `124      `124
X            +-------------+------+------+
X
XThe "Top of List," "End of List" and "Again/system" functions are`032
Xavailable only in keypad mode.`032
X
XThanks go to the authors of lib_default_dir.mar and watch.mar. `032
XWatch.mar is a program that can get you into a lot of trouble,`032
Xespecially with people being paranoid about invasion of privacy.  Use`032
Xit with care and discretion and, for Pete's sake, don't brag about`032
Xhaving it to users who don't need to know.`032
X
XI am happy to answer questions and entertain all suggestions for`032
Xbetter performance or additional features.
X
X-----------
XDan Graham
XDynamics Research Corporation, Andover, Ma
X(508) 475-9090 x2352
XInternet address:  graham@drcvax.af.mil
X======================================================================
XDISCLAIMER:
X
XNeither I nor my employer take any responsibility for any effects of`032
Xusing this program package.  It is possible that in some cases, these`032
Xprograms may be illegal to use or against government or company`032
Xpolicy.  Use is at the risk and discretion of each individual`032
Xreceiving the program package.
X
XWe assume no responsibility for any damage caused by the use of SNAP`032
Xor WATCH, whether of a business, personal or data processing nature.
X
$ CALL UNPACK AAAREADME.TXT;2 375302175
$ create/nolog 'f'
X$! This procedure will build the SNAP product.
X$!
X$ MAC LIB_DEFAULT_DIR
X$ MAC WATCH
X$ FOR/EXT SNAP
X$ LINK/NOTRACE SNAP,LIB_DEFAULT_DIR,SYS$SYSTEM:SYS.STB/SEL
X$ LINK WATCH
X$ EXIT
$ CALL UNPACK BUILD.COM;3 1465714487
$ create/nolog 'f'
X        .title  lib_default_dir - obtain default directory of a process
X
X;++
X; FACILITY:     JCF SYSTEM PROGRAMS
X;
X; ABSTRACT:     This routine obtains the default directory of a given
X;               process specified by process ID. It uses a special kernel
X;               mode AST to get the translation of SYS$DISK and the director
Vy
X;               string in PIO$GT_DDSTRING of the processes virtual address
X;               space.
X;
X; ENVIRONMENT:  Native, User and Kernel mode, privileged code
X;               Not reentrant -- do not call from AST level.
X;
X; AUTHOR:       Michael R. Gretzinger
X; DATE:         26-OCT-1982
X;
X;       Copyright (C) 1982  MIT Joint Computer Facility
X;
X; MODIFIED BY:  Ned Freed (MATHLIB) converted program to routine.
X;               Extensive rewrite for VMS 4.0.
X;
X;               Ned Freed (MATHLIB) converted to use LNM$SEARCH_ONE;
X;               LNM$SEARCHLOG isn't available in VMS 5.0.
X;
X; Call:
X;   ret-status.wlc.v = LIB_DEFAULT_DIR (pid.rl.r, dirstring.wt.ds)
X;--
X
X        .library "SYS$LIBRARY:LIB"
X
X        $STATEDEF
X        $PCBDEF
X        $PHDDEF
X        $ACBDEF
X        $IPLDEF
X        $PRIDEF
X        $PSLDEF
X        $LNMDEF
X        $LNMSTRDEF
X
Xlnm_size = LNM$C_NAMLENGTH + LNMX$T_XLATION
Xdd_size  = 256
X
X        .psect  $LOCAL, PIC,USR,CON,REL,LCL,NOSHR,NOEXE,RD,WRT,NOVEC,LONG
X
Xpid:     .long  0
Xdevice:  .blkb  lnm_size
Xddstring:.blkb  dd_size
X
X        .psect  $CODE, PIC,USR,CON,REL,LCL,SHR,EXE,RD,NOWRT,NOVEC,LONG
X
X        .entry  lib_default_dir,`094m<r2,r3,r4,r5,r6,r7,r8>
X
X        clrb    device+lnmx$t_xlation   ;default to zero length strings
X        clrb    ddstring
X        movl    @4(ap),r0               ;prepare the pid
X        jsb     G`094exe$epid_to_ipid      ;convert to internal form
X        movl    r0,pid
X        bneq    5$                      ;check for
X        pushl   #ss$_nonexpr            ;non-existent process
X        brb     10$                     ;blank strings and return
X
X5$:     $cmkrnl_s routin=get_defdir     ;get into kernel mode for the
X                                        ;real work
X        pushl   r0                      ;save return status
X
X10$:    movl    8(ap),r6                ;get address of destination descr
X        movw    (r6),r7                 ;grab length of destination string
X        cvtbw   device+lnmx$t_xlation,r8 ;grab length of device string
X        movab   @4(r6),r6               ;get address of destination string
X        movc5   r8,device+lnmx$t_xlation+1,#`094A/ /,-
X                r7,(r6)                 ;install device string
X        tstl    r0                      ;see if any room left
X        bneq    20$
X        subw2   r8,r7                   ;compute the remaining length
X        bleq    20$                     ;if none left just punt
+-+-+-+-+-+-+-+-  END  OF PART 1 +-+-+-+-+-+-+-+-


