C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Interceptor Function (preserve stack and all registers)

From: Frederick Virchanza Gotham <cauldwell.thomas_at_[hidden]>
Date: Wed, 15 Apr 2026 10:33:07 +0100
On Wednesday, April 15, 2026, Thiago Macieira wrote:

>
>
> Much simpler to just allow (or even require) the interceptor function to
> have
> the same signature as the intercepted function.
>


I don't think there's any need for interceptor functions if you know the
signature of the "jumped to" function. I mean let's say the "jumped to"
function is:

    std::string Recover(int mode, char const *mask);

I would just intercept it by doing:

    std::string Recover(int mode, char const *mask)
    {
        auto const fp = dlsym( dlopen("abc", RTLD_NOW), "Recover");
        mode |= 1;
        return "\\\\.\\" + fp(mode,mask);
    }

I don't see any need for a new language feature here. Interceptor functions
are for when you want to intercept a call to a function which has any
conceivable signature.

Received on 2026-04-15 09:33:10