2 * Object management functions
4 * Copyright 1999, 2000 Juergen Schmied
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
28 #include "wine/debug.h"
31 #include "ntdll_misc.h"
32 #include "wine/server.h"
34 WINE_DEFAULT_DEBUG_CHANNEL(ntdll
);
36 /* move to somewhere */
37 typedef void * POBJDIR_INFORMATION
;
40 * Generic object functions
43 /******************************************************************************
44 * NtQueryObject [NTDLL.@]
45 * ZwQueryObject [NTDLL.@]
47 NTSTATUS WINAPI
NtQueryObject(
48 IN HANDLE ObjectHandle
,
49 IN OBJECT_INFORMATION_CLASS ObjectInformationClass
,
50 OUT PVOID ObjectInformation
,
52 OUT PULONG ResultLength
)
54 FIXME("(0x%08x,0x%08x,%p,0x%08lx,%p): stub\n",
55 ObjectHandle
, ObjectInformationClass
, ObjectInformation
, Length
, ResultLength
);
59 /******************************************************************************
60 * NtQuerySecurityObject [NTDLL.@]
62 * analogue to GetKernelObjectSecurity
65 * only the lowest 4 bit of SecurityObjectInformationClass are used
66 * 0x7-0xf returns STATUS_ACCESS_DENIED (even running with system privileges)
68 * FIXME: we are constructing a fake sid
69 * (Administrators:Full, System:Full, Everyone:Read)
72 NtQuerySecurityObject(
74 IN SECURITY_INFORMATION RequestedInformation
,
75 OUT PSECURITY_DESCRIPTOR pSecurityDesriptor
,
77 OUT PULONG ResultLength
)
79 static SID_IDENTIFIER_AUTHORITY localSidAuthority
= {SECURITY_NT_AUTHORITY
};
80 static SID_IDENTIFIER_AUTHORITY worldSidAuthority
= {SECURITY_WORLD_SID_AUTHORITY
};
82 PISECURITY_DESCRIPTOR_RELATIVE psd
= (PISECURITY_DESCRIPTOR_RELATIVE
)Buffer
;
83 UINT BufferIndex
= sizeof(SECURITY_DESCRIPTOR_RELATIVE
);
85 FIXME("(0x%08x,0x%08lx,%p,0x%08lx,%p) stub!\n",
86 Object
, RequestedInformation
, pSecurityDesriptor
, Length
, ResultLength
);
88 RequestedInformation
&= 0x0000000f;
90 if (RequestedInformation
& SACL_SECURITY_INFORMATION
) return STATUS_ACCESS_DENIED
;
92 ZeroMemory(Buffer
, 256);
93 RtlCreateSecurityDescriptor((PSECURITY_DESCRIPTOR
)psd
, SECURITY_DESCRIPTOR_REVISION
);
94 psd
->Control
= SE_SELF_RELATIVE
|
95 ((RequestedInformation
& DACL_SECURITY_INFORMATION
) ? SE_DACL_PRESENT
:0);
97 /* owner: administrator S-1-5-20-220*/
98 if (OWNER_SECURITY_INFORMATION
& RequestedInformation
)
100 PSID psid
= (PSID
)&(Buffer
[BufferIndex
]);
102 psd
->Owner
= BufferIndex
;
103 BufferIndex
+= RtlLengthRequiredSid(2);
105 psid
->Revision
= SID_REVISION
;
106 psid
->SubAuthorityCount
= 2;
107 psid
->IdentifierAuthority
= localSidAuthority
;
108 psid
->SubAuthority
[0] = SECURITY_BUILTIN_DOMAIN_RID
;
109 psid
->SubAuthority
[1] = DOMAIN_ALIAS_RID_ADMINS
;
112 /* group: built in domain S-1-5-12 */
113 if (GROUP_SECURITY_INFORMATION
& RequestedInformation
)
115 PSID psid
= (PSID
) &(Buffer
[BufferIndex
]);
117 psd
->Group
= BufferIndex
;
118 BufferIndex
+= RtlLengthRequiredSid(1);
120 psid
->Revision
= SID_REVISION
;
121 psid
->SubAuthorityCount
= 1;
122 psid
->IdentifierAuthority
= localSidAuthority
;
123 psid
->SubAuthority
[0] = SECURITY_LOCAL_SYSTEM_RID
;
126 /* discretionary ACL */
127 if (DACL_SECURITY_INFORMATION
& RequestedInformation
)
130 PACL pacl
= (PACL
)&(Buffer
[BufferIndex
]);
131 PACCESS_ALLOWED_ACE pace
;
134 psd
->Dacl
= BufferIndex
;
136 pacl
->AclRevision
= MIN_ACL_REVISION
;
138 pacl
->AclSize
= BufferIndex
; /* storing the start index temporary */
140 BufferIndex
+= sizeof(ACL
);
142 /* ACE System - full access */
143 pace
= (PACCESS_ALLOWED_ACE
)&(Buffer
[BufferIndex
]);
144 BufferIndex
+= sizeof(ACCESS_ALLOWED_ACE
)-sizeof(DWORD
);
146 pace
->Header
.AceType
= ACCESS_ALLOWED_ACE_TYPE
;
147 pace
->Header
.AceFlags
= CONTAINER_INHERIT_ACE
;
148 pace
->Header
.AceSize
= sizeof(ACCESS_ALLOWED_ACE
)-sizeof(DWORD
) + RtlLengthRequiredSid(1);
149 pace
->Mask
= DELETE
| READ_CONTROL
| WRITE_DAC
| WRITE_OWNER
| 0x3f;
150 pace
->SidStart
= BufferIndex
;
152 /* SID S-1-5-12 (System) */
153 psid
= (PSID
)&(Buffer
[BufferIndex
]);
155 BufferIndex
+= RtlLengthRequiredSid(1);
157 psid
->Revision
= SID_REVISION
;
158 psid
->SubAuthorityCount
= 1;
159 psid
->IdentifierAuthority
= localSidAuthority
;
160 psid
->SubAuthority
[0] = SECURITY_LOCAL_SYSTEM_RID
;
162 /* ACE Administrators - full access*/
163 pace
= (PACCESS_ALLOWED_ACE
) &(Buffer
[BufferIndex
]);
164 BufferIndex
+= sizeof(ACCESS_ALLOWED_ACE
)-sizeof(DWORD
);
166 pace
->Header
.AceType
= ACCESS_ALLOWED_ACE_TYPE
;
167 pace
->Header
.AceFlags
= CONTAINER_INHERIT_ACE
;
168 pace
->Header
.AceSize
= sizeof(ACCESS_ALLOWED_ACE
)-sizeof(DWORD
) + RtlLengthRequiredSid(2);
169 pace
->Mask
= DELETE
| READ_CONTROL
| WRITE_DAC
| WRITE_OWNER
| 0x3f;
170 pace
->SidStart
= BufferIndex
;
172 /* S-1-5-12 (Administrators) */
173 psid
= (PSID
)&(Buffer
[BufferIndex
]);
175 BufferIndex
+= RtlLengthRequiredSid(2);
177 psid
->Revision
= SID_REVISION
;
178 psid
->SubAuthorityCount
= 2;
179 psid
->IdentifierAuthority
= localSidAuthority
;
180 psid
->SubAuthority
[0] = SECURITY_BUILTIN_DOMAIN_RID
;
181 psid
->SubAuthority
[1] = DOMAIN_ALIAS_RID_ADMINS
;
183 /* ACE Everyone - read access */
184 pace
= (PACCESS_ALLOWED_ACE
)&(Buffer
[BufferIndex
]);
185 BufferIndex
+= sizeof(ACCESS_ALLOWED_ACE
)-sizeof(DWORD
);
187 pace
->Header
.AceType
= ACCESS_ALLOWED_ACE_TYPE
;
188 pace
->Header
.AceFlags
= CONTAINER_INHERIT_ACE
;
189 pace
->Header
.AceSize
= sizeof(ACCESS_ALLOWED_ACE
)-sizeof(DWORD
) + RtlLengthRequiredSid(1);
190 pace
->Mask
= READ_CONTROL
| 0x19;
191 pace
->SidStart
= BufferIndex
;
193 /* SID S-1-1-0 (Everyone) */
194 psid
= (PSID
)&(Buffer
[BufferIndex
]);
196 BufferIndex
+= RtlLengthRequiredSid(1);
198 psid
->Revision
= SID_REVISION
;
199 psid
->SubAuthorityCount
= 1;
200 psid
->IdentifierAuthority
= worldSidAuthority
;
201 psid
->SubAuthority
[0] = 0;
203 /* calculate used bytes */
204 pacl
->AclSize
= BufferIndex
- pacl
->AclSize
;
206 *ResultLength
= BufferIndex
;
207 TRACE("len=%lu\n", *ResultLength
);
208 if (Length
< *ResultLength
) return STATUS_BUFFER_TOO_SMALL
;
209 memcpy(pSecurityDesriptor
, Buffer
, *ResultLength
);
211 return STATUS_SUCCESS
;
213 /******************************************************************************
214 * NtDuplicateObject [NTDLL.@]
215 * ZwDuplicateObject [NTDLL.@]
217 NTSTATUS WINAPI
NtDuplicateObject(
218 IN HANDLE SourceProcessHandle
,
219 IN PHANDLE SourceHandle
,
220 IN HANDLE TargetProcessHandle
,
221 OUT PHANDLE TargetHandle
,
222 IN ACCESS_MASK DesiredAccess
,
223 IN BOOLEAN InheritHandle
,
226 FIXME("(0x%08x,%p,0x%08x,%p,0x%08lx,0x%08x,0x%08lx) stub!\n",
227 SourceProcessHandle
,SourceHandle
,TargetProcessHandle
,TargetHandle
,
228 DesiredAccess
,InheritHandle
,Options
);
233 /**************************************************************************
235 * FUNCTION: Closes a handle reference to an object
237 * Handle handle to close
239 NTSTATUS WINAPI
NtClose( HANDLE Handle
)
242 SERVER_START_REQ( close_handle
)
244 req
->handle
= Handle
;
245 ret
= wine_server_call( req
);
246 if (!ret
&& reply
->fd
!= -1) close( reply
->fd
);
252 /******************************************************************************
253 * NtWaitForSingleObject [NTDLL.@]
254 * ZwWaitForSingleObject [NTDLL.@]
256 NTSTATUS WINAPI
NtWaitForSingleObject(
258 IN BOOLEAN Alertable
,
259 IN PLARGE_INTEGER Time
)
261 FIXME("(%p,0x%08x,%p),stub!\n",Object
,Alertable
,Time
);
266 * Directory functions
269 /**************************************************************************
270 * NtOpenDirectoryObject [NTDLL.@]
271 * ZwOpenDirectoryObject [NTDLL.@]
272 * FUNCTION: Opens a namespace directory object
274 * DirectoryHandle Variable which receives the directory handle
275 * DesiredAccess Desired access to the directory
276 * ObjectAttributes Structure describing the directory
279 NTSTATUS WINAPI
NtOpenDirectoryObject(
280 PHANDLE DirectoryHandle
,
281 ACCESS_MASK DesiredAccess
,
282 POBJECT_ATTRIBUTES ObjectAttributes
)
284 FIXME("(%p,0x%08lx,%p): stub\n",
285 DirectoryHandle
, DesiredAccess
, ObjectAttributes
);
286 dump_ObjectAttributes(ObjectAttributes
);
290 /******************************************************************************
291 * NtCreateDirectoryObject [NTDLL.@]
292 * ZwCreateDirectoryObject [NTDLL.@]
294 NTSTATUS WINAPI
NtCreateDirectoryObject(
295 PHANDLE DirectoryHandle
,
296 ACCESS_MASK DesiredAccess
,
297 POBJECT_ATTRIBUTES ObjectAttributes
)
299 FIXME("(%p,0x%08lx,%p),stub!\n",
300 DirectoryHandle
,DesiredAccess
,ObjectAttributes
);
301 dump_ObjectAttributes(ObjectAttributes
);
305 /******************************************************************************
306 * NtQueryDirectoryObject [NTDLL.@]
307 * ZwQueryDirectoryObject [NTDLL.@]
308 * FUNCTION: Reads information from a namespace directory
310 * DirObjInformation Buffer to hold the data read
311 * BufferLength Size of the buffer in bytes
312 * GetNextIndex If TRUE then set ObjectIndex to the index of the next object
313 * If FALSE then set ObjectIndex to the number of objects in the directory
314 * IgnoreInputIndex If TRUE start reading at index 0
315 * If FALSE start reading at the index specified by object index
316 * ObjectIndex Zero based index into the directory, interpretation depends on IgnoreInputIndex and GetNextIndex
317 * DataWritten Caller supplied storage for the number of bytes written (or NULL)
319 NTSTATUS WINAPI
NtQueryDirectoryObject(
320 IN HANDLE DirObjHandle
,
321 OUT POBJDIR_INFORMATION DirObjInformation
,
322 IN ULONG BufferLength
,
323 IN BOOLEAN GetNextIndex
,
324 IN BOOLEAN IgnoreInputIndex
,
325 IN OUT PULONG ObjectIndex
,
326 OUT PULONG DataWritten OPTIONAL
)
328 FIXME("(0x%08x,%p,0x%08lx,0x%08x,0x%08x,%p,%p) stub\n",
329 DirObjHandle
, DirObjInformation
, BufferLength
, GetNextIndex
,
330 IgnoreInputIndex
, ObjectIndex
, DataWritten
);
331 return 0xc0000000; /* We don't have any. Whatever. (Yet.) */
338 /******************************************************************************
339 * NtOpenSymbolicLinkObject [NTDLL.@]
341 NTSTATUS WINAPI
NtOpenSymbolicLinkObject(
342 OUT PHANDLE LinkHandle
,
343 IN ACCESS_MASK DesiredAccess
,
344 IN POBJECT_ATTRIBUTES ObjectAttributes
)
346 FIXME("(%p,0x%08lx,%p) stub\n",
347 LinkHandle
, DesiredAccess
, ObjectAttributes
);
348 dump_ObjectAttributes(ObjectAttributes
);
352 /******************************************************************************
353 * NtCreateSymbolicLinkObject [NTDLL.@]
355 NTSTATUS WINAPI
NtCreateSymbolicLinkObject(
356 OUT PHANDLE SymbolicLinkHandle
,
357 IN ACCESS_MASK DesiredAccess
,
358 IN POBJECT_ATTRIBUTES ObjectAttributes
,
359 IN PUNICODE_STRING Name
)
361 FIXME("(%p,0x%08lx,%p, %p) stub\n",
362 SymbolicLinkHandle
, DesiredAccess
, ObjectAttributes
, debugstr_us(Name
));
363 dump_ObjectAttributes(ObjectAttributes
);
367 /******************************************************************************
368 * NtQuerySymbolicLinkObject [NTDLL.@]
370 NTSTATUS WINAPI
NtQuerySymbolicLinkObject(
371 IN HANDLE LinkHandle
,
372 IN OUT PUNICODE_STRING LinkTarget
,
373 OUT PULONG ReturnedLength OPTIONAL
)
375 FIXME("(0x%08x,%p,%p) stub\n",
376 LinkHandle
, debugstr_us(LinkTarget
), ReturnedLength
);
381 /******************************************************************************
382 * NtAllocateUuids [NTDLL.@]
384 * I have seen lpdwCount pointing to a pointer once...
386 NTSTATUS WINAPI
NtAllocateUuids(LPDWORD lpdwCount
, LPDWORD
*p2
, LPDWORD
*p3
)
388 FIXME("(%p[%ld],%p,%p), stub.\n", lpdwCount
,
389 lpdwCount
? *lpdwCount
: 0,