PiForEachDriverQueryRoutine

__int64 __fastcall PiForEachDriverQueryRoutine(int a1, const WCHAR *a2, ULONG a3, _QWORD *a4){
  ULONG v5; 
  const WCHAR *v6; 
  __int64 result; 
  __int64 v8; 
  __int64 v9; 
  WCHAR v10; 
  struct _UNICODE_STRING DestinationString; 
  UINT64 pulResult; 
  LODWORD(pulResult) = a3;
  v5 = a3;
  v6 = a2;
  DestinationString = 0i64;
  result = 0i64;
  if( (a1 == 1 || a1 == 7) && a3 > 2 )
  {
    if( a1 == 1 )
    {
      RtlInitUnicodeString(&DestinationString, a2, a3);
      return((__int64(__fastcall *)(_QWORD, struct _UNICODE_STRING *, _QWORD))a4[1])(*a4, &DestinationString, a4[2]);
    }
    else if( *a2 )
    {
      while( 1 )
      {
        v8 = -1i64;
        do
          ++v8;
        while( v6[v8] );
        v9 = v8 + 1;
        if( RtlULongSub(v5, (unsigned int)(2 * v9), &pulResult) < 0 )
          break;
        RtlInitUnicodeString(&DestinationString, v6, v10);
        result = ((__int64(__fastcall *)(_QWORD, struct _UNICODE_STRING *, _QWORD))a4[1])(
                   *a4,
                   &DestinationString,
                   a4[2]);
        if( (int)result >= 0 )
        {
          v5 = pulResult;
          if( (unsigned int)pulResult >= 2 )
          {
            v6 += v9;
            if( *v6 )
              continue;
          }
        }
        return result;
      }
      return 0i64;
    }
  }
  return result;
}

Referenced by:

PpForEachDeviceInstanceDriver