Re: Add tests for ntdll event functions

2013-06-03 Thread Andrew Cook
While implemeting NtQueryEvent i stumbled across an odd permissions
issue, which is really what this patch tests

if ((event = create_event( root, &name, req->attributes,
req->manual_reset, req->initial_state, sd )))
{
if (get_error() == STATUS_OBJECT_NAME_EXISTS)
reply->handle = alloc_handle( current->process, event,
req->access, req->attributes );
else
reply->handle = alloc_handle_no_access_check(
current->process, event, req->access, req->attributes );
release_object( event );
}

when creating an event, the handle is allocated with
alloc_handle_no_access_check, which does not call event_map_access
this causes event_op and event_query to fail, as the handle only has
GENERIC_ALL, not the actual event permissions,
which does not match windows behaviour (or at least windows 7 anyway),

On 04/06/13 11:13, Andrew Cook wrote:
> ---
>  dlls/ntdll/tests/Makefile.in |  1 +
>  dlls/ntdll/tests/event.c | 69
> 
>  2 files changed, 70 insertions(+)
>  create mode 100644 dlls/ntdll/tests/event.c
>
> diff --git a/dlls/ntdll/tests/Makefile.in b/dlls/ntdll/tests/Makefile.in
> index 10d6674..a44b880 100644
> --- a/dlls/ntdll/tests/Makefile.in
> +++ b/dlls/ntdll/tests/Makefile.in
> @@ -7,6 +7,7 @@ C_SRCS = \
>   directory.c \
>   env.c \
>   error.c \
> + event.c \
>   exception.c \
>   file.c \
>   generated.c \
> diff --git a/dlls/ntdll/tests/event.c b/dlls/ntdll/tests/event.c
> new file mode 100644
> index 000..f29abc3
> --- /dev/null
> +++ b/dlls/ntdll/tests/event.c
> @@ -0,0 +1,69 @@
> +/*
> + * Unit test suite for event functions
> + *
> + * Copyright 2005 Robert Shearman
> + * Copyright 2005 Vitaliy Margolen
> + *
> + * This library is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU Lesser General Public
> + * License as published by the Free Software Foundation; either
> + * version 2.1 of the License, or (at your option) any later version.
> + *
> + * This library is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> + * Lesser General Public License for more details.
> + *
> + * You should have received a copy of the GNU Lesser General Public
> + * License along with this library; if not, write to the Free Software
> + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
> 02110-1301, USA
> + */
> +
> +#include "ntdll_test.h"
> +#include "winternl.h"
> +#include "winnt.h"
> +
> +static NTSTATUS (WINAPI *pNtCreateEvent) ( PHANDLE, ACCESS_MASK, const
> POBJECT_ATTRIBUTES, BOOLEAN, BOOLEAN);
> +static NTSTATUS (WINAPI *pNtPulseEvent)  ( HANDLE, PULONG );
> +static NTSTATUS (WINAPI *pNtQueryEvent)  ( HANDLE,
> EVENT_INFORMATION_CLASS, PVOID, ULONG, PULONG );
> +static NTSTATUS (WINAPI *pNtClose)   ( HANDLE );
> +static VOID (WINAPI *pRtlInitUnicodeString)( PUNICODE_STRING,
> LPCWSTR );
> +
> +START_TEST(event)
> +{
> +HANDLE Event;
> +NTSTATUS status;
> +UNICODE_STRING str;
> +OBJECT_ATTRIBUTES attr;
> +EVENT_BASIC_INFORMATION info;
> +HMODULE hntdll = GetModuleHandleA("ntdll.dll");
> +HMODULE hkernel32 = GetModuleHandleA("kernel32.dll");
> +static const WCHAR eventName[] =
> {'\\','B','a','s','e','N','a','m','e','d','O','b','j','e','c','t','s','\\','t','e','s','t','E','v','e','n','t',0};
> +
> +if (!hntdll)
> +{
> +skip("not running on NT, skipping test\n");
> +return;
> +}
> +
> +pNtCreateEvent = (void *)GetProcAddress(hntdll, "NtCreateEvent");
> +pNtQueryEvent  = (void *)GetProcAddress(hntdll, "NtQueryEvent");
> +pNtPulseEvent  = (void *)GetProcAddress(hntdll, "NtPulseEvent");
> +pNtClose   = (void *)GetProcAddress(hntdll, "NtClose");
> +pRtlInitUnicodeString = (void *)GetProcAddress(hntdll,
> "RtlInitUnicodeString");
> +
> +pRtlInitUnicodeString(&str, eventName);
> +InitializeObjectAttributes(&attr, &str, 0, 0, NULL);
> +
> +status = pNtCreateEvent(&Event, GENERIC_ALL, &attr, 0, 0);
> +ok( status == STATUS_SUCCESS, "NtCreateEvent failed %08x\n", status );
> +
> +status = pNtPulseEvent(Event, 0);
> +todo_wine ok( status == STATUS_SUCCESS, "NtPulseEvent failed
> %08x\n", status );
> +
> +status = pNtQueryEvent(Event, EventBasicInformation, &info,
> sizeof(info), NULL);
> +todo_wine ok( status == STATUS_SUCCESS, "NtQueryEvent failed
> %08x\n", status );
> +
> +status = pNtClose(Event);
> +ok( status == STATUS_SUCCESS, "NtClose failed %08x\n", status );
> +}





Re: [2/2] wineserver: perform access check when creating event objects (try 2)

2013-08-08 Thread Andrew Cook
Actually ignore this patch, the problem was introduced by 92db6d2c back
in 2007,

server: Don't do access checks on the security descriptors of newly
created objects

which fixes sync.c:363 "CreateEventW with blank sd failed"

i'll need to take another look at this, calling CreateEventEx with
generic flags fails to correctly set permissions, the patch as it stands
though will likely cause regressions.

On 02/08/13 21:58, Andrew Cook wrote:
> ---
>  dlls/ntdll/tests/om.c | 4 ++--
>  server/event.c| 5 +
>  2 files changed, 3 insertions(+), 6 deletions(-)
> 
> 





Re: ntdll: Implement job objects

2013-08-27 Thread Andrew Cook
On 27/08/13 22:02, Dmitry Timoshkov wrote:
> Andrew Cook  wrote:
>> --- a/include/wine/server_protocol.h
>> +++ b/include/wine/server_protocol.h
> 
> And don't include autogenerated stuff in the patch.
> 

Is there anything about this on the wiki? i wasn't sure how
autogenerated files are supposed to be handled.




Re: ntdll/tests: Add tests for job objects. (try 2)

2013-09-06 Thread Andrew Cook
On 06/09/13 17:12, Frédéric Delanoy wrote:
> On Fri, Sep 6, 2013 at 5:41 AM, Andrew Cook  wrote:
>> ---
>>  dlls/ntdll/tests/Makefile.in |   1 +
>>  dlls/ntdll/tests/job.c   | 151
>> +++
>>  include/winnt.h  |   5 ++
>>  3 files changed, 157 insertions(+)
>>  create mode 100644 dlls/ntdll/tests/job.c
> 
> +if(pNtIsProcessInJob)
> +todo_wine todo_wine ok(pNtIsProcessInJob(pi[0].hProcess,
> JobObject) == STATUS_PROCESS_NOT_IN_JOB,
> +"NtIsProcessInJob: expected STATUS_PROCESS_NOT_IN_JOB,
> got %x\n", ret);
> 
> Is that double todo_wine intended? It seems weird...
> 

I have no idea how i missed that.

probably better this patch is disregarded, i've sent an equivalent set
of tests for kernel32.




Re: rpcss: Convert to a service

2013-10-02 Thread Andrew Cook
Ignore this, for some reason this randomly forks a huge number of rpcss
instances, and decided to not do so while i was testing it

On 03/10/13 14:00, Andrew Cook wrote:
> ---
>  dlls/rpcrt4/rpc_epmap.c | 40 ---
>  programs/rpcss/Makefile.in  |  2 +-
>  programs/rpcss/rpcss_main.c | 97
> +++--
>  tools/wine.inf.in   | 11 +
>  4 files changed, 104 insertions(+), 46 deletions(-)
> 
> 





Fwd: Re: kernel32/tests: Add tests for job objects (try 7)

2013-10-11 Thread Andrew Cook
(no idea why my client sent this to wine-patches)

On 10/10/13 15:23, Andrew Cook wrote:
> ---
>  dlls/kernel32/tests/process.c | 159
> +-
>  include/winbase.h |   1 +
>  include/winnt.h   |  90 
>  3 files changed, 249 insertions(+), 1 deletion(-)
> 
> 

there appears to be a window between the all processes leaving a job and
the job actually being considered empty, and no apparent way to wait for
this. I can't reproduce this locally either.

Is there an accepted way to wait for some inaccessible kernel-side
event? reordering some calls would likely hide the issue but i'd rather
avoid that.

https://newtestbot.winehq.org/JobDetails.pl?Key=2687 failure on w8
https://newtestbot.winehq.org/JobDetails.pl?Key=2709 failure on w864
https://newtestbot.winehq.org/JobDetails.pl?Key=2685 same patch, success
on w864