Aucbvax.6908
fa.info-vax
utzoo!decvax!ucbvax!info-vax
Sun Apr 25 09:08:54 1982
Reading your DCL global symbol table from a program
>From EPS@MIT-AI Sun Apr 25 08:58:10 1982
DCL symbols are somewhat simpler creatures than VMS logical
names.  Their queue head is located at CTL$A_CLIDATA+^X28
(%X7FFEA238).  Each entry consists of the usual fore and
back pointers, a word containing the size of the entry, a
byte which is nonzero if the symbol table is full, a byte
indicating the number of optional characters  (i.e. if I
type $ foob*ar:==$foobar this byte will contain a 2, if
the symbol has no abbreviation point it will contain 0),
followed by the symbol name and equivalence as counted
(.ASCIC) strings just as we had before with logical names.
Of course there's gotta be a catch, or one of you would no
doubt have figured this out before.  There's a catch.
("That's some catch that Catch-22.")

$CLISERVDEF defines nine CHMS services you can request of
your CLI via the callback address passed to your main
program as 8(AP) (see the description of LIB$INITIALIZE
in the Run Time Library Reference Manual), or by calling
SYS$CLI.  You will notice that there are codes for defining
local and global symbols.  You will also note the absence
of any way to read (translate) them.  (Why would anyone
want to read a DCL symbol?  Jon Leech <LEECH@MC> decided
that his LOGIN.COM took too long to execute and wrote a
LOGIN.EXE to speed things up.  Such a program needs to be
able to do what .COM files can.).  BTW, you can't define
a symbol with CLI callback that contains an abbreviation
point.  I know, send in a SIR.  Anyway, you'll notice
also CREALOG and DELELOG which hack logical names in
supervisor mode.  These implement things like TEC$MEMORY,
which have to stick around across image activations.

Oh yeah.  The catch is that (for some reason known only
to DEC, of course) this stuff is in pages protected SW,
i.e. not readable in user mode, so the same stunt I
pulled in SHOWGROUP doesn't work.  Of course I wouldn't
let a little thing like access mode stop me.  You
can't see them with EXAMINE/ASCII from command level
either; DEC has EXAMINE fixed to PROBE against user
accessibility.  Replace the 'PROBER #3,R3,(R7)' at
^X2A41 in DCL.EXE with 'PROBER #2,R3,(R7)' if you think
this an unjust restriction.  However, you don't have
to hack your DCL to read stuff in supervisor mode.
A neat little "feature" of the logical name callbacks
is that they don't probe their arguments!  Thus when
the $CRELOGs and $DELLOGs get done they are probed
against supervisor mode.  Time to be devious.
                                     * * *
       .TITLE  SUPERREAD
;
;       Read memory in supervisor mode
;       Eric P. Scott, Caltech, April 1982
;
;       unsigned superread(len, src, dst)
;       unsigned short len;     /* number of bytes to transfer */
;       char *src;              /* copy from */
;       char *dst;              /* copy to */
;
;       Returns:
;               SS$_NORMAL      Service successfully completed.
;               SS$_ACCVIO      src cannot be read or dst cannot be written.
;               SS$_INSFMEM     Process has exceeded logical name limit.
;               SS$_IVLOGNAM    Attempt to transfer more than 63 characters.
;               LIB$_INVARG     Wrong number of arguments.
;               CLI$_INVREQTYP  No CLI.
;
;       Restrictions:
;         Must run under a CLI
;         Should not be called at AST level
;
       $CLIDEF
       $CLISERVDEF
       $DSCDEF
       $LIBDEF
       .PSECT  SUPERREAD,NOWRT,PIC,SHR,LONG
       .ENTRY  SUPERREAD,^M
       CMPW    (AP),#3         ; Takes exactly three arguments
       BNEQ    15$
       TSTW    4(AP)           ; Zero byte transfer OK
       BEQL    20$
       MOVQ    4(AP),-(SP)     ; Request Super $CRELOG
       PUSHAB  LOGNAM
       PUSHL   #LOGLEN!<DSC$K_DTYPE_T@16>!<DSC$K_CLASS_S@24>
       PUSHL   #CLI$K_CLISERV!<CLI$K_CREALOG@8>
       PUSHAL  (SP)
       CALLS   #1,@#SYS$CLI
       BLBC    R0,10$
       MOVL    12(AP),16(SP)   ; TRNLOG to dst buffer
       PUSHL   #3              ; Search process table only
       CLRQ    -(SP)
       PUSHAQ  12+12(SP)
       CLRL    -(SP)
       PUSHAQ  4+20(SP)
       CALLS   #6,@#SYS$TRNLOG
       BLBC    R0,10$
       MOVL    #CLI$K_CLISERV!<CLI$K_DELELOG@8>,(SP)
       PUSHAL  (SP)            ; Request Super $DELLOG
       CALLS   #1,@#SYS$CLI
10$:    RET
15$:    MOVL    #LIB$_INVARG,R0
       RET
20$:    MOVZWL  #1,R0
       RET
       .PSECT  _SUPERREAD,NOWRT,NOEXE,SHR,LONG
LOGNAM: .ASCII  /SUPERREAD___VMS_IS_TWITLY/
LOGLEN=.-LOGNAM
       .END
                                     * * *
The program to use this to read DCL symbols is left as an
exercise (awww).  I've already done it, don't send in the
solution.  Note that the equivalences can be longer than
63 characters so you'll have to call SUPERREAD repeatedly
in some cases.  Good luck!
                                       --Eric

-----------------------------------------------------------------
gopher://quux.org/ conversion by John Goerzen <[email protected]>
of http://communication.ucsd.edu/A-News/


This Usenet Oldnews Archive
article may be copied and distributed freely, provided:

1. There is no money collected for the text(s) of the articles.

2. The following notice remains appended to each copy:

The Usenet Oldnews Archive: Compilation Copyright (C) 1981, 1996
Bruce Jones, Henry Spencer, David Wiseman.