使用 Visual Studio 15 使用 C++ 输入 Ring 0 [英] Entering Ring 0 with C++ using Visual Studio 15

查看:28
本文介绍了使用 Visual Studio 15 使用 C++ 输入 Ring 0的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是的,我知道,周围有一些类似的问题,但没有一个是令人满意的

我知道这是一个愚蠢的想法,但我需要使用我的 Visual Studio 2015 C++-Project 进入内核模式(又名 Ring 0).
我还想以最小的必要努力完成它(意思是,我不想创建一个专门用于测试的驱动程序,并且在每次构建后都必须签名和重新部署,因为这非常乏味).

I know that it is a stupid idea, but I need to enter into kernel-mode (aka Ring 0) with my Visual Studio 2015 C++-Project.
I also want to do it with the minimal effort necessary (meaning, that I do not want to create a driver specifically for testing and having to sign and redeploy after every build as this is very tedious).

我怎样才能做到这一点?

How can I achieve this?

项目是在我的主机上运行还是在远程(或虚拟机)上运行对我来说并不重要——我有足够的机器可供我使用.


背景:我目前正在开发 Cosmos 操作系统,我需要测试需要 Ring 0特权"的 X86 汇编指令,例如rdmsroutin
运行以下代码将在第 8 行中断并带有 0xC0000096: Privileged instructions.-Error:

It does not matter to me, whether the project is run on my host machine or on a remote one (or virtual one) -- I have enough machines at my disposal.


Background: I am currently working on the Cosmos operating system and I need to test X86-assembly instructions which need Ring 0 "privilege", e.g. rdmsr, out, in etc.
Running the following code will break on the 8th line with an 0xC0000096: Privileged instruction.-Error:

int* ptr = new int[4];
int* va = ptr;

__asm
{
    lea esi, va
    mov ecx, 0xe7
    rdmsr                //error, as this must run in ring0
    mov [esi + 4], eax
    mov [esi], edx
    mov ecx, 0xe8
    rdmsr
    mov [esi + 12], eax
    mov [esi + 8], edx
    xor eax, eax
}

....


是的,我完全了解我所承担的任何风险,所以请不要问,为什么我需要做这样的事情,或者我是否想获得程序员的达尔文奖;)

推荐答案

AFAIK Visual Studio 无法调试内核代码,但还有其他调试器可以:WinDbgKD.您需要一些时间来弄清楚它们,但别无他法.

AFAIK Visual Studio cannot debug kernel code, but there are other debuggers that can: WinDbg and KD. You'll need some time to figure them out, but there's no other way.

这篇关于使用 Visual Studio 15 使用 C++ 输入 Ring 0的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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