tags:

views:

50

answers:

1

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
This won't help him or her 'pop up a dialog' if indeed the program has no GUI going to begin with.
bmargulies
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