I gave you working, step-by-step instructions in my post at the top of this page, and demonstrated that gettimeofday call was intercepted, and pointed out potential problems in your own code (i.e. C++ functions get named bizzare names, you need to make it a C function).
If my instructions don't work for you or are missing needed details, please describe where you got stuck.
---------- Post updated at 09:19 AM ---------- Previous update was at 09:03 AM ----------
Quote:
Originally Posted by
lilezek
So is the problem that I write it in C++? Could I use something like extend "C"?
Boy it's a good thing there's a way to do this in userspace, since you'd have no hope at all of running C++ in the kernel
extern "C" gettimeofday(...) might work, but remember, you're writing C
library code, not a normal userspace program. You should try to limit the high-level calls you make as much as possible. I'd avoid using C stdio, let alone iostream and the like. What if, in your gettimeofday() function, something deep in STL decides to call gettimeofday()? You'll get recursion until crash or swapdeath.
What, precisely, do you need C++ for? There may be lower-level alternatives.