OldSchoolHack

Registrieren / Anmelden Deutsch

libsrcapi v1.0

not available
  • Kategorie: Sourcecode
  • Entwickler:
  • Hochgeladen von: System
  • Hinzugefügt am:
  • System: Windows
Download (223.98 KB)

VirusTotal Ergebnis: 0/56

virustotal

Beschreibung

A small idiotproof library for working with and hooking source engine interfaces. Uses my custom vtable hook class.


Here's an example of how to use it that's correct:
CPP Code:
  1.  
  2. //used for CreateInterfaceFn Definition
  3. #include "InterfaceFactory.h"
  4. //contains the interface generation macros
  5. #include "macros.h"
  6.  
  7. V_INTERFACE(IVClient17, 0)
  8.     METHOD(0, int, Init, ARGS_SIGNATURE(CreateInterfaceFn appSystemFactory, CreateInterfaceFn physicsFactory, void *pGlobals), ARGS_INSTANCE_SIGNATURE(CreateInterfaceFn, CreateInterfaceFn, void*), ARGS_INSTANCE(appSystemFactory, physicsFactory, pGlobals))
  9.     METHOD(1, void, PostInit, ARGS_SIGNATURE(void), ARGS_INSTANCE_SIGNATURE(), ARGS_INSTANCE())
  10.     METHOD(2, void, Shutdown, ARGS_SIGNATURE(void), ARGS_INSTANCE_SIGNATURE(), ARGS_INSTANCE())
  11. END_V_INTERFACE
  12.  
  13. void hookShutdown(IVClient17 * client, void * shutdownhookfunc){
  14.     client->hookMethodByIndex(shutdownhookfunc, 2);
  15. }
  16.  
  17. void callShutdown(IVClient17* client){
  18.     client->Shutdown();
  19. }
  20.  
Here's the resulting code generated by the macros:

CPP Code:
  1.  
  2. class IVClient17 : public Interface{
  3.     private:
  4.         RawInterface instance;
  5.     public:
  6.         IVClient17(RawInterface rawInter) :Interface(rawInter, 0 * 4) {
  7.             instance = rawInter;
  8.         }
  9.         int Init(CreateInterfaceFn appSystemFactory, CreateInterfaceFn physicsFactory, void *pGlobals){
  10.             return (((int(__thiscall*)(void*, CreateInterfaceFn, CreateInter
  11.                 faceFn, void*))this->getMethodByIndex(0))((void*)instance, appSystemFactory, physicsFactory, pGlobals));
  12.         }
  13.         void PostInit(void){ return (((void(__thiscall*)(void*))this->getMethodByIndex(1))((void*)instance)); }
  14.         void Shutdown(void){ return (((void(__thiscall*)(void*))this->getMethodByIndex(2))((void*)instance)); }
  15. };
Edit:
Here's how you add a static virtual method:
CPP Code:
  1.  
  2. METHOD(12, void, ExampleStaticVirtualMethod, ARGS_SIGNATURE(int a, int b, int c,), ARGS_STATIC_SIGNATURE(int,int,int), ARGS_STATIC(a,b,c))
  3.  
you basically just swap all INSTANCE for STATIC in the macro names

Download libsrcapi v1.0