Using Function Hooks
Function hooks are a powerful part of BakkesMod. After a function is hooked, any time it is called by Rocket League, your code is called as well. Many useful ones are documented in Commonly Hooked Functions. If you want to better understand them or hook a function that’s undocumented, hopefully this page will help.
There are multiple types of hooks. First are the two simpler ones. gameWrapper
is a GameWrapper and will be accessible from any point in your code.
|
|
HookEvent
runs your code as the function is called
HookEventPost
runs your code as the function is returned from
They return a std::string
which is the name of the calling function. This is useful to differentiate what your caller is if you have multiple hooks calling the same code.
|
|
The two WithCaller variants do the same thing, but let you know a bit more about what is using the function
They provide a caller
value which is obtained from the function’s name. After Function TAGame
there will be a class name ending in _TA
. If the name matches a wrapper name, you can hook it as that wrapper. Car_TA
becomes CarWrapper for example. The image below breaks up a function call into parts. The class is GameEvent_TA, which can be cast to a ServerWrapper.
The hook also provides a void *
pointer. This points at the location of any parameters provided to the function. These aren’t well documented, and are hard to guess, so feel free to ask about them if you think you need them. A couple useful functions and parameters can be found in Commonly Hooked Functions
For example Function TAGame.Car_TA.OnHitBall
has a BallWrapper parameter. To access it, cast the void *
pointer to a struct including the parameters
|
|
Find functions with the function scanner