Raised This Month: $ Target: $400
 0% 

Problem with hooked fuction


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
Misterrr
New Member
Join Date: Jan 2017
Old 06-29-2017 , 08:19   Problem with hooked fuction
Reply With Quote #1

Hello! I'm studying the possibilities of Metamod, and I was wondering if it was possible to intercept the call of the function IBaseFileSystem::Open and call it with another parameter? I was trying to do this:
PHP Code:
SH_DECL_HOOK3(IBaseFileSystemOpenSH_NOATTRIB0FileHandle_t,  const char *, const char *, const char *); 
I announced this
PHP Code:
IBaseFileSystem *basefilesystem NULL;
GET_V_IFACE_CURRENT(GetFileSystemFactorybasefilesystemIBaseFileSystemBASEFILESYSTEM_INTERFACE_VERSION); 
and add hook
PHP Code:
OpenHook SH_ADD_VPHOOK(IBaseFileSystemOpenbasefilesystemSH_MEMBER(this, &SamplePlugin::Hook_Open), false); 
I tried to do so
PHP Code:
FileHandle_t SamplePlugin::Hook_Open(const char *pFileName, const char *pOptions, const char *pathID) {
   if(
strncmp(pFileName"materials/headshot1.vtf"strlen("materials/headshot1.vtf")) == 0) {
         
META_LOG(g_PLAPI"yeaaa opening headshot file \"%s\",pOptions \"%s\",pathID \"%s\"."pFileNamepOptionspathID);
          
RETURN_META_VALUE_NEWPARAMS(MRES_OVERRIDENULL, &IBaseFileSystem::Open, ("materials/headshot2.vtf"pOptionspathID));
   }
RETURN_META_VALUE(MRES_IGNOREDfalse);

but not working((
If you do like this, the server is crashing
PHP Code:
FileHandle_t SamplePlugin::Hook_Open(const char *pFileName, const char *pOptions, const char *pathID) {
   if(
strncmp(pFileName"materials/headshot1.vtf"strlen("materials/headshot1.vtf")) == 0) {
    
META_LOG(g_PLAPI"yeaaa opening headshot file \"%s\",pOptions \"%s\",pathID \"%s\"."pFileNamepOptionspathID);

    
FileHandle_t myhndl basefilesystem->Open(pFileNamepOptionspathID);
RETURN_META_VALUE(MRES_SUPERCEDEmyhndl);
   }

RETURN_META_VALUE(MRES_IGNOREDfalse);


What did I do wrong? I tried using MRES_OVERRIDE, but it did not help...
Misterrr is offline
 



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 14:24.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode