GithubHelp home page GithubHelp logo

Comments (4)

D4edalus avatar D4edalus commented on July 19, 2024

maybe you can show how that would look like for one function?

from cod4x_server.

T-Maxxx avatar T-Maxxx commented on July 19, 2024

void (*Com_Printf)(const char * fmt, ...) = (void(*)(const char *, ...)0x12345678;
Where 0x12345678 is an address in lnxded binary.
Variable Com_Printf (also called function pointer or functor) at a compilation will became a function with next body: jmp dword ptr [0x12345678]. Exactly the same we can see in .asm files.
Here's pseudo assembler code will be generated for Com_Printf("test format %d\n", 0x123);:

push 0x123; push "test format %d\n"; call Com_Printf => jmp 0x12345678 => (original function) => (return back to Com_Printf call).
Obviously, this will work only for __cdecl functions because stack is cleared after original function code. Variadic arguments in declaration always means this is __cdecl function, for other, you must include prologue and epilogue where you will reserve and clear function stack, or save\restore registers (used for IDA's __usercall, __stdcall, __thiscall) etc.

from cod4x_server.

T-Maxxx avatar T-Maxxx commented on July 19, 2024

I can convert assembly code into functors and update compiler script if you want.

from cod4x_server.

T-Maxxx avatar T-Maxxx commented on July 19, 2024

Whop, one more reason to get rid of nasm #76

from cod4x_server.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.