Yes I know, that there are some similar questions around, but none of them are satisfying
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?
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
}
....
And yes, I am fully aware of any risk I am taking, so do please not ask, why I would need to do such a thing or whether I am trying to get the programmer's darwin award ;)