View | Details | Raw Unified | Return to issue 126360
Collapse All | Expand All

(-)a/jurt/source/pipe/com_sun_star_lib_connections_pipe_PipeConnection.c (-9 / +9 lines)
Lines 21-35 Link Here
21
#include "osl/security.h"
21
#include "osl/security.h"
22
#include <osl/pipe.h>
22
#include <osl/pipe.h>
23
23
24
/* On Windows, jpipe.dll must not have dependencies on any other URE DLLs, as
24
/* On Windows, jpipe.dll must not have static dependencies on any other URE DLLs
25
   Java System.LoadLibrary could otherwise not load it.  Therefore, on Windows,
25
   (sal3.dll, uwinapi.dll), as Java System.LoadLibrary could otherwise not load
26
   this code goes into a jpipx.dll that the jpipe.dll wrapper loads with
26
   it.  Therefore, on Windows, this code goes into a jpipx.dll that the jpipe.dll
27
   LoadLibraryEx(LOAD_WITH_ALTERED_SEARCH_PATH).  The function names in this
27
   wrapper loads with LoadLibraryEx(LOAD_WITH_ALTERED_SEARCH_PATH).
28
   wrapped code are truncated from the long JNICALL names, as JNICALL causes
28
   The function names in this wrapped code are truncated from the long JNICALL
29
   some "@N" with different numeric values for N (and probably different across
29
   names, as JNICALL causes some "@N" with different numeric values for
30
   32 and 64 bit) to be added to the symbol names, which the calls to
30
   N (and probably different across 32 and 64 bit) to be added to the symbol
31
   GetProcAddress in wrapper/wrapper.c would otheriwse have to take into
31
   names, which the calls to GetProcAddress in wrapper/wrapper.c would otherwise
32
   account.
32
   have to take into account.
33
*/
33
*/
34
34
35
/*****************************************************************************/
35
/*****************************************************************************/
(-)a/jurt/source/pipe/wrapper/wrapper.c (-15 / +37 lines)
Lines 26-52 Link Here
26
#include "jni.h"
26
#include "jni.h"
27
#include "sal/types.h"
27
#include "sal/types.h"
28
28
29
static HMODULE module;
30
29
31
static FARPROC getFunction(char const * name) {
30
static HMODULE   module   = NULL;
31
static HINSTANCE hInstDLL = NULL;
32
static CRITICAL_SECTION CriticalSection;
33
34
void InitWrapper(void) {
35
    #define MAXPATH 512
36
    wchar_t path[MAXPATH];
37
    DWORD size;
38
39
    size = GetModuleFileNameW(hInstDLL, path, MAXPATH);
40
    if (size == 0) {
41
        abort();
42
    }
43
    path[size - 5] = L'x'; /* ...\jpipe.dll -> ...\jpipx.dll */
44
    module = LoadLibraryExW(path, NULL, LOAD_WITH_ALTERED_SEARCH_PATH);
45
    if (module == NULL) {
46
        abort();
47
    }
48
}
49
50
static FARPROC getFunction(char const * name)
51
{
52
    {
53
        EnterCriticalSection(&CriticalSection);
54
55
        if(module == NULL)
56
            InitWrapper();
57
58
        LeaveCriticalSection(&CriticalSection);
59
    }
60
32
    return GetProcAddress(module, name);
61
    return GetProcAddress(module, name);
33
}
62
}
34
63
35
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) {
64
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) {
36
    (void) lpvReserved;
65
    (void) lpvReserved;
37
    if (fdwReason == DLL_PROCESS_ATTACH) {
66
38
        wchar_t path[32767];
67
    if (fdwReason == DLL_PROCESS_ATTACH)
39
        DWORD size;
68
    {
40
        size = GetModuleFileNameW(hinstDLL, path, 32767);
69
        InitializeCriticalSection(&CriticalSection);
41
        if (size == 0) {
70
        hInstDLL = hinstDLL;
42
            return FALSE;
43
        }
44
        path[size - 5] = L'x'; /* ...\jpipe.dll -> ...\jpipx.dll */
45
        module = LoadLibraryExW(path, NULL, LOAD_WITH_ALTERED_SEARCH_PATH);
46
        if (module == NULL) {
47
            return FALSE;
48
        }
49
    }
71
    }
72
50
    return TRUE;
73
    return TRUE;
51
}
74
}
52
75
53
- 

Return to issue 126360