| 1 | /* $Id: om.cpp,v 1.3 2000-02-03 21:39:12 sandervl Exp $ */
|
|---|
| 2 |
|
|---|
| 3 | /*
|
|---|
| 4 | * Project Odin Software License can be found in LICENSE.TXT
|
|---|
| 5 | * Win32 NT Runtime / NTDLL for OS/2
|
|---|
| 6 | *
|
|---|
| 7 | * Copyright 1998 original WINE Author
|
|---|
| 8 | * Copyright 1998, 1999 Patrick Haller (phaller@gmx.net)
|
|---|
| 9 | *
|
|---|
| 10 | * Object management functions
|
|---|
| 11 | */
|
|---|
| 12 |
|
|---|
| 13 | #include <stdlib.h>
|
|---|
| 14 | #include <string.h>
|
|---|
| 15 |
|
|---|
| 16 | #include "ntdll.h"
|
|---|
| 17 |
|
|---|
| 18 | /* move to somewhere */
|
|---|
| 19 | typedef void * POBJDIR_INFORMATION;
|
|---|
| 20 |
|
|---|
| 21 | /*
|
|---|
| 22 | * Generic object functions
|
|---|
| 23 | */
|
|---|
| 24 |
|
|---|
| 25 | /******************************************************************************
|
|---|
| 26 | * NtQueryObject [NTDLL.161]
|
|---|
| 27 | */
|
|---|
| 28 | NTSTATUS WINAPI NtQueryObject(HANDLE ObjectHandle,
|
|---|
| 29 | OBJECT_INFORMATION_CLASS ObjectInformationClass,
|
|---|
| 30 | PVOID ObjectInformation,
|
|---|
| 31 | ULONG Length,
|
|---|
| 32 | PULONG ResultLength)
|
|---|
| 33 | {
|
|---|
| 34 | dprintf(("NTDLL: NtQueryObject(%08xh,%08xh,%08xh,%08xh,%08xh) not implemented.\n",
|
|---|
| 35 | ObjectHandle,
|
|---|
| 36 | ObjectInformationClass,
|
|---|
| 37 | ObjectInformation,
|
|---|
| 38 | Length,
|
|---|
| 39 | ResultLength));
|
|---|
| 40 |
|
|---|
| 41 | return 0;
|
|---|
| 42 | }
|
|---|
| 43 |
|
|---|
| 44 |
|
|---|
| 45 | /******************************************************************************
|
|---|
| 46 | * NtQuerySecurityObject [NTDLL]
|
|---|
| 47 | */
|
|---|
| 48 | NTSTATUS WINAPI NtQuerySecurityObject(
|
|---|
| 49 | IN HANDLE Object,
|
|---|
| 50 | IN SECURITY_INFORMATION RequestedInformation,
|
|---|
| 51 | OUT PSECURITY_DESCRIPTOR pSecurityDesriptor,
|
|---|
| 52 | IN ULONG Length,
|
|---|
| 53 | OUT PULONG ResultLength)
|
|---|
| 54 | {
|
|---|
| 55 | static SID_IDENTIFIER_AUTHORITY localSidAuthority = {SECURITY_NT_AUTHORITY};
|
|---|
| 56 | static SID_IDENTIFIER_AUTHORITY worldSidAuthority = {SECURITY_WORLD_SID_AUTHORITY};
|
|---|
| 57 | BYTE Buffer[256];
|
|---|
| 58 | PISECURITY_DESCRIPTOR_RELATIVE psd = (PISECURITY_DESCRIPTOR_RELATIVE)Buffer;
|
|---|
| 59 | UINT BufferIndex = sizeof(SECURITY_DESCRIPTOR_RELATIVE);
|
|---|
| 60 |
|
|---|
| 61 | dprintf(("(0x%08x,0x%08lx,%p,0x%08lx,%p) stub!\n",
|
|---|
| 62 | Object, RequestedInformation, pSecurityDesriptor, Length, ResultLength));
|
|---|
| 63 |
|
|---|
| 64 | RequestedInformation &= 0x0000000f;
|
|---|
| 65 |
|
|---|
| 66 | if (RequestedInformation & SACL_SECURITY_INFORMATION) return STATUS_ACCESS_DENIED;
|
|---|
| 67 |
|
|---|
| 68 | ZeroMemory(Buffer, 256);
|
|---|
| 69 | RtlCreateSecurityDescriptor((PSECURITY_DESCRIPTOR)psd, SECURITY_DESCRIPTOR_REVISION);
|
|---|
| 70 | psd->Control = SE_SELF_RELATIVE |
|
|---|
| 71 | ((RequestedInformation & DACL_SECURITY_INFORMATION) ? SE_DACL_PRESENT:0);
|
|---|
| 72 |
|
|---|
| 73 | /* owner: administrator S-1-5-20-220*/
|
|---|
| 74 | if (OWNER_SECURITY_INFORMATION & RequestedInformation)
|
|---|
| 75 | {
|
|---|
| 76 | PSID psid = (PSID)&(Buffer[BufferIndex]);
|
|---|
| 77 |
|
|---|
| 78 | psd->Owner = BufferIndex;
|
|---|
| 79 | BufferIndex += RtlLengthRequiredSid(2);
|
|---|
| 80 |
|
|---|
| 81 | psid->Revision = SID_REVISION;
|
|---|
| 82 | psid->SubAuthorityCount = 2;
|
|---|
| 83 | psid->IdentifierAuthority = localSidAuthority;
|
|---|
| 84 | psid->SubAuthority[0] = SECURITY_BUILTIN_DOMAIN_RID;
|
|---|
| 85 | psid->SubAuthority[1] = DOMAIN_ALIAS_RID_ADMINS;
|
|---|
| 86 | }
|
|---|
| 87 |
|
|---|
| 88 | /* group: built in domain S-1-5-12 */
|
|---|
| 89 | if (GROUP_SECURITY_INFORMATION & RequestedInformation)
|
|---|
| 90 | {
|
|---|
| 91 | PSID psid = (PSID) &(Buffer[BufferIndex]);
|
|---|
| 92 |
|
|---|
| 93 | psd->Group = BufferIndex;
|
|---|
| 94 | BufferIndex += RtlLengthRequiredSid(1);
|
|---|
| 95 |
|
|---|
| 96 | psid->Revision = SID_REVISION;
|
|---|
| 97 | psid->SubAuthorityCount = 1;
|
|---|
| 98 | psid->IdentifierAuthority = localSidAuthority;
|
|---|
| 99 | psid->SubAuthority[0] = SECURITY_LOCAL_SYSTEM_RID;
|
|---|
| 100 | }
|
|---|
| 101 |
|
|---|
| 102 | /* discretionary ACL */
|
|---|
| 103 | if (DACL_SECURITY_INFORMATION & RequestedInformation)
|
|---|
| 104 | {
|
|---|
| 105 | /* acl header */
|
|---|
| 106 | PACL pacl = (PACL)&(Buffer[BufferIndex]);
|
|---|
| 107 | PACCESS_ALLOWED_ACE pace;
|
|---|
| 108 | PSID psid;
|
|---|
| 109 |
|
|---|
| 110 | psd->Dacl = BufferIndex;
|
|---|
| 111 |
|
|---|
| 112 | pacl->AclRevision = MIN_ACL_REVISION;
|
|---|
| 113 | pacl->AceCount = 3;
|
|---|
| 114 | pacl->AclSize = BufferIndex; /* storing the start index temporary */
|
|---|
| 115 |
|
|---|
| 116 | BufferIndex += sizeof(ACL);
|
|---|
| 117 |
|
|---|
| 118 | /* ACE System - full access */
|
|---|
| 119 | pace = (PACCESS_ALLOWED_ACE)&(Buffer[BufferIndex]);
|
|---|
| 120 | BufferIndex += sizeof(ACCESS_ALLOWED_ACE)-sizeof(DWORD);
|
|---|
| 121 |
|
|---|
| 122 | pace->Header.AceType = ACCESS_ALLOWED_ACE_TYPE;
|
|---|
| 123 | pace->Header.AceFlags = CONTAINER_INHERIT_ACE;
|
|---|
| 124 | pace->Header.AceSize = sizeof(ACCESS_ALLOWED_ACE)-sizeof(DWORD) + RtlLengthRequiredSid(1);
|
|---|
| 125 | pace->Mask = DELETE | READ_CONTROL | WRITE_DAC | WRITE_OWNER | 0x3f;
|
|---|
| 126 | pace->SidStart = BufferIndex;
|
|---|
| 127 |
|
|---|
| 128 | /* SID S-1-5-12 (System) */
|
|---|
| 129 | psid = (PSID)&(Buffer[BufferIndex]);
|
|---|
| 130 |
|
|---|
| 131 | BufferIndex += RtlLengthRequiredSid(1);
|
|---|
| 132 |
|
|---|
| 133 | psid->Revision = SID_REVISION;
|
|---|
| 134 | psid->SubAuthorityCount = 1;
|
|---|
| 135 | psid->IdentifierAuthority = localSidAuthority;
|
|---|
| 136 | psid->SubAuthority[0] = SECURITY_LOCAL_SYSTEM_RID;
|
|---|
| 137 |
|
|---|
| 138 | /* ACE Administrators - full access*/
|
|---|
| 139 | pace = (PACCESS_ALLOWED_ACE) &(Buffer[BufferIndex]);
|
|---|
| 140 | BufferIndex += sizeof(ACCESS_ALLOWED_ACE)-sizeof(DWORD);
|
|---|
| 141 |
|
|---|
| 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(2);
|
|---|
| 145 | pace->Mask = DELETE | READ_CONTROL | WRITE_DAC | WRITE_OWNER | 0x3f;
|
|---|
| 146 | pace->SidStart = BufferIndex;
|
|---|
| 147 |
|
|---|
| 148 | /* S-1-5-12 (Administrators) */
|
|---|
| 149 | psid = (PSID)&(Buffer[BufferIndex]);
|
|---|
| 150 |
|
|---|
| 151 | BufferIndex += RtlLengthRequiredSid(2);
|
|---|
| 152 |
|
|---|
| 153 | psid->Revision = SID_REVISION;
|
|---|
| 154 | psid->SubAuthorityCount = 2;
|
|---|
| 155 | psid->IdentifierAuthority = localSidAuthority;
|
|---|
| 156 | psid->SubAuthority[0] = SECURITY_BUILTIN_DOMAIN_RID;
|
|---|
| 157 | psid->SubAuthority[1] = DOMAIN_ALIAS_RID_ADMINS;
|
|---|
| 158 |
|
|---|
| 159 | /* ACE Everyone - read access */
|
|---|
| 160 | pace = (PACCESS_ALLOWED_ACE)&(Buffer[BufferIndex]);
|
|---|
| 161 | BufferIndex += sizeof(ACCESS_ALLOWED_ACE)-sizeof(DWORD);
|
|---|
| 162 |
|
|---|
| 163 | pace->Header.AceType = ACCESS_ALLOWED_ACE_TYPE;
|
|---|
| 164 | pace->Header.AceFlags = CONTAINER_INHERIT_ACE;
|
|---|
| 165 | pace->Header.AceSize = sizeof(ACCESS_ALLOWED_ACE)-sizeof(DWORD) + RtlLengthRequiredSid(1);
|
|---|
| 166 | pace->Mask = READ_CONTROL| 0x19;
|
|---|
| 167 | pace->SidStart = BufferIndex;
|
|---|
| 168 |
|
|---|
| 169 | /* SID S-1-1-0 (Everyone) */
|
|---|
| 170 | psid = (PSID)&(Buffer[BufferIndex]);
|
|---|
| 171 |
|
|---|
| 172 | BufferIndex += RtlLengthRequiredSid(1);
|
|---|
| 173 |
|
|---|
| 174 | psid->Revision = SID_REVISION;
|
|---|
| 175 | psid->SubAuthorityCount = 1;
|
|---|
| 176 | psid->IdentifierAuthority = worldSidAuthority;
|
|---|
| 177 | psid->SubAuthority[0] = 0;
|
|---|
| 178 |
|
|---|
| 179 | /* calculate used bytes */
|
|---|
| 180 | pacl->AclSize = BufferIndex - pacl->AclSize;
|
|---|
| 181 | }
|
|---|
| 182 | *ResultLength = BufferIndex;
|
|---|
| 183 | dprintf(("len=%lu\n", *ResultLength));
|
|---|
| 184 | if (Length < *ResultLength) return STATUS_BUFFER_TOO_SMALL;
|
|---|
| 185 | memcpy(pSecurityDesriptor, Buffer, *ResultLength);
|
|---|
| 186 |
|
|---|
| 187 | return STATUS_SUCCESS;
|
|---|
| 188 | }
|
|---|
| 189 |
|
|---|
| 190 |
|
|---|
| 191 | /******************************************************************************
|
|---|
| 192 | * NtDuplicateObject [NTDLL]
|
|---|
| 193 | */
|
|---|
| 194 | NTSTATUS WINAPI NtDuplicateObject(HANDLE SourceProcessHandle,
|
|---|
| 195 | PHANDLE SourceHandle,
|
|---|
| 196 | HANDLE TargetProcessHandle,
|
|---|
| 197 | PHANDLE TargetHandle,
|
|---|
| 198 | ACCESS_MASK DesiredAccess,
|
|---|
| 199 | BOOLEAN InheritHandle,
|
|---|
| 200 | ULONG Options)
|
|---|
| 201 | {
|
|---|
| 202 | dprintf (("NTDLL: NtDuplicateObject(%08xh,%08xh,%08xh,%08xh,%08xh,%08xh,%08xh) not implemented.\n",
|
|---|
| 203 | SourceProcessHandle,
|
|---|
| 204 | SourceHandle,
|
|---|
| 205 | TargetProcessHandle,
|
|---|
| 206 | TargetHandle,
|
|---|
| 207 | DesiredAccess,
|
|---|
| 208 | InheritHandle,
|
|---|
| 209 | Options));
|
|---|
| 210 |
|
|---|
| 211 | *TargetHandle = 0;
|
|---|
| 212 | return 0;
|
|---|
| 213 | }
|
|---|
| 214 |
|
|---|
| 215 |
|
|---|
| 216 | /**************************************************************************
|
|---|
| 217 | * NtClose [NTDLL.65]
|
|---|
| 218 | * FUNCTION: Closes a handle reference to an object
|
|---|
| 219 | * ARGUMENTS:
|
|---|
| 220 | * Handle handle to close
|
|---|
| 221 | */
|
|---|
| 222 | NTSTATUS WINAPI NtClose(
|
|---|
| 223 | HANDLE Handle)
|
|---|
| 224 | {
|
|---|
| 225 | dprintf(("(0x%08x)\n",Handle));
|
|---|
| 226 | if (CloseHandle(Handle))
|
|---|
| 227 | return STATUS_SUCCESS;
|
|---|
| 228 | return STATUS_UNSUCCESSFUL; /*fixme*/
|
|---|
| 229 | }
|
|---|
| 230 |
|
|---|
| 231 |
|
|---|
| 232 | /******************************************************************************
|
|---|
| 233 | * NtWaitForSingleObject [NTDLL]
|
|---|
| 234 | */
|
|---|
| 235 | NTSTATUS WINAPI NtWaitForSingleObject(PHANDLE Object,
|
|---|
| 236 | BOOLEAN Alertable,
|
|---|
| 237 | PLARGE_INTEGER Time)
|
|---|
| 238 | {
|
|---|
| 239 | dprintf(("NTDLL: NtWaitForSingleObject(%08xh,%08xh,%08xh) not implemented.\n",
|
|---|
| 240 | Object,
|
|---|
| 241 | Alertable,
|
|---|
| 242 | Time));
|
|---|
| 243 |
|
|---|
| 244 | return 0;
|
|---|
| 245 | }
|
|---|
| 246 |
|
|---|
| 247 |
|
|---|
| 248 | /*
|
|---|
| 249 | * Directory functions
|
|---|
| 250 | */
|
|---|
| 251 |
|
|---|
| 252 | /**************************************************************************
|
|---|
| 253 | * NtOpenDirectoryObject [NTDLL.124]
|
|---|
| 254 | * FUNCTION: Opens a namespace directory object
|
|---|
| 255 | * ARGUMENTS:
|
|---|
| 256 | * DirectoryHandle Variable which receives the directory handle
|
|---|
| 257 | * DesiredAccess Desired access to the directory
|
|---|
| 258 | * ObjectAttributes Structure describing the directory
|
|---|
| 259 | * RETURNS: Status
|
|---|
| 260 | */
|
|---|
| 261 | NTSTATUS WINAPI NtOpenDirectoryObject(PHANDLE DirectoryHandle,
|
|---|
| 262 | ACCESS_MASK DesiredAccess,
|
|---|
| 263 | POBJECT_ATTRIBUTES ObjectAttributes)
|
|---|
| 264 | {
|
|---|
| 265 | dprintf(("NTDLL: NtOpenDirectoryObject(%08xh,%08xh,%08xh) not implemented.\n",
|
|---|
| 266 | DirectoryHandle,
|
|---|
| 267 | DesiredAccess,
|
|---|
| 268 | ObjectAttributes));
|
|---|
| 269 |
|
|---|
| 270 | return 0;
|
|---|
| 271 | }
|
|---|
| 272 |
|
|---|
| 273 |
|
|---|
| 274 | /******************************************************************************
|
|---|
| 275 | * NtCreateDirectoryObject [NTDLL]
|
|---|
| 276 | */
|
|---|
| 277 | NTSTATUS WINAPI NtCreateDirectoryObject(PHANDLE DirectoryHandle,
|
|---|
| 278 | ACCESS_MASK DesiredAccess,
|
|---|
| 279 | POBJECT_ATTRIBUTES ObjectAttributes)
|
|---|
| 280 | {
|
|---|
| 281 | dprintf(("NTDLL: NtCreateDirectoryObject(%08xh,%08xh,%08xh) not implemented.\n",
|
|---|
| 282 | DirectoryHandle,
|
|---|
| 283 | DesiredAccess,
|
|---|
| 284 | ObjectAttributes));
|
|---|
| 285 |
|
|---|
| 286 | return 0;
|
|---|
| 287 | }
|
|---|
| 288 |
|
|---|
| 289 |
|
|---|
| 290 | /******************************************************************************
|
|---|
| 291 | * NtQueryDirectoryObject [NTDLL.149]
|
|---|
| 292 | * FUNCTION: Reads information from a namespace directory
|
|---|
| 293 | * ARGUMENTS:
|
|---|
| 294 | * DirObjInformation Buffer to hold the data read
|
|---|
| 295 | * BufferLength Size of the buffer in bytes
|
|---|
| 296 | * GetNextIndex If TRUE then set ObjectIndex to the index of the next object
|
|---|
| 297 | * If FALSE then set ObjectIndex to the number of objects in the directory
|
|---|
| 298 | * IgnoreInputIndex If TRUE start reading at index 0
|
|---|
| 299 | * If FALSE start reading at the index specified by object index
|
|---|
| 300 | * ObjectIndex Zero based index into the directory, interpretation depends on IgnoreInputIndex and GetNextIndex
|
|---|
| 301 | * DataWritten Caller supplied storage for the number of bytes written (or NULL)
|
|---|
| 302 | */
|
|---|
| 303 | NTSTATUS WINAPI NtQueryDirectoryObject(HANDLE DirObjHandle,
|
|---|
| 304 | POBJDIR_INFORMATION DirObjInformation,
|
|---|
| 305 | ULONG BufferLength,
|
|---|
| 306 | BOOLEAN GetNextIndex,
|
|---|
| 307 | BOOLEAN IgnoreInputIndex,
|
|---|
| 308 | PULONG ObjectIndex,
|
|---|
| 309 | PULONG DataWritten)
|
|---|
| 310 | {
|
|---|
| 311 | dprintf(("NTDLL: NtQueryDirectoryObject(%08xh,%08xh,%08xh,%08xh,%08xh,%08xh,%08xh) not implemented.\n",
|
|---|
| 312 | DirObjHandle,
|
|---|
| 313 | DirObjInformation,
|
|---|
| 314 | BufferLength,
|
|---|
| 315 | GetNextIndex,
|
|---|
| 316 | IgnoreInputIndex,
|
|---|
| 317 | ObjectIndex,
|
|---|
| 318 | DataWritten));
|
|---|
| 319 |
|
|---|
| 320 | return 0xc0000000; /* We don't have any. Whatever. (Yet.) */
|
|---|
| 321 | }
|
|---|
| 322 |
|
|---|
| 323 |
|
|---|
| 324 | /*
|
|---|
| 325 | * Link objects
|
|---|
| 326 | */
|
|---|
| 327 |
|
|---|
| 328 | /******************************************************************************
|
|---|
| 329 | * NtOpenSymbolicLinkObject [NTDLL]
|
|---|
| 330 | */
|
|---|
| 331 | NTSTATUS WINAPI NtOpenSymbolicLinkObject(PHANDLE LinkHandle,
|
|---|
| 332 | ACCESS_MASK DesiredAccess,
|
|---|
| 333 | POBJECT_ATTRIBUTES ObjectAttributes)
|
|---|
| 334 | {
|
|---|
| 335 | dprintf(("NTDLL: NtOpenSymbolicLinkObject(%08xh,%08xh,%08xh) not implemented.\n",
|
|---|
| 336 | LinkHandle,
|
|---|
| 337 | DesiredAccess,
|
|---|
| 338 | ObjectAttributes));
|
|---|
| 339 |
|
|---|
| 340 | return 0;
|
|---|
| 341 | }
|
|---|
| 342 |
|
|---|
| 343 |
|
|---|
| 344 | /******************************************************************************
|
|---|
| 345 | * NtCreateSymbolicLinkObject [NTDLL]
|
|---|
| 346 | */
|
|---|
| 347 | NTSTATUS WINAPI NtCreateSymbolicLinkObject(PHANDLE SymbolicLinkHandle,
|
|---|
| 348 | ACCESS_MASK DesiredAccess,
|
|---|
| 349 | POBJECT_ATTRIBUTES ObjectAttributes,
|
|---|
| 350 | PUNICODE_STRING Name)
|
|---|
| 351 | {
|
|---|
| 352 | dprintf(("NTDLL: NtCreateSymbolicLinkObject(%08xh,%08xh,%08xh,%08x) not implemented.\n",
|
|---|
| 353 | SymbolicLinkHandle,
|
|---|
| 354 | DesiredAccess,
|
|---|
| 355 | ObjectAttributes,
|
|---|
| 356 | Name));
|
|---|
| 357 |
|
|---|
| 358 | return 0;
|
|---|
| 359 | }
|
|---|
| 360 |
|
|---|
| 361 |
|
|---|
| 362 | /******************************************************************************
|
|---|
| 363 | * NtQuerySymbolicLinkObject [NTDLL]
|
|---|
| 364 | */
|
|---|
| 365 | NTSTATUS WINAPI NtQuerySymbolicLinkObject(HANDLE LinkHandle,
|
|---|
| 366 | PUNICODE_STRING LinkTarget,
|
|---|
| 367 | PULONG ReturnedLength)
|
|---|
| 368 | {
|
|---|
| 369 | dprintf(("NTDLL: NtQuerySymbolicLinkObject(%08xh,%08xh,%08xh) not implemented.\n",
|
|---|
| 370 | LinkHandle,
|
|---|
| 371 | LinkTarget,
|
|---|
| 372 | ReturnedLength));
|
|---|
| 373 |
|
|---|
| 374 | return 0;
|
|---|
| 375 | }
|
|---|
| 376 |
|
|---|