打开+在记事本中保存 .exe 文件使其损坏
我刚刚发布了这个简单的控制台应用程序,该应用程序应该显示一个文本框,其中包含名为“userID”的设置值,值为 1001。这就像一个魅力。现在我需要的是在编辑器之外从记事本等更改此值。
当我多次打开应用程序时,其中存在无意义的内容(& o! -å Þþþ,o" Ü+)等,但快速(ctrl + F) 我找到了值 1001,并将其更改为其他整数,然后再次运行该应用程序,但它失败了,甚至没有给出任何有用的错误消息。应用程序的未损坏版本,没有更改任何内容,然后从记事本保存,并且它也已损坏,记事本似乎无法打开某些字符或其他内容,我是否需要以某些特定文本发布该应用程序。 unicode 语言或其他什么?
非常感谢:)我知道这听起来像一个愚蠢的应用程序,但这只是一个概念测试:)
我为此使用 vb.net
I just published this simple console application that is supposed to show a textbox with the value of a setting called "userID" with value 1001. This works like a charm. Now what I need is to change this value outside the editor, from notepad etc.
When I open the application a lot in there is non-sence (& o! -å Þþþ,o" Ü+) etc. but with a quick (ctrl + F) I found the value 1001, and changed this to some other integer. I ran the application again, and it failed, didn't even give any userful error-message. At a point I tried just opening a newly published non-corrupted version of the application, didn't change anything, then saved from notepad, and it were also corrupted. It seems like notepad can't open some characters or something. Do I need to publish the application in some specific text-unicode language or something?
Help much appreciated :) I know it sounds like a stupid application, but it is just a test of concept :)
I use vb.net for this
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您需要使用二进制文件编辑器(也称为十六进制编辑器)。如果您以二进制模式打开文件,Visual Studio 就可以做到这一点。
记事本是一个文本编辑器,当您用它保存二进制文件时,它会以各种方式搞乱事情,最明显的是用 \r\n 替换 \n。
此外,关于你的问题的其他一切都非常可怕。为什么要编辑 EXE 文件?
You need to use a binary file editor (also called hex editor). Visual Studio can do that if you open a file in binary mode.
Notepad is a text editor, when you save a binary file with it it will mess things up in all kinds of ways, most obvious being replacing \n with \r\n.
Also everything else about your question is plain scary. Why are you editing an EXE file??
记事本旨在读取和写入文本文件。将任意二进制文件(如可执行文件)加载到记事本中可能会损坏该文件。
您可能正在寻找的通常称为“十六进制编辑器”。
Notepad is designed to read and write text files. Loading an arbitrary binary file (like an executable) into Notepad will probably corrupt the file.
What you're probably looking for is commonly called a "hex editor".
记事本用于编辑文本文件,不能很好地处理二进制文件,即包含各种非文本或不可见 ASCII 代码的文件。
手动更改 EXE 不起作用。您需要一些外部配置文件(例如 XML 或简单的文本文件),您将在其中存储此设置的值并从中读取。
Notepad is made for editing text files and does not handle well binary files, i. e. files that have all kinds of non-text or invisible ASCII codes in them.
Manually changing the EXE won't work. You need some external configuration file (like an XML or a simple text file) where you will store the value of this setting, and read from it.
您是否考虑过修改代码文件,然后运行编译器 通过 Process.Start
Instead of editing an Exe have you considered modifying the code file and then running the compiler via Process.Start