从用户模式进入环0 [英] entering ring 0 from user mode

查看:61
本文介绍了从用户模式进入环0的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大多数现代操作系统都在保护模式下运行。现在,用户程序可以通过直接设置某些控制寄存器中的相应位来输入 ring 0。还是必须通过一些系统调用。



我相信要访问我们需要通过操作系统的硬件。但是,如果我们知道硬件设备的地址,就可以参考设备的位置编写一些汇编语言代码并访问它。当我们用汇编语言代码提供某些硬件设备的地址时会发生什么。



谢谢。

解决方案

 ;设置PE位
mov cr0,eax
或eax,1
mov eax,cr0
;远跳(cs =代码段的选择器)
jmp cs:@pm

@pm:
;现在我们处于从维基百科摘录的PM

中。



基本思想是将 cr0 控制寄存器中的 0th 位设置为1。 b
$ b

但是,如果您已经处于保护模式(例如,您在Windows / Linux中),安全性将限制您执行此操作(您处于第3环-最低信任度)。 b
$ b

因此,第一个进入保护模式的人。


Most modern operating systems run in the protected mode. Now is it possible for the user programs to enter the "ring 0" by directly setting the corresponding bits in some control registers. Or does it have to go through some syscall.

I believe to access the hardware we need to go through the operating system. But if we know the address of the hardware device can we just write some assembly language code with reference to the location of the device and access it. What happens when we give the address of some hardware device in the assembly language code.

Thanks.

解决方案

; set PE bit
mov cr0, eax
or eax, 1
mov eax, cr0
; far jump (cs = selector of code segment)
jmp cs:@pm

@pm:
; Now we are in PM

Taken from Wikipedia.

Basic idea is to set (to 1) 0th bit in cr0 control register.

But if you are already in protected mode (i.e. you are in windows/linux), security restricts you to do it (you are in ring 3 - lowest trust).

So be the first one to get into protected mode.

这篇关于从用户模式进入环0的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆