'Find a free interrupt slot

Some joker (BIOS/DOS/TSR...) has written random data in the Interrupt Vector Table. I know this because disassembling told me so.

Ordinarily before seizing an interrupt vector, I verify that the selected IVT slot is empty. But with all this left-behind-data, how can an humble application know that it is nonetheless safe to hook a particular interrupt vector?

Although my programmer's reference describes the DOS function 25h SetInterruptVector as

"Safely modifies an interrupt vector to point to a specified interrupt handler"

I don't think it cares too much about this pre-existing bogus content. So far for safely!


Is there some ingenious way to be absolutely sure that an interrupt vector is free?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source