ReactOS 0.4.16-dev-336-gb667d82
notifyhook.c
Go to the documentation of this file.
1/*
2 * Copyright 2004 Martin Fuchs
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18
19
20 //
21 // NotifyHook DLL for ROS Explorer
22 //
23 // notifyhook.cpp
24 //
25 // Martin Fuchs, 17.03.2004
26 //
27
28
29#include "../utility/utility.h"
30
31#include "notifyhook.h"
32
33
36static HHOOK s_hNotifyHook;
37
38
40{
41 switch(dwReason) {
45 WM_GETMODULEPATH = RegisterWindowMessageA("WM_GETMODULEPATH");
46 break;
47 }
48
49 return TRUE;
50}
51
52
55 int _len;
57};
58
60{
61 MSG* pmsg = (MSG*)lparam;
62
63 if (pmsg->message == WM_GETMODULEPATH) {
64 struct COPYDATA_STRUCT cds;
66
67 cds._hwnd = pmsg->hwnd;
68 cds._len = GetWindowModuleFileNameA(pmsg->hwnd, cds._path, COUNTOF(cds._path));
69
70 data.dwData = WM_GETMODULEPATH;
71 data.cbData = sizeof(cds);
72 data.lpData = &cds;
73
74 SendMessage((HWND)pmsg->wParam, WM_COPYDATA, (WPARAM)pmsg->hwnd, (LPARAM)&data);
75
76 return 0;
77 }
78
80}
81
82
84{
86
87 return WM_GETMODULEPATH;
88}
89
91{
93 s_hNotifyHook = 0;
94}
95
96
98{
100}
101
102 // retrieve module path by receiving WM_COPYDATA message
104{
106
107 if (data->dwData == WM_GETMODULEPATH) {
108 struct COPYDATA_STRUCT* cds = (struct COPYDATA_STRUCT*) data->lpData;
109
110 *phwnd = cds->_hwnd;
111 lstrcpyn(buffer, cds->_path, size);
112
113 return cds->_len;
114 } else
115 return 0;
116}
@ lparam
Definition: SystemMenu.c:31
@ wparam
Definition: SystemMenu.c:30
DWORD dwReason
Definition: misc.cpp:141
#define TRUE
Definition: types.h:120
#define APIENTRY
Definition: api.h:79
#define DLL_PROCESS_ATTACH
Definition: compat.h:131
#define MAX_PATH
Definition: compat.h:34
#define CALLBACK
Definition: compat.h:35
BOOL WINAPI DisableThreadLibraryCalls(IN HMODULE hLibModule)
Definition: loader.c:85
HINSTANCE hInst
Definition: dxdiag.c:13
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
GLsizeiptr size
Definition: glext.h:5919
GLuint buffer
Definition: glext.h:5915
GLfloat param
Definition: glext.h:5796
#define COUNTOF(x)
Definition: utility.h:93
unsigned int UINT
Definition: ndis.h:50
void DeinstallNotifyHook()
Definition: notifyhook.c:90
LRESULT CALLBACK NotifyHookProc(int code, WPARAM wparam, LPARAM lparam)
Definition: notifyhook.c:59
static HINSTANCE s_hInstance
Definition: notifyhook.c:34
BOOL APIENTRY DllMain(HINSTANCE hInst, DWORD dwReason, LPVOID param)
Definition: notifyhook.c:39
DECL_NOTIFYHOOK int GetWindowModulePathCopyData(LPARAM lparam, HWND *phwnd, LPSTR buffer, int size)
Definition: notifyhook.c:103
static UINT WM_GETMODULEPATH
Definition: notifyhook.c:35
void GetWindowModulePath(HWND hwnd)
Definition: notifyhook.c:97
static HHOOK s_hNotifyHook
Definition: notifyhook.c:36
UINT InstallNotifyHook()
Definition: notifyhook.c:83
#define DECL_NOTIFYHOOK
Definition: notifyhook.h:32
char _path[MAX_PATH]
Definition: notifyhook.c:56
Definition: inflate.c:139
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1829
#define lstrcpyn
Definition: winbase.h:3900
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023
LONG_PTR LPARAM
Definition: windef.h:208
LONG_PTR LRESULT
Definition: windef.h:209
UINT_PTR WPARAM
Definition: windef.h:207
UINT WINAPI RegisterWindowMessageA(_In_ LPCSTR)
struct tagCOPYDATASTRUCT * PCOPYDATASTRUCT
#define SetWindowsHookEx
Definition: winuser.h:5868
BOOL WINAPI UnhookWindowsHookEx(_In_ HHOOK)
#define WM_COPYDATA
Definition: winuser.h:1667
#define SendMessage
Definition: winuser.h:5855
#define WH_GETMESSAGE
Definition: winuser.h:33
LRESULT WINAPI CallNextHookEx(_In_opt_ HHOOK, _In_ int, _In_ WPARAM, _In_ LPARAM)
UINT WINAPI GetWindowModuleFileNameA(_In_ HWND hwnd, _Out_writes_to_(cchFileNameMax, return) LPSTR pszFileName, _In_ UINT cchFileNameMax)
char * LPSTR
Definition: xmlstorage.h:182