cleaned up some handle code
--HG-- extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%40270
This commit is contained in:
parent
7bbe099cea
commit
ab004f5ce5
@ -20,10 +20,6 @@ static cell_t sm_IsValidHandle(IPluginContext *pContext, const cell_t *params)
|
|||||||
static cell_t sm_CloseHandle(IPluginContext *pContext, const cell_t *params)
|
static cell_t sm_CloseHandle(IPluginContext *pContext, const cell_t *params)
|
||||||
{
|
{
|
||||||
Handle_t hndl = static_cast<Handle_t>(params[1]);
|
Handle_t hndl = static_cast<Handle_t>(params[1]);
|
||||||
|
|
||||||
/* :TODO: make this a little bit cleaner, eh? */
|
|
||||||
IPlugin *pPlugin = g_PluginSys.FindPluginByContext(pContext->GetContext());
|
|
||||||
|
|
||||||
HandleSecurity sec;
|
HandleSecurity sec;
|
||||||
|
|
||||||
sec.pIdentity = NULL;
|
sec.pIdentity = NULL;
|
||||||
@ -45,22 +41,23 @@ static cell_t sm_CloneHandle(IPluginContext *pContext, const cell_t *params)
|
|||||||
{
|
{
|
||||||
Handle_t new_hndl;
|
Handle_t new_hndl;
|
||||||
Handle_t hndl = static_cast<Handle_t>(params[1]);
|
Handle_t hndl = static_cast<Handle_t>(params[1]);
|
||||||
IPlugin *pPlugin;
|
|
||||||
HandleError err;
|
HandleError err;
|
||||||
|
IdentityToken_t *pNewOwner;
|
||||||
|
|
||||||
if (params[2] == 0)
|
if (params[2] == 0)
|
||||||
{
|
{
|
||||||
pPlugin = g_PluginSys.FindPluginByContext(pContext->GetContext());
|
pNewOwner = pContext->GetIdentity();
|
||||||
} else {
|
} else {
|
||||||
Handle_t hPlugin = static_cast<Handle_t>(params[2]);
|
Handle_t hPlugin = static_cast<Handle_t>(params[2]);
|
||||||
pPlugin = g_PluginSys.PluginFromHandle(hPlugin, &err);
|
IPlugin *pPlugin = g_PluginSys.PluginFromHandle(hPlugin, &err);
|
||||||
if (!pPlugin)
|
if (!pPlugin)
|
||||||
{
|
{
|
||||||
return pContext->ThrowNativeError("Plugin handle %x is invalid (error %d)", hndl, err);
|
return pContext->ThrowNativeError("Plugin handle %x is invalid (error %d)", hndl, err);
|
||||||
}
|
}
|
||||||
|
pNewOwner = pPlugin->GetIdentity();
|
||||||
}
|
}
|
||||||
|
|
||||||
err = g_HandleSys.CloneHandle(hndl, &new_hndl, pPlugin->GetIdentity(), NULL);
|
err = g_HandleSys.CloneHandle(hndl, &new_hndl, pNewOwner, NULL);
|
||||||
|
|
||||||
if (err == HandleError_Access)
|
if (err == HandleError_Access)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user