May BIOS calls be intercepted?

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
wilsonsamm
Posts: 8
Joined: Mon Mar 24, 2008 6:58 pm

May BIOS calls be intercepted?

Post by wilsonsamm »

Hello everyone, this is my first post on this board :)

Tell me, on the x86 architecture, can a program (operating system kernel, application, machine virtualiser, whatever else...) keep a another piece of code from calling the BIOS and deal with this attempted call and call some other function instead?

for example, a virtual machine runs a program which wants to find out how much memory is available. It calls INT 12 which puts this info into AX. But the virtualiser doesn't want to devote all the RAM to this vm, so how can it prevent this from happening?
I take my tea with milk
User avatar
Brendan
Member
Member
Posts: 8561
Joined: Sat Jan 15, 2005 12:00 am
Location: At his keyboard!
Contact:

Re: May BIOS calls be intercepted?

Post by Brendan »

Hi,
wilsonsamm wrote:for example, a virtual machine runs a program which wants to find out how much memory is available. It calls INT 12 which puts this info into AX. But the virtualiser doesn't want to devote all the RAM to this vm, so how can it prevent this from happening?
This is fairly simple - you replace the BIOS's IVT vector (for which-ever interrupts matter to you) with your own IVT vector, and then you can handle the interrupt/s yourself or jmp to the original interrupt handler (or both, e.g. depending on the value in AX).

Typically you'd do the same to reserve yourself some memory - for e.g. replace the BIOS's "get memory size" functions with your own functions that only report what you don't use.

However, for a true virtualiser you'd use virtual8086 mode and virtualise everything, so that you can have 2 or more virtual programs running at the same time without stuffing each other up. This could/would include your own virtual BIOS running inside the virtual machine.


Cheers,

Brendan
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.
wilsonsamm
Posts: 8
Joined: Mon Mar 24, 2008 6:58 pm

Post by wilsonsamm »

And by this you mean the area of memory between absolute zero and 0x03FF?
That's simpler than I thôt. I'm guessing each entry here contains a 32-bit absolute address pointer to a handler?
I take my tea with milk
Ninjarider
Member
Member
Posts: 62
Joined: Fri Jun 29, 2007 8:36 pm

Post by Ninjarider »

havnt delt with virtual enough yet to really know
dont be suprised if there 16 bit seg:offset
User avatar
JAAman
Member
Member
Posts: 879
Joined: Wed Oct 27, 2004 11:00 pm
Location: WA

Post by JAAman »

wilsonsamm wrote:And by this you mean the area of memory between absolute zero and 0x03FF?
That's simpler than I thôt. I'm guessing each entry here contains a 32-bit absolute address pointer to a handler?
in RMode, on bootup it is located at that address, yes (though it can be moved), but it doesnt use 32 bit addresses, its a 16:16 segment:offset pair, as is customary in RMode


but as brendan said, its even better (though slightly more complicated) to use VMode

this is, of course, assuming your talking about compatibility with older RMode programs
if your talking about new programs written for your OS, PMode is the way to go, and that automatically restricts the user applications in more ways than just that
Post Reply