27 |
#include "gpgme.h" |
#include "gpgme.h" |
28 |
#include "GPGOE.h" |
#include "GPGOE.h" |
29 |
|
|
|
|
|
30 |
/* Global DLL module handle. */ |
/* Global DLL module handle. */ |
31 |
HINSTANCE mod_hinst_dll; |
HINSTANCE mod_hinst_dll; |
32 |
|
|
33 |
|
/* Outlook Express old window procedure. */ |
34 |
|
WNDPROC oe_proc_old; |
35 |
|
|
36 |
/* DLL hook handle for the CBT function. */ |
/* DLL hook handle for the CBT function. */ |
37 |
static HHOOK ctb_hook = NULL; |
static HHOOK ctb_hook = NULL; |
38 |
|
|
39 |
/* Outlook Express window handle. */ |
/* Outlook Express window handle. */ |
40 |
static HWND oe_hwnd = NULL; |
static HWND oe_hwnd = NULL; |
41 |
|
|
|
/* Outlook Express old window procedure. */ |
|
|
WNDPROC oe_proc_old; |
|
|
|
|
42 |
|
|
43 |
/* Main DLL entry point. */ |
/* Main DLL entry point. */ |
44 |
BOOL WINAPI |
BOOL WINAPI |
65 |
|
|
66 |
|
|
67 |
/* Quick and dirty check if the dialog is a common dialog |
/* Quick and dirty check if the dialog is a common dialog |
68 |
and the 'File Save' style. */ |
and the 'File {Open, Save}' style. */ |
69 |
static int |
static int |
70 |
is_filesave_dlg (HWND h) |
is_common_file_dlg (HWND h) |
71 |
{ |
{ |
72 |
HWND button = GetDlgItem (h, 1040); |
HWND button = GetDlgItem (h, 1040); |
73 |
char wclass[200]; |
char wclass[200]; |
81 |
} |
} |
82 |
|
|
83 |
|
|
84 |
|
|
85 |
/* CTB hook procedure. |
/* CTB hook procedure. |
86 |
Monitors the creation of all windows and subclass the window |
Monitors the creation of all windows and subclass the window |
87 |
if it belongs to the Outlook Express message class. */ |
if it belongs to the Outlook Express (message) class. */ |
88 |
static LRESULT CALLBACK |
static LRESULT CALLBACK |
89 |
ctb_proc (int code, WPARAM wparam, LPARAM lparam) |
ctb_proc (int code, WPARAM wparam, LPARAM lparam) |
90 |
{ |
{ |
111 |
else |
else |
112 |
oe_hwnd = hwnd; |
oe_hwnd = hwnd; |
113 |
} |
} |
114 |
|
|
115 |
|
if (!strcmp (wclass, "Outlook Express Browser Class")) { |
116 |
|
oe_main_proc_old = (WNDPROC)GetWindowLong (hwnd, GWL_WNDPROC); |
117 |
|
if (!oe_main_proc_old) |
118 |
|
show_error (NULL, "GPGOE", MB_ICONERROR|MB_OK, |
119 |
|
"Could not get window procedure ec=%d", |
120 |
|
(int)GetLastError ()); |
121 |
|
else if (!SetWindowLong (hwnd, GWL_WNDPROC, (LONG)(WNDPROC)oe_main_proc)) |
122 |
|
show_error (NULL, "GPGOE", MB_ICONERROR|MB_OK, |
123 |
|
"Could not set window procedure: ec=%d", |
124 |
|
(int)GetLastError ()); |
125 |
|
} |
126 |
break; |
break; |
127 |
|
|
|
#if 0 |
|
128 |
case HCBT_ACTIVATE: |
case HCBT_ACTIVATE: |
129 |
|
#if 0 |
130 |
if (plugin_active != NULL && |
if (plugin_active != NULL && |
131 |
WaitForSingleObject (plugin_active, 0) == WAIT_OBJECT_0) { |
WaitForSingleObject (plugin_active, 0) == WAIT_OBJECT_0) { |
132 |
char wclass[200]; |
char wclass[200]; |
133 |
|
|
134 |
if (GetClassName (hwnd, wclass, sizeof (wclass)-1) <= 0 || |
if (GetClassName (hwnd, wclass, sizeof (wclass)-1) <= 0 || |
135 |
!strstr (wclass, "#32770") || !is_filesave_dlg (hwnd)) |
!strstr (wclass, "#32770") || !is_common_file_dlg (hwnd)) |
136 |
break; |
break; |
137 |
of_proc_old = (WNDPROC)GetWindowLong (hwnd, GWL_WNDPROC); |
of_proc_old = (WNDPROC)GetWindowLong (hwnd, GWL_WNDPROC); |
138 |
SetWindowLong (hwnd, GWL_WNDPROC, (LONG)(WNDPROC)of_proc); |
SetWindowLong (hwnd, GWL_WNDPROC, (LONG)(WNDPROC)of_proc); |
139 |
} |
} |
|
break; |
|
140 |
#endif |
#endif |
141 |
|
break; |
142 |
} |
} |
143 |
return CallNextHookEx (ctb_hook, code, wparam, lparam); |
return CallNextHookEx (ctb_hook, code, wparam, lparam); |
144 |
} |
} |
145 |
|
|
146 |
|
|
147 |
/* Initialize the hooks. |
/* Initialize the hooks; a named mutex prevents that the |
148 |
To prevent double initialisation, we use a named mutex. */ |
initialisation is done twice. |
149 |
|
Return value: 0 on success. */ |
150 |
int |
int |
151 |
gpgoe_initialize (void) |
gpgoe_initialize (void) |
152 |
{ |
{ |
158 |
} |
} |
159 |
|
|
160 |
|
|
161 |
/* Deinitialize the hooks and close all handles. */ |
/* Deinitialize the hooks and close all handles. |
162 |
|
Return value: 0 on success. */ |
163 |
int |
int |
164 |
gpgoe_remove (void) |
gpgoe_remove (void) |
165 |
{ |
{ |
|
int rc = 0; |
|
166 |
HANDLE hd; |
HANDLE hd; |
167 |
|
int rc; |
168 |
|
|
169 |
hd = CreateMutex (NULL, TRUE, "gpgoe"); |
hd = CreateMutex (NULL, TRUE, "gpgoe"); |
170 |
if (GetLastError() == ERROR_ALREADY_EXISTS) { |
if (GetLastError() == ERROR_ALREADY_EXISTS) { |