From 57bbce4306410128397208dc4f1257055f9b5e82 Mon Sep 17 00:00:00 2001 From: Pierre Ossman Date: Wed, 25 Apr 2012 14:54:04 +0000 Subject: [PATCH] Use the gcc way of creating shared segments in DLLs. The previous way only works with MSVC. git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@4897 3789f03b-4d11-0410-bbf8-ca57d06f2519 --- win/wm_hooks/CMakeLists.txt | 1 - win/wm_hooks/wm_hooks.cxx | 38 ++++++++++++++++++------------------- win/wm_hooks/wm_hooks.def | 5 ----- 3 files changed, 18 insertions(+), 26 deletions(-) delete mode 100644 win/wm_hooks/wm_hooks.def diff --git a/win/wm_hooks/CMakeLists.txt b/win/wm_hooks/CMakeLists.txt index 071edafd..02bdb1f0 100644 --- a/win/wm_hooks/CMakeLists.txt +++ b/win/wm_hooks/CMakeLists.txt @@ -2,7 +2,6 @@ include_directories(${CMAKE_BINARY_DIR}/win ${CMAKE_CURRENT_SOURCE_DIR}) add_library(wm_hooks SHARED ../wm_hooks/wm_hooks.cxx - ../wm_hooks/wm_hooks.def ../wm_hooks/wm_hooks.rc) # We want the DLL to be named wm_hooks.dll rather than libwm_hooks.dll diff --git a/win/wm_hooks/wm_hooks.cxx b/win/wm_hooks/wm_hooks.cxx index 61328af8..50a981e8 100644 --- a/win/wm_hooks/wm_hooks.cxx +++ b/win/wm_hooks/wm_hooks.cxx @@ -25,6 +25,8 @@ #include #include +#define SHARED __attribute__((section ("shared"), shared)) + UINT WM_HK_PingThread = RegisterWindowMessage(_T("RFB.WM_Hooks.PingThread")); UINT WM_HK_WindowChanged = RegisterWindowMessage(_T("RFB.WM_Hooks.WindowChanged")); @@ -86,20 +88,18 @@ BOOL WINAPI DllMain(HANDLE instance, ULONG reason, LPVOID reserved) { // -=- Display update hooks // -#pragma data_seg(".WM_Hooks_Shared") -DWORD hook_owner = 0; -DWORD hook_target = 0; -HHOOK hook_CallWndProc = 0; -HHOOK hook_CallWndProcRet = 0; -HHOOK hook_GetMessage = 0; -HHOOK hook_DialogMessage = 0; -BOOL enable_cursor_shape = FALSE; -HCURSOR cursor = 0; +DWORD hook_owner SHARED = 0; +DWORD hook_target SHARED = 0; +HHOOK hook_CallWndProc SHARED = 0; +HHOOK hook_CallWndProcRet SHARED = 0; +HHOOK hook_GetMessage SHARED = 0; +HHOOK hook_DialogMessage SHARED = 0; +BOOL enable_cursor_shape SHARED = FALSE; +HCURSOR cursor SHARED = 0; #ifdef _DEBUG -UINT diagnostic_min=1; -UINT diagnostic_max=0; +UINT diagnostic_min SHARED =1; +UINT diagnostic_max SHARED =0; #endif -#pragma data_seg() #ifdef _DEBUG DLLEXPORT void WM_Hooks_SetDiagnosticRange(UINT min, UINT max) { @@ -374,14 +374,12 @@ BOOL WM_Hooks_Remove(DWORD owner) { // -=- User input hooks // -#pragma data_seg(".WM_Hooks_Shared") -HHOOK hook_keyboard = 0; -HHOOK hook_pointer = 0; -bool enable_real_ptr = true; -bool enable_synth_ptr = true; -bool enable_real_kbd = true; -bool enable_synth_kbd = true; -#pragma data_seg() +HHOOK hook_keyboard SHARED = 0; +HHOOK hook_pointer SHARED = 0; +bool enable_real_ptr SHARED = true; +bool enable_synth_ptr SHARED = true; +bool enable_real_kbd SHARED = true; +bool enable_synth_kbd SHARED = true; #ifdef WH_KEYBOARD_LL LRESULT CALLBACK HookKeyboardHook(int nCode, WPARAM wParam, LPARAM lParam) { diff --git a/win/wm_hooks/wm_hooks.def b/win/wm_hooks/wm_hooks.def deleted file mode 100644 index a70908a9..00000000 --- a/win/wm_hooks/wm_hooks.def +++ /dev/null @@ -1,5 +0,0 @@ -LIBRARY "wm_hooks" -; DESCRIPTION 'Window Message Hooks Dynamic Link Library' - -SECTIONS - .WM_Hooks_Shared read write shared -- 2.39.5