I want to define a function with const at the end

124 Views Asked by At

I'm trying to try code injection with MSHook in Objective-C++.

Now I'm trying to hook a function with const at the end of the function and if I put const, I get "pointer to function type cannot have 'const' qualifier" and "non-membe function cannot have 'const' qualifier" errors.

The source code looks like this:

int (*Level_getTime)() const;
int _Level_getTime() const {

    return 15000;
}

%ctor {
    MSHookFunction((void*)(0x1007a6db0 + _dyld_get_image_vmaddr_slide(0)), (void*)&_Level_getTime, (void**)&Level_getTime);
}

Of course, if I build without const, I won't get an error. However, that would cause the app to crash.

What am I supposed to do?

0

There are 0 best solutions below