您现在的位置是:主页 > news > 做网站税点/交换链接的例子
做网站税点/交换链接的例子
admin2025/4/10 20:30:54【news】
简介做网站税点,交换链接的例子,wordpress如何知道用户数量,雄安做网站优化的公司相信大家都不陌生call指令了,但除了常见的段内调用(CS当前指向的段)外,还有其他几种不同的调用,手册上说明是有4种,在第 2A 卷: 指令集参考(A-L)中的CALL—Call Procedure 其中我们要说的另一种就是Far Ca…
相信大家都不陌生call
指令了,但除了常见的段内调用(CS当前指向的段)外,还有其他几种不同的调用,手册上说明是有4种,在第 2A 卷: 指令集参考(A-L)中的CALL—Call Procedure
其中我们要说的另一种就是Far Call
(段间调用),Far Call
也分为两种类型,一种是特权级别相同的段间调用,一种是特权级别不同的段间调用
我们先来看看段内调用和段间调用的区别,在手册中第 1 卷: 基本架构的6.31中
共同点是都会改变Stack和EIP,不同点是Far Call
还会改变CS并且会把调用前的CS压入栈中,在返回的时候也不同,Far Call
会将栈顶返回地址pop
到eip
中,然后再将段选择子pop
到cs
中,返回时候具体区别在第 2B 卷: 指令集参考(M-Z)中的RET—Return from Procedure
还有一种就是特权级别不同之间的Far Call和return,这个解释在手册中的第 1 卷: 基本架构 6.3.6 CALL and RET Operation Between Privilege Levels
这里改变的值有eip cs ss esp,压入堆栈的东西也不同,保存了切换前代码段的堆栈位置,因为特权级别的不同发生了堆栈的切换,但切换esp和ss的值从哪来,这里有说明
- Temporarily saves (internally) the current contents of the SS, ESP, CS, and EIP registers.
- Loads the segment selector and stack pointer for the new stack (that is, the stack for the privilege level being
called) from the TSS into the SS and ESP registers and switches to the new stack.- Pushes the temporarily saved SS and ESP values for the calling procedure’s stack onto the new stack.
这里要注意的一点是如果在Far Calls in Protected Mode
下(第 2A 卷: 指令集参考(A-L)CALL—Call Procedure),那么
大概意思就是会通过提供的段选择子来进行对段描述符的访问
这里提出了如果是不同权限间的代码段调用,使用调用门是首选的办法,使用调用门会进行权限的提升,后面还说了
When executing an inter-privilege-level far call, the code segment for the procedure being called must be accessed through a call gate. The segment selector specified by the target operand identifies the call gate. Here again, the target operand can specify the call gate segment selector either directly with a pointer (ptr16:16 or ptr16:32) or indirectly with a memory location (m16:16 or m16:32). The processor obtains the segment selector for the new code segment and the new instruction pointer (offset) from the call gate descriptor. (The offset from the target operand is ignored when a call gate is used.) On inter-privilege-level calls, the processor switches to the stack for the privilege level of the called procedure. The segment selector for the new stack segment is specified in the TSS for the currently running task. The branch to the new code segment occurs after the stack switch. (Note that when using a call gate to perform a far call to a segment at the same privilege level, no stack switch occurs.) On the new stack, the processor pushes the segment selector and stack pointer for the calling procedure’s stack, an (optional) set of parameters from the calling procedures stack, and the segment selector and instruction pointer for the calling procedure’s code segment. (A value in the call gate descriptor determines how many parameters to copy to the new stack.) Finally, the processor branches to the address of the procedure being called within the new code segment.
大概理解一下就是在执行特权级之间的远距离调用时,必须通过调用门访问被调用过程的代码段。目标操作数指定的段选择子标识了调用门。处理器从调用门描述符中获取新代码段的段选择子和新指令指针(偏移量).(使用调用门时,与目标操作数的偏移将被忽略。)
举个例子,call cs:eip
这里这条指令
在执行特权级之间的远距离调用时,必须通过调用门,而cs指向的段描述符必须是一个调用门,而我们cpu最终执行代码的位置并不是由后面接的操作数eip决定的,而是通过cs中指向的调用门中获取新代码段的段选择子和新指令指针(偏移量),也就是在使用调用门时候后面的eip是被忽略的
如果是同级别的话
A far call to the same privilege level in protected mode is very similar to one carried out in real-address or virtual-8086 mode. The target operand specifies an absolute far address either directly with a pointer (ptr16:16 or ptr16:32) or indirectly with a memory location (m16:16 or m16:32). The operandsize attribute determines the size of the offset (16 or 32 bits) in the far address. The new code segment selector and its descriptor are loaded into CS register, and the offset from the instruction is loaded into the EIP register
大概意思就是 目标操作数可以直接使用指针(ptr16:16或ptr16:32)或间接使用内存位置(m16:16或m16:32)指定绝对远程地址。
新的代码段选择器及其描述符被加载到CS寄存器中,指令的偏移量被加载到EIP寄存器中。也就说是后面的EIP是有效的
总结一下:
1.跨段调用时,一旦有权限切换,就会切换堆栈
2.CS的权限一旦改变,SS的权限也要跟随改变,CS和SS的权限等级必须一致
3.JMP FAR 只能跳转到同级非一致代码段,但CALL FAR 可以通过调用们进行提权,提升CPL权限
4.切换栈时候ESP和SS从哪来,参见TSS段
5.执行特权级之间的远距离调用时call cs:eip
中的Eip是被忽略的,如果是同级别权限eip则是有效的