如何将配置信息放入可执行文件中? [英] How to put configuration information inside the executable?

查看:96
本文介绍了如何将配置信息放入可执行文件中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我们想在Delphi编译器生成的可执行文件中存储关键信息,例如密码和服务器地址,我们如何做到这一点,而又不知道最终的可执行文件大小和二进制结构(如文件末尾)例如?

If we want to store critical information, like passwords and server addresses, inside the executable file generated by the Delphi compiler, how can we do that, without knowing the final executable size and binary structure, like at the end of the file for example?

旁注:

Side note:

要存储的文本已经加密;在某些计算机中,Windows不允许访问注册表中的内容,特别是在用户不是管理员的情况下,并且有黑客可以监视注册表的更改,并且精明的用户可以找到新的Windows注册表项.

The text to be stored is already encrypted; and in some computers the windows don't give access to write in the registry, specially when the user is not administrator, and there are hacks to monitor registry changes and the smart user can find the new windows registry entry.

评论

为什么这个问题被否决?这是可以实现的!对于大多数人来说,如果不感兴趣的话就不会测量.

Why this question was down voted? This is achievable! Doesn't meter if not interesting for most people.

我想到了BIOS和其他可升级的固件,例如可自我更新的卫星电视信号解码器.那怎么可能?

I think about the bios and other firmware upgradeable, like satelite tv signal decoders that update themselves. How is that possible?

推荐答案

创建字符串表资源是一种方法.

Create a string table resource is one way.

创建一个文本文件.说secretstuff.rc(必须具有.rc扩展名) 里面有这样的东西.

Create a text file. say secretstuff.rc (has to have .rc extension) with something like this in it.

STRINGTABLE
{
  1,"This is my encrypted password in say Base64"
}

使用BRCC32将其编译为.res文件.

Compile it to a .res file with BRCC32.

使用编译器指令将其包含在相关代码中

Include it in the relevant code with a compiler directive

{$R secretstuff.res}

之后,您可以使用TResourceStream进行访问.

After that you access with TResourceStream.

如果要更好地进行管理,将它们填充到dll中而不是exe中可能是明智的选择,则可以通过提供新版本的dll来进行更新.

If you want to manage it a bit better might be wise to stuff them in a dll instead of an exe, then you can update things by delivering a new version of the dll.

有一个带有更多细节的示例,另一个目的却是相同的原理,此处

There's an example with a it more detail, another purpose but same principle here

这篇关于如何将配置信息放入可执行文件中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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