Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to do a naked function and inline assembler in x64 Visual C++

I am proxying a method call in using a naked function and inline assembler.

__declspec(naked) void ProxyFunction()
{
    static const unsigned int addressofRealFunction = 0x0041b200;
    __asm
    {
        jmp [addressofRealFunction];
    }
}

How can I translate this to x64? In visual studio there is no inline assembler or naked functions for x64.

Naked removes the assembly prologue and epilogue. I need this to make sure the stack frame stays equivalent for the call.

What would you do?

like image 702
user3380862 Avatar asked Mar 19 '23 01:03

user3380862


1 Answers

Try compiling it straight:

void ProxyFunction()
{
    RealFunction();
}

See if the compiler optimizes it down to bare jump. It might.

like image 66
Seva Alekseyev Avatar answered Apr 06 '23 09:04

Seva Alekseyev