Spore ModAPI/Spore/CppRevEng.h file

Classes

template<typename DetourClass, typename Result, typename ... Parameters>
struct static_detour_<DetourClass, Result(Parameters...)>
The object used for detouring static functions.
struct member_detour_<DetourClass, BaseClass, VirtualClass, Result(Arguments...)>

Functions

auto PrepareDetours(HMODULE hModule) -> void
auto CommitDetours() -> LONG

Defines

#define RedirectVirtualMethod_structret_const(className, virtualType, name, returnType, args, argNames)
#define DisableOptimization
#define EnableOptimization
#define attach_detour(name, className, methodName)
#define DETOUR
#define static_detour(name, declaration)
Detours an static method.
#define member_detour(name, baseClass, declaration)
Detours a class member method.
#define virtual_detour(name, baseClass, virtualClass, declaration)
Detours a virtual class member method.

Define documentation

#define static_detour(name, declaration)

Detours an static method.

Parameters
name The name of this detour object.
declaration The function declaration, with no names. For example, void(int, float)

In the macro parameters you must specify:

  • name: A name given to this detour object, to differentiate it from the rest.
  • delcaration: The return and parameter types, such as bool(int, float)

Inside the detoured function, you can call the original function using original_function() with the appropiate parameters. For example, original_function(3, myObject, 4.0)

This is a class object, so you must follow this declaration with {}. Inside you can define static functions and static variables as well.

#define member_detour(name, baseClass, declaration)

Detours a class member method.

Parameters
name The name of this detour object.
baseClass The name of the class where the method is. From the detoured code you can access its members.
declaration The method declaration, with no names. For example, void(int, float)

In the macro parameters you must specify:

  • name: A name given to this detour object, to differentiate it from the rest.
  • baseClass: The class that the method belongs to.
  • delcaration: The return and parameter types, such as bool(int, float)

Inside the detoured function, you can call the original function using original_function() with the appropiate parameters; the first parameter must be the this pointer (or any other object of the class) pointer. For example, original_function(this, 3, myObject, 4.0)

Inside the detoured function, you can can access the this pointer and any public/protected fields of the base class.

This is a class object, so you must follow this declaration with {}. Inside you can define methods (static and member) and static variables as well. You cannot add member variables.

#define virtual_detour(name, baseClass, virtualClass, declaration)

Detours a virtual class member method.

Parameters
name The name of this detour object.
baseClass The name of the class where the method is. From the detoured code you can access its members.
virtualClass The name of the class where the method is declared.
declaration The method declaration, with no names. For example, void(int, float)

In the macro parameters you must specify:

  • name: A name given to this detour object, to differentiate it from the rest.
  • baseClass: The class that the method belongs to.
  • virtualClass: The parent class that declared the virtual method.
  • delcaration: The return and parameter types, such as bool(int, float)

Not assigning virtualClass correctly might lead to crashes or unexpected behaviour. For example:

class A {
   virtual void func_A();
}
class B {
   virtual void func_B(int);
}
class C : public A, public B {
   virtual void func_B(int) override;
}

If you want to detour func_B, you need to use the macro virtual_detour(MyDetour, C, B, void(int))

Inside the detoured function, you can call the original function using original_function() with the appropiate parameters; the first parameter must be the this pointer (or any other object of the class) pointer. For example, original_function(this, 3, myObject, 4.0)

Inside the detoured function, you can can access the this pointer and any public/protected fields of the base class.

This is a class object, so you must follow this declaration with {}. Inside you can define methods (static and member) and static variables as well. You cannot add member variables.