Page 1 of 1

The base of the GDT (plus the LDT and IDT)...

Posted: Mon Jul 15, 2002 8:44 am
by Peter_Vigren
How do I calculate it?

Re:The base of the GDT (plus the LDT and IDT)...

Posted: Mon Jul 15, 2002 9:30 am
by Pype.Clicker
well, all you need to do is segment(GDT)*16 + offset(GDT). That's your linear base address ;)

Re:The base of the GDT (plus the LDT and IDT)...

Posted: Thu Jul 18, 2002 7:40 pm
by sysfree
How can it be when i'm already in p-mode?
I never know what's the base of cs or ds.

Re:The base of the GDT (plus the LDT and IDT)...

Posted: Fri Jul 19, 2002 1:21 am
by Pype.Clicker
//off-topic : hey, i got a 3rd star :D

in that case (and provided that you're at DPL0), you can use
sgdt [target_6bytes] to get a copy of the current GDT registers.

sidt works the same way. As the system will reply with a linear address, you'll need a data descriptor that starts at offset 0 (or a data descriptor that starts at a well-known address, in that case an alignment of the value read by sgdt will be required) to access the tables. Note however that the easiest way to work is to remember the logical address of your GDT when you set it up ...

For the LDT, things are a bit different while sldt returns the *selector* of the current LDT. Thus you need a pointer to your GDT and access GDT+sldt(). Then, read the LDT descriptor and extracts its base address from the fields...

Hope it'll help

Re:The base of the GDT (plus the LDT and IDT)...

Posted: Fri Jul 19, 2002 3:30 pm
by Peter_Vigren
Pype.Clicker wrote: //off-topic : hey, i got a 3rd star :D
Congratulations... (I misspelled that, didn't I?) :)