CmGetDeviceContainerIdFromBase

__int64 __fastcall CmGetDeviceContainerIdFromBase(__int64 a1, const WCHAR *a2, const wchar_t *a3, wchar_t *a4){
  unsigned int v4; 
  int CachedContextBaseKey; 
  int v11; 
  __int64 v12; 
  int v13; 
  char v14; 
  char v15[7]; 
  HANDLE KeyHandle; 
  int v17[4]; 
  wchar_t pszSrc[40]; 
  v4 = 0;
  KeyHandle = 0i64;
  v15[0] = 0;
  v14 = 0;
  CachedContextBaseKey = RtlStringCchCopyW(a4, 0x27ui64, (PWCHAR)a3);
  if( CachedContextBaseKey >= 0 )
  {
    if( wcscmp((PWCHAR)L"{00000000-0000-0000-0000-000000000000}", (PWCHAR)a3) )
    {
      CachedContextBaseKey = PnpCtxGetCachedContextBaseKey(a1, 10, (__int64 *)&KeyHandle);
      if( CachedContextBaseKey >= 0 )
      {
        CachedContextBaseKey = CmIsDeviceInContainer(a1, (char *)KeyHandle, a3, a3, a2, v15, &v14);
        if( CachedContextBaseKey >= 0 && !v14 )
        {
          while( 1 )
          {
            v17[0] = 39;
            v11 = RegRtlEnumKey(KeyHandle, v4, (char *)pszSrc, (unsigned int *)v17);
            CachedContextBaseKey = v11;
            if( v11 == -2147483622 )
              break;
            if( v11 != -1073741789 )
            {
              if( v11 < 0 )
                return(unsigned int)CachedContextBaseKey;
              v13 = CmValidateDeviceContainerName(v12, pszSrc);
              CachedContextBaseKey = v13;
              if( v13 != -1073741773 )
              {
                if( v13 < 0 )
                  return(unsigned int)CachedContextBaseKey;
                CachedContextBaseKey = CmIsDeviceInContainer(a1, (char *)KeyHandle, pszSrc, a3, a2, v15, &v14);
                if( CachedContextBaseKey < 0 )
                  return(unsigned int)CachedContextBaseKey;
                if( v15[0] )
                  CachedContextBaseKey = RtlStringCchCopyW(a4, 0x27ui64, pszSrc);
                if( CachedContextBaseKey < 0 || v14 )
                  return(unsigned int)CachedContextBaseKey;
              }
            }
            ++v4;
          }
          return 0;
        }
      }
    }
  }
  return(unsigned int)CachedContextBaseKey;
}

Referenced by:

CmDeleteDeviceWorker
CmGetDeviceMappedPropertyFromComposite
PiDcHandleCustomDeviceEvent
PiDcUpdateDeviceContainerMembership