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

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
Peter_Vigren

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

Post by Peter_Vigren »

How do I calculate it?
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

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

Post by Pype.Clicker »

well, all you need to do is segment(GDT)*16 + offset(GDT). That's your linear base address ;)
sysfree

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

Post by sysfree »

How can it be when i'm already in p-mode?
I never know what's the base of cs or ds.
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

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

Post 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
Peter_Vigren

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

Post by Peter_Vigren »

Pype.Clicker wrote: //off-topic : hey, i got a 3rd star :D
Congratulations... (I misspelled that, didn't I?) :)
Post Reply