Changing Privilege Level

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
pini

Changing Privilege Level

Post by pini »

I tried this :

Code: Select all

call USER_SEL:FUNC
in the kernel code (ring 0) to switch to a CPL 3 function FUNC, but I get this :

Code: Select all

call_protected: cs.rpl > CPL
How can I do to switch between CPLs ??
pini

Re:Changing Privilege Level

Post by pini »

Anyway, I found it : I can make a far call to go to a less CPL and make a return to go to a greater CPL
pini

Re:Changing Privilege Level

Post by pini »

Well, I have some problems to make it work...
I have to use a far return to switch from CPL 0 to CPL 3, so I'm using this code :

Code: Select all

push ss
push esp
push cs
push eip
retf
DS, ES, FS and GS are set to zero by the retf, because of the privilege switching, so I put this before my pushs :

Code: Select all

mov ax,USER_DATA_SELECTOR ; GDT Data CPL 3 entry
mov ds,ax
mov es,ax
mov fs,ax
mov gs,ax
But I get this with bochs :

Code: Select all

exception(): 3rd exception with no resolution
I guess I forgot something, but I can't figure out what...
Post Reply