ReactOS  0.4.14-dev-358-gbef841c
changenotify.c File Reference
#include <windef.h>
#include <winbase.h>
#include <shlobj.h>
#include <strsafe.h>
#include <undocshell.h>
#include <shlwapi.h>
#include <wine/debug.h>
#include <wine/list.h>
#include <process.h>
#include <shellutils.h>
#include "pidl.h"
Include dependency graph for changenotify.c:

Go to the source code of this file.

Classes

struct  _NOTIFICATIONLIST
 
struct  new_delivery_notification
 

Macros

#define WIN32_NO_STATUS
 
#define _INC_WINDOWS
 
#define COBJMACROS
 
#define NONAMELESSUNION
 
#define NONAMELESSSTRUCT
 
#define BUFFER_SIZE   1024
 
#define SHCNE_NOITEMEVENTS
 
#define SHCNE_ONEITEMEVENTS
 
#define SHCNE_TWOITEMEVENTS
 
#define DUMPEV(x)   ,( event & SHCNE_##x )? #x " " : ""
 

Typedefs

typedef SHChangeNotifyEntryLPNOTIFYREGISTER
 
typedef struct _NOTIFICATIONLIST NOTIFICATIONLIST
 
typedef struct _NOTIFICATIONLISTLPNOTIFICATIONLIST
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (shell)
 
static const charDumpEvent (LONG event)
 
static const charNodeName (const NOTIFICATIONLIST *item)
 
static void DeleteNode (LPNOTIFICATIONLIST item)
 
void InitChangeNotifications (void)
 
void FreeChangeNotifications (void)
 
ULONG WINAPI SHChangeNotifyRegister (HWND hwnd, int fSources, LONG wEventMask, UINT uMsg, int cItems, SHChangeNotifyEntry *lpItems)
 
BOOL WINAPI SHChangeNotifyDeregister (ULONG hNotify)
 
BOOL WINAPI SHChangeNotifyUpdateEntryList (DWORD unknown1, DWORD unknown2, DWORD unknown3, DWORD unknown4)
 
static BOOL should_notify (LPCITEMIDLIST changed, LPCITEMIDLIST watched, BOOL sub)
 
void WINAPI SHChangeNotify (LONG wEventId, UINT uFlags, LPCVOID dwItem1, LPCVOID dwItem2)
 
EXTERN_C ULONG WINAPI NTSHChangeNotifyRegister (HWND hwnd, int fSources, LONG fEvents, UINT msg, int count, SHChangeNotifyEntry *idlist)
 
HANDLE WINAPI SHChangeNotification_Lock (HANDLE hChange, DWORD dwProcessId, LPITEMIDLIST **lppidls, LPLONG lpwEventId)
 
BOOL WINAPI SHChangeNotification_Unlock (HANDLE hLock)
 
DWORD WINAPI NTSHChangeNotifyDeregister (ULONG x1)
 

Variables

static CRITICAL_SECTION SHELL32_ChangenotifyCS = { &critsect_debug, -1, 0, 0, 0, 0 }
 
static CRITICAL_SECTION_DEBUG critsect_debug
 
static struct list notifications = LIST_INIT( notifications )
 
static LONG next_id
 

Macro Definition Documentation

◆ _INC_WINDOWS

#define _INC_WINDOWS

Definition at line 22 of file changenotify.c.

◆ BUFFER_SIZE

#define BUFFER_SIZE   1024

Definition at line 26 of file changenotify.c.

◆ COBJMACROS

#define COBJMACROS

Definition at line 23 of file changenotify.c.

◆ DUMPEV

#define DUMPEV (   x)    ,( event & SHCNE_##x )? #x " " : ""

◆ NONAMELESSSTRUCT

#define NONAMELESSSTRUCT

Definition at line 25 of file changenotify.c.

◆ NONAMELESSUNION

#define NONAMELESSUNION

Definition at line 24 of file changenotify.c.

◆ SHCNE_NOITEMEVENTS

#define SHCNE_NOITEMEVENTS
Value:
( \
SHCNE_ASSOCCHANGED )

Definition at line 99 of file changenotify.c.

◆ SHCNE_ONEITEMEVENTS

#define SHCNE_ONEITEMEVENTS
Value:
( \
SHCNE_ATTRIBUTES | SHCNE_CREATE | SHCNE_DELETE | SHCNE_DRIVEADD | \
SHCNE_DRIVEADDGUI | SHCNE_DRIVEREMOVED | SHCNE_FREESPACE | \
SHCNE_MEDIAINSERTED | SHCNE_MEDIAREMOVED | SHCNE_MKDIR | \
SHCNE_NETSHARE | SHCNE_NETUNSHARE | SHCNE_RMDIR | \
SHCNE_SERVERDISCONNECT | SHCNE_UPDATEDIR | SHCNE_UPDATEIMAGE )
#define SHCNE_MKDIR
Definition: shlobj.h:1723
#define SHCNE_RMDIR
Definition: shlobj.h:1724
#define SHCNE_UPDATEIMAGE
Definition: shlobj.h:1735
#define SHCNE_NETUNSHARE
Definition: shlobj.h:1730
#define SHCNE_MEDIAREMOVED
Definition: shlobj.h:1726
#define SHCNE_FREESPACE
Definition: shlobj.h:1738
#define SHCNE_DELETE
Definition: shlobj.h:1722
#define SHCNE_UPDATEDIR
Definition: shlobj.h:1732
#define SHCNE_DRIVEADD
Definition: shlobj.h:1728
#define SHCNE_CREATE
Definition: shlobj.h:1721
#define SHCNE_DRIVEREMOVED
Definition: shlobj.h:1727

Definition at line 102 of file changenotify.c.

◆ SHCNE_TWOITEMEVENTS

#define SHCNE_TWOITEMEVENTS
Value:
( \
SHCNE_RENAMEFOLDER | SHCNE_RENAMEITEM | SHCNE_UPDATEITEM )
#define SHCNE_RENAMEITEM
Definition: shlobj.h:1720
#define SHCNE_UPDATEITEM
Definition: shlobj.h:1733

Definition at line 109 of file changenotify.c.

◆ WIN32_NO_STATUS

#define WIN32_NO_STATUS

Definition at line 21 of file changenotify.c.

Typedef Documentation

◆ LPNOTIFICATIONLIST

◆ LPNOTIFYREGISTER

Definition at line 64 of file changenotify.c.

◆ NOTIFICATIONLIST

Function Documentation

◆ DeleteNode()

static void DeleteNode ( LPNOTIFICATIONLIST  item)
static

Definition at line 157 of file changenotify.c.

158 {
159  UINT i;
160 
161  TRACE("item=%p\n", item);
162 
163  /* remove item from list */
164  list_remove( &item->entry );
165 
166  /* free the item */
167  for (i=0; i<item->cidl; i++)
168 #ifdef __REACTOS__
169  {
170  QueueUserAPC(_RequestTermination, m_hThread, (ULONG_PTR) &item->apidl[i] );
171  WaitForSingleObjectEx(m_hThread, 100, FALSE);
172 #endif
173  SHFree((LPITEMIDLIST)item->apidl[i].pidl);
174 #ifdef __REACTOS__
175  SHFree(item->apidl[i].buffer);
176  SHFree(item->apidl[i].backBuffer);
177  }
178 #endif
179  SHFree(item->apidl);
180  SHFree(item);
181 }
DWORD WINAPI WaitForSingleObjectEx(IN HANDLE hHandle, IN DWORD dwMilliseconds, IN BOOL bAlertable)
Definition: synch.c:94
uint32_t ULONG_PTR
Definition: typedefs.h:63
DWORD WINAPI QueueUserAPC(IN PAPCFUNC pfnAPC, IN HANDLE hThread, IN ULONG_PTR dwData)
Definition: thread.c:947
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
__WINE_SERVER_LIST_INLINE void list_remove(struct list *elem)
Definition: list.h:108
#define TRACE(s)
Definition: solgame.cpp:4
static ATOM item
Definition: dde.c:856
unsigned int UINT
Definition: ndis.h:50
void WINAPI SHFree(LPVOID pv)
Definition: shellole.c:331
ITEMIDLIST UNALIGNED * LPITEMIDLIST
Definition: shtypes.idl:41

Referenced by FreeChangeNotifications(), and SHChangeNotifyDeregister().

◆ DumpEvent()

static const char* DumpEvent ( LONG  event)
static

Definition at line 113 of file changenotify.c.

114 {
115  if( event == SHCNE_ALLEVENTS )
116  return "SHCNE_ALLEVENTS";
117 #define DUMPEV(x) ,( event & SHCNE_##x )? #x " " : ""
118  return wine_dbg_sprintf( "%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s"
119  DUMPEV(RENAMEITEM)
120  DUMPEV(CREATE)
121  DUMPEV(DELETE)
122  DUMPEV(MKDIR)
123  DUMPEV(RMDIR)
124  DUMPEV(MEDIAINSERTED)
125  DUMPEV(MEDIAREMOVED)
126  DUMPEV(DRIVEREMOVED)
127  DUMPEV(DRIVEADD)
128  DUMPEV(NETSHARE)
129  DUMPEV(NETUNSHARE)
130  DUMPEV(ATTRIBUTES)
131  DUMPEV(UPDATEDIR)
132  DUMPEV(UPDATEITEM)
133  DUMPEV(SERVERDISCONNECT)
134  DUMPEV(UPDATEIMAGE)
135  DUMPEV(DRIVEADDGUI)
136  DUMPEV(RENAMEFOLDER)
137  DUMPEV(FREESPACE)
138  DUMPEV(EXTENDED_EVENT)
139  DUMPEV(ASSOCCHANGED)
140  DUMPEV(INTERRUPT)
141  );
142 #undef DUMPEV
143 }
const char * wine_dbg_sprintf(const char *format,...)
Definition: compat.c:271
#define SHCNE_ALLEVENTS
Definition: shlobj.h:1744
#define DUMPEV(x)
#define MKDIR(d)
Definition: compat.h:23
struct _cl_event * event
Definition: glext.h:7739
#define DELETE
Definition: nt_native.h:57

Referenced by SHChangeNotify().

◆ FreeChangeNotifications()

void FreeChangeNotifications ( void  )

Definition at line 190 of file changenotify.c.

191 {
193 
194  TRACE("\n");
195 
197 
199  DeleteNode( ptr );
200 
202 
203 #ifdef __REACTOS__
204  QueueUserAPC(_RequestAllTermination, m_hThread, (ULONG_PTR) NULL );
205 #endif
206 
208 }
static struct list notifications
Definition: changenotify.c:90
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
uint32_t ULONG_PTR
Definition: typedefs.h:63
DWORD WINAPI QueueUserAPC(IN PAPCFUNC pfnAPC, IN HANDLE hThread, IN ULONG_PTR dwData)
Definition: thread.c:947
static PVOID ptr
Definition: dispmode.c:27
smooth NULL
Definition: ftsmooth.c:416
static void DeleteNode(LPNOTIFICATIONLIST item)
Definition: changenotify.c:157
#define TRACE(s)
Definition: solgame.cpp:4
void WINAPI DeleteCriticalSection(PCRITICAL_SECTION)
uint32_t entry
Definition: isohybrid.c:63
static unsigned __int64 next
Definition: rand_nt.c:6
#define LIST_FOR_EACH_ENTRY_SAFE(cursor, cursor2, list, type, field)
Definition: list.h:204
static CRITICAL_SECTION SHELL32_ChangenotifyCS
Definition: changenotify.c:43
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)

◆ InitChangeNotifications()

void InitChangeNotifications ( void  )

Definition at line 183 of file changenotify.c.

184 {
185 #ifdef __REACTOS__
186  m_hThread = NULL;
187 #endif
188 }
smooth NULL
Definition: ftsmooth.c:416

Referenced by if().

◆ NodeName()

static const char* NodeName ( const NOTIFICATIONLIST item)
static

Definition at line 145 of file changenotify.c.

146 {
147  const char *str;
149 
150  if(SHGetPathFromIDListW(item->apidl[0].pidl, path ))
152  else
153  str = wine_dbg_sprintf("<not a disk file>" );
154  return str;
155 }
BOOL WINAPI SHGetPathFromIDListW(LPCITEMIDLIST pidl, LPWSTR pszPath)
Definition: pidl.c:1280
const char * wine_dbg_sprintf(const char *format,...)
Definition: compat.c:271
#define debugstr_w
Definition: kernel32.h:32
const WCHAR * str
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define MAX_PATH
Definition: compat.h:26
static ATOM item
Definition: dde.c:856
Definition: services.c:325

Referenced by AcpiNsHandleToName(), CmpCreateKeyControlBlock(), CmpGetNameControlBlock(), Database::fromXml(), LookupAddressForName(), QueryDNS(), SHChangeNotifyRegister(), TestNodeName(), and USBH_IoctlGetNodeName().

◆ NTSHChangeNotifyDeregister()

DWORD WINAPI NTSHChangeNotifyDeregister ( ULONG  x1)

Definition at line 609 of file changenotify.c.

610 {
611  FIXME("(0x%08x):semi stub.\n",x1);
612 
613  return SHChangeNotifyDeregister( x1 );
614 }
_In_ CLIPOBJ _In_ BRUSHOBJ _In_ LONG x1
Definition: winddi.h:3706
#define FIXME(fmt,...)
Definition: debug.h:110
BOOL WINAPI SHChangeNotifyDeregister(ULONG hNotify)
Definition: changenotify.c:283

◆ NTSHChangeNotifyRegister()

EXTERN_C ULONG WINAPI NTSHChangeNotifyRegister ( HWND  hwnd,
int  fSources,
LONG  fEvents,
UINT  msg,
int  count,
SHChangeNotifyEntry idlist 
)

Definition at line 552 of file changenotify.c.

559 {
561  fEvents, msg, count, idlist);
562 }
ULONG WINAPI SHChangeNotifyRegister(HWND hwnd, int fSources, LONG wEventMask, UINT uMsg, int cItems, SHChangeNotifyEntry *lpItems)
Definition: changenotify.c:215
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
GLuint GLuint GLsizei count
Definition: gl.h:1545
#define SHCNRF_NewDelivery
Definition: shlobj.h:1768
#define msg(x)
Definition: auth_time.c:54

◆ SHChangeNotification_Lock()

HANDLE WINAPI SHChangeNotification_Lock ( HANDLE  hChange,
DWORD  dwProcessId,
LPITEMIDLIST **  lppidls,
LPLONG  lpwEventId 
)

Definition at line 567 of file changenotify.c.

572 {
573  struct new_delivery_notification *ndn;
574  UINT offset;
575 
576  TRACE("%p %08x %p %p\n", hChange, dwProcessId, lppidls, lpwEventId);
577 
578  ndn = SHLockShared(hChange, dwProcessId);
579  if(!ndn) {
580  WARN("SHLockShared failed\n");
581  return NULL;
582  }
583 
584  if(lppidls) {
585  offset = (ndn->pidl1_size+sizeof(int)-1)/sizeof(int)*sizeof(int);
586  ndn->pidls[0] = ndn->pidl1_size ? (LPITEMIDLIST)ndn->data : NULL;
587  ndn->pidls[1] = ndn->pidl2_size ? (LPITEMIDLIST)(ndn->data+offset) : NULL;
588  *lppidls = ndn->pidls;
589  }
590 
591  if(lpwEventId)
592  *lpwEventId = ndn->event;
593 
594  return ndn;
595 }
#define WARN(fmt,...)
Definition: debug.h:111
GLintptr offset
Definition: glext.h:5920
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
PVOID WINAPI SHLockShared(HANDLE hShared, DWORD dwProcId)
Definition: ordinal.c:210
unsigned int UINT
Definition: ndis.h:50
ITEMIDLIST UNALIGNED * LPITEMIDLIST
Definition: shtypes.idl:41
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31

Referenced by testwindow_wndproc().

◆ SHChangeNotification_Unlock()

BOOL WINAPI SHChangeNotification_Unlock ( HANDLE  hLock)

Definition at line 600 of file changenotify.c.

601 {
602  TRACE("%p\n", hLock);
603  return SHUnlockShared(hLock);
604 }
#define TRACE(s)
Definition: solgame.cpp:4
BOOL WINAPI SHUnlockShared(LPVOID lpView)
Definition: ordinal.c:242

Referenced by testwindow_wndproc().

◆ SHChangeNotify()

void WINAPI SHChangeNotify ( LONG  wEventId,
UINT  uFlags,
LPCVOID  dwItem1,
LPCVOID  dwItem2 
)

Definition at line 340 of file changenotify.c.

341 {
342  struct notification_recipients {
343  struct list entry;
344  HWND hwnd;
345  DWORD msg;
346  DWORD flags;
347  } *cur, *next;
348 
349  HANDLE shared_data = NULL;
350  LPITEMIDLIST Pidls[2];
352  struct list recipients;
353 
354  Pidls[0] = NULL;
355  Pidls[1] = NULL;
356 
357  TRACE("(0x%08x,0x%08x,%p,%p)\n", wEventId, uFlags, dwItem1, dwItem2);
358 
359  if(uFlags & ~(SHCNF_TYPE|SHCNF_FLUSH))
360  FIXME("ignoring unsupported flags: %x\n", uFlags);
361 
362  if( ( wEventId & SHCNE_NOITEMEVENTS ) && ( dwItem1 || dwItem2 ) )
363  {
364  TRACE("dwItem1 and dwItem2 are not zero, but should be\n");
365  dwItem1 = 0;
366  dwItem2 = 0;
367  return;
368  }
369  else if( ( wEventId & SHCNE_ONEITEMEVENTS ) && dwItem2 )
370  {
371  TRACE("dwItem2 is not zero, but should be\n");
372  dwItem2 = 0;
373  return;
374  }
375 
376  if( ( ( wEventId & SHCNE_NOITEMEVENTS ) &&
377  ( wEventId & ~(SHCNE_NOITEMEVENTS | SHCNE_INTERRUPT) ) ) ||
378  ( ( wEventId & SHCNE_ONEITEMEVENTS ) &&
379  ( wEventId & ~(SHCNE_ONEITEMEVENTS | SHCNE_INTERRUPT) ) ) ||
380  ( ( wEventId & SHCNE_TWOITEMEVENTS ) &&
381  ( wEventId & ~(SHCNE_TWOITEMEVENTS | SHCNE_INTERRUPT) ) ) )
382  {
383  WARN("mutually incompatible events listed\n");
384  return;
385  }
386 
387  /* convert paths in IDLists*/
388  switch (uFlags & SHCNF_TYPE)
389  {
390  case SHCNF_PATHA:
391  if (dwItem1) Pidls[0] = SHSimpleIDListFromPathA(dwItem1); //FIXME
392  if (dwItem2) Pidls[1] = SHSimpleIDListFromPathA(dwItem2); //FIXME
393  break;
394  case SHCNF_PATHW:
395  if (dwItem1) Pidls[0] = SHSimpleIDListFromPathW(dwItem1);
396  if (dwItem2) Pidls[1] = SHSimpleIDListFromPathW(dwItem2);
397 #ifdef __REACTOS__
399  {
400  /*
401  * The last items in the ID are currently files. So we chop off the last
402  * entry, and create a new one using a find data struct.
403  */
404  if (dwItem1 && Pidls[0]){
405  WIN32_FIND_DATAW wfd;
406  LPITEMIDLIST oldpidl, newpidl;
407  LPWSTR p = PathFindFileNameW((LPCWSTR)dwItem1);
408  ILRemoveLastID(Pidls[0]);
409  lstrcpynW(&wfd.cFileName[0], p, MAX_PATH);
410  wfd.dwFileAttributes = FILE_ATTRIBUTE_DIRECTORY;
411  newpidl = _ILCreateFromFindDataW(&wfd);
412  oldpidl = ILClone(Pidls[0]);
413  ILFree(Pidls[0]);
414  Pidls[0] = ILCombine(oldpidl, newpidl);
415  ILFree(newpidl);
416  ILFree(oldpidl);
417  }
418  if (dwItem2 && Pidls[1]){
419  WIN32_FIND_DATAW wfd;
420  LPITEMIDLIST oldpidl, newpidl;
421  LPWSTR p = PathFindFileNameW((LPCWSTR)dwItem2);
422  ILRemoveLastID(Pidls[1]);
423  lstrcpynW(&wfd.cFileName[0], p, MAX_PATH);
424  wfd.dwFileAttributes = FILE_ATTRIBUTE_DIRECTORY;
425  newpidl = _ILCreateFromFindDataW(&wfd);
426  oldpidl = ILClone(Pidls[0]);
427  ILFree(Pidls[1]);
428  Pidls[1] = ILCombine(oldpidl, newpidl);
429  ILFree(newpidl);
430  ILFree(oldpidl);
431  }
432  }
433 #endif
434  break;
435  case SHCNF_IDLIST:
436  Pidls[0] = ILClone(dwItem1);
437  Pidls[1] = ILClone(dwItem2);
438  break;
439  case SHCNF_PRINTERA:
440  case SHCNF_PRINTERW:
441  FIXME("SHChangeNotify with (uFlags & SHCNF_PRINTER)\n");
442  return;
443  case SHCNF_DWORD:
444  default:
445  FIXME("unknown type %08x\n", uFlags & SHCNF_TYPE);
446  return;
447  }
448 
449  list_init(&recipients);
452  {
453  struct notification_recipients *item;
454  BOOL notify = FALSE;
455  DWORD i;
456 
457  for( i=0; (i<ptr->cidl) && !notify ; i++ )
458  {
459  LPCITEMIDLIST pidl = ptr->apidl[i].pidl;
460  BOOL subtree = ptr->apidl[i].fRecursive;
461 
462  if (wEventId & ptr->wEventMask)
463  {
464  if( !pidl ) /* all ? */
465  notify = TRUE;
466  else if( wEventId & SHCNE_NOITEMEVENTS )
467  notify = TRUE;
468  else if( wEventId & ( SHCNE_ONEITEMEVENTS | SHCNE_TWOITEMEVENTS ) )
469  notify = should_notify( Pidls[0], pidl, subtree );
470  else if( wEventId & SHCNE_TWOITEMEVENTS )
471  notify = should_notify( Pidls[1], pidl, subtree );
472  }
473  }
474 
475  if( !notify )
476  continue;
477 
478  item = SHAlloc(sizeof(struct notification_recipients));
479  if(!item) {
480  ERR("out of memory\n");
481  continue;
482  }
483 
484  item->hwnd = ptr->hwnd;
485  item->msg = ptr->uMsg;
486  item->flags = ptr->dwFlags;
487  list_add_tail(&recipients, &item->entry);
488  }
490 
491  LIST_FOR_EACH_ENTRY_SAFE(cur, next, &recipients, struct notification_recipients, entry)
492  {
493  TRACE("notifying %p, event %s(%x)\n", cur->hwnd, DumpEvent(wEventId), wEventId);
494 
495  if (cur->flags & SHCNRF_NewDelivery) {
496  if(!shared_data) {
498  UINT size1 = ILGetSize(Pidls[0]), size2 = ILGetSize(Pidls[1]);
499  UINT offset = (size1+sizeof(int)-1)/sizeof(int)*sizeof(int);
500 
501  notification = SHAlloc(sizeof(struct new_delivery_notification)+offset+size2);
502  if(!notification) {
503  ERR("out of memory\n");
504  } else {
505  notification->event = wEventId;
506  notification->pidl1_size = size1;
507  notification->pidl2_size = size2;
508  if(size1)
509  memcpy(notification->data, Pidls[0], size1);
510  if(size2)
511  memcpy(notification->data+offset, Pidls[1], size2);
512 
513  shared_data = SHAllocShared(notification,
514  sizeof(struct new_delivery_notification)+size1+size2,
517  }
518  }
519 
520  if(shared_data)
521  SendMessageA(cur->hwnd, cur->msg, (WPARAM)shared_data, GetCurrentProcessId());
522  else
523  ERR("out of memory\n");
524  } else {
525  SendMessageA(cur->hwnd, cur->msg, (WPARAM)Pidls, wEventId);
526  }
527 
528  list_remove(&cur->entry);
529  SHFree(cur);
530  }
531  SHFreeShared(shared_data, GetCurrentProcessId());
532  SHFree(Pidls[0]);
533  SHFree(Pidls[1]);
534 
535 #ifndef __REACTOS__
536  if (wEventId & SHCNE_ASSOCCHANGED)
537  {
538  static const WCHAR args[] = {' ','-','a',0 };
539  TRACE("refreshing file type associations\n");
541  }
542 #endif
543 }
#define SHCNE_MKDIR
Definition: shlobj.h:1723
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
#define TRUE
Definition: types.h:120
#define SHCNE_RMDIR
Definition: shlobj.h:1724
void WINAPI ILFree(LPITEMIDLIST pidl)
Definition: pidl.c:925
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
static BOOL run_winemenubuilder(const WCHAR *args)
Definition: intshcut.c:85
#define SHCNE_NOITEMEVENTS
Definition: changenotify.c:99
static BOOL should_notify(LPCITEMIDLIST changed, LPCITEMIDLIST watched, BOOL sub)
Definition: changenotify.c:325
LRESULT WINAPI SendMessageA(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
static struct list notifications
Definition: changenotify.c:90
#define WARN(fmt,...)
Definition: debug.h:111
int notify
Definition: msacm.c:1365
LPITEMIDLIST WINAPI ILCombine(LPCITEMIDLIST pidl1, LPCITEMIDLIST pidl2)
Definition: pidl.c:699
#define SHCNE_RENAMEFOLDER
Definition: shlobj.h:1737
const ITEMIDLIST UNALIGNED * LPCITEMIDLIST
Definition: shtypes.idl:42
GLintptr offset
Definition: glext.h:5920
#define SHCNE_INTERRUPT
Definition: shlobj.h:1745
UINT_PTR WPARAM
Definition: windef.h:207
BOOL WINAPI ILRemoveLastID(LPITEMIDLIST pidl)
Definition: pidl.c:212
UINT uFlags
Definition: api.c:59
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
Definition: match.c:390
#define lstrcpynW
Definition: compat.h:405
#define SHCNF_DWORD
Definition: shlobj.h:1754
__WINE_SERVER_LIST_INLINE void list_add_tail(struct list *list, struct list *elem)
Definition: list.h:102
#define LIST_FOR_EACH_ENTRY(elem, list, type, field)
Definition: list.h:198
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
unsigned int BOOL
Definition: ntddk_ex.h:94
#define FIXME(fmt,...)
Definition: debug.h:110
#define SHCNE_ONEITEMEVENTS
Definition: changenotify.c:102
static PVOID ptr
Definition: dispmode.c:27
smooth NULL
Definition: ftsmooth.c:416
LPWSTR WINAPI PathFindFileNameW(LPCWSTR lpszPath)
Definition: path.c:389
#define SHCNE_TWOITEMEVENTS
Definition: changenotify.c:109
#define FILE_ATTRIBUTE_DIRECTORY
Definition: nt_native.h:705
#define SHCNF_PRINTERW
Definition: shlobj.h:1756
__WINE_SERVER_LIST_INLINE void list_remove(struct list *elem)
Definition: list.h:108
#define TRACE(s)
Definition: solgame.cpp:4
HANDLE WINAPI SHAllocShared(LPCVOID lpvData, DWORD dwSize, DWORD dwProcId)
Definition: ordinal.c:162
LPITEMIDLIST WINAPI SHSimpleIDListFromPathW(LPCWSTR lpszPath)
Definition: pidl.c:1111
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define SHCNF_IDLIST
Definition: shlobj.h:1751
#define MAX_PATH
Definition: compat.h:26
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SHCNF_PRINTERA
Definition: shlobj.h:1753
BOOL WINAPI SHFreeShared(HANDLE hShared, DWORD dwProcId)
Definition: ordinal.c:262
GLbitfield flags
Definition: glext.h:7161
static const char * DumpEvent(LONG event)
Definition: changenotify.c:113
#define SHCNF_TYPE
Definition: shlobj.h:1757
#define SHCNF_FLUSH
Definition: shlobj.h:1758
uint32_t entry
Definition: isohybrid.c:63
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
Definition: _list.h:228
#define SHCNF_PATHW
Definition: shlobj.h:1755
#define SHCNRF_NewDelivery
Definition: shlobj.h:1768
#define ERR(fmt,...)
Definition: debug.h:109
static unsigned __int64 next
Definition: rand_nt.c:6
#define LIST_FOR_EACH_ENTRY_SAFE(cursor, cursor2, list, type, field)
Definition: list.h:204
static ATOM item
Definition: dde.c:856
LPITEMIDLIST WINAPI ILClone(LPCITEMIDLIST pidl)
Definition: pidl.c:228
#define SHCNE_UPDATEDIR
Definition: shlobj.h:1732
static CRITICAL_SECTION SHELL32_ChangenotifyCS
Definition: changenotify.c:43
unsigned int UINT
Definition: ndis.h:50
#define ILGetSize
Definition: shellclasses.h:638
LPITEMIDLIST WINAPI SHSimpleIDListFromPathA(LPCSTR lpszPath)
Definition: pidl.c:1089
void WINAPI SHFree(LPVOID pv)
Definition: shellole.c:331
#define msg(x)
Definition: auth_time.c:54
LPITEMIDLIST _ILCreateFromFindDataW(const WIN32_FIND_DATAW *wfd)
Definition: pidl.c:1727
__WINE_SERVER_LIST_INLINE void list_init(struct list *list)
Definition: list.h:149
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
GLfloat GLfloat p
Definition: glext.h:8902
WCHAR * LPWSTR
Definition: xmlstorage.h:184
ITEMIDLIST UNALIGNED * LPITEMIDLIST
Definition: shtypes.idl:41
LPVOID WINAPI SHAlloc(SIZE_T len)
Definition: shellole.c:309
#define SHCNF_PATHA
Definition: shlobj.h:1752
DWORD WINAPI GetCurrentProcessId(VOID)
Definition: proc.c:1158
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31
#define SHCNE_ASSOCCHANGED
Definition: shlobj.h:1741

Referenced by CFSDropTarget::_DoDrop(), delete_files(), CDefaultContextMenu::DoCreateNewFolder(), DrivesContextMenuCallback(), EditTypeDlg_OnOK(), CLayerUIPropPage::OnApply(), CShellLink::OnNotify(), CNewMenu::SelectNewItem(), CFSFolder::SetNameOf(), SHChangeNotifyWrap(), SHNotifyCopyFileW(), SHNotifyCreateDirectoryW(), SHNotifyDeleteFileW(), SHNotifyMoveFileW(), SHNotifyRemoveDirectoryW(), test_SHChangeNotify(), VfdCloseImage(), and VfdOpenImage().

◆ SHChangeNotifyDeregister()

BOOL WINAPI SHChangeNotifyDeregister ( ULONG  hNotify)

Definition at line 283 of file changenotify.c.

284 {
286 
287  TRACE("(0x%08x)\n", hNotify);
288 
290 
292  {
293  if (node->id == hNotify)
294  {
295  DeleteNode( node );
297  return TRUE;
298  }
299  }
301  return FALSE;
302 }
#define TRUE
Definition: types.h:120
static struct list notifications
Definition: changenotify.c:90
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
struct node node
#define LIST_FOR_EACH_ENTRY(elem, list, type, field)
Definition: list.h:198
static void DeleteNode(LPNOTIFICATIONLIST item)
Definition: changenotify.c:157
#define TRACE(s)
Definition: solgame.cpp:4
uint32_t entry
Definition: isohybrid.c:63
static CRITICAL_SECTION SHELL32_ChangenotifyCS
Definition: changenotify.c:43
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
Definition: dlist.c:348

Referenced by NTSHChangeNotifyDeregister(), CDefView::OnDestroy(), and test_SHChangeNotify().

◆ SHChangeNotifyRegister()

ULONG WINAPI SHChangeNotifyRegister ( HWND  hwnd,
int  fSources,
LONG  wEventMask,
UINT  uMsg,
int  cItems,
SHChangeNotifyEntry lpItems 
)

Definition at line 215 of file changenotify.c.

222 {
224  int i;
225 
226  item = SHAlloc(sizeof(NOTIFICATIONLIST));
227 
228  TRACE("(%p,0x%08x,0x%08x,0x%08x,%d,%p) item=%p\n",
229  hwnd, fSources, wEventMask, uMsg, cItems, lpItems, item);
230 
231 #ifdef __REACTOS__
232  if (!m_hThread)
233  m_hThread = (HANDLE) _beginthreadex(NULL, 0, _RunAsyncThreadProc, NULL, 0, &m_dwThreadId);
234 #endif
235 
236  item->cidl = cItems;
237 #ifdef __REACTOS__
238  item->apidl = SHAlloc(sizeof(SHChangeNotifyEntryInternal) * cItems);
239 #else
240  item->apidl = SHAlloc(sizeof(SHChangeNotifyEntry) * cItems);
241 #endif
242  for(i=0;i<cItems;i++)
243  {
244 #ifdef __REACTOS__
245  ZeroMemory(&item->apidl[i], sizeof(SHChangeNotifyEntryInternal));
246 #endif
247  item->apidl[i].pidl = ILClone(lpItems[i].pidl);
248  item->apidl[i].fRecursive = lpItems[i].fRecursive;
249 #ifdef __REACTOS__
250  item->apidl[i].buffer = SHAlloc(BUFFER_SIZE);
251  item->apidl[i].backBuffer = SHAlloc(BUFFER_SIZE);
252  item->apidl[i].overlapped.hEvent = &item->apidl[i];
253 
254  if (fSources & SHCNRF_InterruptLevel)
255  {
256  if (_OpenDirectory( &item->apidl[i] ))
257  {
258  QueueUserAPC( _AddDirectoryProc, m_hThread, (ULONG_PTR) &item->apidl[i] );
259  }
260  }
261 #endif
262  }
263  item->hwnd = hwnd;
264  item->uMsg = uMsg;
265  item->wEventMask = wEventMask;
266  item->dwFlags = fSources;
268 
269  TRACE("new node: %s\n", NodeName( item ));
270 
272 
273  list_add_tail( &notifications, &item->entry );
274 
276 
277  return item->id;
278 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
static struct list notifications
Definition: changenotify.c:90
#define ZeroMemory
Definition: winbase.h:1642
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
_CRTIMP uintptr_t __cdecl _beginthreadex(_In_opt_ void *_Security, _In_ unsigned _StackSize, _In_ unsigned(__stdcall *_StartAddress)(void *), _In_opt_ void *_ArgList, _In_ unsigned _InitFlag, _Out_opt_ unsigned *_ThrdAddr)
static LONG next_id
Definition: changenotify.c:91
uint32_t ULONG_PTR
Definition: typedefs.h:63
__WINE_SERVER_LIST_INLINE void list_add_tail(struct list *list, struct list *elem)
Definition: list.h:102
DWORD WINAPI QueueUserAPC(IN PAPCFUNC pfnAPC, IN HANDLE hThread, IN ULONG_PTR dwData)
Definition: thread.c:947
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 SHCNRF_InterruptLevel
Definition: shlobj.h:1765
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
PVOID HANDLE
Definition: typedefs.h:71
static const char * NodeName(const NOTIFICATIONLIST *item)
Definition: changenotify.c:145
#define InterlockedIncrement
Definition: armddk.h:53
static ATOM item
Definition: dde.c:856
LPITEMIDLIST WINAPI ILClone(LPCITEMIDLIST pidl)
Definition: pidl.c:228
static CRITICAL_SECTION SHELL32_ChangenotifyCS
Definition: changenotify.c:43
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
LPVOID WINAPI SHAlloc(SIZE_T len)
Definition: shellole.c:309
#define BUFFER_SIZE
Definition: changenotify.c:26

Referenced by CExplorerBand::InitializeExplorerBand(), NTSHChangeNotifyRegister(), CDefView::OnCreate(), and test_SHChangeNotify().

◆ SHChangeNotifyUpdateEntryList()

BOOL WINAPI SHChangeNotifyUpdateEntryList ( DWORD  unknown1,
DWORD  unknown2,
DWORD  unknown3,
DWORD  unknown4 
)

Definition at line 307 of file changenotify.c.

309 {
310  FIXME("(0x%08x, 0x%08x, 0x%08x, 0x%08x)\n",
311  unknown1, unknown2, unknown3, unknown4);
312 
313  return TRUE;
314 }
#define TRUE
Definition: types.h:120
#define FIXME(fmt,...)
Definition: debug.h:110

◆ should_notify()

static BOOL should_notify ( LPCITEMIDLIST  changed,
LPCITEMIDLIST  watched,
BOOL  sub 
)
static

Definition at line 325 of file changenotify.c.

326 {
327  TRACE("%p %p %d\n", changed, watched, sub );
328  if ( !watched )
329  return FALSE;
330  if (ILIsEqual( watched, changed ) )
331  return TRUE;
332  if( sub && ILIsParent( watched, changed, FALSE ) )
333  return TRUE;
334  return FALSE;
335 }
#define TRUE
Definition: types.h:120
BOOL WINAPI ILIsEqual(LPCITEMIDLIST pidl1, LPCITEMIDLIST pidl2)
Definition: pidl.c:535
#define TRACE(s)
Definition: solgame.cpp:4
BOOL WINAPI ILIsParent(LPCITEMIDLIST pidlParent, LPCITEMIDLIST pidlChild, BOOL bImmediate)
Definition: pidl.c:592

Referenced by SHChangeNotify().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( shell  )

Variable Documentation

◆ critsect_debug

CRITICAL_SECTION_DEBUG critsect_debug
static
Initial value:
=
{
0, 0, { (DWORD_PTR)(__FILE__ ": SHELL32_ChangenotifyCS") }
}
#define DWORD_PTR
Definition: treelist.c:76
static CRITICAL_SECTION_DEBUG critsect_debug
Definition: changenotify.c:44
LIST_ENTRY ProcessLocksList
Definition: winbase.h:855
static CRITICAL_SECTION SHELL32_ChangenotifyCS
Definition: changenotify.c:43

Definition at line 44 of file changenotify.c.

◆ next_id

LONG next_id
static

Definition at line 91 of file changenotify.c.

Referenced by get_token(), RPCRT4_CreateConnection(), and SHChangeNotifyRegister().

◆ notifications

struct list notifications = LIST_INIT( notifications )
static

◆ SHELL32_ChangenotifyCS

static CRITICAL_SECTION SHELL32_ChangenotifyCS = { &critsect_debug, -1, 0, 0, 0, 0 }
static