Boost logo

Boost Users :

Subject: [Boost-users] boost::lambda::bind temporary function objects.. and raw C
From: Tomasz Mloduchowski (tomasz_at_[hidden])
Date: 2009-07-31 00:13:31


Hello everyone!

I have a rather challenging question, that perhaps can be resolved
without too much dark magic.

A little background: I'm patching an executable (x86 platform, but could
be easily extended to other architectures).

players:
void TargetFunc(some parameters);
void Hook(some parameters);

method:
Grab first 5 bytes of TargetFunc. Back them up. Replace them with a jmp
Hook.

Make Hook finish as follows:
        Restore the backup of 5 bytes.
        Call TargetFunc again, this time the real one, not the jmp.
        Replace the 5 bytes with jmp Hook, getting ready for the next invocation.

In a nutshell - typical trampoline.

Now, I want to write a framework for this. I would prefer to be able to
have some code reuse. Can either mem_fn or bind be helpful here?

I'm trying to understand how they work. I feel like they are creating
extra 'functions' with some game about parameters. Ideas?

cheers,
Tomasz


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net