LocalConvertStringSDToSD_Rev1
NTSTATUS __stdcall LocalConvertStringSDToSD_Rev1(VOID **SecurityDescriptor){
__int64 v1;
WCHAR *v2;
WCHAR *v3;
NTSTATUS SDControlForString;
VOID *v5;
VOID *v6;
UINT8 v7;
PVOID *v8;
unsigned int *v9;
WCHAR v10;
WCHAR *v11;
NTSTATUS v12;
NTSTATUS v13;
UINT8 v14;
UINT64 v15;
VOID *v16;
NTSTATUS v17;
NTSTATUS SidForString;
NTSTATUS v20;
NTSTATUS v21;
WCHAR *v22;
NTSTATUS v23;
NTSTATUS v24;
NTSTATUS v25;
VOID *v26;
UINT8 v27;
WCHAR *End;
__int16 pControl[2];
unsigned int BufferLength;
_ACL *Acl;
_ACL *Sacl;
VOID *v33;
VOID *SID;
__int128 SecurityDescriptora[2];
__int64 v36;
VOID **FreeSid;
__int64 v38;
UINT8 SaclPresent;
UINT16 v40;
PVOID *v41;
unsigned int *v42;
v38 = v1;
FreeSid = SecurityDescriptor;
v33 = 0i64;
SID = 0i64;
v3 = v2;
Acl = 0i64;
SDControlForString = 0;
Sacl = 0i64;
v5 = 0i64;
v36 = 0i64;
v6 = 0i64;
End = 0i64;
v7 = 0;
LOBYTE(v38) = 0;
LOBYTE(FreeSid) = 0;
BufferLength = 0;
SaclPresent = 0;
pControl[0] = 0;
v40 = 0;
memset(SecurityDescriptora, 0, sizeof(SecurityDescriptora));
if( !v2 )
return 87;
v8 = v41;
if( !v41 )
return 87;
v9 = v42;
if( v42 )
*v42 = 0;
while( v3 )
{
v10 = *v3;
if( *v3 )
{
switch( v10 )
{
case 'D':
if( v3[1] != 58 )
goto LABEL_60;
v11 = v3 + 2;
if( Acl )
goto LABEL_60;
if( *v11 != 40 )
{
SDControlForString = LocalGetSDControlForString(v11, 1ui64, (UINT16 *)pControl, &End);
if( SDControlForString )
goto LABEL_29;
v11 = End;
}
v27 = 0;
v26 = 0i64;
SDControlForString = LocalGetAclForString(v11, 1u, &Acl, &End);
if( SDControlForString )
goto LABEL_29;
v3 = End;
v7 = 1;
break;
case 'G':
SDControlForString = 87;
if( v3[1] != 58 || v6 )
goto LABEL_29;
SidForString = LocalGetSidForString(v3 + 2, &SID, &End, (UINT8 *)&FreeSid, v26, v27);
v6 = SID;
goto LABEL_40;
case 'O':
SDControlForString = 87;
if( v3[1] != 58 || v5 )
goto LABEL_29;
SidForString = LocalGetSidForString(v3 + 2, &v33, &End, (UINT8 *)&v38, v26, v27);
v5 = v33;
LABEL_40:
SDControlForString = SidForString;
if( SidForString )
goto LABEL_29;
v3 = End;
break;
case ' ':
++v3;
break;
default:
if( v10 != 83 || v3[1] != 58 || (v22 = v3 + 2, Sacl) )
{
LABEL_60:
SDControlForString = 87;
goto LABEL_29;
}
if( *v22 != 40 )
{
SDControlForString = LocalGetSDControlForString(v22, 2ui64, &v40, &End);
if( SDControlForString )
goto LABEL_29;
v22 = End;
}
v27 = 0;
v26 = 0i64;
SDControlForString = LocalGetAclForString(v22, 0, &Sacl, &End);
if( SDControlForString )
goto LABEL_29;
v3 = End;
SaclPresent = 1;
break;
}
}
else
{
v3 = 0i64;
}
}
v12 = RtlCreateSecurityDescriptor(SecurityDescriptora, 1ui64);
if( v12 < 0 )
SDControlForString = RtlNtStatusToDosError((unsigned int)v12);
WORD1(SecurityDescriptora[0]) |= pControl[0] | v40;
if( !SDControlForString )
{
if( !v5
|| (v20 = RtlSetOwnerSecurityDescriptor(SecurityDescriptora, v5, 0), v20 >= 0)
|| (v23 = RtlNtStatusToDosError((unsigned int)v20), (SDControlForString = v23) == 0) )
{
if( !v6
|| (v21 = RtlSetGroupSecurityDescriptor(SecurityDescriptora, v6, 0), v21 >= 0)
|| (v24 = RtlNtStatusToDosError((unsigned int)v21), (SDControlForString = v24) == 0) )
{
if( !v7
|| (v13 = RtlSetDaclSecurityDescriptor(SecurityDescriptora, v7, Acl, 0), v13 >= 0)
|| (SDControlForString = RtlNtStatusToDosError((unsigned int)v13)) == 0 )
{
if( !SaclPresent
|| (v25 = RtlSetSaclSecurityDescriptor(SecurityDescriptora, SaclPresent, Sacl, 0), v25 >= 0)
|| (SDControlForString = RtlNtStatusToDosError((unsigned int)v25)) == 0 )
{
if( RtlAbsoluteToSelfRelativeSD(SecurityDescriptora, *v8, (UINT64 *)&BufferLength) == -1073741789 )
{
SDControlForString = 0;
v16 = SddlpAlloc(BufferLength, v14, v15);
*v8 = v16;
if( !v16 )
{
SDControlForString = 8;
goto LABEL_29;
}
v17 = RtlAbsoluteToSelfRelativeSD(SecurityDescriptora, v16, (UINT64 *)&BufferLength);
if( v17 >= 0 )
{
LABEL_27:
if( v9 )
*v9 = BufferLength;
goto LABEL_29;
}
SDControlForString = RtlNtStatusToDosError((unsigned int)v17);
if( *v8 )
ExFreePoolWithTag(*v8, 0);
*v8 = 0i64;
}
else
{
SDControlForString = 122;
}
if( !SDControlForString )
goto LABEL_27;
}
}
}
}
}
LABEL_29:
if( (_BYTE)v38 == 1 && v5 )
ExFreePoolWithTag(v5, 0);
if( (_BYTE)FreeSid == 1 && v6 )
ExFreePoolWithTag(v6, 0);
if( Acl )
ExFreePoolWithTag(Acl, 0);
if( Sacl )
ExFreePoolWithTag(Sacl, 0);
return SDControlForString;
}Referenced by:
SeConvertStringSecurityDescriptorToSecurityDescriptor