PipResetDevice

INT64 __fastcall PipResetDevice(UINT64 a1, WCHAR *a2){
  __int64 v4; 
  int v5; 
  int v6; 
  int v7; 
  int v8; 
  int v9; 
  unsigned int v11; 
  int v12; 
  int v13; 
  struct _UNICODE_STRING DestinationString; 
  GUID Guid; 
  WCHAR SourceString[40]; 
  v13 = 0;
  v12 = 0;
  Guid = 0i64;
  DestinationString = 0i64;
  DbgPrintEx(0x20u, 0, "Resetting device '%ws'\n", a2);
  if( PipResetDeviceBreakOnReset )
    __debugbreak();
  v11 = 78;
  if( (int)CmGetDeviceRegProp(a1, a2, 0i64, 9, (__int64)&v12, (__int64)SourceString, (__int64)&v11, 0) < 0
    || v12 != 1
    || v11 < 2
    || (int)RtlInitUnicodeStringEx(&DestinationString, SourceString) < 0
    || RtlGUIDFromString(&DestinationString, &Guid) < 0 )
  {
    Guid = 0i64;
  }
  if( CmIsRootEnumeratedDevice(a2) )
    goto LABEL_14;
  v4 = *(_QWORD *)&Guid.Data1 - 0x11CEE3254D36E968i64;
  if( *(_QWORD *)&Guid.Data1 == 0x11CEE3254D36E968i64 )
    v4 = *(_QWORD *)Guid.Data4 - 0x1803E12B0008C1BFi64;
  if( !v4 )
  {
LABEL_14:
    v6 = CmDeleteDeviceRegKey(a1, a2, 17, 0);
    v5 = 0;
    if( v6 < 0 )
      v5 = v6;
    v7 = CmDeleteDeviceRegKey(a1, a2, 18, 0);
    if( v5 >= 0 && v7 < 0 )
      v5 = v7;
    v11 = 4;
    if( (int)CmGetDeviceRegProp(a1, a2, 0i64, 11, (__int64)&v12, (__int64)&v13, (__int64)&v11, 0) >= 0
      && v12 == 4
      && v11 == 4 )
    {
      v8 = v13;
    }
    else
    {
      v8 = 0;
    }
    if( (v8 & 0x20) == 0 )
    {
      v13 = v8 | 0x20;
      v9 = CmSetDeviceRegProp(a1, a2, 0i64, 0xBu, 4u, (__int64)&v13, 4u, 0);
      if( v5 >= 0 && v9 < 0 )
        return(unsigned int)v9;
    }
  }
  else
  {
    return(unsigned int)CmDeleteDevice(a1, a2, 0);
  }
  return(unsigned int)v5;
}

Referenced by:

PipResetDevices