[转载]目标 code segment 的访问

当程序中使用指令 call / jmp,以及通过 int 引发中断例程的执行,这将都是对目标的 code segment 进行访问,当通过权限的检查后程序将会跳转到目标的 code segment 进行执行。

在 code segment 的访问过程中涉及到权限级别的改变,stack 的改变等问题。

访问目标 code segment 的几种情形:

1、call / jmp offset
在段内直接 call / jmp,不改变目标 code segment

2、call / jmp code_selector:offset
直接 call / jmp 目标 code segment

3、call / jmp callgate_selector:offset
使用 call gate 的 call / jmp 形式

4、call / jmp tss_selector:offset
使用 TSS gate 的直接 call / jmp 形式,使用了 TSS 任务切换机制

5、call / jmp taskgate_selector:offset
通过 task gate 使用 TSS 任务切换机制

6、int n
使用 int 指令调用 interrupt / trp 例程,或者 task gate 提供的任务切换机制

7、使用 syscall / sysret、 sysenter / sysexit 指令快速调用系统服务例程

8、ret 或 iret
利用 ret 以及 iret 指令构造另一种访问 code segment 的途径。

以上是程序中主动发起访问目标 code segment 大多数方法,在继续执行之前,processor 会进行一系统的检查,包括相关的权限检查、type 检查、limit 检查等,通过了检查后,加载到 cs:rip 后继续执行。

时间: 2024-08-04 13:37:41

[转载]目标 code segment 的访问的相关文章

[转载]通过 call gate 访问目标 code segment

直接 call / jmp 目标 code segment 不能改变当前的 CPL,若要 call / jmp 高权限的 code segment 必须使用 call gate,在 x86 下还要可以 call / jmp TSS descriptor 或者 call / jmp task gate,但在 64 bit 模式下 TSS 任务切换机制不被支持. 同样以下面的指令为例:(1) call  0x20:0x00040000 (2) jmp 0x20:0x00040000 --------

[转载]使用 call/jmp 直接调用/跳转目标 code segment

直接调用/跳转的形式是: call / jmp selector:offset 这里的 selector 是 code segment selector 直接使用 selector 来索引 code segment,这将引发 CS 的改变,code segment descriptor 最终会被加载到 CS 寄存器里. 在 code segment descriptor 加载到 CS 之前,processor 会进行一系列的检查,包括权限检查.type 检查.limit 检查等,在通过检查后,p

[转载]使用哪个 segment registers 进行数据的访问

对于 code segment 的访问,都知道是使用 CS selector register .对于 data segment 的访问,则是根据指令或内存的寻址方式来决定使用哪个 selector registers. 1.对于串操作指令来说,在缺省的情况下:源串引用 DS 作为参考对象,目标串引用 ES 作为参考对象. loadsd /* 从源串 ds:[esi] 中 load 到 eax 中 */ stosd /*  从 eax 中 store 到目标串 es:[edi] 中 */ mov

[转载] data segment 的访问

这里的 data segment 访问控制针使用对 DS.ES.FS 以及 GS selector register 进行访问,不包括 SS selector register,stack segment 访问与一般的 data segment 有些差别. 以 DS 为例代表所有的 data segment 访问(ES.FS 以及 GS),需要的权限条件是:RPL(DS.RPL) <= DPL 且 CPL(CS.DPL) <= DPL. 这里的 RPL 就是 DS.RPL,即:使用 ds se

[转载]stack segment 的访问

基于 stack 的访问都将引发 stack 访问控制检查,对于 stack 的访问控制比一般的 data segment 访问检查要严格. 用简单的式子表达为: if (RPL == DPL && CPL = DPL) { /* 通过检查,允许访问,加载 descriptor 进入 SS */ } else { /* 拒绝访问,引发 #GP 异常 */ goto do_#GP } 访问 stack 仅限于同级访问,RPL.CPL 以及 DPL 三者必须相等.即使 0 级代码也不能访问 3

What is x86 Conforming Code Segment?

SRC=Microprocessor Based Systems SRC=Computer Architecture: A Quantitative Approach

[转载]EF Code First 学习笔记:约定配置

要更改EF中的默认配置有两个方法,一个是用Data Annotations(在命名空间System.ComponentModel.DataAnnotations;),直接作用于类的属性上面;还有一个就是Fluent API,通过新增相应的配置类来覆盖默认配置.现在我们用这两个来对比了解EF中的约定配置. 主键:KEY Data Annotations:通过Key关键字来标识一个主键 [Key] public int DestinationId { get; set; } Fluent API:

[转载]使用 int n 调用系统例程

IDT(Interrupt Descriptor Table)仅能存放 interrupt-gate.trap-gate 和 task-gate. 指令: int 0x80 ----------------------------------- 0x80 是 vector (中断向量号) 在 x86 下,gate-descriptor 是 8 个字节,所以:gate = IDTR.base + vector * 8,在 long mode 下,gate-descrptor 是 16 字节,所以:

[转载] x86 winxp 下的 segmentation 实例

使用 bochs 可以很容易很直观地观察调试系统.下面选取一个 xp 启动的实际片断,如下: <bochs:7> sreg cs:s=0x001b, dl=0x0000ffff, dh=0x00cffa00, valid=1 ds:s=0x0023, dl=0x0000ffff, dl=0x00cff300, valid=31 ss:s=0x0023, dl=0x0000ffff, dl=0x00cff300, valid=31 ss:s=0x0023, dl=0x0000ffff, dl=0