When a user-mode application executes sysenter (int 0x2e in Windows 2000 and earlier versions), the processor switches the execution to kernel mode and, in particular, to a specific address stored in the Model Specific Register (MSR). MSRs are the control registers that are used for debugging, monitoring, toggling, or disabling various CPU features.
There are three important registers for the user-mode-to-kernel-mode switching process using sysenter:
- MSR 0x174 (IA32_SYSENTER_CS): This stores the CS segment register value, which is available after using sysenter; here, the SS segment register will be a CS value + 8.
- MSR 0x175 (IA32_SYSENTER_ESP): This stores the value of the kernel-mode stack pointer once sysenter is executed; it is where the arguments generally will be copied to.
- MSR 0x176 (IA32_SYSENTER_EIP): This is the new EIP value after executing sysenter. It points to the KiSystemService function on x86 or the KiSystemCall64 function on x86-64...