본문 바로가기

프로그래밍/C-CPP

DWORD PTR fs:[0] 는 무엇인가?

반응형

https://answers.yahoo.com/question/index?qid=20070424201345AAXWrs7


질문: DWORD PTR fs:[0]?


fs 는 무엇인가? DWORD PTR ds:[0] 도 본 적이 있다.

ds 는 데이터 세그먼트부터의 오프셋인 것 같은데.



---

답변: 

FS 는 IA-32 프로세서류의 또다른 세그먼트 레지스터이다.

win32 환경에서는, 쓰레드의 TEB (Thread Environment Block)

의 여러 아이템들을 가리키는 데 사용된다. FS[0] 은 SEH

(Structured Exception Handler, 구조적 예외처리) 체인을 

가리킨다. 프로그램은 FS[0] 을 새로운 SEH 구조를 가르키도록

하여 기본 예외처리기가 아닌 예외처리기를 사용할 수 있다.


자세한 내용은 TEB, TIB, SEH 를 구글해 보라.


====

원문


DWORD PTR fs:[0]?


What is this fs? I also seen a variant with DWORD PTR ds:[0] 


I assume ds means offset of the beginning of the data segment?

 Follow   1 answer Report Abuse


---

Answers


 zxreveng

 Best Answer:  FS is another segment register in the IA-32 processors - as you might have gathered. In a Win32 environment, it is used to point to various items in a thread's TEB (Thread Environment Block). FS[0] points to the SEH (Structured Exception Handler) chain. A program can replace the default exception handler. Installation of a handler is accomplished by pointing FS[0] to a new SEH structure. 


See the included links for full details and Goggle TEB, TIB, and SEH.

Source(s):

http://www.microsoft.com/msj/archive/S2CE.aspx 

http://msdn2.microsoft.com/en-us/library/ms253960(VS.80).aspx 

http://en.wikipedia.org/wiki/Win32_Thread_Information_Block

zxreveng · 9 years ago

728x90