Raised This Month: $51 Target: $400
 12% 

[TF2] Detouring CLog::Print not quite working


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
pcmaster
AlliedModders Donor
Join Date: Sep 2009
Old 07-08-2015 , 14:31   [TF2] Detouring CLog::Print not quite working
Reply With Quote #1

Hello,

I am currently trying to detour CLog:rint to hide some messages (namely player joined/disconnected).
It is part of my Admin Stealth plugin and is used to hide joining players from gameme (so the message won't be printed out).

For this, I have detoured CLog:rint(char const*) like this:

PHP Code:

DETOUR_DECL_STATIC1
(CLog_Printvoid, const char *, message)
{
    
g_pSM->LogMessage(myself"CLog::Print called: %s"message);
    
DETOUR_STATIC_CALL(CLog_Print)(message);
    return;
}

bool LH::SDK_OnLoad(char *errorsize_t maxlengthbool late)
{
    
char conf_error[255] = "";

    if (!
gameconfs->LoadGameConfigFile("lh.games", &g_pGameConfconf_errorsizeof(conf_error)))
    {
        if (
conf_error[0])
        {
                
snprintf(errormaxlength"Could not read lh.games.txt: %s"conf_error);
        }
        return 
false;
    }

    
// Prepare and setup detour
    
CDetourManager::Init(g_pSM->GetScriptingEngine(), g_pGameConf);

    
g_pPrintDetour DETOUR_CREATE_STATIC(CLog_Print"CLog::Print");

    if(
g_pPrintDetour != NULL)
    {
        
// Now that the detour is working, enable the Forward too
        
g_pPrintDetour->EnableDetour();
        return 
true;
    }

    
snprintf(errormaxlength"CLog::Print detour failed.");
    return 
false;

(forward stuff omitted).

Gamedata:
PHP Code:
"Games"
{
        
"tf"
        
{
                
"Signatures"
                
{
                        
"CLog::Print"
                        
{
                                
"library"       "engine"
                                "windows"       ""
                                "linux"         "@_ZN4CLog5PrintEPKc"
                                "mac"           "@_ZN4CLog5PrintEPKc"
                        
}
                }
        }

The compilation works and the extension just runs fine, but the supplied message (which should be a const char*) is just plain gibberish:

Quote:
L 07/08/2015 - 20:094: [LH] CLog:rint called: Ё#*********
L 07/08/2015 - 20:094: [LH] CLog:rint called: Ё#*********
L 07/08/2015 - 20:094: [LH] CLog:rint called: Ё#*********
L 07/08/2015 - 20:094: [LH] CLog:rint called: Ё#*********
L 07/08/2015 - 20:094: [LH] CLog:rint called: Ё#*********
L 07/08/2015 - 20:09:52: [LH] CLog:rint called: Ё#*********
Anyone knows what I am doing wrong?
Help would be appreciated!
__________________
Stopped hosting servers as of November 2018, no longer active around here.
pcmaster is offline
asherkin
SourceMod Developer
Join Date: Aug 2009
Location: OnGameFrame()
Old 07-08-2015 , 14:59   Re: [TF2] Detouring CLog::Print not quite working
Reply With Quote #2

Or, for a much easier time, block the player_connect and player_disconnect events.
__________________
asherkin is offline
pcmaster
AlliedModders Donor
Join Date: Sep 2009
Old 07-08-2015 , 15:02   Re: [TF2] Detouring CLog::Print not quite working
Reply With Quote #3

Quote:
Originally Posted by asherkin View Post
Or, for a much easier time, block the player_connect and player_disconnect events.
I am already doing this, but somehow, it's still being logged (and sent to gameMe's servers).
__________________
Stopped hosting servers as of November 2018, no longer active around here.
pcmaster is offline
asherkin
SourceMod Developer
Join Date: Aug 2009
Location: OnGameFrame()
Old 07-08-2015 , 15:20   Re: [TF2] Detouring CLog::Print not quite working
Reply With Quote #4

Quote:
Originally Posted by pcmaster View Post
I am already doing this, but somehow, it's still being logged (and sent to gameMe's servers).
You need to actually block it, not just disable broadcast.
__________________
asherkin is offline
pcmaster
AlliedModders Donor
Join Date: Sep 2009
Old 07-08-2015 , 15:46   Re: [TF2] Detouring CLog::Print not quite working
Reply With Quote #5

Quote:
Originally Posted by asherkin View Post
You need to actually block it, not just disable broadcast.
Won't that interfere with other plugins and/or actual game functions?
__________________
Stopped hosting servers as of November 2018, no longer active around here.
pcmaster is offline
psychonic

BAFFLED
Join Date: May 2008
Old 07-08-2015 , 16:45   Re: [TF2] Detouring CLog::Print not quite working
Reply With Quote #6

Quote:
Originally Posted by pcmaster View Post
Won't that interfere with other plugins and/or actual game functions?
I believe that the only serverside game functions that use those are for logging. Returning Plugin_Handled will block from the game and still allow plugins to get it. Plugin_Stop would block from all.
psychonic is offline
pcmaster
AlliedModders Donor
Join Date: Sep 2009
Old 07-09-2015 , 10:58   Re: [TF2] Detouring CLog::Print not quite working
Reply With Quote #7

Well, blocking the event entirely with Plugin_Handled/Plugin_Stop didn't change anything, gameMe is still seeing the connect..
__________________
Stopped hosting servers as of November 2018, no longer active around here.
pcmaster is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 07-09-2015 , 11:51   Re: [TF2] Detouring CLog::Print not quite working
Reply With Quote #8

I was under the impression that certain games use a new connect event, player_connect_client.

CS:GO and TF2 specifically.
__________________
Not currently working on SourceMod plugin development.
Powerlord is offline
psychonic

BAFFLED
Join Date: May 2008
Old 07-09-2015 , 12:49   Re: [TF2] Detouring CLog::Print not quite working
Reply With Quote #9

Quote:
Originally Posted by Powerlord View Post
I was under the impression that certain games use a new connect event, player_connect_client.

CS:GO and TF2 specifically.
CS:GO only has player_connect and no longer sets the IP address in it. TF2 added a second event, player_connect_client that does not have the IP address set and gets broadcast to clients. TF2 still has player_connect, and it still triggers the serverside logging.

A better approach for both of them would have just been to mark the IP field as type "local", so that the event would stay as-is, with the exception of that field not being broadcasted with it to clients.
psychonic is offline
pcmaster
AlliedModders Donor
Join Date: Sep 2009
Old 07-11-2015 , 08:32   Re: [TF2] Detouring CLog::Print not quite working
Reply With Quote #10

I am currently hooking player_connect_client, so is player_connect doing the logging?
__________________
Stopped hosting servers as of November 2018, no longer active around here.
pcmaster is offline
Reply



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 18:00.


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