FREEHAFER'S TURBO ASSEMBLER VERSION 5 HELP PAGE
THIS WEB SITE IS BY JOHN RICHARD FREEHAFER.
E-MAIL ADDRESS: nfn12346@naples.net
©1999
The following are complete programs for a Turbo Assembler Version 5 compiler:
Hook the timer interrupt 1Ch.
Link Borland C++ 4.52 and TASM 5.
Create a file with a long file name.
Create A File With A Long Filename!
%TITLE "CREATE FILE WITH LONG FILENAME" msg MACRO msgout mov AH, 09h ; function 09h lea DX, msgout ; DX holds message int 21h ; display string interupt ENDM IDEAL MODEL small STACK 256 DATASEG WVALUE DW ? HANDLE DW ? ; file handle junk DB " ",10,13,'$' msgAT DB 10,13,10,13," This program will create a file with a",10,13," long filename if it does not exist already.",'$' msgCode DB 10,13,10,13," CODE FOR ACTION TAKEN = ",'$' CW DB ".",0Ah,0Dh,0Ah,0Dh," Freehafer's File Creation Program Is Terminated!",0Ah,0Dh," (c)1998 INNIEA PUBLISHING COMPANY (r)R",153,142,"K NOG!",0Ah,0Dh,0Ah,0Dh,'$' msgin DB 10,13,10,13," ENTER A PATH OF FILE HAVING A LONG FILE NAME: ",'$' path_buf DB 60 ; path_length DB 0 ; path DB 60 dup ('$') ; CODESEG Start: mov AX, @data mov DS, AX mov ES, AX ;........................................................................ ; ; white background with green font ;........................................................................ mov AH, 9 ; function number mov CX, 2000 ; number of characters of output mov BL, 0F2h ; color code mov AL, 32 ; blank characters int 10h ; call interrupt ;........................................................................ ; ; input path of program to execute ;........................................................................ msg [msgAT] ; display what program does msg [msgin] ; display input message mov AH, 0Ah ; input string function lea DX, [path_buf] ; DS:DX = address of input buffer int 21h ; call interrupt mov BL, [path_length] ; length of string actually read mov BH, 0 ; high byte of length = 0 (length < 256) mov [path+BX], '$' ; make string displayable mov [path+BX], 0 ; make null terminated path ;........................................................................ ; ; way to open file with long name ;........................................................................ mov AX, 716Ch ; Extended Open/Create mov BX, 2 ; mode 0 is read only ; 1 is write only ; 2 is read write mov CX, 0 ; normal attributes ; mov DX, 10h ; 1 is open action ; 10 is create ; 2 replace mov si, seg PATH ; DS:SI = mov ds, si ; segment:offset mov si, offset PATH ; of ASCII file path int 21h ; call interrupt mov [HANDLE], AX ; file handle mov [WVALUE], AX ; display action taken msg [msgCode] ; call DisplayW ; ;........................................................................ ; ; close file ;........................................................................ mov BX, [HANDLE] ; get handle mov AH, 3Eh ; close file function int 21h ; call interrupt ;........................................................................ msg [CW] ; display copyright ;........................................................................ ; ; restore screen ;........................................................................ mov AH, 9 ; function number mov CX, 2000 ; number of characters of output mov BL, 0Fh ; color code mov AL, 32 ; blank characters int 10h ; call interrupt ;........................................................................ msg [junk] ; ;........................................................................ mov AX,4C00h ; int 21h ; termination interupt MASM ; for procedure ;........................................................................ ; ; Display Word Procedure ;........................................................................ DisplayW proc push AX push BX push CX push DX mov AX, WVALUE ; Number To Be Displayed mov BX, 10 mov CX, 0 WNexDiv: mov DX, 0 div BX push DX inc CX cmp AX,0 jne WNexDiv mov AX, 200h WOutSym: pop DX add DL, '0' int 21h loop WOutSym pop DX pop CX pop BX pop AX ret DisplayW endp ;.................................................................... END Start
Download and try this executable freeware to
create a file with a long filename in *.ZIP format!
Check out this hooker!
TITLE Freehafer's Hooking Program ; ; to compile with MASM type: ml name.asm ; to compile with TASM type: tasm name ; tlink /t name ;........................................................................ ; ; Display Message Macro ;........................................................................ msg MACRO msgout ; beginning of macro mov AH, 09h ; function 09h lea DX, msgout ; DX holds message int 21h ; display string interupt ENDM ; end of macro ;........................................................................ .MODEL tiny ; directive placing all memory in one segment ;........................................................................ .code ; ORG 100h ; start: ; begin algorithm ;........................................................................ ; ; display message ;........................................................................ msg CW ; ;........................................................................ ; ; save old interrupt vector ;........................................................................ mov AX, 0 ; mov ES, AX ; mov AX, ES:[1Ch*4] ; mov word ptr OldInt1Ch, AX ; mov AX, ES:[1Ch*4 + 2] ; mov word ptr OldInt1Ch+2, AX ; ;........................................................................ ; ; install new handler ;........................................................................ cli ; mov word ptr ES:[1Ch*4], offset NewHand mov ES:[1Ch*4 + 2], CS ; sti ; ;........................................................................ ; ; delay to see fruits of labor ;........................................................................ mov AH, 86h ; system wait function mov CX, 1Eh ; CX = 1E DX = 8480h for 2 seconds mov DX, 8480h ; int 15h ; ;........................................................................ ; ; reinstall original handler ;........................................................................ mov AX, 0 ; mov ES, AX ; cli ; mov AX, word ptr OldInt1Ch ; mov ES:[1Ch*4], AX ; mov AX, word ptr OldInt1Ch+2 ; mov ES:[1Ch*4+2], AX ; sti ; ;........................................................................ ; ; End Program ;........................................................................ mov AX,4C00h ; termination function int 21h ; termination interupt ;........................................................................ CW DB 10,13,10,13," Freehafer's Hooking Program Beeps Every Time The",10,13," Timer Vector 1Ch Is Called (About 36 Times In 2 Seconds)!",10,13," (c)1999 Inniea Publishing Company R",153,142,"K NOG!",10,13,10,13,'$' OldInt1Ch DD ? ; ;........................................................................ NewHand: ; mov AH, 02h ; mov DL, 07h ; int 21h ; jmp CS:OldInt1Ch ; iret ; ;........................................................................ end start ; end program
Download and try this com freeware
to hook the timer interrupt!
Link Borland C++ 4.52 and TASM 5.
; ASSEMBLY PART ; TO COMPILE ; tasm /ml nog.asm ; bcc -c roak.cpp ; tlink drive_letter:\bc45\lib\c0s roak nog, name_of_executable,,drive_letter:\bc45\lib\cs ; .model small .386 .data PUBLIC _ASM_FUNC msg DB " R",153,142,"K NOG!",10,13,'$' output_value DW ? .code EXTRN _C_FUNC:PROC _ASM_FUNC PROC NEAR ARG proc_input:word, proc_count:word ; save caller's BP to set up for addressing arguments push BP mov BP, SP ; add 2 to input number mov AX, [proc_input] add AX, 2 mov [output_value], AX ; beep mov AH, 2 mov DL, 7 int 21h ; display message count times mov CX, [proc_count] @@lp: mov AH, 9 mov DX, offset msg int 21h loop @@lp ; send number back using C function mov AX, [output_value] push AX call _C_FUNC ; adjust stack pointer and restore caller's base pointer add SP,2 pop BP ; return ret _ASM_FUNC ENDP // C++ PART // TO COMPILE // tasm /ml nog.asm // bcc -c roak.cpp // tlink drive_letter:\bc45\lib\c0s roak nog, name_of_executable,,drive_letter:\bc45\lib\cs // #include
extern "C" void ASM_FUNC(int in_num, int count_num); extern "C" void C_FUNC(int p); void main(){ int in_num = 0, count_num = 0; printf("\n\n Enter a number to be added to 2:\n "); fflush(stdin); scanf("%d",&in_num); printf("\n\n Enter the number of times to display a message:\n "); fflush(stdin); scanf("%d",&count_num); printf("\n\n This program uses roak.cpp and nog.asm to add\n 2 to an input number, and display count\n messages, and beep. The results are:\n\n"); // DISPLAY MESSAGE COUNT TIMES AND ADD 2 TO FIRST INPUT NUMBER. ASM_FUNC(in_num, count_num);} extern "C" void C_FUNC(int result){ printf("\n\n Your number added to 2 is: %d!\n\n FREEHAFER'S DOS BORLAND C++ 4.52 TASM 5 LINK PROGRAM IS TERMINATED!\n\n (C)1999 INNIEA PUBLISHING COMPANY! R%c%cK NOG!\n\n ",result,(char)153,(char)142);}
Download and try this executable freeware
of linked Borland C++ 4.52 and TASM 5!
TOUCH THIS TO GO BACK TO THE HOME PAGE!