📄 hilite.asm
字号:
; DOS colour DIR listings the extremely cheeky way.
; It works by monitoring int 10 output [fns e,9 and a]
; and colourizing "words" which end in certain file extensions.
;
; Please read hilite.txt
;
; If you want to change the extension list just follow the format I used;
; you may have to change some jumps to near if you insert more code
; Will not compile with masm/tasm unless you change the addressing syntax
; viz a viz sq. brackets. In NASM: mov ax,label puts the offset of label in ax
; there are no distinctions between labels and var. names etc etc.
;
;
; This assembly file was written for NASM 0.94
; by Graspy Lemur of Happi Llama Realtech. 06:25 27:07:97.
;
; Version 2. In version 1 I forgot to save the flags so it kept mysteriously
; crashing! Well, this is the way we learn things...
[org 0x100]
[bits 16]
scratch: ; scratch can use these 4 bytes, overwriting the jmp instruction
jmp install ; this instruction takes 3 bytes
lastof4 db 0
oldhandler:
oldoff dw 0
oldseg dw 0
old_fa:
faoff dw 0
faseg dw 0
;old_21:
;off21 dw 0
;seg21 dw 0
psp dw 0
;newint:
;cmp ah,2
;je ohno
;cmp ah,6
;je ohno
;cmp ah,9
;je ohno
;jmp far [cs:old_21]
;ohno:
;iret
check: ;//////////////////////////////////////ARE WE INSTALLED OR NOT????
pushf
cmp ax,0xf9c2
jne dos_go_on_through_mate
popf
mov ax,2c9fh
push cs
pop fs
iret ; return ax=id_installed, fs = resident seg
dos_go_on_through_mate:
popf
jmp far [cs:old_fa]
handler: ;///////////////////////////////////MAIN BIT: INT10 HANDLER
pushf
cmp ah,0xe
je aha ;teletype
cmp ah,9 ;output char and attr
je aha
cmp ah,0xa ;output char
je aha
jmp just_ret
aha:
shr dword [scratch],8 ; imagine one of those led scrollers, except only 4 char
mov byte [lastof4],al ; "I am last of four. You will be assimilated.@
; BOOL PERSON::RESIST( FOE& F)
; { IF ( FOE.NAME=="BORG" ) RETURN FUTILE; }
push dx
cmp byte[scratch+1],13
je near clear_line
mov dl,00001001b; light blue for directories
cmp al,"]"
je near pre_raster ; directories are shown with square brackets.
cmp al,65
jb near pop_dx_and_ret
cmp al,122
ja near pop_dx_and_ret
;do 4 char searches
push eax
push cx
push si
mov si,stuff
mov cl,10 ; 9 categories
next_category:
mov ch,[cs:si] ; # of items
mov dl,[cs:si+1]
add si,2
next_item:
mov eax,[cs:si]
cmp eax,[scratch]
je near raster
or eax,0x20202000
cmp eax,[scratch]
je near raster
add si,4
dec ch
jnz next_item
dec cl
jnz next_category
;do 2 char searches
mov si,stuff2
mov ch,4
next:
mov dl,[cs:si]
mov ax,[cs:si+1]
cmp ax,[scratch+2]
je near raster
or ah,0x20
cmp ax,[scratch+2]
je near raster
add si,3
dec ch
jnz next
pop si
pop cx
pop eax
pop_dx_and_ret:
pop dx
just_ret:
popf
jmp far [cs:oldhandler]
stuff: ;4 char searches
; FORMAT IS # OF ITEMS,COLOUR,LIST OF 4 BYTE SEQUENCES
db 2,00001010B,".COM.EXE"
db 3,00000010B,".BAT.SYS.DLL"
db 5,00001111B,".TXT.DOC.HTM.HLP.FAQ"
db 6,00000110b,".LST.LOG.ERR.PRF.SMP.DIF"
db 7,00000100B,".ZIP.ARJ.LHA.RAR.TGZ.ZOO.ARC"
db 5,00001110B,".BMP.GIF.JPG.TGA.PCX"
db 9,00000101B,".RAW.DAT.TAB.BIN.INI.PIF.RSC.LNK.PAL"
db 4,00001000B,".OLD.TMP.SWP.BAK"
db 3,00000011B,".CPP.HPP.ASM"
db 2,00001011B,".LIB.OBJ"
stuff2:
db 00000100b,".Z",00000011b,".C",00000011b,".H",00001011b,".A"
; 3 char searches (.ME for read.me and .GZ) not implemented- you could
; mask off the other byte and test them but I'm sure there's too many tests
; in there already.
pre_raster:
push eax
push cx
push si
raster:
push es
mov ax,40h
mov es,ax
movzx si,byte [es:50h] ;col
movzx cx,byte [es:51h] ;row
mov ax,cx
shl cx,6
shl ax,4
add si,cx
add si,ax
shl si,1
mov cx,0xb800
mov es,cx
creole
inc si
mov byte [es:si],dl
sub si,3
cmp byte [es:si],32
jne creole
pop es
pop si
pop cx
pop eax
pop dx
jmp just_ret
clear_line:
push si
push es
mov si,4000-159
mov dx,0xb800
mov es,dx
scablet:
mov byte [es:si],00000111b
add si,2
cmp si,4003
jne scablet
pop es
pop si
jmp pop_dx_and_ret
install: ;////////////////////////PROGRAM STARTS HERE
mov ax,0xf9c2
int 0x2f
cmp ax,0x2c9f
jne near doit ;installation check. running prog twice clears it
mov ax,3510h ;check if we're buried in a chain
int 21h
mov ax,es
mov cx,fs
cmp ax,cx
jne ohfuck
cmp bx,handler
jne ohfuck ;someone has chained 10
mov ax,352fh ; check for chain2
int 21h
mov ax,es
mov cx,fs
cmp ax,cx
jne ohfuck
cmp bx,check
jne ohfuck ; someone has chained 2F
;mov ax,3521h ; check for chain2
;int 21h
;mov ax,es
;mov cx,fs
;cmp ax,cx
;jne ohfuck
;cmp bx,newint
;jne ohfuck ; someone has chained 21
mov ax,2510h
push word [fs:oldseg]
pop ds
mov dx,[fs:oldoff]
int 21h ;reset int10 vect
mov ax,252fh
push word [fs:faseg]
pop ds
mov dx,[fs:faoff]
int 21h ; restore int2f for what it isn't worth
;mov ax,2521h
;push word [fs:seg21]
;pop ds
;mov dx,[fs:off21]
;int 21h ;restore int21
mov es,[fs:psp]
mov ah,49h
int 21h ; free that massive chunk of grabbed memory...
push cs
pop ds
mov dx,ms2
mov ah,9
int 21h ; output end message
jmp end
ohfuck: ;//////////////////////////////////CANNOT UNINSTALL
mov dx,ms3
mov ah,9
int 21h
jmp end
doit: ;////////////////////////////////////INIT PROGRAM
;mov ah,62h
;int 21h
mov [psp],es ; get seg addr of current psp
mov es,[es:2ch]
mov ah,49h
int 21h ;free environment block as we don't need it
mov ax,3510h
int 21h
mov [oldoff],bx
mov [oldseg],es ; get old int10 vect
mov ax,352fh
int 21h
mov [faoff],bx
mov [faseg],es ; get old 2f vect
;mov ax,3521h
;int 21h
;mov [off21],bx
;mov [seg21],es ; get old 21 vect
;mov dx,newint
;mov ax,2521h
;int 21h ;set new int21
mov dx,handler
mov ax,2510h
int 21h ; set new int10 handler
mov dx,check
mov ax,252fh
int 21h ; set new int2f handler for inst check.
mov dx,ms1
mov ah,9
int 21h ;print installed message
mov dx,install
int 27h ;t and sr
ms1 db 10,13,"Coloured directory listings: more of them please! [v2]",13,10,"$"
ms2 db 10,13,"In the name of the moon, I will punish you!",13,10,"$"
ms3 db 10,13,"Can't uninstall. Int 0x10 or 0x2F in chain.",13,10,"$"
end:
mov ax,4c00h
int 21h
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -