In IA-32 assembly language, can IDTR, GDTR or LDTR be modified/'loaded' without the LIDT, LGDT and LLDT instructions?
Also, is there a complete list of instructions that can be used to modify other registers? I need to know which instructions could be used to modify CR3, and which instructions could be used to modify ECX.
I am new to IA-32 assembly. I am aware of MOV, ADD, SUB, etc., however it would need to be a complete list and I believe there are probably a whole lot of instructions which could potentially be used to modify these registers.
Thanks! :)
Edit: The reason I want to know is because I am considering whether monitoring an instruction trace (using hardware debugging) of executed instructions is a feasible method of detecting - in an external 'integrity monitoring' machine - any malicious rootkits which alter the addresses in these registers to perform what is known as an Address Translation Redirection Attack (ATRA). Therefore, I am trying to determine whether it is possible to determine a complete list of potential malicious instruction sequences modifying each of these registers.
Best How To :
The IDTR, GDTR or LDTR can be modified by:
- LIDT, LGDT and LLDT instructions
- entering system management mode, modifying the values in the "state save" area, then leaving system management mode to cause the modified values to be loaded
- using hardware virtualisation extensions, where host is able to modify the virtual IDTR, GDTR or LDTR used by guest
Note that this list does not include keeping the IDTR, GDTR or LDTR the same and modifying the data they point to (the IDT, GDT or LDT).
CR3 can be changed by:
mov cr3
instruction
- hardware task switch
- code running in system management mode
- hardware virtualisation extensions (host modifies guest)
ECX can be changed by:
- a few hundred different instructions (too many to list)
- hardware task switch
- code running in system management mode
- hardware virtualisation extensions (host modifies guest)
Note that hardware task switching is almost never used and is also no longer supported in long mode; and system management mode is normally completely unusable for software (including software running at CPL=0) and it's only really possible for the system's firmware to use it.