From: bobdole on

if i understand correctly i can use a detour to call my function
EVERYTIME instead of the actual function of a program...

but what is a trampoline?
does this just move the original instructions of the target function
to a different location on the stack...and then let my custom function
execute....then once its done it will return the original functions
code in its place instead of keeping my hooked function from being
called everytime?
------------------------------------------------------------------------------------------------------------------------------------------------------------
A trampoline is a small block of code modified by Detours to contain
the
instructions of the target function moved to insert the detour and a
jump
to the remainder of the target function
From: David Schwartz on
On Jan 19, 1:29 pm, bobdole <innerfirenucl...(a)gmail.com> wrote:
> if i understand correctly i can use a detour to call my function
> EVERYTIME instead of the actual function of a program...
>
> but what is a trampoline?
> does this just move the original instructions of the target function
> to a different location on the stack...and then let my custom function
> execute....then once its done it will return the original functions
> code in its place instead of keeping my hooked function from being
> called everytime?
> ------------------------------------------------------------------------------------------------------------------------------------------------------------
> A trampoline is a small block of code modified by Detours to contain
> the
> instructions of the target function moved to insert the detour and a
> jump
> to the remainder of the target function

In this context, a trampoline is a function created by a library to
'wrap' another function.

For example, suppose an operating system takes a pointer to a callback
function but that callback function only takes one parameter. If a
library wants to provide a version that takes, say, two parameters, it
can create a function that unpacks a single parameter into the two
required parameters and calls a user-supplied function.

Specifically here, the trampoline is used to 'wrap' the target
function so that code can run before that function. This is commonly
used in 'filter' applications or performance monitoring applications.
The idea is that the code that calls the function need not be modified
and the function need not be modified, the only change needed is to
call the trampoline instead of the target function.

This dynamically-created piece of code is called a "trampoline"
because the CPU jumps into the code and then immediately "bounces off"
of it.

DS