From:	SMTP%"MACRO32%WKUVX1.BITNET@uu7.psi.com"  3-JUN-1993 10:39:30.04
To:	EVERHART
CC:	
Subj:	Re: Image activation

X-Listname: "VMS Internals, MACRO, & BLISS Discussions" <MACRO32@WKUVX1.BITNET>
Warnings-To: <>
Errors-To: MacroMan%WKUVX1.BITNET@uu7.psi.com
Sender: MacroMan%WKUVX1.BITNET@uu7.psi.com
Date: Thu, 03 Jun 1993 08:19:03 -0600 (MDT)
From: Ed Heinrich <HEINRICH%BYUVAX.BITNET@uu7.psi.com>
Reply-To: MACRO32%WKUVX1.BITNET@uu7.psi.com
Subject: Re: Image activation
To: MACRO32@WKUVX1.BITNET
Message-Id: <01GYXN6UBOL48X2U5R@yvax.byu.edu>
Organization: Brigham Young University
X-Envelope-To: MACRO32@WKUVX1.BITNET
X-Vms-To: IN%"MACRO32@WKUVX1.BITNET"
Mime-Version: 1.0
Content-Type: TEXT/PLAIN; CHARSET=US-ASCII
Content-Transfer-Encoding: 7BIT

<PETTER.MOE.93Jun3141539@hugin.kvatro.no> writes:
>
>We have run into some problems when trying to inspect a running image.
>In "VMS Programming, 5b; Runtime Library", chapter 7.1, it is stated that:
>
>        "The image activator maps the user program into the address
>        space of the process and sets up useful information such as
>        the program name.  Then it starts up the command interpreter."
>
>How do you get at this useful information?  What information is
>available, apart from the program name?  Where is this documented?
>What we specifically need is the program name as given by the linker,
>and the time when the image was linked.
>
>Thanks for any help!
>
>Petter Moe


This is documented in the IDSM (or as it is also known as "The Book of Ruth")

I believe that there were several examples of code that do this posted last
month in the ALPHA-VMS mailing list that will work on both VMS/VAX and VMS/AXP
but I can give you a quick overview here.

The image activator will create a structure known as the image header in P1
space when it loads a new image.  From offsets in the image header you can
get at the image name as it was linked, the ident, linktime, patch info, eco
numbers, (stored as a bit mask).

The following code fragment will show you how to get at some of the info
on VMS/VAX environments:

Note:  This is an INCOMPLETE code fragment, NOT a working program!


$IHIDEF
$IHDDEF
$IHPDEF

FMT_1:  .Ascid  /Some FAO formatting string w patch info /
FMT_2:  .Ascid  /Some FAO formatting string without patch info/


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

        MOVAB   FMT_2, R4               ; Default FAO formatting string
        MOVL    #FMT_COUNT, R5          ; Number of parameters
        MOVL    G^CTL$GL_IMGHDRBF, R1   ; Image header buffer address
        MOVL    (R1), R1
        MOVZWL  IHD$W_IMGIDOFF(R1), R0  ; Image identification offset
        MOVAB   (R1)[R0], R2            ; Get image identification address
        MOVZWL  IHD$W_PATCHOFF(R1), R0  ; Patch offset into R0
        BEQL    0$                      ; Branch if no patches
        ADDL    R0, R1                  ; Get base address of IHP into R1
        PUSHL   IHP$L_ECO1(R1)          ; ECO #1 flags
        PUSHAB  IHP$Q_PATDATE(R1)       ; Date of last applied patch
        MOVAB   FMT_1, R4               ; Update format string
        ADDL    #2, R5                  ; Increment parameter count

    0$: PUSHAB  IHI$Q_LINKTIME(R2)      ; Link time/date info
        PUSHAB  IHI$T_IMGID(R2)         ; Image id
        PUSHAB  IHI$T_IMGNAM(R2)        ; Image name address

        pushab  format_desc             ; Resultant length
        pushab  format_desc             ; Formatted output descriptor
        PUSHL   R4                      ; FAO control string address
        CALLS   R5, g^SYS$FAO           ; Go format it

Hope this helps.

*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*
Ed Heinrich                     "History's a lie that they teach you in school"
The LOKI Group, Inc.                    _Living Colour_
HEINRICH@byu.EDU
*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*
