ReactOS  0.4.13-dev-259-g5ca9c9c
util.h File Reference
#include <mapi.h>
#include <mapix.h>
Include dependency graph for util.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  MAPI_FUNCTIONS
 

Typedefs

typedef struct MAPI_FUNCTIONS MAPI_FUNCTIONS
 

Functions

void load_mapi_providers (void) DECLSPEC_HIDDEN
 
void unload_mapi_providers (void) DECLSPEC_HIDDEN
 

Variables

MAPI_FUNCTIONS mapiFunctions DECLSPEC_HIDDEN
 

Typedef Documentation

◆ MAPI_FUNCTIONS

Function Documentation

◆ load_mapi_providers()

void load_mapi_providers ( void  )

Definition at line 1024 of file util.c.

1025 {
1026  static const WCHAR regkey_mail[] = {
1027  'S','o','f','t','w','a','r','e','\\','C','l','i','e','n','t','s','\\',
1028  'M','a','i','l',0 };
1029 
1030  static const WCHAR regkey_dllpath[] = {'D','L','L','P','a','t','h',0 };
1031  static const WCHAR regkey_dllpath_ex[] = {'D','L','L','P','a','t','h','E','x',0 };
1032  static const WCHAR regkey_backslash[] = { '\\', 0 };
1033 
1034  HKEY hkeyMail;
1035  DWORD dwType, dwLen = 0;
1036  LPWSTR appName = NULL, appKey = NULL;
1037 
1038  TRACE("()\n");
1039 
1040  /* Open the Mail key */
1041  if (RegOpenKeyExW(HKEY_LOCAL_MACHINE, regkey_mail, 0, KEY_READ, &hkeyMail) != ERROR_SUCCESS)
1042  return;
1043 
1044  /* Check if we have a default value set, and the length of it */
1045  if ((RegQueryValueExW(hkeyMail, NULL, NULL, &dwType, NULL, &dwLen) != ERROR_SUCCESS) ||
1046  !((dwType == REG_SZ) || (dwType == REG_EXPAND_SZ)) || (dwLen == 0))
1047  goto cleanUp;
1048 
1049  appName = HeapAlloc(GetProcessHeap(), 0, dwLen);
1050 
1051  if (!appName)
1052  goto cleanUp;
1053 
1054  /* Get the value, and get the path to the app key */
1055  RegQueryValueExW(hkeyMail, NULL, NULL, NULL, (LPBYTE)appName, &dwLen);
1056 
1057  TRACE("appName: %s\n", debugstr_w(appName));
1058 
1059  appKey = HeapAlloc(GetProcessHeap(), 0, sizeof(WCHAR) * (lstrlenW(regkey_mail) +
1060  lstrlenW(regkey_backslash) + lstrlenW(appName) + 1));
1061 
1062  if (!appKey)
1063  goto cleanUp;
1064 
1065  lstrcpyW(appKey, regkey_mail);
1066  lstrcatW(appKey, regkey_backslash);
1067  lstrcatW(appKey, appName);
1068 
1069  RegCloseKey(hkeyMail);
1070 
1071  TRACE("appKey: %s\n", debugstr_w(appKey));
1072 
1073  /* Open the app's key */
1074  if (RegOpenKeyExW(HKEY_LOCAL_MACHINE, appKey, 0, KEY_READ, &hkeyMail) != ERROR_SUCCESS)
1075  goto cleanUp;
1076 
1077  /* Try to load the providers */
1078  load_mapi_provider(hkeyMail, regkey_dllpath, &mapi_provider);
1079  load_mapi_provider(hkeyMail, regkey_dllpath_ex, &mapi_ex_provider);
1080 
1081  /* Now try to load our function pointers */
1083 
1084  /* Simple MAPI functions */
1085  if (mapi_provider)
1086  {
1087  mapiFunctions.MAPIAddress = (void*) GetProcAddress(mapi_provider, "MAPIAddress");
1088  mapiFunctions.MAPIDeleteMail = (void*) GetProcAddress(mapi_provider, "MAPIDeleteMail");
1089  mapiFunctions.MAPIDetails = (void*) GetProcAddress(mapi_provider, "MAPIDetails");
1090  mapiFunctions.MAPIFindNext = (void*) GetProcAddress(mapi_provider, "MAPIFindNext");
1091  mapiFunctions.MAPILogoff = (void*) GetProcAddress(mapi_provider, "MAPILogoff");
1092  mapiFunctions.MAPILogon = (void*) GetProcAddress(mapi_provider, "MAPILogon");
1093  mapiFunctions.MAPIReadMail = (void*) GetProcAddress(mapi_provider, "MAPIReadMail");
1094  mapiFunctions.MAPIResolveName = (void*) GetProcAddress(mapi_provider, "MAPIResolveName");
1095  mapiFunctions.MAPISaveMail = (void*) GetProcAddress(mapi_provider, "MAPISaveMail");
1096  mapiFunctions.MAPISendDocuments = (void*) GetProcAddress(mapi_provider, "MAPISendDocuments");
1097  mapiFunctions.MAPISendMail = (void*) GetProcAddress(mapi_provider, "MAPISendMail");
1098  mapiFunctions.MAPISendMailW = (void*) GetProcAddress(mapi_provider, "MAPISendMailW");
1099  }
1100 
1101  /* Extended MAPI functions */
1102  if (mapi_ex_provider)
1103  {
1104  mapiFunctions.MAPIInitialize = (void*) GetProcAddress(mapi_ex_provider, "MAPIInitialize");
1105  mapiFunctions.MAPILogonEx = (void*) GetProcAddress(mapi_ex_provider, "MAPILogonEx");
1106  mapiFunctions.MAPIUninitialize = (void*) GetProcAddress(mapi_ex_provider, "MAPIUninitialize");
1107 
1108  mapiFunctions.DeinitMapiUtil = (void*) GetProcAddress(mapi_ex_provider, "DeinitMapiUtil@0");
1109  mapiFunctions.DllCanUnloadNow = (void*) GetProcAddress(mapi_ex_provider, "DllCanUnloadNow");
1110  mapiFunctions.DllGetClassObject = (void*) GetProcAddress(mapi_ex_provider, "DllGetClassObject");
1111  mapiFunctions.FGetComponentPath = (void*) GetProcAddress(mapi_ex_provider, "FGetComponentPath");
1112  mapiFunctions.HrThisThreadAdviseSink = (void*) GetProcAddress(mapi_ex_provider, "HrThisThreadAdviseSink@8");
1113  mapiFunctions.HrQueryAllRows = (void*) GetProcAddress(mapi_ex_provider, "HrQueryAllRows@24");
1114  mapiFunctions.MAPIAdminProfiles = (void*) GetProcAddress(mapi_ex_provider, "MAPIAdminProfiles");
1115  mapiFunctions.MAPIAllocateBuffer = (void*) GetProcAddress(mapi_ex_provider, "MAPIAllocateBuffer");
1116  mapiFunctions.MAPIAllocateMore = (void*) GetProcAddress(mapi_ex_provider, "MAPIAllocateMore");
1117  mapiFunctions.MAPIFreeBuffer = (void*) GetProcAddress(mapi_ex_provider, "MAPIFreeBuffer");
1118  mapiFunctions.MAPIGetDefaultMalloc = (void*) GetProcAddress(mapi_ex_provider, "MAPIGetDefaultMalloc@0");
1119  mapiFunctions.MAPIOpenLocalFormContainer = (void *) GetProcAddress(mapi_ex_provider, "MAPIOpenLocalFormContainer");
1120  mapiFunctions.OpenStreamOnFile = (void*) GetProcAddress(mapi_ex_provider, "OpenStreamOnFile@24");
1121  mapiFunctions.ScInitMapiUtil = (void*) GetProcAddress(mapi_ex_provider, "ScInitMapiUtil@4");
1122  mapiFunctions.WrapCompressedRTFStream = (void*) GetProcAddress(mapi_ex_provider, "WrapCompressedRTFStream@12");
1123  }
1124 
1125 cleanUp:
1126  RegCloseKey(hkeyMail);
1127  HeapFree(GetProcessHeap(), 0, appKey);
1129 }
LPMAPIDETAILS MAPIDetails
Definition: util.h:34
#define ERROR_SUCCESS
Definition: deptool.c:10
#define KEY_READ
Definition: nt_native.h:1023
LPMAPIRESOLVENAME MAPIResolveName
Definition: util.h:41
LPMAPIADDRESS MAPIAddress
Definition: util.h:32
#define ZeroMemory
Definition: winbase.h:1635
#define lstrlenW
Definition: compat.h:407
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
LPMAPILOGONEX MAPILogonEx
Definition: util.h:39
unsigned char * LPBYTE
Definition: typedefs.h:52
#define debugstr_w
Definition: kernel32.h:32
static HMODULE mapi_ex_provider
Definition: util.c:959
LPMAPISENDDOCUMENTS MAPISendDocuments
Definition: util.h:45
smooth NULL
Definition: ftsmooth.c:416
LPMAPISENDMAIL MAPISendMail
Definition: util.h:43
LPMAPIREADMAIL MAPIReadMail
Definition: util.h:40
LPMAPIDELETEMAIL MAPIDeleteMail
Definition: util.h:33
LPMAPIUNINITIALIZE MAPIUninitialize
Definition: util.h:46
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4134
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned long DWORD
Definition: ntddk_ex.h:95
LPMAPISAVEMAIL MAPISaveMail
Definition: util.h:42
LPMAPIFINDNEXT MAPIFindNext
Definition: util.h:35
LPMAPILOGON MAPILogon
Definition: util.h:38
MAPI_FUNCTIONS mapiFunctions
Definition: util.c:50
static HMODULE mapi_provider
Definition: util.c:958
#define lstrcpyW
Definition: compat.h:406
#define REG_EXPAND_SZ
Definition: nt_native.h:1494
LPMAPILOGOFF MAPILogoff
Definition: util.h:37
static void load_mapi_provider(HKEY hkeyMail, LPCWSTR valueName, HMODULE *mapi_provider)
Definition: util.c:968
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3381
const char * appName(const char *argv0)
Definition: loadlib.c:89
#define GetProcAddress(x, y)
Definition: compat.h:410
LPWSTR WINAPI lstrcatW(LPWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:274
LPMAPIINITIALIZE MAPIInitialize
Definition: util.h:36
WCHAR * LPWSTR
Definition: xmlstorage.h:184
void cleanUp()
Definition: main.cpp:472
LPMAPISENDMAILW MAPISendMailW
Definition: util.h:44
#define HeapFree(x, y, z)
Definition: compat.h:394
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12
#define REG_SZ
Definition: layer.c:22

Referenced by DllMain().

◆ unload_mapi_providers()

void unload_mapi_providers ( void  )

Definition at line 1136 of file util.c.

1137 {
1138  TRACE("()\n");
1139 
1142 }
static HMODULE mapi_ex_provider
Definition: util.c:959
#define TRACE(s)
Definition: solgame.cpp:4
#define FreeLibrary(x)
Definition: compat.h:405
static HMODULE mapi_provider
Definition: util.c:958

Referenced by DllMain().

Variable Documentation

◆ DECLSPEC_HIDDEN

HINSTANCE hInstMAPI32 DECLSPEC_HIDDEN

Definition at line 66 of file util.h.