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"
|
|
|
|
|
|
|
|
#include <assert.h>
|
|
|
|
#include <errno.h>
|
|
|
|
#include <signal.h>
|
|
|
|
#ifdef HAVE_SYS_TIME_H
|
|
|
|
# include <sys/time.h>
|
|
|
|
#endif
|
2005-03-04 13:38:36 +01:00
|
|
|
#ifdef HAVE_POLL_H
|
|
|
|
#include <poll.h>
|
|
|
|
#endif
|
2003-03-31 03:37:04 +02:00
|
|
|
#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
|
|
|
|
|
2005-11-28 17:32:54 +01:00
|
|
|
#include "ntstatus.h"
|
|
|
|
#define WIN32_NO_STATUS
|
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
|
|
|
|
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
|
|
|
|
2007-10-25 20:09:54 +02:00
|
|
|
/* creates a struct security_descriptor and contained information in one contiguous piece of memory */
|
|
|
|
NTSTATUS NTDLL_create_struct_sd(PSECURITY_DESCRIPTOR nt_sd, struct security_descriptor **server_sd,
|
|
|
|
data_size_t *server_sd_len)
|
2007-10-24 17:04:42 +02:00
|
|
|
{
|
|
|
|
unsigned int len;
|
|
|
|
PSID owner, group;
|
|
|
|
ACL *dacl, *sacl;
|
|
|
|
BOOLEAN owner_present, group_present, dacl_present, sacl_present;
|
|
|
|
BOOLEAN defaulted;
|
|
|
|
NTSTATUS status;
|
|
|
|
unsigned char *ptr;
|
|
|
|
|
|
|
|
if (!nt_sd)
|
|
|
|
{
|
|
|
|
*server_sd = NULL;
|
|
|
|
*server_sd_len = 0;
|
|
|
|
return STATUS_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
len = sizeof(struct security_descriptor);
|
|
|
|
|
|
|
|
status = RtlGetOwnerSecurityDescriptor(nt_sd, &owner, &owner_present);
|
|
|
|
if (status != STATUS_SUCCESS) return status;
|
|
|
|
status = RtlGetGroupSecurityDescriptor(nt_sd, &group, &group_present);
|
|
|
|
if (status != STATUS_SUCCESS) return status;
|
|
|
|
status = RtlGetSaclSecurityDescriptor(nt_sd, &sacl_present, &sacl, &defaulted);
|
|
|
|
if (status != STATUS_SUCCESS) return status;
|
|
|
|
status = RtlGetDaclSecurityDescriptor(nt_sd, &dacl_present, &dacl, &defaulted);
|
|
|
|
if (status != STATUS_SUCCESS) return status;
|
|
|
|
|
|
|
|
if (owner_present)
|
|
|
|
len += RtlLengthSid(owner);
|
|
|
|
if (group_present)
|
|
|
|
len += RtlLengthSid(group);
|
|
|
|
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);
|
|
|
|
*server_sd = RtlAllocateHeap(GetProcessHeap(), 0, len);
|
|
|
|
if (!*server_sd) return STATUS_NO_MEMORY;
|
|
|
|
|
|
|
|
(*server_sd)->control = ((SECURITY_DESCRIPTOR *)nt_sd)->Control & ~SE_SELF_RELATIVE;
|
|
|
|
(*server_sd)->owner_len = owner_present ? RtlLengthSid(owner) : 0;
|
|
|
|
(*server_sd)->group_len = group_present ? RtlLengthSid(group) : 0;
|
|
|
|
(*server_sd)->sacl_len = (sacl_present && sacl) ? sacl->AclSize : 0;
|
|
|
|
(*server_sd)->dacl_len = (dacl_present && dacl) ? dacl->AclSize : 0;
|
|
|
|
|
|
|
|
ptr = (unsigned char *)(*server_sd + 1);
|
|
|
|
memcpy(ptr, owner, (*server_sd)->owner_len);
|
|
|
|
ptr += (*server_sd)->owner_len;
|
|
|
|
memcpy(ptr, group, (*server_sd)->group_len);
|
|
|
|
ptr += (*server_sd)->group_len;
|
|
|
|
memcpy(ptr, sacl, (*server_sd)->sacl_len);
|
|
|
|
ptr += (*server_sd)->sacl_len;
|
|
|
|
memcpy(ptr, dacl, (*server_sd)->dacl_len);
|
|
|
|
|
|
|
|
*server_sd_len = len;
|
|
|
|
|
|
|
|
return STATUS_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2007-10-25 20:09:54 +02:00
|
|
|
/* frees a struct security_descriptor allocated by NTDLL_create_struct_sd */
|
|
|
|
void NTDLL_free_struct_sd(struct security_descriptor *server_sd)
|
2007-10-24 17:04:42 +02:00
|
|
|
{
|
|
|
|
RtlFreeHeap(GetProcessHeap(), 0, server_sd);
|
|
|
|
}
|
|
|
|
|
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;
|
2007-10-25 16:42:53 +02:00
|
|
|
struct object_attributes objattr;
|
|
|
|
struct security_descriptor *sd = NULL;
|
2000-01-26 02:39:51 +01:00
|
|
|
|
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
|
|
|
|
2008-12-08 16:05:17 +01:00
|
|
|
objattr.rootdir = wine_server_obj_handle( attr ? attr->RootDirectory : 0 );
|
2007-10-25 16:42:53 +02:00
|
|
|
objattr.sd_len = 0;
|
2007-10-26 18:01:33 +02:00
|
|
|
objattr.name_len = len;
|
2007-10-25 16:42:53 +02:00
|
|
|
if (attr)
|
|
|
|
{
|
2007-10-25 20:09:54 +02:00
|
|
|
ret = NTDLL_create_struct_sd( attr->SecurityDescriptor, &sd, &objattr.sd_len );
|
2007-10-25 16:42:53 +02:00
|
|
|
if (ret != STATUS_SUCCESS) return ret;
|
|
|
|
}
|
|
|
|
|
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;
|
2005-10-27 20:30:37 +02:00
|
|
|
req->attributes = (attr) ? attr->Attributes : 0;
|
2000-08-30 02:00:48 +02:00
|
|
|
req->initial = InitialCount;
|
|
|
|
req->max = MaximumCount;
|
2007-10-25 16:42:53 +02:00
|
|
|
wine_server_add_data( req, &objattr, sizeof(objattr) );
|
|
|
|
if (objattr.sd_len) wine_server_add_data( req, sd, objattr.sd_len );
|
2001-11-30 19:46:42 +01:00
|
|
|
if (len) wine_server_add_data( req, attr->ObjectName->Buffer, len );
|
|
|
|
ret = wine_server_call( req );
|
2008-12-08 16:05:17 +01:00
|
|
|
*SemaphoreHandle = wine_server_ptr_handle( reply->handle );
|
2000-08-30 02:00:48 +02:00
|
|
|
}
|
2001-11-30 19:46:42 +01:00
|
|
|
SERVER_END_REQ;
|
2007-10-25 16:42:53 +02:00
|
|
|
|
2007-10-25 20:09:54 +02:00
|
|
|
NTDLL_free_struct_sd( sd );
|
2007-10-25 16:42:53 +02:00
|
|
|
|
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;
|
2005-10-27 20:30:37 +02:00
|
|
|
req->attributes = (attr) ? attr->Attributes : 0;
|
2008-12-08 16:05:17 +01:00
|
|
|
req->rootdir = wine_server_obj_handle( attr ? attr->RootDirectory : 0 );
|
2001-11-30 19:46:42 +01:00
|
|
|
if (len) wine_server_add_data( req, attr->ObjectName->Buffer, len );
|
|
|
|
ret = wine_server_call( req );
|
2008-12-08 16:05:17 +01:00
|
|
|
*SemaphoreHandle = wine_server_ptr_handle( 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,
|
2005-06-13 12:03:18 +02:00
|
|
|
SEMAPHORE_INFORMATION_CLASS SemaphoreInformationClass,
|
|
|
|
PVOID SemaphoreInformation,
|
1999-03-09 18:47:51 +01:00
|
|
|
ULONG Length,
|
2002-06-01 01:06:46 +02:00
|
|
|
PULONG ReturnLength)
|
1999-03-09 18:47:51 +01:00
|
|
|
{
|
2006-10-16 13:49:06 +02:00
|
|
|
FIXME("(%p,%d,%p,0x%08x,%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
|
|
|
{
|
2008-12-08 16:05:17 +01:00
|
|
|
req->handle = wine_server_obj_handle( handle );
|
2000-08-30 02:00:48 +02:00
|
|
|
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;
|
2007-10-24 17:04:42 +02:00
|
|
|
struct security_descriptor *sd = NULL;
|
|
|
|
struct object_attributes objattr;
|
2000-01-26 02:39:51 +01:00
|
|
|
|
2004-12-02 19:05:37 +01:00
|
|
|
if (len >= MAX_PATH * sizeof(WCHAR)) return STATUS_NAME_TOO_LONG;
|
|
|
|
|
2008-12-08 16:05:17 +01:00
|
|
|
objattr.rootdir = wine_server_obj_handle( attr ? attr->RootDirectory : 0 );
|
2007-10-24 17:04:42 +02:00
|
|
|
objattr.sd_len = 0;
|
2007-10-26 18:01:33 +02:00
|
|
|
objattr.name_len = len;
|
2007-10-24 17:04:42 +02:00
|
|
|
if (attr)
|
|
|
|
{
|
2007-10-25 20:09:54 +02:00
|
|
|
ret = NTDLL_create_struct_sd( attr->SecurityDescriptor, &sd, &objattr.sd_len );
|
2007-10-24 17:04:42 +02:00
|
|
|
if (ret != STATUS_SUCCESS) return ret;
|
|
|
|
}
|
|
|
|
|
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;
|
2005-10-27 20:30:37 +02:00
|
|
|
req->attributes = (attr) ? attr->Attributes : 0;
|
2000-08-30 02:00:48 +02:00
|
|
|
req->manual_reset = ManualReset;
|
|
|
|
req->initial_state = InitialState;
|
2007-10-24 17:04:42 +02:00
|
|
|
wine_server_add_data( req, &objattr, sizeof(objattr) );
|
|
|
|
if (objattr.sd_len) wine_server_add_data( req, sd, objattr.sd_len );
|
2001-11-30 19:46:42 +01:00
|
|
|
if (len) wine_server_add_data( req, attr->ObjectName->Buffer, len );
|
|
|
|
ret = wine_server_call( req );
|
2008-12-08 16:05:17 +01:00
|
|
|
*EventHandle = wine_server_ptr_handle( reply->handle );
|
2000-08-30 02:00:48 +02:00
|
|
|
}
|
2001-11-30 19:46:42 +01:00
|
|
|
SERVER_END_REQ;
|
2007-10-24 17:04:42 +02:00
|
|
|
|
2007-10-25 20:09:54 +02:00
|
|
|
NTDLL_free_struct_sd( sd );
|
2007-10-24 17:04:42 +02:00
|
|
|
|
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;
|
2005-10-27 20:30:37 +02:00
|
|
|
req->attributes = (attr) ? attr->Attributes : 0;
|
2008-12-08 16:05:17 +01:00
|
|
|
req->rootdir = wine_server_obj_handle( attr ? attr->RootDirectory : 0 );
|
2001-11-30 19:46:42 +01:00
|
|
|
if (len) wine_server_add_data( req, attr->ObjectName->Buffer, len );
|
|
|
|
ret = wine_server_call( req );
|
2008-12-08 16:05:17 +01:00
|
|
|
*EventHandle = wine_server_ptr_handle( 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
|
|
|
{
|
2008-12-08 16:05:17 +01:00
|
|
|
req->handle = wine_server_obj_handle( handle );
|
2000-08-30 02:00:48 +02:00
|
|
|
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
|
|
|
{
|
2008-12-08 16:05:17 +01:00
|
|
|
req->handle = wine_server_obj_handle( handle );
|
2000-08-30 02:00:48 +02:00
|
|
|
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)
|
2006-10-16 13:49:06 +02:00
|
|
|
FIXME("(%p,%d)\n", handle, *PulseCount);
|
2004-04-01 23:01:53 +02:00
|
|
|
|
2001-02-27 03:09:16 +01:00
|
|
|
SERVER_START_REQ( event_op )
|
2000-08-30 02:00:48 +02:00
|
|
|
{
|
2008-12-08 16:05:17 +01:00
|
|
|
req->handle = wine_server_obj_handle( handle );
|
2000-08-30 02:00:48 +02:00
|
|
|
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,
|
2007-07-29 22:37:28 +02:00
|
|
|
IN EVENT_INFORMATION_CLASS EventInformationClass,
|
- 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
|
|
|
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)
|
|
|
|
{
|
2007-10-25 16:43:05 +02:00
|
|
|
NTSTATUS status;
|
|
|
|
DWORD len = attr && attr->ObjectName ? attr->ObjectName->Length : 0;
|
|
|
|
struct security_descriptor *sd = NULL;
|
|
|
|
struct object_attributes objattr;
|
2004-12-02 19:05:37 +01:00
|
|
|
|
|
|
|
if (len >= MAX_PATH * sizeof(WCHAR)) return STATUS_NAME_TOO_LONG;
|
|
|
|
|
2008-12-08 16:05:17 +01:00
|
|
|
objattr.rootdir = wine_server_obj_handle( attr ? attr->RootDirectory : 0 );
|
2007-10-25 16:43:05 +02:00
|
|
|
objattr.sd_len = 0;
|
2007-10-26 18:01:33 +02:00
|
|
|
objattr.name_len = len;
|
2007-10-25 16:43:05 +02:00
|
|
|
if (attr)
|
|
|
|
{
|
2007-10-25 20:09:54 +02:00
|
|
|
status = NTDLL_create_struct_sd( attr->SecurityDescriptor, &sd, &objattr.sd_len );
|
2007-10-25 16:43:05 +02:00
|
|
|
if (status != STATUS_SUCCESS) return status;
|
|
|
|
}
|
|
|
|
|
2004-12-02 19:05:37 +01:00
|
|
|
SERVER_START_REQ( create_mutex )
|
|
|
|
{
|
|
|
|
req->access = access;
|
2005-10-27 20:30:37 +02:00
|
|
|
req->attributes = (attr) ? attr->Attributes : 0;
|
2004-12-02 19:05:37 +01:00
|
|
|
req->owned = InitialOwner;
|
2007-10-25 16:43:05 +02:00
|
|
|
wine_server_add_data( req, &objattr, sizeof(objattr) );
|
|
|
|
if (objattr.sd_len) wine_server_add_data( req, sd, objattr.sd_len );
|
2004-12-02 19:05:37 +01:00
|
|
|
if (len) wine_server_add_data( req, attr->ObjectName->Buffer, len );
|
|
|
|
status = wine_server_call( req );
|
2008-12-08 16:05:17 +01:00
|
|
|
*MutantHandle = wine_server_ptr_handle( reply->handle );
|
2004-12-02 19:05:37 +01:00
|
|
|
}
|
|
|
|
SERVER_END_REQ;
|
2007-10-25 16:43:05 +02:00
|
|
|
|
2007-10-25 20:09:54 +02:00
|
|
|
NTDLL_free_struct_sd( sd );
|
2007-10-25 16:43:05 +02:00
|
|
|
|
2004-12-02 19:05:37 +01:00
|
|
|
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;
|
2005-10-27 20:30:37 +02:00
|
|
|
req->attributes = (attr) ? attr->Attributes : 0;
|
2008-12-08 16:05:17 +01:00
|
|
|
req->rootdir = wine_server_obj_handle( attr ? attr->RootDirectory : 0 );
|
2004-12-02 19:05:37 +01:00
|
|
|
if (len) wine_server_add_data( req, attr->ObjectName->Buffer, len );
|
|
|
|
status = wine_server_call( req );
|
2008-12-08 16:05:17 +01:00
|
|
|
*MutantHandle = wine_server_ptr_handle( reply->handle );
|
2004-12-02 19:05:37 +01:00
|
|
|
}
|
|
|
|
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 )
|
|
|
|
{
|
2008-12-08 16:05:17 +01:00
|
|
|
req->handle = wine_server_obj_handle( handle );
|
2004-12-02 19:05:37 +01:00
|
|
|
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 )
|
|
|
|
{
|
2006-10-16 13:49:06 +02:00
|
|
|
FIXME("(%p %u %p %u %p): stub!\n",
|
2004-12-02 19:05:37 +01:00
|
|
|
handle, MutantInformationClass, MutantInformation, MutantInformationLength, ResultLength);
|
|
|
|
return STATUS_NOT_IMPLEMENTED;
|
|
|
|
}
|
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 )
|
|
|
|
{
|
|
|
|
FIXME( "stub: %p %x %s\n", handle, access, attr ? debugstr_us(attr->ObjectName) : "" );
|
|
|
|
*handle = (HANDLE)0xdead;
|
|
|
|
return STATUS_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* NtOpenJobObject [NTDLL.@]
|
|
|
|
* ZwOpenJobObject [NTDLL.@]
|
|
|
|
*/
|
|
|
|
NTSTATUS WINAPI NtOpenJobObject( PHANDLE handle, ACCESS_MASK access, const OBJECT_ATTRIBUTES *attr )
|
|
|
|
{
|
|
|
|
FIXME( "stub: %p %x %s\n", handle, access, attr ? debugstr_us(attr->ObjectName) : "" );
|
|
|
|
return STATUS_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* NtTerminateJobObject [NTDLL.@]
|
|
|
|
* ZwTerminateJobObject [NTDLL.@]
|
|
|
|
*/
|
|
|
|
NTSTATUS WINAPI NtTerminateJobObject( HANDLE handle, NTSTATUS status )
|
|
|
|
{
|
|
|
|
FIXME( "stub: %p %x\n", handle, status );
|
|
|
|
return STATUS_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* NtQueryInformationJobObject [NTDLL.@]
|
|
|
|
* ZwQueryInformationJobObject [NTDLL.@]
|
|
|
|
*/
|
|
|
|
NTSTATUS WINAPI NtQueryInformationJobObject( HANDLE handle, JOBOBJECTINFOCLASS class, PVOID info,
|
|
|
|
ULONG len, PULONG ret_len )
|
|
|
|
{
|
|
|
|
FIXME( "stub: %p %u %p %u %p\n", handle, class, info, len, ret_len );
|
|
|
|
return STATUS_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* NtSetInformationJobObject [NTDLL.@]
|
|
|
|
* ZwSetInformationJobObject [NTDLL.@]
|
|
|
|
*/
|
|
|
|
NTSTATUS WINAPI NtSetInformationJobObject( HANDLE handle, JOBOBJECTINFOCLASS class, PVOID info, ULONG len )
|
|
|
|
{
|
|
|
|
FIXME( "stub: %p %u %p %u\n", handle, class, info, len );
|
|
|
|
return STATUS_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* NtIsProcessInJob [NTDLL.@]
|
|
|
|
* ZwIsProcessInJob [NTDLL.@]
|
|
|
|
*/
|
|
|
|
NTSTATUS WINAPI NtIsProcessInJob( HANDLE process, HANDLE job )
|
|
|
|
{
|
|
|
|
FIXME( "stub: %p %p\n", process, job );
|
|
|
|
return STATUS_PROCESS_NOT_IN_JOB;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* NtAssignProcessToJobObject [NTDLL.@]
|
|
|
|
* ZwAssignProcessToJobObject [NTDLL.@]
|
|
|
|
*/
|
|
|
|
NTSTATUS WINAPI NtAssignProcessToJobObject( HANDLE job, HANDLE process )
|
|
|
|
{
|
|
|
|
FIXME( "stub: %p %p\n", job, process );
|
|
|
|
return STATUS_SUCCESS;
|
|
|
|
}
|
|
|
|
|
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;
|
2005-10-27 20:30:37 +02:00
|
|
|
req->attributes = (attr) ? attr->Attributes : 0;
|
2008-12-08 16:05:17 +01:00
|
|
|
req->rootdir = wine_server_obj_handle( attr ? attr->RootDirectory : 0 );
|
2003-05-20 06:00:42 +02:00
|
|
|
req->manual = (timer_type == NotificationTimer) ? TRUE : FALSE;
|
2004-12-02 19:05:37 +01:00
|
|
|
if (len) wine_server_add_data( req, attr->ObjectName->Buffer, len );
|
2003-05-20 06:00:42 +02:00
|
|
|
status = wine_server_call( req );
|
2008-12-08 16:05:17 +01:00
|
|
|
*handle = wine_server_ptr_handle( reply->handle );
|
2003-05-20 06:00:42 +02:00
|
|
|
}
|
|
|
|
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;
|
2005-10-27 20:30:37 +02:00
|
|
|
req->attributes = (attr) ? attr->Attributes : 0;
|
2008-12-08 16:05:17 +01:00
|
|
|
req->rootdir = wine_server_obj_handle( attr ? attr->RootDirectory : 0 );
|
2004-12-02 19:05:37 +01:00
|
|
|
if (len) wine_server_add_data( req, attr->ObjectName->Buffer, len );
|
2003-05-20 06:00:42 +02:00
|
|
|
status = wine_server_call( req );
|
2008-12-08 16:05:17 +01:00
|
|
|
*handle = wine_server_ptr_handle( reply->handle );
|
2003-05-20 06:00:42 +02:00
|
|
|
}
|
|
|
|
SERVER_END_REQ;
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
* NtSetTimer [NTDLL.@]
|
|
|
|
* ZwSetTimer [NTDLL.@]
|
|
|
|
*/
|
|
|
|
NTSTATUS WINAPI NtSetTimer(IN HANDLE handle,
|
|
|
|
IN const LARGE_INTEGER* when,
|
2005-06-10 21:33:47 +02:00
|
|
|
IN PTIMER_APC_ROUTINE callback,
|
2003-05-20 06:00:42 +02:00
|
|
|
IN PVOID callback_arg,
|
|
|
|
IN BOOLEAN resume,
|
|
|
|
IN ULONG period OPTIONAL,
|
|
|
|
OUT PBOOLEAN state OPTIONAL)
|
|
|
|
{
|
|
|
|
NTSTATUS status = STATUS_SUCCESS;
|
|
|
|
|
2006-10-16 13:49:06 +02:00
|
|
|
TRACE("(%p,%p,%p,%p,%08x,0x%08x,%p) stub\n",
|
2003-05-20 06:00:42 +02:00
|
|
|
handle, when, callback, callback_arg, resume, period, state);
|
|
|
|
|
|
|
|
SERVER_START_REQ( set_timer )
|
|
|
|
{
|
2008-12-08 16:05:17 +01:00
|
|
|
req->handle = wine_server_obj_handle( handle );
|
2003-05-20 06:00:42 +02:00
|
|
|
req->period = period;
|
2007-04-17 20:08:59 +02:00
|
|
|
req->expire = when->QuadPart;
|
2008-12-29 17:43:01 +01:00
|
|
|
req->callback = wine_server_client_ptr( callback );
|
|
|
|
req->arg = wine_server_client_ptr( callback_arg );
|
2003-05-20 06:00:42 +02:00
|
|
|
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 )
|
|
|
|
{
|
2008-12-08 16:05:17 +01:00
|
|
|
req->handle = wine_server_obj_handle( handle );
|
2003-05-20 06:00:42 +02:00
|
|
|
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;
|
|
|
|
|
2006-10-16 13:49:06 +02:00
|
|
|
TRACE("(%p,%d,%p,0x%08x,%p)\n", TimerHandle, TimerInformationClass,
|
2004-12-13 22:10:58 +01:00
|
|
|
TimerInformation, Length, ReturnLength);
|
|
|
|
|
|
|
|
switch (TimerInformationClass)
|
|
|
|
{
|
|
|
|
case TimerBasicInformation:
|
|
|
|
if (Length < sizeof(TIMER_BASIC_INFORMATION))
|
|
|
|
return STATUS_INFO_LENGTH_MISMATCH;
|
|
|
|
|
|
|
|
SERVER_START_REQ(get_timer_info)
|
|
|
|
{
|
2008-12-08 16:05:17 +01:00
|
|
|
req->handle = wine_server_obj_handle( TimerHandle );
|
2004-12-13 22:10:58 +01:00
|
|
|
status = wine_server_call(req);
|
|
|
|
|
|
|
|
/* convert server time to absolute NTDLL time */
|
2007-04-17 20:08:59 +02:00
|
|
|
basic_info->RemainingTime.QuadPart = reply->when;
|
2004-12-13 22:10:58 +01:00
|
|
|
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 )
|
|
|
|
{
|
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
|
|
|
/***********************************************************************
|
|
|
|
* 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;
|
2005-06-06 22:04:33 +02:00
|
|
|
ret = read( ntdll_get_thread_data()->wait_fd[0], &reply, sizeof(reply) );
|
2003-03-31 03:37:04 +02:00
|
|
|
if (ret == sizeof(reply))
|
|
|
|
{
|
|
|
|
if (!reply.cookie) break; /* thread got killed */
|
2008-12-29 17:19:26 +01:00
|
|
|
if (wine_server_get_ptr(reply.cookie) == cookie) return reply.signaled;
|
2003-03-31 03:37:04 +02:00
|
|
|
/* we stole another reply, wait for the real one */
|
|
|
|
signaled = wait_reply( cookie );
|
|
|
|
/* and now put the wrong one back in the pipe */
|
|
|
|
for (;;)
|
|
|
|
{
|
2005-06-06 22:04:33 +02:00
|
|
|
ret = write( ntdll_get_thread_data()->wait_fd[1], &reply, sizeof(reply) );
|
2003-03-31 03:37:04 +02:00
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-01-18 15:41:05 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* invoke_apc
|
|
|
|
*
|
|
|
|
* Invoke a single APC. Return TRUE if a user APC has been run.
|
|
|
|
*/
|
|
|
|
static BOOL invoke_apc( const apc_call_t *call, apc_result_t *result )
|
|
|
|
{
|
|
|
|
BOOL user_apc = FALSE;
|
2008-12-17 19:25:09 +01:00
|
|
|
SIZE_T size;
|
2008-12-30 15:05:38 +01:00
|
|
|
void *addr;
|
2007-01-18 15:41:05 +01:00
|
|
|
|
|
|
|
memset( result, 0, sizeof(*result) );
|
|
|
|
|
|
|
|
switch (call->type)
|
|
|
|
{
|
2007-07-16 16:14:45 +02:00
|
|
|
case APC_NONE:
|
|
|
|
break;
|
2007-01-18 15:41:05 +01:00
|
|
|
case APC_USER:
|
2008-12-30 21:09:41 +01:00
|
|
|
{
|
|
|
|
void (WINAPI *func)(ULONG_PTR,ULONG_PTR,ULONG_PTR) = wine_server_get_ptr( call->user.func );
|
|
|
|
func( call->user.args[0], call->user.args[1], call->user.args[2] );
|
2007-01-18 15:41:05 +01:00
|
|
|
user_apc = TRUE;
|
|
|
|
break;
|
2008-12-30 21:09:41 +01:00
|
|
|
}
|
2007-01-18 15:41:05 +01:00
|
|
|
case APC_TIMER:
|
2008-12-29 17:43:01 +01:00
|
|
|
{
|
|
|
|
void (WINAPI *func)(void*, unsigned int, unsigned int) = wine_server_get_ptr( call->timer.func );
|
|
|
|
func( wine_server_get_ptr( call->timer.arg ),
|
|
|
|
(DWORD)call->timer.time, (DWORD)(call->timer.time >> 32) );
|
2007-01-18 15:41:05 +01:00
|
|
|
user_apc = TRUE;
|
|
|
|
break;
|
2008-12-29 17:43:01 +01:00
|
|
|
}
|
2007-01-18 15:41:05 +01:00
|
|
|
case APC_ASYNC_IO:
|
2008-12-30 20:51:55 +01:00
|
|
|
{
|
|
|
|
void *apc = NULL;
|
2008-12-30 21:09:41 +01:00
|
|
|
IO_STATUS_BLOCK *iosb = wine_server_get_ptr( call->async_io.sb );
|
|
|
|
NTSTATUS (*func)(void *, IO_STATUS_BLOCK *, NTSTATUS, void **) = wine_server_get_ptr( call->async_io.func );
|
2007-03-20 19:27:10 +01:00
|
|
|
result->type = call->type;
|
2008-12-30 21:09:41 +01:00
|
|
|
result->async_io.status = func( wine_server_get_ptr( call->async_io.user ),
|
|
|
|
iosb, call->async_io.status, &apc );
|
2008-12-30 20:51:55 +01:00
|
|
|
if (result->async_io.status != STATUS_PENDING)
|
|
|
|
{
|
|
|
|
result->async_io.total = iosb->Information;
|
2008-12-30 21:09:41 +01:00
|
|
|
result->async_io.apc = wine_server_client_ptr( apc );
|
2008-12-30 20:51:55 +01:00
|
|
|
}
|
2007-01-18 15:41:05 +01:00
|
|
|
break;
|
2008-12-30 20:51:55 +01:00
|
|
|
}
|
2007-01-18 15:41:05 +01:00
|
|
|
case APC_VIRTUAL_ALLOC:
|
|
|
|
result->type = call->type;
|
2008-12-30 15:05:38 +01:00
|
|
|
addr = wine_server_get_ptr( call->virtual_alloc.addr );
|
2008-12-17 19:25:09 +01:00
|
|
|
size = call->virtual_alloc.size;
|
2008-12-30 15:05:38 +01:00
|
|
|
if ((ULONG_PTR)addr == call->virtual_alloc.addr && size == call->virtual_alloc.size)
|
2008-12-17 19:25:09 +01:00
|
|
|
{
|
2008-12-30 15:05:38 +01:00
|
|
|
result->virtual_alloc.status = NtAllocateVirtualMemory( NtCurrentProcess(), &addr,
|
|
|
|
call->virtual_alloc.zero_bits, &size,
|
2008-12-17 19:25:09 +01:00
|
|
|
call->virtual_alloc.op_type,
|
|
|
|
call->virtual_alloc.prot );
|
2008-12-30 15:05:38 +01:00
|
|
|
result->virtual_alloc.addr = wine_server_client_ptr( addr );
|
2008-12-17 19:25:09 +01:00
|
|
|
result->virtual_alloc.size = size;
|
|
|
|
}
|
|
|
|
else result->virtual_alloc.status = STATUS_WORKING_SET_LIMIT_RANGE;
|
2007-01-18 15:41:05 +01:00
|
|
|
break;
|
|
|
|
case APC_VIRTUAL_FREE:
|
|
|
|
result->type = call->type;
|
2008-12-30 15:05:38 +01:00
|
|
|
addr = wine_server_get_ptr( call->virtual_free.addr );
|
2008-12-17 19:25:09 +01:00
|
|
|
size = call->virtual_free.size;
|
2008-12-30 15:05:38 +01:00
|
|
|
if ((ULONG_PTR)addr == call->virtual_free.addr && size == call->virtual_free.size)
|
2008-12-17 19:25:09 +01:00
|
|
|
{
|
2008-12-30 15:05:38 +01:00
|
|
|
result->virtual_free.status = NtFreeVirtualMemory( NtCurrentProcess(), &addr, &size,
|
2008-12-17 19:25:09 +01:00
|
|
|
call->virtual_free.op_type );
|
2008-12-30 15:05:38 +01:00
|
|
|
result->virtual_free.addr = wine_server_client_ptr( addr );
|
2008-12-17 19:25:09 +01:00
|
|
|
result->virtual_free.size = size;
|
|
|
|
}
|
|
|
|
else result->virtual_free.status = STATUS_INVALID_PARAMETER;
|
2007-01-18 15:41:05 +01:00
|
|
|
break;
|
|
|
|
case APC_VIRTUAL_QUERY:
|
|
|
|
{
|
|
|
|
MEMORY_BASIC_INFORMATION info;
|
|
|
|
result->type = call->type;
|
2008-12-30 15:05:38 +01:00
|
|
|
addr = wine_server_get_ptr( call->virtual_query.addr );
|
|
|
|
if ((ULONG_PTR)addr == call->virtual_query.addr)
|
|
|
|
result->virtual_query.status = NtQueryVirtualMemory( NtCurrentProcess(),
|
|
|
|
addr, MemoryBasicInformation, &info,
|
|
|
|
sizeof(info), NULL );
|
|
|
|
else
|
|
|
|
result->virtual_query.status = STATUS_WORKING_SET_LIMIT_RANGE;
|
|
|
|
|
2007-01-18 15:41:05 +01:00
|
|
|
if (result->virtual_query.status == STATUS_SUCCESS)
|
|
|
|
{
|
2008-12-30 15:05:38 +01:00
|
|
|
result->virtual_query.base = wine_server_client_ptr( info.BaseAddress );
|
|
|
|
result->virtual_query.alloc_base = wine_server_client_ptr( info.AllocationBase );
|
2007-01-18 15:41:05 +01:00
|
|
|
result->virtual_query.size = info.RegionSize;
|
|
|
|
result->virtual_query.prot = info.Protect;
|
|
|
|
result->virtual_query.alloc_prot = info.AllocationProtect;
|
2008-12-30 15:22:45 +01:00
|
|
|
result->virtual_query.state = info.State >> 12;
|
|
|
|
result->virtual_query.alloc_type = info.Type >> 16;
|
2007-01-18 15:41:05 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case APC_VIRTUAL_PROTECT:
|
|
|
|
result->type = call->type;
|
2008-12-30 15:05:38 +01:00
|
|
|
addr = wine_server_get_ptr( call->virtual_protect.addr );
|
2008-12-17 19:25:09 +01:00
|
|
|
size = call->virtual_protect.size;
|
2008-12-30 15:05:38 +01:00
|
|
|
if ((ULONG_PTR)addr == call->virtual_protect.addr && size == call->virtual_protect.size)
|
2008-12-17 19:25:09 +01:00
|
|
|
{
|
2008-12-30 15:05:38 +01:00
|
|
|
result->virtual_protect.status = NtProtectVirtualMemory( NtCurrentProcess(), &addr, &size,
|
2008-12-17 19:25:09 +01:00
|
|
|
call->virtual_protect.prot,
|
|
|
|
&result->virtual_protect.prot );
|
2008-12-30 15:05:38 +01:00
|
|
|
result->virtual_protect.addr = wine_server_client_ptr( addr );
|
2008-12-17 19:25:09 +01:00
|
|
|
result->virtual_protect.size = size;
|
|
|
|
}
|
|
|
|
else result->virtual_protect.status = STATUS_INVALID_PARAMETER;
|
2007-01-18 15:41:05 +01:00
|
|
|
break;
|
|
|
|
case APC_VIRTUAL_FLUSH:
|
|
|
|
result->type = call->type;
|
2008-12-30 15:05:38 +01:00
|
|
|
addr = wine_server_get_ptr( call->virtual_flush.addr );
|
2008-12-17 19:25:09 +01:00
|
|
|
size = call->virtual_flush.size;
|
2008-12-30 15:05:38 +01:00
|
|
|
if ((ULONG_PTR)addr == call->virtual_flush.addr && size == call->virtual_flush.size)
|
2008-12-17 19:25:09 +01:00
|
|
|
{
|
|
|
|
result->virtual_flush.status = NtFlushVirtualMemory( NtCurrentProcess(),
|
2008-12-30 15:05:38 +01:00
|
|
|
(const void **)&addr, &size, 0 );
|
|
|
|
result->virtual_flush.addr = wine_server_client_ptr( addr );
|
2008-12-17 19:25:09 +01:00
|
|
|
result->virtual_flush.size = size;
|
|
|
|
}
|
|
|
|
else result->virtual_flush.status = STATUS_INVALID_PARAMETER;
|
2007-01-18 15:41:05 +01:00
|
|
|
break;
|
|
|
|
case APC_VIRTUAL_LOCK:
|
|
|
|
result->type = call->type;
|
2008-12-30 15:05:38 +01:00
|
|
|
addr = wine_server_get_ptr( call->virtual_lock.addr );
|
2008-12-17 19:25:09 +01:00
|
|
|
size = call->virtual_lock.size;
|
2008-12-30 15:05:38 +01:00
|
|
|
if ((ULONG_PTR)addr == call->virtual_lock.addr && size == call->virtual_lock.size)
|
2008-12-17 19:25:09 +01:00
|
|
|
{
|
2008-12-30 15:05:38 +01:00
|
|
|
result->virtual_lock.status = NtLockVirtualMemory( NtCurrentProcess(), &addr, &size, 0 );
|
|
|
|
result->virtual_lock.addr = wine_server_client_ptr( addr );
|
2008-12-17 19:25:09 +01:00
|
|
|
result->virtual_lock.size = size;
|
|
|
|
}
|
|
|
|
else result->virtual_lock.status = STATUS_INVALID_PARAMETER;
|
2007-01-18 15:41:05 +01:00
|
|
|
break;
|
|
|
|
case APC_VIRTUAL_UNLOCK:
|
|
|
|
result->type = call->type;
|
2008-12-30 15:05:38 +01:00
|
|
|
addr = wine_server_get_ptr( call->virtual_unlock.addr );
|
2008-12-17 19:25:09 +01:00
|
|
|
size = call->virtual_unlock.size;
|
2008-12-30 15:05:38 +01:00
|
|
|
if ((ULONG_PTR)addr == call->virtual_unlock.addr && size == call->virtual_unlock.size)
|
2008-12-17 19:25:09 +01:00
|
|
|
{
|
2008-12-30 15:05:38 +01:00
|
|
|
result->virtual_unlock.status = NtUnlockVirtualMemory( NtCurrentProcess(), &addr, &size, 0 );
|
|
|
|
result->virtual_unlock.addr = wine_server_client_ptr( addr );
|
2008-12-17 19:25:09 +01:00
|
|
|
result->virtual_unlock.size = size;
|
|
|
|
}
|
|
|
|
else result->virtual_unlock.status = STATUS_INVALID_PARAMETER;
|
2007-01-18 15:41:05 +01:00
|
|
|
break;
|
|
|
|
case APC_MAP_VIEW:
|
|
|
|
result->type = call->type;
|
2008-12-30 15:05:38 +01:00
|
|
|
addr = wine_server_get_ptr( call->map_view.addr );
|
2008-12-17 19:25:09 +01:00
|
|
|
size = call->map_view.size;
|
2008-12-30 15:05:38 +01:00
|
|
|
if ((ULONG_PTR)addr == call->map_view.addr && size == call->map_view.size)
|
2008-12-17 19:25:09 +01:00
|
|
|
{
|
2008-12-30 15:05:38 +01:00
|
|
|
LARGE_INTEGER offset;
|
|
|
|
offset.QuadPart = call->map_view.offset;
|
2008-12-17 19:25:09 +01:00
|
|
|
result->map_view.status = NtMapViewOfSection( wine_server_ptr_handle(call->map_view.handle),
|
2008-12-30 15:05:38 +01:00
|
|
|
NtCurrentProcess(), &addr,
|
2008-12-17 19:25:09 +01:00
|
|
|
call->map_view.zero_bits, 0,
|
|
|
|
&offset, &size, ViewShare,
|
|
|
|
call->map_view.alloc_type, call->map_view.prot );
|
2008-12-30 15:05:38 +01:00
|
|
|
result->map_view.addr = wine_server_client_ptr( addr );
|
|
|
|
result->map_view.size = size;
|
2008-12-17 19:25:09 +01:00
|
|
|
}
|
|
|
|
else result->map_view.status = STATUS_INVALID_PARAMETER;
|
2008-12-08 16:05:17 +01:00
|
|
|
NtClose( wine_server_ptr_handle(call->map_view.handle) );
|
2007-01-18 15:41:05 +01:00
|
|
|
break;
|
|
|
|
case APC_UNMAP_VIEW:
|
|
|
|
result->type = call->type;
|
2008-12-30 15:05:38 +01:00
|
|
|
addr = wine_server_get_ptr( call->unmap_view.addr );
|
|
|
|
if ((ULONG_PTR)addr == call->unmap_view.addr)
|
|
|
|
result->unmap_view.status = NtUnmapViewOfSection( NtCurrentProcess(), addr );
|
|
|
|
else
|
|
|
|
result->unmap_view.status = STATUS_INVALID_PARAMETER;
|
2007-01-18 15:41:05 +01:00
|
|
|
break;
|
|
|
|
case APC_CREATE_THREAD:
|
|
|
|
{
|
|
|
|
CLIENT_ID id;
|
2008-12-08 16:05:17 +01:00
|
|
|
HANDLE handle;
|
2008-12-17 19:25:09 +01:00
|
|
|
SIZE_T reserve = call->create_thread.reserve;
|
|
|
|
SIZE_T commit = call->create_thread.commit;
|
2008-12-30 15:30:11 +01:00
|
|
|
void *func = wine_server_get_ptr( call->create_thread.func );
|
|
|
|
void *arg = wine_server_get_ptr( call->create_thread.arg );
|
2008-12-17 19:25:09 +01:00
|
|
|
|
2007-01-18 15:41:05 +01:00
|
|
|
result->type = call->type;
|
2008-12-30 15:30:11 +01:00
|
|
|
if (reserve == call->create_thread.reserve && commit == call->create_thread.commit &&
|
|
|
|
(ULONG_PTR)func == call->create_thread.func && (ULONG_PTR)arg == call->create_thread.arg)
|
2008-12-17 19:25:09 +01:00
|
|
|
{
|
|
|
|
result->create_thread.status = RtlCreateUserThread( NtCurrentProcess(), NULL,
|
|
|
|
call->create_thread.suspend, NULL,
|
2008-12-30 15:30:11 +01:00
|
|
|
reserve, commit, func, arg, &handle, &id );
|
2008-12-17 19:25:09 +01:00
|
|
|
result->create_thread.handle = wine_server_obj_handle( handle );
|
|
|
|
result->create_thread.tid = HandleToULong(id.UniqueThread);
|
|
|
|
}
|
|
|
|
else result->create_thread.status = STATUS_INVALID_PARAMETER;
|
2007-01-18 15:41:05 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
server_protocol_error( "get_apc_request: bad type %d\n", call->type );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return user_apc;
|
|
|
|
}
|
|
|
|
|
2007-01-15 22:26:32 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* NTDLL_queue_process_apc
|
|
|
|
*/
|
|
|
|
NTSTATUS NTDLL_queue_process_apc( HANDLE process, const apc_call_t *call, apc_result_t *result )
|
|
|
|
{
|
|
|
|
for (;;)
|
|
|
|
{
|
|
|
|
NTSTATUS ret;
|
|
|
|
HANDLE handle = 0;
|
2007-01-18 15:41:05 +01:00
|
|
|
BOOL self = FALSE;
|
2007-01-15 22:26:32 +01:00
|
|
|
|
|
|
|
SERVER_START_REQ( queue_apc )
|
|
|
|
{
|
2008-12-26 12:19:41 +01:00
|
|
|
req->handle = wine_server_obj_handle( process );
|
2007-01-15 22:26:32 +01:00
|
|
|
req->call = *call;
|
2007-01-18 15:41:05 +01:00
|
|
|
if (!(ret = wine_server_call( req )))
|
|
|
|
{
|
2008-12-08 16:05:17 +01:00
|
|
|
handle = wine_server_ptr_handle( reply->handle );
|
2007-01-18 15:41:05 +01:00
|
|
|
self = reply->self;
|
|
|
|
}
|
2007-01-15 22:26:32 +01:00
|
|
|
}
|
|
|
|
SERVER_END_REQ;
|
2007-01-18 15:41:05 +01:00
|
|
|
if (ret != STATUS_SUCCESS) return ret;
|
2007-01-15 22:26:32 +01:00
|
|
|
|
2007-01-18 15:41:05 +01:00
|
|
|
if (self)
|
2007-01-15 22:26:32 +01:00
|
|
|
{
|
2007-01-18 15:41:05 +01:00
|
|
|
invoke_apc( call, result );
|
2007-01-15 22:26:32 +01:00
|
|
|
}
|
2007-01-18 15:41:05 +01:00
|
|
|
else
|
|
|
|
{
|
|
|
|
NtWaitForSingleObject( handle, FALSE, NULL );
|
2007-01-15 22:26:32 +01:00
|
|
|
|
2007-01-18 15:41:05 +01:00
|
|
|
SERVER_START_REQ( get_apc_result )
|
|
|
|
{
|
2008-12-08 16:05:17 +01:00
|
|
|
req->handle = wine_server_obj_handle( handle );
|
2007-01-18 15:41:05 +01:00
|
|
|
if (!(ret = wine_server_call( req ))) *result = reply->result;
|
|
|
|
}
|
|
|
|
SERVER_END_REQ;
|
|
|
|
|
|
|
|
if (!ret && result->type == APC_NONE) continue; /* APC didn't run, try again */
|
|
|
|
if (ret) NtClose( handle );
|
|
|
|
}
|
2007-01-15 22:26:32 +01:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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,
|
2005-04-24 19:35:52 +02:00
|
|
|
const LARGE_INTEGER *timeout, HANDLE signal_object )
|
2003-03-31 03:37:04 +02:00
|
|
|
{
|
2003-06-30 23:00:15 +02:00
|
|
|
NTSTATUS ret;
|
2008-12-11 20:38:21 +01:00
|
|
|
int i, cookie;
|
2007-07-16 16:14:45 +02:00
|
|
|
BOOL user_apc = FALSE;
|
2008-12-11 20:38:21 +01:00
|
|
|
obj_handle_t obj_handles[MAXIMUM_WAIT_OBJECTS];
|
2007-07-16 16:14:45 +02:00
|
|
|
obj_handle_t apc_handle = 0;
|
|
|
|
apc_call_t call;
|
|
|
|
apc_result_t result;
|
2007-04-17 20:08:59 +02:00
|
|
|
timeout_t abs_timeout = timeout ? timeout->QuadPart : TIMEOUT_INFINITE;
|
2003-03-31 03:37:04 +02:00
|
|
|
|
2007-07-16 16:14:45 +02:00
|
|
|
memset( &result, 0, sizeof(result) );
|
2008-12-11 20:38:21 +01:00
|
|
|
for (i = 0; i < count; i++) obj_handles[i] = wine_server_obj_handle( handles[i] );
|
2007-07-16 16:14:45 +02:00
|
|
|
|
2003-03-31 03:37:04 +02:00
|
|
|
for (;;)
|
|
|
|
{
|
|
|
|
SERVER_START_REQ( select )
|
|
|
|
{
|
2007-07-16 16:14:45 +02:00
|
|
|
req->flags = flags;
|
2008-12-29 17:19:26 +01:00
|
|
|
req->cookie = wine_server_client_ptr( &cookie );
|
2008-12-08 16:05:17 +01:00
|
|
|
req->signal = wine_server_obj_handle( signal_object );
|
2007-07-16 16:14:45 +02:00
|
|
|
req->prev_apc = apc_handle;
|
|
|
|
req->timeout = abs_timeout;
|
|
|
|
wine_server_add_data( req, &result, sizeof(result) );
|
2008-12-11 20:38:21 +01:00
|
|
|
wine_server_add_data( req, obj_handles, count * sizeof(*obj_handles) );
|
2003-03-31 03:37:04 +02:00
|
|
|
ret = wine_server_call( req );
|
2007-04-17 20:08:59 +02:00
|
|
|
abs_timeout = reply->timeout;
|
2007-07-16 16:14:45 +02:00
|
|
|
apc_handle = reply->apc_handle;
|
|
|
|
call = reply->call;
|
2003-03-31 03:37:04 +02:00
|
|
|
}
|
|
|
|
SERVER_END_REQ;
|
|
|
|
if (ret == STATUS_PENDING) ret = wait_reply( &cookie );
|
|
|
|
if (ret != STATUS_USER_APC) break;
|
2007-07-16 16:14:45 +02:00
|
|
|
if (invoke_apc( &call, &result ))
|
|
|
|
{
|
|
|
|
/* if we ran a user apc we have to check once more if an object got signaled,
|
|
|
|
* but we don't want to wait */
|
|
|
|
abs_timeout = 0;
|
|
|
|
user_apc = TRUE;
|
|
|
|
}
|
2005-04-24 19:35:52 +02:00
|
|
|
signal_object = 0; /* don't signal it multiple times */
|
2003-03-31 03:37:04 +02:00
|
|
|
}
|
2004-11-02 20:32:03 +01:00
|
|
|
|
2007-07-16 16:14:45 +02:00
|
|
|
if (ret == STATUS_TIMEOUT && user_apc) ret = STATUS_USER_APC;
|
|
|
|
|
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. */
|
2007-07-16 16:14:45 +02:00
|
|
|
if (ret == STATUS_TIMEOUT) NtYieldExecution();
|
2004-11-02 20:32:03 +01:00
|
|
|
|
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;
|
2005-04-24 19:35:52 +02:00
|
|
|
return NTDLL_wait_for_multiple_objects( count, handles, flags, timeout, 0 );
|
2003-06-30 23:00:15 +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
|
|
|
{
|
|
|
|
return NtWaitForMultipleObjects( 1, &handle, FALSE, alertable, timeout );
|
|
|
|
}
|
2003-06-30 23:00:15 +02:00
|
|
|
|
|
|
|
|
2005-04-24 19:35:52 +02:00
|
|
|
/******************************************************************
|
|
|
|
* NtSignalAndWaitForSingleObject (NTDLL.@)
|
|
|
|
*/
|
|
|
|
NTSTATUS WINAPI NtSignalAndWaitForSingleObject( HANDLE hSignalObject, HANDLE hWaitObject,
|
|
|
|
BOOLEAN alertable, const LARGE_INTEGER *timeout )
|
|
|
|
{
|
|
|
|
UINT flags = SELECT_INTERRUPTIBLE;
|
|
|
|
|
|
|
|
if (!hSignalObject) return STATUS_INVALID_HANDLE;
|
|
|
|
if (alertable) flags |= SELECT_ALERTABLE;
|
|
|
|
return NTDLL_wait_for_multiple_objects( 1, &hWaitObject, flags, timeout, hSignalObject );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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 )
|
|
|
|
{
|
2007-06-04 18:17:16 +02:00
|
|
|
/* if alertable, we need to query the server */
|
|
|
|
if (alertable)
|
|
|
|
return NTDLL_wait_for_multiple_objects( 0, NULL, SELECT_INTERRUPTIBLE | SELECT_ALERTABLE,
|
|
|
|
timeout, 0 );
|
2003-06-30 23:00:15 +02:00
|
|
|
|
2007-04-17 20:08:59 +02:00
|
|
|
if (!timeout || timeout->QuadPart == TIMEOUT_INFINITE) /* sleep forever */
|
2003-06-30 23:00:15 +02:00
|
|
|
{
|
|
|
|
for (;;) select( 0, NULL, NULL, NULL, NULL );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2007-04-17 20:08:59 +02:00
|
|
|
LARGE_INTEGER now;
|
|
|
|
timeout_t when, diff;
|
2003-06-30 23:00:15 +02:00
|
|
|
|
2007-04-17 20:08:59 +02:00
|
|
|
if ((when = timeout->QuadPart) < 0)
|
|
|
|
{
|
|
|
|
NtQuerySystemTime( &now );
|
|
|
|
when = now.QuadPart - when;
|
|
|
|
}
|
2004-11-02 20:32:03 +01:00
|
|
|
|
|
|
|
/* Note that we yield after establishing the desired timeout */
|
|
|
|
NtYieldExecution();
|
2007-04-17 20:08:59 +02:00
|
|
|
if (!when) return STATUS_SUCCESS;
|
2004-11-02 20:32:03 +01:00
|
|
|
|
2003-06-30 23:00:15 +02:00
|
|
|
for (;;)
|
|
|
|
{
|
|
|
|
struct timeval tv;
|
2007-04-17 20:08:59 +02:00
|
|
|
NtQuerySystemTime( &now );
|
|
|
|
diff = (when - now.QuadPart + 9) / 10;
|
|
|
|
if (diff <= 0) break;
|
|
|
|
tv.tv_sec = diff / 1000000;
|
|
|
|
tv.tv_usec = diff % 1000000;
|
2003-06-30 23:00:15 +02:00
|
|
|
if (select( 0, NULL, NULL, NULL, &tv ) != -1) break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return STATUS_SUCCESS;
|
|
|
|
}
|
2006-04-19 10:26:11 +02:00
|
|
|
|
2006-05-12 00:34:55 +02:00
|
|
|
/******************************************************************
|
2007-06-02 00:30:14 +02:00
|
|
|
* NtCreateIoCompletion (NTDLL.@)
|
|
|
|
* ZwCreateIoCompletion (NTDLL.@)
|
|
|
|
*
|
|
|
|
* Creates I/O completion object.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* CompletionPort [O] created completion object handle will be placed there
|
|
|
|
* DesiredAccess [I] desired access to a handle (combination of IO_COMPLETION_*)
|
|
|
|
* ObjectAttributes [I] completion object attributes
|
|
|
|
* NumberOfConcurrentThreads [I] desired number of concurrent active worker threads
|
|
|
|
*
|
2006-05-12 00:34:55 +02:00
|
|
|
*/
|
2006-04-19 10:26:11 +02:00
|
|
|
NTSTATUS WINAPI NtCreateIoCompletion( PHANDLE CompletionPort, ACCESS_MASK DesiredAccess,
|
|
|
|
POBJECT_ATTRIBUTES ObjectAttributes, ULONG NumberOfConcurrentThreads )
|
|
|
|
{
|
2007-09-17 22:00:45 +02:00
|
|
|
NTSTATUS status;
|
|
|
|
|
|
|
|
TRACE("(%p, %x, %p, %d)\n", CompletionPort, DesiredAccess,
|
2006-04-19 10:26:11 +02:00
|
|
|
ObjectAttributes, NumberOfConcurrentThreads);
|
2007-09-17 22:00:45 +02:00
|
|
|
|
|
|
|
if (!CompletionPort)
|
|
|
|
return STATUS_INVALID_PARAMETER;
|
|
|
|
|
|
|
|
SERVER_START_REQ( create_completion )
|
|
|
|
{
|
|
|
|
req->access = DesiredAccess;
|
|
|
|
req->attributes = ObjectAttributes ? ObjectAttributes->Attributes : 0;
|
2008-12-08 16:05:17 +01:00
|
|
|
req->rootdir = wine_server_obj_handle( ObjectAttributes ? ObjectAttributes->RootDirectory : 0 );
|
2007-09-17 22:00:45 +02:00
|
|
|
req->concurrent = NumberOfConcurrentThreads;
|
|
|
|
if (ObjectAttributes && ObjectAttributes->ObjectName)
|
|
|
|
wine_server_add_data( req, ObjectAttributes->ObjectName->Buffer,
|
|
|
|
ObjectAttributes->ObjectName->Length );
|
|
|
|
if (!(status = wine_server_call( req )))
|
2008-12-08 16:05:17 +01:00
|
|
|
*CompletionPort = wine_server_ptr_handle( reply->handle );
|
2007-09-17 22:00:45 +02:00
|
|
|
}
|
|
|
|
SERVER_END_REQ;
|
|
|
|
return status;
|
2006-04-19 10:26:11 +02:00
|
|
|
}
|
|
|
|
|
2007-06-02 00:30:14 +02:00
|
|
|
/******************************************************************
|
|
|
|
* NtSetIoCompletion (NTDLL.@)
|
|
|
|
* ZwSetIoCompletion (NTDLL.@)
|
|
|
|
*
|
|
|
|
* Inserts completion message into queue
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* CompletionPort [I] HANDLE to completion object
|
|
|
|
* CompletionKey [I] completion key
|
|
|
|
* CompletionValue [I] completion value (usually pointer to OVERLAPPED)
|
|
|
|
* Status [I] operation status
|
|
|
|
* NumberOfBytesTransferred [I] number of bytes transferred
|
|
|
|
*/
|
2006-04-19 10:26:11 +02:00
|
|
|
NTSTATUS WINAPI NtSetIoCompletion( HANDLE CompletionPort, ULONG_PTR CompletionKey,
|
2007-06-02 00:30:14 +02:00
|
|
|
ULONG_PTR CompletionValue, NTSTATUS Status,
|
2007-09-17 22:00:45 +02:00
|
|
|
ULONG NumberOfBytesTransferred )
|
2006-04-19 10:26:11 +02:00
|
|
|
{
|
2007-09-17 22:00:45 +02:00
|
|
|
NTSTATUS status;
|
|
|
|
|
|
|
|
TRACE("(%p, %lx, %lx, %x, %d)\n", CompletionPort, CompletionKey,
|
|
|
|
CompletionValue, Status, NumberOfBytesTransferred);
|
|
|
|
|
|
|
|
SERVER_START_REQ( add_completion )
|
|
|
|
{
|
2008-12-08 16:05:17 +01:00
|
|
|
req->handle = wine_server_obj_handle( CompletionPort );
|
2007-09-17 22:00:45 +02:00
|
|
|
req->ckey = CompletionKey;
|
|
|
|
req->cvalue = CompletionValue;
|
|
|
|
req->status = Status;
|
|
|
|
req->information = NumberOfBytesTransferred;
|
|
|
|
status = wine_server_call( req );
|
|
|
|
}
|
|
|
|
SERVER_END_REQ;
|
|
|
|
return status;
|
2006-04-19 10:26:11 +02:00
|
|
|
}
|
|
|
|
|
2007-06-02 00:30:14 +02:00
|
|
|
/******************************************************************
|
|
|
|
* NtRemoveIoCompletion (NTDLL.@)
|
|
|
|
* ZwRemoveIoCompletion (NTDLL.@)
|
|
|
|
*
|
|
|
|
* (Wait for and) retrieve first completion message from completion object's queue
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* CompletionPort [I] HANDLE to I/O completion object
|
|
|
|
* CompletionKey [O] completion key
|
|
|
|
* CompletionValue [O] Completion value given in NtSetIoCompletion or in async operation
|
|
|
|
* iosb [O] IO_STATUS_BLOCK of completed asynchronous operation
|
|
|
|
* WaitTime [I] optional wait time in NTDLL format
|
|
|
|
*
|
|
|
|
*/
|
2006-04-19 10:26:11 +02:00
|
|
|
NTSTATUS WINAPI NtRemoveIoCompletion( HANDLE CompletionPort, PULONG_PTR CompletionKey,
|
2007-06-02 00:30:14 +02:00
|
|
|
PULONG_PTR CompletionValue, PIO_STATUS_BLOCK iosb,
|
2006-04-19 10:26:11 +02:00
|
|
|
PLARGE_INTEGER WaitTime )
|
|
|
|
{
|
2007-09-17 22:00:45 +02:00
|
|
|
NTSTATUS status;
|
|
|
|
|
|
|
|
TRACE("(%p, %p, %p, %p, %p)\n", CompletionPort, CompletionKey,
|
2007-06-02 00:30:14 +02:00
|
|
|
CompletionValue, iosb, WaitTime);
|
2007-09-17 22:00:45 +02:00
|
|
|
|
|
|
|
for(;;)
|
|
|
|
{
|
|
|
|
SERVER_START_REQ( remove_completion )
|
|
|
|
{
|
2008-12-08 16:05:17 +01:00
|
|
|
req->handle = wine_server_obj_handle( CompletionPort );
|
2007-09-17 22:00:45 +02:00
|
|
|
if (!(status = wine_server_call( req )))
|
|
|
|
{
|
|
|
|
*CompletionKey = reply->ckey;
|
|
|
|
*CompletionValue = reply->cvalue;
|
|
|
|
iosb->Information = reply->information;
|
|
|
|
iosb->u.Status = reply->status;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
SERVER_END_REQ;
|
|
|
|
if (status != STATUS_PENDING) break;
|
|
|
|
|
|
|
|
status = NtWaitForSingleObject( CompletionPort, FALSE, WaitTime );
|
|
|
|
if (status != WAIT_OBJECT_0) break;
|
|
|
|
}
|
|
|
|
return status;
|
2007-06-02 00:30:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************
|
|
|
|
* NtOpenIoCompletion (NTDLL.@)
|
|
|
|
* ZwOpenIoCompletion (NTDLL.@)
|
|
|
|
*
|
|
|
|
* Opens I/O completion object
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* CompletionPort [O] completion object handle will be placed there
|
|
|
|
* DesiredAccess [I] desired access to a handle (combination of IO_COMPLETION_*)
|
|
|
|
* ObjectAttributes [I] completion object name
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
NTSTATUS WINAPI NtOpenIoCompletion( PHANDLE CompletionPort, ACCESS_MASK DesiredAccess,
|
|
|
|
POBJECT_ATTRIBUTES ObjectAttributes )
|
|
|
|
{
|
2007-09-17 22:00:45 +02:00
|
|
|
NTSTATUS status;
|
|
|
|
|
|
|
|
TRACE("(%p, 0x%x, %p)\n", CompletionPort, DesiredAccess, ObjectAttributes);
|
|
|
|
|
|
|
|
if (!CompletionPort || !ObjectAttributes || !ObjectAttributes->ObjectName)
|
|
|
|
return STATUS_INVALID_PARAMETER;
|
|
|
|
|
|
|
|
SERVER_START_REQ( open_completion )
|
|
|
|
{
|
|
|
|
req->access = DesiredAccess;
|
2008-12-08 16:05:17 +01:00
|
|
|
req->rootdir = wine_server_obj_handle( ObjectAttributes->RootDirectory );
|
2007-09-17 22:00:45 +02:00
|
|
|
wine_server_add_data( req, ObjectAttributes->ObjectName->Buffer,
|
|
|
|
ObjectAttributes->ObjectName->Length );
|
|
|
|
if (!(status = wine_server_call( req )))
|
2008-12-08 16:05:17 +01:00
|
|
|
*CompletionPort = wine_server_ptr_handle( reply->handle );
|
2007-09-17 22:00:45 +02:00
|
|
|
}
|
|
|
|
SERVER_END_REQ;
|
|
|
|
return status;
|
2007-06-02 00:30:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************
|
|
|
|
* NtQueryIoCompletion (NTDLL.@)
|
|
|
|
* ZwQueryIoCompletion (NTDLL.@)
|
|
|
|
*
|
|
|
|
* Requests information about given I/O completion object
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* CompletionPort [I] HANDLE to completion port to request
|
|
|
|
* InformationClass [I] information class
|
|
|
|
* CompletionInformation [O] user-provided buffer for data
|
|
|
|
* BufferLength [I] buffer length
|
|
|
|
* RequiredLength [O] required buffer length
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
NTSTATUS WINAPI NtQueryIoCompletion( HANDLE CompletionPort, IO_COMPLETION_INFORMATION_CLASS InformationClass,
|
|
|
|
PVOID CompletionInformation, ULONG BufferLength, PULONG RequiredLength )
|
|
|
|
{
|
2007-09-17 22:00:45 +02:00
|
|
|
NTSTATUS status;
|
|
|
|
|
|
|
|
TRACE("(%p, %d, %p, 0x%x, %p)\n", CompletionPort, InformationClass, CompletionInformation,
|
|
|
|
BufferLength, RequiredLength);
|
|
|
|
|
|
|
|
if (!CompletionInformation) return STATUS_INVALID_PARAMETER;
|
|
|
|
switch( InformationClass )
|
|
|
|
{
|
|
|
|
case IoCompletionBasicInformation:
|
|
|
|
{
|
|
|
|
ULONG *info = (ULONG *)CompletionInformation;
|
|
|
|
|
|
|
|
if (RequiredLength) *RequiredLength = sizeof(*info);
|
|
|
|
if (BufferLength != sizeof(*info))
|
|
|
|
status = STATUS_INFO_LENGTH_MISMATCH;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
SERVER_START_REQ( query_completion )
|
|
|
|
{
|
2008-12-08 16:05:17 +01:00
|
|
|
req->handle = wine_server_obj_handle( CompletionPort );
|
2007-09-17 22:00:45 +02:00
|
|
|
if (!(status = wine_server_call( req )))
|
|
|
|
*info = reply->depth;
|
|
|
|
}
|
|
|
|
SERVER_END_REQ;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
status = STATUS_INVALID_PARAMETER;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return status;
|
2006-04-19 10:26:11 +02:00
|
|
|
}
|
2007-11-09 23:12:07 +01:00
|
|
|
|
2008-12-15 13:30:25 +01:00
|
|
|
NTSTATUS NTDLL_AddCompletion( HANDLE hFile, ULONG_PTR CompletionValue,
|
|
|
|
NTSTATUS CompletionStatus, ULONG Information )
|
2007-11-09 23:12:07 +01:00
|
|
|
{
|
|
|
|
NTSTATUS status;
|
|
|
|
|
|
|
|
SERVER_START_REQ( add_fd_completion )
|
|
|
|
{
|
2008-12-08 16:05:17 +01:00
|
|
|
req->handle = wine_server_obj_handle( hFile );
|
2007-11-09 23:12:07 +01:00
|
|
|
req->cvalue = CompletionValue;
|
|
|
|
req->status = CompletionStatus;
|
|
|
|
req->information = Information;
|
|
|
|
status = wine_server_call( req );
|
|
|
|
}
|
|
|
|
SERVER_END_REQ;
|
|
|
|
return status;
|
|
|
|
}
|