Changed DllOverrides so we use builtin rpcrt4, ole32, oleaut32.
[wine/testsucceed.git] / dlls / ntdll / om.c
blob56f65232dec96f2411c15441ddc7829e34727bf4
1 /*
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
21 #include <stdlib.h>
22 #include <string.h>
23 #include <unistd.h>
24 #include "wine/debug.h"
26 #include "ntddk.h"
27 #include "ntdll_misc.h"
28 #include "wine/server.h"
30 WINE_DEFAULT_DEBUG_CHANNEL(ntdll);
32 /* move to somewhere */
33 typedef void * POBJDIR_INFORMATION;
36 * Generic object functions
39 /******************************************************************************
40 * NtQueryObject [NTDLL.@]
41 * ZwQueryObject [NTDLL.@]
43 NTSTATUS WINAPI NtQueryObject(
44 IN HANDLE ObjectHandle,
45 IN OBJECT_INFORMATION_CLASS ObjectInformationClass,
46 OUT PVOID ObjectInformation,
47 IN ULONG Length,
48 OUT PULONG ResultLength)
50 FIXME("(0x%08x,0x%08x,%p,0x%08lx,%p): stub\n",
51 ObjectHandle, ObjectInformationClass, ObjectInformation, Length, ResultLength);
52 return 0;
55 /******************************************************************************
56 * NtQuerySecurityObject [NTDLL.@]
58 * analogue to GetKernelObjectSecurity
60 * NOTES
61 * only the lowest 4 bit of SecurityObjectInformationClass are used
62 * 0x7-0xf returns STATUS_ACCESS_DENIED (even running with system privileges)
64 * FIXME: we are constructing a fake sid
65 * (Administrators:Full, System:Full, Everyone:Read)
67 NTSTATUS WINAPI
68 NtQuerySecurityObject(
69 IN HANDLE Object,
70 IN SECURITY_INFORMATION RequestedInformation,
71 OUT PSECURITY_DESCRIPTOR pSecurityDesriptor,
72 IN ULONG Length,
73 OUT PULONG ResultLength)
75 static SID_IDENTIFIER_AUTHORITY localSidAuthority = {SECURITY_NT_AUTHORITY};
76 static SID_IDENTIFIER_AUTHORITY worldSidAuthority = {SECURITY_WORLD_SID_AUTHORITY};
77 BYTE Buffer[256];
78 PISECURITY_DESCRIPTOR_RELATIVE psd = (PISECURITY_DESCRIPTOR_RELATIVE)Buffer;
79 UINT BufferIndex = sizeof(SECURITY_DESCRIPTOR_RELATIVE);
81 FIXME("(0x%08x,0x%08lx,%p,0x%08lx,%p) stub!\n",
82 Object, RequestedInformation, pSecurityDesriptor, Length, ResultLength);
84 RequestedInformation &= 0x0000000f;
86 if (RequestedInformation & SACL_SECURITY_INFORMATION) return STATUS_ACCESS_DENIED;
88 ZeroMemory(Buffer, 256);
89 RtlCreateSecurityDescriptor((PSECURITY_DESCRIPTOR)psd, SECURITY_DESCRIPTOR_REVISION);
90 psd->Control = SE_SELF_RELATIVE |
91 ((RequestedInformation & DACL_SECURITY_INFORMATION) ? SE_DACL_PRESENT:0);
93 /* owner: administrator S-1-5-20-220*/
94 if (OWNER_SECURITY_INFORMATION & RequestedInformation)
96 PSID psid = (PSID)&(Buffer[BufferIndex]);
98 psd->Owner = BufferIndex;
99 BufferIndex += RtlLengthRequiredSid(2);
101 psid->Revision = SID_REVISION;
102 psid->SubAuthorityCount = 2;
103 psid->IdentifierAuthority = localSidAuthority;
104 psid->SubAuthority[0] = SECURITY_BUILTIN_DOMAIN_RID;
105 psid->SubAuthority[1] = DOMAIN_ALIAS_RID_ADMINS;
108 /* group: built in domain S-1-5-12 */
109 if (GROUP_SECURITY_INFORMATION & RequestedInformation)
111 PSID psid = (PSID) &(Buffer[BufferIndex]);
113 psd->Group = BufferIndex;
114 BufferIndex += RtlLengthRequiredSid(1);
116 psid->Revision = SID_REVISION;
117 psid->SubAuthorityCount = 1;
118 psid->IdentifierAuthority = localSidAuthority;
119 psid->SubAuthority[0] = SECURITY_LOCAL_SYSTEM_RID;
122 /* discretionary ACL */
123 if (DACL_SECURITY_INFORMATION & RequestedInformation)
125 /* acl header */
126 PACL pacl = (PACL)&(Buffer[BufferIndex]);
127 PACCESS_ALLOWED_ACE pace;
128 PSID psid;
130 psd->Dacl = BufferIndex;
132 pacl->AclRevision = MIN_ACL_REVISION;
133 pacl->AceCount = 3;
134 pacl->AclSize = BufferIndex; /* storing the start index temporary */
136 BufferIndex += sizeof(ACL);
138 /* ACE System - full access */
139 pace = (PACCESS_ALLOWED_ACE)&(Buffer[BufferIndex]);
140 BufferIndex += sizeof(ACCESS_ALLOWED_ACE)-sizeof(DWORD);
142 pace->Header.AceType = ACCESS_ALLOWED_ACE_TYPE;
143 pace->Header.AceFlags = CONTAINER_INHERIT_ACE;
144 pace->Header.AceSize = sizeof(ACCESS_ALLOWED_ACE)-sizeof(DWORD) + RtlLengthRequiredSid(1);
145 pace->Mask = DELETE | READ_CONTROL | WRITE_DAC | WRITE_OWNER | 0x3f;
146 pace->SidStart = BufferIndex;
148 /* SID S-1-5-12 (System) */
149 psid = (PSID)&(Buffer[BufferIndex]);
151 BufferIndex += RtlLengthRequiredSid(1);
153 psid->Revision = SID_REVISION;
154 psid->SubAuthorityCount = 1;
155 psid->IdentifierAuthority = localSidAuthority;
156 psid->SubAuthority[0] = SECURITY_LOCAL_SYSTEM_RID;
158 /* ACE Administrators - full access*/
159 pace = (PACCESS_ALLOWED_ACE) &(Buffer[BufferIndex]);
160 BufferIndex += sizeof(ACCESS_ALLOWED_ACE)-sizeof(DWORD);
162 pace->Header.AceType = ACCESS_ALLOWED_ACE_TYPE;
163 pace->Header.AceFlags = CONTAINER_INHERIT_ACE;
164 pace->Header.AceSize = sizeof(ACCESS_ALLOWED_ACE)-sizeof(DWORD) + RtlLengthRequiredSid(2);
165 pace->Mask = DELETE | READ_CONTROL | WRITE_DAC | WRITE_OWNER | 0x3f;
166 pace->SidStart = BufferIndex;
168 /* S-1-5-12 (Administrators) */
169 psid = (PSID)&(Buffer[BufferIndex]);
171 BufferIndex += RtlLengthRequiredSid(2);
173 psid->Revision = SID_REVISION;
174 psid->SubAuthorityCount = 2;
175 psid->IdentifierAuthority = localSidAuthority;
176 psid->SubAuthority[0] = SECURITY_BUILTIN_DOMAIN_RID;
177 psid->SubAuthority[1] = DOMAIN_ALIAS_RID_ADMINS;
179 /* ACE Everyone - read access */
180 pace = (PACCESS_ALLOWED_ACE)&(Buffer[BufferIndex]);
181 BufferIndex += sizeof(ACCESS_ALLOWED_ACE)-sizeof(DWORD);
183 pace->Header.AceType = ACCESS_ALLOWED_ACE_TYPE;
184 pace->Header.AceFlags = CONTAINER_INHERIT_ACE;
185 pace->Header.AceSize = sizeof(ACCESS_ALLOWED_ACE)-sizeof(DWORD) + RtlLengthRequiredSid(1);
186 pace->Mask = READ_CONTROL| 0x19;
187 pace->SidStart = BufferIndex;
189 /* SID S-1-1-0 (Everyone) */
190 psid = (PSID)&(Buffer[BufferIndex]);
192 BufferIndex += RtlLengthRequiredSid(1);
194 psid->Revision = SID_REVISION;
195 psid->SubAuthorityCount = 1;
196 psid->IdentifierAuthority = worldSidAuthority;
197 psid->SubAuthority[0] = 0;
199 /* calculate used bytes */
200 pacl->AclSize = BufferIndex - pacl->AclSize;
202 *ResultLength = BufferIndex;
203 TRACE("len=%lu\n", *ResultLength);
204 if (Length < *ResultLength) return STATUS_BUFFER_TOO_SMALL;
205 memcpy(pSecurityDesriptor, Buffer, *ResultLength);
207 return STATUS_SUCCESS;
209 /******************************************************************************
210 * NtDuplicateObject [NTDLL.@]
211 * ZwDuplicateObject [NTDLL.@]
213 NTSTATUS WINAPI NtDuplicateObject(
214 IN HANDLE SourceProcessHandle,
215 IN PHANDLE SourceHandle,
216 IN HANDLE TargetProcessHandle,
217 OUT PHANDLE TargetHandle,
218 IN ACCESS_MASK DesiredAccess,
219 IN BOOLEAN InheritHandle,
220 ULONG Options)
222 FIXME("(0x%08x,%p,0x%08x,%p,0x%08lx,0x%08x,0x%08lx) stub!\n",
223 SourceProcessHandle,SourceHandle,TargetProcessHandle,TargetHandle,
224 DesiredAccess,InheritHandle,Options);
225 *TargetHandle = 0;
226 return 0;
229 /**************************************************************************
230 * NtClose [NTDLL.@]
231 * FUNCTION: Closes a handle reference to an object
232 * ARGUMENTS:
233 * Handle handle to close
235 NTSTATUS WINAPI NtClose( HANDLE Handle )
237 NTSTATUS ret;
238 SERVER_START_REQ( close_handle )
240 req->handle = Handle;
241 ret = wine_server_call( req );
242 if (!ret && reply->fd != -1) close( reply->fd );
244 SERVER_END_REQ;
245 return ret;
248 /******************************************************************************
249 * NtWaitForSingleObject [NTDLL.@]
250 * ZwWaitForSingleObject [NTDLL.@]
252 NTSTATUS WINAPI NtWaitForSingleObject(
253 IN PHANDLE Object,
254 IN BOOLEAN Alertable,
255 IN PLARGE_INTEGER Time)
257 FIXME("(%p,0x%08x,%p),stub!\n",Object,Alertable,Time);
258 return 0;
262 * Directory functions
265 /**************************************************************************
266 * NtOpenDirectoryObject [NTDLL.@]
267 * ZwOpenDirectoryObject [NTDLL.@]
268 * FUNCTION: Opens a namespace directory object
269 * ARGUMENTS:
270 * DirectoryHandle Variable which receives the directory handle
271 * DesiredAccess Desired access to the directory
272 * ObjectAttributes Structure describing the directory
273 * RETURNS: Status
275 NTSTATUS WINAPI NtOpenDirectoryObject(
276 PHANDLE DirectoryHandle,
277 ACCESS_MASK DesiredAccess,
278 POBJECT_ATTRIBUTES ObjectAttributes)
280 FIXME("(%p,0x%08lx,%p): stub\n",
281 DirectoryHandle, DesiredAccess, ObjectAttributes);
282 dump_ObjectAttributes(ObjectAttributes);
283 return 0;
286 /******************************************************************************
287 * NtCreateDirectoryObject [NTDLL.@]
288 * ZwCreateDirectoryObject [NTDLL.@]
290 NTSTATUS WINAPI NtCreateDirectoryObject(
291 PHANDLE DirectoryHandle,
292 ACCESS_MASK DesiredAccess,
293 POBJECT_ATTRIBUTES ObjectAttributes)
295 FIXME("(%p,0x%08lx,%p),stub!\n",
296 DirectoryHandle,DesiredAccess,ObjectAttributes);
297 dump_ObjectAttributes(ObjectAttributes);
298 return 0;
301 /******************************************************************************
302 * NtQueryDirectoryObject [NTDLL.@]
303 * ZwQueryDirectoryObject [NTDLL.@]
304 * FUNCTION: Reads information from a namespace directory
305 * ARGUMENTS:
306 * DirObjInformation Buffer to hold the data read
307 * BufferLength Size of the buffer in bytes
308 * GetNextIndex If TRUE then set ObjectIndex to the index of the next object
309 * If FALSE then set ObjectIndex to the number of objects in the directory
310 * IgnoreInputIndex If TRUE start reading at index 0
311 * If FALSE start reading at the index specified by object index
312 * ObjectIndex Zero based index into the directory, interpretation depends on IgnoreInputIndex and GetNextIndex
313 * DataWritten Caller supplied storage for the number of bytes written (or NULL)
315 NTSTATUS WINAPI NtQueryDirectoryObject(
316 IN HANDLE DirObjHandle,
317 OUT POBJDIR_INFORMATION DirObjInformation,
318 IN ULONG BufferLength,
319 IN BOOLEAN GetNextIndex,
320 IN BOOLEAN IgnoreInputIndex,
321 IN OUT PULONG ObjectIndex,
322 OUT PULONG DataWritten OPTIONAL)
324 FIXME("(0x%08x,%p,0x%08lx,0x%08x,0x%08x,%p,%p) stub\n",
325 DirObjHandle, DirObjInformation, BufferLength, GetNextIndex,
326 IgnoreInputIndex, ObjectIndex, DataWritten);
327 return 0xc0000000; /* We don't have any. Whatever. (Yet.) */
331 * Link objects
334 /******************************************************************************
335 * NtOpenSymbolicLinkObject [NTDLL.@]
337 NTSTATUS WINAPI NtOpenSymbolicLinkObject(
338 OUT PHANDLE LinkHandle,
339 IN ACCESS_MASK DesiredAccess,
340 IN POBJECT_ATTRIBUTES ObjectAttributes)
342 FIXME("(%p,0x%08lx,%p) stub\n",
343 LinkHandle, DesiredAccess, ObjectAttributes);
344 dump_ObjectAttributes(ObjectAttributes);
345 return 0;
348 /******************************************************************************
349 * NtCreateSymbolicLinkObject [NTDLL.@]
351 NTSTATUS WINAPI NtCreateSymbolicLinkObject(
352 OUT PHANDLE SymbolicLinkHandle,
353 IN ACCESS_MASK DesiredAccess,
354 IN POBJECT_ATTRIBUTES ObjectAttributes,
355 IN PUNICODE_STRING Name)
357 FIXME("(%p,0x%08lx,%p, %p) stub\n",
358 SymbolicLinkHandle, DesiredAccess, ObjectAttributes, debugstr_us(Name));
359 dump_ObjectAttributes(ObjectAttributes);
360 return 0;
363 /******************************************************************************
364 * NtQuerySymbolicLinkObject [NTDLL.@]
366 NTSTATUS WINAPI NtQuerySymbolicLinkObject(
367 IN HANDLE LinkHandle,
368 IN OUT PUNICODE_STRING LinkTarget,
369 OUT PULONG ReturnedLength OPTIONAL)
371 FIXME("(0x%08x,%p,%p) stub\n",
372 LinkHandle, debugstr_us(LinkTarget), ReturnedLength);
374 return 0;
377 /******************************************************************************
378 * NtAllocateUuids [NTDLL.@]
380 * I have seen lpdwCount pointing to a pointer once...
382 NTSTATUS WINAPI NtAllocateUuids(LPDWORD lpdwCount, LPDWORD *p2, LPDWORD *p3)
384 FIXME("(%p[%ld],%p,%p), stub.\n", lpdwCount,
385 lpdwCount ? *lpdwCount : 0,
386 p2, p3);
387 return 0;