| 1 | /* $Id: security.cpp,v 1.1 1999-11-30 19:41:45 sandervl Exp $ */
|
|---|
| 2 | /*
|
|---|
| 3 | * Win32 security API functions for OS/2
|
|---|
| 4 | *
|
|---|
| 5 | * Copyright 1998 Sander van Leeuwen (OS/2 Port)
|
|---|
| 6 | *
|
|---|
| 7 | * Based on Wine code (dlls\advapi32\security.c)
|
|---|
| 8 | *
|
|---|
| 9 | * Copyright original Wine author(s) (????)
|
|---|
| 10 | *
|
|---|
| 11 | * dlls/advapi32/security.c
|
|---|
| 12 | * FIXME: for all functions thunking down to Rtl* functions: implement SetLastError()
|
|---|
| 13 | */
|
|---|
| 14 | #ifdef __WIN32OS2__
|
|---|
| 15 | #include <os2win.h>
|
|---|
| 16 | #include <heapstring.h>
|
|---|
| 17 | #endif
|
|---|
| 18 |
|
|---|
| 19 | #include <string.h>
|
|---|
| 20 |
|
|---|
| 21 | #include "windef.h"
|
|---|
| 22 | #include "winerror.h"
|
|---|
| 23 | #include "heap.h"
|
|---|
| 24 | #include "ntddk.h"
|
|---|
| 25 | #include "ntsecapi.h"
|
|---|
| 26 | #include "debugtools.h"
|
|---|
| 27 |
|
|---|
| 28 | DECLARE_DEBUG_CHANNEL(advapi)
|
|---|
| 29 | DECLARE_DEBUG_CHANNEL(security)
|
|---|
| 30 |
|
|---|
| 31 | static BOOL fInitSecurity = FALSE;
|
|---|
| 32 | static BOOL fHasSecurity = FALSE;
|
|---|
| 33 |
|
|---|
| 34 | static BOOL Wine_HasSecurity(void)
|
|---|
| 35 | {
|
|---|
| 36 | //SvL: Let's not check this for every single call please...
|
|---|
| 37 | if(!fInitSecurity)
|
|---|
| 38 | {
|
|---|
| 39 | OSVERSIONINFOA osi;
|
|---|
| 40 | osi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOA);
|
|---|
| 41 | GetVersionExA(&osi);
|
|---|
| 42 | if (osi.dwPlatformId == VER_PLATFORM_WIN32_NT) {
|
|---|
| 43 | fHasSecurity = TRUE;
|
|---|
| 44 | }
|
|---|
| 45 | fInitSecurity = TRUE;
|
|---|
| 46 | }
|
|---|
| 47 | if(!fHasSecurity) {
|
|---|
| 48 | SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
|---|
| 49 | return FALSE;
|
|---|
| 50 | }
|
|---|
| 51 | return TRUE;
|
|---|
| 52 | }
|
|---|
| 53 |
|
|---|
| 54 |
|
|---|
| 55 | #define CallWin32ToNt(func) \
|
|---|
| 56 | { NTSTATUS ret; \
|
|---|
| 57 | ret = (func); \
|
|---|
| 58 | if (ret !=STATUS_SUCCESS) \
|
|---|
| 59 | { SetLastError (RtlNtStatusToDosError(ret)); return FALSE; } \
|
|---|
| 60 | return TRUE; \
|
|---|
| 61 | }
|
|---|
| 62 |
|
|---|
| 63 | /* ##############################
|
|---|
| 64 | ###### TOKEN FUNCTIONS ######
|
|---|
| 65 | ##############################
|
|---|
| 66 | */
|
|---|
| 67 |
|
|---|
| 68 | /******************************************************************************
|
|---|
| 69 | * OpenProcessToken [ADVAPI32.109]
|
|---|
| 70 | * Opens the access token associated with a process
|
|---|
| 71 | *
|
|---|
| 72 | * PARAMS
|
|---|
| 73 | * ProcessHandle [I] Handle to process
|
|---|
| 74 | * DesiredAccess [I] Desired access to process
|
|---|
| 75 | * TokenHandle [O] Pointer to handle of open access token
|
|---|
| 76 | *
|
|---|
| 77 | * RETURNS STD
|
|---|
| 78 | */
|
|---|
| 79 | BOOL WINAPI
|
|---|
| 80 | OpenProcessToken( HANDLE ProcessHandle, DWORD DesiredAccess,
|
|---|
| 81 | HANDLE *TokenHandle )
|
|---|
| 82 | {
|
|---|
| 83 | if (!Wine_HasSecurity()) return FALSE;
|
|---|
| 84 | CallWin32ToNt(NtOpenProcessToken( ProcessHandle, DesiredAccess, TokenHandle ));
|
|---|
| 85 | }
|
|---|
| 86 |
|
|---|
| 87 | /******************************************************************************
|
|---|
| 88 | * OpenThreadToken [ADVAPI32.114]
|
|---|
| 89 | *
|
|---|
| 90 | * PARAMS
|
|---|
| 91 | * thread []
|
|---|
| 92 | * desiredaccess []
|
|---|
| 93 | * openasself []
|
|---|
| 94 | * thandle []
|
|---|
| 95 | */
|
|---|
| 96 | BOOL WINAPI
|
|---|
| 97 | OpenThreadToken( HANDLE ThreadHandle, DWORD DesiredAccess,
|
|---|
| 98 | BOOL OpenAsSelf, HANDLE *TokenHandle)
|
|---|
| 99 | {
|
|---|
| 100 | if (!Wine_HasSecurity()) return FALSE;
|
|---|
| 101 | CallWin32ToNt (NtOpenThreadToken(ThreadHandle, DesiredAccess, OpenAsSelf, TokenHandle));
|
|---|
| 102 | }
|
|---|
| 103 |
|
|---|
| 104 | /******************************************************************************
|
|---|
| 105 | * AdjustTokenPrivileges [ADVAPI32.10]
|
|---|
| 106 | *
|
|---|
| 107 | * PARAMS
|
|---|
| 108 | * TokenHandle []
|
|---|
| 109 | * DisableAllPrivileges []
|
|---|
| 110 | * NewState []
|
|---|
| 111 | * BufferLength []
|
|---|
| 112 | * PreviousState []
|
|---|
| 113 | * ReturnLength []
|
|---|
| 114 | */
|
|---|
| 115 | BOOL WINAPI
|
|---|
| 116 | AdjustTokenPrivileges( HANDLE TokenHandle, BOOL DisableAllPrivileges,
|
|---|
| 117 | PTOKEN_PRIVILEGES NewState, DWORD BufferLength,
|
|---|
| 118 | PTOKEN_PRIVILEGES PreviousState, LPDWORD ReturnLength )
|
|---|
| 119 | {
|
|---|
| 120 | CallWin32ToNt(NtAdjustPrivilegesToken(TokenHandle, DisableAllPrivileges, NewState, BufferLength, PreviousState, ReturnLength));
|
|---|
| 121 | }
|
|---|
| 122 |
|
|---|
| 123 | /******************************************************************************
|
|---|
| 124 | * GetTokenInformation [ADVAPI32.66]
|
|---|
| 125 | *
|
|---|
| 126 | * PARAMS
|
|---|
| 127 | * token []
|
|---|
| 128 | * tokeninfoclass []
|
|---|
| 129 | * tokeninfo []
|
|---|
| 130 | * tokeninfolength []
|
|---|
| 131 | * retlen []
|
|---|
| 132 | *
|
|---|
| 133 | */
|
|---|
| 134 | BOOL WINAPI
|
|---|
| 135 | GetTokenInformation( HANDLE token, TOKEN_INFORMATION_CLASS tokeninfoclass,
|
|---|
| 136 | LPVOID tokeninfo, DWORD tokeninfolength, LPDWORD retlen )
|
|---|
| 137 | {
|
|---|
| 138 | CallWin32ToNt (NtQueryInformationToken( token, tokeninfoclass, tokeninfo, tokeninfolength, retlen));
|
|---|
| 139 | }
|
|---|
| 140 |
|
|---|
| 141 | /* ##############################
|
|---|
| 142 | ###### SID FUNCTIONS ######
|
|---|
| 143 | ##############################
|
|---|
| 144 | */
|
|---|
| 145 |
|
|---|
| 146 | /******************************************************************************
|
|---|
| 147 | * AllocateAndInitializeSid [ADVAPI32.11]
|
|---|
| 148 | *
|
|---|
| 149 | * PARAMS
|
|---|
| 150 | * pIdentifierAuthority []
|
|---|
| 151 | * nSubAuthorityCount []
|
|---|
| 152 | * nSubAuthority0 []
|
|---|
| 153 | * nSubAuthority1 []
|
|---|
| 154 | * nSubAuthority2 []
|
|---|
| 155 | * nSubAuthority3 []
|
|---|
| 156 | * nSubAuthority4 []
|
|---|
| 157 | * nSubAuthority5 []
|
|---|
| 158 | * nSubAuthority6 []
|
|---|
| 159 | * nSubAuthority7 []
|
|---|
| 160 | * pSid []
|
|---|
| 161 | */
|
|---|
| 162 | BOOL WINAPI
|
|---|
| 163 | AllocateAndInitializeSid( PSID_IDENTIFIER_AUTHORITY pIdentifierAuthority,
|
|---|
| 164 | BYTE nSubAuthorityCount,
|
|---|
| 165 | DWORD nSubAuthority0, DWORD nSubAuthority1,
|
|---|
| 166 | DWORD nSubAuthority2, DWORD nSubAuthority3,
|
|---|
| 167 | DWORD nSubAuthority4, DWORD nSubAuthority5,
|
|---|
| 168 | DWORD nSubAuthority6, DWORD nSubAuthority7,
|
|---|
| 169 | PSID *pSid )
|
|---|
| 170 | {
|
|---|
| 171 | if (!(*pSid = (PSID)HeapAlloc(GetProcessHeap(), 0,
|
|---|
| 172 | GetSidLengthRequired(nSubAuthorityCount))))
|
|---|
| 173 | return FALSE;
|
|---|
| 174 |
|
|---|
| 175 | (*pSid)->Revision = SID_REVISION;
|
|---|
| 176 | if (pIdentifierAuthority)
|
|---|
| 177 | memcpy(&(*pSid)->IdentifierAuthority, pIdentifierAuthority,
|
|---|
| 178 | sizeof (SID_IDENTIFIER_AUTHORITY));
|
|---|
| 179 | *GetSidSubAuthorityCount(*pSid) = nSubAuthorityCount;
|
|---|
| 180 |
|
|---|
| 181 | if (nSubAuthorityCount > 0)
|
|---|
| 182 | *GetSidSubAuthority(*pSid, 0) = nSubAuthority0;
|
|---|
| 183 | if (nSubAuthorityCount > 1)
|
|---|
| 184 | *GetSidSubAuthority(*pSid, 1) = nSubAuthority1;
|
|---|
| 185 | if (nSubAuthorityCount > 2)
|
|---|
| 186 | *GetSidSubAuthority(*pSid, 2) = nSubAuthority2;
|
|---|
| 187 | if (nSubAuthorityCount > 3)
|
|---|
| 188 | *GetSidSubAuthority(*pSid, 3) = nSubAuthority3;
|
|---|
| 189 | if (nSubAuthorityCount > 4)
|
|---|
| 190 | *GetSidSubAuthority(*pSid, 4) = nSubAuthority4;
|
|---|
| 191 | if (nSubAuthorityCount > 5)
|
|---|
| 192 | *GetSidSubAuthority(*pSid, 5) = nSubAuthority5;
|
|---|
| 193 | if (nSubAuthorityCount > 6)
|
|---|
| 194 | *GetSidSubAuthority(*pSid, 6) = nSubAuthority6;
|
|---|
| 195 | if (nSubAuthorityCount > 7)
|
|---|
| 196 | *GetSidSubAuthority(*pSid, 7) = nSubAuthority7;
|
|---|
| 197 |
|
|---|
| 198 | return TRUE;
|
|---|
| 199 | }
|
|---|
| 200 |
|
|---|
| 201 | /******************************************************************************
|
|---|
| 202 | * FreeSid [ADVAPI32.42]
|
|---|
| 203 | *
|
|---|
| 204 | * PARAMS
|
|---|
| 205 | * pSid []
|
|---|
| 206 | */
|
|---|
| 207 | PVOID WINAPI
|
|---|
| 208 | FreeSid( PSID pSid )
|
|---|
| 209 | {
|
|---|
| 210 | HeapFree( GetProcessHeap(), 0, pSid );
|
|---|
| 211 | return NULL;
|
|---|
| 212 | }
|
|---|
| 213 |
|
|---|
| 214 | /******************************************************************************
|
|---|
| 215 | * CopySid [ADVAPI32.24]
|
|---|
| 216 | *
|
|---|
| 217 | * PARAMS
|
|---|
| 218 | * nDestinationSidLength []
|
|---|
| 219 | * pDestinationSid []
|
|---|
| 220 | * pSourceSid []
|
|---|
| 221 | */
|
|---|
| 222 | BOOL WINAPI
|
|---|
| 223 | CopySid( DWORD nDestinationSidLength, PSID pDestinationSid, PSID pSourceSid )
|
|---|
| 224 | {
|
|---|
| 225 |
|
|---|
| 226 | if (!IsValidSid(pSourceSid))
|
|---|
| 227 | return FALSE;
|
|---|
| 228 |
|
|---|
| 229 | if (nDestinationSidLength < GetLengthSid(pSourceSid))
|
|---|
| 230 | return FALSE;
|
|---|
| 231 |
|
|---|
| 232 | memcpy(pDestinationSid, pSourceSid, GetLengthSid(pSourceSid));
|
|---|
| 233 |
|
|---|
| 234 | return TRUE;
|
|---|
| 235 | }
|
|---|
| 236 |
|
|---|
| 237 | /******************************************************************************
|
|---|
| 238 | * IsValidSid [ADVAPI32.80]
|
|---|
| 239 | *
|
|---|
| 240 | * PARAMS
|
|---|
| 241 | * pSid []
|
|---|
| 242 | */
|
|---|
| 243 | BOOL WINAPI
|
|---|
| 244 | IsValidSid( PSID pSid )
|
|---|
| 245 | {
|
|---|
| 246 | if (IsBadReadPtr(pSid, 4))
|
|---|
| 247 | {
|
|---|
| 248 | WARN_(security)("(%p): invalid pointer!", pSid);
|
|---|
| 249 | return FALSE;
|
|---|
| 250 | }
|
|---|
| 251 |
|
|---|
| 252 | if (pSid->SubAuthorityCount > SID_MAX_SUB_AUTHORITIES)
|
|---|
| 253 | return FALSE;
|
|---|
| 254 |
|
|---|
| 255 | if (!pSid || pSid->Revision != SID_REVISION)
|
|---|
| 256 | return FALSE;
|
|---|
| 257 |
|
|---|
| 258 | return TRUE;
|
|---|
| 259 | }
|
|---|
| 260 |
|
|---|
| 261 | /******************************************************************************
|
|---|
| 262 | * EqualSid [ADVAPI32.40]
|
|---|
| 263 | *
|
|---|
| 264 | * PARAMS
|
|---|
| 265 | * pSid1 []
|
|---|
| 266 | * pSid2 []
|
|---|
| 267 | */
|
|---|
| 268 | BOOL WINAPI
|
|---|
| 269 | EqualSid( PSID pSid1, PSID pSid2 )
|
|---|
| 270 | {
|
|---|
| 271 | if (!IsValidSid(pSid1) || !IsValidSid(pSid2))
|
|---|
| 272 | return FALSE;
|
|---|
| 273 |
|
|---|
| 274 | if (*GetSidSubAuthorityCount(pSid1) != *GetSidSubAuthorityCount(pSid2))
|
|---|
| 275 | return FALSE;
|
|---|
| 276 |
|
|---|
| 277 | if (memcmp(pSid1, pSid2, GetLengthSid(pSid1)) != 0)
|
|---|
| 278 | return FALSE;
|
|---|
| 279 |
|
|---|
| 280 | return TRUE;
|
|---|
| 281 | }
|
|---|
| 282 |
|
|---|
| 283 | /******************************************************************************
|
|---|
| 284 | * EqualPrefixSid [ADVAPI32.39]
|
|---|
| 285 | */
|
|---|
| 286 | BOOL WINAPI EqualPrefixSid (PSID pSid1, PSID pSid2) {
|
|---|
| 287 | if (!IsValidSid(pSid1) || !IsValidSid(pSid2))
|
|---|
| 288 | return FALSE;
|
|---|
| 289 |
|
|---|
| 290 | if (*GetSidSubAuthorityCount(pSid1) != *GetSidSubAuthorityCount(pSid2))
|
|---|
| 291 | return FALSE;
|
|---|
| 292 |
|
|---|
| 293 | if (memcmp(pSid1, pSid2, GetSidLengthRequired(pSid1->SubAuthorityCount - 1))
|
|---|
| 294 | != 0)
|
|---|
| 295 | return FALSE;
|
|---|
| 296 |
|
|---|
| 297 | return TRUE;
|
|---|
| 298 | }
|
|---|
| 299 |
|
|---|
| 300 | /******************************************************************************
|
|---|
| 301 | * GetSidLengthRequired [ADVAPI32.63]
|
|---|
| 302 | *
|
|---|
| 303 | * PARAMS
|
|---|
| 304 | * nSubAuthorityCount []
|
|---|
| 305 | */
|
|---|
| 306 | DWORD WINAPI
|
|---|
| 307 | GetSidLengthRequired( BYTE nSubAuthorityCount )
|
|---|
| 308 | {
|
|---|
| 309 | return sizeof (SID) + (nSubAuthorityCount - 1) * sizeof (DWORD);
|
|---|
| 310 | }
|
|---|
| 311 |
|
|---|
| 312 | /******************************************************************************
|
|---|
| 313 | * InitializeSid [ADVAPI32.74]
|
|---|
| 314 | *
|
|---|
| 315 | * PARAMS
|
|---|
| 316 | * pIdentifierAuthority []
|
|---|
| 317 | */
|
|---|
| 318 | BOOL WINAPI
|
|---|
| 319 | InitializeSid (PSID pSid, PSID_IDENTIFIER_AUTHORITY pIdentifierAuthority,
|
|---|
| 320 | BYTE nSubAuthorityCount)
|
|---|
| 321 | {
|
|---|
| 322 | int i;
|
|---|
| 323 |
|
|---|
| 324 | pSid->Revision = SID_REVISION;
|
|---|
| 325 | if (pIdentifierAuthority)
|
|---|
| 326 | memcpy(&pSid->IdentifierAuthority, pIdentifierAuthority,
|
|---|
| 327 | sizeof (SID_IDENTIFIER_AUTHORITY));
|
|---|
| 328 | *GetSidSubAuthorityCount(pSid) = nSubAuthorityCount;
|
|---|
| 329 |
|
|---|
| 330 | for (i = 0; i < nSubAuthorityCount; i++)
|
|---|
| 331 | *GetSidSubAuthority(pSid, i) = 0;
|
|---|
| 332 |
|
|---|
| 333 | return TRUE;
|
|---|
| 334 | }
|
|---|
| 335 |
|
|---|
| 336 | /******************************************************************************
|
|---|
| 337 | * GetSidIdentifierAuthority [ADVAPI32.62]
|
|---|
| 338 | *
|
|---|
| 339 | * PARAMS
|
|---|
| 340 | * pSid []
|
|---|
| 341 | */
|
|---|
| 342 | PSID_IDENTIFIER_AUTHORITY WINAPI
|
|---|
| 343 | GetSidIdentifierAuthority( PSID pSid )
|
|---|
| 344 | {
|
|---|
| 345 | return &pSid->IdentifierAuthority;
|
|---|
| 346 | }
|
|---|
| 347 |
|
|---|
| 348 | /******************************************************************************
|
|---|
| 349 | * GetSidSubAuthority [ADVAPI32.64]
|
|---|
| 350 | *
|
|---|
| 351 | * PARAMS
|
|---|
| 352 | * pSid []
|
|---|
| 353 | * nSubAuthority []
|
|---|
| 354 | */
|
|---|
| 355 | PDWORD WINAPI
|
|---|
| 356 | GetSidSubAuthority( PSID pSid, DWORD nSubAuthority )
|
|---|
| 357 | {
|
|---|
| 358 | return &pSid->SubAuthority[nSubAuthority];
|
|---|
| 359 | }
|
|---|
| 360 |
|
|---|
| 361 | /******************************************************************************
|
|---|
| 362 | * GetSidSubAuthorityCount [ADVAPI32.65]
|
|---|
| 363 | *
|
|---|
| 364 | * PARAMS
|
|---|
| 365 | * pSid []
|
|---|
| 366 | */
|
|---|
| 367 | PUCHAR WINAPI
|
|---|
| 368 | GetSidSubAuthorityCount (PSID pSid)
|
|---|
| 369 | {
|
|---|
| 370 | return &pSid->SubAuthorityCount;
|
|---|
| 371 | }
|
|---|
| 372 |
|
|---|
| 373 | /******************************************************************************
|
|---|
| 374 | * GetLengthSid [ADVAPI32.48]
|
|---|
| 375 | *
|
|---|
| 376 | * PARAMS
|
|---|
| 377 | * pSid []
|
|---|
| 378 | */
|
|---|
| 379 | DWORD WINAPI
|
|---|
| 380 | GetLengthSid (PSID pSid)
|
|---|
| 381 | {
|
|---|
| 382 | return GetSidLengthRequired( * GetSidSubAuthorityCount(pSid) );
|
|---|
| 383 | }
|
|---|
| 384 |
|
|---|
| 385 | /* ##############################################
|
|---|
| 386 | ###### SECURITY DESCRIPTOR FUNCTIONS ######
|
|---|
| 387 | ##############################################
|
|---|
| 388 | */
|
|---|
| 389 |
|
|---|
| 390 | /******************************************************************************
|
|---|
| 391 | * InitializeSecurityDescriptor [ADVAPI32.73]
|
|---|
| 392 | *
|
|---|
| 393 | * PARAMS
|
|---|
| 394 | * pDescr []
|
|---|
| 395 | * revision []
|
|---|
| 396 | */
|
|---|
| 397 | BOOL WINAPI
|
|---|
| 398 | InitializeSecurityDescriptor( SECURITY_DESCRIPTOR *pDescr, DWORD revision )
|
|---|
| 399 | {
|
|---|
| 400 | CallWin32ToNt (RtlCreateSecurityDescriptor(pDescr, revision ));
|
|---|
| 401 | }
|
|---|
| 402 |
|
|---|
| 403 | /******************************************************************************
|
|---|
| 404 | * GetSecurityDescriptorLength [ADVAPI32.55]
|
|---|
| 405 | */
|
|---|
| 406 | DWORD WINAPI GetSecurityDescriptorLength( SECURITY_DESCRIPTOR *pDescr)
|
|---|
| 407 | {
|
|---|
| 408 | return (RtlLengthSecurityDescriptor(pDescr));
|
|---|
| 409 | }
|
|---|
| 410 |
|
|---|
| 411 | /******************************************************************************
|
|---|
| 412 | * GetSecurityDescriptorOwner [ADVAPI32.56]
|
|---|
| 413 | *
|
|---|
| 414 | * PARAMS
|
|---|
| 415 | * pOwner []
|
|---|
| 416 | * lpbOwnerDefaulted []
|
|---|
| 417 | */
|
|---|
| 418 | BOOL WINAPI
|
|---|
| 419 | GetSecurityDescriptorOwner( SECURITY_DESCRIPTOR *pDescr, PSID *pOwner,
|
|---|
| 420 | LPBOOL lpbOwnerDefaulted )
|
|---|
| 421 | {
|
|---|
| 422 | CallWin32ToNt (RtlGetOwnerSecurityDescriptor( pDescr, pOwner, (PBOOLEAN)lpbOwnerDefaulted ));
|
|---|
| 423 | }
|
|---|
| 424 |
|
|---|
| 425 | /******************************************************************************
|
|---|
| 426 | * SetSecurityDescriptorOwner [ADVAPI32]
|
|---|
| 427 | *
|
|---|
| 428 | * PARAMS
|
|---|
| 429 | */
|
|---|
| 430 | BOOL WINAPI SetSecurityDescriptorOwner( PSECURITY_DESCRIPTOR pSecurityDescriptor,
|
|---|
| 431 | PSID pOwner, BOOL bOwnerDefaulted)
|
|---|
| 432 | {
|
|---|
| 433 | CallWin32ToNt (RtlSetOwnerSecurityDescriptor(pSecurityDescriptor, pOwner, bOwnerDefaulted));
|
|---|
| 434 | }
|
|---|
| 435 | /******************************************************************************
|
|---|
| 436 | * GetSecurityDescriptorGroup [ADVAPI32.54]
|
|---|
| 437 | */
|
|---|
| 438 | BOOL WINAPI GetSecurityDescriptorGroup(
|
|---|
| 439 | PSECURITY_DESCRIPTOR SecurityDescriptor,
|
|---|
| 440 | PSID *Group,
|
|---|
| 441 | LPBOOL GroupDefaulted)
|
|---|
| 442 | {
|
|---|
| 443 | CallWin32ToNt (RtlGetGroupSecurityDescriptor(SecurityDescriptor, Group, (PBOOLEAN)GroupDefaulted));
|
|---|
| 444 | }
|
|---|
| 445 | /******************************************************************************
|
|---|
| 446 | * SetSecurityDescriptorGroup
|
|---|
| 447 | */
|
|---|
| 448 | BOOL WINAPI SetSecurityDescriptorGroup ( PSECURITY_DESCRIPTOR SecurityDescriptor,
|
|---|
| 449 | PSID Group, BOOL GroupDefaulted)
|
|---|
| 450 | {
|
|---|
| 451 | CallWin32ToNt (RtlSetGroupSecurityDescriptor( SecurityDescriptor, Group, GroupDefaulted));
|
|---|
| 452 | }
|
|---|
| 453 |
|
|---|
| 454 | /******************************************************************************
|
|---|
| 455 | * IsValidSecurityDescriptor [ADVAPI32.79]
|
|---|
| 456 | *
|
|---|
| 457 | * PARAMS
|
|---|
| 458 | * lpsecdesc []
|
|---|
| 459 | */
|
|---|
| 460 | BOOL WINAPI
|
|---|
| 461 | IsValidSecurityDescriptor( PSECURITY_DESCRIPTOR SecurityDescriptor )
|
|---|
| 462 | {
|
|---|
| 463 | CallWin32ToNt (RtlValidSecurityDescriptor(SecurityDescriptor));
|
|---|
| 464 | }
|
|---|
| 465 |
|
|---|
| 466 | /******************************************************************************
|
|---|
| 467 | * GetSecurityDescriptorDacl [ADVAPI.91]
|
|---|
| 468 | */
|
|---|
| 469 | BOOL WINAPI GetSecurityDescriptorDacl(
|
|---|
| 470 | IN PSECURITY_DESCRIPTOR pSecurityDescriptor,
|
|---|
| 471 | OUT LPBOOL lpbDaclPresent,
|
|---|
| 472 | OUT PACL *pDacl,
|
|---|
| 473 | OUT LPBOOL lpbDaclDefaulted)
|
|---|
| 474 | {
|
|---|
| 475 | CallWin32ToNt (RtlGetDaclSecurityDescriptor(pSecurityDescriptor, (PBOOLEAN)lpbDaclPresent,
|
|---|
| 476 | pDacl, (PBOOLEAN)lpbDaclDefaulted));
|
|---|
| 477 | }
|
|---|
| 478 |
|
|---|
| 479 | /******************************************************************************
|
|---|
| 480 | * SetSecurityDescriptorDacl [ADVAPI.224]
|
|---|
| 481 | */
|
|---|
| 482 | BOOL WINAPI
|
|---|
| 483 | SetSecurityDescriptorDacl (
|
|---|
| 484 | PSECURITY_DESCRIPTOR lpsd,
|
|---|
| 485 | BOOL daclpresent,
|
|---|
| 486 | PACL dacl,
|
|---|
| 487 | BOOL dacldefaulted )
|
|---|
| 488 | {
|
|---|
| 489 | CallWin32ToNt (RtlSetDaclSecurityDescriptor (lpsd, daclpresent, dacl, dacldefaulted ));
|
|---|
| 490 | }
|
|---|
| 491 | /******************************************************************************
|
|---|
| 492 | * GetSecurityDescriptorSacl [ADVAPI.]
|
|---|
| 493 | */
|
|---|
| 494 | BOOL WINAPI GetSecurityDescriptorSacl(
|
|---|
| 495 | IN PSECURITY_DESCRIPTOR lpsd,
|
|---|
| 496 | OUT LPBOOL lpbSaclPresent,
|
|---|
| 497 | OUT PACL *pSacl,
|
|---|
| 498 | OUT LPBOOL lpbSaclDefaulted)
|
|---|
| 499 | {
|
|---|
| 500 | CallWin32ToNt (RtlGetSaclSecurityDescriptor(lpsd, (PBOOLEAN)lpbSaclPresent,
|
|---|
| 501 | pSacl, (PBOOLEAN)lpbSaclDefaulted));
|
|---|
| 502 | }
|
|---|
| 503 |
|
|---|
| 504 | /**************************************************************************
|
|---|
| 505 | * SetSecurityDescriptorSacl [NTDLL.488]
|
|---|
| 506 | */
|
|---|
| 507 | BOOL WINAPI SetSecurityDescriptorSacl (
|
|---|
| 508 | PSECURITY_DESCRIPTOR lpsd,
|
|---|
| 509 | BOOL saclpresent,
|
|---|
| 510 | PACL lpsacl,
|
|---|
| 511 | BOOL sacldefaulted)
|
|---|
| 512 | {
|
|---|
| 513 | CallWin32ToNt (RtlSetSaclSecurityDescriptor(lpsd, saclpresent, lpsacl, sacldefaulted));
|
|---|
| 514 | }
|
|---|
| 515 | /******************************************************************************
|
|---|
| 516 | * MakeSelfRelativeSD [ADVAPI32.95]
|
|---|
| 517 | *
|
|---|
| 518 | * PARAMS
|
|---|
| 519 | * lpabssecdesc []
|
|---|
| 520 | * lpselfsecdesc []
|
|---|
| 521 | * lpbuflen []
|
|---|
| 522 | */
|
|---|
| 523 | BOOL WINAPI
|
|---|
| 524 | MakeSelfRelativeSD( PSECURITY_DESCRIPTOR lpabssecdesc,
|
|---|
| 525 | PSECURITY_DESCRIPTOR lpselfsecdesc, LPDWORD lpbuflen )
|
|---|
| 526 | {
|
|---|
| 527 | FIXME_(advapi)("(%p,%p,%p),stub!\n",lpabssecdesc,lpselfsecdesc,lpbuflen);
|
|---|
| 528 | return TRUE;
|
|---|
| 529 | }
|
|---|
| 530 |
|
|---|
| 531 | /******************************************************************************
|
|---|
| 532 | * GetSecurityDescriptorControl32 [ADVAPI32]
|
|---|
| 533 | */
|
|---|
| 534 |
|
|---|
| 535 | BOOL WINAPI GetSecurityDescriptorControl ( PSECURITY_DESCRIPTOR pSecurityDescriptor,
|
|---|
| 536 | PSECURITY_DESCRIPTOR_CONTROL pControl, LPDWORD lpdwRevision)
|
|---|
| 537 | { FIXME_(advapi)("(%p,%p,%p),stub!\n",pSecurityDescriptor,pControl,lpdwRevision);
|
|---|
| 538 | return 1;
|
|---|
| 539 | }
|
|---|
| 540 |
|
|---|
| 541 | /* ##############################
|
|---|
| 542 | ###### MISC FUNCTIONS ######
|
|---|
| 543 | ##############################
|
|---|
| 544 | */
|
|---|
| 545 |
|
|---|
| 546 | /******************************************************************************
|
|---|
| 547 | * LookupPrivilegeValue32W [ADVAPI32.93]
|
|---|
| 548 | * Retrieves LUID used on a system to represent the privilege name.
|
|---|
| 549 | *
|
|---|
| 550 | * NOTES
|
|---|
| 551 | * lpLuid should be PLUID
|
|---|
| 552 | *
|
|---|
| 553 | * PARAMS
|
|---|
| 554 | * lpSystemName [I] Address of string specifying the system
|
|---|
| 555 | * lpName [I] Address of string specifying the privilege
|
|---|
| 556 | * lpLuid [I] Address of locally unique identifier
|
|---|
| 557 | *
|
|---|
| 558 | * RETURNS STD
|
|---|
| 559 | */
|
|---|
| 560 | BOOL WINAPI
|
|---|
| 561 | LookupPrivilegeValueW( LPCWSTR lpSystemName, LPCWSTR lpName, LPVOID lpLuid )
|
|---|
| 562 | {
|
|---|
| 563 | FIXME_(advapi)("(%s,%s,%p): stub\n",debugstr_w(lpSystemName),
|
|---|
| 564 | debugstr_w(lpName), lpLuid);
|
|---|
| 565 | return TRUE;
|
|---|
| 566 | }
|
|---|
| 567 |
|
|---|
| 568 | /******************************************************************************
|
|---|
| 569 | * LookupPrivilegeValue32A [ADVAPI32.92]
|
|---|
| 570 | */
|
|---|
| 571 | BOOL WINAPI
|
|---|
| 572 | LookupPrivilegeValueA( LPCSTR lpSystemName, LPCSTR lpName, LPVOID lpLuid )
|
|---|
| 573 | {
|
|---|
| 574 | LPWSTR lpSystemNameW = HEAP_strdupAtoW(GetProcessHeap(), 0, lpSystemName);
|
|---|
| 575 | LPWSTR lpNameW = HEAP_strdupAtoW(GetProcessHeap(), 0, lpName);
|
|---|
| 576 | BOOL ret = LookupPrivilegeValueW( lpSystemNameW, lpNameW, lpLuid);
|
|---|
| 577 | HeapFree(GetProcessHeap(), 0, lpNameW);
|
|---|
| 578 | HeapFree(GetProcessHeap(), 0, lpSystemNameW);
|
|---|
| 579 | return ret;
|
|---|
| 580 | }
|
|---|
| 581 |
|
|---|
| 582 | /******************************************************************************
|
|---|
| 583 | * GetFileSecurity32A [ADVAPI32.45]
|
|---|
| 584 | *
|
|---|
| 585 | * Obtains Specified information about the security of a file or directory
|
|---|
| 586 | * The information obtained is constrained by the callers access rights and
|
|---|
| 587 | * privileges
|
|---|
| 588 | */
|
|---|
| 589 | BOOL WINAPI
|
|---|
| 590 | GetFileSecurityA( LPCSTR lpFileName,
|
|---|
| 591 | SECURITY_INFORMATION RequestedInformation,
|
|---|
| 592 | PSECURITY_DESCRIPTOR pSecurityDescriptor,
|
|---|
| 593 | DWORD nLength, LPDWORD lpnLengthNeeded )
|
|---|
| 594 | {
|
|---|
| 595 | FIXME_(advapi)("(%s) : stub\n", debugstr_a(lpFileName));
|
|---|
| 596 | return TRUE;
|
|---|
| 597 | }
|
|---|
| 598 |
|
|---|
| 599 | /******************************************************************************
|
|---|
| 600 | * GetFileSecurity32W [ADVAPI32.46]
|
|---|
| 601 | *
|
|---|
| 602 | * Obtains Specified information about the security of a file or directory
|
|---|
| 603 | * The information obtained is constrained by the callers access rights and
|
|---|
| 604 | * privileges
|
|---|
| 605 | *
|
|---|
| 606 | * PARAMS
|
|---|
| 607 | * lpFileName []
|
|---|
| 608 | * RequestedInformation []
|
|---|
| 609 | * pSecurityDescriptor []
|
|---|
| 610 | * nLength []
|
|---|
| 611 | * lpnLengthNeeded []
|
|---|
| 612 | */
|
|---|
| 613 | BOOL WINAPI
|
|---|
| 614 | GetFileSecurityW( LPCWSTR lpFileName,
|
|---|
| 615 | SECURITY_INFORMATION RequestedInformation,
|
|---|
| 616 | PSECURITY_DESCRIPTOR pSecurityDescriptor,
|
|---|
| 617 | DWORD nLength, LPDWORD lpnLengthNeeded )
|
|---|
| 618 | {
|
|---|
| 619 | FIXME_(advapi)("(%s) : stub\n", debugstr_w(lpFileName) );
|
|---|
| 620 | return TRUE;
|
|---|
| 621 | }
|
|---|
| 622 |
|
|---|
| 623 |
|
|---|
| 624 | /******************************************************************************
|
|---|
| 625 | * LookupAccountSid32A [ADVAPI32.86]
|
|---|
| 626 | */
|
|---|
| 627 | BOOL WINAPI
|
|---|
| 628 | LookupAccountSidA( LPCSTR system, PSID sid, LPCSTR account,
|
|---|
| 629 | LPDWORD accountSize, LPCSTR domain, LPDWORD domainSize,
|
|---|
| 630 | PSID_NAME_USE name_use )
|
|---|
| 631 | {
|
|---|
| 632 | FIXME_(security)("(%s,%p,%p,%p,%p,%p,%p): stub\n",
|
|---|
| 633 | system,sid,account,accountSize,domain,domainSize,name_use);
|
|---|
| 634 | SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
|---|
| 635 | return FALSE;
|
|---|
| 636 | }
|
|---|
| 637 |
|
|---|
| 638 | /******************************************************************************
|
|---|
| 639 | * LookupAccountSid32W [ADVAPI32.87]
|
|---|
| 640 | *
|
|---|
| 641 | * PARAMS
|
|---|
| 642 | * system []
|
|---|
| 643 | * sid []
|
|---|
| 644 | * account []
|
|---|
| 645 | * accountSize []
|
|---|
| 646 | * domain []
|
|---|
| 647 | * domainSize []
|
|---|
| 648 | * name_use []
|
|---|
| 649 | */
|
|---|
| 650 | BOOL WINAPI
|
|---|
| 651 | LookupAccountSidW( LPCWSTR system, PSID sid, LPCWSTR account,
|
|---|
| 652 | LPDWORD accountSize, LPCWSTR domain, LPDWORD domainSize,
|
|---|
| 653 | PSID_NAME_USE name_use )
|
|---|
| 654 | {
|
|---|
| 655 | FIXME_(security)("(%p,%p,%p,%p,%p,%p,%p): stub\n",
|
|---|
| 656 | system,sid,account,accountSize,domain,domainSize,name_use);
|
|---|
| 657 | SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
|---|
| 658 | return FALSE;
|
|---|
| 659 | }
|
|---|
| 660 |
|
|---|
| 661 | /******************************************************************************
|
|---|
| 662 | * SetFileSecurity32A [ADVAPI32.182]
|
|---|
| 663 | * Sets the security of a file or directory
|
|---|
| 664 | */
|
|---|
| 665 | BOOL WINAPI SetFileSecurityA( LPCSTR lpFileName,
|
|---|
| 666 | SECURITY_INFORMATION RequestedInformation,
|
|---|
| 667 | PSECURITY_DESCRIPTOR pSecurityDescriptor)
|
|---|
| 668 | {
|
|---|
| 669 | FIXME_(advapi)("(%s) : stub\n", debugstr_a(lpFileName));
|
|---|
| 670 | return TRUE;
|
|---|
| 671 | }
|
|---|
| 672 |
|
|---|
| 673 | /******************************************************************************
|
|---|
| 674 | * SetFileSecurity32W [ADVAPI32.183]
|
|---|
| 675 | * Sets the security of a file or directory
|
|---|
| 676 | *
|
|---|
| 677 | * PARAMS
|
|---|
| 678 | * lpFileName []
|
|---|
| 679 | * RequestedInformation []
|
|---|
| 680 | * pSecurityDescriptor []
|
|---|
| 681 | */
|
|---|
| 682 | BOOL WINAPI
|
|---|
| 683 | SetFileSecurityW( LPCWSTR lpFileName,
|
|---|
| 684 | SECURITY_INFORMATION RequestedInformation,
|
|---|
| 685 | PSECURITY_DESCRIPTOR pSecurityDescriptor )
|
|---|
| 686 | {
|
|---|
| 687 | FIXME_(advapi)("(%s) : stub\n", debugstr_w(lpFileName) );
|
|---|
| 688 | return TRUE;
|
|---|
| 689 | }
|
|---|
| 690 |
|
|---|
| 691 | /******************************************************************************
|
|---|
| 692 | * QueryWindows31FilesMigration [ADVAPI32.266]
|
|---|
| 693 | *
|
|---|
| 694 | * PARAMS
|
|---|
| 695 | * x1 []
|
|---|
| 696 | */
|
|---|
| 697 | BOOL WINAPI
|
|---|
| 698 | QueryWindows31FilesMigration( DWORD x1 )
|
|---|
| 699 | {
|
|---|
| 700 | FIXME_(advapi)("(%ld):stub\n",x1);
|
|---|
| 701 | return TRUE;
|
|---|
| 702 | }
|
|---|
| 703 |
|
|---|
| 704 | /******************************************************************************
|
|---|
| 705 | * SynchronizeWindows31FilesAndWindowsNTRegistry [ADVAPI32.265]
|
|---|
| 706 | *
|
|---|
| 707 | * PARAMS
|
|---|
| 708 | * x1 []
|
|---|
| 709 | * x2 []
|
|---|
| 710 | * x3 []
|
|---|
| 711 | * x4 []
|
|---|
| 712 | */
|
|---|
| 713 | BOOL WINAPI
|
|---|
| 714 | SynchronizeWindows31FilesAndWindowsNTRegistry( DWORD x1, DWORD x2, DWORD x3,
|
|---|
| 715 | DWORD x4 )
|
|---|
| 716 | {
|
|---|
| 717 | FIXME_(advapi)("(0x%08lx,0x%08lx,0x%08lx,0x%08lx):stub\n",x1,x2,x3,x4);
|
|---|
| 718 | return TRUE;
|
|---|
| 719 | }
|
|---|
| 720 |
|
|---|
| 721 | /******************************************************************************
|
|---|
| 722 | * LsaOpenPolicy [ADVAPI32.200]
|
|---|
| 723 | *
|
|---|
| 724 | * PARAMS
|
|---|
| 725 | * x1 []
|
|---|
| 726 | * x2 []
|
|---|
| 727 | * x3 []
|
|---|
| 728 | * x4 []
|
|---|
| 729 | */
|
|---|
| 730 | NTSTATUS WINAPI
|
|---|
| 731 | LsaOpenPolicy(PLSA_UNICODE_STRING SystemName,
|
|---|
| 732 | PLSA_OBJECT_ATTRIBUTES ObjectAttributes,
|
|---|
| 733 | ACCESS_MASK DesiredAccess,
|
|---|
| 734 | PLSA_HANDLE PolicyHandle)
|
|---|
| 735 | {
|
|---|
| 736 | FIXME_(advapi)("(%p,%p,0x%08lx,%p):stub\n",
|
|---|
| 737 | SystemName, ObjectAttributes,
|
|---|
| 738 | DesiredAccess, PolicyHandle);
|
|---|
| 739 | return 0xc0000000; /* generic error */
|
|---|
| 740 | }
|
|---|
| 741 |
|
|---|
| 742 | /******************************************************************************
|
|---|
| 743 | * NotifyBootConfigStatus [ADVAPI32.97]
|
|---|
| 744 | *
|
|---|
| 745 | * PARAMS
|
|---|
| 746 | * x1 []
|
|---|
| 747 | */
|
|---|
| 748 | BOOL WINAPI
|
|---|
| 749 | NotifyBootConfigStatus( DWORD x1 )
|
|---|
| 750 | {
|
|---|
| 751 | FIXME_(advapi)("(0x%08lx):stub\n",x1);
|
|---|
| 752 | return 1;
|
|---|
| 753 | }
|
|---|
| 754 |
|
|---|
| 755 | /******************************************************************************
|
|---|
| 756 | * RevertToSelf [ADVAPI32.180]
|
|---|
| 757 | *
|
|---|
| 758 | * PARAMS
|
|---|
| 759 | * void []
|
|---|
| 760 | */
|
|---|
| 761 | BOOL WINAPI
|
|---|
| 762 | RevertToSelf( void )
|
|---|
| 763 | {
|
|---|
| 764 | FIXME_(advapi)("(), stub\n");
|
|---|
| 765 | return TRUE;
|
|---|
| 766 | }
|
|---|
| 767 |
|
|---|
| 768 | /******************************************************************************
|
|---|
| 769 | * ImpersonateSelf [ADVAPI32.71]
|
|---|
| 770 | */
|
|---|
| 771 | BOOL WINAPI
|
|---|
| 772 | ImpersonateSelf(SECURITY_IMPERSONATION_LEVEL ImpersonationLevel)
|
|---|
| 773 | {
|
|---|
| 774 | FIXME_(advapi)("(%08x), stub\n", ImpersonationLevel);
|
|---|
| 775 | return TRUE;
|
|---|
| 776 | }
|
|---|
| 777 |
|
|---|
| 778 | /******************************************************************************
|
|---|
| 779 | * AccessCheck32 [ADVAPI32.71]
|
|---|
| 780 | */
|
|---|
| 781 | BOOL WINAPI
|
|---|
| 782 | AccessCheck(PSECURITY_DESCRIPTOR pSecurityDescriptor, HANDLE ClientToken,
|
|---|
| 783 | DWORD DesiredAccess, PGENERIC_MAPPING GenericMapping, PPRIVILEGE_SET PrivilegeSet,
|
|---|
| 784 | LPDWORD PrivilegeSetLength, LPDWORD GrantedAccess, LPBOOL AccessStatus)
|
|---|
| 785 | {
|
|---|
| 786 | FIXME_(advapi)("(%p, %04x, %08lx, %p, %p, %p, %p, %p), stub\n",
|
|---|
| 787 | pSecurityDescriptor, ClientToken, DesiredAccess, GenericMapping,
|
|---|
| 788 | PrivilegeSet, PrivilegeSetLength, GrantedAccess, AccessStatus);
|
|---|
| 789 | *AccessStatus = TRUE;
|
|---|
| 790 | return TRUE;
|
|---|
| 791 | }
|
|---|
| 792 |
|
|---|
| 793 | /*************************************************************************
|
|---|
| 794 | * SetThreadToken [ADVAPI32.231]
|
|---|
| 795 | *
|
|---|
| 796 | * Assigns an "impersonation token" to a thread so it can assume the
|
|---|
| 797 | * security privledges of another thread or process. Can also remove
|
|---|
| 798 | * a previously assigned token. Only supported on NT - it's a stub
|
|---|
| 799 | * exactly like this one on Win9X.
|
|---|
| 800 | *
|
|---|
| 801 | */
|
|---|
| 802 |
|
|---|
| 803 | BOOL WINAPI SetThreadToken(PHANDLE thread, HANDLE token)
|
|---|
| 804 | {
|
|---|
| 805 | FIXME_(advapi)("(%p, %x): stub\n", thread, token);
|
|---|
| 806 |
|
|---|
| 807 | SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
|---|
| 808 |
|
|---|
| 809 | return FALSE;
|
|---|
| 810 | }
|
|---|
| 811 |
|
|---|
| 812 |
|
|---|
| 813 |
|
|---|
| 814 |
|
|---|