Handle system can now unload identities safely. when an identity is removed, all handles owned by it are removed in a chain.
--HG-- extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%40288
This commit is contained in:
		
							parent
							
								
									09b01f7950
								
							
						
					
					
						commit
						efd3a8ab5f
					
				| @ -203,10 +203,6 @@ | |||||||
| 				RelativePath="..\sm_autonatives.cpp" | 				RelativePath="..\sm_autonatives.cpp" | ||||||
| 				> | 				> | ||||||
| 			</File> | 			</File> | ||||||
| 			<File |  | ||||||
| 				RelativePath="..\sm_hl2utils.cpp" |  | ||||||
| 				> |  | ||||||
| 			</File> |  | ||||||
| 			<File | 			<File | ||||||
| 				RelativePath="..\sm_memtable.cpp" | 				RelativePath="..\sm_memtable.cpp" | ||||||
| 				> | 				> | ||||||
| @ -396,6 +392,10 @@ | |||||||
| 			<Filter | 			<Filter | ||||||
| 				Name="Interfaces" | 				Name="Interfaces" | ||||||
| 				> | 				> | ||||||
|  | 				<File | ||||||
|  | 					RelativePath="..\interfaces\IExtensionSys.h" | ||||||
|  | 					> | ||||||
|  | 				</File> | ||||||
| 				<File | 				<File | ||||||
| 					RelativePath="..\interfaces\IForwardSys.h" | 					RelativePath="..\interfaces\IForwardSys.h" | ||||||
| 					> | 					> | ||||||
| @ -408,10 +408,6 @@ | |||||||
| 					RelativePath="..\interfaces\ILibrarySys.h" | 					RelativePath="..\interfaces\ILibrarySys.h" | ||||||
| 					> | 					> | ||||||
| 				</File> | 				</File> | ||||||
| 				<File |  | ||||||
| 					RelativePath="..\interfaces\IModuleSys.h" |  | ||||||
| 					> |  | ||||||
| 				</File> |  | ||||||
| 				<File | 				<File | ||||||
| 					RelativePath="..\interfaces\IPluginFunction.h" | 					RelativePath="..\interfaces\IPluginFunction.h" | ||||||
| 					> | 					> | ||||||
|  | |||||||
| @ -30,6 +30,8 @@ inline const char *StatusToStr(PluginStatus st) | |||||||
| 		return "Uncompiled"; | 		return "Uncompiled"; | ||||||
| 	case Plugin_BadLoad: | 	case Plugin_BadLoad: | ||||||
| 		return "Bad Load"; | 		return "Bad Load"; | ||||||
|  | 	case Plugin_Failed: | ||||||
|  | 		return "Failed"; | ||||||
| 	default: | 	default: | ||||||
| 		assert(false); | 		assert(false); | ||||||
| 		return "-"; | 		return "-"; | ||||||
|  | |||||||
| @ -428,26 +428,12 @@ static cell_t sm_WriteFileLine(IPluginContext *pContext, const cell_t *params) | |||||||
| 	return 1; | 	return 1; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| //:TODO: DEBUG CODE HERE
 |  | ||||||
| cell_t PrintStuff(IPluginContext *pContext, const cell_t *params) |  | ||||||
| { |  | ||||||
| 	char *stuff; |  | ||||||
| 	pContext->LocalToString(params[1], &stuff); |  | ||||||
| 
 |  | ||||||
| 	FILE *fp = fopen("c:\\debug.txt", "at"); |  | ||||||
| 	fprintf(fp, "%s\n", stuff); |  | ||||||
| 	fclose(fp); |  | ||||||
| 
 |  | ||||||
| 	return 0; |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| static FileNatives s_FileNatives; | static FileNatives s_FileNatives; | ||||||
| 
 | 
 | ||||||
| REGISTER_NATIVES(filesystem) | REGISTER_NATIVES(filesystem) | ||||||
| { | { | ||||||
| 	{"OpenDirectory",			sm_OpenDirectory}, | 	{"OpenDirectory",			sm_OpenDirectory}, | ||||||
| 	{"ReadDirEntry",			sm_ReadDirEntry}, | 	{"ReadDirEntry",			sm_ReadDirEntry}, | ||||||
| 	{"PrintStuff",				PrintStuff},//:TODO: remove this when no longer needed
 |  | ||||||
| 	{"OpenFile",				sm_OpenFile}, | 	{"OpenFile",				sm_OpenFile}, | ||||||
| 	{"DeleteFile",				sm_DeleteFile}, | 	{"DeleteFile",				sm_DeleteFile}, | ||||||
| 	{"ReadFileLine",			sm_ReadFileLine}, | 	{"ReadFileLine",			sm_ReadFileLine}, | ||||||
|  | |||||||
| @ -231,7 +231,8 @@ HandleError HandleSystem::MakePrimHandle(HandleType_t type, | |||||||
| 						   QHandle **in_pHandle,  | 						   QHandle **in_pHandle,  | ||||||
| 						   unsigned int *in_index,  | 						   unsigned int *in_index,  | ||||||
| 						   Handle_t *in_handle, | 						   Handle_t *in_handle, | ||||||
| 						   IdentityToken_t *owner) | 						   IdentityToken_t *owner, | ||||||
|  | 						   bool identity) | ||||||
| { | { | ||||||
| 	unsigned int owner_index = 0; | 	unsigned int owner_index = 0; | ||||||
| 
 | 
 | ||||||
| @ -262,7 +263,7 @@ HandleError HandleSystem::MakePrimHandle(HandleType_t type, | |||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	/* Set essential information */ | 	/* Set essential information */ | ||||||
| 	pHandle->set = HandleSet_Used;; | 	pHandle->set = identity ? HandleSet_Identity : HandleSet_Used; | ||||||
| 	pHandle->refcount = 1; | 	pHandle->refcount = 1; | ||||||
| 	pHandle->type = type; | 	pHandle->type = type; | ||||||
| 	pHandle->serial = m_HSerial; | 	pHandle->serial = m_HSerial; | ||||||
| @ -282,8 +283,10 @@ HandleError HandleSystem::MakePrimHandle(HandleType_t type, | |||||||
| 	*in_index = handle; | 	*in_index = handle; | ||||||
| 	*in_handle = hash; | 	*in_handle = hash; | ||||||
| 
 | 
 | ||||||
| 	/* Decode the identity token */ | 	/* Decode the identity token 
 | ||||||
| 	if (owner) | 	 * For now, we don't allow nested ownership | ||||||
|  | 	 */ | ||||||
|  | 	if (owner && !identity) | ||||||
| 	{ | 	{ | ||||||
| 		QHandle *pIdentity = &m_Handles[owner_index]; | 		QHandle *pIdentity = &m_Handles[owner_index]; | ||||||
| 		if (pIdentity->ch_prev == 0) | 		if (pIdentity->ch_prev == 0) | ||||||
| @ -319,7 +322,7 @@ void HandleSystem::SetTypeSecurityOwner(HandleType_t type, IdentityToken_t *pTok | |||||||
| 	m_Types[type].typeSec.ident = pToken; | 	m_Types[type].typeSec.ident = pToken; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| Handle_t HandleSystem::CreateHandle(HandleType_t type, void *object, IdentityToken_t *owner, IdentityToken_t *ident, HandleError *err) | Handle_t HandleSystem::CreateHandleEx(HandleType_t type, void *object, IdentityToken_t *owner, IdentityToken_t *ident, HandleError *err, bool identity) | ||||||
| { | { | ||||||
| 	if (!type  | 	if (!type  | ||||||
| 		|| type >= HANDLESYS_TYPEARRAY_SIZE | 		|| type >= HANDLESYS_TYPEARRAY_SIZE | ||||||
| @ -350,7 +353,7 @@ Handle_t HandleSystem::CreateHandle(HandleType_t type, void *object, IdentityTok | |||||||
| 	QHandle *pHandle; | 	QHandle *pHandle; | ||||||
| 	HandleError _err; | 	HandleError _err; | ||||||
| 
 | 
 | ||||||
| 	if ((_err=MakePrimHandle(type, &pHandle, &index, &handle, owner)) != HandleError_None) | 	if ((_err=MakePrimHandle(type, &pHandle, &index, &handle, owner, identity)) != HandleError_None) | ||||||
| 	{ | 	{ | ||||||
| 		if (err) | 		if (err) | ||||||
| 		{ | 		{ | ||||||
| @ -365,6 +368,11 @@ Handle_t HandleSystem::CreateHandle(HandleType_t type, void *object, IdentityTok | |||||||
| 	return handle; | 	return handle; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | Handle_t HandleSystem::CreateHandle(HandleType_t type, void *object, IdentityToken_t *owner, IdentityToken_t *ident, HandleError *err) | ||||||
|  | { | ||||||
|  | 	return CreateHandleEx(type, object, owner, ident, err, false); | ||||||
|  | } | ||||||
|  | 
 | ||||||
| bool HandleSystem::TypeCheck(HandleType_t intype, HandleType_t outtype) | bool HandleSystem::TypeCheck(HandleType_t intype, HandleType_t outtype) | ||||||
| { | { | ||||||
| 	/* Check the type inheritance */ | 	/* Check the type inheritance */ | ||||||
| @ -453,6 +461,27 @@ bool HandleSystem::CheckAccess(QHandle *pHandle, HandleAccessRight right, const | |||||||
| 	return true; | 	return true; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | HandleError HandleSystem::CloneHandle(QHandle *pHandle, unsigned int index, Handle_t *newhandle, IdentityToken_t *newOwner) | ||||||
|  | { | ||||||
|  | 	/* Get a new Handle ID */ | ||||||
|  | 	unsigned int new_index; | ||||||
|  | 	QHandle *pNewHandle; | ||||||
|  | 	Handle_t new_handle; | ||||||
|  | 	HandleError err; | ||||||
|  | 
 | ||||||
|  | 	if ((err=MakePrimHandle(pHandle->type, &pNewHandle, &new_index, &new_handle, newOwner)) != HandleError_None) | ||||||
|  | 	{ | ||||||
|  | 		return err; | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	pNewHandle->clone = index; | ||||||
|  | 	pHandle->refcount++; | ||||||
|  | 
 | ||||||
|  | 	*newhandle = new_handle; | ||||||
|  | 
 | ||||||
|  | 	return HandleError_None; | ||||||
|  | } | ||||||
|  | 
 | ||||||
| HandleError HandleSystem::CloneHandle(Handle_t handle, Handle_t *newhandle, IdentityToken_t *newOwner, const HandleSecurity *pSecurity) | HandleError HandleSystem::CloneHandle(Handle_t handle, Handle_t *newhandle, IdentityToken_t *newOwner, const HandleSecurity *pSecurity) | ||||||
| { | { | ||||||
| 	HandleError err; | 	HandleError err; | ||||||
| @ -477,44 +506,20 @@ HandleError HandleSystem::CloneHandle(Handle_t handle, Handle_t *newhandle, Iden | |||||||
| 		return HandleError_Access; | 		return HandleError_Access; | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	/* Get a new Handle ID */ | 	/* Make sure we're not cloning a clone */ | ||||||
| 	unsigned int new_index; | 	if (pHandle->clone) | ||||||
| 	QHandle *pNewHandle; |  | ||||||
| 	Handle_t new_handle; |  | ||||||
| 
 |  | ||||||
| 	if ((err=MakePrimHandle(pHandle->type, &pNewHandle, &new_index, &new_handle, newOwner)) != HandleError_None) |  | ||||||
| 	{ | 	{ | ||||||
| 		return err; | 		QHandle *pParent = &m_Handles[pHandle->clone]; | ||||||
|  | 		return CloneHandle(pParent, pHandle->clone, newhandle, newOwner); | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	pNewHandle->clone = index; | 	return CloneHandle(pHandle, index, newhandle, newOwner); | ||||||
| 	pHandle->refcount++; |  | ||||||
| 
 |  | ||||||
| 	*newhandle = new_handle; |  | ||||||
| 
 |  | ||||||
| 	return HandleError_None; |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| HandleError HandleSystem::FreeHandle(Handle_t handle, const HandleSecurity *pSecurity) | HandleError HandleSystem::FreeHandle(QHandle *pHandle, unsigned int index) | ||||||
| { | { | ||||||
| 	unsigned int index; |  | ||||||
| 	QHandle *pHandle; |  | ||||||
| 	HandleError err; |  | ||||||
| 	IdentityToken_t *ident = pSecurity ? pSecurity->pIdentity : NULL; |  | ||||||
| 
 |  | ||||||
| 	if ((err=GetHandle(handle, ident, &pHandle, &index)) != HandleError_None) |  | ||||||
| 	{ |  | ||||||
| 		return err; |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| 	if (!CheckAccess(pHandle, HandleAccess_Delete, pSecurity)) |  | ||||||
| 	{ |  | ||||||
| 		return HandleError_Access; |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| 	QHandleType *pType = &m_Types[pHandle->type]; | 	QHandleType *pType = &m_Types[pHandle->type]; | ||||||
| 
 | 
 | ||||||
| 	bool dofree = false; |  | ||||||
| 	if (pHandle->clone) | 	if (pHandle->clone) | ||||||
| 	{ | 	{ | ||||||
| 		/* If we're a clone, decrease the parent reference count */ | 		/* If we're a clone, decrease the parent reference count */ | ||||||
| @ -537,6 +542,11 @@ HandleError HandleSystem::FreeHandle(Handle_t handle, const HandleSecurity *pSec | |||||||
| 			pType->dispatch->OnHandleDestroy(pMaster->type, pMaster->object); | 			pType->dispatch->OnHandleDestroy(pMaster->type, pMaster->object); | ||||||
| 			ReleasePrimHandle(master); | 			ReleasePrimHandle(master); | ||||||
| 		} | 		} | ||||||
|  | 	} else if (pHandle->set == HandleSet_Identity) { | ||||||
|  | 		/* If we're an identity, skip all this stuff!
 | ||||||
|  | 		 * NOTE: SHARESYS DOES NOT CARE ABOUT THE DESTRUCTOR | ||||||
|  | 		 */ | ||||||
|  | 		ReleasePrimHandle(index); | ||||||
| 	} else { | 	} else { | ||||||
| 		/* Decrement, free if necessary */ | 		/* Decrement, free if necessary */ | ||||||
| 		if (--pHandle->refcount == 0) | 		if (--pHandle->refcount == 0) | ||||||
| @ -546,12 +556,37 @@ HandleError HandleSystem::FreeHandle(Handle_t handle, const HandleSecurity *pSec | |||||||
| 		} else { | 		} else { | ||||||
| 			/* We must be cloned, so mark ourselves as freed */ | 			/* We must be cloned, so mark ourselves as freed */ | ||||||
| 			pHandle->set = HandleSet_Freed; | 			pHandle->set = HandleSet_Freed; | ||||||
|  | 			/* Now, unlink us, so we're not being tracked by the owner */ | ||||||
|  | 			if (pHandle->owner) | ||||||
|  | 			{ | ||||||
|  | 				UnlinkHandleFromOwner(pHandle, index); | ||||||
|  | 			} | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	return HandleError_None; | 	return HandleError_None; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | HandleError HandleSystem::FreeHandle(Handle_t handle, const HandleSecurity *pSecurity) | ||||||
|  | { | ||||||
|  | 	unsigned int index; | ||||||
|  | 	QHandle *pHandle; | ||||||
|  | 	HandleError err; | ||||||
|  | 	IdentityToken_t *ident = pSecurity ? pSecurity->pIdentity : NULL; | ||||||
|  | 
 | ||||||
|  | 	if ((err=GetHandle(handle, ident, &pHandle, &index)) != HandleError_None) | ||||||
|  | 	{ | ||||||
|  | 		return err; | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	if (!CheckAccess(pHandle, HandleAccess_Delete, pSecurity)) | ||||||
|  | 	{ | ||||||
|  | 		return HandleError_Access; | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	return FreeHandle(pHandle, index); | ||||||
|  | } | ||||||
|  | 
 | ||||||
| HandleError HandleSystem::ReadHandle(Handle_t handle, HandleType_t type, const HandleSecurity *pSecurity, void **object) | HandleError HandleSystem::ReadHandle(Handle_t handle, HandleType_t type, const HandleSecurity *pSecurity, void **object) | ||||||
| { | { | ||||||
| 	unsigned int index; | 	unsigned int index; | ||||||
| @ -597,17 +632,9 @@ HandleError HandleSystem::ReadHandle(Handle_t handle, HandleType_t type, const H | |||||||
| 	return HandleError_None; | 	return HandleError_None; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void HandleSystem::ReleasePrimHandle(unsigned int index) | void HandleSystem::UnlinkHandleFromOwner(QHandle *pHandle, unsigned int index) | ||||||
| { | { | ||||||
| 	QHandle *pHandle = &m_Handles[index]; |  | ||||||
| 	 |  | ||||||
| 	pHandle->set = HandleSet_None; |  | ||||||
| 	m_Types[pHandle->type].opened--; |  | ||||||
| 	m_Handles[++m_FreeHandles].freeID = index; |  | ||||||
| 
 |  | ||||||
| 	/* Unlink us if necessary */ | 	/* Unlink us if necessary */ | ||||||
| 	if (pHandle->owner) |  | ||||||
| 	{ |  | ||||||
| 	unsigned int ident_index; | 	unsigned int ident_index; | ||||||
| 	if (IdentityHandle(pHandle->owner, &ident_index) != HandleError_None) | 	if (IdentityHandle(pHandle->owner, &ident_index) != HandleError_None) | ||||||
| 	{ | 	{ | ||||||
| @ -650,7 +677,39 @@ void HandleSystem::ReleasePrimHandle(unsigned int index) | |||||||
| 
 | 
 | ||||||
| 	/* Lastly, decrease the reference count */ | 	/* Lastly, decrease the reference count */ | ||||||
| 	pIdentity->refcount--; | 	pIdentity->refcount--; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | void HandleSystem::ReleasePrimHandle(unsigned int index) | ||||||
|  | { | ||||||
|  | 	QHandle *pHandle = &m_Handles[index]; | ||||||
|  | 	HandleSet set = pHandle->set; | ||||||
|  | 
 | ||||||
|  | 	if (pHandle->owner && (set != HandleSet_Identity)) | ||||||
|  | 	{ | ||||||
|  | 		UnlinkHandleFromOwner(pHandle, index); | ||||||
| 	} | 	} | ||||||
|  | 
 | ||||||
|  | 	/* Were we an identity ourself? */ | ||||||
|  | 	QHandle *pLocal; | ||||||
|  | 	if (set == HandleSet_Identity) | ||||||
|  | 	{ | ||||||
|  | 		/* Extra work to do.  We need to find everything connected to this identity and release it. */ | ||||||
|  | 		unsigned int ch_index, old_index = 0; | ||||||
|  | 		while ((ch_index = pHandle->ch_next) != 0) | ||||||
|  | 		{ | ||||||
|  | 			pLocal = &m_Handles[ch_index]; | ||||||
|  | #if defined _DEBUG | ||||||
|  | 			assert(old_index != ch_index); | ||||||
|  | 			assert(pLocal->set == HandleSet_Used); | ||||||
|  | 			old_index = ch_index; | ||||||
|  | #endif | ||||||
|  | 			FreeHandle(pLocal, ch_index); | ||||||
|  | 		} | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	pHandle->set = HandleSet_None; | ||||||
|  | 	m_Types[pHandle->type].opened--; | ||||||
|  | 	m_Handles[++m_FreeHandles].freeID = index; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| bool HandleSystem::RemoveType(HandleType_t type, IdentityToken_t *ident) | bool HandleSystem::RemoveType(HandleType_t type, IdentityToken_t *ident) | ||||||
| @ -737,19 +796,6 @@ bool HandleSystem::RemoveType(HandleType_t type, IdentityToken_t *ident) | |||||||
| 	return true; | 	return true; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void HandleSystem::MarkHandleAsIdentity(Handle_t handle) |  | ||||||
| { |  | ||||||
| 	QHandle *pHandle; |  | ||||||
| 	unsigned int index; |  | ||||||
| 
 |  | ||||||
| 	if (GetHandle(handle, g_ShareSys.GetIdentRoot(), &pHandle, &index) != HandleError_None) |  | ||||||
| 	{ |  | ||||||
| 		return; |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| 	pHandle->set = HandleSet_Identity; |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| bool HandleSystem::InitAccessDefaults(TypeAccess *pTypeAccess, HandleAccess *pHandleAccess) | bool HandleSystem::InitAccessDefaults(TypeAccess *pTypeAccess, HandleAccess *pHandleAccess) | ||||||
| { | { | ||||||
| 	if (pTypeAccess) | 	if (pTypeAccess) | ||||||
|  | |||||||
| @ -55,8 +55,8 @@ struct QHandle | |||||||
| 	unsigned int freeID;		/* ID of a free handle in the free handle chain */ | 	unsigned int freeID;		/* ID of a free handle in the free handle chain */ | ||||||
| 	/* Indexes into the handle array for owner membership.
 | 	/* Indexes into the handle array for owner membership.
 | ||||||
| 	 * For identity roots, these are treated as the head/tail. */ | 	 * For identity roots, these are treated as the head/tail. */ | ||||||
| 	unsigned int ch_prev;		/* chained previous handle or HEAD */ | 	unsigned int ch_prev;		/* chained previous handle */ | ||||||
| 	unsigned int ch_next;		/* chained next handle or TAIL */ | 	unsigned int ch_next;		/* chained next handle */ | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| struct QHandleType | struct QHandleType | ||||||
| @ -97,6 +97,7 @@ public: //IHandleSystem | |||||||
| 		IdentityToken_t *owner, | 		IdentityToken_t *owner, | ||||||
| 		IdentityToken_t *ident, | 		IdentityToken_t *ident, | ||||||
| 		HandleError *err); | 		HandleError *err); | ||||||
|  | 
 | ||||||
| 	HandleError FreeHandle(Handle_t handle, const HandleSecurity *pSecurity); | 	HandleError FreeHandle(Handle_t handle, const HandleSecurity *pSecurity); | ||||||
| 
 | 
 | ||||||
| 	HandleError CloneHandle(Handle_t handle,  | 	HandleError CloneHandle(Handle_t handle,  | ||||||
| @ -130,26 +131,33 @@ protected: | |||||||
| 							   QHandle **pHandle,  | 							   QHandle **pHandle,  | ||||||
| 							   unsigned int *index,  | 							   unsigned int *index,  | ||||||
| 							   HandleType_t *handle, | 							   HandleType_t *handle, | ||||||
| 							   IdentityToken_t *owner); | 							   IdentityToken_t *owner, | ||||||
|  | 							   bool identity=false); | ||||||
| 
 | 
 | ||||||
| 	/**
 | 	/**
 | ||||||
| 	 * Frees a primitive handle.  Does no object freeing, only reference count, bookkeepping,  | 	 * Frees a primitive handle.  Does no object freeing, only reference count, bookkeepping,  | ||||||
| 	 * and linked list maintenance. | 	 * and linked list maintenance. | ||||||
|  | 	 * If used on an Identity handle, destroys all Handles under that identity. | ||||||
| 	 */ | 	 */ | ||||||
| 	void ReleasePrimHandle(unsigned int index); | 	void ReleasePrimHandle(unsigned int index); | ||||||
| 
 | 
 | ||||||
| 	/**
 | 	/**
 | ||||||
| 	 * Sets the security owner of a type | 	 * Sets the security owner of a type. | ||||||
| 	 */ | 	 */ | ||||||
| 	void SetTypeSecurityOwner(HandleType_t type, IdentityToken_t *pToken); | 	void SetTypeSecurityOwner(HandleType_t type, IdentityToken_t *pToken); | ||||||
| 
 | 
 | ||||||
| 	/**
 | 	/**
 | ||||||
| 	 * Marks a handle as an identity. | 	 * Helper function to check access rights. | ||||||
| 	 * This prevents it from being tampered with by outside stuff |  | ||||||
| 	 */ | 	 */ | ||||||
| 	void MarkHandleAsIdentity(Handle_t handle); |  | ||||||
| 
 |  | ||||||
| 	bool CheckAccess(QHandle *pHandle, HandleAccessRight right, const HandleSecurity *pSecurity); | 	bool CheckAccess(QHandle *pHandle, HandleAccessRight right, const HandleSecurity *pSecurity); | ||||||
|  | 
 | ||||||
|  | 	/** 
 | ||||||
|  | 	 * Some wrappers for internal functions, so we can pass indexes instead of encoded handles. | ||||||
|  | 	 */ | ||||||
|  | 	HandleError FreeHandle(QHandle *pHandle, unsigned int index); | ||||||
|  | 	void UnlinkHandleFromOwner(QHandle *pHandle, unsigned int index); | ||||||
|  | 	HandleError CloneHandle(QHandle *pHandle, unsigned int index, Handle_t *newhandle, IdentityToken_t *newOwner); | ||||||
|  | 	Handle_t CreateHandleEx(HandleType_t type, void *object, IdentityToken_t *owner, IdentityToken_t *ident, HandleError *err, bool identity); | ||||||
| private: | private: | ||||||
| 	QHandle *m_Handles; | 	QHandle *m_Handles; | ||||||
| 	QHandleType *m_Types; | 	QHandleType *m_Types; | ||||||
|  | |||||||
| @ -73,7 +73,7 @@ IdentityType_t ShareSystem::CreateIdentType(const char *name) | |||||||
| 
 | 
 | ||||||
| void ShareSystem::OnHandleDestroy(HandleType_t type, void *object) | void ShareSystem::OnHandleDestroy(HandleType_t type, void *object) | ||||||
| { | { | ||||||
| 	/* We don't care here */ | 	/* THIS WILL NEVER BE CALLED FOR ANYTHING WITH THE IDENTITY TYPE */ | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| IdentityToken_t *ShareSystem::CreateIdentity(IdentityType_t type) | IdentityToken_t *ShareSystem::CreateIdentity(IdentityType_t type) | ||||||
| @ -85,7 +85,7 @@ IdentityToken_t *ShareSystem::CreateIdentity(IdentityType_t type) | |||||||
| 
 | 
 | ||||||
| 	/* :TODO: Cache? */ | 	/* :TODO: Cache? */ | ||||||
| 	IdentityToken_t *pToken = new IdentityToken_t; | 	IdentityToken_t *pToken = new IdentityToken_t; | ||||||
| 	pToken->ident = g_HandleSys.CreateHandle(type, NULL, GetIdentRoot(), GetIdentRoot(), NULL); | 	pToken->ident = g_HandleSys.CreateHandleEx(type, NULL, GetIdentRoot(), GetIdentRoot(), NULL, true); | ||||||
| 
 | 
 | ||||||
| 	return pToken; | 	return pToken; | ||||||
| } | } | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user