ReactOS  0.4.15-dev-1374-g8d3e80e
CChangeNotifyServer Class Reference
Inheritance diagram for CChangeNotifyServer:
Collaboration diagram for CChangeNotifyServer:

Public Member Functions

 CChangeNotifyServer ()
 
virtual ~CChangeNotifyServer ()
 
HRESULT Initialize ()
 
virtual HRESULT STDMETHODCALLTYPE GetWindow (HWND *lphwnd)
 
virtual HRESULT STDMETHODCALLTYPE ContextSensitiveHelp (BOOL fEnterMode)
 
LRESULT OnRegister (UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
 
LRESULT OnUnRegister (UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
 
LRESULT OnDeliverNotification (UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
 
LRESULT OnSuspendResume (UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
 
LRESULT OnRemoveByPID (UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
 
LRESULT OnDestroy (UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
 
 MESSAGE_HANDLER (CN_UNREGISTER_PROCESS, OnRemoveByPID)
 
 MESSAGE_HANDLER (WM_DESTROY, OnDestroy)
 
- Public Member Functions inherited from ATL::CComObjectRootEx< CComMultiThreadModelNoCS >
 ~CComObjectRootEx ()
 
ULONG InternalAddRef ()
 
ULONG InternalRelease ()
 
void Lock ()
 
void Unlock ()
 
HRESULT _AtlInitialConstruct ()
 
- Public Member Functions inherited from ATL::CComObjectRootBase
 CComObjectRootBase ()
 
 ~CComObjectRootBase ()
 
void SetVoid (void *)
 
HRESULT _AtlFinalConstruct ()
 
HRESULT FinalConstruct ()
 
void InternalFinalConstructAddRef ()
 
void InternalFinalConstructRelease ()
 
void FinalRelease ()
 
- Public Member Functions inherited from IUnknown
HRESULT QueryInterface ([in] REFIID riid, [out, iid_is(riid)] void **ppvObject)
 
ULONG AddRef ()
 
ULONG Release ()
 

Private Member Functions

BOOL AddItem (UINT nRegID, DWORD dwUserPID, HANDLE hRegEntry, HWND hwndBroker, CDirectoryWatcher *pDirWatch)
 
BOOL RemoveItemsByRegID (UINT nRegID, DWORD dwOwnerPID)
 
void RemoveItemsByProcess (DWORD dwOwnerPID, DWORD dwUserPID)
 
void DestroyItem (ITEM &item, DWORD dwOwnerPID, HWND *phwndBroker)
 
UINT GetNextRegID ()
 
BOOL DeliverNotification (HANDLE hTicket, DWORD dwOwnerPID)
 
BOOL ShouldNotify (LPDELITICKET pTicket, LPREGENTRY pRegEntry)
 

Private Attributes

UINT m_nNextRegID
 
CSimpleArray< ITEMm_items
 

Additional Inherited Members

- Public Types inherited from IOleWindow
typedef IOleWindowLPOLEWINDOW
 
- Public Types inherited from IUnknown
typedef IUnknownLPUNKNOWN
 
- Static Public Member Functions inherited from ATL::CComObjectRootBase
static void WINAPI ObjectMain (bool)
 
static const struct _ATL_CATMAP_ENTRYGetCategoryMap ()
 
static HRESULT WINAPI InternalQueryInterface (void *pThis, const _ATL_INTMAP_ENTRY *pEntries, REFIID iid, void **ppvObject)
 
- Public Attributes inherited from ATL::CComObjectRootBase
LONG m_dwRef
 

Detailed Description

Definition at line 39 of file CChangeNotifyServer.cpp.

Constructor & Destructor Documentation

◆ CChangeNotifyServer()

CChangeNotifyServer::CChangeNotifyServer ( )

Definition at line 94 of file CChangeNotifyServer.cpp.

96 {
97 }
#define INVALID_REG_ID

◆ ~CChangeNotifyServer()

CChangeNotifyServer::~CChangeNotifyServer ( )
virtual

Definition at line 99 of file CChangeNotifyServer.cpp.

100 {
101 }

Member Function Documentation

◆ AddItem()

BOOL CChangeNotifyServer::AddItem ( UINT  nRegID,
DWORD  dwUserPID,
HANDLE  hRegEntry,
HWND  hwndBroker,
CDirectoryWatcher pDirWatch 
)
private

Definition at line 103 of file CChangeNotifyServer.cpp.

105 {
106  // find the empty room
107  for (INT i = 0; i < m_items.GetSize(); ++i)
108  {
109  if (m_items[i].nRegID == INVALID_REG_ID)
110  {
111  // found the room, populate it
112  m_items[i].nRegID = nRegID;
113  m_items[i].dwUserPID = dwUserPID;
114  m_items[i].hRegEntry = hRegEntry;
115  m_items[i].hwndBroker = hwndBroker;
116  m_items[i].pDirWatch = pDirWatch;
117  return TRUE;
118  }
119  }
120 
121  // no empty room found
122  ITEM item = { nRegID, dwUserPID, hRegEntry, hwndBroker, pDirWatch };
123  m_items.Add(item);
124  return TRUE;
125 }
#define TRUE
Definition: types.h:120
CSimpleArray< ITEM > m_items
int32_t INT
Definition: typedefs.h:58
#define INVALID_REG_ID
static ATOM item
Definition: dde.c:856
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248

Referenced by OnRegister().

◆ ContextSensitiveHelp()

HRESULT WINAPI CChangeNotifyServer::ContextSensitiveHelp ( BOOL  fEnterMode)
virtual

Implements IOleWindow.

Definition at line 465 of file CChangeNotifyServer.cpp.

466 {
467  return E_NOTIMPL;
468 }
#define E_NOTIMPL
Definition: ddrawi.h:99

◆ DeliverNotification()

BOOL CChangeNotifyServer::DeliverNotification ( HANDLE  hTicket,
DWORD  dwOwnerPID 
)
private

Definition at line 347 of file CChangeNotifyServer.cpp.

348 {
349  TRACE("DeliverNotification(%p, %p, 0x%lx)\n", m_hWnd, hTicket, dwOwnerPID);
350 
351  // lock the delivery ticket
352  LPDELITICKET pTicket = (LPDELITICKET)SHLockSharedEx(hTicket, dwOwnerPID, FALSE);
353  if (pTicket == NULL || pTicket->dwMagic != DELITICKET_MAGIC)
354  {
355  ERR("pTicket is invalid\n");
356  SHUnlockShared(pTicket);
357  return FALSE;
358  }
359 
360  // for all items
361  for (INT i = 0; i < m_items.GetSize(); ++i)
362  {
363  // validate the item
364  if (m_items[i].nRegID == INVALID_REG_ID)
365  continue;
366 
367  HANDLE hRegEntry = m_items[i].hRegEntry;
368  if (hRegEntry == NULL)
369  continue;
370 
371  // lock the registration entry
372  LPREGENTRY pRegEntry = (LPREGENTRY)SHLockSharedEx(hRegEntry, dwOwnerPID, FALSE);
373  if (pRegEntry == NULL || pRegEntry->dwMagic != REGENTRY_MAGIC)
374  {
375  ERR("pRegEntry is invalid\n");
376  SHUnlockShared(pRegEntry);
377  continue;
378  }
379 
380  // should we notify for it?
381  BOOL bNotify = ShouldNotify(pTicket, pRegEntry);
382  if (bNotify)
383  {
384  // do notify
385  TRACE("Notifying: %p, 0x%x, %p, %lu\n",
386  pRegEntry->hwnd, pRegEntry->uMsg, hTicket, dwOwnerPID);
387  SendMessageW(pRegEntry->hwnd, pRegEntry->uMsg, (WPARAM)hTicket, dwOwnerPID);
388  TRACE("GetLastError(): %ld\n", ::GetLastError());
389  }
390 
391  // unlock the registration entry
392  SHUnlockShared(pRegEntry);
393  }
394 
395  // unlock the ticket
396  SHUnlockShared(pTicket);
397 
398  return TRUE;
399 }
PVOID WINAPI SHLockSharedEx(HANDLE hData, DWORD dwProcessId, BOOL bWriteAccess)
#define TRUE
Definition: types.h:120
#define DELITICKET_MAGIC
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1044
UINT_PTR WPARAM
Definition: windef.h:207
CSimpleArray< ITEM > m_items
#define REGENTRY_MAGIC
int32_t INT
Definition: typedefs.h:58
#define INVALID_REG_ID
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
#define TRACE(s)
Definition: solgame.cpp:4
BOOL ShouldNotify(LPDELITICKET pTicket, LPREGENTRY pRegEntry)
#define ERR(fmt,...)
Definition: debug.h:110
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define NULL
Definition: types.h:112
struct DELITICKET * LPDELITICKET
BOOL WINAPI SHUnlockShared(LPVOID lpView)
Definition: ordinal.c:288
struct REGENTRY * LPREGENTRY

Referenced by OnDeliverNotification().

◆ DestroyItem()

void CChangeNotifyServer::DestroyItem ( ITEM item,
DWORD  dwOwnerPID,
HWND phwndBroker 
)
private

Definition at line 127 of file CChangeNotifyServer.cpp.

128 {
129  // destroy broker if any and if first time
130  HWND hwndBroker = item.hwndBroker;
131  item.hwndBroker = NULL;
132  if (hwndBroker && hwndBroker != *phwndBroker)
133  {
134  ::DestroyWindow(hwndBroker);
135  *phwndBroker = hwndBroker;
136  }
137 
138  // request termination of pDirWatch if any
139  CDirectoryWatcher *pDirWatch = item.pDirWatch;
140  item.pDirWatch = NULL;
141  if (pDirWatch)
142  pDirWatch->RequestTermination();
143 
144  // free
145  SHFreeShared(item.hRegEntry, dwOwnerPID);
146  item.nRegID = INVALID_REG_ID;
147  item.dwUserPID = 0;
148  item.hRegEntry = NULL;
149  item.hwndBroker = NULL;
150  item.pDirWatch = NULL;
151 }
BOOL WINAPI DestroyWindow(_In_ HWND)
#define INVALID_REG_ID
BOOL WINAPI SHFreeShared(HANDLE hShared, DWORD dwProcId)
Definition: ordinal.c:308
static ATOM item
Definition: dde.c:856
#define NULL
Definition: types.h:112

Referenced by RemoveItemsByProcess(), and RemoveItemsByRegID().

◆ GetNextRegID()

UINT CChangeNotifyServer::GetNextRegID ( )
private

Definition at line 337 of file CChangeNotifyServer.cpp.

338 {
339  m_nNextRegID++;
341  m_nNextRegID++;
342  return m_nNextRegID;
343 }
#define INVALID_REG_ID

Referenced by OnRegister().

◆ GetWindow()

HRESULT WINAPI CChangeNotifyServer::GetWindow ( HWND lphwnd)
virtual

Implements IOleWindow.

Definition at line 457 of file CChangeNotifyServer.cpp.

458 {
459  if (!phwnd)
460  return E_INVALIDARG;
461  *phwnd = m_hWnd;
462  return S_OK;
463 }
#define E_INVALIDARG
Definition: ddrawi.h:101
#define S_OK
Definition: intsafe.h:51

◆ Initialize()

HRESULT CChangeNotifyServer::Initialize ( )

Definition at line 470 of file CChangeNotifyServer.cpp.

471 {
472  // This is called by CChangeNotifyServer_CreateInstance right after instantiation.
473  // Create the window of the server here.
474  Create(0);
475  if (!m_hWnd)
476  return E_FAIL;
477  return S_OK;
478 }
_In_ BOOLEAN Create
Definition: pstypes.h:519
#define E_FAIL
Definition: ddrawi.h:102
#define S_OK
Definition: intsafe.h:51

◆ MESSAGE_HANDLER() [1/2]

CChangeNotifyServer::MESSAGE_HANDLER ( CN_UNREGISTER_PROCESS  ,
OnRemoveByPID   
)

◆ MESSAGE_HANDLER() [2/2]

CChangeNotifyServer::MESSAGE_HANDLER ( WM_DESTROY  ,
OnDestroy   
)

◆ OnDeliverNotification()

LRESULT CChangeNotifyServer::OnDeliverNotification ( UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam,
BOOL bHandled 
)

Definition at line 293 of file CChangeNotifyServer.cpp.

294 {
295  TRACE("OnDeliverNotification(%p, %u, %p, %p)\n", m_hWnd, uMsg, wParam, lParam);
296 
297  HANDLE hTicket = (HANDLE)wParam;
298  DWORD dwOwnerPID = (DWORD)lParam;
299 
300  // do delivery
301  BOOL ret = DeliverNotification(hTicket, dwOwnerPID);
302 
303  // free the ticket
304  SHFreeShared(hTicket, dwOwnerPID);
305  return ret;
306 }
#define DWORD
Definition: nt_native.h:44
WPARAM wParam
Definition: combotst.c:138
unsigned int BOOL
Definition: ntddk_ex.h:94
#define TRACE(s)
Definition: solgame.cpp:4
unsigned long DWORD
Definition: ntddk_ex.h:95
PVOID HANDLE
Definition: typedefs.h:73
BOOL WINAPI SHFreeShared(HANDLE hShared, DWORD dwProcId)
Definition: ordinal.c:308
int ret
BOOL DeliverNotification(HANDLE hTicket, DWORD dwOwnerPID)
LPARAM lParam
Definition: combotst.c:139

◆ OnDestroy()

LRESULT CChangeNotifyServer::OnDestroy ( UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam,
BOOL bHandled 
)

Definition at line 330 of file CChangeNotifyServer.cpp.

331 {
333  return 0;
334 }
static void RequestAllWatchersTermination()

◆ OnRegister()

LRESULT CChangeNotifyServer::OnRegister ( UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam,
BOOL bHandled 
)

Definition at line 207 of file CChangeNotifyServer.cpp.

208 {
209  TRACE("OnRegister(%p, %u, %p, %p)\n", m_hWnd, uMsg, wParam, lParam);
210 
211  // lock the registration entry
212  HANDLE hRegEntry = (HANDLE)wParam;
213  DWORD dwOwnerPID = (DWORD)lParam;
214  LPREGENTRY pRegEntry = (LPREGENTRY)SHLockSharedEx(hRegEntry, dwOwnerPID, TRUE);
215  if (pRegEntry == NULL || pRegEntry->dwMagic != REGENTRY_MAGIC)
216  {
217  ERR("pRegEntry is invalid\n");
218  SHUnlockShared(pRegEntry);
219  return FALSE;
220  }
221 
222  // update registration ID if necessary
223  if (pRegEntry->nRegID == INVALID_REG_ID)
224  pRegEntry->nRegID = GetNextRegID();
225 
226  TRACE("pRegEntry->nRegID: %u\n", pRegEntry->nRegID);
227 
228  // get the user PID; that is the process ID of the target window
229  DWORD dwUserPID;
230  GetWindowThreadProcessId(pRegEntry->hwnd, &dwUserPID);
231 
232  // get broker if any
233  HWND hwndBroker = pRegEntry->hwndBroker;
234 
235  // clone the registration entry
236  HANDLE hNewEntry = SHAllocShared(pRegEntry, pRegEntry->cbSize, dwOwnerPID);
237  if (hNewEntry == NULL)
238  {
239  ERR("Out of memory\n");
240  pRegEntry->nRegID = INVALID_REG_ID;
241  SHUnlockShared(pRegEntry);
242  return FALSE;
243  }
244 
245  // create a directory watch if necessary
246  CDirectoryWatcher *pDirWatch = NULL;
247  if (pRegEntry->ibPidl && (pRegEntry->fSources & SHCNRF_InterruptLevel))
248  {
249  pDirWatch = CreateDirectoryWatcherFromRegEntry(pRegEntry);
250  if (pDirWatch && !pDirWatch->RequestAddWatcher())
251  {
252  ERR("RequestAddWatcher failed: %u\n", pRegEntry->nRegID);
253  pRegEntry->nRegID = INVALID_REG_ID;
254  SHUnlockShared(pRegEntry);
255  delete pDirWatch;
256  return FALSE;
257  }
258  }
259 
260  // unlock the registry entry
261  SHUnlockShared(pRegEntry);
262 
263  // add an ITEM
264  return AddItem(m_nNextRegID, dwUserPID, hNewEntry, hwndBroker, pDirWatch);
265 }
PVOID WINAPI SHLockSharedEx(HANDLE hData, DWORD dwProcessId, BOOL bWriteAccess)
#define TRUE
Definition: types.h:120
#define REGENTRY_MAGIC
#define DWORD
Definition: nt_native.h:44
WPARAM wParam
Definition: combotst.c:138
BOOL AddItem(UINT nRegID, DWORD dwUserPID, HANDLE hRegEntry, HWND hwndBroker, CDirectoryWatcher *pDirWatch)
static CDirectoryWatcher * CreateDirectoryWatcherFromRegEntry(LPREGENTRY pRegEntry)
#define INVALID_REG_ID
#define FALSE
Definition: types.h:117
DWORD WINAPI GetWindowThreadProcessId(HWND, PDWORD)
#define SHCNRF_InterruptLevel
Definition: shlobj.h:1774
#define TRACE(s)
Definition: solgame.cpp:4
HANDLE WINAPI SHAllocShared(LPCVOID lpvData, DWORD dwSize, DWORD dwProcId)
Definition: ordinal.c:162
unsigned long DWORD
Definition: ntddk_ex.h:95
PVOID HANDLE
Definition: typedefs.h:73
#define ERR(fmt,...)
Definition: debug.h:110
#define NULL
Definition: types.h:112
BOOL WINAPI SHUnlockShared(LPVOID lpView)
Definition: ordinal.c:288
LPARAM lParam
Definition: combotst.c:139
struct REGENTRY * LPREGENTRY

◆ OnRemoveByPID()

LRESULT CChangeNotifyServer::OnRemoveByPID ( UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam,
BOOL bHandled 
)

Definition at line 322 of file CChangeNotifyServer.cpp.

323 {
324  DWORD dwOwnerPID, dwUserPID = (DWORD)wParam;
325  GetWindowThreadProcessId(m_hWnd, &dwOwnerPID);
326  RemoveItemsByProcess(dwOwnerPID, dwUserPID);
327  return 0;
328 }
#define DWORD
Definition: nt_native.h:44
WPARAM wParam
Definition: combotst.c:138
void RemoveItemsByProcess(DWORD dwOwnerPID, DWORD dwUserPID)
DWORD WINAPI GetWindowThreadProcessId(HWND, PDWORD)
unsigned long DWORD
Definition: ntddk_ex.h:95

◆ OnSuspendResume()

LRESULT CChangeNotifyServer::OnSuspendResume ( UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam,
BOOL bHandled 
)

Definition at line 310 of file CChangeNotifyServer.cpp.

311 {
312  TRACE("OnSuspendResume\n");
313 
314  // FIXME
315  return FALSE;
316 }
#define FALSE
Definition: types.h:117
#define TRACE(s)
Definition: solgame.cpp:4

◆ OnUnRegister()

LRESULT CChangeNotifyServer::OnUnRegister ( UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam,
BOOL bHandled 
)

Definition at line 271 of file CChangeNotifyServer.cpp.

272 {
273  TRACE("OnUnRegister(%p, %u, %p, %p)\n", m_hWnd, uMsg, wParam, lParam);
274 
275  // validate registration ID
276  UINT nRegID = (UINT)wParam;
277  if (nRegID == INVALID_REG_ID)
278  {
279  ERR("INVALID_REG_ID\n");
280  return FALSE;
281  }
282 
283  // remove it
284  DWORD dwOwnerPID;
285  GetWindowThreadProcessId(m_hWnd, &dwOwnerPID);
286  return RemoveItemsByRegID(nRegID, dwOwnerPID);
287 }
WPARAM wParam
Definition: combotst.c:138
#define INVALID_REG_ID
#define FALSE
Definition: types.h:117
BOOL RemoveItemsByRegID(UINT nRegID, DWORD dwOwnerPID)
DWORD WINAPI GetWindowThreadProcessId(HWND, PDWORD)
#define TRACE(s)
Definition: solgame.cpp:4
unsigned long DWORD
Definition: ntddk_ex.h:95
#define ERR(fmt,...)
Definition: debug.h:110
unsigned int UINT
Definition: ndis.h:50
LPARAM lParam
Definition: combotst.c:139

◆ RemoveItemsByProcess()

void CChangeNotifyServer::RemoveItemsByProcess ( DWORD  dwOwnerPID,
DWORD  dwUserPID 
)
private

Definition at line 169 of file CChangeNotifyServer.cpp.

170 {
171  HWND hwndBroker = NULL;
172  assert(dwUserPID != 0);
173  for (INT i = 0; i < m_items.GetSize(); ++i)
174  {
175  if (m_items[i].dwUserPID == dwUserPID)
176  {
177  DestroyItem(m_items[i], dwOwnerPID, &hwndBroker);
178  }
179  }
180 }
#define assert(x)
Definition: debug.h:53
CSimpleArray< ITEM > m_items
int32_t INT
Definition: typedefs.h:58
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define NULL
Definition: types.h:112
void DestroyItem(ITEM &item, DWORD dwOwnerPID, HWND *phwndBroker)

Referenced by OnRemoveByPID().

◆ RemoveItemsByRegID()

BOOL CChangeNotifyServer::RemoveItemsByRegID ( UINT  nRegID,
DWORD  dwOwnerPID 
)
private

Definition at line 153 of file CChangeNotifyServer.cpp.

154 {
155  BOOL bFound = FALSE;
156  HWND hwndBroker = NULL;
157  assert(nRegID != INVALID_REG_ID);
158  for (INT i = 0; i < m_items.GetSize(); ++i)
159  {
160  if (m_items[i].nRegID == nRegID)
161  {
162  bFound = TRUE;
163  DestroyItem(m_items[i], dwOwnerPID, &hwndBroker);
164  }
165  }
166  return bFound;
167 }
#define TRUE
Definition: types.h:120
#define assert(x)
Definition: debug.h:53
CSimpleArray< ITEM > m_items
int32_t INT
Definition: typedefs.h:58
#define INVALID_REG_ID
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define NULL
Definition: types.h:112
void DestroyItem(ITEM &item, DWORD dwOwnerPID, HWND *phwndBroker)

Referenced by OnUnRegister().

◆ ShouldNotify()

BOOL CChangeNotifyServer::ShouldNotify ( LPDELITICKET  pTicket,
LPREGENTRY  pRegEntry 
)
private

Definition at line 401 of file CChangeNotifyServer.cpp.

402 {
403 #define RETURN(x) do { \
404  TRACE("ShouldNotify return %d\n", (x)); \
405  return (x); \
406 } while (0)
407 
408  if (pTicket->wEventId & SHCNE_INTERRUPT)
409  {
410  if (!(pRegEntry->fSources & SHCNRF_InterruptLevel))
411  RETURN(FALSE);
412  if (!pRegEntry->ibPidl)
413  RETURN(FALSE);
414  }
415  else
416  {
417  if (!(pRegEntry->fSources & SHCNRF_ShellLevel))
418  RETURN(FALSE);
419  }
420 
421  if (!(pTicket->wEventId & pRegEntry->fEvents))
422  RETURN(FALSE);
423 
424  LPITEMIDLIST pidl = NULL, pidl1 = NULL, pidl2 = NULL;
425  if (pRegEntry->ibPidl)
426  pidl = (LPITEMIDLIST)((LPBYTE)pRegEntry + pRegEntry->ibPidl);
427  if (pTicket->ibOffset1)
428  pidl1 = (LPITEMIDLIST)((LPBYTE)pTicket + pTicket->ibOffset1);
429  if (pTicket->ibOffset2)
430  pidl2 = (LPITEMIDLIST)((LPBYTE)pTicket + pTicket->ibOffset2);
431 
432  if (pidl == NULL || (pTicket->wEventId & SHCNE_GLOBALEVENTS))
433  RETURN(TRUE);
434 
435  if (pRegEntry->fRecursive)
436  {
437  if (ILIsParent(pidl, pidl1, FALSE) ||
438  (pidl2 && ILIsParent(pidl, pidl2, FALSE)))
439  {
440  RETURN(TRUE);
441  }
442  }
443  else
444  {
445  if (ILIsEqual(pidl, pidl1) ||
446  ILIsParent(pidl, pidl1, TRUE) ||
447  (pidl2 && ILIsParent(pidl, pidl2, TRUE)))
448  {
449  RETURN(TRUE);
450  }
451  }
452 
453  RETURN(FALSE);
454 #undef RETURN
455 }
#define SHCNE_GLOBALEVENTS
Definition: shlobj.h:1752
#define TRUE
Definition: types.h:120
#define SHCNE_INTERRUPT
Definition: shlobj.h:1754
BOOL WINAPI ILIsEqual(LPCITEMIDLIST pidl1, LPCITEMIDLIST pidl2)
Definition: pidl.c:535
#define RETURN(x)
unsigned char * LPBYTE
Definition: typedefs.h:53
#define FALSE
Definition: types.h:117
#define SHCNRF_InterruptLevel
Definition: shlobj.h:1774
#define SHCNRF_ShellLevel
Definition: shlobj.h:1775
BOOL WINAPI ILIsParent(LPCITEMIDLIST pidlParent, LPCITEMIDLIST pidlChild, BOOL bImmediate)
Definition: pidl.c:592
#define NULL
Definition: types.h:112
ITEMIDLIST UNALIGNED * LPITEMIDLIST
Definition: shtypes.idl:41

Referenced by DeliverNotification().

Member Data Documentation

◆ m_items

CSimpleArray<ITEM> CChangeNotifyServer::m_items
private

◆ m_nNextRegID

UINT CChangeNotifyServer::m_nNextRegID
private

Definition at line 80 of file CChangeNotifyServer.cpp.

Referenced by GetNextRegID(), and OnRegister().


The documentation for this class was generated from the following file: