LocalpConvertStringSidToSid
NTSTATUS __stdcall LocalpConvertStringSidToSid(WCHAR *StringSid, VOID **Sid, WCHAR **End){
NTSTATUS v4;
unsigned int v5;
WCHAR *v6;
WCHAR *v7;
WORD *v8;
INT64 v9;
__int64 v10;
UINT64 v11;
UINT64 v12;
WCHAR *v13;
unsigned __int8 v14;
WCHAR *v15;
unsigned __int64 v16;
WCHAR *v17;
bool v18;
bool v19;
unsigned __int8 v20;
WCHAR *v21;
VOID *v22;
unsigned int v23;
_DWORD *v24;
INT64 v25;
unsigned __int64 v26;
char *v27;
VOID *v28;
WCHAR *v30;
__int64 v31;
__int64 v32;
void *v33;
int v34;
INT64 flags;
INT64 v36;
int v37;
__int16 v38;
WCHAR *endptr;
unsigned int v40;
INT64 error;
VOID *Src;
PVOID P;
VOID **v44;
char v45;
v44 = Sid;
Src = 0i64;
endptr = 0i64;
P = 0i64;
v4 = 0;
v5 = 10;
v40 = 10;
if( !StringSid || !Sid || !End )
return -1073741811;
if( ((*StringSid - 83) & 0xFFDF) != 0 || StringSid[1] != 45 )
return -1073741704;
v6 = StringSid + 2;
if( StringSid[2] == 48 )
{
if( ((StringSid[3] - 88) & 0xFFDF) == 0 )
v5 = 16;
v40 = v5;
}
HIDWORD(error) = wcstoul(v6, &endptr, v5);
if( HIDWORD(error) > 0xFF )
return -1073741704;
if( endptr == v6 )
return -1073741704;
if( *endptr != 45 )
return -1073741704;
v7 = endptr + 1;
if( !endptr[1] )
return -1073741704;
v8 = wcschr(endptr + 1, 45);
if( !v8 || v8 == v7 )
return -1073741704;
if( *v7 != 48 || (v9 = 16i64, ((v7[1] - 88) & 0xFFDF) != 0) )
v9 = v5;
LODWORD(error) = 0;
LODWORD(flags) = 1;
v11 = wcstoxq(0i64, v7, &endptr, v9, flags, &error, v36, (INT64)endptr);
if( v11 > 0xFFFFFFFFFFFFi64 )
return -1073741704;
v13 = endptr;
if( endptr == v7 || *endptr != 45 || !endptr[1] )
return -1073741704;
HIBYTE(v38) = v11;
v14 = 0;
LOBYTE(v38) = BYTE1(v11);
v15 = endptr;
HIBYTE(v37) = BYTE2(v11);
BYTE2(v37) = BYTE3(v11);
LOBYTE(v37) = BYTE5(v11);
BYTE1(v37) = BYTE4(v11);
while( 1 )
{
if( v14 == 0xFF )
{
v4 = -1073741675;
goto LABEL_86;
}
v16 = *v15;
if( (_WORD)v16 != 45 )
break;
if( *(v15 - 1) != 45 )
{
++v14;
if( v15[1] == 48 && ((v15[2] - 88) & 0xFFDF) == 0 )
v15 += 2;
goto LABEL_28;
}
LABEL_24:
LOWORD(v10) = v15[1];
if( (_WORD)v10 == 58 )
{
v12 = 65523i64;
if( (((_WORD)v16 - 71) & 0xFFF3) == 0 && (_DWORD)v16 != 75 )
goto LABEL_34;
}
if( (unsigned __int16)(v16 - 48) > 0x36u
|| (v12 = 0x7E0000007E03FFi64, !_bittest64((const __int64 *)&v12, (unsigned int)(v16 - 48))) )
{
v4 = -1073741704;
LABEL_86:
*End = v15;
return v4;
}
if( (_DWORD)v16 == 68 && (_WORD)v10 == 58 )
{
v30 = endptr;
v31 = v15 - endptr;
v32 = 2 * v31;
if( v31 >= 256 )
{
v33 = SddlpAlloc(v32 + 2, 0x3Au, 0x7E0000007E03FFui64);
P = v33;
if( !v33 )
return -1073741801;
v13 = (WCHAR *)v33;
}
else
{
v13 = (WCHAR *)&v45;
}
memmove(v13, v30, v32);
v5 = v40;
v13[(unsigned __int64)v32 / 2] = 0;
++v14;
*End = v15;
goto LABEL_41;
}
LABEL_28:
if( !++v15 )
goto LABEL_40;
}
if( (unsigned int)v16 > 0x3B )
goto LABEL_24;
v10 = 0x800120100000001i64;
if( !_bittest64(&v10, v16) )
goto LABEL_24;
LABEL_34:
v17 = v15 - 1;
v4 = -1073741704;
v18 = *(v15 - 1) == 45;
if( *(v15 - 1) != 45 )
v17 = v15;
if( *(v15 - 1) != 45 )
v4 = 0;
*End = v17;
if( !v18 )
++v14;
LABEL_40:
v19 = v4 < 0;
if( !v4 )
{
LABEL_41:
v20 = v14 - 1;
if( !v14 )
v20 = 0;
if( !v20 )
goto LABEL_82;
v21 = v13 + 1;
v22 = SddlpAlloc(4i64 * v20, v10, v12);
Src = v22;
if( v22 )
{
v23 = 0;
v24 = v22;
while( 1 )
{
if( *v21 != 48 || (v25 = 16i64, ((v21[1] - 88) & 0xFFDF) != 0) )
v25 = v5;
*v24 = wcstoul(v21, &endptr, v25);
if( endptr )
{
v26 = *endptr;
if( (unsigned int)v26 > 0x3B || (v10 = 0x800320000000001i64, !_bittest64(&v10, v26)) )
{
if( endptr[1] != 58 )
break;
LOWORD(v26) = v26 - 68;
if( (unsigned __int16)v26 > 0xFu )
break;
v34 = 34825;
if( !_bittest(&v34, v26) )
break;
}
}
v21 = endptr + 1;
++v23;
++v24;
if( v23 >= v20 )
goto LABEL_52;
}
LABEL_82:
v4 = -1073741704;
}
else
{
v4 = -1073741801;
}
LABEL_52:
v14 = v20;
v19 = v4 < 0;
}
if( !v19 )
{
v27 = (char *)SddlpAlloc(4i64 * v14 + 12, v10, v12);
*v44 = v27;
if( v27 )
{
v28 = Src;
*v27 = BYTE4(error);
*(_DWORD *)(v27 + 2) = v37;
*((_WORD *)v27 + 3) = v38;
v27[1] = v14;
memmove(v27 + 8, v28, 4 * v14);
}
else
{
v4 = -1073741801;
}
}
if( Src )
ExFreePoolWithTag(Src, 0);
if( P )
ExFreePoolWithTag(P, 0);
return v4;
}Referenced by:
LocalGetSidForString
SeConvertStringSidToSid