Thunk 和 ATL Thunk?

发布于 2024-09-10 23:56:26 字数 100 浏览 2 评论 0原文

有人可以向我解释一下 Thunk 是什么吗?

和 ATL Thunk?

我知道 thunk 与 vtbl 和代码执行有关以找到正确的函数指针。我说得对吗?

Can someone explain to me what a Thunk is?

and an ATL Thunk?

I know a thunk has something to do with the vtbl and execution of code to find the right function pointer. Am I right?

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

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

发布评论

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

评论(1

岁月流歌 2024-09-17 23:56:26

它是从根本上改变执行环境的一段适配器代码的通用术语。我第一次看到它是在 16 位到 32 位 Windows 过渡期间使用的,thunk 用于允许在 16 位模式下运行的代码调用 32 位代码。

ATL thunks 也有类似的东西。它知道如何将 Windows 回调(一个只有窗口句柄来区分上下文的纯 C 执行环境)转换为类对象上的虚拟方法调用。 thunk 负责将窗口句柄映射到包装它的 ATL 类实例,并将消息号转换为相应的虚拟方法。

It is a generic term for a piece of adapter code that fundamentally changes the execution environment. I saw it first being used during the 16-bit to 32-bit Windows transition, a thunk was used to allow code that was running in 16-bit mode to call 32-bit code.

Something similar for ATL thunks. It knows how to turn a Windows callback, a pure C execution environment with nothing but a window handle to distinguish the context, into a virtual method call on a class object. The thunk takes care of mapping the window handle to the ATL class instance that wraps it, and translate the message number to the corresponding virtual method.

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