vBulletin Mods

The Official vBulletin Modifications Site

Easiest way to patch your own hooks into the vBulletin codebase?
by vbSuperfan
27 Aug 2019 00:36

vBulletin tells me that it's completely impossible to modify the contents of posts displayed in the Mobile Suite mobile apps, either by hooks or class extension plugins for the vB5 back-end (which serves the contents to the mobile apps through the API requests that these apps make to it).

Based on this information, my only remaining alternative is to patch the vBulletin code myself, and the cleanest way I can think of is to insert my own hook point(s) into the vBulletin source code and then reference these from an extension/product, thus causing minimal patches of the vBulletin code itself, which can be repeated for future released versions of vBulletin as easily as possible.

My question is therefore:

What is the easiest way to patch your own hooks into the vBulletin codebase? Is there only some single line of code I can insert at the location in the code that I want to hook?

Is there perhaps even some examples available somewhere that I could take a look at in regards to this topic, that anyone knows of?

Dave 27 Aug 2019 01:28

The vBulletin 5 documentation is pretty poor so you'll probably have to figure most things out yourself. In the code the only reference to invoking a hook seems to be function invoke($hook_name, $params) which can be called using (an example taken from the new login hook):

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

The available hooks and classes seems to be imported from the installed products which you can see at /core/vb/vb.php function getHooks. The invoke function can be found at /core/vb/utility/hook/live.php function invoke.

By default vBulletin 5 comes with a couple of packages/products that interact with these hooks so you can see what kind of code you can put inside of hooks and how the params are passed to the hooked function. One example can be found at /core/packages/googlelogin/hooks.php and the other files in that folder.

Hopefully that will help you out for now.

vbSuperfan 27 Aug 2019 22:45

Hello Dave, thanks a million for this information, a very useful starting point for looking into this deeper, which I will absolutely do!

Do you (or anyone else here) know which PHP script in vBulletin that the Mobile Suite mobile apps use for their API calls? That would be a very good starting point for me to begin tracing/reversing code in order to know where to best place my new custom hooks...

--------------- Added 27 Aug 2019 at 23:20 ---------------

Ok, a few moments of web server access log tracing and PHP code reversing later, it would seem that a good target for a custom hook would be the print_apioutput($data) function of the file /core/api.php.

I'll start gently and try to use the hook methodology listed above to insert a hook in it. If it won't work, I'll just patch the hell out of it locally for now, since I've got no time to lose in this matter.

I'll let you know how it goes!

I assume that it won't be possible to use the new fancy-schmancy subclassing extension system of vB5 to get direct access to this function directly from a "product" without any code PHP file patching having to be done at all? Seeing that:

1) This function (print_apioutput()) isn't even inside any object oriented code to begin with.


2) What are the odds of that working as advertised to begin with either way, right...? :(

Or would that actually be able to work somehow? Anyone knows, yes or no?

All times are GMT. The time now is 07:09.

Powered by vBulletin® Version 3.8.14
Copyright © 2022, MH Sub I, LLC dba vBulletin. All Rights Reserved. vBulletin® is a registered trademark of MH Sub I, LLC
Copyright ©2001 - , vbulletin.org. All rights reserved.