1999-03-09 18:47:51 +01:00
|
|
|
/*
|
|
|
|
* Process synchronisation
|
2002-03-10 00:29:33 +01:00
|
|
|
*
|
2003-05-20 06:00:42 +02:00
|
|
|
* Copyright 1996, 1997, 1998 Marcus Meissner
|
|
|
|
* Copyright 1997, 1999 Alexandre Julliard
|
2002-03-10 00:29:33 +01:00
|
|
|
* Copyright 1999, 2000 Juergen Schmied
|
2003-05-20 06:00:42 +02:00
|
|
|
* Copyright 2003 Eric Pouech
|
2002-03-10 00:29:33 +01:00
|
|
|
*
|
|
|
|
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
1999-03-09 18:47:51 +01:00
|
|
|
*/
|
|
|
|
|
2003-03-31 03:37:04 +02:00
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#include <assert.h>
|
|
|
|
#include <errno.h>
|
|
|
|
#include <signal.h>
|
|
|
|
#ifdef HAVE_SYS_TIME_H
|
|
|
|
# include <sys/time.h>
|
|
|
|
#endif
|
|
|
|
#ifdef HAVE_SYS_POLL_H
|
|
|
|
# include <sys/poll.h>
|
|
|
|
#endif
|
|
|
|
#ifdef HAVE_UNISTD_H
|
|
|
|
# include <unistd.h>
|
|
|
|
#endif
|
2004-10-09 04:26:29 +02:00
|
|
|
#ifdef HAVE_SCHED_H
|
|
|
|
# include <sched.h>
|
|
|
|
#endif
|
2003-03-31 03:37:04 +02:00
|
|
|
#include <string.h>
|
2003-09-06 01:08:26 +02:00
|
|
|
#include <stdarg.h>
|
1999-06-12 16:55:11 +02:00
|
|
|
#include <stdio.h>
|
1999-03-09 18:47:51 +01:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <time.h>
|
|
|
|
|
2003-03-31 21:32:20 +02:00
|
|
|
#define NONAMELESSUNION
|
|
|
|
#define NONAMELESSSTRUCT
|
|
|
|
|
2003-09-06 01:08:26 +02:00
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
|
|
|
#include "winreg.h"
|
2002-09-13 00:07:02 +02:00
|
|
|
#include "winternl.h"
|
2003-03-31 03:37:04 +02:00
|
|
|
#include "thread.h"
|
|
|
|
#include "wine/server.h"
|
|
|
|
#include "wine/debug.h"
|
- implementation of RtlReg* (read access), RtlEvent*, RtlSemaphore*,
NtAllocateLocallyUniqueId
- implementation or stubs for NtAccessCheck, NtSetSecurityObject,
RtlClearBits, RtlEqualPrefixSid, RtlFindClearBits,
RtlFormatCurrentUserKeyPath, RtlGetControlSecurityDescriptor,
RtlIdentifierAuthoritySid, RtlImpersonateSelf, RtlInitializeBitMap,
RtlInitializeGenericTable, RtlMakeSelfRelativeSD,
RtlPrefixUnicodeString, RtlSetBits, RtlUnicodeToMultiByteN,
RtlUpcaseUnicodeStringToOemString, RtlUpcaseUnicodeToOemN,
RtlValidSid, RtlxUnicodeStringToOemSize
- corrected most RtlString* functions, added documentation
- more fixes and partial implementations
2000-01-23 23:35:33 +01:00
|
|
|
#include "ntdll_misc.h"
|
1999-03-09 18:47:51 +01:00
|
|
|
|
2002-03-10 00:29:33 +01:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(ntdll);
|
- implementation of RtlReg* (read access), RtlEvent*, RtlSemaphore*,
NtAllocateLocallyUniqueId
- implementation or stubs for NtAccessCheck, NtSetSecurityObject,
RtlClearBits, RtlEqualPrefixSid, RtlFindClearBits,
RtlFormatCurrentUserKeyPath, RtlGetControlSecurityDescriptor,
RtlIdentifierAuthoritySid, RtlImpersonateSelf, RtlInitializeBitMap,
RtlInitializeGenericTable, RtlMakeSelfRelativeSD,
RtlPrefixUnicodeString, RtlSetBits, RtlUnicodeToMultiByteN,
RtlUpcaseUnicodeStringToOemString, RtlUpcaseUnicodeToOemN,
RtlValidSid, RtlxUnicodeStringToOemSize
- corrected most RtlString* functions, added documentation
- more fixes and partial implementations
2000-01-23 23:35:33 +01:00
|
|
|
|
|
|
|
|
1999-03-09 18:47:51 +01:00
|
|
|
/*
|
- implementation of RtlReg* (read access), RtlEvent*, RtlSemaphore*,
NtAllocateLocallyUniqueId
- implementation or stubs for NtAccessCheck, NtSetSecurityObject,
RtlClearBits, RtlEqualPrefixSid, RtlFindClearBits,
RtlFormatCurrentUserKeyPath, RtlGetControlSecurityDescriptor,
RtlIdentifierAuthoritySid, RtlImpersonateSelf, RtlInitializeBitMap,
RtlInitializeGenericTable, RtlMakeSelfRelativeSD,
RtlPrefixUnicodeString, RtlSetBits, RtlUnicodeToMultiByteN,
RtlUpcaseUnicodeStringToOemString, RtlUpcaseUnicodeToOemN,
RtlValidSid, RtlxUnicodeStringToOemSize
- corrected most RtlString* functions, added documentation
- more fixes and partial implementations
2000-01-23 23:35:33 +01:00
|
|
|
* Semaphores
|
1999-03-09 18:47:51 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
/******************************************************************************
|
2001-06-19 20:20:47 +02:00
|
|
|
* NtCreateSemaphore (NTDLL.@)
|
1999-03-09 18:47:51 +01:00
|
|
|
*/
|
2000-08-30 02:00:48 +02:00
|
|
|
NTSTATUS WINAPI NtCreateSemaphore( OUT PHANDLE SemaphoreHandle,
|
|
|
|
IN ACCESS_MASK access,
|
|
|
|
IN const OBJECT_ATTRIBUTES *attr OPTIONAL,
|
2004-12-02 19:05:37 +01:00
|
|
|
IN LONG InitialCount,
|
|
|
|
IN LONG MaximumCount )
|
1999-03-09 18:47:51 +01:00
|
|
|
{
|
2000-08-30 02:00:48 +02:00
|
|
|
DWORD len = attr && attr->ObjectName ? attr->ObjectName->Length : 0;
|
2000-01-26 02:39:51 +01:00
|
|
|
NTSTATUS ret;
|
|
|
|
|
2004-12-02 19:05:37 +01:00
|
|
|
if (MaximumCount <= 0 || InitialCount < 0 || InitialCount > MaximumCount)
|
2000-01-26 02:39:51 +01:00
|
|
|
return STATUS_INVALID_PARAMETER;
|
2004-12-02 19:05:37 +01:00
|
|
|
if (len >= MAX_PATH * sizeof(WCHAR)) return STATUS_NAME_TOO_LONG;
|
2000-01-26 02:39:51 +01:00
|
|
|
|
2001-11-30 19:46:42 +01:00
|
|
|
SERVER_START_REQ( create_semaphore )
|
2000-08-30 02:00:48 +02:00
|
|
|
{
|
2004-12-02 19:05:37 +01:00
|
|
|
req->access = access;
|
2000-08-30 02:00:48 +02:00
|
|
|
req->initial = InitialCount;
|
|
|
|
req->max = MaximumCount;
|
|
|
|
req->inherit = attr && (attr->Attributes & OBJ_INHERIT);
|
2001-11-30 19:46:42 +01:00
|
|
|
if (len) wine_server_add_data( req, attr->ObjectName->Buffer, len );
|
|
|
|
ret = wine_server_call( req );
|
|
|
|
*SemaphoreHandle = reply->handle;
|
2000-08-30 02:00:48 +02:00
|
|
|
}
|
2001-11-30 19:46:42 +01:00
|
|
|
SERVER_END_REQ;
|
2000-01-26 02:39:51 +01:00
|
|
|
return ret;
|
1999-03-09 18:47:51 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
2001-06-19 20:20:47 +02:00
|
|
|
* NtOpenSemaphore (NTDLL.@)
|
1999-03-09 18:47:51 +01:00
|
|
|
*/
|
2000-08-30 02:00:48 +02:00
|
|
|
NTSTATUS WINAPI NtOpenSemaphore( OUT PHANDLE SemaphoreHandle,
|
|
|
|
IN ACCESS_MASK access,
|
|
|
|
IN const OBJECT_ATTRIBUTES *attr )
|
1999-03-09 18:47:51 +01:00
|
|
|
{
|
2000-08-30 02:00:48 +02:00
|
|
|
DWORD len = attr && attr->ObjectName ? attr->ObjectName->Length : 0;
|
2000-01-26 02:39:51 +01:00
|
|
|
NTSTATUS ret;
|
|
|
|
|
2004-12-02 19:05:37 +01:00
|
|
|
if (len >= MAX_PATH * sizeof(WCHAR)) return STATUS_NAME_TOO_LONG;
|
|
|
|
|
2001-11-30 19:46:42 +01:00
|
|
|
SERVER_START_REQ( open_semaphore )
|
2000-08-30 02:00:48 +02:00
|
|
|
{
|
|
|
|
req->access = access;
|
|
|
|
req->inherit = attr && (attr->Attributes & OBJ_INHERIT);
|
2001-11-30 19:46:42 +01:00
|
|
|
if (len) wine_server_add_data( req, attr->ObjectName->Buffer, len );
|
|
|
|
ret = wine_server_call( req );
|
|
|
|
*SemaphoreHandle = reply->handle;
|
2000-08-30 02:00:48 +02:00
|
|
|
}
|
2001-11-30 19:46:42 +01:00
|
|
|
SERVER_END_REQ;
|
2000-01-26 02:39:51 +01:00
|
|
|
return ret;
|
1999-03-09 18:47:51 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
2001-06-19 20:20:47 +02:00
|
|
|
* NtQuerySemaphore (NTDLL.@)
|
1999-03-09 18:47:51 +01:00
|
|
|
*/
|
|
|
|
NTSTATUS WINAPI NtQuerySemaphore(
|
|
|
|
HANDLE SemaphoreHandle,
|
|
|
|
PVOID SemaphoreInformationClass,
|
|
|
|
OUT PVOID SemaphoreInformation,
|
|
|
|
ULONG Length,
|
2002-06-01 01:06:46 +02:00
|
|
|
PULONG ReturnLength)
|
1999-03-09 18:47:51 +01:00
|
|
|
{
|
2002-12-05 20:56:15 +01:00
|
|
|
FIXME("(%p,%p,%p,0x%08lx,%p) stub!\n",
|
1999-03-09 18:47:51 +01:00
|
|
|
SemaphoreHandle, SemaphoreInformationClass, SemaphoreInformation, Length, ReturnLength);
|
- implementation of RtlReg* (read access), RtlEvent*, RtlSemaphore*,
NtAllocateLocallyUniqueId
- implementation or stubs for NtAccessCheck, NtSetSecurityObject,
RtlClearBits, RtlEqualPrefixSid, RtlFindClearBits,
RtlFormatCurrentUserKeyPath, RtlGetControlSecurityDescriptor,
RtlIdentifierAuthoritySid, RtlImpersonateSelf, RtlInitializeBitMap,
RtlInitializeGenericTable, RtlMakeSelfRelativeSD,
RtlPrefixUnicodeString, RtlSetBits, RtlUnicodeToMultiByteN,
RtlUpcaseUnicodeStringToOemString, RtlUpcaseUnicodeToOemN,
RtlValidSid, RtlxUnicodeStringToOemSize
- corrected most RtlString* functions, added documentation
- more fixes and partial implementations
2000-01-23 23:35:33 +01:00
|
|
|
return STATUS_SUCCESS;
|
1999-03-09 18:47:51 +01:00
|
|
|
}
|
2000-08-30 02:00:48 +02:00
|
|
|
|
1999-03-09 18:47:51 +01:00
|
|
|
/******************************************************************************
|
2001-06-19 20:20:47 +02:00
|
|
|
* NtReleaseSemaphore (NTDLL.@)
|
1999-03-09 18:47:51 +01:00
|
|
|
*/
|
2000-08-30 02:00:48 +02:00
|
|
|
NTSTATUS WINAPI NtReleaseSemaphore( HANDLE handle, ULONG count, PULONG previous )
|
1999-03-09 18:47:51 +01:00
|
|
|
{
|
2000-01-26 02:39:51 +01:00
|
|
|
NTSTATUS ret;
|
2001-02-27 03:09:16 +01:00
|
|
|
SERVER_START_REQ( release_semaphore )
|
2000-01-26 02:39:51 +01:00
|
|
|
{
|
2000-08-30 02:00:48 +02:00
|
|
|
req->handle = handle;
|
|
|
|
req->count = count;
|
2001-11-30 19:46:42 +01:00
|
|
|
if (!(ret = wine_server_call( req )))
|
2000-08-30 02:00:48 +02:00
|
|
|
{
|
2001-11-30 19:46:42 +01:00
|
|
|
if (previous) *previous = reply->prev_count;
|
2000-08-30 02:00:48 +02:00
|
|
|
}
|
2000-01-26 02:39:51 +01:00
|
|
|
}
|
2000-08-30 02:00:48 +02:00
|
|
|
SERVER_END_REQ;
|
2000-01-26 02:39:51 +01:00
|
|
|
return ret;
|
1999-03-09 18:47:51 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
- implementation of RtlReg* (read access), RtlEvent*, RtlSemaphore*,
NtAllocateLocallyUniqueId
- implementation or stubs for NtAccessCheck, NtSetSecurityObject,
RtlClearBits, RtlEqualPrefixSid, RtlFindClearBits,
RtlFormatCurrentUserKeyPath, RtlGetControlSecurityDescriptor,
RtlIdentifierAuthoritySid, RtlImpersonateSelf, RtlInitializeBitMap,
RtlInitializeGenericTable, RtlMakeSelfRelativeSD,
RtlPrefixUnicodeString, RtlSetBits, RtlUnicodeToMultiByteN,
RtlUpcaseUnicodeStringToOemString, RtlUpcaseUnicodeToOemN,
RtlValidSid, RtlxUnicodeStringToOemSize
- corrected most RtlString* functions, added documentation
- more fixes and partial implementations
2000-01-23 23:35:33 +01:00
|
|
|
* Events
|
1999-03-09 18:47:51 +01:00
|
|
|
*/
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-03-09 18:47:51 +01:00
|
|
|
/**************************************************************************
|
2001-06-19 20:20:47 +02:00
|
|
|
* NtCreateEvent (NTDLL.@)
|
2001-07-11 20:56:41 +02:00
|
|
|
* ZwCreateEvent (NTDLL.@)
|
1999-03-09 18:47:51 +01:00
|
|
|
*/
|
|
|
|
NTSTATUS WINAPI NtCreateEvent(
|
|
|
|
OUT PHANDLE EventHandle,
|
|
|
|
IN ACCESS_MASK DesiredAccess,
|
2000-08-30 02:00:48 +02:00
|
|
|
IN const OBJECT_ATTRIBUTES *attr,
|
1999-03-09 18:47:51 +01:00
|
|
|
IN BOOLEAN ManualReset,
|
|
|
|
IN BOOLEAN InitialState)
|
|
|
|
{
|
2000-08-30 02:00:48 +02:00
|
|
|
DWORD len = attr && attr->ObjectName ? attr->ObjectName->Length : 0;
|
2000-01-26 02:39:51 +01:00
|
|
|
NTSTATUS ret;
|
|
|
|
|
2004-12-02 19:05:37 +01:00
|
|
|
if (len >= MAX_PATH * sizeof(WCHAR)) return STATUS_NAME_TOO_LONG;
|
|
|
|
|
2001-11-30 19:46:42 +01:00
|
|
|
SERVER_START_REQ( create_event )
|
2000-08-30 02:00:48 +02:00
|
|
|
{
|
2004-12-02 19:05:37 +01:00
|
|
|
req->access = DesiredAccess;
|
2000-08-30 02:00:48 +02:00
|
|
|
req->manual_reset = ManualReset;
|
|
|
|
req->initial_state = InitialState;
|
|
|
|
req->inherit = attr && (attr->Attributes & OBJ_INHERIT);
|
2001-11-30 19:46:42 +01:00
|
|
|
if (len) wine_server_add_data( req, attr->ObjectName->Buffer, len );
|
|
|
|
ret = wine_server_call( req );
|
|
|
|
*EventHandle = reply->handle;
|
2000-08-30 02:00:48 +02:00
|
|
|
}
|
2001-11-30 19:46:42 +01:00
|
|
|
SERVER_END_REQ;
|
2000-01-26 02:39:51 +01:00
|
|
|
return ret;
|
1999-03-09 18:47:51 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
2001-06-19 20:20:47 +02:00
|
|
|
* NtOpenEvent (NTDLL.@)
|
2001-07-11 20:56:41 +02:00
|
|
|
* ZwOpenEvent (NTDLL.@)
|
1999-03-09 18:47:51 +01:00
|
|
|
*/
|
|
|
|
NTSTATUS WINAPI NtOpenEvent(
|
|
|
|
OUT PHANDLE EventHandle,
|
|
|
|
IN ACCESS_MASK DesiredAccess,
|
2000-08-30 02:00:48 +02:00
|
|
|
IN const OBJECT_ATTRIBUTES *attr )
|
1999-03-09 18:47:51 +01:00
|
|
|
{
|
2000-08-30 02:00:48 +02:00
|
|
|
DWORD len = attr && attr->ObjectName ? attr->ObjectName->Length : 0;
|
2000-01-26 02:39:51 +01:00
|
|
|
NTSTATUS ret;
|
|
|
|
|
2004-12-02 19:05:37 +01:00
|
|
|
if (len >= MAX_PATH * sizeof(WCHAR)) return STATUS_NAME_TOO_LONG;
|
|
|
|
|
2001-11-30 19:46:42 +01:00
|
|
|
SERVER_START_REQ( open_event )
|
2000-08-30 02:00:48 +02:00
|
|
|
{
|
|
|
|
req->access = DesiredAccess;
|
|
|
|
req->inherit = attr && (attr->Attributes & OBJ_INHERIT);
|
2001-11-30 19:46:42 +01:00
|
|
|
if (len) wine_server_add_data( req, attr->ObjectName->Buffer, len );
|
|
|
|
ret = wine_server_call( req );
|
|
|
|
*EventHandle = reply->handle;
|
2000-08-30 02:00:48 +02:00
|
|
|
}
|
2001-11-30 19:46:42 +01:00
|
|
|
SERVER_END_REQ;
|
2000-01-26 02:39:51 +01:00
|
|
|
return ret;
|
- implementation of RtlReg* (read access), RtlEvent*, RtlSemaphore*,
NtAllocateLocallyUniqueId
- implementation or stubs for NtAccessCheck, NtSetSecurityObject,
RtlClearBits, RtlEqualPrefixSid, RtlFindClearBits,
RtlFormatCurrentUserKeyPath, RtlGetControlSecurityDescriptor,
RtlIdentifierAuthoritySid, RtlImpersonateSelf, RtlInitializeBitMap,
RtlInitializeGenericTable, RtlMakeSelfRelativeSD,
RtlPrefixUnicodeString, RtlSetBits, RtlUnicodeToMultiByteN,
RtlUpcaseUnicodeStringToOemString, RtlUpcaseUnicodeToOemN,
RtlValidSid, RtlxUnicodeStringToOemSize
- corrected most RtlString* functions, added documentation
- more fixes and partial implementations
2000-01-23 23:35:33 +01:00
|
|
|
}
|
|
|
|
|
1999-03-09 18:47:51 +01:00
|
|
|
|
|
|
|
/******************************************************************************
|
2001-06-19 20:20:47 +02:00
|
|
|
* NtSetEvent (NTDLL.@)
|
2001-07-11 20:56:41 +02:00
|
|
|
* ZwSetEvent (NTDLL.@)
|
1999-03-09 18:47:51 +01:00
|
|
|
*/
|
2000-08-30 02:00:48 +02:00
|
|
|
NTSTATUS WINAPI NtSetEvent( HANDLE handle, PULONG NumberOfThreadsReleased )
|
1999-03-09 18:47:51 +01:00
|
|
|
{
|
2000-08-30 02:00:48 +02:00
|
|
|
NTSTATUS ret;
|
2000-09-29 22:48:04 +02:00
|
|
|
|
|
|
|
/* FIXME: set NumberOfThreadsReleased */
|
|
|
|
|
2001-02-27 03:09:16 +01:00
|
|
|
SERVER_START_REQ( event_op )
|
2000-08-30 02:00:48 +02:00
|
|
|
{
|
|
|
|
req->handle = handle;
|
|
|
|
req->op = SET_EVENT;
|
2001-11-30 19:46:42 +01:00
|
|
|
ret = wine_server_call( req );
|
2000-08-30 02:00:48 +02:00
|
|
|
}
|
|
|
|
SERVER_END_REQ;
|
|
|
|
return ret;
|
1999-03-09 18:47:51 +01:00
|
|
|
}
|
|
|
|
|
- implementation of RtlReg* (read access), RtlEvent*, RtlSemaphore*,
NtAllocateLocallyUniqueId
- implementation or stubs for NtAccessCheck, NtSetSecurityObject,
RtlClearBits, RtlEqualPrefixSid, RtlFindClearBits,
RtlFormatCurrentUserKeyPath, RtlGetControlSecurityDescriptor,
RtlIdentifierAuthoritySid, RtlImpersonateSelf, RtlInitializeBitMap,
RtlInitializeGenericTable, RtlMakeSelfRelativeSD,
RtlPrefixUnicodeString, RtlSetBits, RtlUnicodeToMultiByteN,
RtlUpcaseUnicodeStringToOemString, RtlUpcaseUnicodeToOemN,
RtlValidSid, RtlxUnicodeStringToOemSize
- corrected most RtlString* functions, added documentation
- more fixes and partial implementations
2000-01-23 23:35:33 +01:00
|
|
|
/******************************************************************************
|
2001-06-19 20:20:47 +02:00
|
|
|
* NtResetEvent (NTDLL.@)
|
- implementation of RtlReg* (read access), RtlEvent*, RtlSemaphore*,
NtAllocateLocallyUniqueId
- implementation or stubs for NtAccessCheck, NtSetSecurityObject,
RtlClearBits, RtlEqualPrefixSid, RtlFindClearBits,
RtlFormatCurrentUserKeyPath, RtlGetControlSecurityDescriptor,
RtlIdentifierAuthoritySid, RtlImpersonateSelf, RtlInitializeBitMap,
RtlInitializeGenericTable, RtlMakeSelfRelativeSD,
RtlPrefixUnicodeString, RtlSetBits, RtlUnicodeToMultiByteN,
RtlUpcaseUnicodeStringToOemString, RtlUpcaseUnicodeToOemN,
RtlValidSid, RtlxUnicodeStringToOemSize
- corrected most RtlString* functions, added documentation
- more fixes and partial implementations
2000-01-23 23:35:33 +01:00
|
|
|
*/
|
2000-08-30 02:00:48 +02:00
|
|
|
NTSTATUS WINAPI NtResetEvent( HANDLE handle, PULONG NumberOfThreadsReleased )
|
- implementation of RtlReg* (read access), RtlEvent*, RtlSemaphore*,
NtAllocateLocallyUniqueId
- implementation or stubs for NtAccessCheck, NtSetSecurityObject,
RtlClearBits, RtlEqualPrefixSid, RtlFindClearBits,
RtlFormatCurrentUserKeyPath, RtlGetControlSecurityDescriptor,
RtlIdentifierAuthoritySid, RtlImpersonateSelf, RtlInitializeBitMap,
RtlInitializeGenericTable, RtlMakeSelfRelativeSD,
RtlPrefixUnicodeString, RtlSetBits, RtlUnicodeToMultiByteN,
RtlUpcaseUnicodeStringToOemString, RtlUpcaseUnicodeToOemN,
RtlValidSid, RtlxUnicodeStringToOemSize
- corrected most RtlString* functions, added documentation
- more fixes and partial implementations
2000-01-23 23:35:33 +01:00
|
|
|
{
|
2000-08-30 02:00:48 +02:00
|
|
|
NTSTATUS ret;
|
|
|
|
|
|
|
|
/* resetting an event can't release any thread... */
|
|
|
|
if (NumberOfThreadsReleased) *NumberOfThreadsReleased = 0;
|
|
|
|
|
2001-02-27 03:09:16 +01:00
|
|
|
SERVER_START_REQ( event_op )
|
2000-08-30 02:00:48 +02:00
|
|
|
{
|
|
|
|
req->handle = handle;
|
|
|
|
req->op = RESET_EVENT;
|
2001-11-30 19:46:42 +01:00
|
|
|
ret = wine_server_call( req );
|
2000-08-30 02:00:48 +02:00
|
|
|
}
|
|
|
|
SERVER_END_REQ;
|
|
|
|
return ret;
|
- implementation of RtlReg* (read access), RtlEvent*, RtlSemaphore*,
NtAllocateLocallyUniqueId
- implementation or stubs for NtAccessCheck, NtSetSecurityObject,
RtlClearBits, RtlEqualPrefixSid, RtlFindClearBits,
RtlFormatCurrentUserKeyPath, RtlGetControlSecurityDescriptor,
RtlIdentifierAuthoritySid, RtlImpersonateSelf, RtlInitializeBitMap,
RtlInitializeGenericTable, RtlMakeSelfRelativeSD,
RtlPrefixUnicodeString, RtlSetBits, RtlUnicodeToMultiByteN,
RtlUpcaseUnicodeStringToOemString, RtlUpcaseUnicodeToOemN,
RtlValidSid, RtlxUnicodeStringToOemSize
- corrected most RtlString* functions, added documentation
- more fixes and partial implementations
2000-01-23 23:35:33 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
2001-06-19 20:20:47 +02:00
|
|
|
* NtClearEvent (NTDLL.@)
|
- implementation of RtlReg* (read access), RtlEvent*, RtlSemaphore*,
NtAllocateLocallyUniqueId
- implementation or stubs for NtAccessCheck, NtSetSecurityObject,
RtlClearBits, RtlEqualPrefixSid, RtlFindClearBits,
RtlFormatCurrentUserKeyPath, RtlGetControlSecurityDescriptor,
RtlIdentifierAuthoritySid, RtlImpersonateSelf, RtlInitializeBitMap,
RtlInitializeGenericTable, RtlMakeSelfRelativeSD,
RtlPrefixUnicodeString, RtlSetBits, RtlUnicodeToMultiByteN,
RtlUpcaseUnicodeStringToOemString, RtlUpcaseUnicodeToOemN,
RtlValidSid, RtlxUnicodeStringToOemSize
- corrected most RtlString* functions, added documentation
- more fixes and partial implementations
2000-01-23 23:35:33 +01:00
|
|
|
*
|
|
|
|
* FIXME
|
|
|
|
* same as NtResetEvent ???
|
|
|
|
*/
|
2000-08-30 02:00:48 +02:00
|
|
|
NTSTATUS WINAPI NtClearEvent ( HANDLE handle )
|
- implementation of RtlReg* (read access), RtlEvent*, RtlSemaphore*,
NtAllocateLocallyUniqueId
- implementation or stubs for NtAccessCheck, NtSetSecurityObject,
RtlClearBits, RtlEqualPrefixSid, RtlFindClearBits,
RtlFormatCurrentUserKeyPath, RtlGetControlSecurityDescriptor,
RtlIdentifierAuthoritySid, RtlImpersonateSelf, RtlInitializeBitMap,
RtlInitializeGenericTable, RtlMakeSelfRelativeSD,
RtlPrefixUnicodeString, RtlSetBits, RtlUnicodeToMultiByteN,
RtlUpcaseUnicodeStringToOemString, RtlUpcaseUnicodeToOemN,
RtlValidSid, RtlxUnicodeStringToOemSize
- corrected most RtlString* functions, added documentation
- more fixes and partial implementations
2000-01-23 23:35:33 +01:00
|
|
|
{
|
2000-08-30 02:00:48 +02:00
|
|
|
return NtResetEvent( handle, NULL );
|
- implementation of RtlReg* (read access), RtlEvent*, RtlSemaphore*,
NtAllocateLocallyUniqueId
- implementation or stubs for NtAccessCheck, NtSetSecurityObject,
RtlClearBits, RtlEqualPrefixSid, RtlFindClearBits,
RtlFormatCurrentUserKeyPath, RtlGetControlSecurityDescriptor,
RtlIdentifierAuthoritySid, RtlImpersonateSelf, RtlInitializeBitMap,
RtlInitializeGenericTable, RtlMakeSelfRelativeSD,
RtlPrefixUnicodeString, RtlSetBits, RtlUnicodeToMultiByteN,
RtlUpcaseUnicodeStringToOemString, RtlUpcaseUnicodeToOemN,
RtlValidSid, RtlxUnicodeStringToOemSize
- corrected most RtlString* functions, added documentation
- more fixes and partial implementations
2000-01-23 23:35:33 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
2001-06-19 20:20:47 +02:00
|
|
|
* NtPulseEvent (NTDLL.@)
|
- implementation of RtlReg* (read access), RtlEvent*, RtlSemaphore*,
NtAllocateLocallyUniqueId
- implementation or stubs for NtAccessCheck, NtSetSecurityObject,
RtlClearBits, RtlEqualPrefixSid, RtlFindClearBits,
RtlFormatCurrentUserKeyPath, RtlGetControlSecurityDescriptor,
RtlIdentifierAuthoritySid, RtlImpersonateSelf, RtlInitializeBitMap,
RtlInitializeGenericTable, RtlMakeSelfRelativeSD,
RtlPrefixUnicodeString, RtlSetBits, RtlUnicodeToMultiByteN,
RtlUpcaseUnicodeStringToOemString, RtlUpcaseUnicodeToOemN,
RtlValidSid, RtlxUnicodeStringToOemSize
- corrected most RtlString* functions, added documentation
- more fixes and partial implementations
2000-01-23 23:35:33 +01:00
|
|
|
*
|
|
|
|
* FIXME
|
|
|
|
* PulseCount
|
|
|
|
*/
|
2000-08-30 02:00:48 +02:00
|
|
|
NTSTATUS WINAPI NtPulseEvent( HANDLE handle, PULONG PulseCount )
|
- implementation of RtlReg* (read access), RtlEvent*, RtlSemaphore*,
NtAllocateLocallyUniqueId
- implementation or stubs for NtAccessCheck, NtSetSecurityObject,
RtlClearBits, RtlEqualPrefixSid, RtlFindClearBits,
RtlFormatCurrentUserKeyPath, RtlGetControlSecurityDescriptor,
RtlIdentifierAuthoritySid, RtlImpersonateSelf, RtlInitializeBitMap,
RtlInitializeGenericTable, RtlMakeSelfRelativeSD,
RtlPrefixUnicodeString, RtlSetBits, RtlUnicodeToMultiByteN,
RtlUpcaseUnicodeStringToOemString, RtlUpcaseUnicodeToOemN,
RtlValidSid, RtlxUnicodeStringToOemSize
- corrected most RtlString* functions, added documentation
- more fixes and partial implementations
2000-01-23 23:35:33 +01:00
|
|
|
{
|
2000-08-30 02:00:48 +02:00
|
|
|
NTSTATUS ret;
|
2004-04-01 23:01:53 +02:00
|
|
|
|
|
|
|
if (PulseCount)
|
|
|
|
FIXME("(%p,%ld)\n", handle, *PulseCount);
|
|
|
|
|
2001-02-27 03:09:16 +01:00
|
|
|
SERVER_START_REQ( event_op )
|
2000-08-30 02:00:48 +02:00
|
|
|
{
|
|
|
|
req->handle = handle;
|
|
|
|
req->op = PULSE_EVENT;
|
2001-11-30 19:46:42 +01:00
|
|
|
ret = wine_server_call( req );
|
2000-08-30 02:00:48 +02:00
|
|
|
}
|
|
|
|
SERVER_END_REQ;
|
|
|
|
return ret;
|
- implementation of RtlReg* (read access), RtlEvent*, RtlSemaphore*,
NtAllocateLocallyUniqueId
- implementation or stubs for NtAccessCheck, NtSetSecurityObject,
RtlClearBits, RtlEqualPrefixSid, RtlFindClearBits,
RtlFormatCurrentUserKeyPath, RtlGetControlSecurityDescriptor,
RtlIdentifierAuthoritySid, RtlImpersonateSelf, RtlInitializeBitMap,
RtlInitializeGenericTable, RtlMakeSelfRelativeSD,
RtlPrefixUnicodeString, RtlSetBits, RtlUnicodeToMultiByteN,
RtlUpcaseUnicodeStringToOemString, RtlUpcaseUnicodeToOemN,
RtlValidSid, RtlxUnicodeStringToOemSize
- corrected most RtlString* functions, added documentation
- more fixes and partial implementations
2000-01-23 23:35:33 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
2001-06-19 20:20:47 +02:00
|
|
|
* NtQueryEvent (NTDLL.@)
|
- implementation of RtlReg* (read access), RtlEvent*, RtlSemaphore*,
NtAllocateLocallyUniqueId
- implementation or stubs for NtAccessCheck, NtSetSecurityObject,
RtlClearBits, RtlEqualPrefixSid, RtlFindClearBits,
RtlFormatCurrentUserKeyPath, RtlGetControlSecurityDescriptor,
RtlIdentifierAuthoritySid, RtlImpersonateSelf, RtlInitializeBitMap,
RtlInitializeGenericTable, RtlMakeSelfRelativeSD,
RtlPrefixUnicodeString, RtlSetBits, RtlUnicodeToMultiByteN,
RtlUpcaseUnicodeStringToOemString, RtlUpcaseUnicodeToOemN,
RtlValidSid, RtlxUnicodeStringToOemSize
- corrected most RtlString* functions, added documentation
- more fixes and partial implementations
2000-01-23 23:35:33 +01:00
|
|
|
*/
|
|
|
|
NTSTATUS WINAPI NtQueryEvent (
|
|
|
|
IN HANDLE EventHandle,
|
|
|
|
IN UINT EventInformationClass,
|
|
|
|
OUT PVOID EventInformation,
|
|
|
|
IN ULONG EventInformationLength,
|
|
|
|
OUT PULONG ReturnLength)
|
|
|
|
{
|
2002-12-05 20:56:15 +01:00
|
|
|
FIXME("(%p)\n", EventHandle);
|
- implementation of RtlReg* (read access), RtlEvent*, RtlSemaphore*,
NtAllocateLocallyUniqueId
- implementation or stubs for NtAccessCheck, NtSetSecurityObject,
RtlClearBits, RtlEqualPrefixSid, RtlFindClearBits,
RtlFormatCurrentUserKeyPath, RtlGetControlSecurityDescriptor,
RtlIdentifierAuthoritySid, RtlImpersonateSelf, RtlInitializeBitMap,
RtlInitializeGenericTable, RtlMakeSelfRelativeSD,
RtlPrefixUnicodeString, RtlSetBits, RtlUnicodeToMultiByteN,
RtlUpcaseUnicodeStringToOemString, RtlUpcaseUnicodeToOemN,
RtlValidSid, RtlxUnicodeStringToOemSize
- corrected most RtlString* functions, added documentation
- more fixes and partial implementations
2000-01-23 23:35:33 +01:00
|
|
|
return STATUS_SUCCESS;
|
|
|
|
}
|
2003-03-31 03:37:04 +02:00
|
|
|
|
2004-12-02 19:05:37 +01:00
|
|
|
/*
|
|
|
|
* Mutants (known as Mutexes in Kernel32)
|
|
|
|
*/
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* NtCreateMutant [NTDLL.@]
|
|
|
|
* ZwCreateMutant [NTDLL.@]
|
|
|
|
*/
|
|
|
|
NTSTATUS WINAPI NtCreateMutant(OUT HANDLE* MutantHandle,
|
|
|
|
IN ACCESS_MASK access,
|
|
|
|
IN const OBJECT_ATTRIBUTES* attr OPTIONAL,
|
|
|
|
IN BOOLEAN InitialOwner)
|
|
|
|
{
|
|
|
|
NTSTATUS status;
|
|
|
|
DWORD len = attr && attr->ObjectName ? attr->ObjectName->Length : 0;
|
|
|
|
|
|
|
|
if (len >= MAX_PATH * sizeof(WCHAR)) return STATUS_NAME_TOO_LONG;
|
|
|
|
|
|
|
|
SERVER_START_REQ( create_mutex )
|
|
|
|
{
|
|
|
|
req->access = access;
|
|
|
|
req->owned = InitialOwner;
|
|
|
|
req->inherit = attr && (attr->Attributes & OBJ_INHERIT);
|
|
|
|
if (len) wine_server_add_data( req, attr->ObjectName->Buffer, len );
|
|
|
|
status = wine_server_call( req );
|
|
|
|
*MutantHandle = reply->handle;
|
|
|
|
}
|
|
|
|
SERVER_END_REQ;
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
* NtOpenMutant [NTDLL.@]
|
|
|
|
* ZwOpenMutant [NTDLL.@]
|
|
|
|
*/
|
|
|
|
NTSTATUS WINAPI NtOpenMutant(OUT HANDLE* MutantHandle,
|
|
|
|
IN ACCESS_MASK access,
|
|
|
|
IN const OBJECT_ATTRIBUTES* attr )
|
|
|
|
{
|
|
|
|
NTSTATUS status;
|
|
|
|
DWORD len = attr && attr->ObjectName ? attr->ObjectName->Length : 0;
|
|
|
|
|
|
|
|
if (len >= MAX_PATH * sizeof(WCHAR)) return STATUS_NAME_TOO_LONG;
|
|
|
|
|
|
|
|
SERVER_START_REQ( open_mutex )
|
|
|
|
{
|
|
|
|
req->access = access;
|
|
|
|
req->inherit = attr && (attr->Attributes & OBJ_INHERIT);
|
|
|
|
if (len) wine_server_add_data( req, attr->ObjectName->Buffer, len );
|
|
|
|
status = wine_server_call( req );
|
|
|
|
*MutantHandle = reply->handle;
|
|
|
|
}
|
|
|
|
SERVER_END_REQ;
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
* NtReleaseMutant [NTDLL.@]
|
|
|
|
* ZwReleaseMutant [NTDLL.@]
|
|
|
|
*/
|
|
|
|
NTSTATUS WINAPI NtReleaseMutant( IN HANDLE handle, OUT PLONG prev_count OPTIONAL)
|
|
|
|
{
|
|
|
|
NTSTATUS status;
|
|
|
|
|
|
|
|
SERVER_START_REQ( release_mutex )
|
|
|
|
{
|
|
|
|
req->handle = handle;
|
|
|
|
status = wine_server_call( req );
|
|
|
|
if (prev_count) *prev_count = reply->prev_count;
|
|
|
|
}
|
|
|
|
SERVER_END_REQ;
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************
|
|
|
|
* NtQueryMutant [NTDLL.@]
|
|
|
|
* ZwQueryMutant [NTDLL.@]
|
|
|
|
*/
|
|
|
|
NTSTATUS WINAPI NtQueryMutant(IN HANDLE handle,
|
|
|
|
IN MUTANT_INFORMATION_CLASS MutantInformationClass,
|
|
|
|
OUT PVOID MutantInformation,
|
|
|
|
IN ULONG MutantInformationLength,
|
|
|
|
OUT PULONG ResultLength OPTIONAL )
|
|
|
|
{
|
|
|
|
FIXME("(%p %u %p %lu %p): stub!\n",
|
|
|
|
handle, MutantInformationClass, MutantInformation, MutantInformationLength, ResultLength);
|
|
|
|
return STATUS_NOT_IMPLEMENTED;
|
|
|
|
}
|
2003-03-31 03:37:04 +02:00
|
|
|
|
2003-05-20 06:00:42 +02:00
|
|
|
/*
|
|
|
|
* Timers
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
* NtCreateTimer [NTDLL.@]
|
|
|
|
* ZwCreateTimer [NTDLL.@]
|
|
|
|
*/
|
|
|
|
NTSTATUS WINAPI NtCreateTimer(OUT HANDLE *handle,
|
|
|
|
IN ACCESS_MASK access,
|
2004-12-02 19:05:37 +01:00
|
|
|
IN const OBJECT_ATTRIBUTES *attr OPTIONAL,
|
2003-05-20 06:00:42 +02:00
|
|
|
IN TIMER_TYPE timer_type)
|
|
|
|
{
|
2004-12-02 19:05:37 +01:00
|
|
|
DWORD len = (attr && attr->ObjectName) ? attr->ObjectName->Length : 0;
|
2003-05-20 06:00:42 +02:00
|
|
|
NTSTATUS status;
|
|
|
|
|
2004-12-02 19:05:37 +01:00
|
|
|
if (len >= MAX_PATH * sizeof(WCHAR)) return STATUS_NAME_TOO_LONG;
|
|
|
|
|
2003-05-20 06:00:42 +02:00
|
|
|
if (timer_type != NotificationTimer && timer_type != SynchronizationTimer)
|
|
|
|
return STATUS_INVALID_PARAMETER;
|
|
|
|
|
|
|
|
SERVER_START_REQ( create_timer )
|
|
|
|
{
|
2004-12-02 19:05:37 +01:00
|
|
|
req->access = access;
|
2003-05-20 06:00:42 +02:00
|
|
|
req->manual = (timer_type == NotificationTimer) ? TRUE : FALSE;
|
2004-12-02 19:05:37 +01:00
|
|
|
req->inherit = attr && (attr->Attributes & OBJ_INHERIT);
|
|
|
|
if (len) wine_server_add_data( req, attr->ObjectName->Buffer, len );
|
2003-05-20 06:00:42 +02:00
|
|
|
status = wine_server_call( req );
|
|
|
|
*handle = reply->handle;
|
|
|
|
}
|
|
|
|
SERVER_END_REQ;
|
|
|
|
return status;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
* NtOpenTimer [NTDLL.@]
|
|
|
|
* ZwOpenTimer [NTDLL.@]
|
|
|
|
*/
|
|
|
|
NTSTATUS WINAPI NtOpenTimer(OUT PHANDLE handle,
|
|
|
|
IN ACCESS_MASK access,
|
2004-12-02 19:05:37 +01:00
|
|
|
IN const OBJECT_ATTRIBUTES* attr )
|
2003-05-20 06:00:42 +02:00
|
|
|
{
|
2004-12-02 19:05:37 +01:00
|
|
|
DWORD len = (attr && attr->ObjectName) ? attr->ObjectName->Length : 0;
|
|
|
|
NTSTATUS status;
|
2003-05-20 06:00:42 +02:00
|
|
|
|
2004-12-02 19:05:37 +01:00
|
|
|
if (len >= MAX_PATH * sizeof(WCHAR)) return STATUS_NAME_TOO_LONG;
|
2003-05-20 06:00:42 +02:00
|
|
|
|
|
|
|
SERVER_START_REQ( open_timer )
|
|
|
|
{
|
|
|
|
req->access = access;
|
2004-12-02 19:05:37 +01:00
|
|
|
req->inherit = attr && (attr->Attributes & OBJ_INHERIT);
|
|
|
|
if (len) wine_server_add_data( req, attr->ObjectName->Buffer, len );
|
2003-05-20 06:00:42 +02:00
|
|
|
status = wine_server_call( req );
|
|
|
|
*handle = reply->handle;
|
|
|
|
}
|
|
|
|
SERVER_END_REQ;
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
* NtSetTimer [NTDLL.@]
|
|
|
|
* ZwSetTimer [NTDLL.@]
|
|
|
|
*/
|
|
|
|
NTSTATUS WINAPI NtSetTimer(IN HANDLE handle,
|
|
|
|
IN const LARGE_INTEGER* when,
|
|
|
|
IN PTIMERAPCROUTINE callback,
|
|
|
|
IN PVOID callback_arg,
|
|
|
|
IN BOOLEAN resume,
|
|
|
|
IN ULONG period OPTIONAL,
|
|
|
|
OUT PBOOLEAN state OPTIONAL)
|
|
|
|
{
|
|
|
|
NTSTATUS status = STATUS_SUCCESS;
|
|
|
|
|
|
|
|
TRACE("(%p,%p,%p,%p,%08x,0x%08lx,%p) stub\n",
|
|
|
|
handle, when, callback, callback_arg, resume, period, state);
|
|
|
|
|
|
|
|
SERVER_START_REQ( set_timer )
|
|
|
|
{
|
2004-01-23 02:51:33 +01:00
|
|
|
if (!when->u.LowPart && !when->u.HighPart)
|
2003-05-20 06:00:42 +02:00
|
|
|
{
|
|
|
|
/* special case to start timeout on now+period without too many calculations */
|
|
|
|
req->expire.sec = 0;
|
|
|
|
req->expire.usec = 0;
|
|
|
|
}
|
|
|
|
else NTDLL_get_server_timeout( &req->expire, when );
|
|
|
|
|
|
|
|
req->handle = handle;
|
|
|
|
req->period = period;
|
|
|
|
req->callback = callback;
|
|
|
|
req->arg = callback_arg;
|
|
|
|
status = wine_server_call( req );
|
|
|
|
if (state) *state = reply->signaled;
|
|
|
|
}
|
|
|
|
SERVER_END_REQ;
|
|
|
|
|
|
|
|
/* set error but can still succeed */
|
|
|
|
if (resume && status == STATUS_SUCCESS) return STATUS_TIMER_RESUME_IGNORED;
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
* NtCancelTimer [NTDLL.@]
|
|
|
|
* ZwCancelTimer [NTDLL.@]
|
|
|
|
*/
|
|
|
|
NTSTATUS WINAPI NtCancelTimer(IN HANDLE handle, OUT BOOLEAN* state)
|
|
|
|
{
|
|
|
|
NTSTATUS status;
|
|
|
|
|
|
|
|
SERVER_START_REQ( cancel_timer )
|
|
|
|
{
|
|
|
|
req->handle = handle;
|
|
|
|
status = wine_server_call( req );
|
|
|
|
if (state) *state = reply->signaled;
|
|
|
|
}
|
|
|
|
SERVER_END_REQ;
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
2004-12-13 22:10:58 +01:00
|
|
|
/******************************************************************************
|
|
|
|
* NtQueryTimer (NTDLL.@)
|
|
|
|
*
|
|
|
|
* Retrieves information about a timer.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* TimerHandle [I] The timer to retrieve information about.
|
|
|
|
* TimerInformationClass [I] The type of information to retrieve.
|
|
|
|
* TimerInformation [O] Pointer to buffer to store information in.
|
|
|
|
* Length [I] The length of the buffer pointed to by TimerInformation.
|
|
|
|
* ReturnLength [O] Optional. The size of buffer actually used.
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: STATUS_SUCCESS
|
|
|
|
* Failure: STATUS_INFO_LENGTH_MISMATCH, if Length doesn't match the required data
|
|
|
|
* size for the class specified.
|
|
|
|
* STATUS_INVALID_INFO_CLASS, if an invalid TimerInformationClass was specified.
|
|
|
|
* STATUS_ACCESS_DENIED, if TimerHandle does not have TIMER_QUERY_STATE access
|
|
|
|
* to the timer.
|
|
|
|
*/
|
|
|
|
NTSTATUS WINAPI NtQueryTimer(
|
|
|
|
HANDLE TimerHandle,
|
|
|
|
TIMER_INFORMATION_CLASS TimerInformationClass,
|
|
|
|
PVOID TimerInformation,
|
|
|
|
ULONG Length,
|
|
|
|
PULONG ReturnLength)
|
|
|
|
{
|
|
|
|
TIMER_BASIC_INFORMATION * basic_info = (TIMER_BASIC_INFORMATION *)TimerInformation;
|
|
|
|
NTSTATUS status;
|
|
|
|
LARGE_INTEGER now;
|
|
|
|
|
|
|
|
TRACE("(%p,%d,%p,0x%08lx,%p)\n", TimerHandle, TimerInformationClass,
|
|
|
|
TimerInformation, Length, ReturnLength);
|
|
|
|
|
|
|
|
switch (TimerInformationClass)
|
|
|
|
{
|
|
|
|
case TimerBasicInformation:
|
|
|
|
if (Length < sizeof(TIMER_BASIC_INFORMATION))
|
|
|
|
return STATUS_INFO_LENGTH_MISMATCH;
|
|
|
|
|
|
|
|
SERVER_START_REQ(get_timer_info)
|
|
|
|
{
|
|
|
|
req->handle = TimerHandle;
|
|
|
|
status = wine_server_call(req);
|
|
|
|
|
|
|
|
/* convert server time to absolute NTDLL time */
|
|
|
|
NTDLL_from_server_timeout(&basic_info->RemainingTime, &reply->when);
|
|
|
|
basic_info->TimerState = reply->signaled;
|
|
|
|
}
|
|
|
|
SERVER_END_REQ;
|
|
|
|
|
|
|
|
/* convert from absolute into relative time */
|
|
|
|
NtQuerySystemTime(&now);
|
|
|
|
if (now.QuadPart > basic_info->RemainingTime.QuadPart)
|
|
|
|
basic_info->RemainingTime.QuadPart = 0;
|
|
|
|
else
|
|
|
|
basic_info->RemainingTime.QuadPart -= now.QuadPart;
|
|
|
|
|
|
|
|
if (ReturnLength) *ReturnLength = sizeof(TIMER_BASIC_INFORMATION);
|
|
|
|
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
|
|
|
FIXME("Unhandled class %d\n", TimerInformationClass);
|
|
|
|
return STATUS_INVALID_INFO_CLASS;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-05-20 06:00:42 +02:00
|
|
|
/******************************************************************************
|
|
|
|
* NtQueryTimerResolution [NTDLL.@]
|
|
|
|
*/
|
|
|
|
NTSTATUS WINAPI NtQueryTimerResolution(OUT ULONG* min_resolution,
|
|
|
|
OUT ULONG* max_resolution,
|
|
|
|
OUT ULONG* current_resolution)
|
|
|
|
{
|
|
|
|
FIXME("(%p,%p,%p), stub!\n",
|
|
|
|
min_resolution, max_resolution, current_resolution);
|
|
|
|
|
|
|
|
return STATUS_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* NtSetTimerResolution [NTDLL.@]
|
|
|
|
*/
|
|
|
|
NTSTATUS WINAPI NtSetTimerResolution(IN ULONG resolution,
|
|
|
|
IN BOOLEAN set_resolution,
|
|
|
|
OUT ULONG* current_resolution )
|
|
|
|
{
|
|
|
|
FIXME("(%lu,%u,%p), stub!\n",
|
|
|
|
resolution, set_resolution, current_resolution);
|
|
|
|
|
|
|
|
return STATUS_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-03-31 03:37:04 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* wait_reply
|
|
|
|
*
|
|
|
|
* Wait for a reply on the waiting pipe of the current thread.
|
|
|
|
*/
|
|
|
|
static int wait_reply( void *cookie )
|
|
|
|
{
|
|
|
|
int signaled;
|
|
|
|
struct wake_up_reply reply;
|
|
|
|
for (;;)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
ret = read( NtCurrentTeb()->wait_fd[0], &reply, sizeof(reply) );
|
|
|
|
if (ret == sizeof(reply))
|
|
|
|
{
|
|
|
|
if (!reply.cookie) break; /* thread got killed */
|
|
|
|
if (reply.cookie == cookie) return reply.signaled;
|
|
|
|
/* we stole another reply, wait for the real one */
|
|
|
|
signaled = wait_reply( cookie );
|
|
|
|
/* and now put the wrong one back in the pipe */
|
|
|
|
for (;;)
|
|
|
|
{
|
|
|
|
ret = write( NtCurrentTeb()->wait_fd[1], &reply, sizeof(reply) );
|
|
|
|
if (ret == sizeof(reply)) break;
|
|
|
|
if (ret >= 0) server_protocol_error( "partial wakeup write %d\n", ret );
|
|
|
|
if (errno == EINTR) continue;
|
|
|
|
server_protocol_perror("wakeup write");
|
|
|
|
}
|
|
|
|
return signaled;
|
|
|
|
}
|
|
|
|
if (ret >= 0) server_protocol_error( "partial wakeup read %d\n", ret );
|
|
|
|
if (errno == EINTR) continue;
|
|
|
|
server_protocol_perror("wakeup read");
|
|
|
|
}
|
|
|
|
/* the server closed the connection; time to die... */
|
2003-11-06 01:08:05 +01:00
|
|
|
server_abort_thread(0);
|
2003-03-31 03:37:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* call_apcs
|
|
|
|
*
|
|
|
|
* Call outstanding APCs.
|
|
|
|
*/
|
|
|
|
static void call_apcs( BOOL alertable )
|
|
|
|
{
|
2003-04-05 00:26:34 +02:00
|
|
|
FARPROC proc;
|
2003-03-31 03:37:04 +02:00
|
|
|
LARGE_INTEGER time;
|
2003-04-05 00:26:34 +02:00
|
|
|
void *arg1, *arg2, *arg3;
|
2003-03-31 03:37:04 +02:00
|
|
|
|
|
|
|
for (;;)
|
|
|
|
{
|
|
|
|
int type = APC_NONE;
|
|
|
|
SERVER_START_REQ( get_apc )
|
|
|
|
{
|
|
|
|
req->alertable = alertable;
|
2003-04-05 00:26:34 +02:00
|
|
|
if (!wine_server_call( req )) type = reply->type;
|
|
|
|
proc = reply->func;
|
|
|
|
arg1 = reply->arg1;
|
|
|
|
arg2 = reply->arg2;
|
|
|
|
arg3 = reply->arg3;
|
2003-03-31 03:37:04 +02:00
|
|
|
}
|
|
|
|
SERVER_END_REQ;
|
|
|
|
|
2005-01-14 20:54:38 +01:00
|
|
|
switch (type)
|
2003-03-31 03:37:04 +02:00
|
|
|
{
|
|
|
|
case APC_NONE:
|
|
|
|
return; /* no more APCs */
|
|
|
|
case APC_ASYNC:
|
2003-04-05 00:26:34 +02:00
|
|
|
proc( arg1, arg2 );
|
2003-03-31 03:37:04 +02:00
|
|
|
break;
|
|
|
|
case APC_USER:
|
2003-04-05 00:26:34 +02:00
|
|
|
proc( arg1, arg2, arg3 );
|
2003-03-31 03:37:04 +02:00
|
|
|
break;
|
|
|
|
case APC_TIMER:
|
|
|
|
/* convert sec/usec to NT time */
|
2003-04-05 00:26:34 +02:00
|
|
|
RtlSecondsSince1970ToTime( (time_t)arg1, &time );
|
|
|
|
time.QuadPart += (DWORD)arg2 * 10;
|
2004-01-23 02:51:33 +01:00
|
|
|
proc( arg3, time.u.LowPart, time.u.HighPart );
|
2003-03-31 03:37:04 +02:00
|
|
|
break;
|
|
|
|
case APC_ASYNC_IO:
|
2005-01-14 20:54:38 +01:00
|
|
|
NtCurrentTeb()->num_async_io--;
|
|
|
|
proc( arg1, (IO_STATUS_BLOCK*)arg2, (ULONG)arg3 );
|
2003-03-31 03:37:04 +02:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
server_protocol_error( "get_apc_request: bad type %d\n", type );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-06-30 23:00:15 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* NTDLL_wait_for_multiple_objects
|
|
|
|
*
|
|
|
|
* Implementation of NtWaitForMultipleObjects
|
2003-03-31 03:37:04 +02:00
|
|
|
*/
|
2003-06-30 23:00:15 +02:00
|
|
|
NTSTATUS NTDLL_wait_for_multiple_objects( UINT count, const HANDLE *handles, UINT flags,
|
|
|
|
const LARGE_INTEGER *timeout )
|
2003-03-31 03:37:04 +02:00
|
|
|
{
|
2003-06-30 23:00:15 +02:00
|
|
|
NTSTATUS ret;
|
|
|
|
int cookie;
|
2003-03-31 03:37:04 +02:00
|
|
|
|
2003-06-30 23:00:15 +02:00
|
|
|
if (timeout) flags |= SELECT_TIMEOUT;
|
2003-03-31 03:37:04 +02:00
|
|
|
for (;;)
|
|
|
|
{
|
|
|
|
SERVER_START_REQ( select )
|
|
|
|
{
|
2003-06-30 23:00:15 +02:00
|
|
|
req->flags = flags;
|
2003-03-31 03:37:04 +02:00
|
|
|
req->cookie = &cookie;
|
2003-04-03 00:48:59 +02:00
|
|
|
NTDLL_get_server_timeout( &req->timeout, timeout );
|
2003-03-31 03:37:04 +02:00
|
|
|
wine_server_add_data( req, handles, count * sizeof(HANDLE) );
|
|
|
|
ret = wine_server_call( req );
|
|
|
|
}
|
|
|
|
SERVER_END_REQ;
|
|
|
|
if (ret == STATUS_PENDING) ret = wait_reply( &cookie );
|
|
|
|
if (ret != STATUS_USER_APC) break;
|
2003-06-30 23:00:15 +02:00
|
|
|
call_apcs( (flags & SELECT_ALERTABLE) != 0 );
|
|
|
|
if (flags & SELECT_ALERTABLE) break;
|
2003-03-31 03:37:04 +02:00
|
|
|
}
|
2004-11-02 20:32:03 +01:00
|
|
|
|
|
|
|
/* A test on Windows 2000 shows that Windows always yields during
|
|
|
|
a wait, but a wait that is hit by an event gets a priority
|
|
|
|
boost as well. This seems to model that behavior the closest. */
|
|
|
|
if (ret == WAIT_TIMEOUT) NtYieldExecution();
|
|
|
|
|
2003-03-31 03:37:04 +02:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-06-30 23:00:15 +02:00
|
|
|
/* wait operations */
|
|
|
|
|
|
|
|
/******************************************************************
|
|
|
|
* NtWaitForMultipleObjects (NTDLL.@)
|
|
|
|
*/
|
|
|
|
NTSTATUS WINAPI NtWaitForMultipleObjects( DWORD count, const HANDLE *handles,
|
|
|
|
BOOLEAN wait_all, BOOLEAN alertable,
|
|
|
|
const LARGE_INTEGER *timeout )
|
|
|
|
{
|
|
|
|
UINT flags = SELECT_INTERRUPTIBLE;
|
|
|
|
|
|
|
|
if (!count || count > MAXIMUM_WAIT_OBJECTS) return STATUS_INVALID_PARAMETER_1;
|
|
|
|
|
|
|
|
if (wait_all) flags |= SELECT_ALL;
|
|
|
|
if (alertable) flags |= SELECT_ALERTABLE;
|
|
|
|
return NTDLL_wait_for_multiple_objects( count, handles, flags, timeout );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-03-31 03:37:04 +02:00
|
|
|
/******************************************************************
|
|
|
|
* NtWaitForSingleObject (NTDLL.@)
|
|
|
|
*/
|
2003-06-30 23:00:15 +02:00
|
|
|
NTSTATUS WINAPI NtWaitForSingleObject(HANDLE handle, BOOLEAN alertable, const LARGE_INTEGER *timeout )
|
2003-03-31 03:37:04 +02:00
|
|
|
{
|
|
|
|
return NtWaitForMultipleObjects( 1, &handle, FALSE, alertable, timeout );
|
|
|
|
}
|
2003-06-30 23:00:15 +02:00
|
|
|
|
|
|
|
|
2004-10-11 22:11:01 +02:00
|
|
|
/******************************************************************
|
|
|
|
* NtYieldExecution (NTDLL.@)
|
|
|
|
*/
|
|
|
|
NTSTATUS WINAPI NtYieldExecution(void)
|
|
|
|
{
|
|
|
|
#ifdef HAVE_SCHED_YIELD
|
|
|
|
sched_yield();
|
|
|
|
return STATUS_SUCCESS;
|
|
|
|
#else
|
|
|
|
return STATUS_NO_YIELD_PERFORMED;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-06-30 23:00:15 +02:00
|
|
|
/******************************************************************
|
|
|
|
* NtDelayExecution (NTDLL.@)
|
|
|
|
*/
|
|
|
|
NTSTATUS WINAPI NtDelayExecution( BOOLEAN alertable, const LARGE_INTEGER *timeout )
|
|
|
|
{
|
|
|
|
/* if alertable or async I/O in progress, we need to query the server */
|
2005-01-14 20:54:38 +01:00
|
|
|
if (alertable || NtCurrentTeb()->num_async_io)
|
2003-06-30 23:00:15 +02:00
|
|
|
{
|
|
|
|
UINT flags = SELECT_INTERRUPTIBLE;
|
|
|
|
if (alertable) flags |= SELECT_ALERTABLE;
|
|
|
|
return NTDLL_wait_for_multiple_objects( 0, NULL, flags, timeout );
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!timeout) /* sleep forever */
|
|
|
|
{
|
|
|
|
for (;;) select( 0, NULL, NULL, NULL, NULL );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
abs_time_t when;
|
|
|
|
|
|
|
|
NTDLL_get_server_timeout( &when, timeout );
|
2004-11-02 20:32:03 +01:00
|
|
|
|
|
|
|
/* Note that we yield after establishing the desired timeout */
|
|
|
|
NtYieldExecution();
|
|
|
|
|
2003-06-30 23:00:15 +02:00
|
|
|
for (;;)
|
|
|
|
{
|
|
|
|
struct timeval tv;
|
|
|
|
gettimeofday( &tv, 0 );
|
|
|
|
tv.tv_sec = when.sec - tv.tv_sec;
|
|
|
|
if ((tv.tv_usec = when.usec - tv.tv_usec) < 0)
|
|
|
|
{
|
|
|
|
tv.tv_usec += 1000000;
|
|
|
|
tv.tv_sec--;
|
|
|
|
}
|
2004-11-02 20:32:03 +01:00
|
|
|
/* if our yield already passed enough time, we're done */
|
|
|
|
if (tv.tv_sec < 0) break;
|
|
|
|
|
2003-06-30 23:00:15 +02:00
|
|
|
if (select( 0, NULL, NULL, NULL, &tv ) != -1) break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return STATUS_SUCCESS;
|
|
|
|
}
|