[Search for users]
[Overall Top Noters]
[List of all Conferences]
[Download this site]
Title: | -={ H A C K E R S }=- |
Notice: | Write locked - see NOTED::HACKERS |
Moderator: | DIEHRD::MORRIS |
|
Created: | Thu Feb 20 1986 |
Last Modified: | Mon Aug 03 1992 |
Last Successful Update: | Fri Jun 06 1997 |
Number of topics: | 680 |
Total number of notes: | 5456 |
312.0. "$FAO And VAX MACRO: Having A Problem..." by KIRK::NORTON () Thu Sep 18 1986 11:33
Hi!
If someone has time to answer this, I would appreciate it. This came from
an unanswered question at a Bedford course on accessing VMS from VAX MACRO.
Thanks.
Charles McKinley Norton
BASEWAY Development Engineering
MLO5-2/E50 Pole 36A
223-3590
Problem follows <FF>.
I am having a problem with the $FAO system service. I am including the
source program and the message file. (The source program has the
explanation of the problem in comment form.)
If you need anything else, you can get these files, H1.MAR and
TEST_MSG.MSG in
KIRK::MDC$USERS:[NORTON.SFW.M32]
Please feel free to ask me for anything else you need.
Here is H1.MAR:
;This MACRO32 program does the following:
;
;It establishes a handler, HAND1.
;It PUSHES an info message on the stack and calls LIB$SIGNAL.
;The handler, fetches the corresponding message using $GETMSG,
;and places the message in ERRMSG.
;
;Then, the handler translates this message using $FAO. (The message
;contains $FAO directives.)
;There is a problem with the message. If a string parameter of
;length >= 4 is passed as P1 to $FAO, the string is not translated
;correctly. There is truncation, whose behavior I cannot understand
;from reading the manual. If the string is < 3, the translation is OK.
;
;I have played around with field widths in the message file, and
;cannot get a good translation.
;
;The main program then calls LIB$SIGNAL, after having pushed
;a fatal message on the stack. (The fatal message has no
;FAO directives; hence there is no error of any kind.)
;
;How can I fix the $FAO problem?
;
;I also found something else very interesting:
;if ERRMSGLEN is declared as a .BLKW, $FAO returns a buffer overflow
;error, as there is garbage in the upper 16 bits. If ERRMSGLEN
;is declared as .WORD 0, there is no problem. I think this is
;a bug. If $GETMSG and $FAO are looking for writeonly words to
;write lengths into, it should not matter what is in the upper
;word.
;
.TITLE H1
.PSECT NOSHARED_DATA, PIC, NOEXE, LONG
$CHFDEF
$DSCDEF
;
;This MACRO is here, so you do not have to copy the library.
.MACRO OUTPUT dsc1, t,-
dsc2,f,z,o,l,i,-
len=10, fract=2,-
?ptr1, ?ptr2, ?ptr3,-
?ptr4, ?ptr5
.save_psect local_block
.psect mac__psect noexe,shr,long
mac__out_str=.
.word 0
.byte 14
.byte 2
.long 0
.if not_blank i
mac__out_str_i=.
.word len
.byte 14
.byte 1
.address ptr1
ptr1: .blkb len
.endc
.if not_blank l
mac__out_str_l=.
.word len
.byte 14
.byte 1
.address ptr2
ptr2: .blkb len
.endc
.if not_blank o
mac__out_str_o=.
.word len
.byte 14
.byte 1
.address ptr3
ptr3: .blkb len
.endc
.if not_blank z
mac__out_str_z=.
.word len
.byte 14
.byte 1
.address ptr4
ptr4: .blkb len
.endc
.if not_blank f
mac__out_str_f=.
.word len
.byte 14
.byte 1
.address ptr5
ptr5: .blkb len
.endc
.if not_equal %length(t)
mac__out_str_t=.
.ascid |t|
.endc
mac__tmp_num=.
.blkq 1
mac__arg_count=.
.blkl 1
.restore_psect
pushr #^m<r0,r1>
.if not_blank i
pushaq mac__out_str_i
.ntype mac__mode, i
mac__mode=mac__mode@-4&^xf
addr=0
.iif equal mac__mode, addr=1
.iif equal mac__mode-1, addr=1
.iif equal mac__mode-5, addr=1
.if not_equal addr
movl i,mac__tmp_num
pushal mac__tmp_num
.if_false
pushal i
.endc
calls #2, g^ots$cvt_l_ti
.endc
.if not_blank l
pushaq mac__out_str_l
.ntype mac__mode, l
mac__mode=mac__mode@-4&^xf
addr=0
.iif equal mac__mode, addr=1
.iif equal mac__mode-1, addr=1
.iif equal mac__mode-5, addr=1
.if not_equal addr
movl l,mac__tmp_num
pushal mac__tmp_num
.if_false
pushal l
.endc
calls #2, g^ots$cvt_l_tl
.endc
.if not_blank o
pushaq mac__out_str_o
.ntype mac__mode, o
mac__mode=mac__mode@-4&^xf
addr=1
.iif equal mac__mode, addr=1
.iif equal mac__mode-1, addr=1
.iif equal mac__mode-5, addr=1
.if not_equal addr
movl o,mac__tmp_num
pushal mac__tmp_num
.if_false
pushal o
.endc
calls #2, g^ots$cvt_l_to
.endc
.if not_blank z
pushaq mac__out_str_z
.ntype mac__mode, z
mac__mode=mac__mode@-4&^xf
addr=1
.iif equal mac__mode, addr=1
.iif equal mac__mode-1, addr=1
.iif equal mac__mode-5, addr=1
.if not_equal addr
movl z,mac__tmp_num
pushal mac__tmp_num
.if_false
pushal z
.endc
calls #2, g^ots$cvt_l_tz
.endc
.if not_blank f
pushl #fract
pushaq mac__out_str_f
.ntype mac__mode, f
mac__mode=mac__mode@-4&^xf
addr=1
.iif equal mac__mode, addr=1
.iif equal mac__mode-1, addr=1
.iif equal mac__mode-5, addr=1
.if not_equal addr
movq f,mac__tmp_num
pushaq mac__tmp_num
.if_false
pushaq f
.endc
calls #3, g^for$cvt_d_tf
.endc
movl #1, mac__arg_count
.if not_blank i
pushaq mac__out_str_i
incl mac__arg_count
.endc
.if not_blank l
pushaq mac__out_str_l
incl mac__arg_count
.endc
.if not_blank o
pushaq mac__out_str_o
incl mac__arg_count
.endc
.if not_blank z
pushaq mac__out_str_z
incl mac__arg_count
.endc
.if not_blank f
pushaq mac__out_str_f
incl mac__arg_count
.endc
.if not_blank dsc2
pushaq dsc2
incl mac__arg_count
.endc
.if not_equal %length(t)
pushaq mac__out_str_t
incl mac__arg_count
.endc
.if not_blank dsc1
pushaq dsc1
incl mac__arg_count
.endc
pushaq mac__out_str
calls mac__arg_count, g^str$concat
pushaq mac__out_str
calls #1, g^lib$put_output
popr #^m<r0,r1>
.endm output
PROC_NAME:
.ASCID /FOO/
ALT_NAME:
.ASCID /PRGNAM/;Plug this into the P1= for $FAO to see string
;translation error.
;
.PSECT CODE PIC, SHR, NOWRT, LONG
.ENTRY BEGIN ^M<>
MOVAL HAND1, (FP) ;Establish exception handler.
OUTPUT T=<Call with info>
PUSHL #TST_START ; Error number
CALLS #1, G^LIB$SIGNAL
;
OUTPUT T=<Call with fatal>
PUSHL #TST_BOO
CALLS #1, G^LIB$SIGNAL
;
OUTPUT T=<Call with SS$_NORMAL>
PUSHL #SS$_NORMAL
CALLS #1, G^LIB$SIGNAL
;
MOVL #SS$_NORMAL, R0
RET
.ENTRY HAND1, ^M<R2,R3, R4> ;This is the handler.
.PSECT NOSHARED_DATA, PIC, NOEXE, LONG
ERRMSGLEN:
.WORD 0 ;If this is a .BLKW, then $FAO returns a buffer overflow
;message. What's interesting is that $GETMSG does not
;have a problem. I noticed that there was junk in
;the upper word, when I did an EXAMINE ERRMSGLEN before
;and after the $FAO call.
ERRMSG:
.WORD 160
.BYTE DSC$K_DTYPE_T, DSC$K_CLASS_S
.ADDRESS L1
L1: .BLKB 160
MESSID: .BLKL 1
;
.PSECT CODE PIC, SHR, NOWRT, LONG
MOVL CHF$L_SIGARGLST(AP), R0 ;Get arglist for exception.
MOVL CHF$L_SIG_NAME(R0), R2 ;Get message that was passed.
;
;You are clearing this buffer out, so there is not junk left over in between
;calls to LIB$SIGNAL. Maybe there is a better way to do it, but this works.
;
MOVAL L1, R3 ; Address of buffer to clear
MOVL #20, R4 ; Clear 10 times 8 bytes.
10$: CLRQ (R3) ; Clear 8 bytes.
ADDL2 #8, R3 ; Point to next quadword.
DECL R4 ; One less to clear.
BNEQ 10$ ; Go back if not zero.
$GETMSG_S MSGID=R2, MSGLEN=ERRMSGLEN, - ;Get message.
BUFADR=ERRMSG
;
$FAO_S CTRSTR=ERRMSG, OUTBUF=ERRMSG, OUTLEN=ERRMSGLEN, -;Translate
P1=#PROC_NAME, P2=#0
;
OUTPUT DSC2=ERRMSG
MOVL #SS$_CONTINUE, R0
RET
.END BEGIN
Here is TEST_MSG.MSG:
.TITLE TEST_MSGS
.FACILITY TST,877
.SEVERITY INFO
!
START <Procedure !AS begins at !%D.> /FAO=2
.SEVERITY SEVERE
!
BOO <This is fatal.>
.END
T.R | Title | User | Personal Name | Date | Lines |
---|
312.1 | try the RTL notes conference as well... | GNERIC::KAGEN | | Thu Sep 18 1986 16:00 | 5 |
| I haven't had time to digest this yet but you might try entering
this in the RTL notes conference. It is located at CLT::RTL. I'd
set it up so all you had to do is press kp7 but I don't know how-((.
Mike
|
312.2 | RTL or VMSNOTES? | KIRK::NORTON | | Thu Sep 18 1986 16:10 | 13 |
| Hi!
RE: 312.1
Are you sure RTL is the correct place?
I thought VMSNOTES handled VAX MACRO and system services (like $FAO).
I'll put this in VMSNOTES.
TNX
4 the suggestion.
cmn
|
312.3 | At Your Service | VAXUUM::DYER | Working For The Yankee Dollar | Fri Sep 19 1986 03:08 | 2 |
| [RE .1]: SET NOTE/CONFERENCE=CLT::RTL
<_Jym_>
|
312.4 | Found Answer ; thanks | KIRK::NORTON | | Fri Sep 19 1986 09:39 | 7 |
| Hi!
The $FAO parameter, outbuf, needs to be a different buffer than
ctrstr.
thanks
cmn
|