修正了在.NET程序中的错误得不到源错误、程序、修正了、NET

2023-09-03 06:29:04 作者:屿浪

我有一个程序,我经常使用的是用.NET。 这个程序有一个小虫子,这是非常讨厌,开发者的应用程序是无处可寻。

I have a program i frequently use that is made with .NET. This program has a small bug that is very annoying and the developer to the app is nowhere to be found.

我已经找到了反光问题的位置,只是想在这里补充一个if语句,然后重新编译程序。

I have found the location of the problem in reflector and just want to add a single if-statement here and then recompile the program.

什么是做到这一点的最简单的方法是什么?

What is the easiest way to do this?

我使用导出功能的反射都尝试,但它似乎并没有很好地工作。对于使用-指令的例子很多失踪,被投来回整数枚举也无法正常出口。我相信我可以与一些工作,解决这个问题,但我不知道是否有任何更简单的方式来做到这一点。

I have tried using the export-function in reflector but it doesn't seem to work perfectly. For example alot of using-directives are missing and enums that are cast back and forth to ints are also not exported properly. I believe i can fix this with some work but i'm wondering if there are any easier way to do this.

更新:通过这样解决的:

该方案是一个单一文件的可执行文件

The program is a single file executable

找到用C#-view反射器的bug。然后切换到IL-观点看,你应该寻找什么,在步骤5中。 打开你想改变与ILDASM程序 preSS转储,并选择一个空文件夹,默认设置为我工作。 找到此文件夹中的.il内文件并打开任何文本编辑 找到步骤1中的code。 在新的code替换它,在我的情况下,我不得不用一个简单的返回替换功能的所有内容(IL_0000:R​​ET)。我不认为所有的补丁会这么容易。 从第3步打开文件夹中的commandwindow 运行ILASM,我还必须包括一些资源从原来的exe文件。这些都是与ILDASM自动输出。我用这个ILASM像这样的C:\ WINDOWS \ Microsoft.NET \框架\ V2.0.50727 \ ilasm.exetest.il /resource=test.res /output=FixedProgram.exe Find the bug in reflector with C#-view. Then switch to IL-view to see what you should look for in step 5. Open the program you want to change with ildasm Press dump and select an empty folder, default settings worked for me. Find the .il file in this folder and open with any texteditor Find the code from step 1. Replace it with new code, in my case i just had to replace all the contents of a function with a simple return (IL_0000: ret). I don't think all fixes will be this easy. Open a commandwindow in the folder from step 3 Run ilasm, i also had to include some resources from the original exe. These are automatically output with ildasm. I used this ilasm like this "C:\Windows\Microsoft.NET\Framework\v2.0.50727\ilasm.exe" test.il /resource=test.res /output=FixedProgram.exe

完成!我只使用了固定的程序了几分钟,但现在它似乎之前,工作就像除了错误:)

Done! I've only used the fixed program some minutes right now but it seems to work just like before except for the bug :)

我也遇到了一些问题,应用程序设置。在的%APPDATA%\ ProgramName中的有一个名为像* ProgramName.exe_Url_qa5i3p42aomuvoxpuxuficvbmngksgjs *,所有设置都保存的文件夹。我的新的可执行文件创建一个新的文件夹,这样不同的随机字母在年底使用默认设置。要复制您使用的设置之前只是旧的文件夹中的所有内容复制到新的。

I also ran into some problems with the application settings. In %appdata%\ProgramName there was a folder called something like *ProgramName.exe_Url_qa5i3p42aomuvoxpuxuficvbmngksgjs* where all settings are stored. My new executable created a new folder like this with different random letters at the end and with the default settings. To copy the settings you used before just copy all the contents of the old folder to the new one.

推荐答案

如果程序很简单,在理论上可以使用反射到整个程序反向回C#,进行更改和重新编译。

If the program is simple, in theory you could use reflector to reverse the entire program back to C#, make the change and recompile it.

另外,您可以尝试像 ILDASM ,它应该让你提取白细胞介素,使你的改变(MSIL),然后重新组装(使用的 ILASM )。显然,要做到这一点,你必须弄清楚如何写你的IL变化,所以你可能需要做一些试验,看看如何if语句进行编译。

Alternatively you could try a tool like ILDasm, which should allow you to extract the IL, make your change (in MSIL), and re assemble (using ILAsm). Obviously to do this you'll have to figure out how to write your change in IL, so you'll probably have to do some experimenting to see how if statements compile.

我怀疑两者都将采取插科打诨得到重新编译工作的相当多。

I suspect both will take quite a bit of messing around to get the recompile to work.

祝你好运。

如果你得到它的工作,回来后,让我知道,我会在你如何做这个很感兴趣。

If you get it to work, post back and let me know, I'd be quite interested in how you did this.