Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

542 lines
14 KiB

  1. /*
  2. * _MAPIPRV.H
  3. *
  4. * MAPIX subsystem-wide definitions
  5. */
  6. #ifdef __cplusplus
  7. extern "C" {
  8. #endif
  9. #ifdef OLD_STUFF
  10. #if defined(WIN32) && !defined(MAC) && !defined (COINITEX_DEFINED) && !defined(NT_BUILD)
  11. // COM initialization flags; passed to CoInitializeEx.
  12. // Doc'ed by OLE but not in their header. Not on Windows 95 yet.
  13. typedef enum tagCOINIT
  14. {
  15. COINIT_MULTITHREADED = 0, // OLE calls objects on any thread.
  16. COINIT_SINGLETHREADED = 1, // OLE calls objects on single thread.
  17. COINIT_APARTMENTTHREADED = 2 //$ MAIL: OLE apartment model.
  18. } COINIT;
  19. STDAPI CoInitializeEx(LPMALLOC pMalloc, ULONG);
  20. #endif /**/
  21. #endif
  22. #ifndef MAC
  23. typedef struct ProcessSerialNumber {
  24. unsigned long highLongOfPSN;
  25. unsigned long lowLongOfPSN;
  26. } ProcessSerialNumber;
  27. #endif
  28. #define PSN ProcessSerialNumber
  29. /*
  30. * IsEqualIID
  31. *
  32. * This redefinition removes a dependency on compobj.dll.
  33. * //$ It uses a byte-order-insensitive comparison on data that is
  34. * //$ inherently byte-order-sensitive. If we ever wind up
  35. * //$ remoting MAPI interfaces directly, it will break.
  36. */
  37. #undef IsEqualIID
  38. #define IsEqualIID(i1,i2) IsEqualMAPIUID((i1), (i2))
  39. #ifndef CharSizeOf
  40. #define CharSizeOf(x) (sizeof(x) / sizeof(TCHAR))
  41. #endif
  42. // explicit implementation of CharSizeOf
  43. #define CharSizeOf_A(x) (sizeof(x) / sizeof(CHAR))
  44. #define CharSizeOf_W(x) (sizeof(x) / sizeof(WCHAR))
  45. /*
  46. * Shared memory header structure. This is the only thing that must
  47. * appear at a fixed offset in the shared memory block; anything else
  48. * can move.
  49. *
  50. * //$ the shared profile name is for a temporary implementation of
  51. * //$ piggyback logon
  52. */
  53. #define ghnameMAPIX ((GHNAME)0x4d417049) // Name of Global Heap
  54. #define cbGHInitial ((DWORD) 0x00002000) // Initial size of Global Heap
  55. #define cKeyIncr 0x10 // # of notif key slots to allocate
  56. typedef struct
  57. {
  58. ULONG cRef;
  59. GHID ghidSharedProfile; // for fake piggyback logon
  60. UINT cRefHack;
  61. // Spooler stuff
  62. #if defined(WIN32) && !defined(MAC)
  63. DWORD dwSpoolerPid; // spooler's process handle
  64. #elif defined(MAC)
  65. PSN psnSpooler; // spooler's process serial number
  66. #else
  67. HTASK htaskSpooler; // spooler's task handle
  68. #endif
  69. HWND hwndSpooler; // spooler's window handle
  70. UINT cRefSpooler; // maintained but not used
  71. UINT uSpooler; // spooler status
  72. DWORD dwSecurePid; // security pid
  73. LONG lSecureId; // security id
  74. // Subsystem stuff
  75. GHID ghidTaskList; // linked list of active MAPI callers
  76. GHID ghidProfList; // linked list of profile info
  77. // Notification stuff
  78. USHORT cKeyMac; // count of registered keys
  79. USHORT cKeyMax; // size of key offset array
  80. GHID ghidKeyList; // list of registered keys
  81. // (array of offsets)
  82. ULONG ulConnectStub; // stub spooler registration
  83. GHID ghidOptionList; // Transport registration stuff
  84. // Linked-list of per message & per
  85. // recipient options registered by XPs
  86. GHID ghidUIMutexList; // Linked list of UI mutexes
  87. GHID ghididmp; // Offset of session/identity mapping
  88. ULONG cidmp; // Count of mappings
  89. ULONG cidmpMax; // Available mappings
  90. GHID ghidMsgCacheCtl; // Simple MAPI MsgID cache control struct
  91. } SHDR, FAR *LPSHDR;
  92. /*
  93. * STAG
  94. *
  95. * Sesstion tag -- tags a session with the processes that have logged
  96. * into the profile represented by the session
  97. */
  98. typedef struct _STAG
  99. {
  100. union
  101. {
  102. DWORD pid;
  103. HTASK htask;
  104. PSN psn;
  105. };
  106. } STAG, FAR * LPSTAG;
  107. /*
  108. * SPROF
  109. *
  110. * Shared profile session information.
  111. */
  112. typedef struct
  113. {
  114. ULONG cRef; // Number of sessions active
  115. GHID ghidProfNext; // Next item in chain
  116. // Profile / session flags
  117. USHORT fSpoolerInitDone : 1; // TRUE <=> all XPs are loaded
  118. USHORT fSharedSession : 1; // TRUE <=> shared session is on this profile
  119. USHORT fDeletePending : 1; // TRUE <=> delete profile when zero refcount
  120. USHORT fCleanedProfile : 1; // TRUE <=> already removed temp sections
  121. USHORT wPad;
  122. GHID ghidPBdata; // secret stuff for piggyback logon
  123. ULONG cRowMax; // count of status rows
  124. GHID ghidRowList; // array of offsets to shared row data
  125. CHAR rgchName[cchProfileNameMax+1];
  126. USHORT cstagMac; // count of stags
  127. USHORT cstagMax; // space available for stags
  128. GHID ghidstag; // array of stags held by the session
  129. } SPROF, FAR *LPSPROF;
  130. #ifdef MAC
  131. typedef LRESULT (STDAPICALLTYPE NOTIFYPROC)(HWND, UINT, WPARAM, LPARAM);
  132. typedef struct _tagNOTIFY {
  133. NOTIFYPROC *wndProc;
  134. PSN psn;
  135. } NOTIFY, *LPNOTIFY;
  136. #endif
  137. /*
  138. * STASK
  139. *
  140. * Keeps track of outstanding notifications for a particular
  141. * process. The notification parameters live in shared memory, and
  142. * are hung on a chain from this structure.
  143. *
  144. * The flag 'fSignalled' is set when a message is posted to the
  145. * target task's notification window, and cleared when its
  146. * notification queue is emptied. So at most one message at a
  147. * time is outstanding to a given task.
  148. *
  149. * There is also some auxiliary info like the task's module name,
  150. * for use in debugging.
  151. */
  152. #define MAPI_TASK_SERVICE 0x0001 // task was started as a service
  153. #define MAPI_TASK_SPOOLER 0x0002 // MAPI spooler
  154. #define MAPI_TASK_PENDING 0x0004 // spooler not up yet
  155. //#define MAPI_TASK_SIGNALLED 0x0008
  156. typedef struct
  157. {
  158. GHID ghidTaskNext; // link to next STASK in chain
  159. // Task ID info
  160. #ifndef MAC
  161. HWND hwndNotify; // notification window handle
  162. #else
  163. LPNOTIFY hwndNotify; // Not an hwnd at all!
  164. #endif
  165. CHAR szModName[16]; // module name of running process (ansi only)
  166. #ifdef NT
  167. DWORD dwPID; // If process was started as a service this will contain PID
  168. #endif
  169. UINT uFlags; // Information about task, ie, it's a service
  170. BOOL fSignalled; // TRUE <=> message in queue
  171. UINT cparmsMac; // # of notifications (SPARMS)
  172. UINT cparmsMax; // # of notification slots allocated
  173. GHID ghidparms; // offset to list of SPARMS
  174. } STASK, FAR *LPSTASK;
  175. /*
  176. * LIBINFO
  177. *
  178. * Used to keep track of DLLs loaded. Stores the name of the Dll and
  179. * associated handle.
  180. */
  181. typedef struct
  182. {
  183. LPSTR szDllName; // Name of provider Dll (ANSI only)
  184. HINSTANCE hInstDll; // Handle to the loaded Dll
  185. } LIBINFO, FAR *LPLIBINFO;
  186. /*
  187. *
  188. * Access to proxy and stub internals is restricted to the remoting code only.
  189. * The rest should only access the IUnknown.
  190. *
  191. */
  192. typedef LPUNKNOWN LPPROXY;
  193. typedef LPUNKNOWN LPSTUB;
  194. /*
  195. * Instance global data for mapix.dll -- that is, information
  196. * associated with a particular process.
  197. */
  198. typedef struct
  199. {
  200. BOOL fTriedDlg; // TRUE <=> tried to load dialog DLL
  201. HINSTANCE hinstDlg; // dialogs DLL instance handle
  202. #ifdef OLD_STUFF
  203. MAPIDLG_ScInitMapidlg *pfnInitDlg; // dialog fn proc address
  204. JT_MAPIDLG jtDlg; // dialog functions jump table
  205. LPSESSOBJ psessobj; // chain of session objects
  206. LPIPA pipa; // chain of ProfAdmin objects
  207. HINSTANCE hinstProfile; // profile DLL instance handle
  208. LPPRPROVIDER lpPRProvider; // -> profile provider object
  209. #endif
  210. #if 0 //$ Not needed with the new deferred provider unloading at deinit time
  211. HINSTANCE hLibrary; // latest library to be released
  212. #else //$ Deferred provider unloading support
  213. UINT cLibraries; // number of providers loaded
  214. LPLIBINFO lpLibInfo; // array of info on loaded providers
  215. #endif
  216. //$New SMem stuff
  217. HGH hghShared; // handle to the global heap
  218. GHID ghidshdr; // offset of shared header struct (the Root)
  219. //$New SMem stuff
  220. //$Old SMem stuff
  221. // PSMEM psmem; // shared memory block
  222. // LPSMALLOC psmalloc; // shared heap manager
  223. // UINT ibshdr; // offset of shared header struct
  224. //$Old SMem stuff
  225. ULONG ulXPStatus; // catches transport status row notifs
  226. #ifndef MAC
  227. HWND hwndNotify; // multi-process notification info
  228. #else
  229. LPNOTIFY hwndNotify; // Not an hwnd at all!
  230. #endif
  231. #ifdef OLD_STUFF
  232. LPADVISELIST padviselist; // open notifs on session
  233. #endif
  234. #if defined(WIN32) && !defined(MAC)
  235. HANDLE htNotify; // thread handle of notification thread
  236. DWORD tidNotify; // thread ID of notification thread
  237. HANDLE heventNotify; // event handle for thread sync
  238. SCODE scInitNotify; // for use during startup only
  239. #endif
  240. #ifdef OLD_STUFF
  241. HMODULE hmodWmsfr; // form registry lib handle
  242. LPFNMAPIREGCREATE pfnCreateObject; // form registry init function
  243. LPMESSAGEFILTER pMsgFilter; // IMessage Filter interface
  244. LPUNKNOWN pUnkPSFactory; // Proxy Stub Factory's IUnknown
  245. LPPROXY pProxyListHead; // First of a chain of active proxy objects
  246. LPSTUB pStubListHead; // First of a chain of active stub objects
  247. #endif
  248. #if defined(WOW)
  249. LPVOID pvConnection1632; // The 16 to 32 bit connection
  250. #endif
  251. #if defined(WIN16) && !defined(WOW)
  252. HWND hwndMarshal; // Window to defer release on an unmarshalled
  253. // interface to workaround 16bit CoMarshalInterface
  254. // bug - see SqlGuest:Exchange #14416.
  255. #endif
  256. LPVOID psvctbl; // Spooler's service scheduler
  257. LPVOID pvSentinel; // Variables ABOVE this point are zeroed
  258. // at the last MAPIUninitialize; those
  259. // BELOW this point are not.
  260. int cRef; // reference count for this instance
  261. LPMALLOC pmallocOrig; // allocator from OLE - CoGetMalloc()
  262. HLH hlhProvider; // heap for Provider MAPIAllocateBuffer/More
  263. HLH hlhInternal; // heap for internal allocations
  264. ULONG ulInitFlags; // MAPIInitialize Flags for notification
  265. // support
  266. HMODULE hmod; // module handle of running process
  267. CHAR szModName[16]; // module name of running process (ansi only)
  268. #ifdef WIN16
  269. HINSTANCE hinstApp; // calling app's instance handle
  270. #endif
  271. #ifdef WIN32
  272. HANDLE heSecure; // spooler blocking mutex
  273. #endif
  274. CRITICAL_SECTION cs; // critical section data
  275. } INST, FAR *LPINST;
  276. //
  277. // Generic internal entry ID structure
  278. //
  279. #pragma warning (disable: 4200)
  280. typedef struct _MAPIEID {
  281. BYTE abFlags[4];
  282. MAPIUID mapiuid;
  283. UNALIGNED BYTE bData[];
  284. } MAPI_ENTRYID;
  285. typedef UNALIGNED MAPI_ENTRYID *LPMAPI_ENTRYID;
  286. extern HINSTANCE hinstMapiX;
  287. extern HINSTANCE hinstMapiXWAB;
  288. extern BOOL fGlobalCSValid;
  289. extern BOOL bDNisByLN;
  290. extern TCHAR szResourceDNByLN[32];
  291. extern TCHAR szResourceDNByCommaLN[32];
  292. extern TCHAR szResourceDNByFN[32];
  293. extern BOOL bPrintingOn;
  294. extern HANDLE ghEventOlkRefreshContacts;
  295. extern HANDLE ghEventOlkRefreshFolders;
  296. #ifdef OLD_STUFF
  297. #pragma warning (default: 4200)
  298. // Hack structure for shared session
  299. typedef struct
  300. {
  301. UINT cb; // all-inclusive
  302. UINT cbsd;
  303. BYTE ab[1];
  304. } SESSHACK, FAR *LPSESSHACK;
  305. // Globally defined notification keys
  306. extern struct _NOTIFKEY_notifkeyXPStatus notifkeyXPStatus;
  307. extern struct _NOTIFKEY_notifkeyOlaf notifkeyOlaf;
  308. // Globally defined UIDs
  309. extern MAPIUID muidProviderSection;
  310. extern MAPIUID muidStoreWrap;
  311. extern MAPIUID muidStatusWrap;
  312. extern MAPIUID muidOOP;
  313. #if defined(WIN32) && !defined(MAC)
  314. #ifndef DATA1_BEGIN
  315. #include "mapiperf.h"
  316. #endif
  317. #pragma DATA1_BEGIN
  318. extern CRITICAL_SECTION csMapiInit;
  319. extern CRITICAL_SECTION csHeap;
  320. extern CRITICAL_SECTION csMapiSearchPath;
  321. extern BOOL fGlobalCSValid;
  322. #pragma DATA_END
  323. #endif
  324. // Notification engine
  325. SCODE ScInitNotify( LPINST pinst );
  326. void DeinitNotify(void);
  327. STDMETHODIMP HrSubscribe(LPADVISELIST FAR *lppAdviseList,
  328. LPNOTIFKEY lpKey,
  329. ULONG ulEventMask,
  330. LPMAPIADVISESINK lpAdvise,
  331. ULONG ulFlags,
  332. ULONG FAR *lpulConnection);
  333. STDMETHODIMP HrUnsubscribe(LPADVISELIST FAR *lppAdviseList,
  334. ULONG ulConnection);
  335. STDMETHODIMP HrNotify(LPNOTIFKEY lpKey,
  336. ULONG cNotification,
  337. LPNOTIFICATION lpNotifications,
  338. ULONG * lpulFlags);
  339. // Instantiate an IMsgServiceAdmin interface
  340. SCODE ScNewServiceAdmin(LPMAPIPROF pprofile,
  341. LPVOID lpParentObj,
  342. LPSESSOBJ psessobj,
  343. LPTSTR lpszProfileName,
  344. ULONG ulFlags,
  345. LPSERVICEADMIN FAR *lppServiceAdmin);
  346. // Instantiate an IProviderAdmin interface
  347. SCODE ScNewProviderAdmin(LPMAPIPROF pprofile,
  348. LPVOID lpParentObj,
  349. LPTSTR lpszProfileName,
  350. ULONG ulFlags,
  351. LPMAPIUID lpUID,
  352. BOOL fService,
  353. LPPROVIDERADMIN FAR *lppProviderAdmin);
  354. // Find (and optionally make) an SPROF list entry for a profile
  355. LPSPROF PsprofFindCreate(HGH hgh, GHID ghidshdr, LPSTR szProfile,
  356. BOOL fCreate);
  357. // Decrement the global refcounts for a session
  358. SCODE ScDerefSessionGlobals(LPTSTR lpszProfileName);
  359. SCODE ScDerefProcessSessionGlobals(LPTSTR lpszProfileName
  360. #if defined(WIN32) && !defined(MAC)
  361. , DWORD pid
  362. #elif defined(MAC)
  363. , PSN *ppsn
  364. #elif defined(WIN16)
  365. , HTASK htask
  366. #endif
  367. , ULONG ulFlags
  368. );
  369. // Validate the spooler globals
  370. // S_OK The spooler is up and running
  371. // S_FALSE No spooler is running
  372. // MAPI_E_CALL_FAILED The spooler has died
  373. SCODE ScSpoolerStatus(LPINST pinst, LPSHDR pshdr);
  374. void StopSpooler(LPSHDR pshdr); // NOT USED by design
  375. // Overall subsystem startup-shutdown routines
  376. SCODE ScInitMapiX(ULONG ulFlags, LPBYTE lpbSecurity);
  377. void DeinitMapiX(void);
  378. SCODE ScInitCompobj(LPINST FAR *ppinst, DWORD dwPid);
  379. void DeinitCompobj(LPINST pinst);
  380. void DestroyMapidlg(LPINST pinst);
  381. void CloseMapidlg(void);
  382. SCODE ScGetDlgFunction(UINT ibFunction, FARPROC FAR *lppfn,
  383. BOOL *pfDidInit);
  384. #ifdef WIN16
  385. HINSTANCE HinstApplication(void);
  386. #endif
  387. LPMALLOC PMallocOrig(void);
  388. HLH HlhInternal(void);
  389. void CleanupSession(LPSESSOBJ psessobj, BOOL fToldSpooler);
  390. void LogoffSpooler(LPSESSOBJ psessobj, ULONG ulReserved);
  391. // Get information about an entry ID
  392. HRESULT HrGetEIDType(LPSESSOBJ psessobj,
  393. ULONG cbeid,
  394. LPENTRYID peid,
  395. ULONG FAR *pulType,
  396. LPUNKNOWN FAR *ppunk);
  397. // Get information about a pair of entry IDs
  398. HRESULT HrGetEIDPairType(LPSESSOBJ psessobj,
  399. ULONG cbeid1,
  400. LPENTRYID peid1,
  401. ULONG cbeid2,
  402. LPENTRYID peid2,
  403. ULONG FAR *pulType,
  404. LPUNKNOWN FAR *ppunk);
  405. // Critical section for instance globals
  406. STDAPI_(SCODE) ScGetInst(LPINST FAR *ppinst);
  407. STDAPI_(void) ReleaseInst(LPINST FAR *ppinst);
  408. // Profile section access checks
  409. typedef enum
  410. {
  411. profaccClient = 0,
  412. profaccProvider,
  413. profaccService
  414. } PROFACC;
  415. HRESULT HrCheckProfileAccess(PROFACC profacc,
  416. LPMAPIUID lpuid,
  417. LPMAPIUID lpuidParent,
  418. LPMAPIPROF pprofile);
  419. #endif // OLD_STUFF
  420. #ifdef __cplusplus
  421. } // extern "C"
  422. #endif