ADVAPI32: implement ConvertSidToStringSidA/W
Mike McCormack
mike at codeweavers.com
Sat Aug 7 00:22:33 CDT 2004
ChangeLog:
* implement ConvertSidToStringSidA/W
-------------- next part --------------
Index: dlls/advapi32/security.c
===================================================================
RCS file: /home/wine/wine/dlls/advapi32/security.c,v
retrieving revision 1.70
diff -u -r1.70 security.c
--- dlls/advapi32/security.c 6 Aug 2004 17:31:17 -0000 1.70
+++ dlls/advapi32/security.c 7 Aug 2004 04:02:46 -0000
@@ -2083,6 +2083,72 @@
}
/******************************************************************************
+ * ConvertSidToStringSidW [ADVAPI32.@]
+ *
+ * format of SID string is:
+ * S-<count>-<auth>-<subauth1>-<subauth2>-<subauth3>...
+ * where
+ * <rev> is the revision of the SID encoded as decimal
+ * <auth> is the identifier authority encoded as hex
+ * <subauthN> is the subauthority id encoded as decimal
+ */
+BOOL WINAPI ConvertSidToStringSidW( PSID pSid, LPWSTR *pstr )
+{
+ DWORD sz, i;
+ LPWSTR str;
+ WCHAR fmt[] = {
+ 'S','-','%','u','-','%','2','X','%','2','X','%','X','%','X','%','X','%','X',0 };
+ WCHAR subauthfmt[] = { '-','%','u',0 };
+
+ TRACE("%p %p\n", pSid, pstr );
+
+ if( !IsValidSid( pSid ) )
+ return FALSE;
+
+ if (pSid->Revision != SDDL_REVISION)
+ return FALSE;
+
+ sz = 14 + pSid->SubAuthorityCount * 11;
+ str = LocalAlloc( 0, sz*sizeof(WCHAR) );
+ sprintfW( str, fmt, pSid->Revision,
+ pSid->IdentifierAuthority.Value[2],
+ pSid->IdentifierAuthority.Value[3],
+ pSid->IdentifierAuthority.Value[0]&0x0f,
+ pSid->IdentifierAuthority.Value[4]&0x0f,
+ pSid->IdentifierAuthority.Value[1]&0x0f,
+ pSid->IdentifierAuthority.Value[5]&0x0f);
+ for( i=0; i<pSid->SubAuthorityCount; i++ )
+ sprintfW( str + strlenW(str), subauthfmt, pSid->SubAuthority[i] );
+ *pstr = str;
+
+ return TRUE;
+}
+
+/******************************************************************************
+ * ConvertSidToStringSidA [ADVAPI32.@]
+ */
+BOOL WINAPI ConvertSidToStringSidA(PSID pSid, LPSTR *pstr)
+{
+ LPWSTR wstr = NULL;
+ LPSTR str;
+ UINT len;
+
+ TRACE("%p %p\n", pSid, pstr );
+
+ if( !ConvertSidToStringSidW( pSid, &wstr ) )
+ return FALSE;
+
+ len = WideCharToMultiByte( CP_ACP, 0, wstr, -1, NULL, 0, NULL, NULL );
+ str = LocalAlloc( 0, len );
+ WideCharToMultiByte( CP_ACP, 0, wstr, -1, str, len, NULL, NULL );
+ LocalFree( wstr );
+
+ *pstr = str;
+
+ return TRUE;
+}
+
+/******************************************************************************
* ComputeStringSidSize
*/
static DWORD ComputeStringSidSize(LPCWSTR StringSid)
Index: dlls/advapi32/advapi32.spec
===================================================================
RCS file: /home/wine/wine/dlls/advapi32/advapi32.spec,v
retrieving revision 1.50
diff -u -r1.50 advapi32.spec
--- dlls/advapi32/advapi32.spec 25 May 2004 00:22:42 -0000 1.50
+++ dlls/advapi32/advapi32.spec 7 Aug 2004 04:02:46 -0000
@@ -28,8 +28,8 @@
@ stdcall CloseServiceHandle(long)
@ stdcall CommandLineFromMsiDescriptor(wstr wstr ptr)
@ stdcall ControlService(long long ptr)
-@ stub ConvertSidToStringSidA #(ptr str) ConvertSidToStringSidA
-@ stub ConvertSidToStringSidW #(ptr wstr) ConvertSidToStringSidW
+@ stdcall ConvertSidToStringSidA(ptr str) ConvertSidToStringSidA
+@ stdcall ConvertSidToStringSidW(ptr wstr) ConvertSidToStringSidW
@ stub ConvertStringSecurityDescriptorToSecurityDescriptorA #(str long ptr ptr) ConvertStringSecurityDescriptorToSecurityDescriptorA
@ stdcall ConvertStringSecurityDescriptorToSecurityDescriptorW(wstr long ptr ptr)
@ stdcall CopySid(long ptr ptr)
More information about the wine-patches
mailing list