title: Question about Windows Kernel Object
body: <p>I have got many of my questions solved here, many thanks to you guys. And I'd like to ask one more. :)</p>
  
  <p>I am reading about &lt; Windows via C/C++ >, it said:</p>
  
  <p>When we wnat to gain access to an existing kernel object (rather than create a new one), we must speicify the operations we intend to perform on the object. If we are allowed access with such operations, a handle to the kernel object is returned.</p>
  
  <p>...if the returned handle is used to call an API that requires a right different from you requested for, the access-denied error occurs.</p>
  
  <p>AFAIK, handle is just a plain integer number, it's just an index into the process' handle table, nothing more could the handle value provide. If we have already got a handle to a kernel object, how could the system detect we use it for other operations than we requested for?</p>
  
  <p>A kernel object can have more than one handles, and the owners of these handles may have different access types. Where does the system store these different access type info? I think it should be in the process' handle table.</p>
  
  <p>Suppose I try to open a single kernel object with 2 different access types, 2 handles to the same kernel object should be returned, and thus there'll be 2 entries in the process' handle table, pointing to the same kernel object.</p>
  
  <p>Any insight will be deeply appreciated.</p>
  
  <h2>Update 1</h2>
  
  <p>Thanks guys.</p>
  
  <p>I referred to the &lt; Windows Internals > 5th edition, it said at Ch 6. Access Checks:</p>
  
  <p>The Windows security model requires that a therad speicfy up front, at the time that it opens an object, what types of actions it wants to perfrom on the object. The object manager calls the SRM to perform access checks based on a thread's desired access, and if the access is granted, a handle is assigned to the thread's process with which the thread (or other threads in the process) can perform further operations on the object. As explained in Chapter 3, <strong><em>the object menager records the access permissions granted for a handle in the process's handle table.</em></strong></p>
  
  <p>So it seems my guess is right.</p>
  
  <p>Thanks.</p>