可能的陷阱写入地址(86 - Linux版) [英] Possible to trap write to address (x86 - linux)

查看:135
本文介绍了可能的陷阱写入地址(86 - Linux版)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望能够当对存储器地址的写操作发生以检测 - 通过设置连接到一个中断回调例如。有谁知道怎么样?

I want to be able to detect when a write to memory address occurs -- for example by setting a callback attached to an interrupt. Does anyone know how?

我希望能够在运行时做到这一点(可能GDB有这个功能,但我特别
应用程序会让gdb崩溃)。

I'd like to be able to do this at runtime (possibly gdb has this feature, but my particular application causes gdb to crash).

推荐答案

如果你想拦截写入到一个地址范围,可以使用的 则mprotect() 标记问题是不可写的内存,并且使用的 的sigaction() 赶产生SIGSEGV,做你的日志或任何与标记页面写试。

If you want to intercept writes to a range of addresses, you can use mprotect() to mark the memory in question as non-writeable, and install a signal handler using sigaction() to catch the resulting SIGSEGV, do your logging or whatever and mark the page as writeable again.

这篇关于可能的陷阱写入地址(86 - Linux版)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆