[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference noted::hackers_v1

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

172.0. "ZAP indexed files back to life." by RICARD::HEIN () Thu Oct 24 1985 16:11

Hi,

	Not sure about this one. Is it a hack? is it a tool? It is in no
	shape to be a real tool, so I concidered it a hack.  Here it is:

	The included macro program proved to be VERY useful when 'FIXING'
	a corrupted indexed file. It assumes you know about records and
	buckets and all that nonsense but just need a handy way to get
	to that data. Patch/absolute/ovrewrite will work to some extend
	but not always. A further requirement was that it should be able
	to efficiently ZAP files over the network.

	Here's what it does:

	- Prompt for the name of the file to work on.

		Feel free to use a remote file spec if needed:
		REMOTE"username secret"::IMPORTANT_DATA.CORRUPTED

	- Prompt for an command to be performed.
	
		The commands are (now :-) ;


	o Debug
		Calls the debugger (see previous note) with
		BUFfer address and bucket number in registers.
		EXAMINE, DEPOSIT the bucket to your hearts content.
		Return to program with GO when you think that the
		bucket is in better shape than you found it.
	o Exit
		Guess what...
	o Format
		Prints the formatted header of the bucket
		currently in memory.
	o Write
		Writes out the bucket 'over' the VBN's where it came from.

	0 'Number'
		Any string starting with a numeric charecters (and some
		others :( ) will cause the bucket with that number to
		be read into the buffer. Note: use HEX numbers.

You owe me a beer for every file you save with this litle bugger!
Actually, just a mail would be more appreciated, as my boss thinks
I did this only for the fun of it :^)

Hope it works for you if you should need it,
regards,
	Hein van den Heuvel


FAB:	$FAB	FAC = <BIO,BRO,GET,PUT>, - 	;Allow block I/O read AND write
		FNA = FILENAME_BUF, -		;Address of filename string
		SHR = UPI
RAB:	$RAB	FAB = FAB, -			;Associated FAB
		ROP = <BIO>, -			;block I/O Processing
		UBF = BUF			;Input buffer


	.ENTRY	START, ^M<>
	PUSHAL	FILENAME_SIZ
	PUSHAQ	FILENAME_PROMPT
	PUSHAQ	FILENAME
	CALLS	#3, G^LIB$GET_INPUT
	MOVB	FILENAME_SIZ, FAB+FAB$B_FNS	;Insert the filename size
	$OPEN	FAB=FAB				;Open the input file
	BLBC	R0, BYE				;See you later!
	MOVZBL	FAB+FAB$B_BKS, R0		;Pick up bucket size
	ASHL	#9, R0, R1			;Multiply by 512
	MOVW	R1, RAB+RAB$W_USZ		;Set up size of read
	$CONNECT RAB=RAB			;Connect
	BLBS	R0, MAIN_LOOP			;Go for it!
DONE:	$CLOSE	FAB=FAB		;Close the files
	$EXIT_S
BYE:	RET

MAIN_LOOP:
	MOVL	#VBN_LEN, VBN			;Init len filed in descriptor
	PUSHAQ	VBN				;Output LEN
	PUSHAQ	VBN_PROMPT			;Prompt
	PUSHAQ	VBN				;Buffer
	CALLS	#3, G^LIB$GET_INPUT		;Get it
	BLBC	R0, BYE				;Done?
	CMPB	#^A"A", VBN_BUF			;Numeric?
	BGTR	READ				;
	BICB2	#32, VBN_BUF			;Upcase (the hard way)
	CMPB	#^A"W", VBN_BUF
	BEQL	WRITE
	CMPB	#^A"E", VBN_BUF
	BEQL	DONE
	CMPB	#^A"D", VBN_BUF
	BEQL	DEB
	CMPB	#^A"F", VBN_BUF
	BEQL	FORMAT
	PUSHAQ	INPUT_ERROR
	BRW	GIVE_ERROR
DEB:	BRW	DEBUG
WRITE:
	$WRITE	RAB=RAB
	BLBC	R0, FORMAT
	BRW	MAIN_LOOP

READ:	PUSHAL	RAB+RAB$L_BKT			;Straight into the RAB
	PUSHAL	VBN				;INput again
	CALLS	#2, G^OTS$CVT_TZ_L		;Convert	
	BLBS	R0, 10$
	PUSHAQ	CONVERT_ERROR
	BRW	GIVE_ERROR			
10$:
	$READ	RAB=RAB				;Read the bucket
	BLBS	R0, FORMAT
	PUSHAL	ENDOF_ERROR
	CMPL	R0,#RMS$_EOF
	BEQL	20$
	PUSHAL	READ_ERROR
20$:	BRW	GIVE_ERROR

FORMAT:
	MOVL	#FAO_OUTBUF_L, FAO_OUTBUF_D	;init size
	PUSHL	BUF+13			;15	Flags
	PUSHL	BUF+12			;14	Level
	PUSHL	BUF+6				;13	Last/next
	PUSHL	BUF+4				;12	InUse
	PUSHL	BUF+1				;11	Area
	MOVZWL	RAB+RAB$W_USZ, R1
	PUSHL	BUF-1(R1)			;10	Check-2
	PUSHL	BUF+0				;9	Check-1
	PUSHL	RAB+RAB$L_STV			;8	
	PUSHL	RAB+RAB$L_STS			;7
	PUSHL	BUF+8				;6	
	PUSHL	BUF+2				;5
	PUSHL	RAB+RAB$L_BKT			;4
	PUSHAL	FAO_OUTBUF_D			;3
	PUSHAL	FAO_OUTBUF_D			;2
	PUSHAL	FAO_CTRSTR_D			;1
	CALLS	#15, G^SYS$FAO			
	PUSHAL	FAO_OUTBUF_D
	CALLS	#1, g^LIB$PUT_OUTPUT
	BRW	MAIN_LOOP

DEBUG:	MOVAB	BUF, R2
	MOVZWL	RAB+RAB$W_RSZ, R3
	MOVL	RAB+RAB$L_BKT, R4
	PUSHL	#SS$_DEBUG
	CALLS	#1, g^LIB$SIGNAL
	BRW	MAIN_LOOP
GIVE_ERROR:
	CALLS	#1, G^LIB$PUT_OUTPUT
	BRW	MAIN_LOOP
	
CONVERT_ERROR:	.ASCID	"Error converting block number"
READ_ERROR:	.ASCID	"Error reading VBN"
ENDOF_ERROR:	.ASCID	"Beyond EOF"
INPUT_ERROR:	.ASCID	"No Way"
FILENAME_PROMPT:.ASCID	"Please enter filename:"
FILENAME:	.LONG	80,FILENAME_BUF	;input buffer descriptor
FILENAME_SIZ:	.WORD	0		;Receives length of filename
FILENAME_BUF:	.BLKB	80
VBN_PROMPT:	.ASCID	"Now what? (Debug, Format, HEX VBN #, Write, Exit):"
VBN_LEN = 20
VBN:		.LONG	VBN_LEN, VBN_BUF
VBN_BUF:	.BLKB	VBN_LEN
FAO_CTRSTR_A:	.ASCII	"BKT=!XL(!XW), Next=!XL, STS=!XL, STV=!XL !/"
		.ASCII	"Check=!XB(!XB), Area=!XB, "
		.ASCII	"InUse=!XW ,Last/Next=!XW, Level=!XB, Flags=!XB!/"
FAO_CTRSTR_L = 	. - FAO_CTRSTR_A
FAO_CTRSTR_D:	.LONG	FAO_CTRSTR_L, FAO_CTRSTR_A
FAO_OUTBUF_L =	200
FAO_OUTBUF_A:	.BLKB	FAO_OUTBUF_L
FAO_OUTBUF_D:	.LONG	FAO_OUTBUF_L, FAO_OUTBUF_A
BUF::	.BLKB	512*64
	.END	START
T.RTitleUserPersonal
Name
DateLines
172.1PARVAX::PFAUThu Oct 24 1985 21:014
This should be submitted to the toolshed.

tom_p
(virtual Stan)