开发者

How can I modify the application file of an application that is currently running (on Linux)?

I have an application running called AppFS. This application has an ext2 filesystem just attached to the end of the file (it's positi开发者_如何学Pythononed so that the application binary exists in a 1MB spacing area, followed by the ext2 data).

Now I've got FUSE embedded in the program and I've managed to extract the filesystem out of the application data into a temporary file so that FUSE can mount / use it.

The problem I have now is writing the temporary file back into the application file. I get "Text file busy" presumably because the application has locked itself and won't let writes occur.

Is there a way I can force the file to become unlocked so I can write data to it? (It's important to note that I'm not changing the application binary area - just rewriting the ext2 component.) It needs to be unlocked without requiring root permissions (unlocked by the same user who started the application).


The solution to this problem was to rename the existing application name (to a location within a temporary directory) and to then move the new (generated) file back in it's place and apply the same umask / uid / gid that the old one had. Once it's moved, you can safely just unlink the running executable.

It's a bit of a hacky workaround (I especially don't like the fact that the application is entirely removed and replaced), but it works.


What I would do:

  1. Launch AppFS
  2. Extract only the executable part into a file (without the FS)
  3. Run the extracted executable giving as parameter the original executable (with FS attached)
  4. Modify the original executable from the extracted program (no problems - the executable is no longer running)
  5. Self delete the extracted program when exiting

What you need to do:

  1. Modify the AppFS application to make it do steps 2, 3, 4 and 5 from the previous enumeration.

I don't see any other way for doing this. This architecture resembles the architecture of a SFX.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜