#define to overload virtual function

I want to overload pure virtual function from 3rd party SDK class to put my debug messages like that:

errorStatus aXsaction(){printf(_T("\nabort transaction"));transactionManager->abortTransaction();}

#define transactionManager->abortTransaction() aXsaction()

But compiler complains on the minus sign:
error C2008: '-' : unexpected in macro definition

Is it possible to trick the compiler?

Thank you in advance for any suggestion.
closed account (10X9216C)
If it is a virtual function, just override it.
@ OP: Like myesolar said, this is what virtual functions are for. To have their parent class inherited so that they can be overloaded. Are you sure you mean "overload" and not "hook"?
closed account (10X9216C)
To have their parent class inherited so that they can be overloaded.

Overload != override

1
2
3
4
5
6
7
8
9
10
11
12
13
int foo(double);
int foo(int); // this is overloading

class A
{
   virtual void foo() = 0;
};

class B : A
{
    void foo() override { } // this is overriding
}'
 
Last edited on
Override != hook

You override a function that your class inherits from a parent. You hook a function at run-time so that the host application still thinks it is calling the same callback chain.

1
2
3
4
5
6
LRESULT DLL_EXPORT HookProc(int Code, WPARAM wParam, LPARAM lParam)
{
     //Hook Code Goes Here

     return CallNextHookEx(NULL, Code, wParam, lParam);
}


Injection Binary:
1
2
3
HOOKPROC HookProc = (HOOKPROC) GetProcessAddress(LoadLibrary("Some.dll"), "HookProc@12");

SetWindowsHookEx(WH_DEBUG, HookProc, NULL, TARGET_PROCESS_ID_GOES_HERE);
Last edited on
Topic archived. No new replies allowed.