.net dll是否具有C ++ dll中的dll之类的入口点 [英] does .net dll have an entry point like dll in c++ dll

查看:135
本文介绍了.net dll是否具有C ++ dll中的dll之类的入口点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我真的不确定.net dll是否也像一般的c ++ dll一样具有入口点。
如何查看.net dll是否具有入口点。

I'm really not sure whether .net dll also have entry point like c++ dll generally have. How can i see if .net dll have entry point or not.

我读到某处WIN32 dll可以具有入口点,.net类-libraries不要。

I read somewhere that a WIN32 dlls can have entry-points, dot-net class-libraries dont.

谢谢

推荐答案

这是一个晦涩的问题主题,我将以惊人的速度进行介绍。每个.NET程序集都有一个 unmanaged 入口点,其中5个字节的机器代码(如果为x64构建,则为9字节)用作PE32可执行文件头中标记的入口点。除了JMP指令外,EXE跳到_CorExeMain(),DLL跳到 _ CorDllMain()。这些函数位于mscoree.dll中,可确保加载并初始化CLR,以便可以执行托管代码。

It is an obscure subject, I'll go through it at breakneck speed. Every .NET assembly has an unmanaged entrypoint, 5 bytes of machine code (9 if built for x64) that serve as the entrypoint marked in the PE32 executable file header. Nothing but a JMP instruction, an EXE jumps to _CorExeMain() and a DLL jumps to _CorDllMain(). These functions are located in mscoree.dll and ensure that the CLR is loaded and initialized so it can execute managed code.

这些入口点有助于运行托管程序而无需启动虚拟机主机。避免需要mono.exe或java.exe。它们在现代Windows版本上实际上不再使用,操作系统已意识到包含.NET清单的可执行文件,并且加载程序将作业再次传递给加载程序垫片mscoree.dll。这种认识对于实现相当大的窍门(从包含32位PE32的EXE中架设64位进程)非常重要。标头。 Mscoree.dll修补内部加载程序数据结构以完成此任务。

These entrypoints help to run managed program without having to start the VM host explicitly. Avoids the need for, say, mono.exe or java.exe. They are not actually used anymore on modern Windows versions, the OS has awareness of an executable file containing a .NET manifest and the loader passes the job to a loader shim, mscoree.dll again. This awareness is necessary to implement the considerable trick of erecting a 64-bit process out an EXE that contains a 32-bit PE32 header. Mscoree.dll patches internal loader data structures to accomplish this feat.

每个.NET程序集还包含一个 managed 入口点,该入口点在清单标题中列出。 。 CLR在加载程序集后立即调用。 EXE总是有一个,它指向Main()方法,并且编译器确保您不会忘记编写一个。 DLL 可能有一个,例如,混合模式程序集总是有一个。指向位于其中的模块初始化程序< Module> 类,C ++ / CLI编译器使用它来确保在任何托管代码可以执行之前初始化CRT(C运行时库)。

Each .NET assembly also contains a managed entrypoint, listed in the manifest header. Called by the CLR right after it loaded the assembly. An EXE always has one, it points to the Main() method and the compiler ensures that you can't forget to write one. A DLL might have one, a mixed-mode assembly always has one for example. Points to a module initializer located in the <Module> class, the C++/CLI compiler uses it to ensure that the CRT (C runtime library) is initialized before any managed code can execute.

这篇关于.net dll是否具有C ++ dll中的dll之类的入口点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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