如何编辑内存中不同进程的文件? [英] How Do I Edit A File From A Different Process Which Is In Memory?

查看:93
本文介绍了如何编辑内存中不同进程的文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想编辑一个通过不同程序加载到内存中的文件。我可以编辑并保存本地硬盘上的实际物理文件,但问题是打开文件的其他程序不会刷新,直到它关闭并重新打开。任何想法/建议将不胜感激。

示例程序A在启动时将3个文件加载到内存中,文件将是库存,债务人和设置。我想使用安装文件并更改条目。我可以将文件保存在磁盘上,但文件是否在内存中,如密码,打印机设置等。保持不变。我正在使用vb.net 2005.

I would like to edit a file which gets loaded into memory via a different program.I can edit and save the actual physical file which is on the local hard drive but the problem is that the other program which opened the file will not refresh until it is closed and re-opened. Any ideas/suggestions will be greatly appreciated.
Example Program A loads 3 files into memory when fired up, the file will be stock , debtors and setup. I want to work with the setup file and change an entry. I can save the file on disk but will the file is in memory things like passwords, printer setting ect. stays the same. I'm using vb.net 2005.

推荐答案

这是可能的,但是非常困难。



你必须知道文件在内存中的位置。但是,很有可能你不会在内存中找到文件作为一个好的单个对象,比如一个字符串。在任何情况下,您都必须知道应用程序如何在内存中表示文件以及如何更改您需要更改的内容,逐字节戳更改。



例如,如果应用程序将一个字符串作为BSTR存储在内存中,您可以在字符串的末尾添加内容,但是您还必须返回并在字符串开头之前为字符串添加新的长度数据。



您可以使用WinAPI函数打开另一个类似文件的进程 OpenProcess [ ^ ]和ReadProcessMemory [ ^ ]。您还可以使用 WriteProcessMemory 写回字节数[ ^ ]。
It's possible, but with extreme difficulty.

You have to know where in memory the "file" is. But, chances are really good you're not going to find the "file" as a nice single object, like a string, in memory. In any case, you have to know how the application represents the file in memory and how to change whatever you need to change, poking your changes in byte by byte.

As an example, if the application stores a string in memory as a BSTR, you can add stuff to the end of the string, but you also have to go back and poke in a new length for the string just before the beginning of the string data.

You can open another process for kind of like a file, using the WinAPI function OpenProcess[^] and ReadProcessMemory[^]. You can also write bytes back with WriteProcessMemory[^].


如果你也可以发布代码,那么它很有帮助。但是,在你的程序上刷新它可能会对你有帮助
it is most likely helpful if you can post also the code.However, refreshing it on your program might help you


这篇关于如何编辑内存中不同进程的文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆