* Create the ACCESS_STATE structure much earlier.
* Actually send the access state and parse context to ObFindObject, when called from ObInsertObject (this should fix some hidden regressions, since they finally get an access state with access masks now).
* Remove some deprecated hacks.
* If inserting the handle failed, cleanup the name and remove it from the directory entry.
* Fix a memory leak because we weren't deleting the access state.
svn path=/trunk/; revision=22278
- Minor/trivial fixes to some Object Security APIs that were left in the dark:
* Use PagedPool instead of NonPagedPool memory, and also tag the allocation for debugging.
* Send needed data to the security procedure instead of NULL/0, including the Generic Mapping, and the actual Security Decriptor.
* Only un-assign the descriptor in case of failure, not all the time (the whole point of the API is to assign it!)
* Tell the caller that memory was NOT allocated if we failed to get the security descriptor.
svn path=/trunk/; revision=22277
- Because of the split, we can now directly only do an Increment when duplicating the handle, since we don't need to create a brand new one. Also, when inheriting, we can now properly do an increment as well, instead of simply manually increasing the handle count (because for each inherited handle, access checks and openprocedure should've still been called).
svn path=/trunk/; revision=22276
* Honour ObjectType passed to the function and fail if it doesn't match.
* Use table-based logic instead of process-based logic for Kernel vs User-mode handles (same change that's been done all over the place, since it requires only one dereference of the process object).
* Do the GENERIC/MAXIMUM_ALLOWED logic directly inside the ACCESS_STATE structure.
* This is where we should call the OpenProcedure (acc. to Gl00my), but this kills win32k -- investigate, #ifed out for now.
* Increase the object type's number of handles as well.
* Set the handle table entry's ObAttributes correctly; the old code seems to have been messing that up.
* Honour the AdditionalReferences parameter and do referencing bias if requested.
* Honour the ReturnedObject parameter to return the object pointer back to the caller.
* Add OBTRACEing to the function.
* If we failed because a handle couldn't be allocated, use the distinguied STATUS_INSUFFICIENT_RESOURCES error code instead of the generic STATUS_UNSCUCESFFUL, and backout all the changes we made by calling ObpDecrementHandleCount.
svn path=/trunk/; revision=22267
- Change ObpCreateHandle to use an ACCESS_STATE structure instead of DesiredAccess. This is to help moving to an updated model where creating and incrementing a handle are 2 operations, so that code can be refactored (similarly to how we now have Delete/Decrement as 2 operations).
- Fix functions that were not creating an ACCESS_STATE Structure to create one locally now, or use the one passed as a parameter, if available.
svn path=/trunk/; revision=22265
- Make ObpCreateHandle internal to Ob as it should be. Change NtCreateProcessTokenEx to use ObOpenObjectByPointer, it has no business manually trying to create a handle. Same goes for ExpLoadInitialProcess.
svn path=/trunk/; revision=22264
- Make ObpCreateHandleTable return NTSTATUS instead of VOID, so that it can return STATUS_INSUFFIENT_RESOURCES if the handle table couldn't be allocated.
svn path=/trunk/; revision=22249
- Call the OkayToClose Procedure, if one is present, to allow the object owner a chance to disallow closing this handle. I believe this is required for properly protecting Winsta/Desktop handles (instead of using the regular protection mode, since that one can be bypassed). Thomas, get to work!
svn path=/trunk/; revision=22246
- Added function documentation header for ObpDecrementHandleCount and ObpSetHandleAttributes
- Modified ObpDecrementHandleCount to accept Process and GrantedAccess paraemters since the definition for the Close Procedure Callback requires them (and we were currently sending NULL). Also send 0 for process handle count, since we don't yet parse/support per-process handle databases.
- Minor optimization: All objects have an object type, don't actually check if the object has one when decrementing a handle.
- Minor accounting fix: Decrement the total number of handles for the object type whose handle count is being decreased.
svn path=/trunk/; revision=22245
- Make sure callers of NtMakePermanentObject have SeCreatePermanentPrivilege.
- Implement ObpDeleteNameCheck as described in Gl00my's Ob Documentation (using such documentation falls under US Reverse Engineering Law - Clean rooming).
- Remove duplicated code in ObpDecrementHandleCount and ObpSetPermanentObject and have them use ObpDeleteNameCheck instead.
- Fixes thanks to using this routine:
* Name-check is now properly done.
* The keep-alive reference is now deleted when going from permanent->temporary object.
* The parent directory is now dereferenced and cleared when deleting the object.
* The security procedure is now called to delete the SD, and the name buffer is freed.
- Remove ObGetObjectHandleCount, it's not a public function.
svn path=/trunk/; revision=22244
- Added stub exports for ObCloseHandle, ObReferenceSecurityDesciptor, ObSetHandleAttributes, ObSetSecurityObjectByPointer so that someday someone can know what needs to be implemented.
- Removed ObGetObjectPointerCount. It is not exported in newer OSes and was always undocumented.
- Move ObQueryObjecctAuditingByHandle to security.c and optimized it not to attach to the system process, as well as to cache the handle table instead of dereferencing the owner process all the time.
svn path=/trunk/; revision=22232
- Bug fixes:
* Remove MAXIMUM_ALLOWED<->GENERIC_ALL conversion, I could find no mention of this in the docs.
* Remove GENERIC_ACCESS <-> RtlMapGenericMask conversion, I could find no mention of this in the docs, and this mapping is only required when creating handles, not when referencing pointers.
- Optimizations:
* Restructure code and remove code which was sometimes duplicated up to 5 times.
* Do not attach/detach from the system process, this isn't required since we're merely getting a kernel pointer from the handle netry.
* Directly increase the pointer count instead of calling ObReferenceObject, since we already have the object header in a variable.
* Cache ObpKernelHandleTable/Process->ObjectTable and use those directly instead of always de-referencing the process.
svn path=/trunk/; revision=22231
- Fix ObReferenceObjectByPointer to actually work like documented instead of doing random incorrect checks. Also add special case for Symbolic Link objects as documented by Caz Yokoyama at Microsoft.
svn path=/trunk/; revision=22230
- Re-implement NtSetInformationObject based on ExChangeHandle and using ObpSetHandleAttributes as a callback.
- Re-implement NtQueryObject's ObjectHandleInformation case to simply return the information that's already in HandleAttributes; there is no point in querying for it all over again.
- Fix NtSetInformationObject not to allow a user-mode call to modify kernel-mdoe handle attributes. Add FIXME for Inheritance permissions check.
- Fix NtQueryObject to properly return OBJ_PERMANENT and OBJ_EXCLUSIVE; these flags are not stored in Handle Attributes.
- Fix NtQueryObject not to attempt referencing the handle if the caller specified AllTypesInformation, because then a handle is not needed.
svn path=/trunk/; revision=22228