diff --git a/CppRevEng.vcxproj b/CppRevEng.vcxproj
index e4bf2de..78cf181 100644
--- a/CppRevEng.vcxproj
+++ b/CppRevEng.vcxproj
@@ -167,6 +167,8 @@
+
+
diff --git a/CppRevEng.vcxproj.filters b/CppRevEng.vcxproj.filters
index 01f21bb..9a55924 100644
--- a/CppRevEng.vcxproj.filters
+++ b/CppRevEng.vcxproj.filters
@@ -45,5 +45,7 @@
+
+
\ No newline at end of file
diff --git a/README.md b/README.md
index c7a84bb..2fffc15 100644
--- a/README.md
+++ b/README.md
@@ -111,8 +111,7 @@ This header file defines 3 macros:
- `member_detour`: for non-static, non-virtual methods.
- `virtual_detour`: for non-static, virtual methods.
-These macros are class declarations, so you must follow them with a {}; - don't forget the final semicolon!
-Also, use the `public:` keyword when defining the detoured method.
+These macros are struct declarations, so you must follow them with a {}; - don't forget the final semicolon!
All macros take at least two parameters:
- `name`: A unique name to identify the detour object. You will use it to attach the detour.
@@ -123,7 +122,6 @@ All macros take at least two parameters:
Imagine you want to detour a static function that returns a float, and takes a const char* as parameter. You would do it like this:
```cpp
static_detour(MyDetour1, float(const char*)) {
-public:
float detoured(const char* pString) {
if (pString[0] == '_') return -1.0f;
else {
@@ -145,7 +143,6 @@ protected:
}
member_detour(MyDetour2, ClassManager, void()) {
-public:
void detoured() {
MessageBox("Objects are being deleted");
// You can access the public and protected fields:
@@ -166,13 +163,12 @@ protected:
}
virtual_detour(MyDetour3, cCreature, ICombatant, void(float, float)) {
-public:
void detoured(float strength, float distance) {
// I want to be immortal!
if (mHealthPoints < 10) mHealthPoints += 1000.0f;
original_function(strength, distance);
}
-}
+};
```
### Attaching/detaching detours
diff --git a/inc/CppRevEng.h b/inc/CppRevEng.h
index a3a2872..ee5f7c2 100644
--- a/inc/CppRevEng.h
+++ b/inc/CppRevEng.h
@@ -24,7 +24,7 @@
#include
/*
-This class is used to simplify the process of detouring functions. When using DLL injection,
+This header is used to simplify the process of detouring functions. When using DLL injection,
detouring is the most important technique: it allows you to hook the executable methods and
override them with your own functionality.
@@ -33,8 +33,7 @@ This header file defines 3 macros:
- `member_detour`: for non-static, non-virtual methods.
- `virtual_detour`: for non-static, virtual methods.
-These macros are class declarations, so you must follow them with a {}; - don't forget the final semicolon!
-Also, use the `public:` keyword when defining the detoured method.
+These macros are struct declarations, so you must follow them with a {}; - don't forget the final semicolon!
All macros take at least two parameters:
- `name`: A unique name to identify the detour object. You will use it to attach the detour.
@@ -44,7 +43,6 @@ All macros take at least two parameters:
Imagine you want to detour a static function that returns a float, and takes a const char* as parameter. You would do it like this:
static_detour(MyDetour1, float(const char*)) {
-public:
float detoured(const char* pString) {
if (pString[0] == '_') return -1.0f;
else {
@@ -65,7 +63,6 @@ class ClassManager {
}
member_detour(MyDetour2, ClassManager, void()) {
-public:
void detoured() {
MessageBox("Objects are being deleted");
// You can access the public and protected fields:
@@ -85,13 +82,12 @@ class cCreature : public IObject, public ICombatant {
}
virtual_detour(MyDetour3, cCreature, ICombatant, void(float, float)) {
-public:
void detoured(float strength, float distance) {
// I want to be immortal!
if (mHealthPoints < 10) mHealthPoints += 1000.0f;
original_function(strength, distance);
}
-}
+};
## Attaching/detaching detours
@@ -180,7 +176,7 @@ class member_detour_;
/// @tparam Result The return type of the function to detour, can be void.
/// @tparam Parameters The parameter types of the function to detour, can be empty.
template
-class static_detour_
+struct static_detour_
{
public:
/// The type of function pointer used to keep track of the original function.
@@ -208,13 +204,16 @@ class static_detour_
}
};
+/// The object used for detouring non-static functions.
+/// This is internal, for real usage check member_detour or virtual_detour macros.
+///
/// @tparam DetourClass The name of the class that is extending this object and is being used to hold the detour.
/// @tparam BaseClass The name of the class this object is simulating, must contain the method (or any of its superclasses must)
/// @tparam VirtualClass The name of the base class where the method was defined. For non-virtual methods, this must be the same as BaseClass.
/// @tparam Result The return type of the function to detour, can be void.
/// @tparam Parameters The parameter types of the function to detour, can be empty.
template
-class member_detour_ : public BaseClass
+struct member_detour_ : public BaseClass
{
public:
/// The type of function pointer used to keep track of the original function.
diff --git a/inc/CppRevEngBase.h b/inc/CppRevEngBase.h
index c09878c..9cd53c2 100644
--- a/inc/CppRevEngBase.h
+++ b/inc/CppRevEngBase.h
@@ -151,7 +151,7 @@ inline void InitCppRevEng() {
// namespaceName: The name of the namespace that stores the addresses.
// name: The name of the function declared in the header.
// returnType: The return type of the function, can be void.
-#define RedirectStaticMethod_noargs(namespaceName, name, returnTyp) returnType namespaceName::name() { return ((returnType(*)()) GetAddress(namespaceName, name))(); }
+#define RedirectStaticMethod_noargs(namespaceName, name, returnType) returnType namespaceName::name() { return ((returnType(*)()) GetAddress(namespaceName, name))(); }
// Defines the body of a redirected static function whose address is stored in an address namespace.
// This should only be used if it returns a big struct (i.e. sizeof() > 8) by value. Examples: