          <<< NOTED::DISK$NOTES7:[NOTES$LIBRARY_7OF4]HACKERS.NOTE;1 >>>
                               -< ** Hackers ** >-
================================================================================
Note 1765.5          show device/files from within an image               5 of 8
STAR::FENSTER "Yaacov Fenster, Operating systems Q" 207 lines  25-APR-1995 11:15
--------------------------------------------------------------------------------
    Following is some source code I keyed in years ago from Vax
    Professional (aka DTJ) and modified somewhat. It is module which was
    bound to a key (^F for example) and gave (similar to ^T) a list of all
    the open files for a given process. Not exactly what was asked for, but
    it might be useful. The original author was Lee K. Gleason and I think
    that the original code is on DECUS tapes someplace. (Do we have those
    online anyways ?)
    
    An interesting story goes with this code. Among other things, I was the
    manager/hacker for the local Vaxen, and had implemented some of these
    modules. The similarity to ^T and ease of use got some visting
    contracters to beleive that it was standard VMS. Upon returning to
    their own plant, they complained to DEC that it wasn't working on their
    systems. I wonder what the poor field engineer who fielded that report
    did.
    
    [I know that there aren't any comments, but this was a LONG time ago,
    and I was keying it in from paper. I could comment it if no one wants
    to hack ...]
	.title	opf
	.ident	'x01-000'

	.library	"sys$library:lib.mlb"

	$brkdef
	$ccbdef
	$fcbdef
	$wcbdef
	$ucbdef
	$ddbdef
	$fibdef
	$atrdef
	$secdef
	$phddef
	$pcbdef

id:	.long	^x30
name:	.ascic	/OPF/
load:	.long	0
loadfao:
	.ascid	/Load address is !XL/
loadstr:
	.ascid	/                             /

	.entry	opf,^m<r6>
	pushal	id
	pushal	load
	pushal	name
	pushl	#len
	pushal	doopf
	pushl	#5
	movl	sp,r6
	$cmkrnl_s	routin=keyload,arglst=(r6)
	blbc	r0,1$
	$fao_s	ctrstr = loadfao,outbuf=loadstr,outlen=loadstr,p1=load
	pushal	loadstr
	calls	#1,g^lib$put_output

1$:	ret


	.entry	doopf,^m<r2,r3,r4,r5,r6,r7,r8,r9,r10,r11>

	outstr=0
	outdevstr=520
	faostr=540
	unum=548
	tempstr=562

	moval	fixit,(fp)

	movpsl	r11
	bitl	#^X3000000,r11
	bneq	nk
	ret

nk:	subl	#1024,sp
	movl	sp,r6

	movl	@#ctl$gl_ccbbase,r7
	movzwl	@#ctl$gl_vectors,r8

	movl	#512,outstr(r6)
	moval	outstr+8(r6),outstr+4(r6)

	movl	@#ctl$gl_pcb,r0
	movzbl	pcb$t_terminal(r0),outdevstr(r6)
	moval	pcb$t_terminal+1(r0),outdevstr+4(r6)

	movl	#faolen,faostr(r6)
	moval	faoctr,faostr+4(r6)

	movl	#6,unum(r6)
	moval	unum+8(r6),unum+4(r6)

	movl	#10,tempstr(r6)
	moval	tempstr+8(r6),tempstr+4(r6)

next:
	subl	#ccb$k_length,r7
	decl	r8
	bgtr	20$
	brw	end
20$:
	tstl	ccb$b_amod(r7)
	beql	next

	movl	ccb$l_wind(r7),r9
	beql	next
	blss	nsect

	movl	@#ctl$gl_pcb,r0
	movl	pcb$l_phd(r0),r0
	addl	phd$l_pstbasoff(r0),r0
	cvtwl	r9,r1
	movl	sec$l_window(r0)[r1],r9

nsect:
	movl	wcb$l_fcb(r9),r9
	bneq	10$
	brw	next

10$:
	movl	ccb$l_ucb(r7),r10
	movl	ucb$l_ddb(r10),r11
	movl	ddb$l_sb(r11),r0
	movzbl	sb$t_nodename(r0),r1
	movl	r1,tempstr(r6)
	movc3	r1,sb$t_nodename+1(r0),tempstr+8(r6)
	cmpl	r3,tempstr+4(r6)
	beql	11$
	movb	#^A/$/,(r3)+
	incl	tempstr(r6)
11$:
	movzbl	ddb$t_name(r11),r0
	addl	r0,tempstr(r6)
	movc3	r0,ddb$t_name+1(r11),(r3)

	$fao_s	ctrstr=faostr(r6),outbuf=outstr(r6),outlen=outstr(r6),-
		p1=tempstr(r6),p2=tempstr+4(r6),p3=ucb$w_unit(r10)

	pushal	outstr(r6)
	pushal	fcb$w_fid(r9)
	calls	#2,getnam

	$brkthruw_s	msgbuf=outstr(r6),sendto=outdevstr(r6),sndtyp=#brk$c_device

	brw	next
end:
	ret

	opf$l_chan = 0
	opf$q_iosb = 4
	opf$l_attadr = 12
	opf$c_attlst = 16
	opf$l_fibdesc = 28

	.entry	getnam,^m<r2,r3,r4,r5,r6,r7,r8>

	subl	#256,sp
	movl	sp,r6

	moval	opf$c_attlst(r6),opf$l_attadr(r6)
	movw	#atr$s_file_spec,opf$c_attlst(r6)
	movw	#atr$c_file_spec,opf$c_attlst+2(r6)
	movq	@8(ap),r7
	movl	r8,opf$c_attlst+4(r6)

	clrl	opf$c_attlst+8(r6)
	movl	#fib$w_fid+10,opf$l_fibdesc(r6)
	moval	opf$l_fibdesc+8(r6),opf$l_fibdesc+4(r6)
	movc5	#0,#0,#0,#fib$w_fid+10,@opf$l_fibdesc+4(r6)

	movl	4(ap),r0
	movl	(r0)+,opf$l_fibdesc+8+fib$w_fid(r6)
	movl	(r0),opf$l_fibdesc+8+fib$w_fid+4(r6)

	$assign_s	chan=opf$l_chan(r6),devnam=@8(ap)

	blbc	r0,out

	$qiow_s	func=#io$_access,iosb=opf$q_iosb(r6),chan=opf$l_chan(r6),-
		p1=opf$l_fibdesc(r6),p5=opf$l_attadr(r6)

	blbc	r0,out
	movq	opf$q_iosb(r6),r0
	blbc	r0,out

	movzwl	(r8),@8(ap)
	movc3	(r8),2(r8),(r8)

	$dassgn_s	chan=opf$l_chan(r8)

out:
	ret

	.entry	fixit,^m<>
	$unwind_s
	ret

faoctr:	.ascii	"!AD!ZW"
faolen = .-faoctr

len = . - doopf

	.end	opf
    
