Fix string_t return hook, Fix GetHandleIfValidOrError checking only for g_HookSetupHandle
This commit is contained in:
parent
caccb5a0ff
commit
0a051ab32e
@ -26,7 +26,7 @@ bool GetHandleIfValidOrError(HandleType_t type, void **object, IPluginContext *p
|
|||||||
HandleError err;
|
HandleError err;
|
||||||
HandleSecurity sec(pContext->GetIdentity(), myself->GetIdentity());
|
HandleSecurity sec(pContext->GetIdentity(), myself->GetIdentity());
|
||||||
|
|
||||||
if((err = handlesys->ReadHandle(param, g_HookSetupHandle, &sec, object)) != HandleError_None)
|
if((err = handlesys->ReadHandle(param, type, &sec, object)) != HandleError_None)
|
||||||
{
|
{
|
||||||
return pContext->ThrowNativeError("Invalid Handle %x (error %d)", param, err) != 0;
|
return pContext->ThrowNativeError("Invalid Handle %x (error %d)", param, err) != 0;
|
||||||
}
|
}
|
||||||
|
36
vhook.cpp
36
vhook.cpp
@ -45,13 +45,17 @@ DHooksManager::DHooksManager(HookSetup *setup, void *iface, IPluginFunction *rem
|
|||||||
{
|
{
|
||||||
protoInfo.SetReturnType(0, SourceHook::PassInfo::PassType_Unknown, 0, NULL, NULL, NULL, NULL);
|
protoInfo.SetReturnType(0, SourceHook::PassInfo::PassType_Unknown, 0, NULL, NULL, NULL, NULL);
|
||||||
}
|
}
|
||||||
else if(this->callback->returnType != ReturnType_Float)
|
else if(this->callback->returnType == ReturnType_Float)
|
||||||
{
|
{
|
||||||
protoInfo.SetReturnType(sizeof(void *), SourceHook::PassInfo::PassType_Basic, setup->returnFlag, NULL, NULL, NULL, NULL);
|
protoInfo.SetReturnType(sizeof(void *), SourceHook::PassInfo::PassType_Float, setup->returnFlag, NULL, NULL, NULL, NULL);
|
||||||
|
}
|
||||||
|
else if(this->callback->returnType == ReturnType_String)
|
||||||
|
{
|
||||||
|
protoInfo.SetReturnType(sizeof(void *), SourceHook::PassInfo::PassType_Object, setup->returnFlag, NULL, NULL, NULL, NULL);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
protoInfo.SetReturnType(sizeof(void *), SourceHook::PassInfo::PassType_Float, setup->returnFlag, NULL, NULL, NULL, NULL);
|
protoInfo.SetReturnType(sizeof(void *), SourceHook::PassInfo::PassType_Basic, setup->returnFlag, NULL, NULL, NULL, NULL);
|
||||||
}
|
}
|
||||||
HookManagerPubFunc hook = g_pHookManager->MakeHookMan(protoInfo, 0, this->callback->offset);
|
HookManagerPubFunc hook = g_pHookManager->MakeHookMan(protoInfo, 0, this->callback->offset);
|
||||||
|
|
||||||
@ -135,7 +139,7 @@ HookReturnStruct *GetReturnStruct(DHooksCallback *dg, const void *result)
|
|||||||
switch(dg->returnType)
|
switch(dg->returnType)
|
||||||
{
|
{
|
||||||
case ReturnType_String:
|
case ReturnType_String:
|
||||||
*(string_t *)res->orgResult = *(string_t *)res->orgResult;
|
*(string_t *)res->orgResult = *(string_t *)result;
|
||||||
break;
|
break;
|
||||||
//ReturnType_Vector,
|
//ReturnType_Vector,
|
||||||
case ReturnType_Int:
|
case ReturnType_Int:
|
||||||
@ -290,9 +294,9 @@ void *Callback(DHooksCallback *dg, void **argStack)
|
|||||||
if(dg->returnType != ReturnType_Void)
|
if(dg->returnType != ReturnType_Void)
|
||||||
{
|
{
|
||||||
if(returnStruct->isChanged)
|
if(returnStruct->isChanged)
|
||||||
{
|
{
|
||||||
g_SHPtr->SetRes(MRES_OVERRIDE);
|
g_SHPtr->SetRes(MRES_OVERRIDE);
|
||||||
mres = MRES_OVERRIDE;
|
mres = MRES_OVERRIDE;
|
||||||
ret = *(void **)returnStruct->newResult;
|
ret = *(void **)returnStruct->newResult;
|
||||||
}
|
}
|
||||||
else //Throw an error if no override was set
|
else //Throw an error if no override was set
|
||||||
@ -307,9 +311,9 @@ void *Callback(DHooksCallback *dg, void **argStack)
|
|||||||
if(dg->returnType != ReturnType_Void)
|
if(dg->returnType != ReturnType_Void)
|
||||||
{
|
{
|
||||||
if(returnStruct->isChanged)
|
if(returnStruct->isChanged)
|
||||||
{
|
{
|
||||||
g_SHPtr->SetRes(MRES_SUPERCEDE);
|
g_SHPtr->SetRes(MRES_SUPERCEDE);
|
||||||
mres = MRES_SUPERCEDE;
|
mres = MRES_SUPERCEDE;
|
||||||
ret = *(void **)returnStruct->newResult;
|
ret = *(void **)returnStruct->newResult;
|
||||||
}
|
}
|
||||||
else //Throw an error if no override was set
|
else //Throw an error if no override was set
|
||||||
@ -444,9 +448,9 @@ void *Callback_float(DHooksCallback *dg, void **argStack)
|
|||||||
if(dg->returnType != ReturnType_Void)
|
if(dg->returnType != ReturnType_Void)
|
||||||
{
|
{
|
||||||
if(returnStruct->isChanged)
|
if(returnStruct->isChanged)
|
||||||
{
|
{
|
||||||
g_SHPtr->SetRes(MRES_OVERRIDE);
|
g_SHPtr->SetRes(MRES_OVERRIDE);
|
||||||
mres = MRES_OVERRIDE;
|
mres = MRES_OVERRIDE;
|
||||||
*(float *)ret = *(float *)returnStruct->newResult;
|
*(float *)ret = *(float *)returnStruct->newResult;
|
||||||
}
|
}
|
||||||
else //Throw an error if no override was set
|
else //Throw an error if no override was set
|
||||||
@ -461,9 +465,9 @@ void *Callback_float(DHooksCallback *dg, void **argStack)
|
|||||||
if(dg->returnType != ReturnType_Void)
|
if(dg->returnType != ReturnType_Void)
|
||||||
{
|
{
|
||||||
if(returnStruct->isChanged)
|
if(returnStruct->isChanged)
|
||||||
{
|
{
|
||||||
g_SHPtr->SetRes(MRES_SUPERCEDE);
|
g_SHPtr->SetRes(MRES_SUPERCEDE);
|
||||||
mres = MRES_SUPERCEDE;
|
mres = MRES_SUPERCEDE;
|
||||||
*(float *)ret = *(float *)returnStruct->newResult;
|
*(float *)ret = *(float *)returnStruct->newResult;
|
||||||
}
|
}
|
||||||
else //Throw an error if no override was set
|
else //Throw an error if no override was set
|
||||||
|
Loading…
Reference in New Issue
Block a user