Is it OK to remove .property statements from ILAsm files for production use?

…衆ロ難τιáo~ 提交于 2020-01-04 17:19:10

问题


Still working on my obfuscation program based on modifying ILAsm files. (Ref. Which C# method names should not be obfuscated? )

In looking at the ILAsm code, I get the impression that the .property statements aren't used for anything, at least not for program execution. Am I right in thinking they are only there to provide metadata for Visual Studio? And if so, is it OK to simply remove them when the ILAsm code will only be used to produce production modules that will never be used with Visual Studio?


回答1:


You're correct that the fact something is declared as a property does not affect program execution. As the book Inside Microsoft .NET IL Assembler states in its introduction to the chapter concerning properties, the JIT compiler and execution engine are completely unaware of properties, and no IL instructions make any reference to the property concept.

Note that Visual Studio is not the only consumer of metadata. If you strip .property and reassemble, you'll have the getter and setter methods, but it obviously isn't a property any more. The most obvious example of where this becomes a problem : what if an instance of an object gets handed off to another method which uses reflection to invoke each property on the class? The properties would not be found and run-time behavior has changed as a result of the proposed obfuscation method.

Of course, scenarios such as reflection and serialization are a common gotcha with obfuscation tools, as was discussed in your previous question. So, what I'm saying is, it is problematic, but its problematic in a similar set of scenarios as those discussed in your other thread -- particularly those scenarios where metadata is being consumed or serialization is being performed at run-time.

The latest edition of the book I mentioned above has a different name: Expert .NET 2.0 IL Assembler; it may be a useful reference to you. Compiling for the .NET Common Language Runtime may also be valuable.



来源:https://stackoverflow.com/questions/5761202/is-it-ok-to-remove-property-statements-from-ilasm-files-for-production-use

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!