Changeset 21325 for trunk/src


Ignore:
Timestamp:
Jul 3, 2009, 11:59:02 PM (16 years ago)
Author:
ydario
Message:

advapi32 and crypt32 updates.

Location:
trunk/src
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/advapi32/ADVAPI32.DEF

    r5748 r21325  
    439439     UnlockServiceDatabase      = _UnlockServiceDatabase@4           @401
    440440
     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  
    439439     UnlockServiceDatabase      = _UnlockServiceDatabase@4           @401
    440440
     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  
    2525$(OBJDIR)\advapi32rsrc.obj \
    2626$(OBJDIR)\lsa.obj \
     27$(OBJDIR)\registry.obj \
    2728$(OBJDIR)\security.obj \
    2829$(OBJDIR)\security_odin.obj \
     
    3132$(OBJDIR)\eventlog.obj \
    3233$(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\
    3340$(DLLENTRY)
    3441
     
    3946LIBS = \
    4047$(ODIN32_LIB)/kernel32.lib \
     48$(ODIN32_LIB)/user32.lib \
    4149$(ODIN32_LIB)/ntdll.lib \
    4250$(ODIN32_LIB)/$(ODINCRT).lib \
  • trunk/src/advapi32/security.c

    r10272 r21325  
    99#include "heap.h"
    1010#include "ntddk.h"
     11#include "ntstatus.h"
    1112#include "ntsecapi.h"
     13#include "sddl.h"
     14//#include "wine/debug.h"
    1215#include "debugtools.h"
     16#include "wine/unicode.h"
    1317
    1418#ifdef __WIN32OS2__
    15 #include <heapstring.h>
     19//#include <heapstring.h>
     20LPWSTR WIN32API HEAP_strdupAtoW( HANDLE heap, DWORD flags, LPCSTR str );
    1621#endif
    1722
    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; \
     23WINE_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 */
     28static inline BOOL set_ntstatus( NTSTATUS status )
     29{
     30    if (status) SetLastError( RtlNtStatusToDosError( status ));
     31    return !status;
    2632        }
    2733
     
    3036        if (oa)
    3137        {
    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",
    3339                oa->Length, oa->RootDirectory,
    3440                oa->ObjectName?debugstr_w(oa->ObjectName->Buffer):"null",
     
    4450/******************************************************************************
    4551 * OpenProcessToken                     [ADVAPI32.@]
    46  * Opens the access token associated with a process
     52 * Opens the access token associated with a process handle.
    4753 *
    4854 * PARAMS
     
    5157 *   TokenHandle   [O] Pointer to handle of open access token
    5258 *
    53  * RETURNS STD
     59 * RETURNS
     60 *  Success: TRUE. TokenHandle contains the access token.
     61 *  Failure: FALSE.
     62 *
     63 * NOTES
     64 *  See NtOpenProcessToken.
    5465 */
    5566BOOL WINAPI
     
    5768                  HANDLE *TokenHandle )
    5869{
    59         CallWin32ToNt(NtOpenProcessToken( ProcessHandle, DesiredAccess, TokenHandle ));
     70        return set_ntstatus(NtOpenProcessToken( ProcessHandle, DesiredAccess, TokenHandle ));
    6071}
    6172
     
    6374 * OpenThreadToken [ADVAPI32.@]
    6475 *
    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.
    7090 */
    7191BOOL WINAPI
     
    7393                 BOOL OpenAsSelf, HANDLE *TokenHandle)
    7494{
    75         CallWin32ToNt (NtOpenThreadToken(ThreadHandle, DesiredAccess, OpenAsSelf, TokenHandle));
     95        return set_ntstatus( NtOpenThreadToken(ThreadHandle, DesiredAccess, OpenAsSelf, TokenHandle));
    7696}
    7797
     
    7999 * AdjustTokenPrivileges [ADVAPI32.@]
    80100 *
    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.
    88118 */
    89119BOOL WINAPI
     
    92122                       LPVOID PreviousState, LPDWORD ReturnLength )
    93123{
    94         CallWin32ToNt(NtAdjustPrivilegesToken(TokenHandle, DisableAllPrivileges, NewState, BufferLength, PreviousState, ReturnLength));
     124        return set_ntstatus( NtAdjustPrivilegesToken(TokenHandle, DisableAllPrivileges,
     125                                                     NewState, BufferLength, PreviousState,
     126                                                     ReturnLength));
    95127}
    96128
     
    98130 * CheckTokenMembership [ADVAPI32.@]
    99131 *
    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.
    104142 */
    105143BOOL WINAPI
     
    107145                      PBOOL IsMember )
    108146{
    109   FIXME("(0x%08x %p %p) stub!\n", TokenHandle, SidToCheck, IsMember);
     147  FIXME("(%p %p %p) stub!\n", TokenHandle, SidToCheck, IsMember);
    110148
    111149  *IsMember = TRUE;
     
    117155 *
    118156 * 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.
    125169 */
    126170BOOL WINAPI
     
    128172                     LPVOID tokeninfo, DWORD tokeninfolength, LPDWORD retlen )
    129173{
    130         CallWin32ToNt (NtQueryInformationToken( token, tokeninfoclass, tokeninfo, tokeninfolength, retlen));
     174    return set_ntstatus (NtQueryInformationToken( token, tokeninfoclass, tokeninfo, tokeninfolength, retlen));
    131175}
    132176
     
    134178 * SetThreadToken [ADVAPI32.@]
    135179 *
    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 */
    143196BOOL WINAPI SetThreadToken(PHANDLE thread, HANDLE token)
    144197{
     
    344397 */
    345398BOOL WINAPI
    346 InitializeSecurityDescriptor( SECURITY_DESCRIPTOR *pDescr, DWORD revision )
    347 {
    348         CallWin32ToNt (RtlCreateSecurityDescriptor(pDescr, revision ));
    349 }
     399InitializeSecurityDescriptor( PSECURITY_DESCRIPTOR pDescr, DWORD revision )
     400{
     401        return set_ntstatus( RtlCreateSecurityDescriptor(pDescr, revision ));
     402}
     403
    350404
    351405/******************************************************************************
    352406 * GetSecurityDescriptorLength [ADVAPI32.@]
    353407 */
    354 DWORD WINAPI GetSecurityDescriptorLength( SECURITY_DESCRIPTOR *pDescr)
    355 {
    356         return (RtlLengthSecurityDescriptor(pDescr));
     408DWORD WINAPI GetSecurityDescriptorLength( PSECURITY_DESCRIPTOR pDescr)
     409{
     410        return RtlLengthSecurityDescriptor(pDescr);
    357411}
    358412
     
    365419 */
    366420BOOL WINAPI
    367 GetSecurityDescriptorOwner( SECURITY_DESCRIPTOR *pDescr, PSID *pOwner,
     421GetSecurityDescriptorOwner( PSECURITY_DESCRIPTOR pDescr, PSID *pOwner,
    368422                            LPBOOL lpbOwnerDefaulted )
    369423{
    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;
    371428}
    372429
     
    379436                                   PSID pOwner, BOOL bOwnerDefaulted)
    380437{
    381         CallWin32ToNt (RtlSetOwnerSecurityDescriptor(pSecurityDescriptor, pOwner, bOwnerDefaulted));
     438    return set_ntstatus( RtlSetOwnerSecurityDescriptor(pSecurityDescriptor, pOwner, bOwnerDefaulted));
    382439}
    383440/******************************************************************************
     
    389446        LPBOOL GroupDefaulted)
    390447{
    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;
    392452}       
    393453/******************************************************************************
     
    397457                                           PSID Group, BOOL GroupDefaulted)
    398458{
    399         CallWin32ToNt (RtlSetGroupSecurityDescriptor( SecurityDescriptor, Group, GroupDefaulted));
     459    return set_ntstatus( RtlSetGroupSecurityDescriptor( SecurityDescriptor, Group, GroupDefaulted));
    400460}
    401461
     
    409469IsValidSecurityDescriptor( PSECURITY_DESCRIPTOR SecurityDescriptor )
    410470{
    411         CallWin32ToNt (RtlValidSecurityDescriptor(SecurityDescriptor));
     471    return set_ntstatus( RtlValidSecurityDescriptor(SecurityDescriptor));
    412472}
    413473
     
    421481        OUT LPBOOL lpbDaclDefaulted)
    422482{
    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;
    425488}       
    426489
     
    435498        BOOL dacldefaulted )
    436499{
    437         CallWin32ToNt (RtlSetDaclSecurityDescriptor (lpsd, daclpresent, dacl, dacldefaulted ));
     500    return set_ntstatus( RtlSetDaclSecurityDescriptor (lpsd, daclpresent, dacl, dacldefaulted ) );
    438501}
    439502/******************************************************************************
     
    446509        OUT LPBOOL lpbSaclDefaulted)
    447510{
    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;
    450516}       
    451517
     
    459525        BOOL sacldefaulted)
    460526{
    461         CallWin32ToNt (RtlSetSaclSecurityDescriptor(lpsd, saclpresent, lpsacl, sacldefaulted));
     527    return set_ntstatus (RtlSetSaclSecurityDescriptor(lpsd, saclpresent, lpsacl, sacldefaulted));
    462528}
    463529/******************************************************************************
     
    475541        IN OUT LPDWORD lpdwBufferLength)
    476542{
    477         CallWin32ToNt (RtlMakeSelfRelativeSD(pAbsoluteSecurityDescriptor,pSelfRelativeSecurityDescriptor, lpdwBufferLength));
     543    return set_ntstatus( RtlMakeSelfRelativeSD( pAbsoluteSecurityDescriptor,
     544                                                pSelfRelativeSecurityDescriptor, lpdwBufferLength));
    478545}
    479546
     
    485552                 PSECURITY_DESCRIPTOR_CONTROL pControl, LPDWORD lpdwRevision)
    486553{
    487         CallWin32ToNt (RtlGetControlSecurityDescriptor(pSecurityDescriptor,pControl,lpdwRevision));
     554        return set_ntstatus (RtlGetControlSecurityDescriptor(pSecurityDescriptor,pControl,lpdwRevision));
    488555}               
    489556
     
    496563 * InitializeAcl [ADVAPI32.@]
    497564 */
    498 DWORD WINAPI InitializeAcl(PACL acl, DWORD size, DWORD rev)
    499 {
    500         CallWin32ToNt (RtlCreateAcl(acl, size, rev));
    501 }
    502 
     565BOOL WINAPI InitializeAcl(PACL acl, DWORD size, DWORD rev)
     566{
     567    return set_ntstatus( RtlCreateAcl(acl, size, rev));
     568}
     569
     570/******************************************************************************
     571 *  AddAccessAllowedAceEx [ADVAPI32.@]
     572 */
     573BOOL 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 */
     588BOOL WINAPI GetAce(PACL pAcl,DWORD dwAceIndex,LPVOID *pAce )
     589{
     590    return set_ntstatus(RtlGetAce(pAcl, dwAceIndex, pAce));
     591}
    503592/*      ##############################
    504593        ######  MISC FUNCTIONS  ######
     
    547636 * GetFileSecurityA [ADVAPI32.@]
    548637 *
    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.
    552654 */
    553655BOOL WINAPI
     
    557659                    DWORD nLength, LPDWORD lpnLengthNeeded )
    558660{
    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;
    561677}
    562678
     
    564680 * GetFileSecurityW [ADVAPI32.@]
    565681 *
    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.
    576683 */
    577684BOOL WINAPI
     
    725832 *
    726833 * PARAMS
    727  *   x1 []
    728  *   x2 []
    729  *   x3 []
    730  *   x4 []
     834 *   SystemName       [I]
     835 *   ObjectAttributes [I]
     836 *   DesiredAccess    [I]
     837 *   PolicyHandle     [I/O]
    731838 */
    732839NTSTATUS WINAPI
     
    742849        dumpLsaAttributes(ObjectAttributes);
    743850        if(PolicyHandle) *PolicyHandle = (LSA_HANDLE)0xcafe;
    744         return TRUE;
     851        return STATUS_SUCCESS;
    745852}
    746853
     
    9071014        LPBOOL AccessStatus)
    9081015{
    909         CallWin32ToNt (NtAccessCheck(SecurityDescriptor, ClientToken, DesiredAccess,
     1016        return set_ntstatus (NtAccessCheck(SecurityDescriptor, ClientToken, DesiredAccess,
    9101017          GenericMapping, PrivilegeSet, PrivilegeSetLength, GrantedAccess, (PBOOLEAN)AccessStatus));
    9111018}
     
    9191026        IN PSECURITY_DESCRIPTOR SecurityDescriptor )
    9201027{
    921         CallWin32ToNt (NtSetSecurityObject (Handle, SecurityInformation, SecurityDescriptor));
    922 }
     1028        return set_ntstatus (NtSetSecurityObject (Handle, SecurityInformation, SecurityDescriptor));
     1029}
     1030
    9231031
    9241032/******************************************************************************
     
    9521060
    9531061/******************************************************************************
    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 */
     1071BOOL 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 */
     1110BOOL 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  
    1515//******************************************************************************
    1616//******************************************************************************
    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 //******************************************************************************
    9617DWORD WINAPI SystemFunction011(DWORD arg1, DWORD arg2, DWORD arg3)
    9718{
    9819    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));
    11420    SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
    11521    return 0;
     
    12026{
    12127    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;
    12330}
    12431//******************************************************************************
     
    12734{
    12835    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;
    13038}
    13139//******************************************************************************
     
    15058{
    15159    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;
    15362}
    15463//******************************************************************************
     
    15766{
    15867    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;
    16070}
    16171//******************************************************************************
     
    16474{
    16575    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;
    16778}
    16879//******************************************************************************
     
    17182{
    17283    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;
    17486}
    17587//******************************************************************************
     
    17890{
    17991    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;
    18194}
    18295//******************************************************************************
     
    18598{
    18699    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));
    202100    SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
    203101    return 0;
     
    208106{
    209107    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;
    211110}
    212111//******************************************************************************
     
    215114{
    216115    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;
    218118}
    219119//******************************************************************************
     
    234134}
    235135//******************************************************************************
    236 //calls RtlCompareMemory
    237 //******************************************************************************
    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 //******************************************************************************
    245136//looks the same as 030
    246137//******************************************************************************
     
    248139{
    249140    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));
    258141    SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
    259142    return 0;
  • trunk/src/crypt32/crypt32.def

    r21311 r21325  
    22DESCRIPTION 'Odin32 System DLL - crypt32'
    33DATA MULTIPLE NONSHARED
    4 
    5 IMPORTS
    6 _fdopen = MSVCRT.190
    7 snprintf = MSVCRT.407
    8 strcasecmp = MSVCRT.426
    9 open = MSVCRT.368
    10 close = MSVCRT.158
    11 _CryptContextAddRef@12 = ADVAPI32.424
    12 RegDeleteTreeW = ADVAPI32.425
    13 SetFilePointerEx = KERNEL32.3161
    14 CryptSetProvParam = ADVAPI32.71
    154
    165EXPORTS
  • trunk/src/crypt32/crypt32_private.h

    r21311 r21325  
    395395#define POINTER_ALIGN_DWORD_PTR(p) ((LPVOID)ALIGN_DWORD_PTR((/*DWORD_PTR*/unsigned int)(p)))
    396396
     397#define strcasecmp  lstrcmpiA
    397398
    398399#endif
  • trunk/src/crypt32/main.c

    r21311 r21325  
    250250    return NULL;
    251251}
     252
     253void 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
     300void 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 
     317int 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
     389int 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
     575int 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  
    299299    TRACE("\n");
    300300
    301     fp = fdopen(fd, "r");
     301    fp = odin_fdopen(fd, "r");
    302302    if (fp)
    303303    {
     
    364364    TRACE("(%s, %p, %d)\n", debugstr_a(path), store, allow_dir);
    365365
    366     fd = open(path, O_RDONLY);
     366    fd = _open(path, O_RDONLY);
    367367    if (fd != -1)
    368368    {
     
    388388        }
    389389#endif
    390         close(fd);
     390        _close(fd);
    391391    }
    392392    return ret;
Note: See TracChangeset for help on using the changeset viewer.