从C / C ++ code执行RDMSR和WRMSR指令 [英] Execute RDMSR and WRMSR instructions from C/C++ code
问题描述
我需要控制C-国家配置。具体来说,我可能想执行以下ASM code:
I need to control C-State configuration. Specifically, I'd probably like to execute the following asm code:
__asm
{
rdmsr
and eax, 0x00
or eax, 0x01
wrmsr
}
目前,我得到了 RDMSR
行此异常:
Currently, I got this exception on rdmsr
line:
Unhandled exception at 0x00e3139e in MessWithCStates.exe: 0xC0000096: Privileged instruction.
我怎么能(永久)提升我的应用程序的特权时,以便它可以执行上述code?我使用VS 2010。
How can I (permanently) elevate priviliges of my app so it could execute the code above? I use VS 2010.
<击>注:这是可能无需编写内核模式驱动程序。见的 R / W的一切的击>
推荐答案
有机会,你是在x86处理器中环3.您没有执行此命令权限运行该code。期。这是硬件限制。执行该指令的唯一方法是进入Ring 0的机会是,你的系统不会让你这样做。您将需要编写内核模式驱动程序来实现。
Chances are, you are running this code on an x86 processor within Ring 3. You do not have the privileges to execute this command. Period. This is a hardware limitation. The only way to execute that instruction is to go into Ring 0 and chances are, your OS won't let you do that. You will need to write a kernel-mode driver to accomplish this.
修改: http://faydoc.tripod.com/cpu /rdmsr.htm 有更多的信息。
这篇关于从C / C ++ code执行RDMSR和WRMSR指令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!