Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is a privileged instruction?

I have added some code which compiles cleanly and have just received this Windows error:

--------------------------- (MonTel Administrator) 2.12.7: MtAdmin.exe - Application Error --------------------------- The exception Privileged instruction.   (0xc0000096) occurred in the application at location 0x00486752. 

I am about to go on a bug hunt, and I am expecting it to be something silly that I have done which just happens to produce this message. The code compiles cleanly with no errors or warnings. The size of the EXE file has grown to 1,454,132 bytes and includes links to ODCS.lib, but it is otherwise pure C to the Win32 API, with DEBUG on (running on a P4 on Windows 2000).

like image 215
David L Morris Avatar asked Sep 18 '08 02:09

David L Morris


People also ask

What is the difference between privileged and non-privileged instruction?

Suppose an attempt is made to execute a privileged instruction in non-privileged mode which causes a run-time error. Generally the user mode of the operating system is called non-privileged mode and kernel mode of the operating system is called privileged mode.

What are privileged instructions in virtualization?

Privileged Instructions: instructions that if executed in user mode trap to kernel mode, but if executed in kernel mode they do not trap. Control Sensitive Instructions: instructions that modify the system registers.

When privileged instruction is executed?

To allow for privileged instructions a "mode bit" is added into the computer's software to indicate one of two dual modes: monitor mode or user mode. The privileged instruction can only be executed when the microprocessor is running in monitor (or supervisor) mode, a mode that enables execution of all instructions.


2 Answers

To answer the question, a privileged instruction is a processor op-code (assembler instruction) which can only be executed in "supervisor" (or Ring-0) mode. These types of instructions tend to be used to access I/O devices and protected data structures from the windows kernel.

Regular programs execute in "user mode" (Ring-3) which disallows direct access to I/O devices, etc...

As others mentioned, the cause is probably a corrupted stack or a messed up function pointer call.

like image 145
Benoit Avatar answered Nov 03 '22 13:11

Benoit


This sort of thing usually happens when using function pointers that point to invalid data. It can also happen if you have code that trashes your return stack. It can sometimes be quite tricky to track these sort of bugs down because they usually are hard to reproduce.

like image 35
Daniel Avatar answered Nov 03 '22 14:11

Daniel