0

I am learning about detouring functions using Detours 1.5. I have made a target executable which contains this function

float myFunction(int a)
{
    cout << "The function argument value is " << a << std::endl;
    return static_cast<float>(a);
}

And a DLL, which will be injected into it, that contains this code

...
float(__cdecl originalFunc) (int);

float hookedFunc(int in)
{
    std::cout << "Function myFunction() was intercepted!\n";
    return originalFunc(18);
}

BOOL APIENTRY DllMain(HANDLE hModule, DWORD dwReason, LPVOID lpReserved)
{
    switch (dwReason)
    {
    case DLL_PROCESS_ATTACH:
        originalFunc = (float(__cdecl*)(int))DetourFunction((PBYTE)FUNCTION_ADDRESS, (PBYTE)hookedFunc);
        break;
    }

    return true;
}

But on the line "originalFunc = ..." (after the process attach) the compiler is throwing an error "expression must be a modifiable lvalue". I assume it's because I am trying to assign a value to a function, but that's how it was shown in the tutorial, so how do I fix this? The IDE I am using is Visual Studio 2015 Community Edition.

0 Answers0