PiSwDeviceMakeCompatibleIds

NTSTATUS __stdcall PiSwDeviceMakeCompatibleIds(PI_SWD_OBJECT *SwDeviceObject, WCHAR **CompatibleIds){
  const wchar_t *v2; 
  NTSTATUS v3; 
  __int64 v6; 
  __int64 v7; 
  __int64 v8; 
  __int64 v9; 
  VOID **PoolWithTag; 
  WCHAR *v11; 
  _WORD *v12; 
  VOID **v13; 
  __int64 v14; 
  __int64 v15; 
  NTSTATUS result; 

  v2 = (const wchar_t *)*((_QWORD *)SwDeviceObject + 4);
  v3 = 0;
  v6 = 0i64;
  if( v2 )
  {
    while( *v2 )
    {
      v7 = -1i64;
      do
        ++v7;
      while( v2[v7] );
      v8 = v7 + 1;
      if( wcsicmp(v2, L"SWD\\GenericRaw") && wcsicmp(v2, L"SWD\\Generic") )
        v6 += 2 * v8;
      v2 += v8;
    }
  }
  v9 = v6 + 30;
  if( (SwDeviceObject[16] & 8) != 0 )
    v9 = v6;
  PoolWithTag = ExAllocatePoolWithTag(1ui64, v9 + 26, 1466986064i64);
  v11 = (WCHAR *)PoolWithTag;
  if( PoolWithTag )
  {
    v12 = (_WORD *)*((_QWORD *)SwDeviceObject + 4);
    v13 = PoolWithTag;
    if( v12 )
    {
      while( *v12 )
      {
        v14 = -1i64;
        do
          ++v14;
        while( v12[v14] );
        v15 = v14 + 1;
        if( wcsicmp(v12, L"SWD\\GenericRaw") && wcsicmp(v12, L"SWD\\Generic") )
        {
          memmove(v13, v12, 2 * v15);
          v13 = (VOID **)((char *)v13 + 2 * v15);
        }
        v12 += v15;
      }
    }
    if( (SwDeviceObject[16] & 8) == 0 )
    {
      *(_OWORD *)v13 = *(_OWORD *)L"SWD\\GenericRaw";
      v13[2] = *(VOID **)L"ricRaw";
      *((_DWORD *)v13 + 6) = *(_DWORD *)L"aw";
      *((_WORD *)v13 + 14) = PiSwGenericRawCompatibleId[14];
      v13 = (VOID **)((char *)v13 + 30);
    }
    *(_OWORD *)v13 = *(_OWORD *)L"SWD\\Generic";
    v13[2] = *(VOID **)L"ric";
    *((_WORD *)v13 + 12) = 0;
  }
  else
  {
    v3 = -1073741670;
  }
  result = v3;
  *CompatibleIds = v11;
  return result;
}

Referenced by:

PiSwPdoPnPDispatch