how to get privilege (x86)?

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
descent
Posts: 10
Joined: Wed Sep 05, 2012 1:25 am
Location: Taiwan

how to get privilege (x86)?

Post 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?
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: how to get privilege (x86)?

Post 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.
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
User avatar
bluemoon
Member
Member
Posts: 1761
Joined: Wed Dec 01, 2010 3:41 am
Location: Hong Kong

Re: how to get privilege (x86)?

Post by bluemoon »

On some platform there is a simple API for applications:

Code: Select all

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