- Timestamp:
- Jul 3, 2009, 11:59:02 PM (16 years ago)
- Location:
- trunk/src
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/advapi32/ADVAPI32.DEF
r5748 r21325 439 439 UnlockServiceDatabase = _UnlockServiceDatabase@4 @401 440 440 441 AddAccessAllowedAceEx = _AddAccessAllowedAceEx@20 @420 442 ConvertSidToStringSidA = _ConvertSidToStringSidA@8 @421 443 ConvertSidToStringSidW = _ConvertSidToStringSidW@8 @422 444 CheckTokenMembership = _CheckTokenMembership@12 @423 445 CryptContextAddRef = _CryptContextAddRef@12 @424 446 RegDeleteTreeW = _RegDeleteTreeW@8 @425 -
trunk/src/advapi32/advapi32dbg.def
r21306 r21325 439 439 UnlockServiceDatabase = _UnlockServiceDatabase@4 @401 440 440 441 AddAccessAllowedAceEx = _AddAccessAllowedAceEx@20 @420 442 ConvertSidToStringSidA = _ConvertSidToStringSidA@8 @421 443 ConvertSidToStringSidW = _ConvertSidToStringSidW@8 @422 444 CheckTokenMembership = _CheckTokenMembership@12 @423 445 CryptContextAddRef = _CryptContextAddRef@12 @424 446 RegDeleteTreeW = _RegDeleteTreeW@8 @425 -
trunk/src/advapi32/makefile
r21306 r21325 25 25 $(OBJDIR)\advapi32rsrc.obj \ 26 26 $(OBJDIR)\lsa.obj \ 27 $(OBJDIR)\registry.obj \ 27 28 $(OBJDIR)\security.obj \ 28 29 $(OBJDIR)\security_odin.obj \ … … 31 32 $(OBJDIR)\eventlog.obj \ 32 33 $(OBJDIR)\crypt.obj \ 34 $(OBJDIR)\crypt_arc4.obj\ 35 $(OBJDIR)\crypt_des.obj\ 36 $(OBJDIR)\crypt_lmhash.obj\ 37 $(OBJDIR)\crypt_md4.obj\ 38 $(OBJDIR)\crypt_md5.obj\ 39 $(OBJDIR)\crypt_sha.obj\ 33 40 $(DLLENTRY) 34 41 … … 39 46 LIBS = \ 40 47 $(ODIN32_LIB)/kernel32.lib \ 48 $(ODIN32_LIB)/user32.lib \ 41 49 $(ODIN32_LIB)/ntdll.lib \ 42 50 $(ODIN32_LIB)/$(ODINCRT).lib \ -
trunk/src/advapi32/security.c
r10272 r21325 9 9 #include "heap.h" 10 10 #include "ntddk.h" 11 #include "ntstatus.h" 11 12 #include "ntsecapi.h" 13 #include "sddl.h" 14 //#include "wine/debug.h" 12 15 #include "debugtools.h" 16 #include "wine/unicode.h" 13 17 14 18 #ifdef __WIN32OS2__ 15 #include <heapstring.h> 19 //#include <heapstring.h> 20 LPWSTR WIN32API HEAP_strdupAtoW( HANDLE heap, DWORD flags, LPCSTR str ); 16 21 #endif 17 22 18 DEFAULT_DEBUG_CHANNEL(advapi); 19 20 #define CallWin32ToNt(func) \ 21 { NTSTATUS ret; \ 22 ret = (func); \ 23 if (ret !=STATUS_SUCCESS) \ 24 { SetLastError (RtlNtStatusToDosError(ret)); return FALSE; } \ 25 return TRUE; \ 23 WINE_DEFAULT_DEBUG_CHANNEL(advapi); 24 25 26 /* set last error code from NT status and get the proper boolean return value */ 27 /* used for functions that are a simple wrapper around the corresponding ntdll API */ 28 static inline BOOL set_ntstatus( NTSTATUS status ) 29 { 30 if (status) SetLastError( RtlNtStatusToDosError( status )); 31 return !status; 26 32 } 27 33 … … 30 36 if (oa) 31 37 { 32 TRACE("\n\tlength=%lu, rootdir= 0x%08x, objectname=%s\n\tattr=0x%08lx, sid=%p qos=%p\n",38 TRACE("\n\tlength=%lu, rootdir=%p, objectname=%s\n\tattr=0x%08lx, sid=%p qos=%p\n", 33 39 oa->Length, oa->RootDirectory, 34 40 oa->ObjectName?debugstr_w(oa->ObjectName->Buffer):"null", … … 44 50 /****************************************************************************** 45 51 * OpenProcessToken [ADVAPI32.@] 46 * Opens the access token associated with a process 52 * Opens the access token associated with a process handle. 47 53 * 48 54 * PARAMS … … 51 57 * TokenHandle [O] Pointer to handle of open access token 52 58 * 53 * RETURNS STD 59 * RETURNS 60 * Success: TRUE. TokenHandle contains the access token. 61 * Failure: FALSE. 62 * 63 * NOTES 64 * See NtOpenProcessToken. 54 65 */ 55 66 BOOL WINAPI … … 57 68 HANDLE *TokenHandle ) 58 69 { 59 CallWin32ToNt(NtOpenProcessToken( ProcessHandle, DesiredAccess, TokenHandle ));70 return set_ntstatus(NtOpenProcessToken( ProcessHandle, DesiredAccess, TokenHandle )); 60 71 } 61 72 … … 63 74 * OpenThreadToken [ADVAPI32.@] 64 75 * 65 * PARAMS 66 * thread [] 67 * desiredaccess [] 68 * openasself [] 69 * thandle [] 76 * Opens the access token associated with a thread handle. 77 * 78 * PARAMS 79 * ThreadHandle [I] Handle to process 80 * DesiredAccess [I] Desired access to the thread 81 * OpenAsSelf [I] ??? 82 * TokenHandle [O] Destination for the token handle 83 * 84 * RETURNS 85 * Success: TRUE. TokenHandle contains the access token. 86 * Failure: FALSE. 87 * 88 * NOTES 89 * See NtOpenThreadToken. 70 90 */ 71 91 BOOL WINAPI … … 73 93 BOOL OpenAsSelf, HANDLE *TokenHandle) 74 94 { 75 CallWin32ToNt (NtOpenThreadToken(ThreadHandle, DesiredAccess, OpenAsSelf, TokenHandle));95 return set_ntstatus( NtOpenThreadToken(ThreadHandle, DesiredAccess, OpenAsSelf, TokenHandle)); 76 96 } 77 97 … … 79 99 * AdjustTokenPrivileges [ADVAPI32.@] 80 100 * 81 * PARAMS 82 * TokenHandle [] 83 * DisableAllPrivileges [] 84 * NewState [] 85 * BufferLength [] 86 * PreviousState [] 87 * ReturnLength [] 101 * Adjust the privileges of an open token handle. 102 * 103 * PARAMS 104 * TokenHandle [I] Handle from OpenProcessToken() or OpenThreadToken() 105 * DisableAllPrivileges [I] TRUE=Remove all privileges, FALSE=Use NewState 106 * NewState [I] Desired new privileges of the token 107 * BufferLength [I] Length of NewState 108 * PreviousState [O] Destination for the previous state 109 * ReturnLength [I/O] Size of PreviousState 110 * 111 * 112 * RETURNS 113 * Success: TRUE. Privileges are set to NewState and PreviousState is updated. 114 * Failure: FALSE. 115 * 116 * NOTES 117 * See NtAdjustPrivilegesToken. 88 118 */ 89 119 BOOL WINAPI … … 92 122 LPVOID PreviousState, LPDWORD ReturnLength ) 93 123 { 94 CallWin32ToNt(NtAdjustPrivilegesToken(TokenHandle, DisableAllPrivileges, NewState, BufferLength, PreviousState, ReturnLength)); 124 return set_ntstatus( NtAdjustPrivilegesToken(TokenHandle, DisableAllPrivileges, 125 NewState, BufferLength, PreviousState, 126 ReturnLength)); 95 127 } 96 128 … … 98 130 * CheckTokenMembership [ADVAPI32.@] 99 131 * 100 * PARAMS 101 * TokenHandle [] 102 * SidToCheck [] 103 * IsMember [] 132 * Determine if an access token is a member of a SID. 133 * 134 * PARAMS 135 * TokenHandle [I] Handle from OpenProcessToken() or OpenThreadToken() 136 * SidToCheck [I] SID that possibly contains the token 137 * IsMember [O] Destination for result. 138 * 139 * RETURNS 140 * Success: TRUE. IsMember is TRUE if TokenHandle is a member, FALSE otherwise. 141 * Failure: FALSE. 104 142 */ 105 143 BOOL WINAPI … … 107 145 PBOOL IsMember ) 108 146 { 109 FIXME("( 0x%08x%p %p) stub!\n", TokenHandle, SidToCheck, IsMember);147 FIXME("(%p %p %p) stub!\n", TokenHandle, SidToCheck, IsMember); 110 148 111 149 *IsMember = TRUE; … … 117 155 * 118 156 * PARAMS 119 * token [] 120 * tokeninfoclass [] 121 * tokeninfo [] 122 * tokeninfolength [] 123 * retlen [] 124 * 157 * token [I] Handle from OpenProcessToken() or OpenThreadToken() 158 * tokeninfoclass [I] A TOKEN_INFORMATION_CLASS from "winnt.h" 159 * tokeninfo [O] Destination for token information 160 * tokeninfolength [I] Length of tokeninfo 161 * retlen [O] Destination for returned token information length 162 * 163 * RETURNS 164 * Success: TRUE. tokeninfo contains retlen bytes of token information 165 * Failure: FALSE. 166 * 167 * NOTES 168 * See NtQueryInformationToken. 125 169 */ 126 170 BOOL WINAPI … … 128 172 LPVOID tokeninfo, DWORD tokeninfolength, LPDWORD retlen ) 129 173 { 130 CallWin32ToNt(NtQueryInformationToken( token, tokeninfoclass, tokeninfo, tokeninfolength, retlen));174 return set_ntstatus (NtQueryInformationToken( token, tokeninfoclass, tokeninfo, tokeninfolength, retlen)); 131 175 } 132 176 … … 134 178 * SetThreadToken [ADVAPI32.@] 135 179 * 136 * Assigns an "impersonation token" to a thread so it can assume the 137 * security privledges of another thread or process. Can also remove 138 * a previously assigned token. Only supported on NT - it's a stub 139 * exactly like this one on Win9X. 140 * 141 */ 142 180 * Assigns an 'impersonation token' to a thread so it can assume the 181 * security privileges of another thread or process. Can also remove 182 * a previously assigned token. 183 * 184 * PARAMS 185 * thread [O] Handle to thread to set the token for 186 * token [I] Token to set 187 * 188 * RETURNS 189 * Success: TRUE. The threads access token is set to token 190 * Failure: FALSE. 191 * 192 * NOTES 193 * Only supported on NT or higher. On Win9X this function does nothing. 194 * See SetTokenInformation. 195 */ 143 196 BOOL WINAPI SetThreadToken(PHANDLE thread, HANDLE token) 144 197 { … … 344 397 */ 345 398 BOOL WINAPI 346 InitializeSecurityDescriptor( SECURITY_DESCRIPTOR *pDescr, DWORD revision ) 347 { 348 CallWin32ToNt (RtlCreateSecurityDescriptor(pDescr, revision )); 349 } 399 InitializeSecurityDescriptor( PSECURITY_DESCRIPTOR pDescr, DWORD revision ) 400 { 401 return set_ntstatus( RtlCreateSecurityDescriptor(pDescr, revision )); 402 } 403 350 404 351 405 /****************************************************************************** 352 406 * GetSecurityDescriptorLength [ADVAPI32.@] 353 407 */ 354 DWORD WINAPI GetSecurityDescriptorLength( SECURITY_DESCRIPTOR *pDescr)355 { 356 return (RtlLengthSecurityDescriptor(pDescr));408 DWORD WINAPI GetSecurityDescriptorLength( PSECURITY_DESCRIPTOR pDescr) 409 { 410 return RtlLengthSecurityDescriptor(pDescr); 357 411 } 358 412 … … 365 419 */ 366 420 BOOL WINAPI 367 GetSecurityDescriptorOwner( SECURITY_DESCRIPTOR *pDescr, PSID *pOwner,421 GetSecurityDescriptorOwner( PSECURITY_DESCRIPTOR pDescr, PSID *pOwner, 368 422 LPBOOL lpbOwnerDefaulted ) 369 423 { 370 CallWin32ToNt (RtlGetOwnerSecurityDescriptor( pDescr, pOwner, (PBOOLEAN)lpbOwnerDefaulted )); 424 BOOLEAN defaulted; 425 BOOL ret = set_ntstatus( RtlGetOwnerSecurityDescriptor( pDescr, pOwner, &defaulted )); 426 *lpbOwnerDefaulted = defaulted; 427 return ret; 371 428 } 372 429 … … 379 436 PSID pOwner, BOOL bOwnerDefaulted) 380 437 { 381 CallWin32ToNt (RtlSetOwnerSecurityDescriptor(pSecurityDescriptor, pOwner, bOwnerDefaulted));438 return set_ntstatus( RtlSetOwnerSecurityDescriptor(pSecurityDescriptor, pOwner, bOwnerDefaulted)); 382 439 } 383 440 /****************************************************************************** … … 389 446 LPBOOL GroupDefaulted) 390 447 { 391 CallWin32ToNt (RtlGetGroupSecurityDescriptor(SecurityDescriptor, Group, (PBOOLEAN)GroupDefaulted)); 448 BOOLEAN defaulted; 449 BOOL ret = set_ntstatus( RtlGetGroupSecurityDescriptor(SecurityDescriptor, Group, &defaulted )); 450 *GroupDefaulted = defaulted; 451 return ret; 392 452 } 393 453 /****************************************************************************** … … 397 457 PSID Group, BOOL GroupDefaulted) 398 458 { 399 CallWin32ToNt (RtlSetGroupSecurityDescriptor( SecurityDescriptor, Group, GroupDefaulted));459 return set_ntstatus( RtlSetGroupSecurityDescriptor( SecurityDescriptor, Group, GroupDefaulted)); 400 460 } 401 461 … … 409 469 IsValidSecurityDescriptor( PSECURITY_DESCRIPTOR SecurityDescriptor ) 410 470 { 411 CallWin32ToNt (RtlValidSecurityDescriptor(SecurityDescriptor));471 return set_ntstatus( RtlValidSecurityDescriptor(SecurityDescriptor)); 412 472 } 413 473 … … 421 481 OUT LPBOOL lpbDaclDefaulted) 422 482 { 423 CallWin32ToNt (RtlGetDaclSecurityDescriptor(pSecurityDescriptor, (PBOOLEAN)lpbDaclPresent, 424 pDacl, (PBOOLEAN)lpbDaclDefaulted)); 483 BOOLEAN present, defaulted; 484 BOOL ret = set_ntstatus( RtlGetDaclSecurityDescriptor(pSecurityDescriptor, &present, pDacl, &defaulted)); 485 *lpbDaclPresent = present; 486 *lpbDaclDefaulted = defaulted; 487 return ret; 425 488 } 426 489 … … 435 498 BOOL dacldefaulted ) 436 499 { 437 CallWin32ToNt (RtlSetDaclSecurityDescriptor (lpsd, daclpresent, dacl, dacldefaulted ));500 return set_ntstatus( RtlSetDaclSecurityDescriptor (lpsd, daclpresent, dacl, dacldefaulted ) ); 438 501 } 439 502 /****************************************************************************** … … 446 509 OUT LPBOOL lpbSaclDefaulted) 447 510 { 448 CallWin32ToNt (RtlGetSaclSecurityDescriptor(lpsd, 449 (PBOOLEAN)lpbSaclPresent, pSacl, (PBOOLEAN)lpbSaclDefaulted)); 511 BOOLEAN present, defaulted; 512 BOOL ret = set_ntstatus( RtlGetSaclSecurityDescriptor(lpsd, &present, pSacl, &defaulted) ); 513 *lpbSaclPresent = present; 514 *lpbSaclDefaulted = defaulted; 515 return ret; 450 516 } 451 517 … … 459 525 BOOL sacldefaulted) 460 526 { 461 CallWin32ToNt(RtlSetSaclSecurityDescriptor(lpsd, saclpresent, lpsacl, sacldefaulted));527 return set_ntstatus (RtlSetSaclSecurityDescriptor(lpsd, saclpresent, lpsacl, sacldefaulted)); 462 528 } 463 529 /****************************************************************************** … … 475 541 IN OUT LPDWORD lpdwBufferLength) 476 542 { 477 CallWin32ToNt (RtlMakeSelfRelativeSD(pAbsoluteSecurityDescriptor,pSelfRelativeSecurityDescriptor, lpdwBufferLength)); 543 return set_ntstatus( RtlMakeSelfRelativeSD( pAbsoluteSecurityDescriptor, 544 pSelfRelativeSecurityDescriptor, lpdwBufferLength)); 478 545 } 479 546 … … 485 552 PSECURITY_DESCRIPTOR_CONTROL pControl, LPDWORD lpdwRevision) 486 553 { 487 CallWin32ToNt(RtlGetControlSecurityDescriptor(pSecurityDescriptor,pControl,lpdwRevision));554 return set_ntstatus (RtlGetControlSecurityDescriptor(pSecurityDescriptor,pControl,lpdwRevision)); 488 555 } 489 556 … … 496 563 * InitializeAcl [ADVAPI32.@] 497 564 */ 498 DWORD WINAPI InitializeAcl(PACL acl, DWORD size, DWORD rev) 499 { 500 CallWin32ToNt (RtlCreateAcl(acl, size, rev)); 501 } 502 565 BOOL WINAPI InitializeAcl(PACL acl, DWORD size, DWORD rev) 566 { 567 return set_ntstatus( RtlCreateAcl(acl, size, rev)); 568 } 569 570 /****************************************************************************** 571 * AddAccessAllowedAceEx [ADVAPI32.@] 572 */ 573 BOOL WINAPI AddAccessAllowedAceEx( 574 IN OUT PACL pAcl, 575 IN DWORD dwAceRevision, 576 IN DWORD AceFlags, 577 IN DWORD AccessMask, 578 IN PSID pSid) 579 { 580 FIXME("AddAccessAllowedAceEx (%x, %x, %x, %x, %x): stub\n", pAcl, dwAceRevision, AceFlags, AccessMask, pSid); 581 return FALSE; 582 // return set_ntstatus(RtlAddAccessAllowedAceEx(pAcl, dwAceRevision, AceFlags, AccessMask, pSid)); 583 } 584 585 /****************************************************************************** 586 * GetAce [ADVAPI32.@] 587 */ 588 BOOL WINAPI GetAce(PACL pAcl,DWORD dwAceIndex,LPVOID *pAce ) 589 { 590 return set_ntstatus(RtlGetAce(pAcl, dwAceIndex, pAce)); 591 } 503 592 /* ############################## 504 593 ###### MISC FUNCTIONS ###### … … 547 636 * GetFileSecurityA [ADVAPI32.@] 548 637 * 549 * Obtains Specified information about the security of a file or directory 550 * The information obtained is constrained by the callers access rights and 551 * privileges 638 * Obtains Specified information about the security of a file or directory. 639 * 640 * PARAMS 641 * lpFileName [I] Name of the file to get info for 642 * RequestedInformation [I] SE_ flags from "winnt.h" 643 * pSecurityDescriptor [O] Destination for security information 644 * nLength [I] Length of pSecurityDescriptor 645 * lpnLengthNeeded [O] Destination for length of returned security information 646 * 647 * RETURNS 648 * Success: TRUE. pSecurityDescriptor contains the requested information. 649 * Failure: FALSE. lpnLengthNeeded contains the required space to return the info. 650 * 651 * NOTES 652 * The information returned is constrained by the callers access rights and 653 * privileges. 552 654 */ 553 655 BOOL WINAPI … … 557 659 DWORD nLength, LPDWORD lpnLengthNeeded ) 558 660 { 559 FIXME("(%s) : stub\n", debugstr_a(lpFileName)); 560 return TRUE; 661 DWORD len; 662 BOOL r; 663 LPWSTR name = NULL; 664 665 if( lpFileName ) 666 { 667 len = MultiByteToWideChar( CP_ACP, 0, lpFileName, -1, NULL, 0 ); 668 name = HeapAlloc( GetProcessHeap(), 0, len*sizeof(WCHAR) ); 669 MultiByteToWideChar( CP_ACP, 0, lpFileName, -1, name, len ); 670 } 671 672 r = GetFileSecurityW( name, RequestedInformation, pSecurityDescriptor, 673 nLength, lpnLengthNeeded ); 674 HeapFree( GetProcessHeap(), 0, name ); 675 676 return r; 561 677 } 562 678 … … 564 680 * GetFileSecurityW [ADVAPI32.@] 565 681 * 566 * Obtains Specified information about the security of a file or directory 567 * The information obtained is constrained by the callers access rights and 568 * privileges 569 * 570 * PARAMS 571 * lpFileName [] 572 * RequestedInformation [] 573 * pSecurityDescriptor [] 574 * nLength [] 575 * lpnLengthNeeded [] 682 * See GetFileSecurityA. 576 683 */ 577 684 BOOL WINAPI … … 725 832 * 726 833 * PARAMS 727 * x1 []728 * x2 []729 * x3 []730 * x4 []834 * SystemName [I] 835 * ObjectAttributes [I] 836 * DesiredAccess [I] 837 * PolicyHandle [I/O] 731 838 */ 732 839 NTSTATUS WINAPI … … 742 849 dumpLsaAttributes(ObjectAttributes); 743 850 if(PolicyHandle) *PolicyHandle = (LSA_HANDLE)0xcafe; 744 return TRUE;851 return STATUS_SUCCESS; 745 852 } 746 853 … … 907 1014 LPBOOL AccessStatus) 908 1015 { 909 CallWin32ToNt(NtAccessCheck(SecurityDescriptor, ClientToken, DesiredAccess,1016 return set_ntstatus (NtAccessCheck(SecurityDescriptor, ClientToken, DesiredAccess, 910 1017 GenericMapping, PrivilegeSet, PrivilegeSetLength, GrantedAccess, (PBOOLEAN)AccessStatus)); 911 1018 } … … 919 1026 IN PSECURITY_DESCRIPTOR SecurityDescriptor ) 920 1027 { 921 CallWin32ToNt (NtSetSecurityObject (Handle, SecurityInformation, SecurityDescriptor)); 922 } 1028 return set_ntstatus (NtSetSecurityObject (Handle, SecurityInformation, SecurityDescriptor)); 1029 } 1030 923 1031 924 1032 /****************************************************************************** … … 952 1060 953 1061 /****************************************************************************** 954 * GetAce [ADVAPI32.@] 955 */ 956 BOOL WINAPI GetAce(PACL pAcl,DWORD dwAceIndex,LPVOID *pAce ) 957 { 958 CallWin32ToNt(RtlGetAce(pAcl, dwAceIndex, pAce)); 959 } 1062 * ConvertSidToStringSidW [ADVAPI32.@] 1063 * 1064 * format of SID string is: 1065 * S-<count>-<auth>-<subauth1>-<subauth2>-<subauth3>... 1066 * where 1067 * <rev> is the revision of the SID encoded as decimal 1068 * <auth> is the identifier authority encoded as hex 1069 * <subauthN> is the subauthority id encoded as decimal 1070 */ 1071 BOOL WINAPI ConvertSidToStringSidW( PSID pSid, LPWSTR *pstr ) 1072 { 1073 DWORD sz, i; 1074 LPWSTR str; 1075 WCHAR fmt[] = { 'S','-','%','u','-','%','d',0 }; 1076 WCHAR subauthfmt[] = { '-','%','u',0 }; 1077 SID* pisid=pSid; 1078 1079 TRACE("%p %p\n", pSid, pstr ); 1080 1081 if( !IsValidSid( pSid ) ) 1082 return FALSE; 1083 1084 if (pisid->Revision != SDDL_REVISION) 1085 return FALSE; 1086 if (pisid->IdentifierAuthority.Value[0] || 1087 pisid->IdentifierAuthority.Value[1]) 1088 { 1089 FIXME("not matching MS' bugs\n"); 1090 return FALSE; 1091 } 1092 1093 sz = 14 + pisid->SubAuthorityCount * 11; 1094 str = LocalAlloc( 0, sz*sizeof(WCHAR) ); 1095 sprintfW( str, fmt, pisid->Revision, MAKELONG( 1096 MAKEWORD( pisid->IdentifierAuthority.Value[5], 1097 pisid->IdentifierAuthority.Value[4] ), 1098 MAKEWORD( pisid->IdentifierAuthority.Value[3], 1099 pisid->IdentifierAuthority.Value[2] ) ) ); 1100 for( i=0; i<pisid->SubAuthorityCount; i++ ) 1101 sprintfW( str + strlenW(str), subauthfmt, pisid->SubAuthority[i] ); 1102 *pstr = str; 1103 1104 return TRUE; 1105 } 1106 1107 /****************************************************************************** 1108 * ConvertSidToStringSidA [ADVAPI32.@] 1109 */ 1110 BOOL WINAPI ConvertSidToStringSidA(PSID pSid, LPSTR *pstr) 1111 { 1112 LPWSTR wstr = NULL; 1113 LPSTR str; 1114 UINT len; 1115 1116 TRACE("%p %p\n", pSid, pstr ); 1117 1118 if( !ConvertSidToStringSidW( pSid, &wstr ) ) 1119 return FALSE; 1120 1121 len = WideCharToMultiByte( CP_ACP, 0, wstr, -1, NULL, 0, NULL, NULL ); 1122 str = LocalAlloc( 0, len ); 1123 WideCharToMultiByte( CP_ACP, 0, wstr, -1, str, len, NULL, NULL ); 1124 LocalFree( wstr ); 1125 1126 *pstr = str; 1127 1128 return TRUE; 1129 } -
trunk/src/advapi32/systemfunction.cpp
r5748 r21325 15 15 //****************************************************************************** 16 16 //****************************************************************************** 17 DWORD WINAPI SystemFunction001(DWORD arg1, DWORD arg2, DWORD arg3)18 {19 dprintf(("NOT IMPLEMENTED: SystemFunction001 %x %x %x", arg1, arg2, arg3));20 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);21 return 0;22 }23 //******************************************************************************24 //******************************************************************************25 DWORD WINAPI SystemFunction002(DWORD arg1, DWORD arg2, DWORD arg3)26 {27 dprintf(("NOT IMPLEMENTED: SystemFunction002 %x %x %x", arg1, arg2, arg3));28 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);29 return 0;30 }31 //******************************************************************************32 //******************************************************************************33 DWORD WINAPI SystemFunction003(DWORD arg1, DWORD arg2)34 {35 dprintf(("NOT IMPLEMENTED: SystemFunction003 %x %x %x", arg1, arg2));36 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);37 return 0;38 }39 //******************************************************************************40 //******************************************************************************41 DWORD WINAPI SystemFunction004(DWORD arg1, DWORD arg2, DWORD arg3)42 {43 dprintf(("NOT IMPLEMENTED: SystemFunction004 %x %x %x", arg1, arg2, arg3));44 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);45 return 0;46 }47 //******************************************************************************48 //******************************************************************************49 DWORD WINAPI SystemFunction005(DWORD arg1, DWORD arg2, DWORD arg3)50 {51 dprintf(("NOT IMPLEMENTED: SystemFunction005 %x %x %x", arg1, arg2, arg3));52 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);53 return 0;54 }55 //******************************************************************************56 //******************************************************************************57 DWORD WINAPI SystemFunction006(DWORD arg1, DWORD arg2)58 {59 dprintf(("NOT IMPLEMENTED: SystemFunction006 %x %x %x", arg1, arg2));60 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);61 return 0;62 }63 //******************************************************************************64 //******************************************************************************65 DWORD WINAPI SystemFunction007(DWORD arg1, DWORD arg2)66 {67 dprintf(("NOT IMPLEMENTED: SystemFunction007 %x %x %x", arg1, arg2));68 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);69 return 0;70 }71 //******************************************************************************72 //******************************************************************************73 DWORD WINAPI SystemFunction008(DWORD arg1, DWORD arg2, DWORD arg3)74 {75 dprintf(("NOT IMPLEMENTED: SystemFunction008 %x %x %x", arg1, arg2, arg3));76 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);77 return 0;78 }79 //******************************************************************************80 //******************************************************************************81 DWORD WINAPI SystemFunction009(DWORD arg1, DWORD arg2, DWORD arg3)82 {83 dprintf(("NOT IMPLEMENTED: SystemFunction009 %x %x %x", arg1, arg2, arg3));84 return SystemFunction008(arg1, arg2, arg3);85 }86 //******************************************************************************87 //******************************************************************************88 DWORD WINAPI SystemFunction010(DWORD arg1, DWORD arg2, DWORD arg3)89 {90 dprintf(("NOT IMPLEMENTED: SystemFunction010 %x %x %x", arg1, arg2, arg3));91 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);92 return 0;93 }94 //******************************************************************************95 //******************************************************************************96 17 DWORD WINAPI SystemFunction011(DWORD arg1, DWORD arg2, DWORD arg3) 97 18 { 98 19 dprintf(("NOT IMPLEMENTED: SystemFunction011 %x %x %x", arg1, arg2, arg3)); 99 return SystemFunction010(arg1, arg2, arg3);100 }101 //******************************************************************************102 //******************************************************************************103 DWORD WINAPI SystemFunction012(DWORD arg1, DWORD arg2, DWORD arg3)104 {105 dprintf(("NOT IMPLEMENTED: SystemFunction012 %x %x %x", arg1, arg2, arg3));106 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);107 return 0;108 }109 //******************************************************************************110 //******************************************************************************111 DWORD WINAPI SystemFunction013(DWORD arg1, DWORD arg2, DWORD arg3)112 {113 dprintf(("NOT IMPLEMENTED: SystemFunction013 %x %x %x", arg1, arg2, arg3));114 20 SetLastError(ERROR_CALL_NOT_IMPLEMENTED); 115 21 return 0; … … 120 26 { 121 27 dprintf(("NOT IMPLEMENTED: SystemFunction014 %x %x %x", arg1, arg2, arg3)); 122 return SystemFunction012(arg1, arg2, arg3); 28 SetLastError(ERROR_CALL_NOT_IMPLEMENTED); 29 return 0; 123 30 } 124 31 //****************************************************************************** … … 127 34 { 128 35 dprintf(("NOT IMPLEMENTED: SystemFunction015 %x %x %x", arg1, arg2, arg3)); 129 return SystemFunction013(arg1, arg2, arg3); 36 SetLastError(ERROR_CALL_NOT_IMPLEMENTED); 37 return 0; 130 38 } 131 39 //****************************************************************************** … … 150 58 { 151 59 dprintf(("NOT IMPLEMENTED: SystemFunction018 %x %x %x", arg1, arg2, arg3)); 152 return SystemFunction016(arg1, arg2, arg3); 60 SetLastError(ERROR_CALL_NOT_IMPLEMENTED); 61 return 0; 153 62 } 154 63 //****************************************************************************** … … 157 66 { 158 67 dprintf(("NOT IMPLEMENTED: SystemFunction019 %x %x %x", arg1, arg2, arg3)); 159 return SystemFunction017(arg1, arg2, arg3); 68 SetLastError(ERROR_CALL_NOT_IMPLEMENTED); 69 return 0; 160 70 } 161 71 //****************************************************************************** … … 164 74 { 165 75 dprintf(("NOT IMPLEMENTED: SystemFunction020 %x %x %x", arg1, arg2, arg3)); 166 return SystemFunction012(arg1, arg2, arg3); 76 SetLastError(ERROR_CALL_NOT_IMPLEMENTED); 77 return 0; 167 78 } 168 79 //****************************************************************************** … … 171 82 { 172 83 dprintf(("NOT IMPLEMENTED: SystemFunction021 %x %x %x", arg1, arg2, arg3)); 173 return SystemFunction013(arg1, arg2, arg3); 84 SetLastError(ERROR_CALL_NOT_IMPLEMENTED); 85 return 0; 174 86 } 175 87 //****************************************************************************** … … 178 90 { 179 91 dprintf(("NOT IMPLEMENTED: SystemFunction022 %x %x %x", arg1, arg2, arg3)); 180 return SystemFunction020(arg1, arg2, arg3); 92 SetLastError(ERROR_CALL_NOT_IMPLEMENTED); 93 return 0; 181 94 } 182 95 //****************************************************************************** … … 185 98 { 186 99 dprintf(("NOT IMPLEMENTED: SystemFunction023 %x %x %x", arg1, arg2, arg3)); 187 return SystemFunction021(arg1, arg2, arg3);188 }189 //******************************************************************************190 //******************************************************************************191 DWORD WINAPI SystemFunction024(DWORD arg1, DWORD arg2, DWORD arg3)192 {193 dprintf(("NOT IMPLEMENTED: SystemFunction024 %x %x %x", arg1, arg2, arg3));194 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);195 return 0;196 }197 //******************************************************************************198 //******************************************************************************199 DWORD WINAPI SystemFunction025(DWORD arg1, DWORD arg2, DWORD arg3)200 {201 dprintf(("NOT IMPLEMENTED: SystemFunction025 %x %x %x", arg1, arg2, arg3));202 100 SetLastError(ERROR_CALL_NOT_IMPLEMENTED); 203 101 return 0; … … 208 106 { 209 107 dprintf(("NOT IMPLEMENTED: SystemFunction026 %x %x %x", arg1, arg2, arg3)); 210 return SystemFunction024(arg1, arg2, arg3); 108 SetLastError(ERROR_CALL_NOT_IMPLEMENTED); 109 return 0; 211 110 } 212 111 //****************************************************************************** … … 215 114 { 216 115 dprintf(("NOT IMPLEMENTED: SystemFunction027 %x %x %x", arg1, arg2, arg3)); 217 return SystemFunction025(arg1, arg2, arg3); 116 SetLastError(ERROR_CALL_NOT_IMPLEMENTED); 117 return 0; 218 118 } 219 119 //****************************************************************************** … … 234 134 } 235 135 //****************************************************************************** 236 //calls RtlCompareMemory237 //******************************************************************************238 DWORD WINAPI SystemFunction030(DWORD arg1, DWORD arg2)239 {240 dprintf(("NOT IMPLEMENTED: SystemFunction030 %x %x", arg1, arg2));241 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);242 return 0;243 }244 //******************************************************************************245 136 //looks the same as 030 246 137 //****************************************************************************** … … 248 139 { 249 140 dprintf(("NOT IMPLEMENTED: SystemFunction031 %x %x", arg1, arg2)); 250 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);251 return 0;252 }253 //******************************************************************************254 //******************************************************************************255 DWORD WINAPI SystemFunction032(DWORD arg1, DWORD arg2)256 {257 dprintf(("NOT IMPLEMENTED: SystemFunction032 %x %x", arg1, arg2));258 141 SetLastError(ERROR_CALL_NOT_IMPLEMENTED); 259 142 return 0; -
trunk/src/crypt32/crypt32.def
r21311 r21325 2 2 DESCRIPTION 'Odin32 System DLL - crypt32' 3 3 DATA MULTIPLE NONSHARED 4 5 IMPORTS6 _fdopen = MSVCRT.1907 snprintf = MSVCRT.4078 strcasecmp = MSVCRT.4269 open = MSVCRT.36810 close = MSVCRT.15811 _CryptContextAddRef@12 = ADVAPI32.42412 RegDeleteTreeW = ADVAPI32.42513 SetFilePointerEx = KERNEL32.316114 CryptSetProvParam = ADVAPI32.7115 4 16 5 EXPORTS -
trunk/src/crypt32/crypt32_private.h
r21311 r21325 395 395 #define POINTER_ALIGN_DWORD_PTR(p) ((LPVOID)ALIGN_DWORD_PTR((/*DWORD_PTR*/unsigned int)(p))) 396 396 397 #define strcasecmp lstrcmpiA 397 398 398 399 #endif -
trunk/src/crypt32/main.c
r21311 r21325 250 250 return NULL; 251 251 } 252 253 void ulong2string (unsigned long number, char *string, int n, int base) 254 { 255 static char *digits = "0123456789ABCDEF"; 256 257 unsigned long tmp = number; 258 char *s = string; 259 int len = 0; 260 int l = 0; 261 int i; 262 263 if (n <= 0) 264 { 265 return; 266 } 267 268 if (tmp == 0) 269 { 270 s[l++] = digits[0]; 271 } 272 273 while (tmp != 0) 274 { 275 if (l >= n) 276 { 277 break; 278 } 279 s[l++] = digits[tmp%base]; 280 len++; 281 tmp /= base; 282 } 283 if (l < n) 284 { 285 s[l++] = '\0'; 286 } 287 288 s = string; 289 290 for (i = 0; i < len/2; i++) 291 { 292 tmp = s[i]; 293 s[i] = s[len - i - 1]; 294 s[len - i - 1] = tmp; 295 } 296 297 return; 298 } 299 300 void long2string (long number, char *string, int n, int base) 301 { 302 if (n <= 0) 303 { 304 return; 305 } 306 307 if (number < 0) 308 { 309 *string++ = '-'; 310 number = -number; 311 n--; 312 } 313 314 ulong2string (number, string, n, base); 315 } 316 317 int string2ulong (const char *string, char **pstring2, unsigned long *pvalue, int base) 318 { 319 unsigned long value = 0; 320 int sign = 1; 321 322 const char *p = string; 323 324 if (p[0] == '-') 325 { 326 sign = -1; 327 p++; 328 } 329 330 if (base == 0) 331 { 332 if (p[0] == 0 && (p[1] == 'x' || p[1] == 'X')) 333 { 334 base = 16; 335 p += 2; 336 } 337 else if (p[0] == 0) 338 { 339 base = 8; 340 p += 1; 341 } 342 else 343 { 344 base = 10; 345 } 346 } 347 348 while (*p) 349 { 350 int digit = 0; 351 352 if ('0' <= *p && *p <= '9') 353 { 354 digit = *p - '0'; 355 } 356 else if ('a' <= *p && *p <= 'f') 357 { 358 digit = *p - 'a' + 0xa; 359 } 360 else if ('A' <= *p && *p <= 'F') 361 { 362 digit = *p - 'A' + 0xa; 363 } 364 else 365 { 366 break; 367 } 368 369 if (digit >= base) 370 { 371 break; 372 } 373 374 value = value*base + digit; 375 376 p++; 377 } 378 379 if (pstring2) 380 { 381 *pstring2 = (char *)p; 382 } 383 384 *pvalue = sign*value; 385 386 return 1; 387 } 388 389 int vsnprintf (char *buf, int n, const char *fmt, va_list args) 390 { 391 int count = 0; 392 char *s = (char *)fmt; 393 char *d = buf; 394 395 if (n <= 0) 396 { 397 return 0; 398 } 399 400 n--; 401 402 while (*s && count < n) 403 { 404 char tmpstr[16]; 405 406 char *str = NULL; 407 408 int width = 0; 409 int precision = 0; 410 411 if (*s == '%') 412 { 413 s++; 414 415 if ('0' <= *s && *s <= '9' || *s == '-') 416 { 417 char setprec = (*s == '0'); 418 string2ulong (s, &s, (unsigned long *)&width, 10); 419 if (setprec) 420 { 421 precision = width; 422 } 423 } 424 425 if (*s == '.') 426 { 427 s++; 428 string2ulong (s, &s, (unsigned long *)&precision, 10); 429 } 430 431 if (*s == 's') 432 { 433 str = va_arg(args, char *); 434 s++; 435 precision = 0; 436 } 437 else if (*s == 'c') 438 { 439 tmpstr[0] = va_arg(args, int); 440 tmpstr[1] = 0; 441 str = &tmpstr[0]; 442 s++; 443 precision = 0; 444 } 445 else if (*s == 'p' || *s == 'P') 446 { 447 int num = va_arg(args, int); 448 449 ulong2string (num, tmpstr, sizeof (tmpstr), 16); 450 451 str = &tmpstr[0]; 452 s++; 453 width = 8; 454 precision = 8; 455 } 456 else 457 { 458 if (*s == 'l') 459 { 460 s++; 461 } 462 463 if (*s == 'd' || *s == 'i') 464 { 465 int num = va_arg(args, int); 466 467 long2string (num, tmpstr, sizeof (tmpstr), 10); 468 469 str = &tmpstr[0]; 470 s++; 471 } 472 else if (*s == 'u') 473 { 474 int num = va_arg(args, int); 475 476 ulong2string (num, tmpstr, sizeof (tmpstr), 10); 477 478 str = &tmpstr[0]; 479 s++; 480 } 481 else if (*s == 'x' || *s == 'X') 482 { 483 int num = va_arg(args, int); 484 485 ulong2string (num, tmpstr, sizeof (tmpstr), 16); 486 487 str = &tmpstr[0]; 488 s++; 489 } 490 } 491 } 492 493 if (str != NULL) 494 { 495 int i; 496 char numstr[16]; 497 int len = strlen (str); 498 int leftalign = 0; 499 500 if (width < 0) 501 { 502 width = -width; 503 leftalign = 1; 504 } 505 506 if (precision) 507 { 508 i = 0; 509 while (precision > len) 510 { 511 numstr[i++] = '0'; 512 precision--; 513 } 514 515 memcpy (&numstr[i], str, len); 516 517 str = &numstr[0]; 518 len += i; 519 } 520 521 if (len < width && !leftalign) 522 { 523 while (len < width && count < n) 524 { 525 *d++ = ' '; 526 width--; 527 count++; 528 } 529 530 if (count >= n) 531 { 532 break; 533 } 534 } 535 536 i = 0; 537 while (i < len && count < n) 538 { 539 *d++ = str[i++]; 540 count++; 541 } 542 543 if (count >= n) 544 { 545 break; 546 } 547 548 if (len < width && leftalign) 549 { 550 while (len < width && count < n) 551 { 552 *d++ = ' '; 553 width--; 554 count++; 555 } 556 557 if (count >= n) 558 { 559 break; 560 } 561 } 562 } 563 else 564 { 565 *d++ = *s++; 566 count++; 567 } 568 } 569 570 *d = '\0'; 571 572 return count + 1; 573 } 574 575 int snprintf (char *buf, int n, const char *fmt, ...) 576 { 577 va_list args; 578 579 int rc = 0; 580 581 va_start (args, fmt); 582 583 rc = vsnprintf (buf, n, fmt, args); 584 585 va_end (args); 586 587 return rc; 588 } -
trunk/src/crypt32/rootstore.c
r21311 r21325 299 299 TRACE("\n"); 300 300 301 fp = fdopen(fd, "r");301 fp = odin_fdopen(fd, "r"); 302 302 if (fp) 303 303 { … … 364 364 TRACE("(%s, %p, %d)\n", debugstr_a(path), store, allow_dir); 365 365 366 fd = open(path, O_RDONLY);366 fd = _open(path, O_RDONLY); 367 367 if (fd != -1) 368 368 { … … 388 388 } 389 389 #endif 390 close(fd);390 _close(fd); 391 391 } 392 392 return ret;
Note:
See TracChangeset
for help on using the changeset viewer.