Commit 6d50cfca authored by André Hentschel's avatar André Hentschel Committed by Alexandre Julliard

ntdll: Use a dynamic buffer for change notification data.

parent 95763d91
...@@ -3307,8 +3307,10 @@ struct read_changes_info ...@@ -3307,8 +3307,10 @@ struct read_changes_info
HANDLE FileHandle; HANDLE FileHandle;
PVOID Buffer; PVOID Buffer;
ULONG BufferSize; ULONG BufferSize;
ULONG data_size;
PIO_APC_ROUTINE apc; PIO_APC_ROUTINE apc;
void *apc_arg; void *apc_arg;
char data[1];
}; };
/* callback for ioctl user APC */ /* callback for ioctl user APC */
...@@ -3322,14 +3324,13 @@ static void WINAPI read_changes_user_apc( void *arg, IO_STATUS_BLOCK *io, ULONG ...@@ -3322,14 +3324,13 @@ static void WINAPI read_changes_user_apc( void *arg, IO_STATUS_BLOCK *io, ULONG
static NTSTATUS read_changes_apc( void *user, PIO_STATUS_BLOCK iosb, NTSTATUS status, void **apc ) static NTSTATUS read_changes_apc( void *user, PIO_STATUS_BLOCK iosb, NTSTATUS status, void **apc )
{ {
struct read_changes_info *info = user; struct read_changes_info *info = user;
char data[PATH_MAX];
NTSTATUS ret; NTSTATUS ret;
int size; int size;
SERVER_START_REQ( read_change ) SERVER_START_REQ( read_change )
{ {
req->handle = wine_server_obj_handle( info->FileHandle ); req->handle = wine_server_obj_handle( info->FileHandle );
wine_server_set_reply( req, data, PATH_MAX ); wine_server_set_reply( req, info->data, info->data_size );
ret = wine_server_call( req ); ret = wine_server_call( req );
size = wine_server_reply_size( reply ); size = wine_server_reply_size( reply );
} }
...@@ -3340,7 +3341,7 @@ static NTSTATUS read_changes_apc( void *user, PIO_STATUS_BLOCK iosb, NTSTATUS st ...@@ -3340,7 +3341,7 @@ static NTSTATUS read_changes_apc( void *user, PIO_STATUS_BLOCK iosb, NTSTATUS st
PFILE_NOTIFY_INFORMATION pfni = info->Buffer; PFILE_NOTIFY_INFORMATION pfni = info->Buffer;
int i, left = info->BufferSize; int i, left = info->BufferSize;
DWORD *last_entry_offset = NULL; DWORD *last_entry_offset = NULL;
struct filesystem_event *event = (struct filesystem_event*)data; struct filesystem_event *event = (struct filesystem_event*)info->data;
while (size && left >= sizeof(*pfni)) while (size && left >= sizeof(*pfni))
{ {
...@@ -3413,6 +3414,7 @@ NtNotifyChangeDirectoryFile( HANDLE FileHandle, HANDLE Event, ...@@ -3413,6 +3414,7 @@ NtNotifyChangeDirectoryFile( HANDLE FileHandle, HANDLE Event,
{ {
struct read_changes_info *info; struct read_changes_info *info;
NTSTATUS status; NTSTATUS status;
ULONG size = max( 4096, BufferSize );
ULONG_PTR cvalue = ApcRoutine ? 0 : (ULONG_PTR)ApcContext; ULONG_PTR cvalue = ApcRoutine ? 0 : (ULONG_PTR)ApcContext;
TRACE("%p %p %p %p %p %p %u %u %d\n", TRACE("%p %p %p %p %p %p %u %u %d\n",
...@@ -3425,7 +3427,7 @@ NtNotifyChangeDirectoryFile( HANDLE FileHandle, HANDLE Event, ...@@ -3425,7 +3427,7 @@ NtNotifyChangeDirectoryFile( HANDLE FileHandle, HANDLE Event,
if (CompletionFilter == 0 || (CompletionFilter & ~FILE_NOTIFY_ALL)) if (CompletionFilter == 0 || (CompletionFilter & ~FILE_NOTIFY_ALL))
return STATUS_INVALID_PARAMETER; return STATUS_INVALID_PARAMETER;
info = RtlAllocateHeap( GetProcessHeap(), 0, sizeof *info ); info = RtlAllocateHeap( GetProcessHeap(), 0, offsetof( struct read_changes_info, data[size] ));
if (!info) if (!info)
return STATUS_NO_MEMORY; return STATUS_NO_MEMORY;
...@@ -3434,6 +3436,7 @@ NtNotifyChangeDirectoryFile( HANDLE FileHandle, HANDLE Event, ...@@ -3434,6 +3436,7 @@ NtNotifyChangeDirectoryFile( HANDLE FileHandle, HANDLE Event,
info->BufferSize = BufferSize; info->BufferSize = BufferSize;
info->apc = ApcRoutine; info->apc = ApcRoutine;
info->apc_arg = ApcContext; info->apc_arg = ApcContext;
info->data_size = size;
SERVER_START_REQ( read_directory_changes ) SERVER_START_REQ( read_directory_changes )
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment