Сегментная адресация в x64.


? x64 ?????????? ????????? ???????? ?????? ?? ???, ??? ? ????????? x86. ?????????? ????????????, ??????? ? ??????? ????, ????? ?? ????? ?? ????????, ??, ? ??????? ??? ?????????, «???» ???? ??????? ?????? ? ? user mode.

??? ??? ??????? ?? ????? ?????? “Intel® 64 and IA-32 Architectures Software Developer's Manual”:

 

3.2.4 Segmentation in IA-32e Mode

… In 64-bit mode, segmentation is generally (but not completely) disabled, creating a flat 64-bit linear-address space. The processor treats the segment base of CS, DS, ES, SS as zero, creating a linear address that is equal to the effective address. The FS and GS segments are exceptions…

? ?????:

3.4.4 Segment Loading Instructions in IA-32e Mode

Because ES, DS, and SS segment registers are not used in 64-bit mode, their fields (base, limit, and attribute) in segment descriptor registers are ignored. Some forms of segment load instructions are also invalid (for example, LDS, POP ES).

??????????, ??? ?????? ??????????? ?????????? ??????. ??????????? ????????? ?????? ???????????? ?????? ??? ???????? ?????? ??????????, ???? ??????? (???/??????), ??????????? ???? (32/64 ???) ? ?.?. ?????????? ???????? ?????? ?? ?????? ? ? ??? ???? ????? ????????? ????????, ?????? ?????? ?????????? ??????? ????? ???????? ???????? ? ???????. ?????? ??, ? ????? ?????? ??????? ???? ???????? ????????:

  • ????? ?????????? ????????, ??????????? ? DS, ES ??? SS, ????? ???????? ?????????? ?????????.
  • ? ?????? CS, ?????????? ?????? ??? ???????? (???/??????) ? ??????????? ???? (32/64 ???).
  • ? ?????? FS ? GS, ???? ???????? ???????? ????? MSR (model specific register), ??? ??? ? ??????? ? ?????????? ??????????? ????? ???? ???????? ????? ????????.

? Windows ??? «?????????? ?????????» ???? ????? ????? ????. ????????, ??? ??????? ??????????? ? ?????????? ??????? ????? GetThreadContext ? SetThreadContext ?????????? ?????????? ????????: SetThreadContext ?????????? ???? CONTEXT_SEGMENTS; GetThreadContext – ?????????? ??????? ???????????? ?????????. ????????? ????? ? ????, ??????? ????????? ?????????? ? ????????? ???????, ????????????? ?????????? ?????????? ???????? ? ???????????????? ?????????.

?????????? ????????? ????????? ?????????? ??????????? ? ????? ?????????????? ?????, ????????? ????? ?????????? ???. ???? ? ???, ??? ??? ????????? ???? ??????????? ?????? ??? 64-? ??????? ????. 32-? ?????? ???, ??-???????? ??????????? ???? ???????? ?????????? ?????????. ?????? ??????????? ????, ??? ????? ????????? Access Violation, ???????????????? ???????? ??????????, ??????????? ? ?????????? ???????? ???????? ???????? ???????? ?? GetThreadContext, ??????? ?????? ????????? ?????????? ???????? ??? ??????????? ?? ????????? ???????? ? ???????? ??????????. ????? ????, ???? ?????????? ?????????? ?????????? ? ???? ?? ????? ??? ?????? ??? ?? ?????. ?????????? ????????????? ????? ????????, ????? ???????????? ?????????? ???????? ? ?????????? ????????.

? ?? ????, ?? ??? ???, ???????? FS…

? ??????? ????? ?????? ????? ?????. ? ????? ????? ?????? ??? ???? ?? ??? ????? ?????? ??? Wow64.

Cross-posted from blog.not-a-kernel-guy.com.

Skip to main content