CmDeleteDeviceMappedPropertyFromDriverKeyRegValue

__int64 __fastcall CmDeleteDeviceMappedPropertyFromDriverKeyRegValue(__int64 a1, const wchar_t *a2, __int64 a3){
  int v4; 
  unsigned int v5; 
  DEVPROPKEY **v7; 
  DEVPROPKEY *v8; 
  DEVPROPKEY **v9; 
  __int64 v10; 
  int v11; 
  unsigned int v12; 
  WCHAR *v13; 
  HANDLE v14; 
  int inited; 
  __int64 v17; 
  struct _UNICODE_STRING DestinationString; 
  HANDLE KeyHandle; 
  KeyHandle = 0i64;
  v4 = *(_DWORD *)(a3 + 16);
  v5 = 0;
  v7 = &off_140986950;
  do
  {
    v8 = *v7;
    v9 = v7;
    if( v4 == (*v7)->pid )
    {
      v10 = *(_QWORD *)a3 - *(_QWORD *)&v8->fmtid.Data1;
      if( *(_QWORD *)a3 == *(_QWORD *)&v8->fmtid.Data1 )
        v10 = *(_QWORD *)(a3 + 8) - *(_QWORD *)v8->fmtid.Data4;
      if( !v10 )
        break;
    }
    v9 = 0i64;
    ++v5;
    v7 += 4;
  }
  while( v5 < 0xD );
  if( !v9 )
    return(unsigned int)-1073741802;
  v11 = CmOpenDeviceRegKey(a1, a2, 18, 0, 2, 0, (__int64)&KeyHandle, 0i64);
  v12 = v11;
  if( v11 == -1073741772 )
  {
    v12 = 0;
  }
  else if( v11 >= 0 )
  {
    v13 = (WCHAR *)v9[2];
    v14 = KeyHandle;
    DestinationString = 0i64;
    inited = RtlInitUnicodeStringEx(&DestinationString, v13);
    if( inited >= 0 )
      inited = ZwDeleteValueKey(v14, &DestinationString);
    if( inited == -1073741772 )
      goto LABEL_16;
    if( inited != -1073741444 )
    {
      if( inited >= 0 )
      {
LABEL_16:
        if( *(_DWORD *)(a3 + 16) == 2 )
        {
          v17 = *(_QWORD *)a3 - *(_QWORD *)&DEVPKEY_Device_DriverDate.fmtid.Data1;
          if( *(_QWORD *)a3 == *(_QWORD *)&DEVPKEY_Device_DriverDate.fmtid.Data1 )
            v17 = *(_QWORD *)(a3 + 8) - *(_QWORD *)DEVPKEY_Device_DriverDate.fmtid.Data4;
          if( !v17 )
          {
            DestinationString = 0i64;
            if( (int)RtlInitUnicodeStringEx(&DestinationString, (WCHAR *)L"DriverDate") >= 0 )
              ZwDeleteValueKey(KeyHandle, &DestinationString);
          }
        }
        goto LABEL_17;
      }
      v12 = inited;
    }
  }
LABEL_17:
  if( KeyHandle )
    ZwClose(KeyHandle);
  return v12;
}

Referenced by:

CmSetDeviceMappedProperty