NGEN 处理 .NET 应用程序是否有助于保护其免受逆向工程影响?如果没有我什么时候使用它?

发布于 2024-09-16 17:07:59 字数 53 浏览 4 评论 0原文

如果 Ngen 不保护我的应用程序,我什么时候可以合理地期望在我的职业生涯中使用此应用程序?

If Ngen doesn't protect my application, when would I reasonably expect to use this application in my career?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

2024-09-23 17:07:59

Jeffrey Richter 在他的书中写了一篇很棒的文章,我不知道第三版是否有它,但这是他的一篇很棒的文章 在 2002 年写过关于 Ngen'ing 的文章,至今仍然具有相关性。

亮点:

同时,还有一些潜在的
NGen 文件的问题:

  • 没有知识产权保护。很多人相信
    或许可以发送 NGend
    文件而不传送文件
    包含原始IL代码
    从而保持他们的智力
    财产是秘密。不幸的是,这
    是不可能的。在运行时,CLR
    需要访问程序集
    元数据和 NGend 文件不
    包含元数据。

  • NGend 文件可能会不同步。当 CLR 加载一个
    NGen 的文件比较了一些
    属性关于
    先前编译的代码和
    当前的执行环境。如果有的话
    的属性不匹配,那么
    NGen 的文件无法使用,并且
    使用正常的 JIT 编译过程
    相反。

  • 管理不善。 NGen 的文件不会自动删除
    程序集被反向卸载
    轻松影响 .NET Frameworks
    管理和 XCOPY 部署
    故事。

  • 加载时间性能较差(变基)。当 Windows 加载
    NGend 文件,它检查是否
    文件在其首选基地加载
    地址。如果文件无法加载
    首选基地址,然后是 Windows
    重新定位文件,修复所有
    内存地址引用。这是
    非常耗时,因为
    Windows 必须将整个文件加载到
    内存并修改其中的各个字节
    文件。欲了解更多信息
    变基请参阅我的书:
    为 Microsoft 编写应用程序
    Windows,第四版(微软
    按)。

执行时间性能较差。

在编译代码时,NGen 无法像 JIT 编译器那样对执行环境做出尽可能多的假设。这会导致 NGen.exe 生成带有许多内存引用间接寻址的代码,而这些间接引用对于 JIT 编译的代码来说是不必要的

Jeffrey Richter wrote a great piece in his book, I don't know if the third release has it, but here is a great piece he wrote in 2002 about Ngen'ing which is still relevant.

Highlights:

Meanwhile, there are several potential
problems with respect to NGen'd files:

  • No Intellectual Property Protection. Many people believe that
    it might be possible to ship NGend
    files without shipping the files
    containing the original IL code
    thereby keeping their intellectual
    property a secret. Unfortunately, this
    is not possible. At runtime, the CLR
    requires access to the assemblys
    metadata and the NGend files do not
    contain the metadata.

  • NGend Files Can Get Out-Of-Sync. When the CLR loads an
    NGen'd file it compares a number of
    attributes about the
    previously-compile code and the
    current execution environment. If any
    of the attributes don't match then the
    NGen'd file cannot be used and the
    normal JIT compiler process is used
    instead.

  • Poor Administration. NGen'd file are not automatically deleted when an
    assembly is uninstalled adversely
    affecting the .NET Frameworks easy
    administration and XCOPY deployment
    story.

  • Inferior Load-Time Performance (Rebasing). When Windows loads an
    NGend file, it checks to see if the
    file loads at its preferred base
    address. If the file cant load at its
    preferred base address, then Windows
    relocates the file, fixing-up all of
    the memory address references. This is
    extremely time consuming because
    Windows must load the entire file into
    memory and modify various bytes within
    the file. For more information about
    rebasing please see my book:
    Programming Applications for Microsoft
    Windows, 4th Edition (Microsoft
    Press).

Inferior Execution-Time Performance.

When compiling code, NGen cant make as many assumptions about the execution environment as the JIT compiler can. This causes NGen.exe to produce code with a number of memory-reference indirections that aren't necessary for JIT compiled code

高跟鞋的旋律 2024-09-23 17:07:59

NGen 仅用于编译 IL 以提高性能。您可能需要研究代码混淆以保护应用程序免受逆向工程的影响。

NGen is only for compiling the IL for performance increases. You would want to look into code obfuscation for protecting the app from reverse engineering.

落叶缤纷 2024-09-23 17:07:59

加载速度才是它真正有用的地方。也就是说,它可以实现高达 2000%(是的,这是正确的)的改进。

编辑:

请注意,JIT 化的代码通常比 NGEN 化的代码更快。

Loading speed is all it is really useful for. That said, it can make up to a 2000% (yes that is correct) improvement.

Edit:

Please note that JIT'ed code normally tends to be faster than NGEN'ed code.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文