ExpressionConvertToString
NTSTATUS __stdcall ExpressionConvertToString(
_DEVPROP_FILTER_EXPRESSION *Filter,
UINT64 ExpressionStringSize,
WCHAR *ExpressionString,
UINT64 *RequiredSize){
unsigned int v4;
UINT64 v7;
WCHAR *v8;
int v9;
int v10;
WCHAR *v11;
__int64 v12;
unsigned int v13;
unsigned int v14;
int v15;
unsigned int v16;
signed int v17;
int v18;
int v19;
int v20;
int v21;
WCHAR *v22;
int v23;
int v24;
int v25;
int v26;
__int64 v27;
unsigned int v28;
unsigned int v29;
unsigned __int64 v30;
UINT64 dwFlags;
size_t pcbRemaining[2];
_NTSTRSAFE_PWSTR ppszDestEnd[2];
UINT64 RequiredSizea;
UINT64 *v36;
v36 = RequiredSize;
v4 = ExpressionStringSize;
*(_QWORD *)pcbRemaining = 0i64;
v7 = 0i64;
*(_QWORD *)ppszDestEnd = 0i64;
v8 = 0i64;
LODWORD(RequiredSizea) = 0;
if( !Filter )
return -1073741811;
if( (unsigned int)ExpressionStringSize >= 2 )
*ExpressionString = 0;
v10 = *Filter & 0xFF00000;
if( v10 )
{
switch( v10 )
{
case 1048576:
v11 = (WCHAR *)L"AND(";
break;
case 2097152:
goto LABEL_12;
case 3145728:
v11 = L"OR(";
break;
case 4194304:
LABEL_12:
v11 = (WCHAR *)L")";
break;
case 5242880:
v11 = L"NOT(";
break;
case 6291456:
goto LABEL_12;
default:
return -1073741811;
}
v12 = -1i64;
do
++v12;
while( v11[v12] );
v13 = 2 * v12 + 2;
if( RequiredSize )
*(_DWORD *)RequiredSize = v13;
if( v13 > (unsigned int)ExpressionStringSize )
return -1073741789;
else
return RtlStringCbCopyW(ExpressionString, (unsigned int)ExpressionStringSize, v11);
}
v14 = 6;
if( (unsigned int)ExpressionStringSize >= 6 )
{
LODWORD(dwFlags) = 1024;
v9 = RtlStringCbCopyExW(
ExpressionString,
(unsigned int)ExpressionStringSize,
(WCHAR *)L"[{",
(WCHAR **)ppszDestEnd,
(UINT64 *)pcbRemaining,
dwFlags);
if( v9 < 0 )
return v9;
v7 = *(_QWORD *)pcbRemaining;
v8 = *(WCHAR **)ppszDestEnd;
}
v15 = *Filter & 0xF0000;
if( (*Filter & 0x10000) != 0 )
{
v15 = *Filter & 0xE0000;
v14 = 16;
if( v4 >= 0x10 )
{
LODWORD(dwFlags) = 1024;
v9 = RtlStringCbCopyExW(v8, v7, (WCHAR *)L"(NOT)", (WCHAR **)ppszDestEnd, (UINT64 *)pcbRemaining, dwFlags);
if( v9 < 0 )
return v9;
v7 = *(_QWORD *)pcbRemaining;
v8 = *(WCHAR **)ppszDestEnd;
}
}
if( (v15 & 0x20000) != 0 )
{
v15 &= ~0x20000u;
v14 += 26;
if( v14 <= v4 )
{
LODWORD(dwFlags) = 1024;
v9 = RtlStringCbCopyExW(v8, v7, (WCHAR *)L"(IGNORE_CASE)", (WCHAR **)ppszDestEnd, (UINT64 *)pcbRemaining, dwFlags);
if( v9 < 0 )
return v9;
v7 = *(_QWORD *)pcbRemaining;
v8 = *(WCHAR **)ppszDestEnd;
}
}
if( v15 )
return -1073741811;
v16 = v14 + 2;
if( v16 <= v4 )
{
LODWORD(dwFlags) = 1024;
v9 = RtlStringCbCopyExW(v8, v7, (WCHAR *)L"}", (WCHAR **)ppszDestEnd, (UINT64 *)pcbRemaining, dwFlags);
if( v9 < 0 )
return v9;
v7 = *(_QWORD *)pcbRemaining;
v8 = *(WCHAR **)ppszDestEnd;
}
v17 = *Filter & 0xF000FFFF;
if( v17 > 4096 )
{
if( v17 != 0x10000000 )
return -1073741811;
v22 = (WCHAR *)L"(array_contains)";
}
else if( v17 == 4096 )
{
v22 = L"(list_contains)";
}
else if( v17 > 6 )
{
v23 = v17 - 7;
if( v23 )
{
v24 = v23 - 1;
if( v24 )
{
v25 = v24 - 1;
if( v25 )
{
v26 = v25 - 1;
if( v26 )
{
if( v26 != 1 )
return -1073741811;
v22 = L"(contains)";
}
else
{
v22 = L"(ends_with)";
}
}
else
{
v22 = L"(begins_with)";
}
}
else
{
v22 = L"(|)";
}
}
else
{
v22 = L"(&)";
}
}
else if( v17 == 6 )
{
v22 = L"(<=)";
}
else
{
v18 = v17 - 1;
if( v18 )
{
v19 = v18 - 1;
if( v19 )
{
v20 = v19 - 1;
if( v20 )
{
v21 = v20 - 1;
if( v21 )
{
if( v21 != 1 )
return -1073741811;
v22 = L"(>=)";
}
else
{
v22 = L"(<)";
}
}
else
{
v22 = L"(>)";
}
}
else
{
v22 = L"(==)";
}
}
else
{
v22 = L"(Exists)";
}
}
v27 = -1i64;
do
++v27;
while( v22[v27] );
v28 = v16 + 2 * v27;
if( v28 <= v4 )
{
LODWORD(dwFlags) = 1024;
v9 = RtlStringCbCopyExW(v8, v7, v22, (WCHAR **)ppszDestEnd, (UINT64 *)pcbRemaining, dwFlags);
if( v9 < 0 )
return v9;
v7 = *(_QWORD *)pcbRemaining;
v8 = *(WCHAR **)ppszDestEnd;
}
v9 = ConvertDevpropertyToString((const _DEVPROPERTY *)(Filter + 2), (unsigned int)v7, v8, &RequiredSizea);
if( (int)(v9 + 0x80000000) < 0 || v9 == -1073741789 )
{
v9 = 0;
v29 = RequiredSizea + v28;
v30 = (unsigned int)RequiredSizea - 2i64;
if( v7 >= v30 )
{
v7 += 2i64 - (unsigned int)RequiredSizea;
v8 += v30 >> 1;
}
if( v29 > v4
|| (LODWORD(dwFlags) = 1024,
v9 = RtlStringCbCopyExW(v8, v7, (WCHAR *)L"]", (WCHAR **)ppszDestEnd, (UINT64 *)pcbRemaining, dwFlags),
v9 >= 0) )
{
if( v36 )
*(_DWORD *)v36 = v29;
if( v29 > v4 )
return -1073741789;
}
}
return v9;
}Referenced by:
FilterConvertToString