diff options
author | Lyubomir Marinov <lyubomir.marinov@jitsi.org> | 2011-01-11 11:08:34 +0000 |
---|---|---|
committer | Lyubomir Marinov <lyubomir.marinov@jitsi.org> | 2011-01-11 11:08:34 +0000 |
commit | 48f29f665763b598e0d953864afa367fc669f081 (patch) | |
tree | f44672e5bf7c5d3bd6fc001bac9794d3f95d3737 /src/native/addrbook/msoutlook | |
parent | e80a62b8e63da9291f74ed4c19030ae4a278ec55 (diff) | |
download | jitsi-48f29f665763b598e0d953864afa367fc669f081.zip jitsi-48f29f665763b598e0d953864afa367fc669f081.tar.gz jitsi-48f29f665763b598e0d953864afa367fc669f081.tar.bz2 |
Fixes an access violation in the support for the Address Book of Microsoft Outlook (privately) reported by Damian Minkov.
Diffstat (limited to 'src/native/addrbook/msoutlook')
4 files changed, 56 insertions, 41 deletions
diff --git a/src/native/addrbook/msoutlook/Makefile b/src/native/addrbook/msoutlook/Makefile index a971bbe..6b85fc2 100644 --- a/src/native/addrbook/msoutlook/Makefile +++ b/src/native/addrbook/msoutlook/Makefile @@ -1,23 +1,27 @@ -CC = gcc -O2 -OUTLOOK_MAPI_HEADERS ?= /c/Users/lyubomir/Downloads/Outlook2010MAPIHeaders -TARGET_BASENAME = jmsoutlookaddrbook - -ARCH = $(shell $(CC) -dumpmachine | sed -e s/x86_64-.*/-64/ -e s/i.86-.*//) -ifeq "$(ARCH)" "-64" - JAVA_HOME ?= C:/PROGRA~1/jdk -else - JAVA_HOME ?= C:/PROGRA~2/jdk -endif - -CPPFLAGS = -I$(JAVA_HOME)/include -I$(JAVA_HOME)/include/win32 -I$(OUTLOOK_MAPI_HEADERS) -I.. -LDFLAGS = -shared -Wl,--kill-at -LIBS = -luuid -ladvapi32 -TARGET = ../../../../lib/native/windows$(ARCH)/$(TARGET_BASENAME).dll - -$(TARGET): \ - ../AddrBookContactQuery.c \ - MsOutlookMAPIHResultException.cxx \ - net_java_sip_communicator_plugin_addrbook_msoutlook_MsOutlookAddrBookContactQuery.cxx \ - net_java_sip_communicator_plugin_addrbook_msoutlook_MsOutlookAddrBookContactSourceService.cxx - $(CC) $(CPPFLAGS) $^ $(LDFLAGS) -o $@ $(LIBS) - -strip $(TARGET) +CC = gcc -O2
+OUTLOOK_MAPI_HEADERS ?= C:/Users/lyubomir/Downloads/Outlook2010MAPIHeaders
+TARGET_BASENAME = jmsoutlookaddrbook
+
+ARCH = $(shell $(CC) -dumpmachine | sed -e s/x86_64-.*/-64/ -e s/i.86-.*// -e s/mingw32//)
+ifeq "$(ARCH)" "-64"
+ JAVA_HOME ?= C:/PROGRA~1/jdk
+else
+ JAVA_HOME ?= C:/PROGRA~2/jdk
+endif
+
+CPPFLAGS = \
+ -Wall -Wreturn-type \
+ -DWINVER=0x0502 -D_WIN32_WINNT=0x0502 \
+ -DJNI_IMPLEMENTATION \
+ -I$(JAVA_HOME)/include -I$(JAVA_HOME)/include/win32 -I$(OUTLOOK_MAPI_HEADERS) -I..
+LDFLAGS = -shared -Wl,--kill-at -Wl,--subsystem,windows
+LIBS = -ladvapi32 -luuid
+TARGET = ../../../../lib/native/windows$(ARCH)/$(TARGET_BASENAME).dll
+
+$(TARGET): \
+ ../AddrBookContactQuery.c \
+ MsOutlookMAPIHResultException.cxx \
+ net_java_sip_communicator_plugin_addrbook_msoutlook_MsOutlookAddrBookContactQuery.cxx \
+ net_java_sip_communicator_plugin_addrbook_msoutlook_MsOutlookAddrBookContactSourceService.cxx
+ $(CC) $(CPPFLAGS) $^ $(LDFLAGS) -o $@ $(LIBS)
+ -strip $(TARGET)
diff --git a/src/native/addrbook/msoutlook/MsOutlookMAPI.h b/src/native/addrbook/msoutlook/MsOutlookMAPI.h index 6dcc0b0..33f5747 100644 --- a/src/native/addrbook/msoutlook/MsOutlookMAPI.h +++ b/src/native/addrbook/msoutlook/MsOutlookMAPI.h @@ -8,17 +8,19 @@ #ifndef _NET_JAVA_SIP_COMMUNICATOR_PLUGIN_ADDRBOOK_MSOUTLOOK_MSOUTLOOKMAPI_H_
#define _NET_JAVA_SIP_COMMUNICATOR_PLUGIN_ADDRBOOK_MSOUTLOOK_MSOUTLOOKMAPI_H_
+#define WIN32_LEAN_AND_MEAN
+#include <windows.h>
+
#ifndef __in_opt
#define __in_opt
#endif /* #ifndef __in_opt */
-
+#if defined(_WINBASE_H) && !defined(_WINBASE_)
+#define _tagCY_DEFINED
+#define _WINBASE_
+#endif
#include <mapitags.h>
#include <mapix.h>
-#define WIN32_LEAN_AND_MEAN
-#include <windows.h>
-
-
SCODE MsOutlookAddrBook_MAPIAllocateBuffer(ULONG size, LPVOID FAR *buffer);
#define MAPIAllocateBuffer MsOutlookAddrBook_MAPIAllocateBuffer
ULONG MsOutlookAddrBook_MAPIFreeBuffer(LPVOID buffer);
diff --git a/src/native/addrbook/msoutlook/MsOutlookMAPIHResultException.cxx b/src/native/addrbook/msoutlook/MsOutlookMAPIHResultException.cxx index cfe5fa8..4c090a3 100644 --- a/src/native/addrbook/msoutlook/MsOutlookMAPIHResultException.cxx +++ b/src/native/addrbook/msoutlook/MsOutlookMAPIHResultException.cxx @@ -62,33 +62,38 @@ MsOutlookMAPIHResultException_throwNew if (message)
{
- jmethodID methodID;
-
- methodID
+ jmethodID methodID
= jniEnv->GetMethodID(
clazz,
"<init>",
"(JLjava/lang/String;)V");
+
if (methodID)
{
- jobject t;
+ jstring jmessage = jniEnv->NewStringUTF(message);
- t = jniEnv->NewObject(clazz, methodID, hResult, message);
- if (t)
- jniEnv->Throw((jthrowable) t);
+ if (jmessage)
+ {
+ jobject t
+ = jniEnv->NewObject(
+ clazz,
+ methodID,
+ (jlong) hResult, jmessage);
+
+ if (t)
+ jniEnv->Throw((jthrowable) t);
+ }
return;
}
}
{
- jmethodID methodID;
+ jmethodID methodID = jniEnv->GetMethodID(clazz, "<init>", "(J)V");
- methodID = jniEnv->GetMethodID(clazz, "<init>", "(J)V");
if (methodID)
{
- jobject t;
+ jobject t = jniEnv->NewObject(clazz, methodID, hResult);
- t = jniEnv->NewObject(clazz, methodID, hResult);
if (t)
jniEnv->Throw((jthrowable) t);
return;
diff --git a/src/native/addrbook/msoutlook/net_java_sip_communicator_plugin_addrbook_msoutlook_MsOutlookAddrBookContactSourceService.cxx b/src/native/addrbook/msoutlook/net_java_sip_communicator_plugin_addrbook_msoutlook_MsOutlookAddrBookContactSourceService.cxx index 3db6812..88282c0 100644 --- a/src/native/addrbook/msoutlook/net_java_sip_communicator_plugin_addrbook_msoutlook_MsOutlookAddrBookContactSourceService.cxx +++ b/src/native/addrbook/msoutlook/net_java_sip_communicator_plugin_addrbook_msoutlook_MsOutlookAddrBookContactSourceService.cxx @@ -77,14 +77,15 @@ Java_net_java_sip_communicator_plugin_addrbook_msoutlook_MsOutlookAddrBookContac str = installRootKeyName + subkeyNameLength;
memcpy(str, _T("\\Outlook\\InstallRoot"), 20 * sizeof(TCHAR));
*(str + 20) = 0;
- if ((ERROR_SUCCESS
+ if (ERROR_SUCCESS
== RegOpenKeyEx(
officeKey,
installRootKeyName,
0,
KEY_QUERY_VALUE,
&installRootKey))
- && (ERROR_SUCCESS
+ {
+ if ((ERROR_SUCCESS
== RegQueryValueEx(
installRootKey,
_T("Path"),
@@ -143,7 +144,10 @@ Java_net_java_sip_communicator_plugin_addrbook_msoutlook_MsOutlookAddrBookContac if (pathValue != installRootKeyName)
free(pathValue);
}
+ RegCloseKey(installRootKey);
+ }
}
+ RegCloseKey(officeKey);
}
/* If we've determined that we'd like to go on with MAPI, try to load it. */
|