修改正在运行的可执行的内容资源

修改正在运行的可执行的内容资源

本文介绍了修改正在运行的可执行的内容资源的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所有,

我保存在我的资源应用程序设置。当我的程序第一次加载,我读使用WinAPI的指定资源。然后我分析检索字节的数据。这完美的作品对我来说。

I store my application settings in a resource. When my program first loads, I read the specified resource using WinAPI. I then parse the retrieved byte data. This works flawlessly for me.

现在让我们假设一个用户在改变我的应用程序的设置。他/她检查CheckBox控件。我想更新的设置保存到我的资源。然而,似乎我的应用程序运行时,我给UpdateResource调用将无法工作。我不能修改我的资源数据,即使它是相同的大小。

Now let's say that a user alters a setting in my application. He/she checks a checkbox control. I would like to save the updated setting to my resource. However, it seems that my call to UpdateResource will not work while my application is running. I can't modify my resource data even though it is the same size.

首先,它是可以修改正在运行的图像的资源数据?第二,如果这是不可能的,做什么替代我有我的应用程序内部存储设置

First, is it possible to modify a running image's resource data? Second, if that is not possible, what alternatives do I have for storing settings internally within my application?

请注意:我必须有我跑步可执行文件中的设置。他们不能上的硬盘或者在注册表中。请不要甚至认为,作为一个选项。

NOTE: I must have the settings within my running executable. They cannot be on the harddrive or in the registry. Please don't even suggest that as an option.

推荐答案

这是100%可以编写自修改代码。这只是不是很容易做到的。

It is 100% possible to write self-modifying code. It's just not very easy to do.

当您启动您的可执行文件时,Windows映射在内存中。这基本上锁定该文件并在运行时防止编辑。你可以很明显,取消映射程序(通过使用NTDLL无证功能)。当你的文件是未映射,您将能够将更改写入它

When you launch your executable file, windows maps it in memory. This essentially locks the file and prevents edits while it is running. You can, obviously, unmap your program (by using an undocumented function in ntdll). When your file is unmapped, you will be able to write changes to it.

这是有点类似于你想要做什么:

This is kinda similar to what you want to do: http://www.johnfindlay.plus.com/lcc-win32/asm/SelDelNT.htm

而不是删除它,很明显,你要做出改变。疯狂背后的想法是一样的 - 你必须取消映射文件

Instead of deleting it, obviously, you want to make changes. The idea behind the madness is the same - you must unmap the file.

这篇关于修改正在运行的可执行的内容资源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-05 13:00