punycode_decode
NTSTATUS __stdcall punycode_decode(
WCHAR *pInput,
INT64 inputLength,
WCHAR *pOutput,
INT64 *poutputBufferLength,
UINT8 bAllowEmail,
UINT8 bUseStd3Rules,
UINT8 *bAsciiOnly,
WCHAR **pOutputEmailAt,
INT64 a9){
UINT8 *v9;
WCHAR *v10;
__int64 v11;
WCHAR *v12;
WCHAR *v13;
WCHAR *v14;
WCHAR *v15;
UINT8 v16;
WCHAR *LabelEnd;
WCHAR *v18;
signed __int64 v19;
unsigned __int64 v20;
WCHAR *v21;
const wchar_t *v22;
WCHAR *v23;
__int16 v24;
WCHAR *v25;
__int64 v26;
WCHAR v27;
int v29;
int v30;
int v31;
int v32;
WCHAR *v33;
int v34;
int v35;
int i;
int v37;
int v38;
int v39;
__int64 v40;
__int64 v41;
__int64 v42;
__int64 v43;
int v44;
WCHAR *v45;
WCHAR *v46;
WCHAR v47;
__int16 v48;
__int64 v49;
WCHAR *v50;
__int16 v51;
NTSTATUS v52;
WCHAR *pInsertLocation;
unsigned __int64 v54;
WCHAR *v55;
WCHAR *v56;
int v57;
WCHAR *ppOutput;
INT64 *v59;
v59 = poutputBufferLength;
ppOutput = pOutput;
v9 = bAsciiOnly;
v10 = pOutput;
v11 = *(int *)poutputBufferLength;
*(_DWORD *)poutputBufferLength = 0;
*v9 = 1;
if( (int)inputLength <= 0 )
return -1073740010;
v12 = &v10[v11];
v13 = pInput;
v14 = v10;
pInsertLocation = v10;
v56 = v10;
v54 = (unsigned __int64)v12;
v15 = &pInput[(int)inputLength];
v55 = pInput - 1;
*pOutputEmailAt = v10 - 1;
if( pInput >= v15 )
return -1073740010;
v16 = bAllowEmail;
while( 1 )
{
LabelEnd = FindLabelEnd(v13, v15, v16);
v21 = LabelEnd;
if( LabelEnd == v13 )
break;
if( !v16
&& (bUseStd3Rules && (*v13 == 45 || (unsigned __int64)LabelEnd > v20 && *(LabelEnd - 1) == 45)
|| (__int64)(((char *)LabelEnd - (char *)v13) & 0xFFFFFFFFFFFFFFFEui64) > v19) )
{
return -1073740010;
}
if( (__int64)(((char *)v15 - (char *)v13) & 0xFFFFFFFFFFFFFFFEui64) < 8 )
goto LABEL_80;
v22 = L"xl--";
if( !v16 )
v22 = L"xn--";
if( wcsnicmp(v13, v22, 4u) )
{
LOWORD(v19) = 126;
LABEL_80:
if( (__int64)(((char *)v12 - (char *)v10) & 0xFFFFFFFFFFFFFFFEui64) < (__int64)(((char *)v21 - (char *)v13) & 0xFFFFFFFFFFFFFFFEui64) )
return -1073740010;
v50 = v13;
if( v13 < v21 )
{
v51 = 1;
while( (v16 || (!bUseStd3Rules || ValidateStd3Range(*v50)) && *v50 >= 0x20u && *v50 != 127)
&& (unsigned __int16)(*v50 - v51) <= (unsigned __int16)v19 )
{
*v10 = *v50++;
ppOutput = ++v10;
if( v50 >= v21 )
goto LABEL_92;
}
return -1073740010;
}
goto LABEL_92;
}
*v9 = 0;
v13 += 4;
v23 = v21 - 1;
if( v21 - 1 < v13 )
{
LABEL_18:
v23 = 0i64;
}
else
{
while( *v23 != 45 )
{
if( --v23 < v13 )
goto LABEL_18;
}
}
if( v23 == v21 - 1 )
return -1073740010;
if( v23 && v23 > v13 )
{
v24 = 1;
v25 = v13;
v26 = v23 - v13;
do
{
if( v10 >= v12 )
break;
if( !v16 && (bUseStd3Rules && !ValidateStd3Range(*v25) || *v25 < 0x20u || *v25 == 127) )
return -1073740010;
v27 = *v25;
if( (unsigned __int16)(*v25 - v24) > 0x7Eu )
return -1073740010;
if( !v16 && (unsigned __int16)(v27 - 65) <= 0x19u )
v27 += 32;
*v10 = v27;
++v25;
ppOutput = ++v10;
}
while( v25 != v23 );
if( v25 != v23 )
return -1073740010;
}
else
{
LODWORD(v26) = 0;
}
v57 = 0;
v29 = v26 + 1;
v30 = 128;
if( (int)v26 <= 0 )
v29 = 0;
v31 = 0;
v32 = 72;
v33 = &v13[v29];
if( v33 < v21 )
{
LABEL_40:
v34 = v31;
v35 = 1;
for( i = 36; v33 < v21; i += 36 )
{
v37 = *v33;
if( (unsigned __int16)(v37 - 48) > 9u )
{
if( (unsigned __int16)(v37 - 97) > 0x19u )
v38 = (unsigned __int16)(v37 - 65) > 0x19u ? -1 : v37 - 65;
else
v38 = v37 - 97;
}
else
{
v38 = v37 - 22;
}
++v33;
if( v38 < 0 || v38 > (0x7FFFFFF - v31) / v35 )
break;
v31 += v35 * v38;
if( i > v32 )
{
if( i < v32 + 26 )
v39 = i - v32;
else
v39 = 26;
}
else
{
v39 = 1;
}
if( v38 < v39 )
{
v52 = adapt((unsigned int)(v31 - v34), (unsigned int)(v10 - pInsertLocation) - v57 + 1);
v41 = v40 - v57;
v42 = v31 / (v41 + 1);
v43 = v31 % (v41 + 1);
v44 = v43;
if( v42 > 0x7FFFFFF - v30 )
return -1073740010;
v30 += v42;
if( (unsigned int)(v30 - 128) > 0x10FF7F || (unsigned int)(v30 - 55296) <= 0x7FF )
return -1073740010;
if( v57 <= 0 )
{
v45 = &pInsertLocation[(int)v43];
}
else
{
v45 = pInsertLocation;
if( (int)v43 > 0 )
{
while( v45 < v10 )
{
v46 = v45 + 1;
LODWORD(v43) = v43 - 1;
if( (unsigned __int16)(*v45 + 10240) > 0x7FFu )
v46 = v45;
v45 = v46 + 1;
if( (int)v43 <= 0 )
goto LABEL_70;
}
return -1073740010;
}
}
LABEL_70:
if( v30 >= 0x10000 )
{
if( (unsigned __int64)v10 >= v54 - 2 || v45 > v10 )
return -1073740010;
InsertChar((v30 - 0x10000) / 1024 - 10240, v45, &ppOutput);
++v57;
v47 = v48 - 9216;
v45 = (WCHAR *)(v49 + 2);
}
else
{
if( (unsigned __int64)v10 >= v54 || v45 > v10 )
return -1073740010;
v47 = v30;
}
InsertChar(v47, v45, &ppOutput);
v10 = ppOutput;
v31 = v44 + 1;
if( v33 >= v21 )
goto LABEL_91;
v32 = v52;
goto LABEL_40;
}
if( v35 > 0x7FFFFFF / (36 - v39) )
return -1073740010;
v35 *= 36 - v39;
}
return -1073740010;
}
LABEL_91:
v9 = bAsciiOnly;
v12 = (WCHAR *)v54;
v14 = pInsertLocation;
LABEL_92:
if( !v16 && ((__int64)(((char *)v21 - (char *)v13) & 0xFFFFFFFFFFFFFFFEui64) > 126 || v10 == v14) )
return -1073740010;
if( v21 != v15 )
{
if( v10 >= v12 )
return -1073740010;
*v10++ = *v21;
ppOutput = v10;
}
if( v16 )
{
v16 = 0;
v55 = v21;
*pOutputEmailAt = (WCHAR *)((char *)v10 - (v15 != v21 ? 2 : 0));
if( v21 == v15 - 1 )
return -1073740010;
}
v13 = v21 + 1;
pInsertLocation = v10;
v14 = v10;
v18 = v10;
if( v21 >= v15 )
goto LABEL_104;
}
if( v16 || LabelEnd != v15 )
return -1073740010;
LABEL_104:
if( v18 != v56 && v15 - v55 <= 256i64 - (*(v15 - 1) != 46) )
{
*(_DWORD *)v59 = v18 - v56;
return 0;
}
return -1073740010;
}Referenced by:
RtlpIdnToUnicodeWorker