advapi32/ntdll: MakeRelativeSD should preserve NULL pointers (with testcase).
[wine] / dlls / ntdll / om.c
1 /*
2  *      Object management functions
3  *
4  * Copyright 1999, 2000 Juergen Schmied
5  * Copyright 2005 Vitaliy Margolen
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this library; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20  */
21
22 #include "config.h"
23
24 #include <stdarg.h>
25 #include <stdlib.h>
26 #include <string.h>
27 #ifdef HAVE_IO_H
28 # include <io.h>
29 #endif
30 #ifdef HAVE_UNISTD_H
31 # include <unistd.h>
32 #endif
33
34 #include "ntstatus.h"
35 #define WIN32_NO_STATUS
36 #include "wine/debug.h"
37 #include "windef.h"
38 #include "winternl.h"
39 #include "ntdll_misc.h"
40 #include "wine/server.h"
41
42 WINE_DEFAULT_DEBUG_CHANNEL(ntdll);
43
44
45 /*
46  *      Generic object functions
47  */
48
49 /******************************************************************************
50  * NtQueryObject [NTDLL.@]
51  * ZwQueryObject [NTDLL.@]
52  */
53 NTSTATUS WINAPI NtQueryObject(IN HANDLE handle,
54                               IN OBJECT_INFORMATION_CLASS info_class,
55                               OUT PVOID ptr, IN ULONG len, OUT PULONG used_len)
56 {
57     NTSTATUS status;
58
59     TRACE("(%p,0x%08x,%p,0x%08x,%p): stub\n",
60           handle, info_class, ptr, len, used_len);
61
62     if (used_len) *used_len = 0;
63
64     switch (info_class)
65     {
66     case ObjectBasicInformation:
67         {
68             POBJECT_BASIC_INFORMATION p = (POBJECT_BASIC_INFORMATION)ptr;
69
70             if (len < sizeof(*p)) return STATUS_INVALID_BUFFER_SIZE;
71
72             SERVER_START_REQ( get_object_info )
73             {
74                 req->handle = handle;
75                 status = wine_server_call( req );
76                 if (status == STATUS_SUCCESS)
77                 {
78                     memset( p, 0, sizeof(*p) );
79                     p->GrantedAccess = reply->access;
80                     p->PointerCount = reply->ref_count;
81                     p->HandleCount = 1; /* at least one */
82                     if (used_len) *used_len = sizeof(*p);
83                 }
84             }
85             SERVER_END_REQ;
86         }
87         break;
88     case ObjectDataInformation:
89         {
90             OBJECT_DATA_INFORMATION* p = (OBJECT_DATA_INFORMATION*)ptr;
91
92             if (len < sizeof(*p)) return STATUS_INVALID_BUFFER_SIZE;
93
94             SERVER_START_REQ( set_handle_info )
95             {
96                 req->handle = handle;
97                 req->flags  = 0;
98                 req->mask   = 0;
99                 status = wine_server_call( req );
100                 if (status == STATUS_SUCCESS)
101                 {
102                     p->InheritHandle = (reply->old_flags & HANDLE_FLAG_INHERIT) ? TRUE : FALSE;
103                     p->ProtectFromClose = (reply->old_flags & HANDLE_FLAG_PROTECT_FROM_CLOSE) ? TRUE : FALSE;
104                     if (used_len) *used_len = sizeof(*p);
105                 }
106             }
107             SERVER_END_REQ;
108         }
109         break;
110     default:
111         FIXME("Unsupported information class %u\n", info_class);
112         status = STATUS_NOT_IMPLEMENTED;
113         break;
114     }
115     return status;
116 }
117
118 /******************************************************************
119  *              NtSetInformationObject [NTDLL.@]
120  *              ZwSetInformationObject [NTDLL.@]
121  *
122  */
123 NTSTATUS WINAPI NtSetInformationObject(IN HANDLE handle,
124                                        IN OBJECT_INFORMATION_CLASS info_class,
125                                        IN PVOID ptr, IN ULONG len)
126 {
127     NTSTATUS status;
128
129     TRACE("(%p,0x%08x,%p,0x%08x): stub\n",
130           handle, info_class, ptr, len);
131
132     switch (info_class)
133     {
134     case ObjectDataInformation:
135         {
136             OBJECT_DATA_INFORMATION* p = (OBJECT_DATA_INFORMATION*)ptr;
137
138             if (len < sizeof(*p)) return STATUS_INVALID_BUFFER_SIZE;
139
140             SERVER_START_REQ( set_handle_info )
141             {
142                 req->handle = handle;
143                 req->flags  = 0;
144                 req->mask   = HANDLE_FLAG_INHERIT | HANDLE_FLAG_PROTECT_FROM_CLOSE;
145                 if (p->InheritHandle)    req->flags |= HANDLE_FLAG_INHERIT;
146                 if (p->ProtectFromClose) req->flags |= HANDLE_FLAG_PROTECT_FROM_CLOSE;
147                 status = wine_server_call( req );
148             }
149             SERVER_END_REQ;
150         }
151         break;
152     default:
153         FIXME("Unsupported information class %u\n", info_class);
154         status = STATUS_NOT_IMPLEMENTED;
155         break;
156     }
157     return status;
158 }
159
160 /******************************************************************************
161  *  NtQuerySecurityObject       [NTDLL.@]
162  *
163  * An ntdll analogue to GetKernelObjectSecurity().
164  *
165  * NOTES
166  *  only the lowest 4 bit of SecurityObjectInformationClass are used
167  *  0x7-0xf returns STATUS_ACCESS_DENIED (even running with system privileges)
168  *
169  * FIXME
170  *  We are constructing a fake sid (Administrators:Full, System:Full, Everyone:Read)
171  */
172 NTSTATUS WINAPI
173 NtQuerySecurityObject(
174         IN HANDLE Object,
175         IN SECURITY_INFORMATION RequestedInformation,
176         OUT PSECURITY_DESCRIPTOR pSecurityDesriptor,
177         IN ULONG Length,
178         OUT PULONG ResultLength)
179 {
180         static const SID_IDENTIFIER_AUTHORITY localSidAuthority = {SECURITY_NT_AUTHORITY};
181         static const SID_IDENTIFIER_AUTHORITY worldSidAuthority = {SECURITY_WORLD_SID_AUTHORITY};
182         BYTE Buffer[256];
183         PISECURITY_DESCRIPTOR_RELATIVE psd = (PISECURITY_DESCRIPTOR_RELATIVE)Buffer;
184         UINT BufferIndex = sizeof(SECURITY_DESCRIPTOR_RELATIVE);
185
186         FIXME("(%p,0x%08x,%p,0x%08x,%p) stub!\n",
187         Object, RequestedInformation, pSecurityDesriptor, Length, ResultLength);
188
189         RequestedInformation &= 0x0000000f;
190
191         ZeroMemory(Buffer, 256);
192         RtlCreateSecurityDescriptor((PSECURITY_DESCRIPTOR)psd, SECURITY_DESCRIPTOR_REVISION);
193         psd->Control = SE_SELF_RELATIVE |
194           ((RequestedInformation & DACL_SECURITY_INFORMATION) ? SE_DACL_PRESENT:0);
195
196         /* owner: administrator S-1-5-20-220*/
197         if (OWNER_SECURITY_INFORMATION & RequestedInformation)
198         {
199           SID* psid = (SID*)&(Buffer[BufferIndex]);
200
201           psd->Owner = BufferIndex;
202           BufferIndex += RtlLengthRequiredSid(2);
203
204           psid->Revision = SID_REVISION;
205           psid->SubAuthorityCount = 2;
206           psid->IdentifierAuthority = localSidAuthority;
207           psid->SubAuthority[0] = SECURITY_BUILTIN_DOMAIN_RID;
208           psid->SubAuthority[1] = DOMAIN_ALIAS_RID_ADMINS;
209         }
210
211         /* group: built in domain S-1-5-12 */
212         if (GROUP_SECURITY_INFORMATION & RequestedInformation)
213         {
214           SID* psid = (SID*) &(Buffer[BufferIndex]);
215
216           psd->Group = BufferIndex;
217           BufferIndex += RtlLengthRequiredSid(1);
218
219           psid->Revision = SID_REVISION;
220           psid->SubAuthorityCount = 1;
221           psid->IdentifierAuthority = localSidAuthority;
222           psid->SubAuthority[0] = SECURITY_LOCAL_SYSTEM_RID;
223         }
224
225         /* discretionary ACL */
226         if (DACL_SECURITY_INFORMATION & RequestedInformation)
227         {
228           /* acl header */
229           PACL pacl = (PACL)&(Buffer[BufferIndex]);
230           PACCESS_ALLOWED_ACE pace;
231           SID* psid;
232
233           psd->Dacl = BufferIndex;
234
235           pacl->AclRevision = MIN_ACL_REVISION;
236           pacl->AceCount = 3;
237           pacl->AclSize = BufferIndex; /* storing the start index temporary */
238
239           BufferIndex += sizeof(ACL);
240
241           /* ACE System - full access */
242           pace = (PACCESS_ALLOWED_ACE)&(Buffer[BufferIndex]);
243           BufferIndex += sizeof(ACCESS_ALLOWED_ACE)-sizeof(DWORD);
244
245           pace->Header.AceType = ACCESS_ALLOWED_ACE_TYPE;
246           pace->Header.AceFlags = CONTAINER_INHERIT_ACE;
247           pace->Header.AceSize = sizeof(ACCESS_ALLOWED_ACE)-sizeof(DWORD) + RtlLengthRequiredSid(1);
248           pace->Mask = STANDARD_RIGHTS_ALL | SPECIFIC_RIGHTS_ALL;
249           pace->SidStart = BufferIndex;
250
251           /* SID S-1-5-12 (System) */
252           psid = (SID*)&(Buffer[BufferIndex]);
253
254           BufferIndex += RtlLengthRequiredSid(1);
255
256           psid->Revision = SID_REVISION;
257           psid->SubAuthorityCount = 1;
258           psid->IdentifierAuthority = localSidAuthority;
259           psid->SubAuthority[0] = SECURITY_LOCAL_SYSTEM_RID;
260
261           /* ACE Administrators - full access*/
262           pace = (PACCESS_ALLOWED_ACE) &(Buffer[BufferIndex]);
263           BufferIndex += sizeof(ACCESS_ALLOWED_ACE)-sizeof(DWORD);
264
265           pace->Header.AceType = ACCESS_ALLOWED_ACE_TYPE;
266           pace->Header.AceFlags = CONTAINER_INHERIT_ACE;
267           pace->Header.AceSize = sizeof(ACCESS_ALLOWED_ACE)-sizeof(DWORD) + RtlLengthRequiredSid(2);
268           pace->Mask = STANDARD_RIGHTS_ALL | SPECIFIC_RIGHTS_ALL;
269           pace->SidStart = BufferIndex;
270
271           /* S-1-5-12 (Administrators) */
272           psid = (SID*)&(Buffer[BufferIndex]);
273
274           BufferIndex += RtlLengthRequiredSid(2);
275
276           psid->Revision = SID_REVISION;
277           psid->SubAuthorityCount = 2;
278           psid->IdentifierAuthority = localSidAuthority;
279           psid->SubAuthority[0] = SECURITY_BUILTIN_DOMAIN_RID;
280           psid->SubAuthority[1] = DOMAIN_ALIAS_RID_ADMINS;
281
282           /* ACE Everyone - read access */
283           pace = (PACCESS_ALLOWED_ACE)&(Buffer[BufferIndex]);
284           BufferIndex += sizeof(ACCESS_ALLOWED_ACE)-sizeof(DWORD);
285
286           pace->Header.AceType = ACCESS_ALLOWED_ACE_TYPE;
287           pace->Header.AceFlags = CONTAINER_INHERIT_ACE;
288           pace->Header.AceSize = sizeof(ACCESS_ALLOWED_ACE)-sizeof(DWORD) + RtlLengthRequiredSid(1);
289           pace->Mask = READ_CONTROL| 0x19;
290           pace->SidStart = BufferIndex;
291
292           /* SID S-1-1-0 (Everyone) */
293           psid = (SID*)&(Buffer[BufferIndex]);
294
295           BufferIndex += RtlLengthRequiredSid(1);
296
297           psid->Revision = SID_REVISION;
298           psid->SubAuthorityCount = 1;
299           psid->IdentifierAuthority = worldSidAuthority;
300           psid->SubAuthority[0] = 0;
301
302           /* calculate used bytes */
303           pacl->AclSize = BufferIndex - pacl->AclSize;
304         }
305         *ResultLength = BufferIndex;
306         TRACE("len=%u\n", *ResultLength);
307         if (Length < *ResultLength) return STATUS_BUFFER_TOO_SMALL;
308         memcpy(pSecurityDesriptor, Buffer, *ResultLength);
309
310         return STATUS_SUCCESS;
311 }
312
313
314 /******************************************************************************
315  *  NtDuplicateObject           [NTDLL.@]
316  *  ZwDuplicateObject           [NTDLL.@]
317  */
318 NTSTATUS WINAPI NtDuplicateObject( HANDLE source_process, HANDLE source,
319                                    HANDLE dest_process, PHANDLE dest,
320                                    ACCESS_MASK access, ULONG attributes, ULONG options )
321 {
322     NTSTATUS ret;
323     SERVER_START_REQ( dup_handle )
324     {
325         req->src_process = source_process;
326         req->src_handle  = source;
327         req->dst_process = dest_process;
328         req->access      = access;
329         req->attributes  = attributes;
330         req->options     = options;
331
332         if (!(ret = wine_server_call( req )))
333         {
334             if (dest) *dest = reply->handle;
335             if (reply->closed)
336             {
337                 if (reply->self)
338                 {
339                     int fd = server_remove_fd_from_cache( source );
340                     if (fd != -1) close( fd );
341                 }
342             }
343             else if (options & DUPLICATE_CLOSE_SOURCE)
344                 WARN( "failed to close handle %p in process %p\n", source, source_process );
345         }
346     }
347     SERVER_END_REQ;
348     return ret;
349 }
350
351 /**************************************************************************
352  *                 NtClose                              [NTDLL.@]
353  *
354  * Close a handle reference to an object.
355  * 
356  * PARAMS
357  *  Handle [I] handle to close
358  *
359  * RETURNS
360  *  Success: ERROR_SUCCESS.
361  *  Failure: An NTSTATUS error code.
362  */
363 NTSTATUS WINAPI NtClose( HANDLE Handle )
364 {
365     NTSTATUS ret;
366     int fd = server_remove_fd_from_cache( Handle );
367
368     SERVER_START_REQ( close_handle )
369     {
370         req->handle = Handle;
371         ret = wine_server_call( req );
372     }
373     SERVER_END_REQ;
374     if (fd != -1) close( fd );
375     return ret;
376 }
377
378 /*
379  *      Directory functions
380  */
381
382 /**************************************************************************
383  * NtOpenDirectoryObject [NTDLL.@]
384  * ZwOpenDirectoryObject [NTDLL.@]
385  *
386  * Open a namespace directory object.
387  * 
388  * PARAMS
389  *  DirectoryHandle  [O] Destination for the new directory handle
390  *  DesiredAccess    [I] Desired access to the directory
391  *  ObjectAttributes [I] Structure describing the directory
392  *
393  * RETURNS
394  *  Success: ERROR_SUCCESS.
395  *  Failure: An NTSTATUS error code.
396  */
397 NTSTATUS WINAPI NtOpenDirectoryObject(PHANDLE DirectoryHandle, ACCESS_MASK DesiredAccess,
398                                       POBJECT_ATTRIBUTES ObjectAttributes)
399 {
400     NTSTATUS ret;
401     TRACE("(%p,0x%08x)\n", DirectoryHandle, DesiredAccess);
402     dump_ObjectAttributes(ObjectAttributes);
403
404     if (!DirectoryHandle) return STATUS_ACCESS_VIOLATION;
405     if (!ObjectAttributes) return STATUS_INVALID_PARAMETER;
406     /* Have to test it here because server won't know difference between
407      * ObjectName == NULL and ObjectName == "" */
408     if (!ObjectAttributes->ObjectName)
409     {
410         if (ObjectAttributes->RootDirectory)
411             return STATUS_OBJECT_NAME_INVALID;
412         else
413             return STATUS_OBJECT_PATH_SYNTAX_BAD;
414     }
415
416     SERVER_START_REQ(open_directory)
417     {
418         req->access = DesiredAccess;
419         req->attributes = ObjectAttributes->Attributes;
420         req->rootdir = ObjectAttributes->RootDirectory;
421         if (ObjectAttributes->ObjectName)
422             wine_server_add_data(req, ObjectAttributes->ObjectName->Buffer,
423                                  ObjectAttributes->ObjectName->Length);
424         ret = wine_server_call( req );
425         *DirectoryHandle = reply->handle;
426     }
427     SERVER_END_REQ;
428     return ret;
429 }
430
431 /******************************************************************************
432  *  NtCreateDirectoryObject     [NTDLL.@]
433  *  ZwCreateDirectoryObject     [NTDLL.@]
434  *
435  * Create a namespace directory object.
436  * 
437  * PARAMS
438  *  DirectoryHandle  [O] Destination for the new directory handle
439  *  DesiredAccess    [I] Desired access to the directory
440  *  ObjectAttributes [I] Structure describing the directory
441  *
442  * RETURNS
443  *  Success: ERROR_SUCCESS.
444  *  Failure: An NTSTATUS error code.
445  */
446 NTSTATUS WINAPI NtCreateDirectoryObject(PHANDLE DirectoryHandle, ACCESS_MASK DesiredAccess,
447                                         POBJECT_ATTRIBUTES ObjectAttributes)
448 {
449     NTSTATUS ret;
450     TRACE("(%p,0x%08x)\n", DirectoryHandle, DesiredAccess);
451     dump_ObjectAttributes(ObjectAttributes);
452
453     if (!DirectoryHandle) return STATUS_ACCESS_VIOLATION;
454
455     SERVER_START_REQ(create_directory)
456     {
457         req->access = DesiredAccess;
458         req->attributes = ObjectAttributes ? ObjectAttributes->Attributes : 0;
459         req->rootdir = ObjectAttributes ? ObjectAttributes->RootDirectory : 0;
460         if (ObjectAttributes && ObjectAttributes->ObjectName)
461             wine_server_add_data(req, ObjectAttributes->ObjectName->Buffer,
462                                  ObjectAttributes->ObjectName->Length);
463         ret = wine_server_call( req );
464         *DirectoryHandle = reply->handle;
465     }
466     SERVER_END_REQ;
467     return ret;
468 }
469
470 /******************************************************************************
471  * NtQueryDirectoryObject [NTDLL.@]
472  * ZwQueryDirectoryObject [NTDLL.@]
473  *
474  * Read information from a namespace directory.
475  * 
476  * PARAMS
477  *  DirectoryHandle   [I]   Handle to a directory object
478  *  Buffer            [O]   Buffer to hold the read data
479  *  BufferLength      [I]   Size of the buffer in bytes
480  *  ReturnSingleEntry [I]   If TRUE, return a single entry, if FALSE, return as many as fit in the buffer
481  *  RestartScan       [I]   If TRUE, start scanning from the start, if FALSE, scan from Context
482  *  Context           [I/O] Indicates what point of the directory the scan is at
483  *  ReturnLength      [O]   Caller supplied storage for the number of bytes written (or NULL)
484  *
485  * RETURNS
486  *  Success: ERROR_SUCCESS.
487  *  Failure: An NTSTATUS error code.
488  */
489 NTSTATUS WINAPI NtQueryDirectoryObject(IN HANDLE DirectoryHandle, OUT PDIRECTORY_BASIC_INFORMATION Buffer,
490                                        IN ULONG BufferLength, IN BOOLEAN ReturnSingleEntry, IN BOOLEAN RestartScan,
491                                        IN OUT PULONG Context, OUT PULONG ReturnLength OPTIONAL)
492 {
493     FIXME("(%p,%p,0x%08x,0x%08x,0x%08x,%p,%p), stub\n", DirectoryHandle, Buffer, BufferLength, ReturnSingleEntry,
494           RestartScan, Context, ReturnLength);
495
496     return STATUS_NOT_IMPLEMENTED;
497 }
498
499 /*
500  *      Link objects
501  */
502
503 /******************************************************************************
504  *  NtOpenSymbolicLinkObject    [NTDLL.@]
505  *  ZwOpenSymbolicLinkObject    [NTDLL.@]
506  *
507  * Open a namespace symbolic link object.
508  * 
509  * PARAMS
510  *  LinkHandle       [O] Destination for the new symbolic link handle
511  *  DesiredAccess    [I] Desired access to the symbolic link
512  *  ObjectAttributes [I] Structure describing the symbolic link
513  *
514  * RETURNS
515  *  Success: ERROR_SUCCESS.
516  *  Failure: An NTSTATUS error code.
517  */
518 NTSTATUS WINAPI NtOpenSymbolicLinkObject(OUT PHANDLE LinkHandle, IN ACCESS_MASK DesiredAccess,
519                                          IN POBJECT_ATTRIBUTES ObjectAttributes)
520 {
521     NTSTATUS ret;
522     TRACE("(%p,0x%08x,%p)\n",LinkHandle, DesiredAccess, ObjectAttributes);
523     dump_ObjectAttributes(ObjectAttributes);
524
525     if (!LinkHandle) return STATUS_ACCESS_VIOLATION;
526     if (!ObjectAttributes) return STATUS_INVALID_PARAMETER;
527     /* Have to test it here because server won't know difference between
528      * ObjectName == NULL and ObjectName == "" */
529     if (!ObjectAttributes->ObjectName)
530     {
531         if (ObjectAttributes->RootDirectory)
532             return STATUS_OBJECT_NAME_INVALID;
533         else
534             return STATUS_OBJECT_PATH_SYNTAX_BAD;
535     }
536
537     SERVER_START_REQ(open_symlink)
538     {
539         req->access = DesiredAccess;
540         req->attributes = ObjectAttributes->Attributes;
541         req->rootdir = ObjectAttributes->RootDirectory;
542         if (ObjectAttributes->ObjectName)
543             wine_server_add_data(req, ObjectAttributes->ObjectName->Buffer,
544                                  ObjectAttributes->ObjectName->Length);
545         ret = wine_server_call( req );
546         *LinkHandle = reply->handle;
547     }
548     SERVER_END_REQ;
549     return ret;
550 }
551
552 /******************************************************************************
553  *  NtCreateSymbolicLinkObject  [NTDLL.@]
554  *  ZwCreateSymbolicLinkObject  [NTDLL.@]
555  *
556  * Open a namespace symbolic link object.
557  * 
558  * PARAMS
559  *  SymbolicLinkHandle [O] Destination for the new symbolic link handle
560  *  DesiredAccess      [I] Desired access to the symbolic link
561  *  ObjectAttributes   [I] Structure describing the symbolic link
562  *  TargetName         [I] Name of the target symbolic link points to
563  *
564  * RETURNS
565  *  Success: ERROR_SUCCESS.
566  *  Failure: An NTSTATUS error code.
567  */
568 NTSTATUS WINAPI NtCreateSymbolicLinkObject(OUT PHANDLE SymbolicLinkHandle,IN ACCESS_MASK DesiredAccess,
569                                            IN POBJECT_ATTRIBUTES ObjectAttributes,
570                                            IN PUNICODE_STRING TargetName)
571 {
572     NTSTATUS ret;
573     TRACE("(%p,0x%08x,%p, -> %s)\n", SymbolicLinkHandle, DesiredAccess, ObjectAttributes,
574                                       debugstr_us(TargetName));
575     dump_ObjectAttributes(ObjectAttributes);
576
577     if (!SymbolicLinkHandle || !TargetName) return STATUS_ACCESS_VIOLATION;
578     if (!TargetName->Buffer) return STATUS_INVALID_PARAMETER;
579
580     SERVER_START_REQ(create_symlink)
581     {
582         req->access = DesiredAccess;
583         req->attributes = ObjectAttributes ? ObjectAttributes->Attributes : 0;
584         req->rootdir = ObjectAttributes ? ObjectAttributes->RootDirectory : 0;
585         if (ObjectAttributes && ObjectAttributes->ObjectName)
586         {
587             req->name_len = ObjectAttributes->ObjectName->Length;
588             wine_server_add_data(req, ObjectAttributes->ObjectName->Buffer,
589                                  ObjectAttributes->ObjectName->Length);
590         }
591         else
592             req->name_len = 0;
593         wine_server_add_data(req, TargetName->Buffer, TargetName->Length);
594         ret = wine_server_call( req );
595         *SymbolicLinkHandle = reply->handle;
596     }
597     SERVER_END_REQ;
598     return ret;
599 }
600
601 /******************************************************************************
602  *  NtQuerySymbolicLinkObject   [NTDLL.@]
603  *  ZwQuerySymbolicLinkObject   [NTDLL.@]
604  *
605  * Query a namespace symbolic link object target name.
606  * 
607  * PARAMS
608  *  LinkHandle     [I] Handle to a symbolic link object
609  *  LinkTarget     [O] Destination for the symbolic link target
610  *  ReturnedLength [O] Size of returned data
611  *
612  * RETURNS
613  *  Success: ERROR_SUCCESS.
614  *  Failure: An NTSTATUS error code.
615  */
616 NTSTATUS WINAPI NtQuerySymbolicLinkObject(IN HANDLE LinkHandle, IN OUT PUNICODE_STRING LinkTarget,
617                                           OUT PULONG ReturnedLength OPTIONAL)
618 {
619     NTSTATUS ret;
620     TRACE("(%p,%p,%p)\n", LinkHandle, LinkTarget, ReturnedLength);
621
622     if (!LinkTarget) return STATUS_ACCESS_VIOLATION;
623
624     SERVER_START_REQ(query_symlink)
625     {
626         req->handle = LinkHandle;
627         wine_server_set_reply( req, LinkTarget->Buffer, LinkTarget->MaximumLength );
628         if (!(ret = wine_server_call( req )))
629         {
630             LinkTarget->Length = wine_server_reply_size(reply);
631             if (ReturnedLength) *ReturnedLength = LinkTarget->Length;
632         }
633     }
634     SERVER_END_REQ;
635     return ret;
636 }
637
638 /******************************************************************************
639  *  NtAllocateUuids   [NTDLL.@]
640  */
641 NTSTATUS WINAPI NtAllocateUuids(
642         PULARGE_INTEGER Time,
643         PULONG Range,
644         PULONG Sequence)
645 {
646         FIXME("(%p,%p,%p), stub.\n", Time, Range, Sequence);
647         return 0;
648 }