[Libreoffice-commits] core.git: Branch 'aoo/trunk' - jurt/source

2015-11-11 Thread Damjan Jovanovic
 jurt/source/pipe/com_sun_star_lib_connections_pipe_PipeConnection.c |   18 +--
 jurt/source/pipe/wrapper/wrapper.c  |   51 
++
 2 files changed, 23 insertions(+), 46 deletions(-)

New commits:
commit 81f02514035de84eb4851917db7aa9455672efb8
Author: Damjan Jovanovic 
Date:   Wed Nov 11 17:16:25 2015 +

r1712824 withdrawn by committer.

diff --git 
a/jurt/source/pipe/com_sun_star_lib_connections_pipe_PipeConnection.c 
b/jurt/source/pipe/com_sun_star_lib_connections_pipe_PipeConnection.c
index 5244c3e..fae40f9 100644
--- a/jurt/source/pipe/com_sun_star_lib_connections_pipe_PipeConnection.c
+++ b/jurt/source/pipe/com_sun_star_lib_connections_pipe_PipeConnection.c
@@ -25,15 +25,15 @@
 #include "osl/security.h"
 #include 
 
-/* On Windows, jpipe.dll must not have static dependencies on any other URE 
DLLs
-   (sal3.dll, uwinapi.dll), as Java System.LoadLibrary could otherwise not load
-   it.  Therefore, on Windows, this code goes into a jpipx.dll that the 
jpipe.dll
-   wrapper loads with LoadLibraryEx(LOAD_WITH_ALTERED_SEARCH_PATH).
-   The function names in this wrapped code are truncated from the long JNICALL
-   names, as JNICALL causes some "@N" with different numeric values for
-   N (and probably different across 32 and 64 bit) to be added to the symbol
-   names, which the calls to GetProcAddress in wrapper/wrapper.c would 
otherwise
-   have to take into account.
+/* On Windows, jpipe.dll must not have dependencies on any other URE DLLs, as
+   Java System.LoadLibrary could otherwise not load it.  Therefore, on Windows,
+   this code goes into a jpipx.dll that the jpipe.dll wrapper loads with
+   LoadLibraryEx(LOAD_WITH_ALTERED_SEARCH_PATH).  The function names in this
+   wrapped code are truncated from the long JNICALL names, as JNICALL causes
+   some "@N" with different numeric values for N (and probably different across
+   32 and 64 bit) to be added to the symbol names, which the calls to
+   GetProcAddress in wrapper/wrapper.c would otheriwse have to take into
+   account.
 */
 
 /*/
diff --git a/jurt/source/pipe/wrapper/wrapper.c 
b/jurt/source/pipe/wrapper/wrapper.c
index 314cc18..59d51d1 100644
--- a/jurt/source/pipe/wrapper/wrapper.c
+++ b/jurt/source/pipe/wrapper/wrapper.c
@@ -30,50 +30,27 @@
 #include "jni.h"
 #include "sal/types.h"
 
+static HMODULE module;
 
-static HMODULE   module   = NULL;
-static HINSTANCE hInstDLL = NULL;
-static CRITICAL_SECTION CriticalSection;
-
-void InitWrapper(void) {
-#define MAXPATH 512
-wchar_t path[MAXPATH];
-DWORD size;
-
-size = GetModuleFileNameW(hInstDLL, path, MAXPATH);
-if (size == 0) {
-abort();
-}
-path[size - 5] = L'x'; /* ...\jpipe.dll -> ...\jpipx.dll */
-module = LoadLibraryExW(path, NULL, LOAD_WITH_ALTERED_SEARCH_PATH);
-if (module == NULL) {
-abort();
-}
-}
-
-static FARPROC getFunction(char const * name)
-{
-{
-EnterCriticalSection();
-
-if(module == NULL)
-InitWrapper();
-
-LeaveCriticalSection();
-}
-
+static FARPROC getFunction(char const * name) {
 return GetProcAddress(module, name);
 }
 
 BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) {
 (void) lpvReserved;
-
-if (fdwReason == DLL_PROCESS_ATTACH)
-{
-InitializeCriticalSection();
-hInstDLL = hinstDLL;
+if (fdwReason == DLL_PROCESS_ATTACH) {
+wchar_t path[32767];
+DWORD size;
+size = GetModuleFileNameW(hinstDLL, path, 32767);
+if (size == 0) {
+return FALSE;
+}
+path[size - 5] = L'x'; /* ...\jpipe.dll -> ...\jpipx.dll */
+module = LoadLibraryExW(path, NULL, LOAD_WITH_ALTERED_SEARCH_PATH);
+if (module == NULL) {
+return FALSE;
+}
 }
-
 return TRUE;
 }
 
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: Branch 'aoo/trunk' - jurt/source

2015-11-05 Thread Damjan Jovanovic
 jurt/source/pipe/com_sun_star_lib_connections_pipe_PipeConnection.c |   18 +--
 jurt/source/pipe/wrapper/wrapper.c  |   51 
+++---
 2 files changed, 46 insertions(+), 23 deletions(-)

New commits:
commit d0991ab96b863dfae89a6ce4e9ac90016681b61d
Author: Damjan Jovanovic 
Date:   Thu Nov 5 17:23:14 2015 +

#i126360# Possible exception/segfault in jurt jpipe.dll under Windows with 
pipe connection

- Remove the LoadLibrary from DLLMain (from windows not recommended)
see 
http://msdn.microsoft.com/en-us/library/windows/desktop/ms682583(v=vs.85).aspx
in section Remarks
- Improve the comment why we need two dll's (jpipe.dll and jpipx.dll)
- Integrate CriticalSection, init in DllMain see link

http://msdn.microsoft.com/en-us/library/windows/desktop/dn633971(v=vs.85).aspx#general_best_practices

Patch by: Juergen Funk 
Review by: Damjan Jovanovic

diff --git 
a/jurt/source/pipe/com_sun_star_lib_connections_pipe_PipeConnection.c 
b/jurt/source/pipe/com_sun_star_lib_connections_pipe_PipeConnection.c
index fae40f9..5244c3e 100644
--- a/jurt/source/pipe/com_sun_star_lib_connections_pipe_PipeConnection.c
+++ b/jurt/source/pipe/com_sun_star_lib_connections_pipe_PipeConnection.c
@@ -25,15 +25,15 @@
 #include "osl/security.h"
 #include 
 
-/* On Windows, jpipe.dll must not have dependencies on any other URE DLLs, as
-   Java System.LoadLibrary could otherwise not load it.  Therefore, on Windows,
-   this code goes into a jpipx.dll that the jpipe.dll wrapper loads with
-   LoadLibraryEx(LOAD_WITH_ALTERED_SEARCH_PATH).  The function names in this
-   wrapped code are truncated from the long JNICALL names, as JNICALL causes
-   some "@N" with different numeric values for N (and probably different across
-   32 and 64 bit) to be added to the symbol names, which the calls to
-   GetProcAddress in wrapper/wrapper.c would otheriwse have to take into
-   account.
+/* On Windows, jpipe.dll must not have static dependencies on any other URE 
DLLs
+   (sal3.dll, uwinapi.dll), as Java System.LoadLibrary could otherwise not load
+   it.  Therefore, on Windows, this code goes into a jpipx.dll that the 
jpipe.dll
+   wrapper loads with LoadLibraryEx(LOAD_WITH_ALTERED_SEARCH_PATH).
+   The function names in this wrapped code are truncated from the long JNICALL
+   names, as JNICALL causes some "@N" with different numeric values for
+   N (and probably different across 32 and 64 bit) to be added to the symbol
+   names, which the calls to GetProcAddress in wrapper/wrapper.c would 
otherwise
+   have to take into account.
 */
 
 /*/
diff --git a/jurt/source/pipe/wrapper/wrapper.c 
b/jurt/source/pipe/wrapper/wrapper.c
index 59d51d1..314cc18 100644
--- a/jurt/source/pipe/wrapper/wrapper.c
+++ b/jurt/source/pipe/wrapper/wrapper.c
@@ -30,27 +30,50 @@
 #include "jni.h"
 #include "sal/types.h"
 
-static HMODULE module;
 
-static FARPROC getFunction(char const * name) {
+static HMODULE   module   = NULL;
+static HINSTANCE hInstDLL = NULL;
+static CRITICAL_SECTION CriticalSection;
+
+void InitWrapper(void) {
+#define MAXPATH 512
+wchar_t path[MAXPATH];
+DWORD size;
+
+size = GetModuleFileNameW(hInstDLL, path, MAXPATH);
+if (size == 0) {
+abort();
+}
+path[size - 5] = L'x'; /* ...\jpipe.dll -> ...\jpipx.dll */
+module = LoadLibraryExW(path, NULL, LOAD_WITH_ALTERED_SEARCH_PATH);
+if (module == NULL) {
+abort();
+}
+}
+
+static FARPROC getFunction(char const * name)
+{
+{
+EnterCriticalSection();
+
+if(module == NULL)
+InitWrapper();
+
+LeaveCriticalSection();
+}
+
 return GetProcAddress(module, name);
 }
 
 BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) {
 (void) lpvReserved;
-if (fdwReason == DLL_PROCESS_ATTACH) {
-wchar_t path[32767];
-DWORD size;
-size = GetModuleFileNameW(hinstDLL, path, 32767);
-if (size == 0) {
-return FALSE;
-}
-path[size - 5] = L'x'; /* ...\jpipe.dll -> ...\jpipx.dll */
-module = LoadLibraryExW(path, NULL, LOAD_WITH_ALTERED_SEARCH_PATH);
-if (module == NULL) {
-return FALSE;
-}
+
+if (fdwReason == DLL_PROCESS_ATTACH)
+{
+InitializeCriticalSection();
+hInstDLL = hinstDLL;
 }
+
 return TRUE;
 }
 
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits