Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hardware breakpoint not called #4

Open
hagaisela opened this issue Dec 21, 2022 · 0 comments
Open

hardware breakpoint not called #4

hagaisela opened this issue Dec 21, 2022 · 0 comments

Comments

@hagaisela
Copy link

hagaisela commented Dec 21, 2022

Hi,
I am trying to detect a memory corruption using this library. I wrote a little test program to try and test it but my callback doesn't get called. what am I missing?

#include "hwbp_lib.h"

#include <stdio.h>
#include <stdbool.h>
#include <sys/syscall.h>      /* Definition of SYS_* constants */
#include <unistd.h>
#include <stdlib.h>
#include <stdint.h>

static void
handle_suspect_write(int dummy)
{
    printf("gotcha!!!\n");
}

int main(int arc, char** argv)
{
    uint64_t *dummy = malloc(sizeof(uint64_t));
    *dummy = 0;

    pid_t tid = syscall(__NR_gettid);

    bool bp_written = install_breakpoint(dummy, 0, HW_BREAKPOINT_WRITE_ACCESS, tid, handle_suspect_write);
    if (!bp_written)
    {
        printf("failed to install breakpoint\n");
        return -1;
    }

    *dummy = 1;
    usleep(1000000);
    free(dummy);
    return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant