gpt4 book ai didi

visual-c++ - 为什么ucrtbase会导出_CxxThrowException?

转载 作者:行者123 更新时间:2023-12-05 03:10:24 29 4
gpt4 key购买 nike

为什么ucrtbase.dllvcruntime140.dll根据 Dependency Walker,它们导出的某些功能是否重叠?

免责声明:我目前纯粹出于学术兴趣。

我目前正在尝试了解 Microsoft Visual-C++ CRT 相关 DLL 文件的布局。在此处查找 UCRT 信息和一般文件:

简而言之,对于普通的 C++ 应用程序,您在运行时具有这些(顶层)DLL 依赖项:

  • ucrtbase.dll - “编译器独立”的东西
  • vcruntime<ver>.dll - “依赖于编译器”的东西
  • msvcp<ver>.dll - C++ 标准库

从这些信息中可以突出显示的是:

来自博客条目:

... split the CRT into two logical parts: The VCRuntime, which contained the compiler support functionality required for things like process startup and exception handling ...

来自 MSDN 页面:

The vcruntime library contains Visual C++ CRT implementation-specific code, such as exception handling and debugging support, runtime checks and type information, implementation details and certain extended library functions. This library is specific to the version of the compiler used.

在使用 Dependency Walker 浏览 DLL 时,我注意到 ucrt 和 vcruntime 都导出函数 _CxxThrowException .如果您曾经查看过 vc++ 堆栈跟踪,那么这个函数就是老熟人了:

Builds the exception record and calls the runtime environment to start processing the exception.

我很惊讶地发现这是从 ucrtbase.dll 导出的因为 - 正如上面的两个引号所表明的那样 - 我曾认为这种机制完全属于编译器特定方面的事物。

在撰写本文时,我注意到其他一些重叠:极少数标准 C 库函数(memcpy,...,strstr,...)也从 vcruntime140.dll 中导出。虽然我原以为他们只会住在ucrtbase .

那么这里发生了什么,我可以从中学到什么?

最佳答案

通用 CRT (ucrtbase.dll) 包含 VCRuntime 的私有(private)副本,供 Windows 操作系统组件使用。 VCRuntime 的私有(private)副本是操作系统的内部实现细节,可能随时更改(即,不提供任何应用程序兼容性保证。

在任何情况下都不要使用通用 CRT 的这些导出。 (Windows SDK 中没有库为这些导出提供可链接的符号,因此不小心使用它们是不可能的。)

关于visual-c++ - 为什么ucrtbase会导出_CxxThrowException?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40184496/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com