11 BOOL32 WINAPI IsValidSid (LPSID pSid);
12 BOOL32 WINAPI EqualSid (LPSID pSid1, LPSID pSid2);
13 BOOL32 WINAPI EqualPrefixSid (LPSID pSid1, LPSID pSid2);
14 DWORD WINAPI GetSidLengthRequired (BYTE nSubAuthorityCount);
15 BOOL32 WINAPI AllocateAndInitializeSid(LPSID_IDENTIFIER_AUTHORITY pIdentifierAuthority, BYTE nSubAuthorityCount, DWORD nSubAuthority0, DWORD nSubAuthority1, DWORD nSubAuthority2, DWORD nSubAuthority3, DWORD nSubAuthority4, DWORD nSubAuthority5, DWORD nSubAuthority6, DWORD nSubAuthority7, LPSID *pSid);
16 VOID* WINAPI FreeSid(LPSID pSid);
17 BOOL32 WINAPI InitializeSid (LPSID pSid, LPSID_IDENTIFIER_AUTHORITY pIdentifierAuthority, BYTE nSubAuthorityCount);
18 LPSID_IDENTIFIER_AUTHORITY WINAPI GetSidIdentifierAuthority(LPSID pSid);
19 DWORD* WINAPI GetSidSubAuthority(LPSID pSid, DWORD nSubAuthority);
20 BYTE* WINAPI GetSidSubAuthorityCount(LPSID pSid);
21 DWORD WINAPI GetLengthSid(LPSID pSid);
22 BOOL32 WINAPI CopySid(DWORD nDestinationSidLength, LPSID pDestinationSid, LPSID pSourceSid);
24 /***********************************************************************
25 * IsValidSid (ADVAPI.80)
27 BOOL32 WINAPI IsValidSid (LPSID pSid) {
28 if (!pSid || pSid->Revision != SID_REVISION)
34 /***********************************************************************
35 * EqualSid (ADVAPI.40)
37 BOOL32 WINAPI EqualSid (LPSID pSid1, LPSID pSid2) {
38 if (!IsValidSid(pSid1) || !IsValidSid(pSid2))
41 if (*GetSidSubAuthorityCount(pSid1) != *GetSidSubAuthorityCount(pSid2))
44 if (memcmp(pSid1, pSid2, GetLengthSid(pSid1)) != 0)
50 /***********************************************************************
51 * EqualPrefixSid (ADVAPI.39)
53 BOOL32 WINAPI EqualPrefixSid (LPSID pSid1, LPSID pSid2) {
54 if (!IsValidSid(pSid1) || !IsValidSid(pSid2))
57 if (*GetSidSubAuthorityCount(pSid1) != *GetSidSubAuthorityCount(pSid2))
60 if (memcmp(pSid1, pSid2, GetSidLengthRequired(pSid1->SubAuthorityCount - 1))
67 /***********************************************************************
68 * GetSidLengthRequired (ADVAPI.63)
70 DWORD WINAPI GetSidLengthRequired (BYTE nSubAuthorityCount) {
71 return sizeof (SID) + (nSubAuthorityCount - 1 * sizeof (DWORD));
74 /***********************************************************************
75 * AllocateAndInitializeSid (ADVAPI.11)
77 BOOL32 WINAPI AllocateAndInitializeSid(LPSID_IDENTIFIER_AUTHORITY pIdentifierAuthority,
78 BYTE nSubAuthorityCount,
79 DWORD nSubAuthority0, DWORD nSubAuthority1,
80 DWORD nSubAuthority2, DWORD nSubAuthority3,
81 DWORD nSubAuthority4, DWORD nSubAuthority5,
82 DWORD nSubAuthority6, DWORD nSubAuthority7,
85 *pSid = xmalloc(GetSidLengthRequired(nSubAuthorityCount));
86 (*pSid)->Revision = SID_REVISION;
87 if (pIdentifierAuthority)
88 memcpy(&(*pSid)->IdentifierAuthority, pIdentifierAuthority,
89 sizeof (SID_IDENTIFIER_AUTHORITY));
90 *GetSidSubAuthorityCount(*pSid) = nSubAuthorityCount;
92 if (nSubAuthorityCount > 0)
93 *GetSidSubAuthority(*pSid, 0) = nSubAuthority0;
94 if (nSubAuthorityCount > 1)
95 *GetSidSubAuthority(*pSid, 1) = nSubAuthority1;
96 if (nSubAuthorityCount > 2)
97 *GetSidSubAuthority(*pSid, 2) = nSubAuthority2;
98 if (nSubAuthorityCount > 3)
99 *GetSidSubAuthority(*pSid, 3) = nSubAuthority3;
100 if (nSubAuthorityCount > 4)
101 *GetSidSubAuthority(*pSid, 4) = nSubAuthority4;
102 if (nSubAuthorityCount > 5)
103 *GetSidSubAuthority(*pSid, 5) = nSubAuthority5;
104 if (nSubAuthorityCount > 6)
105 *GetSidSubAuthority(*pSid, 6) = nSubAuthority6;
106 if (nSubAuthorityCount > 7)
107 *GetSidSubAuthority(*pSid, 7) = nSubAuthority7;
112 /***********************************************************************
113 * FreeSid (ADVAPI.42)
115 VOID* WINAPI FreeSid(LPSID pSid) {
120 /***********************************************************************
121 * InitializeSecurityDescriptor (ADVAPI.73)
123 BOOL32 WINAPI InitializeSecurityDescriptor( SECURITY_DESCRIPTOR *pDescr,
126 fprintf( stdnimp, "InitializeSecurityDescriptor: empty stub\n" );
131 /***********************************************************************
132 * InitializeSid (ADVAPI.74)
134 BOOL32 WINAPI InitializeSid (LPSID pSid, LPSID_IDENTIFIER_AUTHORITY pIdentifierAuthority,
135 BYTE nSubAuthorityCount)
139 pSid->Revision = SID_REVISION;
140 if (pIdentifierAuthority)
141 memcpy(&pSid->IdentifierAuthority, pIdentifierAuthority,
142 sizeof (SID_IDENTIFIER_AUTHORITY));
143 *GetSidSubAuthorityCount(pSid) = nSubAuthorityCount;
145 for (i = 0; i < nSubAuthorityCount; i++)
146 *GetSidSubAuthority(pSid, i) = 0;
151 /***********************************************************************
152 * GetSidIdentifierAuthority (ADVAPI.62)
154 LPSID_IDENTIFIER_AUTHORITY WINAPI GetSidIdentifierAuthority (LPSID pSid)
156 return &pSid->IdentifierAuthority;
159 /***********************************************************************
160 * GetSidSubAuthority (ADVAPI.64)
162 DWORD * WINAPI GetSidSubAuthority (LPSID pSid, DWORD nSubAuthority)
164 return &pSid->SubAuthority[nSubAuthority];
167 /***********************************************************************
168 * GetSidSubAuthorityCount (ADVAPI.65)
170 BYTE * WINAPI GetSidSubAuthorityCount (LPSID pSid)
172 return &pSid->SubAuthorityCount;
175 /***********************************************************************
176 * GetLengthSid (ADVAPI.48)
178 DWORD WINAPI GetLengthSid (LPSID pSid)
180 return GetSidLengthRequired(*GetSidSubAuthorityCount(pSid));
183 /***********************************************************************
184 * CopySid (ADVAPI.24)
186 BOOL32 WINAPI CopySid (DWORD nDestinationSidLength, LPSID pDestinationSid,
190 if (!IsValidSid(pSourceSid))
193 if (nDestinationSidLength < GetLengthSid(pSourceSid))
196 memcpy(pDestinationSid, pSourceSid, GetLengthSid(pSourceSid));