NASM - The Netwide Assembler
NASM Forum => Programming with NASM => Topic started 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
-
If I told you that I need help changing the oil on my car, what would your first question be?
-
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.
-
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:
[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.
-
Thank you Keith Kanios again for your useful contribution and help.
I really appreciates your notes.
With regards