Hooking CPointServerCommand::InputCommand

Please post any questions about developing your plugin here. Please use the search function before posting!
User avatar
Doldol
Senior Member
Posts: 200
Joined: Sat Jul 07, 2012 7:09 pm
Location: Belgium

Hooking CPointServerCommand::InputCommand

Postby Doldol » Tue Jan 05, 2016 5:47 am

I'm trying to hook the InputCommand command function but it doesn't show up in the main virtual table for CPointServerCommand.

Instead the xrefs window points me to this, which seemed to be what I wanted, looking at it in the xrefs window.
But when I browse to it I find it by it's lonesome seemingly not in a vtable. I actually am not sure what this means.

Helps pwease? I'd rather not use a signature if at all possible.

Code: Select all

D30 00                                            db    0
.data:00AC2D31 00                                            db    0
.data:00AC2D32 00                                            db    0
.data:00AC2D33 00                                            db    0
.data:00AC2D34 20 F8 51 00                                   dd offset _ZN19CPointServerCommand12InputCommandER11inputdata_t ; CPointServerCommand::InputCommand(inputdata_t &)
.data:00AC2D38 00                                            db    0
.data:00AC2D39 00                                            db    0
.data:00AC2D3A 00                                            db    0
.data:00AC2D3B 00                                            db    0
.data:00AC2D3C 00                                            db    0
.data:00AC2D3D 00                                            db    0


And it's not in here:

Code: Select all

Inheritance Tree:
 CPointServerCommand
  CPointEntity
   CBaseEntity
    IServerEntity
     IServerUnknown
      IHandleEntity


VTable for CPointServerCommand: (0, 0)
 Lin  Win Function
   0    0 CPointServerCommand::~CPointServerCommand()
   1    0 CPointServerCommand::~CPointServerCommand()
   2    1 CBaseEntity::SetRefEHandle(CBaseHandle const&)
   3    2 CBaseEntity::GetRefEHandle(void)const
   4    3 CBaseEntity::GetCollideable(void)
   5    4 CBaseEntity::GetNetworkable(void)
   6    5 CBaseEntity::GetBaseEntity(void)
   7    6 CBaseEntity::GetModelIndex(void)const
   8    7 CBaseEntity::GetModelName(void)const
   9    8 CBaseEntity::SetModelIndex(int)
  10    9 CBaseEntity::GetServerClass(void)
  11   10 CBaseEntity::YouForgotToImplementOrDeclareServerClass(void)
  12   11 CPointServerCommand::GetDataDescMap(void)
  13   12 CBaseEntity::SetModelIndexOverride(int, int)
  14   13 CBaseEntity::TestCollision(Ray_t const&, unsigned int, CGameTrace &)
  15   14 CBaseEntity::TestHitboxes(Ray_t const&, unsigned int, CGameTrace &)
  16   15 CBaseEntity::ComputeWorldSpaceSurroundingBox(Vector *, Vector *)
  17   16 CBaseEntity::ShouldCollide(int, int)const
  18   17 CBaseEntity::SetOwnerEntity(CBaseEntity*)
  19   18 CBaseEntity::ShouldTransmit(CCheckTransmitInfo const*)
  20   19 CBaseEntity::UpdateTransmitState(void)
  21   20 CBaseEntity::SetTransmit(CCheckTransmitInfo *, bool)
  22   21 CBaseEntity::GetTracerType(void)
  23   22 CPointEntity::Spawn(void)
  24   23 CBaseEntity::Precache(void)
  25   24 CBaseEntity::SetModel(char const*)
  26   25 CBaseEntity::OnNewModel(void)
  27   26 CBaseEntity::PostConstructor(char const*)
  28   27 CBaseEntity::PostClientActive(void)
  29   28 CBaseEntity::ParseMapData(CEntityMapData *)
  30   29 CPointEntity::KeyValue(char const*, char const*)
  31   31 CBaseEntity::KeyValue(char const*, float)
  32   30 CBaseEntity::KeyValue(char const*, Vector const&)
  33   32 CBaseEntity::GetKeyValue(char const*, char *, int)
  34   33 CBaseEntity::Activate(void)
  35   34 CBaseEntity::SetParent(CBaseEntity*, int)
  36   35 CPointEntity::ObjectCaps(void)
  37   36 CBaseEntity::AcceptInput(char const*, CBaseEntity*, CBaseEntity*, variant_t, int)
  38   37 CBaseEntity::GetInputDispatchEffectPosition(char const*, Vector &, QAngle &)
  39   38 CBaseEntity: :D rawDebugGeometryOverlays(void)
  40   39 CBaseEntity: :D rawDebugTextOverlays(void)
  41   40 CBaseEntity::Save(ISave &)
  42   41 CBaseEntity::Restore(IRestore &)
  43   42 CBaseEntity::ShouldSavePhysics(void)
  44   43 CBaseEntity::OnSave(IEntitySaveUtils *)
  45   44 CBaseEntity::OnRestore(void)
  46   45 CBaseEntity::RequiredEdictIndex(void)
  47   46 CBaseEntity::MoveDone(void)
  48   47 CBaseEntity::Think(void)
  49   49 CBaseEntity::NetworkStateChanged_m_nNextThinkTick(void)
  50   48 CBaseEntity::NetworkStateChanged_m_nNextThinkTick(void *)
  51   50 CBaseEntity::GetBaseAnimating(void)
  52   51 CBaseEntity::GetResponseSystem(void)
  53   52 CBaseEntity: :D ispatchResponse(char const*)
  54   53 CBaseEntity::Classify(void)
  55   54 CBaseEntity: :D eathNotice(CBaseEntity*)
  56   55 CBaseEntity::ShouldAttractAutoAim(CBaseEntity*)
  57   56 CBaseEntity::GetAutoAimRadius(void)
  58   57 CBaseEntity::GetAutoAimCenter(void)
  59   58 CBaseEntity::GetBeamTraceFilter(void)
  60   59 CBaseEntity::PassesDamageFilter(CTakeDamageInfo const&)
  61   60 CBaseEntity::TraceAttack(CTakeDamageInfo const&, Vector const&, CGameTrace *, CDmgAccumulator *)
  62   61 CBaseEntity::CanBeHitByMeleeAttack(CBaseEntity*)
  63   62 CBaseEntity::OnTakeDamage(CTakeDamageInfo const&)
  64   63 CBaseEntity::AdjustDamageDirection(CTakeDamageInfo const&, Vector &, CBaseEntity*)
  65   64 CBaseEntity::TakeHealth(float, int)
  66   65 CBaseEntity::IsAlive(void)
  67   66 CBaseEntity::Event_Killed(CTakeDamageInfo const&)
  68   67 CBaseEntity::Event_KilledOther(CBaseEntity*, CTakeDamageInfo const&)
  69   68 CBaseEntity::BloodColor(void)
  70   69 CBaseEntity::IsTriggered(CBaseEntity*)
  71   70 CBaseEntity::IsNPC(void)const
  72   71 CBaseEntity::MyCombatCharacterPointer(void)
  73   72 CBaseEntity::MyNextBotPointer(void)
  74   73 CBaseEntity::GetDelay(void)
  75   74 CBaseEntity::IsMoving(void)
  76   75 CBaseEntity: :D amageDecal(int, int)
  77   76 CBaseEntity: :D ecalTrace(CGameTrace *, char const*)
  78   77 CBaseEntity::ImpactTrace(CGameTrace *, int, char const*)
  79   78 CBaseEntity::OnControls(CBaseEntity*)
  80   79 CBaseEntity::HasTarget(string_t)
  81   80 CBaseEntity::IsPlayer(void)const
  82   81 CBaseEntity::IsNetClient(void)const
  83   82 CBaseEntity::IsTemplate(void)
  84   83 CBaseEntity::IsBaseObject(void)const
  85   84 CBaseEntity::IsBaseTrain(void)const
  86   85 CBaseEntity::IsCombatItem(void)const
  87   86 CBaseEntity::IsBaseCombatWeapon(void)const
  88   87 CBaseEntity::IsWearable(void)const
  89   88 CBaseEntity::MyCombatWeaponPointer(void)
  90   89 CBaseEntity::GetServerVehicle(void)
  91   90 CBaseEntity::IsViewable(void)
  92   91 CBaseEntity::ChangeTeam(int)
  93   92 CBaseEntity::OnEntityEvent(EntityEvent_t, void *)
  94   94 CBaseEntity::CanStandOn(CBaseEntity*)const
  95   93 CBaseEntity::CanStandOn(edict_t *)const
  96   96 CBaseEntity::GetEnemy(void)
  97   95 CBaseEntity::GetEnemy(void)const
  98   97 CBaseEntity::Use(CBaseEntity*, CBaseEntity*, USE_TYPE, float)
  99   98 CBaseEntity::StartTouch(CBaseEntity*)
 100   99 CBaseEntity::Touch(CBaseEntity*)
 101  100 CBaseEntity::EndTouch(CBaseEntity*)
 102  101 CBaseEntity::StartBlocked(CBaseEntity*)
 103  102 CBaseEntity::Blocked(CBaseEntity*)
 104  103 CBaseEntity::EndBlocked(void)
 105  104 CBaseEntity::PhysicsSimulate(void)
 106  105 CBaseEntity::UpdateOnRemove(void)
 107  106 CBaseEntity::StopLoopingSounds(void)
 108  107 CBaseEntity::SUB_AllowedToFade(void)
 109  108 CBaseEntity::Teleport(Vector const*, QAngle const*, Vector const*)
 110  109 CBaseEntity::NotifySystemEvent(CBaseEntity*, notify_system_event_t, notify_system_event_params_t const&)
 111  110 CBaseEntity::MakeTracer(Vector const&, CGameTrace const&, int)
 112  111 CBaseEntity::GetTracerAttachment(void)
 113  112 CBaseEntity::FireBullets(FireBulletsInfo_t const&)
 114  113 CBaseEntity: :D oImpactEffect(CGameTrace &, int)
 115  114 CBaseEntity::ModifyFireBulletsDamage(CTakeDamageInfo *)
 116  115 CBaseEntity::Respawn(void)
 117  116 CBaseEntity::IsLockedByMaster(void)
 118  117 CBaseEntity::GetMaxHealth(void)const
 119  118 CBaseEntity::ModifyOrAppendCriteria(AI_CriteriaSet &)
 120  120 CBaseEntity::NetworkStateChanged_m_iMaxHealth(void)
 121  119 CBaseEntity::NetworkStateChanged_m_iMaxHealth(void *)
 122  122 CBaseEntity::NetworkStateChanged_m_iHealth(void)
 123  121 CBaseEntity::NetworkStateChanged_m_iHealth(void *)
 124  124 CBaseEntity::NetworkStateChanged_m_lifeState(void)
 125  123 CBaseEntity::NetworkStateChanged_m_lifeState(void *)
 126  126 CBaseEntity::NetworkStateChanged_m_takedamage(void)
 127  125 CBaseEntity::NetworkStateChanged_m_takedamage(void *)
 128  127 CBaseEntity::GetDamageType(void)const
 129  128 CBaseEntity::GetDamage(void)
 130  129 CBaseEntity::SetDamage(float)
 131  130 CBaseEntity::EyePosition(void)
 132  131 CBaseEntity::EyeAngles(void)
 133  132 CBaseEntity::LocalEyeAngles(void)
 134  133 CBaseEntity::EarPosition(void)
 135  134 CBaseEntity::BodyTarget(Vector const&, bool)
 136  135 CBaseEntity::HeadTarget(Vector const&)
 137  136 CBaseEntity::GetVectors(Vector *, Vector *, Vector *)const
 138  137 CBaseEntity::GetViewOffset(void)const
 139  138 CBaseEntity::SetViewOffset(Vector const&)
 140  139 CBaseEntity::GetSmoothedVelocity(void)
 141  140 CBaseEntity::GetVelocity(Vector *, Vector *)
 142  142 CBaseEntity::FVisible(CBaseEntity*, int, CBaseEntity**)
 143  141 CBaseEntity::FVisible(Vector const&, int, CBaseEntity**)
 144  143 CBaseEntity::CanBeSeenBy(CAI_BaseNPC *)
 145  144 CBaseEntity::GetAttackDamageScale(CBaseEntity*)
 146  145 CBaseEntity::GetReceivedDamageScale(CBaseEntity*)
 147  146 CBaseEntity::GetGroundVelocityToApply(Vector &)
 148  147 CBaseEntity::PhysicsSplash(Vector const&, Vector const&, float, float)
 149  148 CBaseEntity::Splash(void)
 150  149 CBaseEntity::WorldSpaceCenter(void)const
 151  150 CBaseEntity::GetSoundEmissionOrigin(void)const
 152  151 CBaseEntity::ModifyEmitSoundParams(EmitSound_t &)
 153  152 CBaseEntity::IsDeflectable(void)
 154  153 CBaseEntity: :D eflected(CBaseEntity*, Vector &)
 155  154 CBaseEntity::CreateVPhysics(void)
 156  155 CBaseEntity::ForceVPhysicsCollide(CBaseEntity*)
 157  156 CBaseEntity::VPhysicsDestroyObject(void)
 158  157 CBaseEntity::VPhysicsUpdate(IPhysicsObject *)
 159  158 CBaseEntity::VPhysicsTakeDamage(CTakeDamageInfo const&)
 160  159 CBaseEntity::VPhysicsShadowCollision(int, gamevcollisionevent_t *)
 161  160 CBaseEntity::VPhysicsShadowUpdate(IPhysicsObject *)
 162  161 CBaseEntity::VPhysicsCollision(int, gamevcollisionevent_t *)
 163  162 CBaseEntity::VPhysicsFriction(IPhysicsObject *, float, int, int)
 164  163 CBaseEntity::UpdatePhysicsShadowToCurrentPosition(float)
 165  164 CBaseEntity::VPhysicsGetObjectList(IPhysicsObject **, int)
 166  165 CBaseEntity::VPhysicsIsFlesh(void)
 167  166 CBaseEntity::HasPhysicsAttacker(float)
 168  167 CBaseEntity::PhysicsSolidMaskForEntity(void)const
 169  168 CBaseEntity::ResolveFlyCollisionCustom(CGameTrace &, Vector &)
 170  169 CBaseEntity::PerformCustomPhysics(Vector *, Vector *, QAngle *, QAngle *)
 171  170 CBaseEntity::GetStepOrigin(void)const
 172  171 CBaseEntity::GetStepAngles(void)const
 173  172 CBaseEntity::ShouldDrawWaterImpacts(void)
 174  174 CBaseEntity::NetworkStateChanged_m_fFlags(void)
 175  173 CBaseEntity::NetworkStateChanged_m_fFlags(void *)
 176  176 CBaseEntity::NetworkStateChanged_m_nWaterLevel(void)
 177  175 CBaseEntity::NetworkStateChanged_m_nWaterLevel(void *)
 178  178 CBaseEntity::NetworkStateChanged_m_hGroundEntity(void)
 179  177 CBaseEntity::NetworkStateChanged_m_hGroundEntity(void *)
 180  180 CBaseEntity::NetworkStateChanged_m_vecBaseVelocity(void)
 181  179 CBaseEntity::NetworkStateChanged_m_vecBaseVelocity(void *)
 182  182 CBaseEntity::NetworkStateChanged_m_flFriction(void)
 183  181 CBaseEntity::NetworkStateChanged_m_flFriction(void *)
 184  184 CBaseEntity::NetworkStateChanged_m_vecVelocity(void)
 185  183 CBaseEntity::NetworkStateChanged_m_vecVelocity(void *)
 186  186 CBaseEntity::NetworkStateChanged_m_vecViewOffset(void)
 187  185 CBaseEntity::NetworkStateChanged_m_vecViewOffset(void *)
 188  187 CBaseEntity::ShouldBlockNav(void)const


(I need this because I'm trying to hook (prevent) a map changing specific console commands while still being able to change them through RCON.)

Another question, IDA x64 is way faster but the vtable dumping Python script doesn't work with it (doesn't print the tree/wrong offsets), any way to fix that?
User avatar
satoon101
Project Leader
Posts: 2697
Joined: Sat Jul 07, 2012 1:59 am

Postby satoon101 » Tue Jan 05, 2016 6:31 am

Unless I am missing something (which I very well am at this late hour), this is setup as an input:
https://github.com/alliedmodders/hl2sdk/blob/98fe5b5a34b3721fe4d60ec7ba3a28ade3512560/game/server/client.cpp#L576

If you follow the instructions at this link (or rather, use the link at the very bottom of the first post), you will see that CPointServerCommand has an input for all engines/games named Command. So, you should be able to use the following to hook it:

Syntax: Select all

from entities.entity import Entity
from memory.hooks import PreHook

entity = Entity.find_or_create('point_servercommand')


@PreHook(entity.get_input('Command'))
def _pre_insert_command(args):
"""Your code here"""


We could also add that input to our entities data, which would allow you to use the following instead (depending on the name we would give it):

Syntax: Select all

from entities.entity import Entity
from memory.hooks import PreHook

entity = Entity.find_or_create('point_servercommand')


@PreHook(entity.input_command)
def _pre_insert_command(args):
"""Your code here"""


However, it also seems that all CPointServerCommand::InputCommand does is call engine_server.server_command. That would make the following a slightly easier route:

Syntax: Select all

from engines.server import engine_server
from memory import get_virtual_function
from memory.hooks import PreHook

@PreHook(get_virtual_function(engine_server, 'ServerCommand'))
def _pre_server_command(args):
"""Your code here"""
Image
User avatar
Doldol
Senior Member
Posts: 200
Joined: Sat Jul 07, 2012 7:09 pm
Location: Belgium

Postby Doldol » Tue Jan 05, 2016 7:57 am

satoon101 wrote:Unless I am missing something (which I very well am at this late hour), this is setup as an input:
https://github.com/alliedmodders/hl2sdk/blob/98fe5b5a34b3721fe4d60ec7ba3a28ade3512560/game/server/client.cpp#L576

If you follow the instructions at this link (or rather, use the link at the very bottom of the first post), you will see that CPointServerCommand has an input for all engines/games named Command. So, you should be able to use the following to hook it:

Syntax: Select all

from entities.entity import Entity
from memory.hooks import PreHook

entity = Entity.find_or_create('point_servercommand')


@PreHook(entity.get_input('Command'))
def _pre_insert_command(args):
"""Your code here"""



Yup, totally forgot about that urh, I even looked that input up in Hammer prior to this, thanks, that solved it and explains the issue I was having with the offsets!

In my case the last option shouldn't work as afaik that would also hook commands entered into the console, which I don't want to hook.

Return to “Plugin Development Support”

Who is online

Users browsing this forum: No registered users and 121 guests