1999-03-09 18:47:51 +01:00
|
|
|
/*
|
|
|
|
* Object management functions
|
2002-03-10 00:29:33 +01:00
|
|
|
*
|
|
|
|
* Copyright 1999, 2000 Juergen Schmied
|
2005-11-30 19:22:57 +01:00
|
|
|
* Copyright 2005 Vitaliy Margolen
|
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
|
|
|
*/
|
|
|
|
|
2002-08-17 02:43:16 +02:00
|
|
|
#include "config.h"
|
|
|
|
|
2003-09-06 01:08:26 +02:00
|
|
|
#include <stdarg.h>
|
1999-03-09 18:47:51 +01:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
2002-08-26 23:53:24 +02:00
|
|
|
#ifdef HAVE_IO_H
|
|
|
|
# include <io.h>
|
|
|
|
#endif
|
2002-08-17 02:43:16 +02:00
|
|
|
#ifdef HAVE_UNISTD_H
|
|
|
|
# include <unistd.h>
|
|
|
|
#endif
|
1999-03-09 18:47:51 +01:00
|
|
|
|
2005-11-28 17:32:54 +01:00
|
|
|
#include "ntstatus.h"
|
|
|
|
#define WIN32_NO_STATUS
|
|
|
|
#include "wine/debug.h"
|
2003-09-06 01:08:26 +02:00
|
|
|
#include "windef.h"
|
2002-09-13 00:07:02 +02:00
|
|
|
#include "winternl.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"
|
2001-07-19 02:39:09 +02:00
|
|
|
#include "wine/server.h"
|
1999-03-09 18:47:51 +01:00
|
|
|
|
2002-03-10 00:29:33 +01:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(ntdll);
|
1999-04-19 16:56:29 +02:00
|
|
|
|
1999-03-09 18:47:51 +01:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Generic object functions
|
|
|
|
*/
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-03-09 18:47:51 +01:00
|
|
|
/******************************************************************************
|
2001-06-19 20:20:47 +02:00
|
|
|
* NtQueryObject [NTDLL.@]
|
2001-07-11 20:56:41 +02:00
|
|
|
* ZwQueryObject [NTDLL.@]
|
1999-03-09 18:47:51 +01:00
|
|
|
*/
|
2003-05-20 21:20:42 +02:00
|
|
|
NTSTATUS WINAPI NtQueryObject(IN HANDLE handle,
|
|
|
|
IN OBJECT_INFORMATION_CLASS info_class,
|
|
|
|
OUT PVOID ptr, IN ULONG len, OUT PULONG used_len)
|
1999-03-09 18:47:51 +01:00
|
|
|
{
|
2003-05-20 21:20:42 +02:00
|
|
|
NTSTATUS status;
|
|
|
|
|
2006-10-16 13:49:06 +02:00
|
|
|
TRACE("(%p,0x%08x,%p,0x%08x,%p): stub\n",
|
2003-05-20 21:20:42 +02:00
|
|
|
handle, info_class, ptr, len, used_len);
|
|
|
|
|
|
|
|
if (used_len) *used_len = 0;
|
|
|
|
|
|
|
|
switch (info_class)
|
|
|
|
{
|
2007-01-25 07:43:04 +01:00
|
|
|
case ObjectBasicInformation:
|
|
|
|
{
|
|
|
|
POBJECT_BASIC_INFORMATION p = (POBJECT_BASIC_INFORMATION)ptr;
|
|
|
|
|
|
|
|
if (len < sizeof(*p)) return STATUS_INVALID_BUFFER_SIZE;
|
|
|
|
|
|
|
|
SERVER_START_REQ( get_object_info )
|
|
|
|
{
|
|
|
|
req->handle = handle;
|
|
|
|
status = wine_server_call( req );
|
|
|
|
if (status == STATUS_SUCCESS)
|
|
|
|
{
|
|
|
|
memset( p, 0, sizeof(*p) );
|
|
|
|
p->GrantedAccess = reply->access;
|
|
|
|
p->PointerCount = reply->ref_count;
|
|
|
|
p->HandleCount = 1; /* at least one */
|
|
|
|
if (used_len) *used_len = sizeof(*p);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
SERVER_END_REQ;
|
|
|
|
}
|
|
|
|
break;
|
2003-05-20 21:20:42 +02:00
|
|
|
case ObjectDataInformation:
|
|
|
|
{
|
|
|
|
OBJECT_DATA_INFORMATION* p = (OBJECT_DATA_INFORMATION*)ptr;
|
|
|
|
|
|
|
|
if (len < sizeof(*p)) return STATUS_INVALID_BUFFER_SIZE;
|
|
|
|
|
|
|
|
SERVER_START_REQ( set_handle_info )
|
|
|
|
{
|
|
|
|
req->handle = handle;
|
|
|
|
req->flags = 0;
|
|
|
|
req->mask = 0;
|
|
|
|
status = wine_server_call( req );
|
|
|
|
if (status == STATUS_SUCCESS)
|
|
|
|
{
|
|
|
|
p->InheritHandle = (reply->old_flags & HANDLE_FLAG_INHERIT) ? TRUE : FALSE;
|
|
|
|
p->ProtectFromClose = (reply->old_flags & HANDLE_FLAG_PROTECT_FROM_CLOSE) ? TRUE : FALSE;
|
|
|
|
if (used_len) *used_len = sizeof(*p);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
SERVER_END_REQ;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
FIXME("Unsupported information class %u\n", info_class);
|
|
|
|
status = STATUS_NOT_IMPLEMENTED;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************
|
|
|
|
* NtSetInformationObject [NTDLL.@]
|
|
|
|
* ZwSetInformationObject [NTDLL.@]
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
NTSTATUS WINAPI NtSetInformationObject(IN HANDLE handle,
|
|
|
|
IN OBJECT_INFORMATION_CLASS info_class,
|
|
|
|
IN PVOID ptr, IN ULONG len)
|
|
|
|
{
|
|
|
|
NTSTATUS status;
|
|
|
|
|
2006-10-16 13:49:06 +02:00
|
|
|
TRACE("(%p,0x%08x,%p,0x%08x): stub\n",
|
2003-05-20 21:20:42 +02:00
|
|
|
handle, info_class, ptr, len);
|
|
|
|
|
|
|
|
switch (info_class)
|
|
|
|
{
|
|
|
|
case ObjectDataInformation:
|
|
|
|
{
|
|
|
|
OBJECT_DATA_INFORMATION* p = (OBJECT_DATA_INFORMATION*)ptr;
|
|
|
|
|
|
|
|
if (len < sizeof(*p)) return STATUS_INVALID_BUFFER_SIZE;
|
|
|
|
|
|
|
|
SERVER_START_REQ( set_handle_info )
|
|
|
|
{
|
|
|
|
req->handle = handle;
|
|
|
|
req->flags = 0;
|
|
|
|
req->mask = HANDLE_FLAG_INHERIT | HANDLE_FLAG_PROTECT_FROM_CLOSE;
|
|
|
|
if (p->InheritHandle) req->flags |= HANDLE_FLAG_INHERIT;
|
|
|
|
if (p->ProtectFromClose) req->flags |= HANDLE_FLAG_PROTECT_FROM_CLOSE;
|
|
|
|
status = wine_server_call( req );
|
|
|
|
}
|
|
|
|
SERVER_END_REQ;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
FIXME("Unsupported information class %u\n", info_class);
|
|
|
|
status = STATUS_NOT_IMPLEMENTED;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return status;
|
1999-03-09 18:47:51 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
2001-06-21 01:03:14 +02:00
|
|
|
* NtQuerySecurityObject [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
|
|
|
*
|
2003-03-18 19:35:48 +01:00
|
|
|
* An ntdll analogue to GetKernelObjectSecurity().
|
- 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
|
|
|
*/
|
2002-06-01 01:06:46 +02:00
|
|
|
NTSTATUS WINAPI
|
- 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
|
|
|
NtQuerySecurityObject(
|
|
|
|
IN HANDLE Object,
|
|
|
|
IN SECURITY_INFORMATION RequestedInformation,
|
2007-10-02 16:55:13 +02:00
|
|
|
OUT PSECURITY_DESCRIPTOR pSecurityDescriptor,
|
- 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
|
|
|
IN ULONG Length,
|
|
|
|
OUT PULONG ResultLength)
|
1999-03-09 18:47:51 +01:00
|
|
|
{
|
2007-10-02 16:55:13 +02:00
|
|
|
PISECURITY_DESCRIPTOR_RELATIVE psd = pSecurityDescriptor;
|
|
|
|
NTSTATUS status;
|
|
|
|
unsigned int buffer_size = 512;
|
2008-11-03 23:42:42 +01:00
|
|
|
BOOLEAN need_more_memory;
|
- 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-02 16:55:13 +02:00
|
|
|
TRACE("(%p,0x%08x,%p,0x%08x,%p)\n",
|
|
|
|
Object, RequestedInformation, pSecurityDescriptor, Length, ResultLength);
|
- 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-02 16:55:13 +02:00
|
|
|
do
|
|
|
|
{
|
|
|
|
char *buffer = RtlAllocateHeap(GetProcessHeap(), 0, buffer_size);
|
|
|
|
if (!buffer)
|
|
|
|
return STATUS_NO_MEMORY;
|
- 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
|
|
|
|
2008-11-03 23:42:42 +01:00
|
|
|
need_more_memory = FALSE;
|
|
|
|
|
2007-10-02 16:55:13 +02:00
|
|
|
SERVER_START_REQ( get_security_object )
|
|
|
|
{
|
|
|
|
req->handle = Object;
|
|
|
|
req->security_info = RequestedInformation;
|
|
|
|
wine_server_set_reply( req, buffer, buffer_size );
|
|
|
|
status = wine_server_call( req );
|
|
|
|
if (status == STATUS_SUCCESS)
|
|
|
|
{
|
|
|
|
struct security_descriptor *sd = (struct security_descriptor *)buffer;
|
|
|
|
if (reply->sd_len)
|
|
|
|
{
|
|
|
|
*ResultLength = sizeof(SECURITY_DESCRIPTOR_RELATIVE) +
|
|
|
|
sd->owner_len + sd->group_len + sd->sacl_len + sd->dacl_len;
|
|
|
|
if (Length >= *ResultLength)
|
|
|
|
{
|
|
|
|
psd->Revision = SECURITY_DESCRIPTOR_REVISION;
|
|
|
|
psd->Sbz1 = 0;
|
|
|
|
psd->Control = sd->control | SE_SELF_RELATIVE;
|
|
|
|
psd->Owner = sd->owner_len ? sizeof(SECURITY_DESCRIPTOR_RELATIVE) : 0;
|
|
|
|
psd->Group = sd->group_len ? sizeof(SECURITY_DESCRIPTOR_RELATIVE) + sd->owner_len : 0;
|
|
|
|
psd->Sacl = sd->sacl_len ? sizeof(SECURITY_DESCRIPTOR_RELATIVE) + sd->owner_len + sd->group_len : 0;
|
|
|
|
psd->Dacl = sd->dacl_len ? sizeof(SECURITY_DESCRIPTOR_RELATIVE) + sd->owner_len + sd->group_len + sd->sacl_len : 0;
|
|
|
|
/* owner, group, sacl and dacl are the same type as in the server
|
|
|
|
* and in the same order so we copy the memory in one block */
|
|
|
|
memcpy((char *)pSecurityDescriptor + sizeof(SECURITY_DESCRIPTOR_RELATIVE),
|
|
|
|
buffer + sizeof(struct security_descriptor),
|
|
|
|
sd->owner_len + sd->group_len + sd->sacl_len + sd->dacl_len);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
status = STATUS_BUFFER_TOO_SMALL;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
*ResultLength = sizeof(SECURITY_DESCRIPTOR_RELATIVE);
|
|
|
|
if (Length >= *ResultLength)
|
|
|
|
{
|
|
|
|
memset(psd, 0, sizeof(*psd));
|
|
|
|
psd->Revision = SECURITY_DESCRIPTOR_REVISION;
|
|
|
|
psd->Control = SE_SELF_RELATIVE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
status = STATUS_BUFFER_TOO_SMALL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (status == STATUS_BUFFER_TOO_SMALL)
|
|
|
|
{
|
|
|
|
buffer_size = reply->sd_len;
|
|
|
|
need_more_memory = TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
SERVER_END_REQ;
|
|
|
|
RtlFreeHeap(GetProcessHeap(), 0, buffer);
|
|
|
|
} while (need_more_memory);
|
- 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-02 16:55:13 +02:00
|
|
|
return status;
|
1999-03-09 18:47:51 +01:00
|
|
|
}
|
2002-09-16 21:32:50 +02:00
|
|
|
|
|
|
|
|
1999-03-09 18:47:51 +01:00
|
|
|
/******************************************************************************
|
2001-06-21 01:03:14 +02:00
|
|
|
* NtDuplicateObject [NTDLL.@]
|
2001-07-11 20:56:41 +02:00
|
|
|
* ZwDuplicateObject [NTDLL.@]
|
1999-03-09 18:47:51 +01:00
|
|
|
*/
|
2002-09-16 21:32:50 +02:00
|
|
|
NTSTATUS WINAPI NtDuplicateObject( HANDLE source_process, HANDLE source,
|
|
|
|
HANDLE dest_process, PHANDLE dest,
|
|
|
|
ACCESS_MASK access, ULONG attributes, ULONG options )
|
1999-03-09 18:47:51 +01:00
|
|
|
{
|
2002-09-16 21:32:50 +02:00
|
|
|
NTSTATUS ret;
|
|
|
|
SERVER_START_REQ( dup_handle )
|
|
|
|
{
|
|
|
|
req->src_process = source_process;
|
|
|
|
req->src_handle = source;
|
|
|
|
req->dst_process = dest_process;
|
|
|
|
req->access = access;
|
2005-12-09 12:21:35 +01:00
|
|
|
req->attributes = attributes;
|
2002-09-16 21:32:50 +02:00
|
|
|
req->options = options;
|
|
|
|
|
|
|
|
if (!(ret = wine_server_call( req )))
|
|
|
|
{
|
|
|
|
if (dest) *dest = reply->handle;
|
2006-11-02 20:48:19 +01:00
|
|
|
if (reply->closed)
|
2007-01-18 12:18:29 +01:00
|
|
|
{
|
2007-01-18 12:18:51 +01:00
|
|
|
if (reply->self)
|
|
|
|
{
|
|
|
|
int fd = server_remove_fd_from_cache( source );
|
|
|
|
if (fd != -1) close( fd );
|
|
|
|
}
|
2007-01-18 12:18:29 +01:00
|
|
|
}
|
2006-11-02 20:48:19 +01:00
|
|
|
else if (options & DUPLICATE_CLOSE_SOURCE)
|
|
|
|
WARN( "failed to close handle %p in process %p\n", source, source_process );
|
2002-09-16 21:32:50 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
SERVER_END_REQ;
|
|
|
|
return ret;
|
1999-03-09 18:47:51 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************
|
2001-06-19 20:20:47 +02:00
|
|
|
* NtClose [NTDLL.@]
|
2003-03-18 19:35:48 +01:00
|
|
|
*
|
|
|
|
* Close a handle reference to an object.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* Handle [I] handle to close
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: ERROR_SUCCESS.
|
|
|
|
* Failure: An NTSTATUS error code.
|
1999-03-09 18:47:51 +01:00
|
|
|
*/
|
2000-07-29 23:56:59 +02:00
|
|
|
NTSTATUS WINAPI NtClose( HANDLE Handle )
|
1999-03-09 18:47:51 +01:00
|
|
|
{
|
2000-08-30 02:00:48 +02:00
|
|
|
NTSTATUS ret;
|
2007-01-18 12:18:29 +01:00
|
|
|
int fd = server_remove_fd_from_cache( Handle );
|
|
|
|
|
2001-02-27 03:09:16 +01:00
|
|
|
SERVER_START_REQ( close_handle )
|
2000-08-30 02:00:48 +02:00
|
|
|
{
|
|
|
|
req->handle = Handle;
|
2001-11-30 19:46:42 +01:00
|
|
|
ret = wine_server_call( req );
|
2000-08-30 02:00:48 +02:00
|
|
|
}
|
|
|
|
SERVER_END_REQ;
|
2007-01-18 12:18:29 +01:00
|
|
|
if (fd != -1) close( fd );
|
2000-08-30 02:00:48 +02:00
|
|
|
return ret;
|
1999-03-09 18:47:51 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Directory functions
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**************************************************************************
|
2001-06-19 20:20:47 +02:00
|
|
|
* NtOpenDirectoryObject [NTDLL.@]
|
2001-07-11 20:56:41 +02:00
|
|
|
* ZwOpenDirectoryObject [NTDLL.@]
|
2003-03-18 19:35:48 +01:00
|
|
|
*
|
|
|
|
* Open a namespace directory object.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* DirectoryHandle [O] Destination for the new directory handle
|
|
|
|
* DesiredAccess [I] Desired access to the directory
|
|
|
|
* ObjectAttributes [I] Structure describing the directory
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: ERROR_SUCCESS.
|
|
|
|
* Failure: An NTSTATUS error code.
|
1999-03-09 18:47:51 +01:00
|
|
|
*/
|
2005-11-29 17:21:05 +01:00
|
|
|
NTSTATUS WINAPI NtOpenDirectoryObject(PHANDLE DirectoryHandle, ACCESS_MASK DesiredAccess,
|
|
|
|
POBJECT_ATTRIBUTES ObjectAttributes)
|
1999-03-09 18:47:51 +01:00
|
|
|
{
|
2005-11-29 17:21:05 +01:00
|
|
|
NTSTATUS ret;
|
2006-10-16 13:49:06 +02:00
|
|
|
TRACE("(%p,0x%08x)\n", DirectoryHandle, DesiredAccess);
|
2005-11-29 17:21:05 +01:00
|
|
|
dump_ObjectAttributes(ObjectAttributes);
|
|
|
|
|
|
|
|
if (!DirectoryHandle) return STATUS_ACCESS_VIOLATION;
|
|
|
|
if (!ObjectAttributes) return STATUS_INVALID_PARAMETER;
|
|
|
|
/* Have to test it here because server won't know difference between
|
|
|
|
* ObjectName == NULL and ObjectName == "" */
|
|
|
|
if (!ObjectAttributes->ObjectName)
|
|
|
|
{
|
|
|
|
if (ObjectAttributes->RootDirectory)
|
|
|
|
return STATUS_OBJECT_NAME_INVALID;
|
|
|
|
else
|
|
|
|
return STATUS_OBJECT_PATH_SYNTAX_BAD;
|
|
|
|
}
|
|
|
|
|
|
|
|
SERVER_START_REQ(open_directory)
|
|
|
|
{
|
|
|
|
req->access = DesiredAccess;
|
|
|
|
req->attributes = ObjectAttributes->Attributes;
|
|
|
|
req->rootdir = ObjectAttributes->RootDirectory;
|
|
|
|
if (ObjectAttributes->ObjectName)
|
|
|
|
wine_server_add_data(req, ObjectAttributes->ObjectName->Buffer,
|
|
|
|
ObjectAttributes->ObjectName->Length);
|
|
|
|
ret = wine_server_call( req );
|
|
|
|
*DirectoryHandle = reply->handle;
|
|
|
|
}
|
|
|
|
SERVER_END_REQ;
|
|
|
|
return ret;
|
1999-03-09 18:47:51 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
2001-06-21 01:03:14 +02:00
|
|
|
* NtCreateDirectoryObject [NTDLL.@]
|
2001-07-11 20:56:41 +02:00
|
|
|
* ZwCreateDirectoryObject [NTDLL.@]
|
2005-11-29 17:21:05 +01:00
|
|
|
*
|
|
|
|
* Create a namespace directory object.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* DirectoryHandle [O] Destination for the new directory handle
|
|
|
|
* DesiredAccess [I] Desired access to the directory
|
|
|
|
* ObjectAttributes [I] Structure describing the directory
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: ERROR_SUCCESS.
|
|
|
|
* Failure: An NTSTATUS error code.
|
1999-03-09 18:47:51 +01:00
|
|
|
*/
|
2005-11-29 17:21:05 +01:00
|
|
|
NTSTATUS WINAPI NtCreateDirectoryObject(PHANDLE DirectoryHandle, ACCESS_MASK DesiredAccess,
|
|
|
|
POBJECT_ATTRIBUTES ObjectAttributes)
|
1999-03-09 18:47:51 +01:00
|
|
|
{
|
2005-11-29 17:21:05 +01:00
|
|
|
NTSTATUS ret;
|
2006-10-16 13:49:06 +02:00
|
|
|
TRACE("(%p,0x%08x)\n", DirectoryHandle, DesiredAccess);
|
2005-11-29 17:21:05 +01:00
|
|
|
dump_ObjectAttributes(ObjectAttributes);
|
|
|
|
|
|
|
|
if (!DirectoryHandle) return STATUS_ACCESS_VIOLATION;
|
|
|
|
|
|
|
|
SERVER_START_REQ(create_directory)
|
|
|
|
{
|
|
|
|
req->access = DesiredAccess;
|
|
|
|
req->attributes = ObjectAttributes ? ObjectAttributes->Attributes : 0;
|
|
|
|
req->rootdir = ObjectAttributes ? ObjectAttributes->RootDirectory : 0;
|
|
|
|
if (ObjectAttributes && ObjectAttributes->ObjectName)
|
|
|
|
wine_server_add_data(req, ObjectAttributes->ObjectName->Buffer,
|
|
|
|
ObjectAttributes->ObjectName->Length);
|
|
|
|
ret = wine_server_call( req );
|
|
|
|
*DirectoryHandle = reply->handle;
|
|
|
|
}
|
|
|
|
SERVER_END_REQ;
|
|
|
|
return ret;
|
1999-03-09 18:47:51 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
2001-06-19 20:20:47 +02:00
|
|
|
* NtQueryDirectoryObject [NTDLL.@]
|
2001-07-11 20:56:41 +02:00
|
|
|
* ZwQueryDirectoryObject [NTDLL.@]
|
2003-03-18 19:35:48 +01:00
|
|
|
*
|
|
|
|
* Read information from a namespace directory.
|
|
|
|
*
|
|
|
|
* PARAMS
|
2007-12-05 16:57:41 +01:00
|
|
|
* handle [I] Handle to a directory object
|
|
|
|
* buffer [O] Buffer to hold the read data
|
|
|
|
* size [I] Size of the buffer in bytes
|
|
|
|
* single_entry [I] If TRUE, return a single entry, if FALSE, return as many as fit in the buffer
|
|
|
|
* restart [I] If TRUE, start scanning from the start, if FALSE, scan from Context
|
|
|
|
* context [I/O] Indicates what point of the directory the scan is at
|
|
|
|
* ret_size [O] Caller supplied storage for the number of bytes written (or NULL)
|
2003-03-18 19:35:48 +01:00
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: ERROR_SUCCESS.
|
|
|
|
* Failure: An NTSTATUS error code.
|
1999-03-09 18:47:51 +01:00
|
|
|
*/
|
2007-12-05 16:57:41 +01:00
|
|
|
NTSTATUS WINAPI NtQueryDirectoryObject(HANDLE handle, PDIRECTORY_BASIC_INFORMATION buffer,
|
|
|
|
ULONG size, BOOLEAN single_entry, BOOLEAN restart,
|
|
|
|
PULONG context, PULONG ret_size)
|
1999-03-09 18:47:51 +01:00
|
|
|
{
|
2007-12-05 16:57:41 +01:00
|
|
|
NTSTATUS ret;
|
|
|
|
|
|
|
|
if (restart) *context = 0;
|
|
|
|
|
|
|
|
if (single_entry)
|
|
|
|
{
|
|
|
|
if (size <= sizeof(*buffer) + 2*sizeof(WCHAR)) return STATUS_BUFFER_OVERFLOW;
|
|
|
|
|
|
|
|
SERVER_START_REQ( get_directory_entry )
|
|
|
|
{
|
|
|
|
req->handle = handle;
|
|
|
|
req->index = *context;
|
|
|
|
wine_server_set_reply( req, buffer + 1, size - sizeof(*buffer) - 2*sizeof(WCHAR) );
|
|
|
|
if (!(ret = wine_server_call( req )))
|
|
|
|
{
|
|
|
|
buffer->ObjectName.Buffer = (WCHAR *)(buffer + 1);
|
|
|
|
buffer->ObjectName.Length = reply->name_len;
|
|
|
|
buffer->ObjectName.MaximumLength = reply->name_len + sizeof(WCHAR);
|
|
|
|
buffer->ObjectTypeName.Buffer = (WCHAR *)(buffer + 1) + reply->name_len/sizeof(WCHAR) + 1;
|
|
|
|
buffer->ObjectTypeName.Length = wine_server_reply_size( reply ) - reply->name_len;
|
|
|
|
buffer->ObjectTypeName.MaximumLength = buffer->ObjectTypeName.Length + sizeof(WCHAR);
|
|
|
|
/* make room for the terminating null */
|
|
|
|
memmove( buffer->ObjectTypeName.Buffer, buffer->ObjectTypeName.Buffer - 1,
|
|
|
|
buffer->ObjectTypeName.Length );
|
|
|
|
buffer->ObjectName.Buffer[buffer->ObjectName.Length/sizeof(WCHAR)] = 0;
|
|
|
|
buffer->ObjectTypeName.Buffer[buffer->ObjectTypeName.Length/sizeof(WCHAR)] = 0;
|
|
|
|
(*context)++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
SERVER_END_REQ;
|
|
|
|
if (ret_size)
|
|
|
|
*ret_size = buffer->ObjectName.MaximumLength + buffer->ObjectTypeName.MaximumLength + sizeof(*buffer);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
FIXME("multiple entries not implemented\n");
|
|
|
|
ret = STATUS_NOT_IMPLEMENTED;
|
|
|
|
}
|
2005-10-28 18:42:11 +02:00
|
|
|
|
2007-12-05 16:57:41 +01:00
|
|
|
return ret;
|
1999-03-09 18:47:51 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Link objects
|
|
|
|
*/
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-03-09 18:47:51 +01:00
|
|
|
/******************************************************************************
|
2001-06-21 01:03:14 +02:00
|
|
|
* NtOpenSymbolicLinkObject [NTDLL.@]
|
2005-11-30 19:22:57 +01:00
|
|
|
* ZwOpenSymbolicLinkObject [NTDLL.@]
|
|
|
|
*
|
|
|
|
* Open a namespace symbolic link object.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* LinkHandle [O] Destination for the new symbolic link handle
|
|
|
|
* DesiredAccess [I] Desired access to the symbolic link
|
|
|
|
* ObjectAttributes [I] Structure describing the symbolic link
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: ERROR_SUCCESS.
|
|
|
|
* Failure: An NTSTATUS error code.
|
1999-03-09 18:47:51 +01:00
|
|
|
*/
|
2005-11-30 19:22:57 +01:00
|
|
|
NTSTATUS WINAPI NtOpenSymbolicLinkObject(OUT PHANDLE LinkHandle, IN ACCESS_MASK DesiredAccess,
|
|
|
|
IN POBJECT_ATTRIBUTES ObjectAttributes)
|
1999-03-09 18:47:51 +01:00
|
|
|
{
|
2005-11-30 19:22:57 +01:00
|
|
|
NTSTATUS ret;
|
2006-10-16 13:49:06 +02:00
|
|
|
TRACE("(%p,0x%08x,%p)\n",LinkHandle, DesiredAccess, ObjectAttributes);
|
2005-11-30 19:22:57 +01:00
|
|
|
dump_ObjectAttributes(ObjectAttributes);
|
|
|
|
|
|
|
|
if (!LinkHandle) return STATUS_ACCESS_VIOLATION;
|
|
|
|
if (!ObjectAttributes) return STATUS_INVALID_PARAMETER;
|
|
|
|
/* Have to test it here because server won't know difference between
|
|
|
|
* ObjectName == NULL and ObjectName == "" */
|
|
|
|
if (!ObjectAttributes->ObjectName)
|
|
|
|
{
|
|
|
|
if (ObjectAttributes->RootDirectory)
|
|
|
|
return STATUS_OBJECT_NAME_INVALID;
|
|
|
|
else
|
|
|
|
return STATUS_OBJECT_PATH_SYNTAX_BAD;
|
|
|
|
}
|
|
|
|
|
|
|
|
SERVER_START_REQ(open_symlink)
|
|
|
|
{
|
|
|
|
req->access = DesiredAccess;
|
2006-06-17 13:32:05 +02:00
|
|
|
req->attributes = ObjectAttributes->Attributes;
|
|
|
|
req->rootdir = ObjectAttributes->RootDirectory;
|
2005-11-30 19:22:57 +01:00
|
|
|
if (ObjectAttributes->ObjectName)
|
|
|
|
wine_server_add_data(req, ObjectAttributes->ObjectName->Buffer,
|
|
|
|
ObjectAttributes->ObjectName->Length);
|
|
|
|
ret = wine_server_call( req );
|
|
|
|
*LinkHandle = reply->handle;
|
|
|
|
}
|
|
|
|
SERVER_END_REQ;
|
|
|
|
return ret;
|
1999-03-09 18:47:51 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
2001-06-21 01:03:14 +02:00
|
|
|
* NtCreateSymbolicLinkObject [NTDLL.@]
|
2005-11-30 19:22:57 +01:00
|
|
|
* ZwCreateSymbolicLinkObject [NTDLL.@]
|
|
|
|
*
|
|
|
|
* Open a namespace symbolic link object.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* SymbolicLinkHandle [O] Destination for the new symbolic link handle
|
|
|
|
* DesiredAccess [I] Desired access to the symbolic link
|
|
|
|
* ObjectAttributes [I] Structure describing the symbolic link
|
|
|
|
* TargetName [I] Name of the target symbolic link points to
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: ERROR_SUCCESS.
|
|
|
|
* Failure: An NTSTATUS error code.
|
1999-03-09 18:47:51 +01:00
|
|
|
*/
|
2005-11-30 19:22:57 +01:00
|
|
|
NTSTATUS WINAPI NtCreateSymbolicLinkObject(OUT PHANDLE SymbolicLinkHandle,IN ACCESS_MASK DesiredAccess,
|
|
|
|
IN POBJECT_ATTRIBUTES ObjectAttributes,
|
|
|
|
IN PUNICODE_STRING TargetName)
|
1999-03-09 18:47:51 +01:00
|
|
|
{
|
2005-11-30 19:22:57 +01:00
|
|
|
NTSTATUS ret;
|
2006-10-16 13:49:06 +02:00
|
|
|
TRACE("(%p,0x%08x,%p, -> %s)\n", SymbolicLinkHandle, DesiredAccess, ObjectAttributes,
|
2005-11-30 19:22:57 +01:00
|
|
|
debugstr_us(TargetName));
|
|
|
|
dump_ObjectAttributes(ObjectAttributes);
|
|
|
|
|
|
|
|
if (!SymbolicLinkHandle || !TargetName) return STATUS_ACCESS_VIOLATION;
|
|
|
|
if (!TargetName->Buffer) return STATUS_INVALID_PARAMETER;
|
|
|
|
|
|
|
|
SERVER_START_REQ(create_symlink)
|
|
|
|
{
|
|
|
|
req->access = DesiredAccess;
|
|
|
|
req->attributes = ObjectAttributes ? ObjectAttributes->Attributes : 0;
|
|
|
|
req->rootdir = ObjectAttributes ? ObjectAttributes->RootDirectory : 0;
|
2007-01-21 21:14:35 +01:00
|
|
|
if (ObjectAttributes && ObjectAttributes->ObjectName)
|
2005-11-30 19:22:57 +01:00
|
|
|
{
|
|
|
|
req->name_len = ObjectAttributes->ObjectName->Length;
|
|
|
|
wine_server_add_data(req, ObjectAttributes->ObjectName->Buffer,
|
|
|
|
ObjectAttributes->ObjectName->Length);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
req->name_len = 0;
|
|
|
|
wine_server_add_data(req, TargetName->Buffer, TargetName->Length);
|
|
|
|
ret = wine_server_call( req );
|
|
|
|
*SymbolicLinkHandle = reply->handle;
|
|
|
|
}
|
|
|
|
SERVER_END_REQ;
|
|
|
|
return ret;
|
1999-03-09 18:47:51 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
2001-06-21 01:03:14 +02:00
|
|
|
* NtQuerySymbolicLinkObject [NTDLL.@]
|
2005-11-30 19:22:57 +01:00
|
|
|
* ZwQuerySymbolicLinkObject [NTDLL.@]
|
|
|
|
*
|
|
|
|
* Query a namespace symbolic link object target name.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* LinkHandle [I] Handle to a symbolic link object
|
|
|
|
* LinkTarget [O] Destination for the symbolic link target
|
|
|
|
* ReturnedLength [O] Size of returned data
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: ERROR_SUCCESS.
|
|
|
|
* Failure: An NTSTATUS error code.
|
1999-03-09 18:47:51 +01:00
|
|
|
*/
|
2005-11-30 19:22:57 +01:00
|
|
|
NTSTATUS WINAPI NtQuerySymbolicLinkObject(IN HANDLE LinkHandle, IN OUT PUNICODE_STRING LinkTarget,
|
|
|
|
OUT PULONG ReturnedLength OPTIONAL)
|
1999-03-09 18:47:51 +01:00
|
|
|
{
|
2005-11-30 19:22:57 +01:00
|
|
|
NTSTATUS ret;
|
|
|
|
TRACE("(%p,%p,%p)\n", LinkHandle, LinkTarget, ReturnedLength);
|
1999-03-09 18:47:51 +01:00
|
|
|
|
2005-11-30 19:22:57 +01:00
|
|
|
if (!LinkTarget) return STATUS_ACCESS_VIOLATION;
|
|
|
|
|
|
|
|
SERVER_START_REQ(query_symlink)
|
|
|
|
{
|
|
|
|
req->handle = LinkHandle;
|
|
|
|
wine_server_set_reply( req, LinkTarget->Buffer, LinkTarget->MaximumLength );
|
|
|
|
if (!(ret = wine_server_call( req )))
|
|
|
|
{
|
|
|
|
LinkTarget->Length = wine_server_reply_size(reply);
|
|
|
|
if (ReturnedLength) *ReturnedLength = LinkTarget->Length;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
SERVER_END_REQ;
|
|
|
|
return ret;
|
1999-03-09 18:47:51 +01:00
|
|
|
}
|
|
|
|
|
2000-04-13 17:56:40 +02:00
|
|
|
/******************************************************************************
|
2001-06-21 01:03:14 +02:00
|
|
|
* NtAllocateUuids [NTDLL.@]
|
2000-04-13 17:56:40 +02:00
|
|
|
*/
|
2005-06-16 12:46:11 +02:00
|
|
|
NTSTATUS WINAPI NtAllocateUuids(
|
|
|
|
PULARGE_INTEGER Time,
|
|
|
|
PULONG Range,
|
|
|
|
PULONG Sequence)
|
2000-04-13 17:56:40 +02:00
|
|
|
{
|
2005-06-16 12:46:11 +02:00
|
|
|
FIXME("(%p,%p,%p), stub.\n", Time, Range, Sequence);
|
2000-04-13 17:56:40 +02:00
|
|
|
return 0;
|
|
|
|
}
|