10 BOOL32 WINAPI
IsValidSid (LPSID pSid
);
11 BOOL32 WINAPI
EqualSid (LPSID pSid1
, LPSID pSid2
);
12 BOOL32 WINAPI
EqualPrefixSid (LPSID pSid1
, LPSID pSid2
);
13 DWORD WINAPI
GetSidLengthRequired (BYTE nSubAuthorityCount
);
14 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
);
15 VOID
* WINAPI
FreeSid(LPSID pSid
);
16 BOOL32 WINAPI
InitializeSid (LPSID pSid
, LPSID_IDENTIFIER_AUTHORITY pIdentifierAuthority
, BYTE nSubAuthorityCount
);
17 LPSID_IDENTIFIER_AUTHORITY WINAPI
GetSidIdentifierAuthority(LPSID pSid
);
18 DWORD
* WINAPI
GetSidSubAuthority(LPSID pSid
, DWORD nSubAuthority
);
19 BYTE
* WINAPI
GetSidSubAuthorityCount(LPSID pSid
);
20 DWORD WINAPI
GetLengthSid(LPSID pSid
);
21 BOOL32 WINAPI
CopySid(DWORD nDestinationSidLength
, LPSID pDestinationSid
, LPSID pSourceSid
);
23 /***********************************************************************
24 * IsValidSid (ADVAPI.80)
26 BOOL32 WINAPI
IsValidSid (LPSID pSid
) {
27 if (!pSid
|| pSid
->Revision
!= SID_REVISION
)
33 /***********************************************************************
34 * EqualSid (ADVAPI.40)
36 BOOL32 WINAPI
EqualSid (LPSID pSid1
, LPSID pSid2
) {
37 if (!IsValidSid(pSid1
) || !IsValidSid(pSid2
))
40 if (*GetSidSubAuthorityCount(pSid1
) != *GetSidSubAuthorityCount(pSid2
))
43 if (memcmp(pSid1
, pSid2
, GetLengthSid(pSid1
)) != 0)
49 /***********************************************************************
50 * EqualPrefixSid (ADVAPI.39)
52 BOOL32 WINAPI
EqualPrefixSid (LPSID pSid1
, LPSID pSid2
) {
53 if (!IsValidSid(pSid1
) || !IsValidSid(pSid2
))
56 if (*GetSidSubAuthorityCount(pSid1
) != *GetSidSubAuthorityCount(pSid2
))
59 if (memcmp(pSid1
, pSid2
, GetSidLengthRequired(pSid1
->SubAuthorityCount
- 1))
66 /***********************************************************************
67 * GetSidLengthRequired (ADVAPI.63)
69 DWORD WINAPI
GetSidLengthRequired (BYTE nSubAuthorityCount
) {
70 return sizeof (SID
) + (nSubAuthorityCount
- 1 * sizeof (DWORD
));
73 /***********************************************************************
74 * AllocateAndInitializeSid (ADVAPI.11)
76 BOOL32 WINAPI
AllocateAndInitializeSid(LPSID_IDENTIFIER_AUTHORITY pIdentifierAuthority
,
77 BYTE nSubAuthorityCount
,
78 DWORD nSubAuthority0
, DWORD nSubAuthority1
,
79 DWORD nSubAuthority2
, DWORD nSubAuthority3
,
80 DWORD nSubAuthority4
, DWORD nSubAuthority5
,
81 DWORD nSubAuthority6
, DWORD nSubAuthority7
,
84 if (!(*pSid
= HeapAlloc( GetProcessHeap(), 0,
85 GetSidLengthRequired(nSubAuthorityCount
))))
87 (*pSid
)->Revision
= SID_REVISION
;
88 if (pIdentifierAuthority
)
89 memcpy(&(*pSid
)->IdentifierAuthority
, pIdentifierAuthority
,
90 sizeof (SID_IDENTIFIER_AUTHORITY
));
91 *GetSidSubAuthorityCount(*pSid
) = nSubAuthorityCount
;
93 if (nSubAuthorityCount
> 0)
94 *GetSidSubAuthority(*pSid
, 0) = nSubAuthority0
;
95 if (nSubAuthorityCount
> 1)
96 *GetSidSubAuthority(*pSid
, 1) = nSubAuthority1
;
97 if (nSubAuthorityCount
> 2)
98 *GetSidSubAuthority(*pSid
, 2) = nSubAuthority2
;
99 if (nSubAuthorityCount
> 3)
100 *GetSidSubAuthority(*pSid
, 3) = nSubAuthority3
;
101 if (nSubAuthorityCount
> 4)
102 *GetSidSubAuthority(*pSid
, 4) = nSubAuthority4
;
103 if (nSubAuthorityCount
> 5)
104 *GetSidSubAuthority(*pSid
, 5) = nSubAuthority5
;
105 if (nSubAuthorityCount
> 6)
106 *GetSidSubAuthority(*pSid
, 6) = nSubAuthority6
;
107 if (nSubAuthorityCount
> 7)
108 *GetSidSubAuthority(*pSid
, 7) = nSubAuthority7
;
113 /***********************************************************************
114 * FreeSid (ADVAPI.42)
116 VOID
* WINAPI
FreeSid(LPSID pSid
)
118 HeapFree( GetProcessHeap(), 0, pSid
);
122 /***********************************************************************
123 * InitializeSecurityDescriptor (ADVAPI.73)
125 BOOL32 WINAPI
InitializeSecurityDescriptor( SECURITY_DESCRIPTOR
*pDescr
,
128 fprintf( stdnimp
, "InitializeSecurityDescriptor: empty stub\n" );
133 /***********************************************************************
134 * InitializeSid (ADVAPI.74)
136 BOOL32 WINAPI
InitializeSid (LPSID pSid
, LPSID_IDENTIFIER_AUTHORITY pIdentifierAuthority
,
137 BYTE nSubAuthorityCount
)
141 pSid
->Revision
= SID_REVISION
;
142 if (pIdentifierAuthority
)
143 memcpy(&pSid
->IdentifierAuthority
, pIdentifierAuthority
,
144 sizeof (SID_IDENTIFIER_AUTHORITY
));
145 *GetSidSubAuthorityCount(pSid
) = nSubAuthorityCount
;
147 for (i
= 0; i
< nSubAuthorityCount
; i
++)
148 *GetSidSubAuthority(pSid
, i
) = 0;
153 /***********************************************************************
154 * GetSidIdentifierAuthority (ADVAPI.62)
156 LPSID_IDENTIFIER_AUTHORITY WINAPI
GetSidIdentifierAuthority (LPSID pSid
)
158 return &pSid
->IdentifierAuthority
;
161 /***********************************************************************
162 * GetSidSubAuthority (ADVAPI.64)
164 DWORD
* WINAPI
GetSidSubAuthority (LPSID pSid
, DWORD nSubAuthority
)
166 return &pSid
->SubAuthority
[nSubAuthority
];
169 /***********************************************************************
170 * GetSidSubAuthorityCount (ADVAPI.65)
172 BYTE
* WINAPI
GetSidSubAuthorityCount (LPSID pSid
)
174 return &pSid
->SubAuthorityCount
;
177 /***********************************************************************
178 * GetLengthSid (ADVAPI.48)
180 DWORD WINAPI
GetLengthSid (LPSID pSid
)
182 return GetSidLengthRequired(*GetSidSubAuthorityCount(pSid
));
185 /***********************************************************************
186 * CopySid (ADVAPI.24)
188 BOOL32 WINAPI
CopySid (DWORD nDestinationSidLength
, LPSID pDestinationSid
,
192 if (!IsValidSid(pSourceSid
))
195 if (nDestinationSidLength
< GetLengthSid(pSourceSid
))
198 memcpy(pDestinationSid
, pSourceSid
, GetLengthSid(pSourceSid
));