ReactOS 0.4.17-dev-966-gf06eace
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)
 
void unload_mapi_providers (void)
 

Variables

MAPI_FUNCTIONS mapiFunctions
 
HINSTANCE hInstMAPI32
 

Typedef Documentation

◆ MAPI_FUNCTIONS

Function Documentation

◆ load_mapi_providers()

void load_mapi_providers ( void  )

Definition at line 1021 of file util.c.

1022{
1023 static const WCHAR regkey_mail[] = L"Software\\Clients\\Mail";
1024
1025 HKEY hkeyMail;
1026 DWORD dwType, dwLen = 0;
1027 LPWSTR appName = NULL, appKey = NULL;
1028
1029 TRACE("()\n");
1030
1031 /* Open the Mail key */
1032 if (RegOpenKeyExW(HKEY_LOCAL_MACHINE, regkey_mail, 0, KEY_READ, &hkeyMail) != ERROR_SUCCESS)
1033 return;
1034
1035 /* Check if we have a default value set, and the length of it */
1036 if ((RegQueryValueExW(hkeyMail, NULL, NULL, &dwType, NULL, &dwLen) != ERROR_SUCCESS) ||
1037 !((dwType == REG_SZ) || (dwType == REG_EXPAND_SZ)) || (dwLen == 0))
1038 goto cleanUp;
1039
1040 appName = HeapAlloc(GetProcessHeap(), 0, dwLen);
1041
1042 if (!appName)
1043 goto cleanUp;
1044
1045 /* Get the value, and get the path to the app key */
1046 RegQueryValueExW(hkeyMail, NULL, NULL, NULL, (LPBYTE)appName, &dwLen);
1047
1048 TRACE("appName: %s\n", debugstr_w(appName));
1049
1050 appKey = HeapAlloc(GetProcessHeap(), 0, sizeof(WCHAR) * (lstrlenW(regkey_mail) +
1051 lstrlenW(L"\\") + lstrlenW(appName) + 1));
1052
1053 if (!appKey)
1054 goto cleanUp;
1055
1056 lstrcpyW(appKey, regkey_mail);
1057 lstrcatW(appKey, L"\\");
1058 lstrcatW(appKey, appName);
1059
1060 RegCloseKey(hkeyMail);
1061
1062 TRACE("appKey: %s\n", debugstr_w(appKey));
1063
1064 /* Open the app's key */
1065 if (RegOpenKeyExW(HKEY_LOCAL_MACHINE, appKey, 0, KEY_READ, &hkeyMail) != ERROR_SUCCESS)
1066 goto cleanUp;
1067
1068 /* Try to load the providers */
1069 load_mapi_provider(hkeyMail, L"DLLPath", &mapi_provider);
1070 load_mapi_provider(hkeyMail, L"DLLPathEx", &mapi_ex_provider);
1071
1072 /* Now try to load our function pointers */
1074
1075 /* Simple MAPI functions */
1076 if (mapi_provider)
1077 {
1078 mapiFunctions.MAPIAddress = (void*) GetProcAddress(mapi_provider, "MAPIAddress");
1079 mapiFunctions.MAPIDeleteMail = (void*) GetProcAddress(mapi_provider, "MAPIDeleteMail");
1080 mapiFunctions.MAPIDetails = (void*) GetProcAddress(mapi_provider, "MAPIDetails");
1081 mapiFunctions.MAPIFindNext = (void*) GetProcAddress(mapi_provider, "MAPIFindNext");
1082 mapiFunctions.MAPILogoff = (void*) GetProcAddress(mapi_provider, "MAPILogoff");
1083 mapiFunctions.MAPILogon = (void*) GetProcAddress(mapi_provider, "MAPILogon");
1084 mapiFunctions.MAPIReadMail = (void*) GetProcAddress(mapi_provider, "MAPIReadMail");
1085 mapiFunctions.MAPIResolveName = (void*) GetProcAddress(mapi_provider, "MAPIResolveName");
1086 mapiFunctions.MAPISaveMail = (void*) GetProcAddress(mapi_provider, "MAPISaveMail");
1087 mapiFunctions.MAPISendDocuments = (void*) GetProcAddress(mapi_provider, "MAPISendDocuments");
1088 mapiFunctions.MAPISendMail = (void*) GetProcAddress(mapi_provider, "MAPISendMail");
1089 mapiFunctions.MAPISendMailW = (void*) GetProcAddress(mapi_provider, "MAPISendMailW");
1090 }
1091
1092 /* Extended MAPI functions */
1093 if (mapi_ex_provider)
1094 {
1095 mapiFunctions.MAPIInitialize = (void*) GetProcAddress(mapi_ex_provider, "MAPIInitialize");
1096 mapiFunctions.MAPILogonEx = (void*) GetProcAddress(mapi_ex_provider, "MAPILogonEx");
1097 mapiFunctions.MAPIUninitialize = (void*) GetProcAddress(mapi_ex_provider, "MAPIUninitialize");
1098
1099 mapiFunctions.DeinitMapiUtil = (void*) GetProcAddress(mapi_ex_provider, "DeinitMapiUtil@0");
1100 mapiFunctions.DllCanUnloadNow = (void*) GetProcAddress(mapi_ex_provider, "DllCanUnloadNow");
1101 mapiFunctions.DllGetClassObject = (void*) GetProcAddress(mapi_ex_provider, "DllGetClassObject");
1102 mapiFunctions.FGetComponentPath = (void*) GetProcAddress(mapi_ex_provider, "FGetComponentPath");
1103 mapiFunctions.HrThisThreadAdviseSink = (void*) GetProcAddress(mapi_ex_provider, "HrThisThreadAdviseSink@8");
1104 mapiFunctions.HrQueryAllRows = (void*) GetProcAddress(mapi_ex_provider, "HrQueryAllRows@24");
1105 mapiFunctions.MAPIAdminProfiles = (void*) GetProcAddress(mapi_ex_provider, "MAPIAdminProfiles");
1106 mapiFunctions.MAPIAllocateBuffer = (void*) GetProcAddress(mapi_ex_provider, "MAPIAllocateBuffer");
1107 mapiFunctions.MAPIAllocateMore = (void*) GetProcAddress(mapi_ex_provider, "MAPIAllocateMore");
1108 mapiFunctions.MAPIFreeBuffer = (void*) GetProcAddress(mapi_ex_provider, "MAPIFreeBuffer");
1109 mapiFunctions.MAPIGetDefaultMalloc = (void*) GetProcAddress(mapi_ex_provider, "MAPIGetDefaultMalloc@0");
1110 mapiFunctions.MAPIOpenLocalFormContainer = (void *) GetProcAddress(mapi_ex_provider, "MAPIOpenLocalFormContainer");
1111 mapiFunctions.OpenStreamOnFile = (void*) GetProcAddress(mapi_ex_provider, "OpenStreamOnFile@24");
1112 mapiFunctions.ScInitMapiUtil = (void*) GetProcAddress(mapi_ex_provider, "ScInitMapiUtil@4");
1113 mapiFunctions.WrapCompressedRTFStream = (void*) GetProcAddress(mapi_ex_provider, "WrapCompressedRTFStream@12");
1114 }
1115
1116cleanUp:
1117 RegCloseKey(hkeyMail);
1118 HeapFree(GetProcessHeap(), 0, appKey);
1120}
#define REG_SZ
Definition: layer.c:22
#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
#define L(x)
Definition: resources.c:13
void cleanUp()
Definition: main.cpp:469
unsigned long DWORD
Definition: ntddk_ex.h:95
#define debugstr_w
Definition: kernel32.h:32
const char * appName(const char *argv0)
Definition: loadlib.c:89
LPWSTR WINAPI lstrcatW(LPWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:274
#define ZeroMemory
Definition: minwinbase.h:31
#define KEY_READ
Definition: nt_native.h:1026
#define REG_EXPAND_SZ
Definition: nt_native.h:1497
short WCHAR
Definition: pedump.c:58
#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
uint16_t * LPWSTR
Definition: typedefs.h:56
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12

Referenced by DllMain().

◆ unload_mapi_providers()

void unload_mapi_providers ( void  )

Definition at line 1127 of file util.c.

1128{
1129 TRACE("()\n");
1130
1133}
#define FreeLibrary(x)
Definition: compat.h:748

Referenced by DllMain().

Variable Documentation

◆ hInstMAPI32

HINSTANCE hInstMAPI32
extern

Definition at line 37 of file mapi32_main.c.

Referenced by DllMain(), MAPISendMail(), and MAPISendMailW().

◆ mapiFunctions