From:	MERC::"uunet!WKUVX1.BITNET!MacroMan" 26-MAR-1993 07:47:41.73
To:	MACRO32@WKUVX1.BITNET
CC:	
Subj:	RE: Need help with IMGACT

Martin <winter@vision.rs.ch> writes:

> I want to change from one program to another one (without getting back),
> but I can't use LIB$DO_COMMAND (because this needs a CLI). Does anybody
> know how to use the IMGACT-service ?

The following program does most of the work (as far as can be done
in user mode - note that "normal" image activation takes place
in supervisor mode, allowing for execute-only & privileges images).

It correctly loads a program but doesn't start it - you have to look
at the header buffer (which has a copy of the image header) for the
transfer addresses. (This program's purpose is to "translate" any
status message in the context of the "right" image).

I did that once, and got the FORTRAN compiler running this way ...

HOWEVER, one of the things that the program doesn't get right is
condition handling, since (among other things) the stack contains
frames belonging to the "old" image.

Enjoy ...

Wolfgang J. Moeller, GWDG, D-3400 Goettingen, F.R.Germany | Disclaimer ...
PSI%(0262)45050352008::MOELLER      Phone: +49 551 201516 | No claim intended!
Internet: moeller@gwdgv1.dnet.gwdg.de   | This space intentionally left blank.

        .title  xfmsg           use $IMGACT to issue exit message
;
;       w.j.m. sep 85 (VMS V4.1)
;       mod 13-sep-1989 wjm: (VMS V5.1) $IMGACT complained about VA_IN_USE,
;                               so let's $DELTVA all of p0 space beforehand.
;
;       this subroutine copies part of itself upon the stack,
;       loads an image and then *exits* with status
;
;       call:
;               subroutine xfmsg(image,status)
;               character*(*) image     ! default is 'SYS$SYSTEM:.EXE'
;               integer status          ! by reference
;               * does not return *
;
;
stackcode:      ;PIC stuff to be copied
                ;entered here via JUMP
                ;r7 -> descriptor of image name
                ;r8 = exit status
;
        movab   handl,(fp)
;
        movaq   delrange,r2
        $deltva_s       inadr=(r2)
        blbc    r0,13$
;
        subl    #512,sp
        movl    sp,r6           ;r6 -> hdrbuf
        pushab  dflnam1
        pushl   #dflnam1l
        $imgact_s       name=(r7),dflnam=-8(r6),hdrbuf=(r6)
        blbc    r0,13$
        $imgfix_s
        blbc    r0,13$
;
        movl    r8,r0
13$:
        $exit_s r0
;
;
handl:  .word   ^m<>            ;brute force catch-all handler
        moval   @1*4(ap),r1     ;r1 -> sigargs, (r1) = #args
        blbs    4(r1),9$        ;good status? yes -> ignore
        $exit_s 4(r1)           ;4(r1) is 1st status
9$:     movl    s^#ss$_continue,r0      ;ignore signal if good
        ret
;
;
delrange:
        .long   0,^x3fffffff    ;all of p0 space
;
dflnam1:        .ascii  "SYS$SYSTEM:.EXE"
dflnam1l=.-dflnam1
;
stackcodel=.-stackcode  ; end of stack code
;
;
;*****
;
        .ENTRY  XFMSG,^m<r2,r3,r4,r5,r6,r7,r8>
;
        movq    @1*4(ap),r6     ;r6,r7 = image name dsc.
        movzwl  r6,r6
        subl    r6,sp
        movc3   r6,(r7),(sp)    ;copy on stack
        pushl   sp
        pushl   r6
        movl    sp,r7           ;r7 -> new image name dsc.
;
        movl    @2*4(ap),r8     ;r8 = exit status
;
        subl    #stackcodel,sp
        movc3   #stackcodel,stackcode,(sp)
;
        jmp     (sp)
;
;
        .end

Wolfgang J. Moeller, GWDG, D-3400 Goettingen, F.R.Germany | Disclaimer ...
PSI%(0262)45050352008::MOELLER      Phone: +49 551 201516 | No claim intended!
Internet: moeller@gwdgv1.dnet.gwdg.de   | This space intentionally left blank.
