View Single Post
Author Message
nosoop
Veteran Member
Join Date: Aug 2014
Old 03-21-2018 , 09:53   Calling constructors from server binary?
Reply With Quote #1

Hey there.
I'm trying to experiment with hooking some NextBot-related function calls in TF2 (and figuring out C++ in the process).

Right now I have a hook on a function CTFBotScenarioMonitor::DesiredScenarioAndClassAction, which expects a return type Action<CTFBot>. I'd like to return an instance of one of the other actions present in the game.

Is there a way to manually get the size of a class, or to instantiate an instance of that class without an explicit size declaration? I'm able to allocate memory and call the ctor of something like CTFBotSeekAndDestroy, but so far I'm manually inputting the amount to allocate based on existing references. Was wondering if there were any other approaches (or something available to extensions that I didn't find).

Thanks!
__________________
I do TF2, TF2 servers, and TF2 plugins.
I don't do DMs over Discord -- PM me on the forums regarding inquiries.
AlliedModders Releases / Github / TF2 Server / Donate (BTC / BCH / coffee)

Last edited by nosoop; 03-22-2018 at 22:37. Reason: added a question mark to the title
nosoop is offline