A while ago, I had to trace through a lot of code in the CPU pane to track down some memory allocation related issues.
I wondered what the use of the FS segment was about, so via [Archive.is] delphi what is fs segment used for – Google Search, I found that it is related to Win32 Structured Exception handling and therefore not limited to Delphi, through these links:
- [WayBack] Guard page exceptions in Delphi? – Stack Overflow
- [WayBack] Debugging Session: Exception Handlers
- [WayBack] Debugging Session: Exception Frame Types
- [WayBack] cbloom rants: 11-09-11 – Weird shite about Exceptions in Windows
- WayBack: A Crash Course on theDepths of Win32 Structured Exception Handling, MSJ January 1997
- Backups of that:
- [WayBack] A Crash Course on TheDepths of Win32 Structured Exception Handling, MSJ January 1997 | Callback (Computer Programming) | Pointer (Computer Programming)
- [WayBack] A Crash Course on theDepths of Win32 Structured Exception Handling, MSJ January 1997
- Which got me to:
- [WayBack] BYTE* / Resources
- [WayBack] Under the Hood: New Vectored Exception Handling in Windows XP
- [WayBack] Exception Handling: Jeremy Gordon – win32 exception handling
- [WayBack] Under the Hood, MSJ April 1997: Pietrek – stack walking with symbolic traces #1
- [WayBack] Under the Hood, MSJ May 1997: Pietrek – stack walking with symbolic traces #2
- [WayBack] Under the Hood: Improved Error Reporting with DBGHELP 5.1 APIs: Pietrek – stack walking with symbolic traces #3
- [WayBack] Under the Hood, MSJ October 1997: Matt Pietrek – exception generator
- [WayBack] BYTE* / Undocumented 32-bit PEB and TEB Structures
- [WayBack] BYTE* / Undocumented 64-bit PEB and TEB Structures
- [WayBack] Under The Hood — MSJ, May 1996: Matt Pietrek – Thread Information Block (TIB)
- [WayBack] BYTE* / Resources
- Which got me to:
- Backups of that:
- [WayBack] Win32 Exception Handling for assembler programmers by Jeremy Gordon
- [WayBack] windows – what is fs:[register+value] meaning in assembly? – Stack Overflow
- [WayBack] windows – Where ES/GS/FS are pointing to? – Reverse Engineering Stack Exchange
- [WayBack] IsBadXxxPtr should really be called CrashProgramRandomly – The Old New Thing
- Microsoft-specific exception handling mechanisms – Wikipedia: Structured Exception Handling
- Exception handling syntax – Wikipedia: Microsoft specific
- Win32 Thread Information Block – Wikipedia
- Protected mode – Wikipedia
- x86 memory segmentation – Wikipedia: 80386 protected mode
A few disassembly parts to show how the Delphi Win32 compiler uses this for try finally blocks and try except blocks is below. Note that often, there are implicit try finally blocks when having managed method parameters or local variables.
–jeroen






