From:	CRDGW2::CRDGW2::MRGATE::"SMTP::CRVAX.SRI.COM::RELAY-INFO-VAX" 12-FEB-1992 17:04:44.73
To:	ARISIA::EVERHART
CC:	
Subj:	Program to change other process names

From:	RELAY-INFO-VAX@CRVAX.SRI.COM@SMTP@CRDGW2
To:	Everhart@Arisia@MRGATE

Received:  by crdgw1.ge.com (5.57/GE 1.123)
	 id AA04605; Wed, 12 Feb 92 16:10:39 EST
Received: From CUNYVM.CUNY.EDU by CRVAX.SRI.COM with TCP; Wed, 12 FEB 92 10:58:39 PST
Received: from mailgate.ucd.ie by CUNYVM.CUNY.EDU (IBM VM SMTP V2R2)
   with BSMTP id 4426; Wed, 12 Feb 92 13:58:05 EST
Received: from enterprise.eurokom.ie by mailgate.ucd.ie (PMDF #12050) id
 <01GGFSWDUEQO8WW0GC@mailgate.ucd.ie>; Wed, 12 Feb 1992 16:50 GMT
Received: from kirk.eurokom.ie by enterprise.eurokom.ie (PMDF #12050) id
 <01GGFSX71PYO99DIG0@enterprise.eurokom.ie>; Wed, 12 Feb 1992 16:51 CET
Received: from kirk.eurokom.ie by kirk.eurokom.ie (PMDF #12050) id
 <01GGFT1GMR3W0000BP@kirk.eurokom.ie>; Wed, 12 Feb 1992 16:54 WET
Date: Wed, 12 Feb 1992 16:54 WET
From: VMS Systems <T.Wade@vms.eurokom.ie>
Subject: Program to change other process names
Sender: Tom Wade VMS Systems <T.Wade@VMS.EUROKOM.IE>
To: KJAIN@LOTUS.COM, INFO-VAX@KL.SRI.COM
Message-Id: <01GGFT1GMR3W0000BP@kirk.eurokom.ie>
X-Envelope-To: INFO-VAX@KL.SRI.COM
X-Vms-To: kjain@lotus.com
X-Vms-Cc: info-vax@kl.sri.com

Hello,

Enclosed is a program to allow a privileged user to change the name of a
process other than his own.  There is no supported way to do this via system
services (at least as far as VMS 5.4-3), so you have to resort to something
like this.  Extract out the source .MAR file and compile it.  Extract the
CLD file, altering the IMAGE line to point at your .EXE, and
        $ SET COMMAND <file>.CLD

To invoke, type

        $ Procname <new-process-name> /id=<process=ID>

Have fun.  I have tested it with VMS 5.4-3.

***** Warning ***** Warning ***** Warning ***** Warning ***** Warning *****
THIS IS KERNEL MODE CODE.  ERRORS OCCURRING IN KERNEL MODE NORMALLY RESULT IN
FATAL BUGCHECKS. WHILE THIS PROGRAM HAS BEEN TESTED BY THE IMPLEMENTOR, NO
WARRANTY IS STATED OR IMPLIED AS TO THE BEHAVIOR OF THIS PROGRAM ON YOUR
MACHINE.  IT IS YOUR RESPONSIBILITY TO TEST IT TO YOUR SATISFACTION.
***** Warning ***** Warning ***** Warning ***** Warning ***** Warning *****

------------- File SET-PROCNAME.MAR ---------------------------------------
;*****************************************************************************
;
                .Title  SET_PROC_NAME

;   Set the Process Name for another process.
;
;   (c)  Tom Wade  T.Wade@vms.eurokom.ie 1991.
;
;   This program works under VMS 5.4, and should work for 5.x
;   Command invocation is
;
;       $ PROCNAME  "process-name" /id=<pid>
;
;   You may need to SET COMMAND PROC-NAME.CLD if the command is not in your
;   DCLTABLES (which is unlikely).
;
;   Privileges required:        CMKRNL
;
;   Warning:    This is Kernel Mode Code.  It has been tested on a VAXstation
;               3100 using VMS 5.4, and in a cluster environment.  While it is
;               not anticipated that the program could cause a crash, the
;               author offers no warranty that it won't.  Use at your own risk.


                .Ident          "V1.0"

                .Library        "SYS$SHARE:LIB.MLB"
                .Link           "SYS$SYSTEM:SYS.STB"/SELECTIVE_SEARCH

                $PCBDEF                         ; Process control blocks

;------------------------------------------------------------------------------
;       Macros.
;------------------------------------------------------------------------------

                .Macro  CHECK   ?label          ; check the status
                        Blbs    R0,     label   ; and exit if not
                        $EXIT_S R0              ; ok.
                Label:
                .Endm   CHECK

;------------------------------------------------------------------------------
;       Data used at low IPL.
;------------------------------------------------------------------------------

Proc_prompt:    .Ascid  "NAME"                  ; prompt for the proc name
Pid_Prompt:     .Ascid  "ID"                    ; prompt for the PID.

Input_desc:     .Long   15                      ; user's input
                .Address proc_name

Pid_desc:       .Long   8                       ; user's PID in text form
                .Address pid_text
Pid_Text:       .Blkb   8

Lock_range:     .Address lock_start             ; where to start locking.
                .Address lock_end               ; where to stop locking.


;------------------------------------------------------------------------------
;   User Mode code.
;------------------------------------------------------------------------------

                .Entry  Start   ^M <>

                Pushal  length                  ; input via CLD
                Pushaq  input_desc
                Pushaq  proc_prompt
                Calls   #3,     G^Cli$Get_Value
                Check

                Pushal  pid_desc                ; get the target EPID.
                Pushaq  pid_desc
                Pushaq  pid_prompt
                Calls   #3,     G^Cli$Get_Value
                Check

                Pushal  epid                    ; Convert from hexadecimal
                Pushaq  pid_desc                ; string to longword.
                Calls   #2,     G^Ots$Cvt_TZ_L
                Check

                $LKWSET_S -                     ; batten down the hatches
                        inadr = lock_range
                Check


                $CMKRNL_S -                     ; Warp drive on.
                        routin = set_proc_name, -
                        arglst = pid_args

                Ret                             ; return to DCL


;------------------------------------------------------------------------------
;       Data used at IPL$_Synch
;------------------------------------------------------------------------------

Lock_Start:
Epid:           .Long   0                       ; Extended Pid

Pid_args:       .Long   1                       ; argument block for NAMPID
                .Address epid
                .Long   0

Proc_name:      .Blkb   15                      ; actual process name.
Length:         .Long   0                       ; length of process name.

;------------------------------------------------------------------------------
;       Kernel Mode Code.
;               Convert EPID to IPID, and poke the process name into the
;               target PCB.
;------------------------------------------------------------------------------

                .Entry  SET_PROC_NAME   ^M <R2, R3, R4, R5>

                Jsb     G^Exe$Nampid            ; get internal PID, raise IPL
                Blbc    R0,     exit            ; to 8, and get SCHED spinlock.
                                                ; (target PCB address returned
                                                ; in R4).
                Movb    length, -               ; poke length of proc name
                        Pcb$T_Lname(R4)         ; into PCB
                Movc3   length, proc_name,-     ; poke process name into PCB
                        Pcb$T_Lname+1(R4)

                Unlock  lockname=SCHED, -       ; release spinlock and drop
                        newipl=#0               ; warp drive.

Lock_end:       Movl    #SS$_Normal,    R0      ; return success code.
Exit:           Ret                             ; Beam me up Scotty.

                .End    Start

------------------ File PROC-NAME.CLD ---------------------------------
        Define Verb  PROCNAME
                Image   SYS$DISK:[]SET-PROCNAME
                Parameter       P1, Label=NAME, Value (required)
                Qualifier       ID, Value (required), Default, nonnegatable

--------------------------------------------------------------------------
Tom Wade            |  Internet:    T.Wade@vms.eurokom.ie  (all domain mailers).
Network Manager     |  Bitnet:      T_WADE@EUROKOM
EuroKom             |  PSI-Mail:    PSI%272431001992::_T_WADE
University College  |  DEC EASYnet: DECWRL::"t.wade@vms.eurokom.ie"   (VMS Mail)
Belfield            |  JANET:       t.wade%ie.eurokom.vms@UK.AC.EARN-RELAY
Dublin 4            |  X400:        [Address Exceeds 65536 byte buffer]
Ireland             |  Telex:       (0500) 91178 UCD EI  ("TO: WADE" at start)
--------------------+----------------------------------------------------------
Voice:+353-1-2697890|  Official Disclaimer:  "This is not a disclaimer"
Fax:  +353-1-2838605|          Unix  ....  Just say No !
-------------------------------------------------------------------------------


