NASM - The Netwide Assembler

NASM Forum => Programming with NASM => Topic started by: mannoosh2000 on April 16, 2010, 11:20:26 PM

Title: Need help about Modifying an existing ISR
Post by: mannoosh2000 on April 16, 2010, 11:20:26 PM
Hello,

What is the best way to modify an existing ISR without affecting the original function of the routine?
I need to choose an existing ISR and add some code to it.


Thanx
Title: Re: Need help about Modifying an existing ISR
Post by: Keith Kanios on April 17, 2010, 02:00:57 AM
If I told you that I need help changing the oil on my car, what would your first question be?
Title: Re: Need help about Modifying an existing ISR
Post by: mannoosh2000 on April 17, 2010, 08:48:34 AM
Thank you Keith Kanios for your contribution... and I shall explain more.

The task is to write an assembly program that exploid an existing ISR. So, I need first to choose an appropriate ISR.

Then,for evey 10th call of the ISR, the ISR must be modified to send a chosen character on the serial port. So the ISR must presesrve it's original function as well as have the new code addition that send a character on the serial port.

The program should be executable under Windows environment.

I hope that I gave a more vlear view of the task.
Title: Re: Need help about Modifying an existing ISR
Post by: Keith Kanios on April 18, 2010, 06:47:36 AM
The Windows-specific portion of this task is better off explained by articles such as this one (http://www.codeproject.com/KB/system/phymem2.aspx).

A minimalistic approach specific to the x86 architecture would be to read the particular entry of the IVT/IDT, isolate the current address of the desired ISR, store that address as apart of your ISR that accounts for it, and replace that IVT/IDT entry with the address of your ISR.

Below is a simplistic (32-bit) example of a replacement ISR:

Code: [Select]
[section .data]
old_isr DD 0
count DB 0

[section .code]
new_isr:
 inc BYTE[count]
 cmp BYTE[count],9
 jb .yield
 mov BYTE[count],0
 ;... do my stuff...
.yield:
 jmp DWORD[old_isr]

Again, the above example is simplistic and the aforementioned article would be infinitely more useful.
Title: Re: Need help about Modifying an existing ISR
Post by: mannoosh2000 on April 19, 2010, 05:25:09 PM
Thank you Keith Kanios again for your useful contribution and help.
I really appreciates your notes.

With regards