PnpDeleteDeviceInterfaces

VOID __stdcall PnpDeleteDeviceInterfaces(_UNICODE_STRING *DeviceInstancePath, INT16 DX){
  _ETHREAD *CurrentThread; 
  void *PoolWithTag; 
  int MatchingFilteredDeviceInterfaceList; 
  unsigned int v6; 
  WCHAR *i; 
  struct _UNICODE_STRING DestinationString; 
  unsigned int v9; 
  WCHAR *OutString; 
  v9 = 0;
  CurrentThread = (_ETHREAD *)KeGetCurrentThread();
  PoolWithTag = 0i64;
  OutString = 0i64;
  DestinationString = 0i64;
  --*((_WORD *)CurrentThread + 242);
  ExAcquireResourceExclusiveLite(&PnpRegistryDeviceResource, 1u);
  if( (int)PnpUnicodeStringToWstr(&OutString, 0i64, DeviceInstancePath) >= 0 )
  {
    v9 = 4096;
    MatchingFilteredDeviceInterfaceList = -1073741789;
    v6 = 0;
    while( v6 < 5 )
    {
      if( PoolWithTag )
        ExFreePoolWithTag(PoolWithTag, 0);
      PoolWithTag = ExAllocatePoolWithTag(PagedPool, 2i64 * v9, 0x20207050ui64);
      if( !PoolWithTag )
      {
        MatchingFilteredDeviceInterfaceList = -1073741670;
        break;
      }
      ++v6;
      MatchingFilteredDeviceInterfaceList = CmGetMatchingFilteredDeviceInterfaceList(
                                              PiPnpRtlCtx,
                                              0i64,
                                              (__int64)OutString,
                                              0,
                                              0i64,
                                              0i64,
                                              (__int64)PoolWithTag,
                                              v9,
                                              (__int64)&v9,
                                              0);
      if( MatchingFilteredDeviceInterfaceList != -1073741789 )
        break;
    }
    if( MatchingFilteredDeviceInterfaceList >= 0 )
    {
      for( i = (WCHAR *)PoolWithTag; *i; i += ((unsigned __int64)DestinationString.Length + 2) >> 1 )
      {
        if( (int)RtlInitUnicodeStringEx(&DestinationString, i) >= 0 )
          CmDeleteDeviceInterface(PiPnpRtlCtx, DestinationString.Buffer, 0);
      }
    }
  }
  ExReleaseResourceLite(&PnpRegistryDeviceResource);
  KeLeaveCriticalRegionThread((__int64)KeGetCurrentThread());
  if( PoolWithTag )
    ExFreePoolWithTag(PoolWithTag, 0);
  PnpUnicodeStringToWstrFree(OutString, DeviceInstancePath);
}

Referenced by:

PiDevCfgConfigureDevice