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

Req: A message hooker/logger


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
EKS
Veteran Member
Join Date: Mar 2004
Location: Norway
Old 12-04-2005 , 17:40   Req: A message hooker/logger
Reply With Quote #1

I requested this on irc, and got a few replyes on how to solve it. But it turns out i dont have suffient c++ skills.

A example of what im looking for from amxmodx ( http://forums.alliedmods.net/showthread.php?p=65983 )

My orignal idea was hook UserMessageBegin() then all the WriteByte / WriteXXXX and the MessageEnd().
If anyone has a code example on how to hook it, id be greatefull.


EDIT:
I did ask about this on irc, both cybermind and LDuke was helpfull in trying to help me, but i dont have the understanding of c++ to pull it off.
EKS is offline
BAILOPAN
Join Date: Jan 2004
Old 12-04-2005 , 21:23  
Reply With Quote #2

You can hook messagebegin/end with SourceHook but Write* require detours.
__________________
egg
BAILOPAN is offline
sslice
Senior Member
Join Date: Feb 2005
Location: Texas, USA
Old 12-04-2005 , 22:30  
Reply With Quote #3

You may not beable to hook Write*, but you can always hook UserMessageBegin, then pump a different bf_write through UserMessageBegin, and "supercede" the hook.

Only thing that might be tricky is reading the data that is already in bf_write, but not at all impossible since member functions like GetData() and GetNumBytesWritten() exist (look at bitbuf.h).
__________________
sslice is offline
cybermind
Senior Member
Join Date: Oct 2004
Old 12-05-2005 , 11:26  
Reply With Quote #4

Edit: After a sudden realization, this whole method won't work. But it's nice to dream. The mod wouldn't call your plugin's bf_write member functions despite the bf_write existing in your address space. BAILOPAN mentioned a while ago that bf_write is not virtual, and I simply ignored it thinking he was talking about the inability to hook it with SourceHook. The actual effect of not being virtual would be that the mod would call it's own locally-defined member functions, just with your instance as the "this" pointer. While this would store the buffer info in your instance, you'd be left with the same problem of not knowing what types of data exist in the buffer as you would not know what Write* functions were called. So yeah, wait for SourceHook to have detour support.

Quote:
Originally Posted by cybermind
Quote:
Originally Posted by sslice
You may not beable to hook Write*, but you can always hook UserMessageBegin, then pump a different bf_write through UserMessageBegin, and "supercede" the hook.
Hey that was my idea!

Quote:
Originally Posted by sslice
Only thing that might be tricky is reading the data that is already in bf_write, but not at all impossible since member functions like GetData() and GetNumBytesWritten() exist (look at bitbuf.h).
If you are just logging, trying to get data in the real bf_write isn't an issue.

If you aren't logging, and trying to block or modify a message, the best course of action would be to not initiate an actual UserMessage at first, and store all Write* data in some heterogenous collection (multiple-type storage structure, probably simplest with void*). In a IVEngineServer::EndMessage hook, you would examine the stored data and determined if it's acceptable to send or if it needs modification, finally calling the actual IVEngineServer::UserMessageBegin and associated Write* functions.

Ah, forgot to mention, although it should be obvious: anytime more than one plugin creates a bf_write hook of this type causes large problems. Until SourceHook features Detours, there is no good way to handle the issue. While a bf_write hook manager could be placed in SourceMM, it is too high-level of a function for SourceMM to be managing.
cybermind is offline
sslice
Senior Member
Join Date: Feb 2005
Location: Texas, USA
Old 12-06-2005 , 18:48  
Reply With Quote #5

SourceDetours? lol
__________________
sslice 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:21.


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