Subject: | Hooks support is broken in Strawberry Perl |
Hooks currently don't work if build with GCC/MingW.
I've added a patch to fix it. MSVC build is tested too, and works fine.
Subject: | strawberry.patch |
--- GuiTest.xs 2010-10-24 02:26:25.000000000 +0700
+++ GuiTest.xs_ 2010-10-24 02:28:16.000000000 +0700
@@ -38,29 +38,36 @@
HINSTANCE g_hDLL = NULL;
+
+#if defined (__GNUC__)
+ #define SHARED_ATTR __attribute__((section ("shared_seg"), shared))
+#else
+ #define SHARED_ATTR
+#endif
+
#pragma data_seg(".shared")
// Used by hooking/injected routines
-HWND g_hWnd = 0;
-HHOOK g_hHook = NULL;
-HWND g_popup = 0; //Hold's popup menu's handle
-BOOL g_bRetVal = 0;
-char g_szBuffer[MAX_DATA_BUF+1] = {NUL};
-UINT WM_LV_GETTEXT = 0;
-UINT WM_LV_SELBYINDEX = 0;
-UINT WM_LV_SELBYTEXT = 0;
-UINT WM_LV_ISSEL = 0;
-UINT WM_TC_GETTEXT = 0;
-UINT WM_TC_SELBYINDEX = 0;
-UINT WM_TC_SELBYTEXT = 0;
-UINT WM_TC_ISSEL = 0;
-UINT WM_TV_SELBYPATH = 0;
-UINT WM_TV_GETSELPATH = 0;
-UINT WM_INITMENUPOPUPX = WM_INITMENUPOPUP; //Only needed to conform with SetHook()'s calling convention
-BOOL unicode_semantics = 0;
+HWND g_hWnd SHARED_ATTR = 0;
+HHOOK g_hHook SHARED_ATTR = NULL;
+HWND g_popup SHARED_ATTR = 0; //Hold's popup menu's handle
+BOOL g_bRetVal SHARED_ATTR = 0;
+char g_szBuffer[MAX_DATA_BUF+1] SHARED_ATTR = {NUL};
+UINT WM_LV_GETTEXT SHARED_ATTR = 0;
+UINT WM_LV_SELBYINDEX SHARED_ATTR = 0;
+UINT WM_LV_SELBYTEXT SHARED_ATTR = 0;
+UINT WM_LV_ISSEL SHARED_ATTR = 0;
+UINT WM_TC_GETTEXT SHARED_ATTR = 0;
+UINT WM_TC_SELBYINDEX SHARED_ATTR = 0;
+UINT WM_TC_SELBYTEXT SHARED_ATTR = 0;
+UINT WM_TC_ISSEL SHARED_ATTR = 0;
+UINT WM_TV_SELBYPATH SHARED_ATTR = 0;
+UINT WM_TV_GETSELPATH SHARED_ATTR = 0;
+UINT WM_INITMENUPOPUPX SHARED_ATTR = WM_INITMENUPOPUP; //Only needed to conform with SetHook()'s calling convention
+BOOL unicode_semantics SHARED_ATTR = 0;
#pragma data_seg()
#pragma comment(linker, "/SECTION:.shared,RWS")
-BOOL APIENTRY DllMain(HANDLE hModule, DWORD ul_reason_for_call,
+extern "C" BOOL WINAPI DllMain(HANDLE hModule, DWORD ul_reason_for_call,
LPVOID lpReserved)
{
switch (ul_reason_for_call)