ReactOS 0.4.16-dev-336-gb667d82
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 1023 of file util.c.

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

Referenced by DllMain().

◆ unload_mapi_providers()

void unload_mapi_providers ( void  )

Definition at line 1135 of file util.c.

1136{
1137 TRACE("()\n");
1138
1141}
#define FreeLibrary(x)
Definition: compat.h:748

Referenced by DllMain().

Variable Documentation

◆ DECLSPEC_HIDDEN

HINSTANCE hInstMAPI32 DECLSPEC_HIDDEN
extern

Definition at line 66 of file util.h.