我怎样才能让mapi系统存根dll将扩展mapi调用传递给我的dll?
由于各种原因(质疑原因对我没有帮助),我想为windows xp实现自己的扩展mapi dll。我现在有一个 dll 框架,只有几个入口点用于测试,但是系统 mapi 存根(c:\windows\system32\mapi32.dll,我已经检查它与 mapistub.dll 相同)不会传递对我的 dll,同时它很乐意将相同的调用传递给 MS Outlook 的 msmapi32.dll(MAPIInitialize、MAPILoginEx 是两个这样的调用)。存根和扩展的mapi dll之间有一些秘密握手,其中存根检查“是的,它是一个扩展的mapi dll”:也许是存在一些我尚未实现的额外入口点,也许是某个函数的返回值, 我不知道。我尝试跟踪我编写的示例应用程序,该应用程序使用 STraceNT 和 ProcessMonitor 调用 MAPIPInitialize,但没有显示任何明显的内容。跟踪显示,存根确实加载了我的 dll,但随后发现秘密武器显然丢失了,并返回错误代码而不是调用我的 dll 的函数。除了 DLL 的导出表中存在 MAPIPInitialize 之外,调用 MAPIPInitialize 还需要什么? GetProcAddress 说它在那里。
我想知道的是如何最小化扩展我的骨架扩展mapi dll,以便存根mapi dll将通过扩展mapi调用传递到我的dll。秘诀是什么?我不想花一周痛苦的时间在 msvc 上对存根行为进行逆向工程。
For various reasons (questioning the reasons is not helpful to me), I'd like to implement my own extended mapi dll for windows xp. I have a skeleton dll now, just a few entrypoints exist for testing, but the system mapi stub (c:\windows\system32\mapi32.dll, I've checked that it's identical to mapistub.dll) will not pass through calls to my dll, while it happily passes the same calls through to MS Outlook's msmapi32.dll, (MAPIInitialize, MAPILoginEx are two such calls). There's some secret handshake between the stub and the extended mapi dll wherein the stub checks that "yup, it's an extended mapi dll": maybe it's the presence of some additional entrypoints I haven't implemented yet, maybe it's the return value from some function, I don't know. I've tried tracing a sample app I wrote that calls MAPIInitialize with STraceNT and ProcessMonitor but that didn't show anything obvious. Tracing has shown that indeed the stub loads my dll, but then finds the secret sauce is missing apparently, and returns an error code instead of calling my dll's function. What more could be needed for calling MAPIInitialize than the presence of MAPIInitialize in my dll's exports table? GetProcAddress says it's there.
What I'd like to know is how to minimally extend my skeleton extended mapi dll so that the stub mapi dll will pass through extended mapi calls to my dll. What's the secret sauce? I'd rather not spend a painful week in msvc reverse engineering the stub behavior.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
通过加载 MS 的调试符号并深入调试器中的存根库代码来解决这个问题。存根库不加载“MAPIInitialize”,而是加载“MAPIInitialize@4”。我将 MAPIInitialize@4=_MAPIInitialize@4 添加到 .def 文件的 EXPORTS 部分,现在一切正常。
顺便说一句,为了获取系统库的符号,不要下载MS的XP SP3调试符号包,这些符号没有正确更新,并且无法在调试器中工作。相反,将 VS 指向 MS 的在线符号服务器 (http://msdl.microsoft.com/download/symbols) 并让 VS 将符号提取到本地符号缓存目录。
Figured it out by loading MS's debugging symbols and diving in to the stub library code in the debugger. The stub library doesn't load "MAPIInitialize", it loads "MAPIInitialize@4". I added MAPIInitialize@4=_MAPIInitialize@4 to my EXPORTS section of the .def file and all works fine now.
By the way, in order to get symbols for system libraries, don't download MS's debugging symbol package for XP SP3, the symbols were not updated correctly and won't work in the debugger. Instead point VS to MS's online symbol server (http://msdl.microsoft.com/download/symbols) and let VS slurp the symbols to a local symbol cache directory.