Re: lea with fs override




"JC" <spamtrap@xxxxxxxxxx> wrote in message
news:e2plll$lul$2@xxxxxxxxxxxxxxxxxxxx
I'd like to know, from userland, what base linear address my OS
(Windows XP) has set the FS segment (or GS, for that matter) to point
to.

I thought I could be clever, and do something like this (intel
syntax):

lea eax, fs:[0]

To figure this out. Unfortunately, LEA ignores segment overrides, and
I get back 0. Not helpful.

Is there another way to figure this out?


There is an instruction to get access rights, lar, and one to get the
segment limit, lsl. But, there isn't one to get the base address. You need
to locate the GDT (This is environment specific, i.e., I don't know how
to...). Once you've located the GDT, index into the GDT array by the
selector. Each selector should be a multiple of 8 which corresponds to it's
offset from the start of the GDT. (if FS is 0x18, descriptor is at address
of GDT plus 0x18). Copy your descriptor (8 bytes that your selector point
to). Extract the base address from the copied descriptor (you'll need the
Intel manuals for the layout, or it might be on www.sandpile.org). It's
possible that you'll need to locate a descriptor which points to the GDT to
give you access to the GDT which could be in it's own segment. The number
of selectors in the GDT can be determined from the segment limit of this
'GDT access' selector divided by eight.

That's all I've got...


Rod Pemberton


.



Relevant Pages

  • Re: 32 bit flat memory model
    ... the segment and offset are ... In protected mode (without paging), ... selector instead. ... The selector selects a single descriptor from a table of ...
    (comp.lang.asm.x86)
  • Re: The relation between %fs and fs base
    ... base address can be fitted in 32 bits, a GDT entry is used for better ... > I want to access different TLS through both fs base and GDT ... > %fs" (where GDT_SEL is the selector of GDT entry)? ... > segment registers are still 16 bits as in x86, ...
    (freebsd-current)
  • Re: From rmode to pmode
    ... usage: Descriptor Base, Limit, Attr ... ; GDT ... He labels the second selector SelectorVideo and sets it equalt to 0x10. ... mov ax, cs ...
    (alt.lang.asm)
  • Re: IP Level Encryption (kind of long)
    ... Segment register with a segment selector for a data segment or ... with a selector for a writeable data segment. ... "When the S (descriptor type) flag in a segment descriptor is set, ... a code segment address at the same physical address in memory. ...
    (sci.crypt)
  • Re: why the selector is Descriptor - empty Descriptor
    ... the selector is the index of GDT and three bite which contain ... T1 and RPL.so my question still is why the program define the selector ... The reason that works is because the actual index into the descriptor ... order zero bits ...
    (alt.lang.asm)