Page 1 of 1

how to get privilege (x86)?

Posted: Sun Sep 16, 2012 9:45 pm
by descent
when a process is running, how to get its privilege?
I want to know now running code is ring0, ring1, ring2 or ring3.
read %cs bit0, bit1 is ok?

Re: how to get privilege (x86)?

Posted: Mon Sep 17, 2012 1:06 am
by Combuster
Read the manual on conforming and non-conforming segments, then for a 32-bit kernel, try SS instead. Then when you're done, get rid of the code because there's absolutely no need to have it.

Re: how to get privilege (x86)?

Posted: Mon Sep 17, 2012 1:44 am
by bluemoon
On some platform there is a simple API for applications:

Code: Select all

bool IsRing3(void) {
  return true;
}
/troll