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).
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.
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.
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With