InterceptCall

Intercept a library of a system call

To use: define a function (typically, with extern(C) linkage) that performs the alternative implementation of the library call. Then expand the template mixin here, giving it your function as a template argument.

The template mixin will define a function called next_ yourfunction

version(linux && X86_64)
mixin template InterceptCall () {}

Examples

extern(C) int socket(int domain, int type, int protocol) {
    import std.stdio;
    int ret = next_socket(domain, type, protocol);

    writefln("socket(%s, %s, %s) = %s", domain, type, protocol, ret);

    return ret;
}

mixin InterceptCall!socket;

Meta