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
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
1999-03-09 18:47:51 +01:00
|
|
|
*/
|
|
|
|
|
2003-03-31 03:37:04 +02:00
|
|
|
#include "config.h"
|
2013-08-28 21:10:50 +02:00
|
|
|
#include "wine/port.h"
|
2003-03-31 03:37:04 +02:00
|
|
|
|
2019-02-06 03:21:07 +01:00
|
|
|
#include <limits.h>
|
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>
|
|
|
|
|
2005-11-28 17:32:54 +01:00
|
|
|
#include "ntstatus.h"
|
|
|
|
#define WIN32_NO_STATUS
|
2015-03-14 03:38:17 +01:00
|
|
|
#define NONAMELESSUNION
|
2003-09-06 01:08:26 +02:00
|
|
|
#include "windef.h"
|
2008-03-01 11:57:00 +01:00
|
|
|
#include "winternl.h"
|
2003-03-31 03:37:04 +02:00
|
|
|
#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
|
|
|
|
2019-06-10 17:07:53 +02:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(sync);
|
- 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
|
|
|
|
2007-10-25 20:09:54 +02:00
|
|
|
/* creates a struct security_descriptor and contained information in one contiguous piece of memory */
|
2016-01-15 09:40:56 +01:00
|
|
|
NTSTATUS alloc_object_attributes( const OBJECT_ATTRIBUTES *attr, struct object_attributes **ret,
|
|
|
|
data_size_t *ret_len )
|
2007-10-24 17:04:42 +02:00
|
|
|
{
|
2016-01-15 09:40:56 +01:00
|
|
|
unsigned int len = sizeof(**ret);
|
2017-09-12 14:33:37 +02:00
|
|
|
PSID owner = NULL, group = NULL;
|
2007-10-24 17:04:42 +02:00
|
|
|
ACL *dacl, *sacl;
|
2017-09-12 14:33:37 +02:00
|
|
|
BOOLEAN dacl_present, sacl_present, defaulted;
|
2016-01-15 09:40:56 +01:00
|
|
|
PSECURITY_DESCRIPTOR sd;
|
2007-10-24 17:04:42 +02:00
|
|
|
NTSTATUS status;
|
|
|
|
|
2016-01-15 09:40:56 +01:00
|
|
|
*ret = NULL;
|
|
|
|
*ret_len = 0;
|
|
|
|
|
2016-01-15 10:25:58 +01:00
|
|
|
if (!attr) return STATUS_SUCCESS;
|
2007-10-24 17:04:42 +02:00
|
|
|
|
2016-01-29 16:30:25 +01:00
|
|
|
if (attr->Length != sizeof(*attr)) return STATUS_INVALID_PARAMETER;
|
|
|
|
|
2016-01-15 09:40:56 +01:00
|
|
|
if ((sd = attr->SecurityDescriptor))
|
|
|
|
{
|
|
|
|
len += sizeof(struct security_descriptor);
|
|
|
|
|
2017-09-12 14:33:37 +02:00
|
|
|
if ((status = RtlGetOwnerSecurityDescriptor( sd, &owner, &defaulted ))) return status;
|
|
|
|
if ((status = RtlGetGroupSecurityDescriptor( sd, &group, &defaulted ))) return status;
|
2016-01-15 09:40:56 +01:00
|
|
|
if ((status = RtlGetSaclSecurityDescriptor( sd, &sacl_present, &sacl, &defaulted ))) return status;
|
|
|
|
if ((status = RtlGetDaclSecurityDescriptor( sd, &dacl_present, &dacl, &defaulted ))) return status;
|
2017-09-12 14:33:37 +02:00
|
|
|
if (owner) len += RtlLengthSid( owner );
|
|
|
|
if (group) len += RtlLengthSid( group );
|
2016-01-15 09:40:56 +01:00
|
|
|
if (sacl_present && sacl) len += sacl->AclSize;
|
|
|
|
if (dacl_present && dacl) len += dacl->AclSize;
|
|
|
|
|
|
|
|
/* fix alignment for the Unicode name that follows the structure */
|
|
|
|
len = (len + sizeof(WCHAR) - 1) & ~(sizeof(WCHAR) - 1);
|
|
|
|
}
|
2007-10-24 17:04:42 +02:00
|
|
|
|
2016-01-15 09:40:56 +01:00
|
|
|
if (attr->ObjectName)
|
|
|
|
{
|
2016-01-19 07:52:35 +01:00
|
|
|
if (attr->ObjectName->Length & (sizeof(WCHAR) - 1)) return STATUS_OBJECT_NAME_INVALID;
|
|
|
|
len += attr->ObjectName->Length;
|
2016-01-15 09:40:56 +01:00
|
|
|
}
|
2016-01-28 13:24:12 +01:00
|
|
|
else if (attr->RootDirectory) return STATUS_OBJECT_NAME_INVALID;
|
2007-10-24 17:04:42 +02:00
|
|
|
|
2018-09-20 12:59:32 +02:00
|
|
|
len = (len + 3) & ~3; /* DWORD-align the entire structure */
|
|
|
|
|
2016-01-15 09:40:56 +01:00
|
|
|
*ret = RtlAllocateHeap( GetProcessHeap(), HEAP_ZERO_MEMORY, len );
|
|
|
|
if (!*ret) return STATUS_NO_MEMORY;
|
|
|
|
|
|
|
|
(*ret)->rootdir = wine_server_obj_handle( attr->RootDirectory );
|
2016-01-15 09:53:34 +01:00
|
|
|
(*ret)->attributes = attr->Attributes;
|
2016-01-15 09:40:56 +01:00
|
|
|
|
|
|
|
if (attr->SecurityDescriptor)
|
|
|
|
{
|
|
|
|
struct security_descriptor *descr = (struct security_descriptor *)(*ret + 1);
|
|
|
|
unsigned char *ptr = (unsigned char *)(descr + 1);
|
|
|
|
|
|
|
|
descr->control = ((SECURITY_DESCRIPTOR *)sd)->Control & ~SE_SELF_RELATIVE;
|
2017-09-12 14:33:37 +02:00
|
|
|
if (owner) descr->owner_len = RtlLengthSid( owner );
|
|
|
|
if (group) descr->group_len = RtlLengthSid( group );
|
2016-01-15 09:40:56 +01:00
|
|
|
if (sacl_present && sacl) descr->sacl_len = sacl->AclSize;
|
|
|
|
if (dacl_present && dacl) descr->dacl_len = dacl->AclSize;
|
|
|
|
|
|
|
|
memcpy( ptr, owner, descr->owner_len );
|
|
|
|
ptr += descr->owner_len;
|
|
|
|
memcpy( ptr, group, descr->group_len );
|
|
|
|
ptr += descr->group_len;
|
|
|
|
memcpy( ptr, sacl, descr->sacl_len );
|
|
|
|
ptr += descr->sacl_len;
|
|
|
|
memcpy( ptr, dacl, descr->dacl_len );
|
|
|
|
(*ret)->sd_len = (sizeof(*descr) + descr->owner_len + descr->group_len + descr->sacl_len +
|
|
|
|
descr->dacl_len + sizeof(WCHAR) - 1) & ~(sizeof(WCHAR) - 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (attr->ObjectName)
|
|
|
|
{
|
|
|
|
unsigned char *ptr = (unsigned char *)(*ret + 1) + (*ret)->sd_len;
|
2016-01-19 07:52:35 +01:00
|
|
|
(*ret)->name_len = attr->ObjectName->Length;
|
2016-01-15 09:40:56 +01:00
|
|
|
memcpy( ptr, attr->ObjectName->Buffer, (*ret)->name_len );
|
|
|
|
}
|
|
|
|
|
|
|
|
*ret_len = len;
|
|
|
|
return STATUS_SUCCESS;
|
2007-10-24 17:04:42 +02:00
|
|
|
}
|
|
|
|
|
2016-01-29 06:57:04 +01:00
|
|
|
NTSTATUS validate_open_object_attributes( const OBJECT_ATTRIBUTES *attr )
|
|
|
|
{
|
2016-01-29 16:30:25 +01:00
|
|
|
if (!attr || attr->Length != sizeof(*attr)) return STATUS_INVALID_PARAMETER;
|
2016-01-29 06:57:04 +01:00
|
|
|
|
|
|
|
if (attr->ObjectName)
|
|
|
|
{
|
|
|
|
if (attr->ObjectName->Length & (sizeof(WCHAR) - 1)) return STATUS_OBJECT_NAME_INVALID;
|
|
|
|
}
|
|
|
|
else if (attr->RootDirectory) return STATUS_OBJECT_NAME_INVALID;
|
|
|
|
|
|
|
|
return STATUS_SUCCESS;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
*/
|
2020-06-04 20:19:37 +02:00
|
|
|
NTSTATUS WINAPI NtCreateSemaphore( HANDLE *handle, ACCESS_MASK access, const OBJECT_ATTRIBUTES *attr,
|
|
|
|
LONG initial, LONG max )
|
1999-03-09 18:47:51 +01:00
|
|
|
{
|
2020-06-04 20:19:37 +02:00
|
|
|
return unix_funcs->NtCreateSemaphore( handle, access, attr, initial, max );
|
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
|
|
|
*/
|
2016-01-29 06:57:04 +01:00
|
|
|
NTSTATUS WINAPI NtOpenSemaphore( HANDLE *handle, ACCESS_MASK access, const OBJECT_ATTRIBUTES *attr )
|
1999-03-09 18:47:51 +01:00
|
|
|
{
|
2020-06-04 20:19:37 +02:00
|
|
|
return unix_funcs->NtOpenSemaphore( handle, access, attr );
|
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
|
|
|
*/
|
2013-12-25 05:28:36 +01:00
|
|
|
NTSTATUS WINAPI NtQuerySemaphore( HANDLE handle, SEMAPHORE_INFORMATION_CLASS class,
|
|
|
|
void *info, ULONG len, ULONG *ret_len )
|
1999-03-09 18:47:51 +01:00
|
|
|
{
|
2020-06-04 20:19:37 +02:00
|
|
|
return unix_funcs->NtQuerySemaphore( handle, class, info, len, ret_len );
|
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
|
|
|
{
|
2020-06-04 20:19:37 +02:00
|
|
|
return unix_funcs->NtReleaseSemaphore( handle, count, previous );
|
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
|
|
|
*/
|
2020-06-04 20:34:58 +02:00
|
|
|
NTSTATUS WINAPI NtCreateEvent( HANDLE *handle, ACCESS_MASK access, const OBJECT_ATTRIBUTES *attr,
|
|
|
|
EVENT_TYPE type, BOOLEAN state )
|
1999-03-09 18:47:51 +01:00
|
|
|
{
|
2020-06-04 20:34:58 +02:00
|
|
|
return unix_funcs->NtCreateEvent( handle, access, attr, type, state );
|
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
|
|
|
*/
|
2016-01-29 06:57:04 +01:00
|
|
|
NTSTATUS WINAPI NtOpenEvent( HANDLE *handle, ACCESS_MASK access, const OBJECT_ATTRIBUTES *attr )
|
1999-03-09 18:47:51 +01:00
|
|
|
{
|
2020-06-04 20:34:58 +02:00
|
|
|
return unix_funcs->NtOpenEvent( handle, access, attr );
|
- 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
|
|
|
*/
|
2019-03-11 18:06:32 +01:00
|
|
|
NTSTATUS WINAPI NtSetEvent( HANDLE handle, LONG *prev_state )
|
1999-03-09 18:47:51 +01:00
|
|
|
{
|
2020-06-04 20:34:58 +02:00
|
|
|
return unix_funcs->NtSetEvent( handle, prev_state );
|
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
|
|
|
*/
|
2019-03-11 18:06:32 +01:00
|
|
|
NTSTATUS WINAPI NtResetEvent( HANDLE handle, LONG *prev_state )
|
- 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
|
|
|
{
|
2020-06-04 20:34:58 +02:00
|
|
|
return unix_funcs->NtResetEvent( handle, prev_state );
|
- 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
|
|
|
{
|
2020-06-04 20:34:58 +02:00
|
|
|
return unix_funcs->NtClearEvent( 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
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
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
|
|
|
|
*/
|
2019-03-11 18:06:32 +01:00
|
|
|
NTSTATUS WINAPI NtPulseEvent( HANDLE handle, LONG *prev_state )
|
- 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
|
|
|
{
|
2020-06-04 20:34:58 +02:00
|
|
|
return unix_funcs->NtPulseEvent( handle, prev_state );
|
- 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
|
|
|
*/
|
2013-08-26 11:52:51 +02:00
|
|
|
NTSTATUS WINAPI NtQueryEvent( HANDLE handle, EVENT_INFORMATION_CLASS class,
|
|
|
|
void *info, ULONG len, ULONG *ret_len )
|
- 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
|
|
|
{
|
2020-06-04 20:34:58 +02:00
|
|
|
return unix_funcs->NtQueryEvent( handle, class, info, len, ret_len );
|
- 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
|
|
|
}
|
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.@]
|
|
|
|
*/
|
2020-06-04 21:10:17 +02:00
|
|
|
NTSTATUS WINAPI NtCreateMutant( HANDLE *handle, ACCESS_MASK access, const OBJECT_ATTRIBUTES *attr,
|
|
|
|
BOOLEAN owned )
|
2004-12-02 19:05:37 +01:00
|
|
|
{
|
2020-06-04 21:10:17 +02:00
|
|
|
return unix_funcs->NtCreateMutant( handle, access, attr, owned );
|
2004-12-02 19:05:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
* NtOpenMutant [NTDLL.@]
|
|
|
|
* ZwOpenMutant [NTDLL.@]
|
|
|
|
*/
|
2016-01-29 06:57:04 +01:00
|
|
|
NTSTATUS WINAPI NtOpenMutant( HANDLE *handle, ACCESS_MASK access, const OBJECT_ATTRIBUTES *attr )
|
2004-12-02 19:05:37 +01:00
|
|
|
{
|
2020-06-04 21:10:17 +02:00
|
|
|
return unix_funcs->NtOpenMutant( handle, access, attr );
|
2004-12-02 19:05:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
* NtReleaseMutant [NTDLL.@]
|
|
|
|
* ZwReleaseMutant [NTDLL.@]
|
|
|
|
*/
|
2020-06-04 21:10:17 +02:00
|
|
|
NTSTATUS WINAPI NtReleaseMutant( HANDLE handle, LONG *prev_count )
|
2004-12-02 19:05:37 +01:00
|
|
|
{
|
2020-06-04 21:10:17 +02:00
|
|
|
return unix_funcs->NtReleaseMutant( handle, prev_count );
|
2004-12-02 19:05:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************
|
|
|
|
* NtQueryMutant [NTDLL.@]
|
|
|
|
* ZwQueryMutant [NTDLL.@]
|
|
|
|
*/
|
2016-05-03 02:55:34 +02:00
|
|
|
NTSTATUS WINAPI NtQueryMutant( HANDLE handle, MUTANT_INFORMATION_CLASS class,
|
|
|
|
void *info, ULONG len, ULONG *ret_len )
|
2004-12-02 19:05:37 +01:00
|
|
|
{
|
2020-06-04 21:10:17 +02:00
|
|
|
return unix_funcs->NtQueryMutant( handle, class, info, len, ret_len );
|
2004-12-02 19:05:37 +01:00
|
|
|
}
|
2003-03-31 03:37:04 +02:00
|
|
|
|
2008-09-04 22:47:13 +02:00
|
|
|
/*
|
|
|
|
* Jobs
|
|
|
|
*/
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* NtCreateJobObject [NTDLL.@]
|
|
|
|
* ZwCreateJobObject [NTDLL.@]
|
|
|
|
*/
|
|
|
|
NTSTATUS WINAPI NtCreateJobObject( PHANDLE handle, ACCESS_MASK access, const OBJECT_ATTRIBUTES *attr )
|
|
|
|
{
|
2020-06-13 13:21:26 +02:00
|
|
|
return unix_funcs->NtCreateJobObject( handle, access, attr );
|
2008-09-04 22:47:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* NtOpenJobObject [NTDLL.@]
|
|
|
|
* ZwOpenJobObject [NTDLL.@]
|
|
|
|
*/
|
2016-01-29 06:57:04 +01:00
|
|
|
NTSTATUS WINAPI NtOpenJobObject( HANDLE *handle, ACCESS_MASK access, const OBJECT_ATTRIBUTES *attr )
|
2008-09-04 22:47:13 +02:00
|
|
|
{
|
2020-06-13 13:21:26 +02:00
|
|
|
return unix_funcs->NtOpenJobObject( handle, access, attr );
|
2008-09-04 22:47:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* NtTerminateJobObject [NTDLL.@]
|
|
|
|
* ZwTerminateJobObject [NTDLL.@]
|
|
|
|
*/
|
|
|
|
NTSTATUS WINAPI NtTerminateJobObject( HANDLE handle, NTSTATUS status )
|
|
|
|
{
|
2020-06-13 13:21:26 +02:00
|
|
|
return unix_funcs->NtTerminateJobObject( handle, status );
|
2008-09-04 22:47:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* NtQueryInformationJobObject [NTDLL.@]
|
|
|
|
* ZwQueryInformationJobObject [NTDLL.@]
|
|
|
|
*/
|
|
|
|
NTSTATUS WINAPI NtQueryInformationJobObject( HANDLE handle, JOBOBJECTINFOCLASS class, PVOID info,
|
|
|
|
ULONG len, PULONG ret_len )
|
|
|
|
{
|
2020-06-13 13:21:26 +02:00
|
|
|
return unix_funcs->NtQueryInformationJobObject( handle, class, info, len, ret_len );
|
2008-09-04 22:47:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* NtSetInformationJobObject [NTDLL.@]
|
|
|
|
* ZwSetInformationJobObject [NTDLL.@]
|
|
|
|
*/
|
|
|
|
NTSTATUS WINAPI NtSetInformationJobObject( HANDLE handle, JOBOBJECTINFOCLASS class, PVOID info, ULONG len )
|
|
|
|
{
|
2020-06-13 13:21:26 +02:00
|
|
|
return unix_funcs->NtSetInformationJobObject( handle, class, info, len );
|
2008-09-04 22:47:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* NtIsProcessInJob [NTDLL.@]
|
|
|
|
* ZwIsProcessInJob [NTDLL.@]
|
|
|
|
*/
|
|
|
|
NTSTATUS WINAPI NtIsProcessInJob( HANDLE process, HANDLE job )
|
|
|
|
{
|
2020-06-13 13:21:26 +02:00
|
|
|
return unix_funcs->NtIsProcessInJob( process, job );
|
2008-09-04 22:47:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* NtAssignProcessToJobObject [NTDLL.@]
|
|
|
|
* ZwAssignProcessToJobObject [NTDLL.@]
|
|
|
|
*/
|
|
|
|
NTSTATUS WINAPI NtAssignProcessToJobObject( HANDLE job, HANDLE process )
|
|
|
|
{
|
2020-06-13 13:21:26 +02:00
|
|
|
return unix_funcs->NtAssignProcessToJobObject( job, process );
|
2008-09-04 22:47:13 +02:00
|
|
|
}
|
|
|
|
|
2003-05-20 06:00:42 +02:00
|
|
|
/*
|
|
|
|
* Timers
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
* NtCreateTimer [NTDLL.@]
|
|
|
|
* ZwCreateTimer [NTDLL.@]
|
|
|
|
*/
|
2020-06-04 21:21:33 +02:00
|
|
|
NTSTATUS WINAPI NtCreateTimer( HANDLE *handle, ACCESS_MASK access, const OBJECT_ATTRIBUTES *attr,
|
|
|
|
TIMER_TYPE type )
|
2003-05-20 06:00:42 +02:00
|
|
|
{
|
2020-06-04 21:21:33 +02:00
|
|
|
return unix_funcs->NtCreateTimer( handle, access, attr, type );
|
2003-05-20 06:00:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
* NtOpenTimer [NTDLL.@]
|
|
|
|
* ZwOpenTimer [NTDLL.@]
|
|
|
|
*/
|
2016-01-29 06:57:04 +01:00
|
|
|
NTSTATUS WINAPI NtOpenTimer( HANDLE *handle, ACCESS_MASK access, const OBJECT_ATTRIBUTES *attr )
|
2003-05-20 06:00:42 +02:00
|
|
|
{
|
2020-06-04 21:21:33 +02:00
|
|
|
return unix_funcs->NtOpenTimer( handle, access, attr );
|
2003-05-20 06:00:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
* NtSetTimer [NTDLL.@]
|
|
|
|
* ZwSetTimer [NTDLL.@]
|
|
|
|
*/
|
2020-06-04 21:21:33 +02:00
|
|
|
NTSTATUS WINAPI NtSetTimer( HANDLE handle, const LARGE_INTEGER *when, PTIMER_APC_ROUTINE callback,
|
|
|
|
void *arg, BOOLEAN resume, ULONG period, BOOLEAN *state )
|
2003-05-20 06:00:42 +02:00
|
|
|
{
|
2020-06-04 21:21:33 +02:00
|
|
|
return unix_funcs->NtSetTimer( handle, when, callback, arg, resume, period, state );
|
2003-05-20 06:00:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
* NtCancelTimer [NTDLL.@]
|
|
|
|
* ZwCancelTimer [NTDLL.@]
|
|
|
|
*/
|
2020-06-04 21:21:33 +02:00
|
|
|
NTSTATUS WINAPI NtCancelTimer( HANDLE handle, BOOLEAN *state )
|
2003-05-20 06:00:42 +02:00
|
|
|
{
|
2020-06-04 21:21:33 +02:00
|
|
|
return unix_funcs->NtCancelTimer( handle, state );
|
2003-05-20 06:00:42 +02:00
|
|
|
}
|
|
|
|
|
2004-12-13 22:10:58 +01:00
|
|
|
/******************************************************************************
|
|
|
|
* NtQueryTimer (NTDLL.@)
|
2020-06-04 21:21:33 +02:00
|
|
|
*/
|
|
|
|
NTSTATUS WINAPI NtQueryTimer( HANDLE handle, TIMER_INFORMATION_CLASS class,
|
|
|
|
void *info, ULONG len, ULONG *ret_len )
|
|
|
|
{
|
|
|
|
return unix_funcs->NtQueryTimer( handle, class, info, len, ret_len );
|
2004-12-13 22:10:58 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
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 )
|
|
|
|
{
|
2006-10-16 13:49:06 +02:00
|
|
|
FIXME("(%u,%u,%p), stub!\n",
|
2003-05-20 06:00:42 +02:00
|
|
|
resolution, set_resolution, current_resolution);
|
|
|
|
|
|
|
|
return STATUS_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-03-31 03:37:04 +02:00
|
|
|
|
2003-06-30 23:00:15 +02:00
|
|
|
/* wait operations */
|
|
|
|
|
2015-08-24 08:17:54 +02:00
|
|
|
/******************************************************************
|
|
|
|
* NtWaitForMultipleObjects (NTDLL.@)
|
|
|
|
*/
|
|
|
|
NTSTATUS WINAPI NtWaitForMultipleObjects( DWORD count, const HANDLE *handles,
|
|
|
|
BOOLEAN wait_any, BOOLEAN alertable,
|
|
|
|
const LARGE_INTEGER *timeout )
|
|
|
|
{
|
2020-06-04 20:06:53 +02:00
|
|
|
return unix_funcs->NtWaitForMultipleObjects( count, handles, wait_any, alertable, timeout );
|
2015-08-24 08:17:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
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
|
|
|
{
|
2020-06-04 20:06:53 +02:00
|
|
|
return unix_funcs->NtWaitForSingleObject( handle, alertable, timeout );
|
2003-03-31 03:37:04 +02:00
|
|
|
}
|
2003-06-30 23:00:15 +02:00
|
|
|
|
|
|
|
|
2005-04-24 19:35:52 +02:00
|
|
|
/******************************************************************
|
|
|
|
* NtSignalAndWaitForSingleObject (NTDLL.@)
|
|
|
|
*/
|
2020-06-04 20:06:53 +02:00
|
|
|
NTSTATUS WINAPI NtSignalAndWaitForSingleObject( HANDLE signal, HANDLE wait,
|
2005-04-24 19:35:52 +02:00
|
|
|
BOOLEAN alertable, const LARGE_INTEGER *timeout )
|
|
|
|
{
|
2020-06-04 20:06:53 +02:00
|
|
|
return unix_funcs->NtSignalAndWaitForSingleObject( signal, wait, alertable, timeout );
|
2005-04-24 19:35:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-10-11 22:11:01 +02:00
|
|
|
/******************************************************************
|
|
|
|
* NtYieldExecution (NTDLL.@)
|
|
|
|
*/
|
|
|
|
NTSTATUS WINAPI NtYieldExecution(void)
|
|
|
|
{
|
2020-06-04 20:06:53 +02:00
|
|
|
return unix_funcs->NtYieldExecution();
|
2004-10-11 22:11:01 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-06-30 23:00:15 +02:00
|
|
|
/******************************************************************
|
|
|
|
* NtDelayExecution (NTDLL.@)
|
|
|
|
*/
|
|
|
|
NTSTATUS WINAPI NtDelayExecution( BOOLEAN alertable, const LARGE_INTEGER *timeout )
|
|
|
|
{
|
2020-06-04 20:06:53 +02:00
|
|
|
return unix_funcs->NtDelayExecution( alertable, timeout );
|
2003-06-30 23:00:15 +02:00
|
|
|
}
|
2006-04-19 10:26:11 +02:00
|
|
|
|
2013-08-21 12:51:31 +02:00
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* NtCreateKeyedEvent (NTDLL.@)
|
|
|
|
*/
|
|
|
|
NTSTATUS WINAPI NtCreateKeyedEvent( HANDLE *handle, ACCESS_MASK access,
|
|
|
|
const OBJECT_ATTRIBUTES *attr, ULONG flags )
|
|
|
|
{
|
2020-06-04 21:27:22 +02:00
|
|
|
return unix_funcs->NtCreateKeyedEvent( handle, access, attr, flags );
|
2013-08-21 12:51:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* NtOpenKeyedEvent (NTDLL.@)
|
|
|
|
*/
|
|
|
|
NTSTATUS WINAPI NtOpenKeyedEvent( HANDLE *handle, ACCESS_MASK access, const OBJECT_ATTRIBUTES *attr )
|
|
|
|
{
|
2020-06-04 21:27:22 +02:00
|
|
|
return unix_funcs->NtOpenKeyedEvent( handle, access, attr );
|
2013-08-21 12:51:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* NtWaitForKeyedEvent (NTDLL.@)
|
|
|
|
*/
|
|
|
|
NTSTATUS WINAPI NtWaitForKeyedEvent( HANDLE handle, const void *key,
|
|
|
|
BOOLEAN alertable, const LARGE_INTEGER *timeout )
|
|
|
|
{
|
2020-06-04 21:27:22 +02:00
|
|
|
return unix_funcs->NtWaitForKeyedEvent( handle, key, alertable, timeout );
|
2013-08-21 12:51:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* NtReleaseKeyedEvent (NTDLL.@)
|
|
|
|
*/
|
|
|
|
NTSTATUS WINAPI NtReleaseKeyedEvent( HANDLE handle, const void *key,
|
|
|
|
BOOLEAN alertable, const LARGE_INTEGER *timeout )
|
|
|
|
{
|
2020-06-04 21:27:22 +02:00
|
|
|
return unix_funcs->NtReleaseKeyedEvent( handle, key, alertable, timeout );
|
2013-08-21 12:51:31 +02:00
|
|
|
}
|
|
|
|
|
2006-05-12 00:34:55 +02:00
|
|
|
/******************************************************************
|
2007-06-02 00:30:14 +02:00
|
|
|
* NtCreateIoCompletion (NTDLL.@)
|
|
|
|
* ZwCreateIoCompletion (NTDLL.@)
|
2006-05-12 00:34:55 +02:00
|
|
|
*/
|
2020-06-13 11:56:30 +02:00
|
|
|
NTSTATUS WINAPI NtCreateIoCompletion( HANDLE *handle, ACCESS_MASK access, OBJECT_ATTRIBUTES *attr,
|
|
|
|
ULONG threads )
|
2006-04-19 10:26:11 +02:00
|
|
|
{
|
2020-06-13 11:56:30 +02:00
|
|
|
return unix_funcs->NtCreateIoCompletion( handle, access, attr, threads );
|
2006-04-19 10:26:11 +02:00
|
|
|
}
|
|
|
|
|
2007-06-02 00:30:14 +02:00
|
|
|
/******************************************************************
|
|
|
|
* NtSetIoCompletion (NTDLL.@)
|
|
|
|
* ZwSetIoCompletion (NTDLL.@)
|
|
|
|
*/
|
2020-06-13 11:56:30 +02:00
|
|
|
NTSTATUS WINAPI NtSetIoCompletion( HANDLE handle, ULONG_PTR key, ULONG_PTR value,
|
|
|
|
NTSTATUS status, SIZE_T count )
|
2006-04-19 10:26:11 +02:00
|
|
|
{
|
2020-06-13 11:56:30 +02:00
|
|
|
return unix_funcs->NtSetIoCompletion( handle, key, value, status, count );
|
2006-04-19 10:26:11 +02:00
|
|
|
}
|
|
|
|
|
2007-06-02 00:30:14 +02:00
|
|
|
/******************************************************************
|
|
|
|
* NtRemoveIoCompletion (NTDLL.@)
|
|
|
|
* ZwRemoveIoCompletion (NTDLL.@)
|
|
|
|
*/
|
2020-06-13 11:56:30 +02:00
|
|
|
NTSTATUS WINAPI NtRemoveIoCompletion( HANDLE handle, ULONG_PTR *key, ULONG_PTR *value,
|
|
|
|
IO_STATUS_BLOCK *io, LARGE_INTEGER *timeout )
|
2006-04-19 10:26:11 +02:00
|
|
|
{
|
2020-06-13 11:56:30 +02:00
|
|
|
return unix_funcs->NtRemoveIoCompletion( handle, key, value, io, timeout );
|
2007-06-02 00:30:14 +02:00
|
|
|
}
|
|
|
|
|
2018-09-30 23:59:47 +02:00
|
|
|
/******************************************************************
|
|
|
|
* NtRemoveIoCompletionEx (NTDLL.@)
|
|
|
|
* ZwRemoveIoCompletionEx (NTDLL.@)
|
|
|
|
*/
|
|
|
|
NTSTATUS WINAPI NtRemoveIoCompletionEx( HANDLE port, FILE_IO_COMPLETION_INFORMATION *info, ULONG count,
|
|
|
|
ULONG *written, LARGE_INTEGER *timeout, BOOLEAN alertable )
|
|
|
|
{
|
2020-06-13 11:56:30 +02:00
|
|
|
return unix_funcs->NtRemoveIoCompletionEx( port, info, count, written, timeout, alertable );
|
2018-09-30 23:59:47 +02:00
|
|
|
}
|
|
|
|
|
2007-06-02 00:30:14 +02:00
|
|
|
/******************************************************************
|
|
|
|
* NtOpenIoCompletion (NTDLL.@)
|
|
|
|
* ZwOpenIoCompletion (NTDLL.@)
|
|
|
|
*/
|
2016-01-29 06:57:04 +01:00
|
|
|
NTSTATUS WINAPI NtOpenIoCompletion( HANDLE *handle, ACCESS_MASK access, const OBJECT_ATTRIBUTES *attr )
|
2007-06-02 00:30:14 +02:00
|
|
|
{
|
2020-06-13 11:56:30 +02:00
|
|
|
return unix_funcs->NtOpenIoCompletion( handle, access, attr );
|
2007-06-02 00:30:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************
|
|
|
|
* NtQueryIoCompletion (NTDLL.@)
|
|
|
|
* ZwQueryIoCompletion (NTDLL.@)
|
|
|
|
*/
|
2020-06-13 11:56:30 +02:00
|
|
|
NTSTATUS WINAPI NtQueryIoCompletion( HANDLE handle, IO_COMPLETION_INFORMATION_CLASS class,
|
|
|
|
void *buffer, ULONG len, ULONG *ret_len )
|
2007-06-02 00:30:14 +02:00
|
|
|
{
|
2020-06-13 11:56:30 +02:00
|
|
|
return unix_funcs->NtQueryIoCompletion( handle, class, buffer, len, ret_len );
|
2006-04-19 10:26:11 +02:00
|
|
|
}
|
2007-11-09 23:12:07 +01:00
|
|
|
|
2013-08-28 21:10:50 +02:00
|
|
|
/******************************************************************
|
|
|
|
* RtlRunOnceInitialize (NTDLL.@)
|
|
|
|
*/
|
|
|
|
void WINAPI RtlRunOnceInitialize( RTL_RUN_ONCE *once )
|
|
|
|
{
|
|
|
|
once->Ptr = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************
|
|
|
|
* RtlRunOnceBeginInitialize (NTDLL.@)
|
|
|
|
*/
|
|
|
|
DWORD WINAPI RtlRunOnceBeginInitialize( RTL_RUN_ONCE *once, ULONG flags, void **context )
|
|
|
|
{
|
|
|
|
if (flags & RTL_RUN_ONCE_CHECK_ONLY)
|
|
|
|
{
|
|
|
|
ULONG_PTR val = (ULONG_PTR)once->Ptr;
|
|
|
|
|
|
|
|
if (flags & RTL_RUN_ONCE_ASYNC) return STATUS_INVALID_PARAMETER;
|
|
|
|
if ((val & 3) != 2) return STATUS_UNSUCCESSFUL;
|
|
|
|
if (context) *context = (void *)(val & ~3);
|
|
|
|
return STATUS_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (;;)
|
|
|
|
{
|
|
|
|
ULONG_PTR next, val = (ULONG_PTR)once->Ptr;
|
|
|
|
|
|
|
|
switch (val & 3)
|
|
|
|
{
|
|
|
|
case 0: /* first time */
|
2020-05-02 15:10:04 +02:00
|
|
|
if (!InterlockedCompareExchangePointer( &once->Ptr,
|
|
|
|
(flags & RTL_RUN_ONCE_ASYNC) ? (void *)3 : (void *)1, 0 ))
|
2013-08-28 21:10:50 +02:00
|
|
|
return STATUS_PENDING;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 1: /* in progress, wait */
|
|
|
|
if (flags & RTL_RUN_ONCE_ASYNC) return STATUS_INVALID_PARAMETER;
|
|
|
|
next = val & ~3;
|
2020-05-02 15:10:04 +02:00
|
|
|
if (InterlockedCompareExchangePointer( &once->Ptr, (void *)((ULONG_PTR)&next | 1),
|
|
|
|
(void *)val ) == (void *)val)
|
2018-10-26 11:27:11 +02:00
|
|
|
NtWaitForKeyedEvent( 0, &next, FALSE, NULL );
|
2013-08-28 21:10:50 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 2: /* done */
|
|
|
|
if (context) *context = (void *)(val & ~3);
|
|
|
|
return STATUS_SUCCESS;
|
|
|
|
|
|
|
|
case 3: /* in progress, async */
|
|
|
|
if (!(flags & RTL_RUN_ONCE_ASYNC)) return STATUS_INVALID_PARAMETER;
|
|
|
|
return STATUS_PENDING;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************
|
|
|
|
* RtlRunOnceComplete (NTDLL.@)
|
|
|
|
*/
|
|
|
|
DWORD WINAPI RtlRunOnceComplete( RTL_RUN_ONCE *once, ULONG flags, void *context )
|
|
|
|
{
|
|
|
|
if ((ULONG_PTR)context & 3) return STATUS_INVALID_PARAMETER;
|
|
|
|
|
|
|
|
if (flags & RTL_RUN_ONCE_INIT_FAILED)
|
|
|
|
{
|
|
|
|
if (context) return STATUS_INVALID_PARAMETER;
|
|
|
|
if (flags & RTL_RUN_ONCE_ASYNC) return STATUS_INVALID_PARAMETER;
|
|
|
|
}
|
|
|
|
else context = (void *)((ULONG_PTR)context | 2);
|
|
|
|
|
|
|
|
for (;;)
|
|
|
|
{
|
|
|
|
ULONG_PTR val = (ULONG_PTR)once->Ptr;
|
|
|
|
|
|
|
|
switch (val & 3)
|
|
|
|
{
|
|
|
|
case 1: /* in progress */
|
2020-05-02 15:10:04 +02:00
|
|
|
if (InterlockedCompareExchangePointer( &once->Ptr, context, (void *)val ) != (void *)val) break;
|
2013-08-28 21:10:50 +02:00
|
|
|
val &= ~3;
|
|
|
|
while (val)
|
|
|
|
{
|
|
|
|
ULONG_PTR next = *(ULONG_PTR *)val;
|
2018-10-26 11:27:11 +02:00
|
|
|
NtReleaseKeyedEvent( 0, (void *)val, FALSE, NULL );
|
2013-08-28 21:10:50 +02:00
|
|
|
val = next;
|
|
|
|
}
|
|
|
|
return STATUS_SUCCESS;
|
|
|
|
|
|
|
|
case 3: /* in progress, async */
|
|
|
|
if (!(flags & RTL_RUN_ONCE_ASYNC)) return STATUS_INVALID_PARAMETER;
|
2020-05-02 15:10:04 +02:00
|
|
|
if (InterlockedCompareExchangePointer( &once->Ptr, context, (void *)val ) != (void *)val) break;
|
2013-08-28 21:10:50 +02:00
|
|
|
return STATUS_SUCCESS;
|
|
|
|
|
|
|
|
default:
|
|
|
|
return STATUS_UNSUCCESSFUL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************
|
|
|
|
* RtlRunOnceExecuteOnce (NTDLL.@)
|
|
|
|
*/
|
|
|
|
DWORD WINAPI RtlRunOnceExecuteOnce( RTL_RUN_ONCE *once, PRTL_RUN_ONCE_INIT_FN func,
|
|
|
|
void *param, void **context )
|
2012-07-22 16:33:14 +02:00
|
|
|
{
|
2013-08-28 21:10:50 +02:00
|
|
|
DWORD ret = RtlRunOnceBeginInitialize( once, 0, context );
|
|
|
|
|
|
|
|
if (ret != STATUS_PENDING) return ret;
|
|
|
|
|
|
|
|
if (!func( once, param, context ))
|
|
|
|
{
|
|
|
|
RtlRunOnceComplete( once, RTL_RUN_ONCE_INIT_FAILED, NULL );
|
|
|
|
return STATUS_UNSUCCESSFUL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return RtlRunOnceComplete( once, 0, context ? *context : NULL );
|
2012-07-22 16:33:14 +02:00
|
|
|
}
|
2013-09-03 11:08:42 +02:00
|
|
|
|
2014-01-11 02:18:10 +01:00
|
|
|
|
|
|
|
/* SRW locks implementation
|
|
|
|
*
|
|
|
|
* The memory layout used by the lock is:
|
|
|
|
*
|
|
|
|
* 32 31 16 0
|
|
|
|
* ________________ ________________
|
|
|
|
* | X| #exclusive | #shared |
|
|
|
|
* ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
|
|
|
|
* Since there is no space left for a separate counter of shared access
|
|
|
|
* threads inside the locked section the #shared field is used for multiple
|
|
|
|
* purposes. The following table lists all possible states the lock can be
|
|
|
|
* in, notation: [X, #exclusive, #shared]:
|
|
|
|
*
|
2016-08-02 00:10:09 +02:00
|
|
|
* [0, 0, N] -> locked by N shared access threads, if N=0 it's unlocked
|
2014-01-11 02:18:10 +01:00
|
|
|
* [0, >=1, >=1] -> threads are requesting exclusive locks, but there are
|
|
|
|
* still shared access threads inside. #shared should not be incremented
|
|
|
|
* anymore!
|
|
|
|
* [1, >=1, >=0] -> lock is owned by an exclusive thread and the #shared
|
|
|
|
* counter can be used again to count the number of threads waiting in the
|
|
|
|
* queue for shared access.
|
|
|
|
*
|
|
|
|
* the following states are invalid and will never occur:
|
|
|
|
* [0, >=1, 0], [1, 0, >=0]
|
|
|
|
*
|
|
|
|
* The main problem arising from the fact that we have no separate counter
|
|
|
|
* of shared access threads inside the locked section is that in the state
|
|
|
|
* [0, >=1, >=1] above we cannot add additional waiting threads to the
|
|
|
|
* shared access queue - it wouldn't be possible to distinguish waiting
|
|
|
|
* threads and those that are still inside. To solve this problem the lock
|
2014-02-07 22:42:49 +01:00
|
|
|
* uses the following approach: a thread that isn't able to allocate a
|
2014-01-11 02:18:10 +01:00
|
|
|
* shared lock just uses the exclusive queue instead. As soon as the thread
|
2014-02-07 22:42:49 +01:00
|
|
|
* is woken up it is in the state [1, >=1, >=0]. In this state it's again
|
2014-01-11 02:18:10 +01:00
|
|
|
* possible to use the shared access queue. The thread atomically moves
|
2014-02-07 22:42:49 +01:00
|
|
|
* itself to the shared access queue and releases the exclusive lock, so
|
2014-01-11 02:18:10 +01:00
|
|
|
* that the "real" exclusive access threads have a chance. As soon as they
|
|
|
|
* are all ready the shared access threads are processed.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define SRWLOCK_MASK_IN_EXCLUSIVE 0x80000000
|
|
|
|
#define SRWLOCK_MASK_EXCLUSIVE_QUEUE 0x7fff0000
|
|
|
|
#define SRWLOCK_MASK_SHARED_QUEUE 0x0000ffff
|
|
|
|
#define SRWLOCK_RES_EXCLUSIVE 0x00010000
|
|
|
|
#define SRWLOCK_RES_SHARED 0x00000001
|
|
|
|
|
|
|
|
#ifdef WORDS_BIGENDIAN
|
2020-04-14 01:09:44 +02:00
|
|
|
#define srwlock_key_exclusive(lock) ((void *)(((ULONG_PTR)&lock->Ptr + 1) & ~1))
|
|
|
|
#define srwlock_key_shared(lock) ((void *)(((ULONG_PTR)&lock->Ptr + 3) & ~1))
|
2014-01-11 02:18:10 +01:00
|
|
|
#else
|
2020-04-14 01:09:44 +02:00
|
|
|
#define srwlock_key_exclusive(lock) ((void *)(((ULONG_PTR)&lock->Ptr + 3) & ~1))
|
|
|
|
#define srwlock_key_shared(lock) ((void *)(((ULONG_PTR)&lock->Ptr + 1) & ~1))
|
2014-01-11 02:18:10 +01:00
|
|
|
#endif
|
|
|
|
|
2014-01-21 22:04:20 +01:00
|
|
|
static inline void srwlock_check_invalid( unsigned int val )
|
|
|
|
{
|
|
|
|
/* Throw exception if it's impossible to acquire/release this lock. */
|
|
|
|
if ((val & SRWLOCK_MASK_EXCLUSIVE_QUEUE) == SRWLOCK_MASK_EXCLUSIVE_QUEUE ||
|
|
|
|
(val & SRWLOCK_MASK_SHARED_QUEUE) == SRWLOCK_MASK_SHARED_QUEUE)
|
|
|
|
RtlRaiseStatus(STATUS_RESOURCE_NOT_OWNED);
|
|
|
|
}
|
|
|
|
|
2014-01-11 02:18:10 +01:00
|
|
|
static inline unsigned int srwlock_lock_exclusive( unsigned int *dest, int incr )
|
|
|
|
{
|
|
|
|
unsigned int val, tmp;
|
|
|
|
/* Atomically modifies the value of *dest by adding incr. If the shared
|
|
|
|
* queue is empty and there are threads waiting for exclusive access, then
|
|
|
|
* sets the mark SRWLOCK_MASK_IN_EXCLUSIVE to signal other threads that
|
2014-02-07 22:42:49 +01:00
|
|
|
* they are allowed again to use the shared queue counter. */
|
2014-01-11 02:18:10 +01:00
|
|
|
for (val = *dest;; val = tmp)
|
|
|
|
{
|
|
|
|
tmp = val + incr;
|
2014-01-21 22:04:20 +01:00
|
|
|
srwlock_check_invalid( tmp );
|
2014-01-11 02:18:10 +01:00
|
|
|
if ((tmp & SRWLOCK_MASK_EXCLUSIVE_QUEUE) && !(tmp & SRWLOCK_MASK_SHARED_QUEUE))
|
|
|
|
tmp |= SRWLOCK_MASK_IN_EXCLUSIVE;
|
2020-05-02 15:10:04 +02:00
|
|
|
if ((tmp = InterlockedCompareExchange( (int *)dest, tmp, val )) == val)
|
2014-01-11 02:18:10 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
return val;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline unsigned int srwlock_unlock_exclusive( unsigned int *dest, int incr )
|
|
|
|
{
|
|
|
|
unsigned int val, tmp;
|
|
|
|
/* Atomically modifies the value of *dest by adding incr. If the queue of
|
|
|
|
* threads waiting for exclusive access is empty, then remove the
|
|
|
|
* SRWLOCK_MASK_IN_EXCLUSIVE flag (only the shared queue counter will
|
|
|
|
* remain). */
|
|
|
|
for (val = *dest;; val = tmp)
|
|
|
|
{
|
|
|
|
tmp = val + incr;
|
2014-01-21 22:04:20 +01:00
|
|
|
srwlock_check_invalid( tmp );
|
2014-01-11 02:18:10 +01:00
|
|
|
if (!(tmp & SRWLOCK_MASK_EXCLUSIVE_QUEUE))
|
|
|
|
tmp &= SRWLOCK_MASK_SHARED_QUEUE;
|
2020-05-02 15:10:04 +02:00
|
|
|
if ((tmp = InterlockedCompareExchange( (int *)dest, tmp, val )) == val)
|
2014-01-11 02:18:10 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
return val;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void srwlock_leave_exclusive( RTL_SRWLOCK *lock, unsigned int val )
|
|
|
|
{
|
|
|
|
/* Used when a thread leaves an exclusive section. If there are other
|
2014-02-07 22:42:49 +01:00
|
|
|
* exclusive access threads they are processed first, followed by
|
2014-01-11 02:18:10 +01:00
|
|
|
* the shared waiters. */
|
|
|
|
if (val & SRWLOCK_MASK_EXCLUSIVE_QUEUE)
|
2018-10-26 11:27:11 +02:00
|
|
|
NtReleaseKeyedEvent( 0, srwlock_key_exclusive(lock), FALSE, NULL );
|
2014-01-11 02:18:10 +01:00
|
|
|
else
|
|
|
|
{
|
|
|
|
val &= SRWLOCK_MASK_SHARED_QUEUE; /* remove SRWLOCK_MASK_IN_EXCLUSIVE */
|
|
|
|
while (val--)
|
2018-10-26 11:27:11 +02:00
|
|
|
NtReleaseKeyedEvent( 0, srwlock_key_shared(lock), FALSE, NULL );
|
2014-01-11 02:18:10 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void srwlock_leave_shared( RTL_SRWLOCK *lock, unsigned int val )
|
|
|
|
{
|
|
|
|
/* Wake up one exclusive thread as soon as the last shared access thread
|
|
|
|
* has left. */
|
|
|
|
if ((val & SRWLOCK_MASK_EXCLUSIVE_QUEUE) && !(val & SRWLOCK_MASK_SHARED_QUEUE))
|
2018-10-26 11:27:11 +02:00
|
|
|
NtReleaseKeyedEvent( 0, srwlock_key_exclusive(lock), FALSE, NULL );
|
2014-01-11 02:18:10 +01:00
|
|
|
}
|
|
|
|
|
2013-09-03 11:08:42 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* RtlInitializeSRWLock (NTDLL.@)
|
2014-01-11 02:18:10 +01:00
|
|
|
*
|
|
|
|
* NOTES
|
|
|
|
* Please note that SRWLocks do not keep track of the owner of a lock.
|
|
|
|
* It doesn't make any difference which thread for example unlocks an
|
|
|
|
* SRWLock (see corresponding tests). This implementation uses two
|
|
|
|
* keyed events (one for the exclusive waiters and one for the shared
|
|
|
|
* waiters) and is limited to 2^15-1 waiting threads.
|
2013-09-03 11:08:42 +02:00
|
|
|
*/
|
|
|
|
void WINAPI RtlInitializeSRWLock( RTL_SRWLOCK *lock )
|
|
|
|
{
|
|
|
|
lock->Ptr = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* RtlAcquireSRWLockExclusive (NTDLL.@)
|
2014-01-11 02:18:10 +01:00
|
|
|
*
|
|
|
|
* NOTES
|
|
|
|
* Unlike RtlAcquireResourceExclusive this function doesn't allow
|
|
|
|
* nested calls from the same thread. "Upgrading" a shared access lock
|
|
|
|
* to an exclusive access lock also doesn't seem to be supported.
|
2013-09-03 11:08:42 +02:00
|
|
|
*/
|
|
|
|
void WINAPI RtlAcquireSRWLockExclusive( RTL_SRWLOCK *lock )
|
|
|
|
{
|
2020-06-09 12:35:01 +02:00
|
|
|
if (unix_funcs->fast_RtlAcquireSRWLockExclusive( lock ) != STATUS_NOT_IMPLEMENTED)
|
2019-06-10 17:07:53 +02:00
|
|
|
return;
|
|
|
|
|
2014-01-11 02:18:10 +01:00
|
|
|
if (srwlock_lock_exclusive( (unsigned int *)&lock->Ptr, SRWLOCK_RES_EXCLUSIVE ))
|
2018-10-26 11:27:11 +02:00
|
|
|
NtWaitForKeyedEvent( 0, srwlock_key_exclusive(lock), FALSE, NULL );
|
2013-09-03 11:08:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* RtlAcquireSRWLockShared (NTDLL.@)
|
2014-01-21 22:18:10 +01:00
|
|
|
*
|
|
|
|
* NOTES
|
|
|
|
* Do not call this function recursively - it will only succeed when
|
|
|
|
* there are no threads waiting for an exclusive lock!
|
2013-09-03 11:08:42 +02:00
|
|
|
*/
|
|
|
|
void WINAPI RtlAcquireSRWLockShared( RTL_SRWLOCK *lock )
|
|
|
|
{
|
2014-01-11 02:18:10 +01:00
|
|
|
unsigned int val, tmp;
|
2019-06-10 17:07:53 +02:00
|
|
|
|
2020-06-09 12:35:01 +02:00
|
|
|
if (unix_funcs->fast_RtlAcquireSRWLockShared( lock ) != STATUS_NOT_IMPLEMENTED)
|
2019-06-10 17:07:53 +02:00
|
|
|
return;
|
|
|
|
|
2014-01-11 02:18:10 +01:00
|
|
|
/* Acquires a shared lock. If it's currently not possible to add elements to
|
|
|
|
* the shared queue, then request exclusive access instead. */
|
|
|
|
for (val = *(unsigned int *)&lock->Ptr;; val = tmp)
|
|
|
|
{
|
|
|
|
if ((val & SRWLOCK_MASK_EXCLUSIVE_QUEUE) && !(val & SRWLOCK_MASK_IN_EXCLUSIVE))
|
|
|
|
tmp = val + SRWLOCK_RES_EXCLUSIVE;
|
|
|
|
else
|
|
|
|
tmp = val + SRWLOCK_RES_SHARED;
|
2020-05-02 15:10:04 +02:00
|
|
|
if ((tmp = InterlockedCompareExchange( (int *)&lock->Ptr, tmp, val )) == val)
|
2014-01-11 02:18:10 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Drop exclusive access again and instead requeue for shared access. */
|
|
|
|
if ((val & SRWLOCK_MASK_EXCLUSIVE_QUEUE) && !(val & SRWLOCK_MASK_IN_EXCLUSIVE))
|
|
|
|
{
|
2018-10-26 11:27:11 +02:00
|
|
|
NtWaitForKeyedEvent( 0, srwlock_key_exclusive(lock), FALSE, NULL );
|
2014-01-11 02:18:10 +01:00
|
|
|
val = srwlock_unlock_exclusive( (unsigned int *)&lock->Ptr, (SRWLOCK_RES_SHARED
|
|
|
|
- SRWLOCK_RES_EXCLUSIVE) ) - SRWLOCK_RES_EXCLUSIVE;
|
|
|
|
srwlock_leave_exclusive( lock, val );
|
|
|
|
}
|
|
|
|
|
|
|
|
if (val & SRWLOCK_MASK_EXCLUSIVE_QUEUE)
|
2018-10-26 11:27:11 +02:00
|
|
|
NtWaitForKeyedEvent( 0, srwlock_key_shared(lock), FALSE, NULL );
|
2013-09-03 11:08:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* RtlReleaseSRWLockExclusive (NTDLL.@)
|
|
|
|
*/
|
|
|
|
void WINAPI RtlReleaseSRWLockExclusive( RTL_SRWLOCK *lock )
|
|
|
|
{
|
2020-06-09 12:35:01 +02:00
|
|
|
if (unix_funcs->fast_RtlReleaseSRWLockExclusive( lock ) != STATUS_NOT_IMPLEMENTED)
|
2019-06-10 17:07:53 +02:00
|
|
|
return;
|
|
|
|
|
2014-01-11 02:18:10 +01:00
|
|
|
srwlock_leave_exclusive( lock, srwlock_unlock_exclusive( (unsigned int *)&lock->Ptr,
|
|
|
|
- SRWLOCK_RES_EXCLUSIVE ) - SRWLOCK_RES_EXCLUSIVE );
|
2013-09-03 11:08:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* RtlReleaseSRWLockShared (NTDLL.@)
|
|
|
|
*/
|
|
|
|
void WINAPI RtlReleaseSRWLockShared( RTL_SRWLOCK *lock )
|
|
|
|
{
|
2020-06-09 12:35:01 +02:00
|
|
|
if (unix_funcs->fast_RtlReleaseSRWLockShared( lock ) != STATUS_NOT_IMPLEMENTED)
|
2019-06-10 17:07:53 +02:00
|
|
|
return;
|
|
|
|
|
2014-01-11 02:18:10 +01:00
|
|
|
srwlock_leave_shared( lock, srwlock_lock_exclusive( (unsigned int *)&lock->Ptr,
|
|
|
|
- SRWLOCK_RES_SHARED ) - SRWLOCK_RES_SHARED );
|
2013-09-03 11:08:42 +02:00
|
|
|
}
|
2014-01-05 03:48:34 +01:00
|
|
|
|
2014-01-21 22:18:10 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* RtlTryAcquireSRWLockExclusive (NTDLL.@)
|
|
|
|
*
|
|
|
|
* NOTES
|
2019-12-12 11:22:59 +01:00
|
|
|
* Similarly to AcquireSRWLockExclusive, recursive calls are not allowed
|
|
|
|
* and will fail with a FALSE return value.
|
2014-01-21 22:18:10 +01:00
|
|
|
*/
|
|
|
|
BOOLEAN WINAPI RtlTryAcquireSRWLockExclusive( RTL_SRWLOCK *lock )
|
|
|
|
{
|
2019-06-10 17:07:53 +02:00
|
|
|
NTSTATUS ret;
|
|
|
|
|
2020-06-09 12:35:01 +02:00
|
|
|
if ((ret = unix_funcs->fast_RtlTryAcquireSRWLockExclusive( lock )) != STATUS_NOT_IMPLEMENTED)
|
2019-06-10 17:07:53 +02:00
|
|
|
return (ret == STATUS_SUCCESS);
|
|
|
|
|
2020-05-02 15:10:04 +02:00
|
|
|
return InterlockedCompareExchange( (int *)&lock->Ptr, SRWLOCK_MASK_IN_EXCLUSIVE |
|
|
|
|
SRWLOCK_RES_EXCLUSIVE, 0 ) == 0;
|
2014-01-21 22:18:10 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* RtlTryAcquireSRWLockShared (NTDLL.@)
|
|
|
|
*/
|
|
|
|
BOOLEAN WINAPI RtlTryAcquireSRWLockShared( RTL_SRWLOCK *lock )
|
|
|
|
{
|
|
|
|
unsigned int val, tmp;
|
2019-06-10 17:07:53 +02:00
|
|
|
NTSTATUS ret;
|
|
|
|
|
2020-06-09 12:35:01 +02:00
|
|
|
if ((ret = unix_funcs->fast_RtlTryAcquireSRWLockShared( lock )) != STATUS_NOT_IMPLEMENTED)
|
2019-06-10 17:07:53 +02:00
|
|
|
return (ret == STATUS_SUCCESS);
|
|
|
|
|
2014-01-21 22:18:10 +01:00
|
|
|
for (val = *(unsigned int *)&lock->Ptr;; val = tmp)
|
|
|
|
{
|
|
|
|
if (val & SRWLOCK_MASK_EXCLUSIVE_QUEUE)
|
|
|
|
return FALSE;
|
2020-05-02 15:10:04 +02:00
|
|
|
if ((tmp = InterlockedCompareExchange( (int *)&lock->Ptr, val + SRWLOCK_RES_SHARED, val )) == val)
|
2014-01-21 22:18:10 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2014-01-05 03:48:34 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* RtlInitializeConditionVariable (NTDLL.@)
|
|
|
|
*
|
|
|
|
* Initializes the condition variable with NULL.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* variable [O] condition variable
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Nothing.
|
|
|
|
*/
|
|
|
|
void WINAPI RtlInitializeConditionVariable( RTL_CONDITION_VARIABLE *variable )
|
|
|
|
{
|
|
|
|
variable->Ptr = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* RtlWakeConditionVariable (NTDLL.@)
|
|
|
|
*
|
|
|
|
* Wakes up one thread waiting on the condition variable.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* variable [I/O] condition variable to wake up.
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Nothing.
|
|
|
|
*
|
|
|
|
* NOTES
|
|
|
|
* The calling thread does not have to own any lock in order to call
|
|
|
|
* this function.
|
|
|
|
*/
|
|
|
|
void WINAPI RtlWakeConditionVariable( RTL_CONDITION_VARIABLE *variable )
|
|
|
|
{
|
2020-06-09 12:38:37 +02:00
|
|
|
if (unix_funcs->fast_RtlWakeConditionVariable( variable, 1 ) == STATUS_NOT_IMPLEMENTED)
|
2020-04-14 01:09:43 +02:00
|
|
|
{
|
2020-05-02 15:10:04 +02:00
|
|
|
InterlockedIncrement( (int *)&variable->Ptr );
|
2019-02-10 19:26:45 +01:00
|
|
|
RtlWakeAddressSingle( variable );
|
2020-04-14 01:09:43 +02:00
|
|
|
}
|
2014-01-05 03:48:34 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* RtlWakeAllConditionVariable (NTDLL.@)
|
|
|
|
*
|
|
|
|
* See WakeConditionVariable, wakes up all waiting threads.
|
|
|
|
*/
|
|
|
|
void WINAPI RtlWakeAllConditionVariable( RTL_CONDITION_VARIABLE *variable )
|
|
|
|
{
|
2020-06-09 12:38:37 +02:00
|
|
|
if (unix_funcs->fast_RtlWakeConditionVariable( variable, INT_MAX ) == STATUS_NOT_IMPLEMENTED)
|
2020-04-14 01:09:43 +02:00
|
|
|
{
|
2020-05-02 15:10:04 +02:00
|
|
|
InterlockedIncrement( (int *)&variable->Ptr );
|
2019-02-10 19:26:45 +01:00
|
|
|
RtlWakeAddressAll( variable );
|
2020-04-14 01:09:43 +02:00
|
|
|
}
|
2014-01-05 03:48:34 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* RtlSleepConditionVariableCS (NTDLL.@)
|
|
|
|
*
|
|
|
|
* Atomically releases the critical section and suspends the thread,
|
|
|
|
* waiting for a Wake(All)ConditionVariable event. Afterwards it enters
|
|
|
|
* the critical section again and returns.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* variable [I/O] condition variable
|
|
|
|
* crit [I/O] critical section to leave temporarily
|
|
|
|
* timeout [I] timeout
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* see NtWaitForKeyedEvent for all possible return values.
|
|
|
|
*/
|
|
|
|
NTSTATUS WINAPI RtlSleepConditionVariableCS( RTL_CONDITION_VARIABLE *variable, RTL_CRITICAL_SECTION *crit,
|
|
|
|
const LARGE_INTEGER *timeout )
|
|
|
|
{
|
|
|
|
NTSTATUS status;
|
2020-04-14 01:09:43 +02:00
|
|
|
int val;
|
2019-02-07 19:39:46 +01:00
|
|
|
|
2020-06-09 12:38:37 +02:00
|
|
|
if ((status = unix_funcs->fast_RtlSleepConditionVariableCS( variable, crit,
|
|
|
|
timeout )) != STATUS_NOT_IMPLEMENTED)
|
2020-04-14 01:09:43 +02:00
|
|
|
return status;
|
2014-01-05 03:48:34 +01:00
|
|
|
|
2020-04-14 01:09:43 +02:00
|
|
|
val = *(int *)&variable->Ptr;
|
|
|
|
RtlLeaveCriticalSection( crit );
|
|
|
|
status = RtlWaitOnAddress( &variable->Ptr, &val, sizeof(int), timeout );
|
2014-01-05 03:48:34 +01:00
|
|
|
RtlEnterCriticalSection( crit );
|
|
|
|
return status;
|
|
|
|
}
|
2014-01-22 01:05:15 +01:00
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* RtlSleepConditionVariableSRW (NTDLL.@)
|
|
|
|
*
|
|
|
|
* Atomically releases the SRWLock and suspends the thread,
|
|
|
|
* waiting for a Wake(All)ConditionVariable event. Afterwards it enters
|
|
|
|
* the SRWLock again with the same access rights and returns.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* variable [I/O] condition variable
|
|
|
|
* lock [I/O] SRWLock to leave temporarily
|
|
|
|
* timeout [I] timeout
|
|
|
|
* flags [I] type of the current lock (exclusive / shared)
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* see NtWaitForKeyedEvent for all possible return values.
|
|
|
|
*
|
|
|
|
* NOTES
|
|
|
|
* the behaviour is undefined if the thread doesn't own the lock.
|
|
|
|
*/
|
|
|
|
NTSTATUS WINAPI RtlSleepConditionVariableSRW( RTL_CONDITION_VARIABLE *variable, RTL_SRWLOCK *lock,
|
|
|
|
const LARGE_INTEGER *timeout, ULONG flags )
|
|
|
|
{
|
|
|
|
NTSTATUS status;
|
2020-04-14 01:09:43 +02:00
|
|
|
int val;
|
|
|
|
|
2020-06-09 12:38:37 +02:00
|
|
|
if ((status = unix_funcs->fast_RtlSleepConditionVariableSRW( variable, lock, timeout,
|
|
|
|
flags )) != STATUS_NOT_IMPLEMENTED)
|
2020-04-14 01:09:43 +02:00
|
|
|
return status;
|
|
|
|
|
|
|
|
val = *(int *)&variable->Ptr;
|
2014-01-22 01:05:15 +01:00
|
|
|
|
|
|
|
if (flags & RTL_CONDITION_VARIABLE_LOCKMODE_SHARED)
|
|
|
|
RtlReleaseSRWLockShared( lock );
|
|
|
|
else
|
|
|
|
RtlReleaseSRWLockExclusive( lock );
|
|
|
|
|
2020-04-14 01:09:43 +02:00
|
|
|
status = RtlWaitOnAddress( &variable->Ptr, &val, sizeof(int), timeout );
|
2014-01-22 01:05:15 +01:00
|
|
|
|
|
|
|
if (flags & RTL_CONDITION_VARIABLE_LOCKMODE_SHARED)
|
|
|
|
RtlAcquireSRWLockShared( lock );
|
|
|
|
else
|
|
|
|
RtlAcquireSRWLockExclusive( lock );
|
|
|
|
return status;
|
|
|
|
}
|
2018-10-26 08:50:14 +02:00
|
|
|
|
2018-12-01 02:03:56 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* RtlWaitOnAddress (NTDLL.@)
|
|
|
|
*/
|
|
|
|
NTSTATUS WINAPI RtlWaitOnAddress( const void *addr, const void *cmp, SIZE_T size,
|
|
|
|
const LARGE_INTEGER *timeout )
|
|
|
|
{
|
2020-06-09 12:39:49 +02:00
|
|
|
return unix_funcs->RtlWaitOnAddress( addr, cmp, size, timeout );
|
2018-10-26 08:50:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* RtlWakeAddressAll (NTDLL.@)
|
|
|
|
*/
|
|
|
|
void WINAPI RtlWakeAddressAll( const void *addr )
|
|
|
|
{
|
2020-06-09 12:39:49 +02:00
|
|
|
return unix_funcs->RtlWakeAddressAll( addr );
|
2018-10-26 08:50:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* RtlWakeAddressSingle (NTDLL.@)
|
|
|
|
*/
|
|
|
|
void WINAPI RtlWakeAddressSingle( const void *addr )
|
|
|
|
{
|
2020-06-09 12:39:49 +02:00
|
|
|
return unix_funcs->RtlWakeAddressSingle( addr );
|
2018-10-26 08:50:14 +02:00
|
|
|
}
|