4

I need to debug an application written in C that reads and writes to segment register FS. To debug this application I need to see the memory address where FS points to.

The application uses code like this:

mov rdx, fs:[rcx]
mov fs:[rcx], rsi

How do I get the linear virtual address of a read/write from/to segment registers? I can compile this application for either Linux or Winodws.

Fee
  • 601
  • 8
  • 19

1 Answers1

4

On linux, you can use arch_prctl(ARCH_GET_FS, &fsbase). In windows, if the FS is pointing to the TEB as usual, you can read fs:[0x18] to get the base address, or use features of your debugger if available.

Jester
  • 54,538
  • 4
  • 72
  • 115