Skip to content

Failed to unprotect memory #51

@houxinlin

Description

@houxinlin
#include <funchook.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

static int  (*getpid_func)();

static int getpid_hook() {
    printf("origin getpid==%d\n",getpid_func());
    return 0;
}

int main() {
    funchook_t *funchook = funchook_create();

    getpid_func = getpid;
    funchook_prepare(funchook, (void**)&getpid_func, getpid_hook);

    if (funchook_install(funchook, 0) != FUNCHOOK_ERROR_SUCCESS) {
        printf("%s\n", funchook_error_message(funchook));
    }

    printf("%d\n",getpid());
    return 0;
}

output

Failed to unprotect memory 0xffff876d7000 (size=4096, prot=read,write,exec) <- 0xffff876d76b0 (size=8, error=Invalid argument)
3358211

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions