Moved GUID definitions to their respective dll.
[wine/gsoc_dplay.git] / dlls / ntdll / om.c
blob8a3da0620fede23d973f2128c3101501b4d0e7a6
1 /*
2 * Object management functions
3 */
5 #include <stdlib.h>
6 #include <string.h>
7 #include "debugtools.h"
9 #include "ntddk.h"
10 #include "ntdll_misc.h"
11 #include "server.h"
13 DEFAULT_DEBUG_CHANNEL(ntdll);
15 /* move to somewhere */
16 typedef void * POBJDIR_INFORMATION;
19 * Generic object functions
22 /******************************************************************************
23 * NtQueryObject [NTDLL.161]
25 NTSTATUS WINAPI NtQueryObject(
26 IN HANDLE ObjectHandle,
27 IN OBJECT_INFORMATION_CLASS ObjectInformationClass,
28 OUT PVOID ObjectInformation,
29 IN ULONG Length,
30 OUT PULONG ResultLength)
32 FIXME("(0x%08x,0x%08x,%p,0x%08lx,%p): stub\n",
33 ObjectHandle, ObjectInformationClass, ObjectInformation, Length, ResultLength);
34 return 0;
37 /******************************************************************************
38 * NtQuerySecurityObject [NTDLL]
40 * analogue to GetKernelObjectSecurity
42 * NOTES
43 * only the lowest 4 bit of SecurityObjectInformationClass are used
44 * 0x7-0xf returns STATUS_ACCESS_DENIED (even running with system priviledges)
46 * FIXME: we are constructing a fake sid
47 * (Administrators:Full, System:Full, Everyone:Read)
49 NTSTATUS WINAPI
50 NtQuerySecurityObject(
51 IN HANDLE Object,
52 IN SECURITY_INFORMATION RequestedInformation,
53 OUT PSECURITY_DESCRIPTOR pSecurityDesriptor,
54 IN ULONG Length,
55 OUT PULONG ResultLength)
57 static SID_IDENTIFIER_AUTHORITY localSidAuthority = {SECURITY_NT_AUTHORITY};
58 static SID_IDENTIFIER_AUTHORITY worldSidAuthority = {SECURITY_WORLD_SID_AUTHORITY};
59 BYTE Buffer[256];
60 PISECURITY_DESCRIPTOR_RELATIVE psd = (PISECURITY_DESCRIPTOR_RELATIVE)Buffer;
61 UINT BufferIndex = sizeof(SECURITY_DESCRIPTOR_RELATIVE);
63 FIXME("(0x%08x,0x%08lx,%p,0x%08lx,%p) stub!\n",
64 Object, RequestedInformation, pSecurityDesriptor, Length, ResultLength);
66 RequestedInformation &= 0x0000000f;
68 if (RequestedInformation & SACL_SECURITY_INFORMATION) return STATUS_ACCESS_DENIED;
70 ZeroMemory(Buffer, 256);
71 RtlCreateSecurityDescriptor((PSECURITY_DESCRIPTOR)psd, SECURITY_DESCRIPTOR_REVISION);
72 psd->Control = SE_SELF_RELATIVE |
73 ((RequestedInformation & DACL_SECURITY_INFORMATION) ? SE_DACL_PRESENT:0);
75 /* owner: administrator S-1-5-20-220*/
76 if (OWNER_SECURITY_INFORMATION & RequestedInformation)
78 PSID psid = (PSID)&(Buffer[BufferIndex]);
80 psd->Owner = BufferIndex;
81 BufferIndex += RtlLengthRequiredSid(2);
83 psid->Revision = SID_REVISION;
84 psid->SubAuthorityCount = 2;
85 psid->IdentifierAuthority = localSidAuthority;
86 psid->SubAuthority[0] = SECURITY_BUILTIN_DOMAIN_RID;
87 psid->SubAuthority[1] = DOMAIN_ALIAS_RID_ADMINS;
90 /* group: built in domain S-1-5-12 */
91 if (GROUP_SECURITY_INFORMATION & RequestedInformation)
93 PSID psid = (PSID) &(Buffer[BufferIndex]);
95 psd->Group = BufferIndex;
96 BufferIndex += RtlLengthRequiredSid(1);
98 psid->Revision = SID_REVISION;
99 psid->SubAuthorityCount = 1;
100 psid->IdentifierAuthority = localSidAuthority;
101 psid->SubAuthority[0] = SECURITY_LOCAL_SYSTEM_RID;
104 /* discretionary ACL */
105 if (DACL_SECURITY_INFORMATION & RequestedInformation)
107 /* acl header */
108 PACL pacl = (PACL)&(Buffer[BufferIndex]);
109 PACCESS_ALLOWED_ACE pace;
110 PSID psid;
112 psd->Dacl = BufferIndex;
114 pacl->AclRevision = MIN_ACL_REVISION;
115 pacl->AceCount = 3;
116 pacl->AclSize = BufferIndex; /* storing the start index temporary */
118 BufferIndex += sizeof(ACL);
120 /* ACE System - full access */
121 pace = (PACCESS_ALLOWED_ACE)&(Buffer[BufferIndex]);
122 BufferIndex += sizeof(ACCESS_ALLOWED_ACE)-sizeof(DWORD);
124 pace->Header.AceType = ACCESS_ALLOWED_ACE_TYPE;
125 pace->Header.AceFlags = CONTAINER_INHERIT_ACE;
126 pace->Header.AceSize = sizeof(ACCESS_ALLOWED_ACE)-sizeof(DWORD) + RtlLengthRequiredSid(1);
127 pace->Mask = DELETE | READ_CONTROL | WRITE_DAC | WRITE_OWNER | 0x3f;
128 pace->SidStart = BufferIndex;
130 /* SID S-1-5-12 (System) */
131 psid = (PSID)&(Buffer[BufferIndex]);
133 BufferIndex += RtlLengthRequiredSid(1);
135 psid->Revision = SID_REVISION;
136 psid->SubAuthorityCount = 1;
137 psid->IdentifierAuthority = localSidAuthority;
138 psid->SubAuthority[0] = SECURITY_LOCAL_SYSTEM_RID;
140 /* ACE Administrators - full access*/
141 pace = (PACCESS_ALLOWED_ACE) &(Buffer[BufferIndex]);
142 BufferIndex += sizeof(ACCESS_ALLOWED_ACE)-sizeof(DWORD);
144 pace->Header.AceType = ACCESS_ALLOWED_ACE_TYPE;
145 pace->Header.AceFlags = CONTAINER_INHERIT_ACE;
146 pace->Header.AceSize = sizeof(ACCESS_ALLOWED_ACE)-sizeof(DWORD) + RtlLengthRequiredSid(2);
147 pace->Mask = DELETE | READ_CONTROL | WRITE_DAC | WRITE_OWNER | 0x3f;
148 pace->SidStart = BufferIndex;
150 /* S-1-5-12 (Administrators) */
151 psid = (PSID)&(Buffer[BufferIndex]);
153 BufferIndex += RtlLengthRequiredSid(2);
155 psid->Revision = SID_REVISION;
156 psid->SubAuthorityCount = 2;
157 psid->IdentifierAuthority = localSidAuthority;
158 psid->SubAuthority[0] = SECURITY_BUILTIN_DOMAIN_RID;
159 psid->SubAuthority[1] = DOMAIN_ALIAS_RID_ADMINS;
161 /* ACE Everyone - read access */
162 pace = (PACCESS_ALLOWED_ACE)&(Buffer[BufferIndex]);
163 BufferIndex += sizeof(ACCESS_ALLOWED_ACE)-sizeof(DWORD);
165 pace->Header.AceType = ACCESS_ALLOWED_ACE_TYPE;
166 pace->Header.AceFlags = CONTAINER_INHERIT_ACE;
167 pace->Header.AceSize = sizeof(ACCESS_ALLOWED_ACE)-sizeof(DWORD) + RtlLengthRequiredSid(1);
168 pace->Mask = READ_CONTROL| 0x19;
169 pace->SidStart = BufferIndex;
171 /* SID S-1-1-0 (Everyone) */
172 psid = (PSID)&(Buffer[BufferIndex]);
174 BufferIndex += RtlLengthRequiredSid(1);
176 psid->Revision = SID_REVISION;
177 psid->SubAuthorityCount = 1;
178 psid->IdentifierAuthority = worldSidAuthority;
179 psid->SubAuthority[0] = 0;
181 /* calculate used bytes */
182 pacl->AclSize = BufferIndex - pacl->AclSize;
184 *ResultLength = BufferIndex;
185 TRACE("len=%lu\n", *ResultLength);
186 if (Length < *ResultLength) return STATUS_BUFFER_TOO_SMALL;
187 memcpy(pSecurityDesriptor, Buffer, *ResultLength);
189 return STATUS_SUCCESS;
191 /******************************************************************************
192 * NtDuplicateObject [NTDLL]
194 NTSTATUS WINAPI NtDuplicateObject(
195 IN HANDLE SourceProcessHandle,
196 IN PHANDLE SourceHandle,
197 IN HANDLE TargetProcessHandle,
198 OUT PHANDLE TargetHandle,
199 IN ACCESS_MASK DesiredAccess,
200 IN BOOLEAN InheritHandle,
201 ULONG Options)
203 FIXME("(0x%08x,%p,0x%08x,%p,0x%08lx,0x%08x,0x%08lx) stub!\n",
204 SourceProcessHandle,SourceHandle,TargetProcessHandle,TargetHandle,
205 DesiredAccess,InheritHandle,Options);
206 *TargetHandle = 0;
207 return 0;
210 /**************************************************************************
211 * NtClose [NTDLL.65]
212 * FUNCTION: Closes a handle reference to an object
213 * ARGUMENTS:
214 * Handle handle to close
216 NTSTATUS WINAPI NtClose( HANDLE Handle )
218 struct close_handle_request *req = get_req_buffer();
219 req->handle = Handle;
220 return server_call_noerr( REQ_CLOSE_HANDLE );
223 /******************************************************************************
224 * NtWaitForSingleObject [NTDLL]
226 NTSTATUS WINAPI NtWaitForSingleObject(
227 IN PHANDLE Object,
228 IN BOOLEAN Alertable,
229 IN PLARGE_INTEGER Time)
231 FIXME("(%p,0x%08x,%p),stub!\n",Object,Alertable,Time);
232 return 0;
236 * Directory functions
239 /**************************************************************************
240 * NtOpenDirectoryObject [NTDLL.124]
241 * FUNCTION: Opens a namespace directory object
242 * ARGUMENTS:
243 * DirectoryHandle Variable which receives the directory handle
244 * DesiredAccess Desired access to the directory
245 * ObjectAttributes Structure describing the directory
246 * RETURNS: Status
248 NTSTATUS WINAPI NtOpenDirectoryObject(
249 PHANDLE DirectoryHandle,
250 ACCESS_MASK DesiredAccess,
251 POBJECT_ATTRIBUTES ObjectAttributes)
253 FIXME("(%p,0x%08lx,%p): stub\n",
254 DirectoryHandle, DesiredAccess, ObjectAttributes);
255 dump_ObjectAttributes(ObjectAttributes);
256 return 0;
259 /******************************************************************************
260 * NtCreateDirectoryObject [NTDLL]
262 NTSTATUS WINAPI NtCreateDirectoryObject(
263 PHANDLE DirectoryHandle,
264 ACCESS_MASK DesiredAccess,
265 POBJECT_ATTRIBUTES ObjectAttributes)
267 FIXME("(%p,0x%08lx,%p),stub!\n",
268 DirectoryHandle,DesiredAccess,ObjectAttributes);
269 dump_ObjectAttributes(ObjectAttributes);
270 return 0;
273 /******************************************************************************
274 * NtQueryDirectoryObject [NTDLL.149]
275 * FUNCTION: Reads information from a namespace directory
276 * ARGUMENTS:
277 * DirObjInformation Buffer to hold the data read
278 * BufferLength Size of the buffer in bytes
279 * GetNextIndex If TRUE then set ObjectIndex to the index of the next object
280 * If FALSE then set ObjectIndex to the number of objects in the directory
281 * IgnoreInputIndex If TRUE start reading at index 0
282 * If FALSE start reading at the index specified by object index
283 * ObjectIndex Zero based index into the directory, interpretation depends on IgnoreInputIndex and GetNextIndex
284 * DataWritten Caller supplied storage for the number of bytes written (or NULL)
286 NTSTATUS WINAPI NtQueryDirectoryObject(
287 IN HANDLE DirObjHandle,
288 OUT POBJDIR_INFORMATION DirObjInformation,
289 IN ULONG BufferLength,
290 IN BOOLEAN GetNextIndex,
291 IN BOOLEAN IgnoreInputIndex,
292 IN OUT PULONG ObjectIndex,
293 OUT PULONG DataWritten OPTIONAL)
295 FIXME("(0x%08x,%p,0x%08lx,0x%08x,0x%08x,%p,%p) stub\n",
296 DirObjHandle, DirObjInformation, BufferLength, GetNextIndex,
297 IgnoreInputIndex, ObjectIndex, DataWritten);
298 return 0xc0000000; /* We don't have any. Whatever. (Yet.) */
302 * Link objects
305 /******************************************************************************
306 * NtOpenSymbolicLinkObject [NTDLL]
308 NTSTATUS WINAPI NtOpenSymbolicLinkObject(
309 OUT PHANDLE LinkHandle,
310 IN ACCESS_MASK DesiredAccess,
311 IN POBJECT_ATTRIBUTES ObjectAttributes)
313 FIXME("(%p,0x%08lx,%p) stub\n",
314 LinkHandle, DesiredAccess, ObjectAttributes);
315 dump_ObjectAttributes(ObjectAttributes);
316 return 0;
319 /******************************************************************************
320 * NtCreateSymbolicLinkObject [NTDLL]
322 NTSTATUS WINAPI NtCreateSymbolicLinkObject(
323 OUT PHANDLE SymbolicLinkHandle,
324 IN ACCESS_MASK DesiredAccess,
325 IN POBJECT_ATTRIBUTES ObjectAttributes,
326 IN PUNICODE_STRING Name)
328 FIXME("(%p,0x%08lx,%p, %p) stub\n",
329 SymbolicLinkHandle, DesiredAccess, ObjectAttributes, debugstr_us(Name));
330 dump_ObjectAttributes(ObjectAttributes);
331 return 0;
334 /******************************************************************************
335 * NtQuerySymbolicLinkObject [NTDLL]
337 NTSTATUS WINAPI NtQuerySymbolicLinkObject(
338 IN HANDLE LinkHandle,
339 IN OUT PUNICODE_STRING LinkTarget,
340 OUT PULONG ReturnedLength OPTIONAL)
342 FIXME("(0x%08x,%p,%p) stub\n",
343 LinkHandle, debugstr_us(LinkTarget), ReturnedLength);
345 return 0;
348 /******************************************************************************
349 * NtAllocateUuids [NTDLL]
351 * I have seen lpdwCount pointing to a pointer once...
353 NTSTATUS WINAPI NtAllocateUuids(LPDWORD lpdwCount, LPDWORD *p2, LPDWORD *p3)
355 FIXME("(%p[%ld],%p,%p), stub.\n", lpdwCount,
356 lpdwCount ? *lpdwCount : 0,
357 p2, p3);
358 return 0;