PnpGetDeviceLocationStrings
__int64 __fastcall PnpGetDeviceLocationStrings(__int64 a1, __int64 *a2, _DWORD *a3){
__int64 v3;
__int64 v4;
_QWORD *v5;
unsigned int v6;
_QWORD *v7;
void *PoolWithTag;
PVOID *v9;
int v10;
_DWORD *v11;
_DWORD *v12;
unsigned int v13;
NTSTATUS v14;
int v15;
int v16;
unsigned int v17;
_WORD *i;
__int64 v19;
__int64 v20;
__int64 v21;
UINT64 v22;
UINT8 *v23;
_WORD *v24;
unsigned int v25;
int v26;
char v27;
char v28;
__int64 v29;
__int64 v30;
PVOID *v31;
VOID *v33;
unsigned int v34;
UINT8 *v35;
unsigned int v36;
unsigned int v37;
unsigned int v38;
unsigned int v39;
UINT8 *v40;
char v41;
char v42;
char v43;
unsigned int v44;
UINT8 *v45;
char v46;
char v47;
__int64 v48;
__int64 v49;
UINT8 *v50;
__int64 v51;
__int64 v52;
__int64 v53;
int v54;
int v55;
unsigned int v56;
unsigned int v57;
void *Src;
PVOID P;
int v60;
unsigned int v61;
unsigned int v62;
unsigned int v63;
unsigned int v64;
__int64 v65;
_DWORD *v66;
NTSTATUS v67;
__int64 v68;
INTERFACE Interface;
__int64(__fastcall *v70)(void *, void **);
__int64 v71;
char v72;
int v75;
v71 = a1;
v70 = 0i64;
Src = 0i64;
LOBYTE(v60) = 0;
v3 = a1;
v61 = -1;
v4 = 0i64;
v56 = -1;
v65 = 0i64;
memset(&Interface, 0, sizeof(Interface));
if( !a1 || !a2 || !a3 )
return 3221225485i64;
v5 = IopRootDeviceNode;
*a2 = 0i64;
*a3 = 0;
if( (_QWORD *)v3 == v5 )
return 3221225486i64;
v6 = 0;
v7 = (_QWORD *)v3;
do
{
v7 = (_QWORD *)v7[2];
++v6;
}
while( v7 != v5 );
v64 = v6;
v68 = v6;
PoolWithTag = ExAllocatePoolWithTag(PagedPool, 8i64 * v6, 0x75737050ui64);
P = PoolWithTag;
v9 = (PVOID *)PoolWithTag;
if( PoolWithTag )
{
memset((INT64)PoolWithTag, 0i64);
v10 = 1;
v11 = ExAllocatePoolWithTag(PagedPool, 4i64 * v6, 0x75737050ui64);
v66 = v11;
v12 = v11;
if( v11 )
{
memset((INT64)v11, 0i64);
v75 = 1;
v13 = 0;
if( (PVOID)v3 != IopRootDeviceNode )
{
while( 1 )
{
v14 = PnpQueryInterface(
*(DEVICE_OBJECT **)(v3 + 32),
&GUID_PNP_LOCATION_INTERFACE,
1u,
0x28u,
0i64,
&Interface);
if( v14 < 0 )
{
v4 = 0i64;
goto LABEL_53;
}
if( v70 )
{
Src = 0i64;
v14 = v70(Interface.Context, &Src);
if( v14 < 0 )
goto LABEL_112;
if( !Src )
v14 = -1073741637;
if( v14 < 0 )
{
LABEL_112:
if( Src )
{
ExFreePoolWithTag(Src, 0);
Src = 0i64;
}
}
else
{
v15 = 0;
v16 = 0;
v17 = 0;
v12[v13] = 0;
for( i = Src; *i; i += v21 + 1 )
{
++v15;
v19 = -1i64;
v12[v13] = v15;
do
++v19;
while( i[v19] );
v16 += v19 + 1;
v20 = -1i64;
do
++v20;
while( i[v20] );
if( (unsigned int)v20 <= v17 )
LODWORD(v20) = v17;
v17 = v20;
v21 = -1i64;
do
++v21;
while( i[v21] );
}
LODWORD(v4) = v17 + v4;
v22 = 2i64 * (unsigned int)(v16 + 1);
v75 *= v15;
v23 = (UINT8 *)ExAllocatePoolWithTag(PagedPool, v22, 0x75737050ui64);
*((_QWORD *)P + v13) = v23;
if( v23 )
{
memmove(v23, (UINT8 *)Src, v22);
v24 = (_WORD *)*((_QWORD *)P + v13);
if( *v24 )
{
v25 = v61;
LOBYTE(v26) = v60;
while( 1 )
{
v27 = 0;
v28 = 0;
while( 1 )
{
if( *v24 == 33 )
{
v27 = 1;
goto LABEL_51;
}
if( *v24 != 64 )
break;
v28 = 1;
LABEL_51:
++v24;
}
v26 = (unsigned __int8)v26;
if( v28 )
v26 = 1;
if( v27 && v25 == -1 )
v25 = v13;
v29 = -1i64;
do
++v29;
while( v24[v29] );
v24 += v29 + 1;
if( !*v24 )
{
v60 = v26;
v3 = v71;
v61 = v25;
v12 = v66;
break;
}
}
}
++v13;
}
else
{
v14 = -1073741670;
}
ExFreePoolWithTag(Src, 0);
v6 = v64;
Src = 0i64;
}
}
else
{
v14 = -1073741823;
}
if( Interface.InterfaceDereference )
Interface.InterfaceDereference(Interface.Context);
if( v14 < 0 )
{
v4 = v65;
goto LABEL_53;
}
if( v14 == 288 || v13 == v6 )
{
LODWORD(v4) = v4 + 1;
LABEL_66:
v10 = v75;
break;
}
v3 = *(_QWORD *)(v3 + 16);
LODWORD(v4) = v4 + 1;
v71 = v3;
if( (PVOID)v3 == IopRootDeviceNode )
goto LABEL_66;
}
}
v14 = 0;
v67 = 0;
v33 = ExAllocatePoolWithTag(PagedPool, 2i64 * (unsigned int)(v10 * v4 + 1), 0x75737050ui64);
v65 = (__int64)v33;
v4 = (__int64)v33;
if( v33 )
{
memset((INT64)v33, 0i64);
v34 = v13 - 1;
v57 = v13 - 1;
v35 = (UINT8 *)v4;
v62 = 0;
v36 = 0;
if( !v10 )
{
LABEL_102:
*(_WORD *)v35 = 0;
*a2 = v4;
*a3 = (__int64)&v35[-v4 + 2] >> 1;
goto LABEL_53;
}
v37 = v75;
LABEL_70:
v38 = v34;
v63 = v37;
v39 = v37;
v72 = 0;
v40 = v35;
v41 = 0;
v42 = 0;
v43 = 0;
LABEL_71:
v44 = v36 / (v39 / v66[v38]) % v66[v38];
v45 = (UINT8 *)*((_QWORD *)P + v38);
if( v44 )
{
v52 = v44;
do
{
v53 = -1i64;
do
++v53;
while( *(_WORD *)&v45[2 * v53] );
v45 += 2 * v53 + 2;
--v52;
}
while( v52 );
v37 = v75;
}
v46 = 0;
v47 = 0;
while( 1 )
{
if( *(_WORD *)v45 == 33 )
{
v46 = 1;
}
else
{
if( *(_WORD *)v45 != 64 )
{
if( v38 == v34 )
{
v54 = -1;
v72 = v46;
v41 = v46;
v42 = v46;
v43 = v46;
if( v46 )
v54 = v38;
v56 = v54;
}
if( v46 )
{
if( !(_BYTE)v60 && !v43 )
goto LABEL_100;
v56 = v38;
v41 = 1;
v43 = v42 != 0 ? v43 : 0;
}
else
{
v72 = 0;
}
if( v47 )
{
v55 = -1;
v72 = v46;
v40 = v35;
v41 = v46;
v43 = v46;
if( v46 )
v55 = v38;
v56 = v55;
}
v48 = -1i64;
do
++v48;
while( *(_WORD *)&v45[2 * v48] );
memmove(v40, v45, 2 * v48);
v49 = -1i64;
do
++v49;
while( *(_WORD *)&v45[2 * v49] );
v50 = &v40[2 * v49];
if( v38 )
{
v51 = (__int64)v66;
v42 = v72;
v36 = v62;
v34 = v57;
*(_WORD *)v50 = 35;
v40 = v50 + 2;
v39 = v63 / *(_DWORD *)(v51 + 4i64 * v38--);
v63 = v39;
goto LABEL_71;
}
if( !v41 || v43 && v56 <= v61 )
{
*(_WORD *)v50 = 0;
v35 = v50 + 2;
}
v34 = v57;
LABEL_100:
v36 = v62 + 1;
v62 = v36;
if( v36 >= v37 )
{
v14 = v67;
v4 = v65;
v12 = v66;
goto LABEL_102;
}
goto LABEL_70;
}
v47 = 1;
}
v45 += 2;
}
}
v14 = -1073741670;
LABEL_53:
v9 = (PVOID *)P;
}
else
{
v14 = -1073741670;
}
if( v64 )
{
v30 = v68;
v31 = v9;
do
{
if( *v31 )
ExFreePoolWithTag(*v31, 0);
++v31;
--v30;
}
while( v30 );
}
ExFreePoolWithTag(v9, 0);
if( v12 )
ExFreePoolWithTag(v12, 0);
if( v14 < 0 )
{
if( v4 )
ExFreePoolWithTag((PVOID)v4, 0);
}
}
else
{
return(unsigned int)-1073741670;
}
return(unsigned int)v14;
}Referenced by:
PiProcessNewDeviceNode
PiQueryRemovableDeviceOverride