ReactOS  0.4.13-dev-259-g5ca9c9c
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 
36 static HHOOK s_hNotifyHook;
37 
38 
40 {
41  switch(dwReason) {
42  case DLL_PROCESS_ATTACH:
45  WM_GETMODULEPATH = RegisterWindowMessageA("WM_GETMODULEPATH");
46  break;
47  }
48 
49  return TRUE;
50 }
51 
52 
55  int _len;
56  char _path[MAX_PATH];
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 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
static UINT WM_GETMODULEPATH
Definition: notifyhook.c:35
#define TRUE
Definition: types.h:120
#define WH_GETMESSAGE
Definition: winuser.h:33
char _path[MAX_PATH]
Definition: notifyhook.c:56
static HINSTANCE s_hInstance
Definition: notifyhook.c:34
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1827
DECL_NOTIFYHOOK int GetWindowModulePathCopyData(LPARAM lparam, HWND *phwnd, LPSTR buffer, int size)
Definition: notifyhook.c:103
#define CALLBACK
Definition: compat.h:27
UINT WINAPI GetWindowModuleFileNameA(_In_ HWND hwnd, _Out_writes_to_(cchFileNameMax, return) LPSTR pszFileName, _In_ UINT cchFileNameMax)
BOOL WINAPI DisableThreadLibraryCalls(IN HMODULE hLibModule)
Definition: loader.c:85
BOOL APIENTRY DllMain(HINSTANCE hInst, DWORD dwReason, LPVOID param)
Definition: notifyhook.c:39
GLuint buffer
Definition: glext.h:5915
#define DLL_PROCESS_ATTACH
Definition: compat.h:120
UINT_PTR WPARAM
Definition: windef.h:207
char * LPSTR
Definition: xmlstorage.h:182
DWORD dwReason
Definition: misc.cpp:154
static HHOOK s_hNotifyHook
Definition: notifyhook.c:36
unsigned int BOOL
Definition: ntddk_ex.h:94
static UINT WPARAM LPARAM lparam
Definition: combo.c:716
LONG_PTR LPARAM
Definition: windef.h:208
void DeinstallNotifyHook()
Definition: notifyhook.c:90
LRESULT CALLBACK NotifyHookProc(int code, WPARAM wparam, LPARAM lparam)
Definition: notifyhook.c:59
#define WM_COPYDATA
Definition: winuser.h:1646
GLsizeiptr size
Definition: glext.h:5919
GLfloat param
Definition: glext.h:5796
#define MAX_PATH
Definition: compat.h:26
#define SetWindowsHookEx
Definition: winuser.h:5722
unsigned long DWORD
Definition: ntddk_ex.h:95
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
struct tagCOPYDATASTRUCT * PCOPYDATASTRUCT
#define DECL_NOTIFYHOOK
Definition: notifyhook.h:32
BOOL WINAPI UnhookWindowsHookEx(_In_ HHOOK)
LRESULT WINAPI CallNextHookEx(_In_opt_ HHOOK, _In_ int, _In_ WPARAM, _In_ LPARAM)
HINSTANCE hInst
Definition: dxdiag.c:13
unsigned int UINT
Definition: ndis.h:50
void GetWindowModulePath(HWND hwnd)
Definition: notifyhook.c:97
#define SendMessage
Definition: winuser.h:5709
#define COUNTOF(x)
Definition: utility.h:93
UINT InstallNotifyHook()
Definition: notifyhook.c:83
LONG_PTR LRESULT
Definition: windef.h:209
UINT WINAPI RegisterWindowMessageA(_In_ LPCSTR)
#define APIENTRY
Definition: api.h:79
static UINT WPARAM wparam
Definition: combo.c:716
#define lstrcpyn
Definition: winbase.h:3689