Physical address and GDT

Hello,

Quote
> After reading through some of the newsgroup discussion, it seems that in
> order to do so, I will need to convert the segment value to the selector
> value.  Then obtain the base address from GDT and add to the offset to
> obtain the physical address.

In protected mode, the CPU uses selectors *instead of* segments. You don't have
to convert it, it's loaded into the segment register.

Quote
> The problem is : how can I found out where GDT is?  How can I access GDT?
> Is there any int calls to get the address of GDT? (such as int 31h sub
> calls)? or something else?

Forget the GDT, you don't have to bother it.
BP uses RTM.EXE to manage protected mode. RTM has support for WinAPI functions.
GetSelectorBase(<selector>) returns the *linear* address of the selector.

If you know the linear address (SEG*16+OFS), just create a new selector, and use
it to access the memory.

function NewSelector(sBase, sLimit: longint): pointer;
var sel: word;
begin
  sel := AllocSelector(0);
  SetSelectorBase(sBase);
  SetSelectorLimit(sLimit);
  NewSelector := ptr(sel,0);
end;

This returns you a pointer (sel:ofs, not seg:ofs) which points to the address,
you specify in sBase, even if sBase is not a paragraph boundary. sLimit is the
selector length. On a 286, it must be 65536 or less. On a 386 it's max 4GB (-1
as longint, hehehe).

Do not use invalid selector base, it may cause a page fault (but it's not a big
trouble in pmode... :)

Andras