ApiSetComposeSchema
__int64 __fastcall ApiSetComposeSchema(UINT8 **a1, unsigned int *a2, _DWORD *a3, int a4){
UINT8 *v4;
unsigned int v6;
int v7;
int v8;
__int64 v9;
__int64 v10;
_DWORD *v11;
unsigned int v12;
__int64 v13;
char v14;
__int64 v15;
__int64 v16;
__int64 v17;
unsigned int v18;
WCHAR *v19;
_WORD *v20;
UINT16 v21;
CHAR *v22;
int v23;
int v24;
UINT8 *PoolWithTag;
unsigned int v26;
__int64 v27;
__int64 v28;
unsigned int v29;
int v30;
int v31;
unsigned int v32;
__int64 i;
UINT8 *v34;
int v35;
int v36;
__int64 j;
UINT8 *v38;
int v39;
int v40;
unsigned int v41;
__int64 v42;
unsigned int v43;
__int64 v44;
char *v45;
unsigned int v46;
__int64 v47;
UINT8 *v48;
__int64 v49;
__int64 v50;
__int64 v51;
__int64 v52;
char *v53;
__int64 v54;
WCHAR *v55;
_WORD *v56;
CHAR *v57;
__int64 v58;
int v59;
int v60;
UINT8 *v61;
UINT8 *v62;
unsigned int v64;
int v65;
unsigned int a2a;
unsigned int a2b;
int a2_4;
unsigned int a2_4a;
int a2_4b;
unsigned int v71;
unsigned int v72;
int v73;
__int64 v74;
int v75;
__int64 v76;
int v77;
__int64 v78;
char *v79;
WCHAR *v80;
char *v81;
char *v82;
__int64 v83;
int v84;
int v85;
unsigned int v86;
__int128 v87;
int v88;
UINT64 v91;
LODWORD(v91) = a4;
v4 = *a1;
if( *(_DWORD *)*a1 < 5u || *a3 < 5u )
return 3221225659i64;
if( (*((_DWORD *)v4 + 2) & 1) != 0 )
return 3221225485i64;
if( !*((_DWORD *)v4 + 3) )
return 3221225485i64;
v6 = a3[3];
a2a = v6;
if( !v6 )
return 3221225485i64;
v64 = 0;
v7 = 0;
v8 = ApiSetValidateSchemaFormat(v4, *((unsigned int *)v4 + 1));
if( v8 < 0 )
return(unsigned int)v8;
v8 = ApiSetValidateSchemaFormat(a3, (unsigned int)a3[1]);
if( v8 < 0 )
return(unsigned int)v8;
v9 = 0i64;
v10 = (unsigned int)a3[4];
v74 = v10;
while( 1 )
{
v11 = (_DWORD *)((char *)&a3[6 * v9] + v10);
if( (*v11 & 4) == 0 )
break;
++v64;
v7 += (v11[2] + 3) & 0xFFFFFFFC;
LABEL_29:
v9 = (unsigned int)(v9 + 1);
if( (unsigned int)v9 >= v6 )
{
v24 = 24 * v64;
a2_4a = v7 + 24 * v64 + *((_DWORD *)v4 + 1) + 8 * v64;
PoolWithTag = (UINT8 *)ExAllocatePoolWithTag(PagedPool, a2_4a, 0x68635341ui64);
if( PoolWithTag )
{
v26 = *((_DWORD *)v4 + 4) + 24 * *((_DWORD *)v4 + 3);
v27 = v26;
memmove(PoolWithTag, v4, v26);
v28 = v24 + v26;
v29 = *((_DWORD *)v4 + 5) - v26;
v30 = v29 + v28;
v65 = v29 + v28;
LODWORD(v91) = v29 + v28;
memmove(&PoolWithTag[v28], &v4[v27], v29);
memset((INT64)&PoolWithTag[v30], 0i64);
v31 = v7 + v30;
memmove(&PoolWithTag[v31], &v4[*((unsigned int *)v4 + 5)], (unsigned int)(8 * *((_DWORD *)v4 + 3)));
v32 = a2_4a;
*((_DWORD *)PoolWithTag + 1) = a2_4a;
*((_DWORD *)PoolWithTag + 5) = v31;
if( v24 )
{
for( i = 0i64; (unsigned int)i < *((_DWORD *)PoolWithTag + 3); i = (unsigned int)(i + 1) )
{
v34 = &PoolWithTag[*((unsigned int *)PoolWithTag + 4)];
v35 = *(_DWORD *)&v34[24 * i + 4];
if( v35 )
*(_DWORD *)&v34[24 * i + 4] = v24 + v35;
v36 = *(_DWORD *)&v34[24 * i + 16];
if( v36 )
*(_DWORD *)&v34[24 * i + 16] = v24 + v36;
for( j = 0i64; (unsigned int)j < *(_DWORD *)&v34[24 * i + 20]; j = (unsigned int)(j + 1) )
{
v38 = &PoolWithTag[*(unsigned int *)&v34[24 * i + 16]];
v39 = *(_DWORD *)&v38[20 * j + 4];
if( v39 )
*(_DWORD *)&v38[20 * j + 4] = v24 + v39;
v40 = *(_DWORD *)&v38[20 * j + 12];
if( v40 )
*(_DWORD *)&v38[20 * j + 12] = v24 + v40;
}
}
}
v8 = ApiSetValidateSchemaFormat(PoolWithTag, a2_4a);
if( v8 < 0 )
goto LABEL_83;
v41 = 0;
v42 = 0i64;
v71 = 0;
a2_4b = 0;
if( a3[3] )
{
v43 = v64;
do
{
v44 = 3 * v42;
v45 = (char *)a3 + (unsigned int)a3[4];
v82 = v45;
v46 = *(_DWORD *)&v45[24 * v42 + 8];
v47 = *(unsigned int *)&v45[24 * v42 + 4];
a2b = v46;
if( (*(_DWORD *)&v45[24 * v42] & 4) != 0 )
{
if( v41 >= v43 )
{
LABEL_86:
v8 = -2147483643;
goto LABEL_83;
}
v48 = &PoolWithTag[*((unsigned int *)PoolWithTag + 4)];
v71 = v41 + 1;
v49 = *((unsigned int *)PoolWithTag + 3);
v50 = 3 * v49;
*((_DWORD *)PoolWithTag + 3) = v49 + 1;
*(_OWORD *)&v48[8 * v50] = 0i64;
*(_QWORD *)&v48[8 * v50 + 16] = 0i64;
*(_DWORD *)&v48[8 * v50] = *(_DWORD *)&v45[24 * v42];
*(_DWORD *)&v48[8 * v50 + 4] = v65;
*(_DWORD *)&v48[8 * v50 + 8] = v46;
*(_DWORD *)&v48[8 * v50 + 12] = v46;
v8 = AsiAddDataToSchema((INT64)PoolWithTag, &v91, (char *)a3 + v47, v46);
if( v8 < 0 )
goto LABEL_83;
v65 = v91;
LABEL_78:
v41 = v71;
}
else
{
v81 = (char *)a3 + v47;
v51 = 0i64;
v75 = 0;
v73 = 0;
if( *(_DWORD *)&v45[8 * v44 + 20] )
{
while( 1 )
{
v52 = 5 * v51;
v53 = (char *)a3 + *(unsigned int *)&v45[8 * v44 + 16];
v78 = 5 * v51;
v79 = v53;
v54 = *(unsigned int *)&v53[20 * v51 + 16];
v55 = (WCHAR *)((char *)a3 + *(unsigned int *)&v53[20 * v51 + 12]);
v80 = v55;
v56 = (WCHAR *)((char *)v55 + v54);
do
{
if( (unsigned int)v54 <= 1 )
break;
LODWORD(v54) = v54 - 2;
--v56;
}
while( *v56 != 45 );
if( !((unsigned __int16)v54 >> 1) )
break;
v77 = *(_DWORD *)&v53[4 * v52 + 4];
v57 = ApiSetpSearchForApiSet(PoolWithTag, v55, (unsigned __int16)v54 >> 1);
if( v57 )
{
v59 = v65;
}
else
{
if( v71 >= v64 )
goto LABEL_86;
v58 = *((unsigned int *)PoolWithTag + 3);
++v71;
v57 = (CHAR *)&PoolWithTag[24 * v58 + *((unsigned int *)PoolWithTag + 4)];
*((_DWORD *)PoolWithTag + 3) = v58 + 1;
*(_OWORD *)v57 = 0i64;
*((_QWORD *)v57 + 2) = 0i64;
*((_DWORD *)v57 + 1) = v65;
*((_DWORD *)v57 + 2) = *(_DWORD *)&v79[4 * v78 + 16];
*((_DWORD *)v57 + 3) = v54;
v8 = AsiAddDataToSchema((INT64)PoolWithTag, &v91, v80, *(unsigned int *)&v79[4 * v78 + 16]);
if( v8 < 0 )
goto LABEL_83;
*((_DWORD *)v57 + 5) = 1;
v88 = 0;
*((_DWORD *)v57 + 4) = v91;
v87 = 0i64;
v8 = AsiAddDataToSchema((INT64)PoolWithTag, &v91, &v87, 0x14ui64);
if( v8 < 0 )
goto LABEL_83;
v59 = v91;
v65 = v91;
}
if( (*(_DWORD *)v57 & 1) == 0 )
{
v60 = v75;
if( !v75 )
{
v75 = v59;
v8 = AsiAddDataToSchema((INT64)PoolWithTag, &v91, v81, a2b);
if( v8 < 0 )
goto LABEL_83;
v60 = v75;
v65 = v91;
}
if( !*((_DWORD *)v57 + 5) )
{
v8 = -1073741811;
goto LABEL_83;
}
v61 = &PoolWithTag[*((unsigned int *)v57 + 4)];
if( *((_DWORD *)v61 + 4) && v77 )
{
*((_DWORD *)v61 + 1) = v60;
*((_DWORD *)v61 + 2) = a2b;
v8 = AsiAddDataToSchema((INT64)PoolWithTag, &v91, v61, (unsigned int)(20 * *((_DWORD *)v57 + 5)));
if( v8 < 0 )
goto LABEL_83;
v83 = 0i64;
v84 = 0;
*((_DWORD *)v57 + 4) = v65;
v85 = v75;
v86 = a2b;
v8 = AsiAddDataToSchema((INT64)PoolWithTag, &v91, &v83, 0x14ui64);
if( v8 < 0 )
goto LABEL_83;
++*((_DWORD *)v57 + 5);
AsiSortValueList((INT64)PoolWithTag, (INT64)v57);
v65 = v91;
}
else
{
*((_DWORD *)v61 + 1) = 0;
*((_DWORD *)v61 + 2) = 0;
*((_DWORD *)v61 + 3) = v60;
*((_DWORD *)v61 + 4) = a2b;
*((_DWORD *)v57 + 5) = 1;
}
}
v45 = v82;
v51 = (unsigned int)(v73 + 1);
v73 = v51;
if( (unsigned int)v51 >= *(_DWORD *)&v82[8 * v44 + 20] )
{
v43 = v64;
goto LABEL_78;
}
}
v8 = -1073740670;
goto LABEL_83;
}
}
v42 = (unsigned int)(a2_4b + 1);
a2_4b = v42;
}
while( (unsigned int)v42 < a3[3] );
}
if( v64 && !(unsigned int)AsiPopulateHashes((UINT64 *)PoolWithTag) )
{
v8 = -1073741823;
goto LABEL_83;
}
v8 = ApiSetValidateSchemaFormat(PoolWithTag, v32);
if( v8 < 0 )
{
LABEL_83:
v62 = PoolWithTag;
}
else
{
v62 = v4;
*a1 = PoolWithTag;
*a2 = v32;
}
ExFreeHeapPool(v62);
}
else
{
return(unsigned int)-1073741801;
}
return(unsigned int)v8;
}
}
v12 = v11[5];
v13 = 0i64;
v14 = 0;
LODWORD(v91) = 0;
v72 = v12;
if( !v12 )
goto LABEL_29;
v15 = (unsigned int)v11[4];
v76 = v15;
while( 1 )
{
v16 = v15 + 20 * v13;
v17 = *(unsigned int *)((char *)a3 + v16 + 16);
v18 = *(_DWORD *)((char *)a3 + v16 + 16);
v19 = (WCHAR *)((char *)a3 + *(unsigned int *)((char *)a3 + v16 + 12));
v20 = (WCHAR *)((char *)v19 + v17);
if( (unsigned int)v17 > 1 )
{
do
{
v18 -= 2;
--v20;
}
while( *v20 != 45 && v18 > 1 );
}
v21 = (unsigned __int16)v18 >> 1;
if( !v21 )
break;
a2_4 = *(_DWORD *)((char *)a3 + v16 + 4);
v22 = ApiSetpSearchForApiSet(v4, v19, v21);
if( v22 )
{
if( (*(_DWORD *)v22 & 1) == 0 )
{
if( !v14 )
{
v14 = 1;
v7 += (v11[2] + 3) & 0xFFFFFFFC;
}
v23 = *((_DWORD *)v22 + 5);
if( !v23 )
return(unsigned int)-1073741811;
if( *(_DWORD *)&v4[*((unsigned int *)v22 + 4) + 16] && a2_4 )
v7 += 20 * v23 + 20;
}
}
else
{
++v64;
v7 += ((v17 + 3) & 0xFFFFFFFC) + 20;
if( !v14 )
{
v14 = 1;
v7 += (v11[2] + 3) & 0xFFFFFFFC;
}
}
v15 = v76;
v13 = (unsigned int)(v91 + 1);
LODWORD(v91) = v13;
if( (unsigned int)v13 >= v72 )
{
v6 = a2a;
v10 = v74;
goto LABEL_29;
}
}
return(unsigned int)-1073740670;
}Referenced by:
ApiSetpLoadSchemaExtension