CmDeleteInterfaceClassMappedPropertyFromRegValue

NTSTATUS __stdcall CmDeleteInterfaceClassMappedPropertyFromRegValue(
        HPNPCTX *hPnpCtx,
        WCHAR *ClassGuid,
        VOID *ObjectBaseKey,
        _DEVPROPKEY *PropertyKey){
  unsigned int pid; 
  NTSTATUS v5; 
  UINT64 v9; 
  DEVPROPKEY **v10; 
  DEVPROPKEY *v11; 
  DEVPROPKEY **v12; 
  __int64 v13; 
  __int64 v14; 
  int inited; 
  _OBJECT_TYPE *v16; 
  VOID **ClassKey; 
  UINT64 *Disposition; 
  _UNICODE_STRING DestinationString; 
  VOID *KeyHandle; 

  pid = PropertyKey->pid;
  v5 = 0;
  KeyHandle = 0i64;
  if( pid < 2 )
    return -1073741264;
  v9 = 0i64;
  v10 = &off_140983758;
  do
  {
    v11 = *v10;
    v12 = v10;
    if( pid == (*v10)->pid )
    {
      v13 = *(_QWORD *)&PropertyKey->fmtid.Data1 - *(_QWORD *)&v11->fmtid.Data1;
      if( *(_QWORD *)&PropertyKey->fmtid.Data1 == *(_QWORD *)&v11->fmtid.Data1 )
        v13 = *(_QWORD *)PropertyKey->fmtid.Data4 - *(_QWORD *)v11->fmtid.Data4;
      if( !v13 )
        break;
    }
    v12 = 0i64;
    v9 = (unsigned int)(v9 + 1);
    v10 += 2;
  }
  while( !(_DWORD)v9 );
  if( !v12 )
    return -1073741264;
  if( pid == 2 )
  {
    v14 = *(_QWORD *)&PropertyKey->fmtid.Data1 - *(_QWORD *)&DEVPKEY_DeviceInterfaceClass_DefaultInterface.fmtid.Data1;
    if( *(_QWORD *)&PropertyKey->fmtid.Data1 == *(_QWORD *)&DEVPKEY_DeviceInterfaceClass_DefaultInterface.fmtid.Data1 )
      v14 = *(_QWORD *)PropertyKey->fmtid.Data4 - *(_QWORD *)DEVPKEY_DeviceInterfaceClass_DefaultInterface.fmtid.Data4;
    if( !v14 )
    {
      if( !ObjectBaseKey )
      {
        LOBYTE(Disposition) = 0;
        LODWORD(ClassKey) = 1;
        v5 = CmOpenInterfaceClassRegKey(hPnpCtx, ClassGuid, v9, (UINT8)PropertyKey, ClassKey, Disposition);
        if( v5 < 0 )
          return v5;
        ObjectBaseKey = 0i64;
      }
      v5 = PnpOpenPropertiesKey((__int64)hPnpCtx, ObjectBaseKey, 0i64, 2u, 0, (int)Disposition, (INT64)&KeyHandle);
      if( v5 == -1073741772 )
      {
        return -1073741275;
      }
      else if( v5 >= 0 )
      {
        DestinationString = 0i64;
        inited = RtlInitUnicodeStringEx(&DestinationString, (WCHAR *)L"Default");
        if( inited >= 0 )
          inited = ZwDeleteValueKey(KeyHandle, &DestinationString, v16);
        ZwClose((_HANDLE)KeyHandle);
        if( inited != -1073741772 && inited != -1073741444 && inited < 0 )
          return inited;
      }
    }
  }
  return v5;
}

Referenced by:

CmSetInterfaceClassMappedProperty