Prev: About daemon process
Next: ftok
From: parag on 31 Jan 2010 07:14 hi All, is it possible to write some API that will attach a callback as a harware breakpoint on a address at runtime int* a = malloc(20); now API(a, <func>); will call func everytime a is changed or accessed ( access mdoes could also be added during attaching the callback ) I asked in the C forum, the moderator said, that this is an OS specific question and rejected the question in the C forum comp.lang.c.moderated please help -Parag
From: Daniel Molina Wegener on 31 Jan 2010 09:15 -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA512 On Dom 31 Ene 2010 09:14, parag wrote: > hi All, > > is it possible to write some API that will attach a callback as a > harware breakpoint on a address at runtime > > > int* a = malloc(20); > > now > > API(a, <func>); > > will call func everytime a is changed or accessed ( access mdoes could > also be added during attaching the callback ) I don't know any /standard/ way to that task. You can try operating system specific system calls, for example in Linux you can use ptrace(2) to create that kind of wrapper. > > I asked in the C forum, the moderator said, that this is an OS > specific question and rejected the question in the C forum > > comp.lang.c.moderated > > please help > -Parag Best regards, - -- | Daniel Molina <dmw [at] coder [dot] cl> | | IT Consulting & Software Development | | Phone: +56 2 9790277 | http://coder.cl/ | -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (GNU/Linux) iQIcBAEBCgAGBQJLZZCPAAoJEHxqfq6Y4O5NMIEP+wRlHPIzqfXFlJ7bVVAtwhBE eCWSjf9LJ2QENAUNhY/xu2D4pfSnsRtbFYCX3zxy0HpR4nKJ9sH2DPe4iFyVBktH QOuJMJPY/18FnUihbkEwZH9rNl1AJonnwP1YHwB4CvtpNZFgNJFyGsv+yB3NhP7s LyaET4ELuDVF3mUcxE2eB24H7YwIjK0g6Uvunvt2hNjU50fzqmyNU9PZQJjlhjMR xGXdAl11F/djeflHCPChKNzkoMaz3/eiAbgc6Y/HMdMQYwBqpEp6U5HVGkjBrbrO Kq6qlesRAHadE9bfaLWJCYZKNKKMVeBhaRi6I19kQyB6Fm1lZUKjWaxrUev3XS5B 38enfuwMVMxDjSh5+bYUpW4VFGd19EsOfMCqIJUnc5c9nAxIOvVM5i7Tx6/5/3z4 Czuf5TCnxJrXcUis4WAjA6z9BaaAZskt/fbPMgM2mS4O6Jn3t+wHkbjXV2Tl7uhk LJaS6fOyk4UaxNOZbQ2rFPsJHJZOoBbTk5f0c1EWETyhPs+atvbj/Qj/mjo4qLD7 LBBuNWwhjlwpWcw7Cyi8Pj+K0Rf5ToAe4CgyNSe9/wadEZMUKBvcmOC8k/MDZULL FPpwsjnPkKA3FG3x5CHBzzVZj0IeXTDLYc1pzTQxUonBC1id9o3GvXLWh1MXGKUg bb/TL8v2KZh1tzoZSgV2 =ufob -----END PGP SIGNATURE-----
From: David Schwartz on 31 Jan 2010 09:33 On Jan 31, 4:14 am, parag <parag.p...(a)gmail.com> wrote: > is it possible to write some API that will attach a callback as a > harware breakpoint on a address at runtime > > int* a = malloc(20); > > now > > API(a, <func>); > > will call func everytime a is changed or accessed ( access mdoes could > also be added during attaching the callback ) It's much easier if you can combine them into one function. It's very hard to protect just 20 bytes with most hardware. However, if you can have a special allocation function, it can 'mmap' its own pages and protect them with 'mprotect'. Then attempts to access the pages will result in SIGSEGV/SIGFAULT, which you can catch. DS
|
Pages: 1 Prev: About daemon process Next: ftok |