[Winpt-commits] r61 - trunk/PTD
scm-commit at wald.intevation.org
scm-commit at wald.intevation.org
Wed Nov 2 15:48:01 CET 2005
Author: werner
Date: 2005-11-02 15:48:01 +0100 (Wed, 02 Nov 2005)
New Revision: 61
Modified:
trunk/PTD/ChangeLog
trunk/PTD/PTD.cpp
Log:
Fixed DLLMain linkage and enabled shared segment.
Modified: trunk/PTD/ChangeLog
===================================================================
--- trunk/PTD/ChangeLog 2005-11-02 14:35:48 UTC (rev 60)
+++ trunk/PTD/ChangeLog 2005-11-02 14:48:01 UTC (rev 61)
@@ -1,3 +1,8 @@
+2005-11-02 Werner Koch <wk at g10code.com>
+
+ * PTD.cpp: Use an attribute to mark variables as shared.
+ (DllMain): Return int and not bool. Use C linkage.
+
2005-11-02 Timo Schulz <ts at g10code.com>
* wptWipeFile.cpp (add_random, init_random): New.
Modified: trunk/PTD/PTD.cpp
===================================================================
--- trunk/PTD/PTD.cpp 2005-11-02 14:35:48 UTC (rev 60)
+++ trunk/PTD/PTD.cpp 2005-11-02 14:48:01 UTC (rev 61)
@@ -32,17 +32,30 @@
HINSTANCE glob_hinst;
-/* We need a special section in the DLL for storing our shared data */
+/* We need a special section in the DLL for storing our shared data.
+ This shared data is required by the hook function becuase theat
+ function is called in the context of the actual thread running the
+ hook and thus we need a way to communicate the result of our hook
+ function back to us. We use a shared data segment for this. */
+#ifdef __GNUC__
+#define ATTR_SEC __attribute__((section (".SHARDAT"), shared))
+#else
+#define ATTR_SEC
#pragma data_seg(".SHARDAT")
-static HHOOK cbt_hook = NULL; /* CTB hook handle. */
-static DWORD tray_proc_id = 0; /* WinPT PID */
-static HWND shell_traywnd = 0; /* Tray window handle. */
-static HWND curr_focus = NULL; /* Current window focus handle. */
-static HWND rebar_w32 = NULL;
-static HWND mstask_swc = NULL;
-static HWND systab_c32 = NULL;
+#endif
+static HHOOK cbt_hook ATTR_SEC = NULL; /* CTB hook handle. */
+static DWORD tray_proc_id ATTR_SEC = 0; /* WinPT PID */
+static HWND shell_traywnd ATTR_SEC = 0; /* Tray window handle. */
+static HWND curr_focus ATTR_SEC = NULL; /* Current window focus handle. */
+static HWND rebar_w32 ATTR_SEC = NULL;
+static HWND mstask_swc ATTR_SEC = NULL;
+static HWND systab_c32 ATTR_SEC = NULL;
+#ifndef __GNUC__
#pragma data_seg()
+#endif
+#undef ATTR_SEC
+
static unsigned *journ_keys = 0;
static unsigned key_idx = 0;
static unsigned nkeys = 0;
@@ -93,15 +106,7 @@
tray_proc_id = GetCurrentProcessId ();
cbt_hook = SetWindowsHookEx (WH_CBT, PTD_CBT_proc, glob_hinst, 0);
if (cbt_hook == NULL)
- {
- char buf[500];
-
- FormatMessage (FORMAT_MESSAGE_FROM_SYSTEM, NULL, GetLastError (),
- MAKELANGID (LANG_NEUTRAL, SUBLANG_DEFAULT),
- buf, sizeof buf -1, NULL);
- MessageBox (NULL, buf, "Error", MB_OK|MB_ICONSTOP);
return FALSE;
- }
/* Okay, what are we doing here:
@@ -267,7 +272,7 @@
-BOOL WINAPI
+extern "C" int WINAPI
DllMain (HINSTANCE hinst, DWORD reason, LPVOID reserv)
{
switch (reason) {
More information about the Winpt-commits
mailing list