Implement RegNotifyChangeKeyValue on top of NtNotifyChangeKey.

This commit is contained in:
Robert Shearman 2005-05-16 14:08:11 +00:00 committed by Alexandre Julliard
parent bac5f4603d
commit efbea2e2bc
2 changed files with 53 additions and 30 deletions

View File

@ -35,11 +35,11 @@
#include "winreg.h" #include "winreg.h"
#include "winerror.h" #include "winerror.h"
#include "ntstatus.h" #include "ntstatus.h"
#include "wine/unicode.h"
#include "wine/server.h"
#include "wine/debug.h"
#include "winternl.h" #include "winternl.h"
#include "wine/unicode.h"
#include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL(reg); WINE_DEFAULT_DEBUG_CHANNEL(reg);
/* allowed bits for access mask */ /* allowed bits for access mask */
@ -2032,32 +2032,23 @@ LONG WINAPI RegNotifyChangeKeyValue( HKEY hkey, BOOL fWatchSubTree,
DWORD fdwNotifyFilter, HANDLE hEvent, DWORD fdwNotifyFilter, HANDLE hEvent,
BOOL fAsync ) BOOL fAsync )
{ {
LONG ret; NTSTATUS status;
IO_STATUS_BLOCK iosb;
TRACE("(%p,%i,%ld,%p,%i)\n",hkey,fWatchSubTree,fdwNotifyFilter, hkey = get_special_root_hkey( hkey );
hEvent,fAsync); if (!hkey) return ERROR_INVALID_HANDLE;
if( !fAsync ) TRACE("(%p,%i,%ld,%p,%i)\n", hkey, fWatchSubTree, fdwNotifyFilter,
hEvent = CreateEventW(NULL, 0, 0, NULL); hEvent, fAsync);
SERVER_START_REQ( set_registry_notification ) status = NtNotifyChangeKey( hkey, hEvent, NULL, NULL, &iosb,
{ fdwNotifyFilter, fWatchSubTree, NULL, 0,
req->hkey = hkey; fAsync );
req->event = hEvent;
req->subtree = fWatchSubTree;
req->filter = fdwNotifyFilter;
ret = RtlNtStatusToDosError( wine_server_call(req) );
}
SERVER_END_REQ;
if( !fAsync )
{
if( ret == ERROR_SUCCESS )
WaitForSingleObject( hEvent, INFINITE );
CloseHandle( hEvent );
}
return ret; if (status && status != STATUS_TIMEOUT)
return RtlNtStatusToDosError( status );
return ERROR_SUCCESS;
} }
/****************************************************************************** /******************************************************************************

View File

@ -595,15 +595,47 @@ NTSTATUS WINAPI NtNotifyChangeKey(
IN PVOID ApcContext OPTIONAL, IN PVOID ApcContext OPTIONAL,
OUT PIO_STATUS_BLOCK IoStatusBlock, OUT PIO_STATUS_BLOCK IoStatusBlock,
IN ULONG CompletionFilter, IN ULONG CompletionFilter,
IN BOOLEAN Asynchroneous, IN BOOLEAN Asynchronous,
OUT PVOID ChangeBuffer, OUT PVOID ChangeBuffer,
IN ULONG Length, IN ULONG Length,
IN BOOLEAN WatchSubtree) IN BOOLEAN WatchSubtree)
{ {
FIXME("(%p,%p,%p,%p,%p,0x%08lx, 0x%08x,%p,0x%08lx,0x%08x) stub!\n", NTSTATUS ret;
KeyHandle, Event, ApcRoutine, ApcContext, IoStatusBlock, CompletionFilter,
Asynchroneous, ChangeBuffer, Length, WatchSubtree); TRACE("(%p,%p,%p,%p,%p,0x%08lx, 0x%08x,%p,0x%08lx,0x%08x)\n",
return STATUS_SUCCESS; KeyHandle, Event, ApcRoutine, ApcContext, IoStatusBlock, CompletionFilter,
Asynchronous, ChangeBuffer, Length, WatchSubtree);
if (ApcRoutine || ApcContext || ChangeBuffer || Length)
FIXME("Unimplemented optional parameter\n");
if (!Asynchronous)
{
OBJECT_ATTRIBUTES attr;
InitializeObjectAttributes( &attr, NULL, 0, NULL, NULL );
ret = NtCreateEvent( &Event, EVENT_ALL_ACCESS, &attr, FALSE, FALSE );
if (ret != STATUS_SUCCESS)
return ret;
}
SERVER_START_REQ( set_registry_notification )
{
req->hkey = KeyHandle;
req->event = Event;
req->subtree = WatchSubtree;
req->filter = CompletionFilter;
ret = wine_server_call( req );
}
SERVER_END_REQ;
if (!Asynchronous)
{
if (ret == STATUS_SUCCESS)
NtWaitForSingleObject( Event, FALSE, NULL );
NtClose( Event );
}
return STATUS_SUCCESS;
} }
/****************************************************************************** /******************************************************************************