Article 8 TSR Program Design

Source: Internet
Author: User

This blog post introduces a simple example of TSR program design.

 

I. What is TSR?

TSR is short for terminate and stay resident program. Memory resident programs refer

A program that leaves a part of the program in the memory after execution and is protected by the operating system and can be activated by the outside world. I

Generally, TSR is disconnected from DoS or BIOS.

 

Ii. What is the TSR design concept introduced in this blog?

Designed features: after running TSR, no matter what you enter, the screen will only display "a tsr was installed in

Computer by lulipeng !". (The input control character has no effect, such as shift or Ctrl, because it is not on the keyboard.

Buffer)

Design method: ① change the 16h interrupt address to the address of your own program, retain the original interrupt address, so as to meet your needs

To call.

② DOS Function calls int 16 h, A = 10 h is to read characters from the keyboard buffer, Al = read ASCII characters.

You only need to change the corresponding Al to the characters that are pre-designed and output in a certain order.

③ Why is the method in ② feasible? The blogger guesses that when the character is entered in command.com, the program

It will call the 10 h function of int 16 h to read the ASCII character and then output it. We only need to intercept Al,

Change it.

 

3. Notes

The code is successfully tested in command.com of win7 flagship edition. It is ineffective in cmd.exe!

Unfortunately, I do not understand the original committee?

 

Iv. Code

Code segmentassume Cs: codeoldint16 DW ?,? Msgindex DW 0msg dB 'a TSR was installed in the computer by lulipeng! 'Newint16 proc far; CMP ah, 0; je leavecmp ah, 10hje go_1jmp dword ptr oldint16; if it is not a read keyboard input, call the original int 16 h and return go_1 directly: pushfcall dword ptr oldint16; call the original int 16 h and read the characters to CMP Al, 0 dhje GO_2 in Al; if it is a carriage return, the input ends, and the carriage return operator does not process push SiMoV Si, msgindexmov Al, MSG [Si]; change the original character to the programmer-defined character Inc sicmp Si, 48je go_3back: mov msgindex, sipop sijmp donego3: mov Si, 0jmp backgo_2: mov msgindex, 0 done: iretnewint16 endpstart:; Use int 21 h, Ah = 35 h, Al = 16 h to retrieve the address interrupted by the 16h number, which exists in mov Al, 16 hmov Ah in ES: BX, 35 hint 21 hmov oldint16, bxmov oldint16 [2], es; Use int 21 h, Ah = 25 h, Al = 16 h, put DS: the address in dx is written to the 16h interrupt push cspop dsmov dx, offset newint16mov Al, 16 hmov ah, 25 hint 21 h; The content before the start label is stored in the memory mov dx, offset startint 27 hmov ah, 4 Chint 21 hcode endsend start

 

V. Results

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.