entering ring 0 from user mode

前端 未结 3 1209
情书的邮戳
情书的邮戳 2021-01-16 14:50

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

相关标签:
3条回答
  • 2021-01-16 14:55

    To enter Ring 0, you must perform a system call, and by its nature, the system controls where you go, because for the call you simply give an index to the CPU, and the CPU looks inside a table to know what to call. You can't really get around the security aspect (obviously) to do something else, but maybe this link will help.

    0 讨论(0)
  • 2021-01-16 15:03
    ; 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 讨论(0)
  • 2021-01-16 15:13

    You can ask the operating system to map the memory of the hardware device into the memory space of your program. Once that's done, you can just read and write that memory from ring 3. Whether that's possible to do, or how to do that, depends on the operating system or the device.

    0 讨论(0)
提交回复
热议问题