2004-01-23 21:16:04 +00:00
|
|
|
/* $Id: cnotify.c,v 1.10 2004/01/23 21:16:03 ekohl Exp $
|
2000-03-15 12:25:47 +00:00
|
|
|
*
|
1999-01-01 22:03:17 +00:00
|
|
|
* COPYRIGHT: See COPYING in the top level directory
|
|
|
|
* PROJECT: ReactOS system libraries
|
|
|
|
* FILE: lib/kernel32/file/find.c
|
|
|
|
* PURPOSE: Find functions
|
|
|
|
* PROGRAMMER: Ariadne ( ariadne@xs4all.nl)
|
|
|
|
* UPDATE HISTORY:
|
|
|
|
* Created 01/11/98
|
|
|
|
*/
|
2000-03-15 12:25:47 +00:00
|
|
|
|
2003-01-15 21:24:36 +00:00
|
|
|
#include <k32.h>
|
1999-01-01 22:03:17 +00:00
|
|
|
|
2003-03-23 19:51:11 +00:00
|
|
|
#define NDEBUG
|
2004-01-23 21:16:04 +00:00
|
|
|
#include "../include/debug.h"
|
2000-03-15 12:25:47 +00:00
|
|
|
|
2003-07-10 18:50:51 +00:00
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
2004-01-23 16:37:11 +00:00
|
|
|
BOOL STDCALL
|
2001-03-31 01:17:30 +00:00
|
|
|
FindCloseChangeNotification (HANDLE hChangeHandle)
|
1999-01-01 22:03:17 +00:00
|
|
|
{
|
2003-03-23 19:51:11 +00:00
|
|
|
NtClose(hChangeHandle);
|
|
|
|
return TRUE;
|
1999-01-01 22:03:17 +00:00
|
|
|
}
|
|
|
|
|
2000-03-15 12:25:47 +00:00
|
|
|
|
2003-07-10 18:50:51 +00:00
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
1999-01-01 22:03:17 +00:00
|
|
|
HANDLE
|
|
|
|
STDCALL
|
2000-03-15 12:25:47 +00:00
|
|
|
FindFirstChangeNotificationA (
|
|
|
|
LPCSTR lpPathName,
|
2004-01-23 16:37:11 +00:00
|
|
|
BOOL bWatchSubtree,
|
2000-03-15 12:25:47 +00:00
|
|
|
DWORD dwNotifyFilter
|
|
|
|
)
|
1999-01-01 22:03:17 +00:00
|
|
|
{
|
2000-03-15 12:25:47 +00:00
|
|
|
UNICODE_STRING PathNameU;
|
|
|
|
ANSI_STRING PathName;
|
2003-03-23 19:51:11 +00:00
|
|
|
HANDLE hNotify;
|
1999-01-01 22:03:17 +00:00
|
|
|
|
2000-03-15 12:25:47 +00:00
|
|
|
RtlInitAnsiString (&PathName,
|
|
|
|
(LPSTR)lpPathName);
|
1999-01-01 22:03:17 +00:00
|
|
|
|
2000-03-15 12:25:47 +00:00
|
|
|
/* convert ansi (or oem) string to unicode */
|
|
|
|
if (bIsFileApiAnsi)
|
2003-03-23 19:51:11 +00:00
|
|
|
{
|
2000-03-15 12:25:47 +00:00
|
|
|
RtlAnsiStringToUnicodeString (&PathNameU,
|
|
|
|
&PathName,
|
|
|
|
TRUE);
|
2003-03-23 19:51:11 +00:00
|
|
|
}
|
2000-03-15 12:25:47 +00:00
|
|
|
else
|
2003-03-23 19:51:11 +00:00
|
|
|
{
|
2000-03-15 12:25:47 +00:00
|
|
|
RtlOemStringToUnicodeString (&PathNameU,
|
|
|
|
&PathName,
|
|
|
|
TRUE);
|
2003-03-23 19:51:11 +00:00
|
|
|
}
|
1999-01-01 22:03:17 +00:00
|
|
|
|
2003-03-23 19:51:11 +00:00
|
|
|
hNotify = FindFirstChangeNotificationW (PathNameU.Buffer,
|
|
|
|
bWatchSubtree,
|
|
|
|
dwNotifyFilter);
|
1999-01-01 22:03:17 +00:00
|
|
|
|
2003-03-23 19:51:11 +00:00
|
|
|
RtlFreeUnicodeString(&PathNameU);
|
2000-03-15 12:25:47 +00:00
|
|
|
|
2003-03-23 19:51:11 +00:00
|
|
|
return hNotify;
|
1999-01-01 22:03:17 +00:00
|
|
|
}
|
|
|
|
|
2000-03-15 12:25:47 +00:00
|
|
|
|
2003-07-10 18:50:51 +00:00
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
1999-01-01 22:03:17 +00:00
|
|
|
HANDLE
|
|
|
|
STDCALL
|
2000-03-15 12:25:47 +00:00
|
|
|
FindFirstChangeNotificationW (
|
|
|
|
LPCWSTR lpPathName,
|
2004-01-23 16:37:11 +00:00
|
|
|
BOOL bWatchSubtree,
|
2000-03-15 12:25:47 +00:00
|
|
|
DWORD dwNotifyFilter
|
|
|
|
)
|
1999-01-01 22:03:17 +00:00
|
|
|
{
|
2003-03-23 19:51:11 +00:00
|
|
|
NTSTATUS Status;
|
|
|
|
UNICODE_STRING NtPathU;
|
|
|
|
IO_STATUS_BLOCK IoStatus;
|
|
|
|
OBJECT_ATTRIBUTES ObjectAttributes;
|
|
|
|
HANDLE hDir;
|
|
|
|
|
|
|
|
/*
|
|
|
|
RtlDosPathNameToNtPathName takes a fully qualified file name "C:\Projects\LoadLibrary\Debug\TestDll.dll"
|
|
|
|
and returns something like "\??\C:\Projects\LoadLibrary\Debug\TestDll.dll."
|
|
|
|
If the file name cannot be interpreted, then the routine returns STATUS_OBJECT_PATH_SYNTAX_BAD and
|
|
|
|
ends execution.
|
|
|
|
*/
|
|
|
|
|
|
|
|
if (!RtlDosPathNameToNtPathName_U ((LPWSTR)lpPathName,
|
|
|
|
&NtPathU,
|
|
|
|
NULL,
|
|
|
|
NULL))
|
|
|
|
{
|
2003-06-07 Casper S. Hornstrup <chorns@users.sourceforge.net>
* include/ddk/dbgfuncs.h: Move ...
* include/ntos/dbgfuncs.h: ... here.
* include/basetsd.h (LONG32): Make it a long.
* include/ntos.h: Include ntos/dbgfuncs.h.
* include/ddk/dbgfuncs.h (DBG_STATUS_*, DBG_GET_SHOW_*): Move to
include/ntos/dbgfuncs.h.
* include/ddk/exfuncs.h (ExNotifyCallback): Match w32api prototype.
(*BinaryTree, *SplayTree, *HashTable): Move to include/ntos/zw.h.
* include/ddk/extypes.h (TRAVERSE_METHOD, PKEY_COMPARATOR,
PTRAVERSE_ROUTINE, _BINARY_TREE_NODE, BINARY_TREE, SPLAY_TREE_NODE,
SPLAY_TREE, HASH_TABLE): Move to include/ntos/zwtypes.h.
* include/ddk/status.h (STATUS_PATH_SYNTAX_BAD): Rename to
STATUS_OBJECT_PATH_SYNTAX_BAD.
* apps/utils/objdir/objdir.c (StatusToName): Change
STATUS_PATH_SYNTAX_BAD to STATUS_OBJECT_PATH_SYNTAX_BAD.
* ntoskrnl/dbg/errinfo.c: Use STATUS_OBJECT_PATH_SYNTAX_BAD.
* include/ntos/rtl.h (RtlQueryRegistryValues, RtlWriteRegistryValue,
RtlDeleteRegistryValue): Match w32api prototypes.
* include/ntos/zw.h (ZwQuerySystemTime): Ditto.
* lib/kernel32/file/cnotify.c (FindFirstChangeNotificationW): Use
STATUS_OBJECT_PATH_SYNTAX_BAD.
* lib/ntdll/rtl/registry.c (RtlDeleteRegistryValue,
RtlQueryRegistryValues, RtlWriteRegistryValue): Match w32api prototypes.
* ntoskrnl/cm/cm.h, ntoskrnl/cm/ntfunc.c, ntoskrnl/cm/regfile.c: Change
FILETIME to LARGE_INTEGER.
* ntoskrnl/cm/rtlfunc.c (RtlDeleteRegistryValue, RtlQueryRegistryValues,
RtlWriteRegistryValue): Match w32api prototypes.
* ntoskrnl/ex/callback.c (ExNotifyCallback): Ditto.
* ntoskrnl/ex/time.c (NtQuerySystemTime): Ditto.
svn path=/trunk/; revision=4870
2003-06-07 16:16:39 +00:00
|
|
|
SetLastErrorByStatus(STATUS_OBJECT_PATH_SYNTAX_BAD);
|
2003-03-23 19:51:11 +00:00
|
|
|
return INVALID_HANDLE_VALUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
InitializeObjectAttributes (&ObjectAttributes,
|
|
|
|
&NtPathU,
|
|
|
|
0,
|
|
|
|
NULL,
|
|
|
|
NULL);
|
|
|
|
|
2003-07-15 10:49:52 +00:00
|
|
|
Status = NtOpenFile (&hDir,
|
2003-03-23 19:51:11 +00:00
|
|
|
SYNCHRONIZE|FILE_LIST_DIRECTORY,
|
|
|
|
&ObjectAttributes,
|
|
|
|
&IoStatus,
|
|
|
|
FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE,
|
|
|
|
FILE_DIRECTORY_FILE);
|
|
|
|
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
SetLastErrorByStatus(Status);
|
|
|
|
return INVALID_HANDLE_VALUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
Status = NtNotifyChangeDirectoryFile(hDir,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
&IoStatus,
|
|
|
|
NULL,//Buffer,
|
|
|
|
0,//BufferLength,
|
|
|
|
dwNotifyFilter,
|
|
|
|
bWatchSubtree);
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
SetLastErrorByStatus(Status);
|
|
|
|
return INVALID_HANDLE_VALUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return hDir;
|
1999-01-01 22:03:17 +00:00
|
|
|
}
|
|
|
|
|
2000-03-15 12:25:47 +00:00
|
|
|
|
2003-07-10 18:50:51 +00:00
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
2004-01-23 16:37:11 +00:00
|
|
|
BOOL
|
1999-01-01 22:03:17 +00:00
|
|
|
STDCALL
|
2000-03-15 12:25:47 +00:00
|
|
|
FindNextChangeNotification (
|
|
|
|
HANDLE hChangeHandle
|
1999-01-01 22:03:17 +00:00
|
|
|
)
|
|
|
|
{
|
2003-03-23 19:51:11 +00:00
|
|
|
IO_STATUS_BLOCK IoStatus;
|
|
|
|
NTSTATUS Status;
|
|
|
|
|
|
|
|
Status = NtNotifyChangeDirectoryFile(hChangeHandle,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
&IoStatus,
|
|
|
|
NULL,//Buffer,
|
|
|
|
0,//BufferLength,
|
|
|
|
FILE_NOTIFY_CHANGE_SECURITY,//meaningless for subsequent calls, but must contain a valid flag(s)
|
|
|
|
0//meaningless for subsequent calls
|
|
|
|
);
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
SetLastErrorByStatus(Status);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
1999-01-01 22:03:17 +00:00
|
|
|
}
|
|
|
|
|
2000-03-15 12:25:47 +00:00
|
|
|
/* EOF */
|