How can i hook file saving in Linux systems (to show my programm dialog, opearting with them then)?
A:
If you can compile them you can link first against a custom library that provides open().
There's a stock way of doing it.
If you can't compile it, this works most of the time:
Write function _open_posthook that does syscall(NR_OPEN, ...)
Provide shared library libopenhook that provides your new open. Rembember you renamed open to _open_posthook() here unless you want recursion. Don't forget to also provide creat().
Load this library with LD_PRELOAD.
EDIT: if you're trying for security this won't work. You might be able to get away with using strace() but unless you are very careful a determined programmer can overcome that too.
Joshua
2010-04-26 00:26:35
This won't help him or her 'pop up a dialog' if indeed the program has no GUI going to begin with.
bmargulies
2010-04-26 01:05:59
You could use some IPC to send a message to a helper app which can then show t he dialogue. It's ugly though. I think this is what Windows on-access AV scanners etc typically do. Using a LD_PRELOAD hook isn't secure, as sufficiently determined apps (or indeed, statically linked ones) can bypass it.
MarkR
2010-04-26 12:40:47