Restoring real-mode

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
moth

Restoring real-mode

Post by moth »

What needs to be backed up before entering and restored after leaving
protected mode?  The things I can think of off hand are:

all registers
GDT
IDT

Anything else?  Anyone have a doc that explains how to correctly and
safly do this.
Legend

RE:Restoring real-mode

Post by Legend »

Real mode doesn't care about GDT and IDT.
And I think you don't need to save registers like eax ...
Jamethiel

RE:Restoring real-mode

Post by Jamethiel »

Real mode -does- care about the IDT. You need to restore it to base 0 limit 0x3ff.
Legend

RE:Restoring real-mode

Post by Legend »

*storesitinmind*, didn't know that :)
Jamethiel

RE:Restoring real-mode

Post by Jamethiel »

Actually, there's a neat trick you can do with this. Allocate a block of memory 0x400 bytes long, and set it as your real-mode IDT. Populate it with interrupt handlers that do an indirect jump through the address in the vector table at 0000:0000. Now you can hook interrupts before anyone else who adds their vectors afterwards, and most software doesn't think to check for this.
Post Reply