views:

57

answers:

1

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.

A: 

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.

Bogatyr