ReactOS  0.4.14-dev-384-g5b37caa
dmoreg.c
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2003 Michael G├╝nnewig
3  * Copyright (C) 2003 CodeWeavers Inc. (Ulrich Czekalla)
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
18  */
19 
20 #include <stdarg.h>
21 
22 #define COBJMACROS
23 
24 #include "windef.h"
25 #include "winbase.h"
26 #include "winuser.h"
27 #include "winerror.h"
28 #include "winreg.h"
29 #include "objbase.h"
30 #include "wine/debug.h"
31 #include "dmo.h"
32 
34 
35 #define MSDMO_MAJOR_VERSION 6
36 
37 static const WCHAR szDMORootKey[] =
38 {
39  'D','i','r','e','c','t','S','h','o','w','\\',
40  'M','e','d','i','a','O','b','j','e','c','t','s',0
41 };
42 
43 static const WCHAR szDMOInputType[] =
44 {
45  'I','n','p','u','t','T','y','p','e','s',0
46 };
47 
48 static const WCHAR szDMOOutputType[] =
49 {
50  'O','u','t','p','u','t','T','y','p','e','s',0
51 };
52 
53 static const WCHAR szDMOKeyed[] =
54 {
55  'K','e','y','e','d',0
56 };
57 
58 static const WCHAR szDMOCategories[] =
59 {
60  'C','a','t','e','g','o','r','i','e','s',0
61 };
62 
63 static const WCHAR szGUIDFmt[] =
64 {
65  '%','0','8','X','-','%','0','4','X','-','%','0','4','X','-','%','0',
66  '2','X','%','0','2','X','-','%','0','2','X','%','0','2','X','%','0','2',
67  'X','%','0','2','X','%','0','2','X','%','0','2','X',0
68 };
69 
70 static const WCHAR szCat3Fmt[] =
71 {
72  '%','s','\\','%','s','\\','%','s',0
73 };
74 
75 static const WCHAR szCat2Fmt[] =
76 {
77  '%','s','\\','%','s',0
78 };
79 
80 static const WCHAR szToGuidFmt[] =
81 {
82  '{','%','s','}',0
83 };
84 
85 
86 typedef struct
87 {
98 } IEnumDMOImpl;
99 
101 {
102  return CONTAINING_RECORD(iface, IEnumDMOImpl, IEnumDMO_iface);
103 }
104 
105 static HRESULT read_types(HKEY root, LPCWSTR key, ULONG *supplied, ULONG requested, DMO_PARTIAL_MEDIATYPE* types);
106 
107 static const IEnumDMOVtbl edmovt;
108 
109 static LPWSTR GUIDToString(LPWSTR lpwstr, REFGUID lpcguid)
110 {
111  wsprintfW(lpwstr, szGUIDFmt, lpcguid->Data1, lpcguid->Data2,
112  lpcguid->Data3, lpcguid->Data4[0], lpcguid->Data4[1],
113  lpcguid->Data4[2], lpcguid->Data4[3], lpcguid->Data4[4],
114  lpcguid->Data4[5], lpcguid->Data4[6], lpcguid->Data4[7]);
115 
116  return lpwstr;
117 }
118 
119 static HRESULT string_to_guid(const WCHAR *string, GUID *guid)
120 {
121  WCHAR buffer[39];
122  buffer[0] = '{';
123  lstrcpyW(buffer + 1, string);
124  buffer[37] = '}';
125  buffer[38] = 0;
126  return CLSIDFromString(buffer, guid);
127 }
128 
130 {
131 
132  return (IsEqualCLSID(&mt1->type, &mt2->type) ||
133  IsEqualCLSID(&mt2->type, &GUID_NULL) ||
134  IsEqualCLSID(&mt1->type, &GUID_NULL)) &&
135  (IsEqualCLSID(&mt1->subtype, &mt2->subtype) ||
136  IsEqualCLSID(&mt2->subtype, &GUID_NULL) ||
137  IsEqualCLSID(&mt1->subtype, &GUID_NULL));
138 }
139 
141 {
142  LONG ret;
143 
144  if (MSDMO_MAJOR_VERSION > 5)
145  {
146  ret = RegSetValueExW(hkey, name, 0, REG_BINARY, (const BYTE*) types,
147  count* sizeof(DMO_PARTIAL_MEDIATYPE));
148  }
149  else
150  {
151  HKEY skey1,skey2,skey3;
152  DWORD index = 0;
153  WCHAR szGuidKey[64];
154 
156  KEY_WRITE, NULL, &skey1, NULL);
157  if (ret)
158  return HRESULT_FROM_WIN32(ret);
159 
160  while (index < count)
161  {
162  GUIDToString(szGuidKey,&types[index].type);
163  ret = RegCreateKeyExW(skey1, szGuidKey, 0, NULL,
165  GUIDToString(szGuidKey,&types[index].subtype);
166  ret = RegCreateKeyExW(skey2, szGuidKey, 0, NULL,
168  RegCloseKey(skey3);
169  RegCloseKey(skey2);
170  index ++;
171  }
172  RegCloseKey(skey1);
173  }
174 
175  return HRESULT_FROM_WIN32(ret);
176 }
177 
178 /***************************************************************
179  * DMORegister (MSDMO.@)
180  *
181  * Register a DirectX Media Object.
182  */
184  LPCWSTR szName,
185  REFCLSID clsidDMO,
186  REFGUID guidCategory,
187  DWORD dwFlags,
188  DWORD cInTypes,
189  const DMO_PARTIAL_MEDIATYPE *pInTypes,
190  DWORD cOutTypes,
191  const DMO_PARTIAL_MEDIATYPE *pOutTypes
192 )
193 {
194  WCHAR szguid[64];
195  HRESULT hres;
196  HKEY hrkey = 0;
197  HKEY hkey = 0;
198  HKEY hckey = 0;
199  HKEY hclskey = 0;
200  LONG ret;
201 
202  TRACE("%s %s %s\n", debugstr_w(szName), debugstr_guid(clsidDMO), debugstr_guid(guidCategory));
203 
204  if (IsEqualGUID(guidCategory, &GUID_NULL))
205  return E_INVALIDARG;
206 
209  if (ret)
210  return E_FAIL;
211 
212  /* Create clsidDMO key under MediaObjects */
213  ret = RegCreateKeyExW(hrkey, GUIDToString(szguid, clsidDMO), 0, NULL,
215  if (ret)
216  goto lend;
217 
218  /* Set default Name value */
219  ret = RegSetValueExW(hkey, NULL, 0, REG_SZ, (const BYTE*) szName,
220  (lstrlenW(szName) + 1) * sizeof(WCHAR));
221 
222  /* Set InputTypes */
223  hres = write_types(hkey, szDMOInputType, pInTypes, cInTypes);
224 
225  /* Set OutputTypes */
226  hres = write_types(hkey, szDMOOutputType, pOutTypes, cOutTypes);
227 
229  {
230  /* Create Keyed key */
231  ret = RegCreateKeyExW(hkey, szDMOKeyed, 0, NULL,
233  if (ret)
234  goto lend;
235  RegCloseKey(hckey);
236  }
237 
238  /* Register the category */
241  if (ret)
242  goto lend;
243 
244  RegCloseKey(hkey);
245 
246  ret = RegCreateKeyExW(hckey, GUIDToString(szguid, guidCategory), 0, NULL,
248  if (ret)
249  goto lend;
250  ret = RegCreateKeyExW(hkey, GUIDToString(szguid, clsidDMO), 0, NULL,
252  if (ret)
253  goto lend;
254 
255 lend:
256  if (hkey)
257  RegCloseKey(hkey);
258  if (hckey)
259  RegCloseKey(hckey);
260  if (hclskey)
261  RegCloseKey(hclskey);
262  if (hrkey)
263  RegCloseKey(hrkey);
264 
266  TRACE(" hresult=0x%08x\n", hres);
267  return hres;
268 }
269 
271 {
272  HKEY catkey;
273  LONG ret;
274 
275  ret = RegOpenKeyExW(categories, catW, 0, KEY_WRITE, &catkey);
276  if (!ret)
277  {
278  ret = RegDeleteKeyW(catkey, dmoW);
279  RegCloseKey(catkey);
280  }
281 
282  return !ret ? S_OK : S_FALSE;
283 }
284 
285 /***************************************************************
286  * DMOUnregister (MSDMO.@)
287  *
288  * Unregister a DirectX Media Object.
289  */
291 {
292  HKEY rootkey = 0, categorieskey = 0;
293  WCHAR dmoW[64], catW[64];
294  HRESULT hr = S_FALSE;
295  LONG ret;
296 
297  TRACE("%s %s\n", debugstr_guid(dmo), debugstr_guid(category));
298 
300  if (ret)
301  return S_FALSE;
302 
303  GUIDToString(dmoW, dmo);
304  RegDeleteKeyW(rootkey, dmoW);
305 
306  /* open 'Categories' */
307  ret = RegOpenKeyExW(rootkey, szDMOCategories, 0, KEY_WRITE|KEY_ENUMERATE_SUB_KEYS, &categorieskey);
308  RegCloseKey(rootkey);
309  if (ret)
310  {
312  goto lend;
313  }
314 
315  /* remove from all categories */
317  {
318  DWORD index = 0, len = ARRAY_SIZE(catW);
319 
320  while (!RegEnumKeyExW(categorieskey, index++, catW, &len, NULL, NULL, NULL, NULL))
321  hr = unregister_dmo_from_category(dmoW, catW, categorieskey);
322  }
323  else
324  {
325  GUIDToString(catW, category);
326  hr = unregister_dmo_from_category(dmoW, catW, categorieskey);
327  }
328 
329 lend:
330  if (categorieskey)
331  RegCloseKey(categorieskey);
332 
333  return hr;
334 }
335 
336 
337 /***************************************************************
338  * DMOGetName (MSDMO.@)
339  *
340  * Get DMO Name from the registry
341  */
343 {
344  static const INT max_name_len = 80*sizeof(WCHAR);
345  DWORD count = max_name_len;
346  WCHAR szguid[64];
347  HKEY hrkey, hkey;
348  LONG ret;
349 
350  TRACE("%s %p\n", debugstr_guid(clsidDMO), name);
351 
353  return E_FAIL;
354 
355  ret = RegOpenKeyExW(hrkey, GUIDToString(szguid, clsidDMO), 0, KEY_READ, &hkey);
356  RegCloseKey(hrkey);
357  if (ret)
358  return E_FAIL;
359 
361  RegCloseKey(hkey);
362 
363  if (!ret && count > 1)
364  {
365  TRACE("name=%s\n", debugstr_w(name));
366  return S_OK;
367  }
368 
369  name[0] = 0;
370  return S_FALSE;
371 }
372 
374 {
375  *ret = NULL;
376 
377  if (count == 0)
378  return S_OK;
379 
380  *ret = HeapAlloc(GetProcessHeap(), 0, count*sizeof(*types));
381  if (!*ret)
382  return E_OUTOFMEMORY;
383 
384  memcpy(*ret, types, count*sizeof(*types));
385  return S_OK;
386 }
387 
388 /**************************************************************************
389  * IEnumDMO_Constructor
390  */
392  REFGUID guidCategory,
393  DWORD dwFlags,
394  DWORD cInTypes,
395  const DMO_PARTIAL_MEDIATYPE *pInTypes,
396  DWORD cOutTypes,
397  const DMO_PARTIAL_MEDIATYPE *pOutTypes,
398  IEnumDMO **obj)
399 {
400  IEnumDMOImpl* lpedmo;
401  HRESULT hr;
402 
403  *obj = NULL;
404 
406  if (!lpedmo)
407  return E_OUTOFMEMORY;
408 
409  lpedmo->IEnumDMO_iface.lpVtbl = &edmovt;
410  lpedmo->ref = 1;
411  lpedmo->index = -1;
412  lpedmo->category = *guidCategory;
413  lpedmo->dwFlags = dwFlags;
414  lpedmo->cInTypes = cInTypes;
415  lpedmo->cOutTypes = cOutTypes;
416  lpedmo->hkey = NULL;
417 
418  hr = dup_partial_mediatype(pInTypes, cInTypes, &lpedmo->pInTypes);
419  if (FAILED(hr))
420  goto lerr;
421 
422  hr = dup_partial_mediatype(pOutTypes, cOutTypes, &lpedmo->pOutTypes);
423  if (FAILED(hr))
424  goto lerr;
425 
426  /* If not filtering by category enum from media objects root */
427  if (IsEqualGUID(guidCategory, &GUID_NULL))
428  {
430  }
431  else
432  {
433  WCHAR szguid[64];
434  WCHAR szKey[MAX_PATH];
435 
436  wsprintfW(szKey, szCat3Fmt, szDMORootKey, szDMOCategories, GUIDToString(szguid, guidCategory));
437  RegOpenKeyExW(HKEY_CLASSES_ROOT, szKey, 0, KEY_READ, &lpedmo->hkey);
438  }
439 
440 lerr:
441 
442  if (FAILED(hr))
443  IEnumDMO_Release(&lpedmo->IEnumDMO_iface);
444  else
445  {
446  TRACE("returning %p\n", lpedmo);
447  *obj = &lpedmo->IEnumDMO_iface;
448  }
449 
450  return hr;
451 }
452 
453 /******************************************************************************
454  * IEnumDMO_fnAddRef
455  */
457 {
459  ULONG refCount = InterlockedIncrement(&This->ref);
460  TRACE("(%p)->(%d)\n", This, refCount);
461  return refCount;
462 }
463 
464 /**************************************************************************
465  * EnumDMO_QueryInterface
466  */
468 {
470 
471  TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppvObj);
472 
473  *ppvObj = NULL;
474 
475  if (IsEqualIID(riid, &IID_IEnumDMO) ||
477  {
478  *ppvObj = iface;
479  IEnumDMO_AddRef(iface);
480  }
481 
482  return *ppvObj ? S_OK : E_NOINTERFACE;
483 }
484 
485 /******************************************************************************
486  * IEnumDMO_fnRelease
487  */
489 {
491  ULONG refCount = InterlockedDecrement(&This->ref);
492 
493  TRACE("(%p)->(%d)\n", This, refCount);
494 
495  if (!refCount)
496  {
497  if (This->hkey)
498  RegCloseKey(This->hkey);
499  HeapFree(GetProcessHeap(), 0, This->pInTypes);
500  HeapFree(GetProcessHeap(), 0, This->pOutTypes);
502  }
503  return refCount;
504 }
505 
506 
507 /******************************************************************************
508  * IEnumDMO_fnNext
509  */
511  IEnumDMO * iface,
512  DWORD cItemsToFetch,
513  CLSID * pCLSID,
514  WCHAR ** Names,
515  DWORD * pcItemsFetched)
516 {
517  HKEY hkey;
518  WCHAR szNextKey[MAX_PATH];
519  WCHAR szGuidKey[64];
520  WCHAR szKey[MAX_PATH];
521  WCHAR szValue[MAX_PATH];
522  DWORD len;
523  UINT count = 0;
524  HRESULT hres = S_OK;
525  LONG ret;
526  GUID guid;
527 
529 
530  TRACE("(%p)->(%d %p %p %p)\n", This, cItemsToFetch, pCLSID, Names, pcItemsFetched);
531 
532  if (!pCLSID)
533  return E_POINTER;
534 
535  if (!pcItemsFetched && cItemsToFetch > 1)
536  return E_INVALIDARG;
537 
538  while (count < cItemsToFetch)
539  {
540  This->index++;
541 
542  len = MAX_PATH;
543  ret = RegEnumKeyExW(This->hkey, This->index, szNextKey, &len, NULL, NULL, NULL, NULL);
544  if (ret != ERROR_SUCCESS)
545  {
547  break;
548  }
549 
550  if (string_to_guid(szNextKey, &guid) != S_OK)
551  continue;
552 
553  TRACE("found %s\n", debugstr_w(szNextKey));
554 
555  if (!(This->dwFlags & DMO_ENUMF_INCLUDE_KEYED))
556  {
557  wsprintfW(szKey, szCat3Fmt, szDMORootKey, szNextKey, szDMOKeyed);
558  ret = RegOpenKeyExW(HKEY_CLASSES_ROOT, szKey, 0, KEY_READ, &hkey);
559  if (ERROR_SUCCESS == ret)
560  {
561  RegCloseKey(hkey);
562  /* Skip Keyed entries */
563  continue;
564  }
565  }
566 
567  wsprintfW(szKey, szCat2Fmt, szDMORootKey, szNextKey);
568  ret = RegOpenKeyExW(HKEY_CLASSES_ROOT, szKey, 0, KEY_READ, &hkey);
569  TRACE("testing %s\n", debugstr_w(szKey));
570 
571  if (This->pInTypes)
572  {
573  UINT i, j;
574  DWORD cInTypes;
575  DMO_PARTIAL_MEDIATYPE* pInTypes;
576 
577  hres = read_types(hkey, szDMOInputType, &cInTypes,
578  sizeof(szValue)/sizeof(DMO_PARTIAL_MEDIATYPE),
579  (DMO_PARTIAL_MEDIATYPE*)szValue);
580 
581  if (FAILED(hres))
582  {
583  RegCloseKey(hkey);
584  continue;
585  }
586 
587  pInTypes = (DMO_PARTIAL_MEDIATYPE *)szValue;
588 
589  TRACE("read %d intypes for %s:\n", cInTypes, debugstr_w(szKey));
590  for (i = 0; i < cInTypes; i++) {
591  TRACE("intype %d: type %s, subtype %s\n", i, debugstr_guid(&pInTypes[i].type),
592  debugstr_guid(&pInTypes[i].subtype));
593  }
594 
595  for (i = 0; i < This->cInTypes; i++)
596  {
597  for (j = 0; j < cInTypes; j++)
598  {
599  if (IsMediaTypeEqual(&pInTypes[j], &This->pInTypes[i]))
600  break;
601  }
602 
603  if (j >= cInTypes)
604  break;
605  }
606 
607  if (i < This->cInTypes)
608  {
609  RegCloseKey(hkey);
610  continue;
611  }
612  }
613 
614  if (This->pOutTypes)
615  {
616  UINT i, j;
617  DWORD cOutTypes;
618  DMO_PARTIAL_MEDIATYPE* pOutTypes;
619 
620  hres = read_types(hkey, szDMOOutputType, &cOutTypes,
621  sizeof(szValue)/sizeof(DMO_PARTIAL_MEDIATYPE),
622  (DMO_PARTIAL_MEDIATYPE*)szValue);
623 
624  if (FAILED(hres))
625  {
626  RegCloseKey(hkey);
627  continue;
628  }
629 
630  pOutTypes = (DMO_PARTIAL_MEDIATYPE *)szValue;
631 
632  TRACE("read %d outtypes for %s:\n", cOutTypes, debugstr_w(szKey));
633  for (i = 0; i < cOutTypes; i++) {
634  TRACE("outtype %d: type %s, subtype %s\n", i, debugstr_guid(&pOutTypes[i].type),
635  debugstr_guid(&pOutTypes[i].subtype));
636  }
637 
638  for (i = 0; i < This->cOutTypes; i++)
639  {
640  for (j = 0; j < cOutTypes; j++)
641  {
642  if (IsMediaTypeEqual(&pOutTypes[j], &This->pOutTypes[i]))
643  break;
644  }
645 
646  if (j >= cOutTypes)
647  break;
648  }
649 
650  if (i < This->cOutTypes)
651  {
652  RegCloseKey(hkey);
653  continue;
654  }
655  }
656 
657  /* Media object wasn't filtered so add it to return list */
658  len = MAX_PATH * sizeof(WCHAR);
659  ret = RegQueryValueExW(hkey, NULL, NULL, NULL, (LPBYTE)szValue, &len);
660  if (Names)
661  {
662  Names[count] = NULL;
663  if (ret == ERROR_SUCCESS)
664  {
665  Names[count] = CoTaskMemAlloc((lstrlenW(szValue) + 1) * sizeof(WCHAR));
666  if (Names[count])
667  lstrcpyW(Names[count], szValue);
668  }
669  }
670  wsprintfW(szGuidKey,szToGuidFmt,szNextKey);
671  CLSIDFromString(szGuidKey, &pCLSID[count]);
672 
673  TRACE("found match %s %s\n", debugstr_w(szValue), debugstr_w(szNextKey));
674  RegCloseKey(hkey);
675  count++;
676  }
677 
678  if (pcItemsFetched) *pcItemsFetched = count;
679  if (count < cItemsToFetch)
680  hres = S_FALSE;
681 
682  TRACE("<-- %i found\n",count);
683  return hres;
684 }
685 
686 
687 /******************************************************************************
688  * IEnumDMO_fnSkip
689  */
690 static HRESULT WINAPI IEnumDMO_fnSkip(IEnumDMO * iface, DWORD cItemsToSkip)
691 {
693 
694  TRACE("(%p)->(%d)\n", This, cItemsToSkip);
695  This->index += cItemsToSkip;
696 
697  return S_OK;
698 }
699 
700 
701 /******************************************************************************
702  * IEnumDMO_fnReset
703  */
705 {
707 
708  TRACE("(%p)\n", This);
709  This->index = -1;
710 
711  return S_OK;
712 }
713 
714 
715 /******************************************************************************
716  * IEnumDMO_fnClone
717  */
719 {
721  TRACE("(%p)->(%p)\n", This, ppEnum);
722  return IEnumDMO_Constructor(&This->category, This->dwFlags, This->cInTypes, This->pInTypes,
723  This->cOutTypes, This->pOutTypes, ppEnum);
724 }
725 
726 
727 /***************************************************************
728  * DMOEnum (MSDMO.@)
729  *
730  * Enumerate DirectX Media Objects in the registry.
731  */
734  DWORD flags,
735  DWORD cInTypes,
736  const DMO_PARTIAL_MEDIATYPE *pInTypes,
737  DWORD cOutTypes,
738  const DMO_PARTIAL_MEDIATYPE *pOutTypes,
739  IEnumDMO **ppEnum)
740 {
741  TRACE("%s 0x%08x %d %p %d %p %p\n", debugstr_guid(category), flags, cInTypes, pInTypes,
742  cOutTypes, pOutTypes, ppEnum);
743 
744  if (TRACE_ON(msdmo))
745  {
746  DWORD i;
747  if (cInTypes)
748  {
749  for (i = 0; i < cInTypes; i++)
750  TRACE("intype %d - type %s, subtype %s\n", i, debugstr_guid(&pInTypes[i].type),
751  debugstr_guid(&pInTypes[i].subtype));
752  }
753 
754  if (cOutTypes) {
755  for (i = 0; i < cOutTypes; i++)
756  TRACE("outtype %d - type %s, subtype %s\n", i, debugstr_guid(&pOutTypes[i].type),
757  debugstr_guid(&pOutTypes[i].subtype));
758  }
759  }
760 
761  return IEnumDMO_Constructor(category, flags, cInTypes,
762  pInTypes, cOutTypes, pOutTypes, ppEnum);
763 }
764 
765 
766 static const IEnumDMOVtbl edmovt =
767 {
775 };
776 
777 
779 {
780  HRESULT ret = S_OK;
781 
782  if (MSDMO_MAJOR_VERSION > 5)
783  {
784  DWORD len;
785  LONG rc;
786 
787  len = requested * sizeof(DMO_PARTIAL_MEDIATYPE);
789  ret = HRESULT_FROM_WIN32(rc);
790 
791  *supplied = len / sizeof(DMO_PARTIAL_MEDIATYPE);
792  }
793  else
794  {
795  HKEY hkey;
796  WCHAR szGuidKey[64];
797 
798  *supplied = 0;
799  if (ERROR_SUCCESS == RegOpenKeyExW(root, key, 0, KEY_READ, &hkey))
800  {
801  int index = 0;
802  WCHAR szNextKey[MAX_PATH];
803  DWORD len;
804  LONG rc = ERROR_SUCCESS;
805 
806  while (rc == ERROR_SUCCESS)
807  {
808  len = MAX_PATH;
809  rc = RegEnumKeyExW(hkey, index, szNextKey, &len, NULL, NULL, NULL, NULL);
810  if (rc == ERROR_SUCCESS)
811  {
812  HKEY subk;
813  int sub_index = 0;
814  LONG rcs = ERROR_SUCCESS;
815  WCHAR szSubKey[MAX_PATH];
816 
817  RegOpenKeyExW(hkey, szNextKey, 0, KEY_READ, &subk);
818  while (rcs == ERROR_SUCCESS)
819  {
820  len = MAX_PATH;
821  rcs = RegEnumKeyExW(subk, sub_index, szSubKey, &len, NULL, NULL, NULL, NULL);
822  if (rcs == ERROR_SUCCESS)
823  {
824  if (*supplied >= requested)
825  {
826  /* Bailing */
827  ret = S_FALSE;
828  rc = ERROR_MORE_DATA;
829  rcs = ERROR_MORE_DATA;
830  break;
831  }
832 
833  wsprintfW(szGuidKey,szToGuidFmt,szNextKey);
834  CLSIDFromString(szGuidKey, &types[*supplied].type);
835  wsprintfW(szGuidKey,szToGuidFmt,szSubKey);
836  CLSIDFromString(szGuidKey, &types[*supplied].subtype);
837  TRACE("Adding type %s subtype %s at index %i\n",
838  debugstr_guid(&types[*supplied].type),
839  debugstr_guid(&types[*supplied].subtype),
840  *supplied);
841  (*supplied)++;
842  }
843  sub_index++;
844  }
845  index++;
846  }
847  }
848  RegCloseKey(hkey);
849  }
850  }
851  return ret;
852 }
853 
854 /***************************************************************
855  * DMOGetTypes (MSDMO.@)
856  */
858  ULONG ulInputTypesRequested,
859  ULONG* pulInputTypesSupplied,
860  DMO_PARTIAL_MEDIATYPE* pInputTypes,
861  ULONG ulOutputTypesRequested,
862  ULONG* pulOutputTypesSupplied,
863  DMO_PARTIAL_MEDIATYPE* pOutputTypes)
864 {
865  HKEY root,hkey;
866  HRESULT ret = S_OK;
867  WCHAR szguid[64];
868 
869  TRACE ("(%s,%u,%p,%p,%u,%p,%p)\n", debugstr_guid(clsidDMO), ulInputTypesRequested,
870  pulInputTypesSupplied, pInputTypes, ulOutputTypesRequested, pulOutputTypesSupplied,
871  pOutputTypes);
872 
874  KEY_READ, &root))
875  return E_FAIL;
876 
877  if (ERROR_SUCCESS != RegOpenKeyExW(root,GUIDToString(szguid,clsidDMO) , 0,
878  KEY_READ, &hkey))
879  {
880  RegCloseKey(root);
881  return E_FAIL;
882  }
883 
884  if (ulInputTypesRequested > 0)
885  {
886  ret = read_types(hkey, szDMOInputType, pulInputTypesSupplied, ulInputTypesRequested, pInputTypes );
887  }
888  else
889  *pulInputTypesSupplied = 0;
890 
891  if (ulOutputTypesRequested > 0)
892  {
893  HRESULT ret2;
894  ret2 = read_types(hkey, szDMOOutputType, pulOutputTypesSupplied, ulOutputTypesRequested, pOutputTypes );
895 
896  if (ret == S_OK)
897  ret = ret2;
898  }
899  else
900  *pulOutputTypesSupplied = 0;
901 
902  return ret;
903 }
int WINAPIV wsprintfW(_Out_ LPWSTR, _In_ _Printf_format_string_ LPCWSTR,...)
static const WCHAR dmoW[]
PWSTR Names[NAMES_COUNT]
static const WCHAR szDMORootKey[]
Definition: dmoreg.c:37
#define REFIID
Definition: guiddef.h:118
#define E_NOINTERFACE
Definition: winerror.h:2364
#define HRESULT_FROM_WIN32(x)
Definition: winerror.h:92
#define ERROR_SUCCESS
Definition: deptool.c:10
HRESULT hr
Definition: shlfolder.c:183
static const WCHAR szToGuidFmt[]
Definition: dmoreg.c:80
Definition: scsiwmi.h:51
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
DMO_PARTIAL_MEDIATYPE * pOutTypes
Definition: dmoreg.c:96
static HRESULT WINAPI IEnumDMO_fnReset(IEnumDMO *iface)
Definition: dmoreg.c:704
static HRESULT WINAPI IEnumDMO_fnSkip(IEnumDMO *iface, DWORD cItemsToSkip)
Definition: dmoreg.c:690
#define REG_BINARY
Definition: nt_native.h:1496
#define KEY_READ
Definition: nt_native.h:1023
REFIID riid
Definition: precomp.h:44
#define REFCLSID
Definition: guiddef.h:117
static HRESULT WINAPI IEnumDMO_fnNext(IEnumDMO *iface, DWORD cItemsToFetch, CLSID *pCLSID, WCHAR **Names, DWORD *pcItemsFetched)
Definition: dmoreg.c:510
GLuint GLuint GLsizei count
Definition: gl.h:1545
struct _root root
LONG WINAPI RegDeleteKeyW(_In_ HKEY hKey, _In_ LPCWSTR lpSubKey)
Definition: reg.c:1237
static const WCHAR szGUIDFmt[]
Definition: dmoreg.c:63
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
GLuint buffer
Definition: glext.h:5915
unsigned short Data2
Definition: scsiwmi.h:53
DWORD dwFlags
Definition: dmoreg.c:92
static HRESULT write_types(HKEY hkey, LPCWSTR name, const DMO_PARTIAL_MEDIATYPE *types, DWORD count)
Definition: dmoreg.c:140
#define lstrlenW
Definition: compat.h:415
#define E_FAIL
Definition: ddrawi.h:102
int32_t INT
Definition: typedefs.h:56
LONG WINAPI RegCreateKeyExW(_In_ HKEY hKey, _In_ LPCWSTR lpSubKey, _In_ DWORD Reserved, _In_opt_ LPWSTR lpClass, _In_ DWORD dwOptions, _In_ REGSAM samDesired, _In_opt_ LPSECURITY_ATTRIBUTES lpSecurityAttributes, _Out_ PHKEY phkResult, _Out_opt_ LPDWORD lpdwDisposition)
Definition: reg.c:1091
static const WCHAR szDMOKeyed[]
Definition: dmoreg.c:53
DMO_PARTIAL_MEDIATYPE * pInTypes
Definition: dmoreg.c:94
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
static IEnumDMOImpl * impl_from_IEnumDMO(IEnumDMO *iface)
Definition: dmoreg.c:100
const GUID * guid
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
unsigned char * LPBYTE
Definition: typedefs.h:52
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
static HRESULT IEnumDMO_Constructor(REFGUID guidCategory, DWORD dwFlags, DWORD cInTypes, const DMO_PARTIAL_MEDIATYPE *pInTypes, DWORD cOutTypes, const DMO_PARTIAL_MEDIATYPE *pOutTypes, IEnumDMO **obj)
Definition: dmoreg.c:391
unsigned int BOOL
Definition: ntddk_ex.h:94
long LONG
Definition: pedump.c:60
unsigned long Data1
Definition: scsiwmi.h:52
static const WCHAR szDMOOutputType[]
Definition: dmoreg.c:48
#define debugstr_w
Definition: kernel32.h:32
static HRESULT WINAPI IEnumDMO_fnQueryInterface(IEnumDMO *iface, REFIID riid, void **ppvObj)
Definition: dmoreg.c:467
#define S_FALSE
Definition: winerror.h:2357
#define E_INVALIDARG
Definition: ddrawi.h:101
HRESULT WINAPI DMORegister(LPCWSTR szName, REFCLSID clsidDMO, REFGUID guidCategory, DWORD dwFlags, DWORD cInTypes, const DMO_PARTIAL_MEDIATYPE *pInTypes, DWORD cOutTypes, const DMO_PARTIAL_MEDIATYPE *pOutTypes)
Definition: dmoreg.c:183
struct _DMO_PARTIAL_MEDIATYPE DMO_PARTIAL_MEDIATYPE
smooth NULL
Definition: ftsmooth.c:416
HRESULT WINAPI DMOGetName(REFCLSID clsidDMO, WCHAR name[])
Definition: dmoreg.c:342
static HRESULT unregister_dmo_from_category(const WCHAR *dmoW, const WCHAR *catW, HKEY categories)
Definition: dmoreg.c:270
GLuint index
Definition: glext.h:6031
#define debugstr_guid
Definition: kernel32.h:35
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
DWORD cOutTypes
Definition: dmoreg.c:95
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
Definition: glfuncs.h:250
HKEY hkey
Definition: dmoreg.c:97
#define REG_OPTION_NON_VOLATILE
Definition: nt_native.h:1057
#define KEY_WRITE
Definition: nt_native.h:1031
LONG WINAPI RegSetValueExW(_In_ HKEY hKey, _In_ LPCWSTR lpValueName, _In_ DWORD Reserved, _In_ DWORD dwType, _In_ CONST BYTE *lpData, _In_ DWORD cbData)
Definition: reg.c:4895
IEnumDMO IEnumDMO_iface
Definition: dmoreg.c:88
#define TRACE(s)
Definition: solgame.cpp:4
HRESULT hres
Definition: protocol.c:465
#define GetProcessHeap()
Definition: compat.h:403
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4116
Definition: cmds.c:130
static const IEnumDMOVtbl edmovt
Definition: dmoreg.c:107
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:77
HRESULT WINAPI DMOUnregister(REFCLSID dmo, REFGUID category)
Definition: dmoreg.c:290
const GUID IID_IUnknown
#define MAX_PATH
Definition: compat.h:26
#define WINAPI
Definition: msvc.h:8
static const WCHAR szDMOCategories[]
Definition: dmoreg.c:58
static const WCHAR szDMOInputType[]
Definition: dmoreg.c:43
unsigned long DWORD
Definition: ntddk_ex.h:95
static ULONG WINAPI IEnumDMO_fnRelease(IEnumDMO *iface)
Definition: dmoreg.c:488
GLbitfield flags
Definition: glext.h:7161
int ret
static const WCHAR szCat3Fmt[]
Definition: dmoreg.c:70
#define InterlockedDecrement
Definition: armddk.h:52
static const WCHAR szCat2Fmt[]
Definition: dmoreg.c:75
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
#define MSDMO_MAJOR_VERSION
Definition: dmoreg.c:35
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
GLenum GLsizei len
Definition: glext.h:6722
unsigned char BYTE
Definition: mem.h:68
#define GUID_NULL
Definition: ks.h:106
static HRESULT read_types(HKEY root, LPCWSTR key, ULONG *supplied, ULONG requested, DMO_PARTIAL_MEDIATYPE *types)
Definition: dmoreg.c:778
#define ERROR_MORE_DATA
Definition: dderror.h:13
static HRESULT WINAPI IEnumDMO_fnClone(IEnumDMO *iface, IEnumDMO **ppEnum)
Definition: dmoreg.c:718
LONG ref
Definition: dmoreg.c:89
static LPWSTR GUIDToString(LPWSTR lpwstr, REFGUID lpcguid)
Definition: dmoreg.c:109
static BOOL IsMediaTypeEqual(const DMO_PARTIAL_MEDIATYPE *mt1, const DMO_PARTIAL_MEDIATYPE *mt2)
Definition: dmoreg.c:129
#define S_OK
Definition: intsafe.h:59
#define InterlockedIncrement
Definition: armddk.h:53
GUID category
Definition: dmoreg.c:91
static HRESULT string_to_guid(const WCHAR *string, GUID *guid)
Definition: dmoreg.c:119
#define lstrcpyW
Definition: compat.h:414
#define ARRAY_SIZE(a)
Definition: main.h:24
HRESULT WINAPI DMOEnum(REFGUID category, DWORD flags, DWORD cInTypes, const DMO_PARTIAL_MEDIATYPE *pInTypes, DWORD cOutTypes, const DMO_PARTIAL_MEDIATYPE *pOutTypes, IEnumDMO **ppEnum)
Definition: dmoreg.c:732
unsigned int UINT
Definition: ndis.h:50
BOOL WINAPI IsEqualGUID(REFGUID rguid1, REFGUID rguid2)
Definition: compobj.c:4112
#define HEAP_ZERO_MEMORY
Definition: compat.h:123
WINE_DEFAULT_DEBUG_CHANNEL(msdmo)
unsigned char Data4[8]
Definition: scsiwmi.h:55
DWORD cInTypes
Definition: dmoreg.c:93
static HRESULT dup_partial_mediatype(const DMO_PARTIAL_MEDIATYPE *types, DWORD count, DMO_PARTIAL_MEDIATYPE **ret)
Definition: dmoreg.c:373
Definition: name.c:36
static const WCHAR szName[]
Definition: msipriv.h:1194
HRESULT WINAPI CLSIDFromString(LPCOLESTR idstr, LPCLSID id)
Definition: compobj.c:2338
unsigned int ULONG
Definition: retypes.h:1
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3366
#define HKEY_CLASSES_ROOT
Definition: winreg.h:10
unsigned short Data3
Definition: scsiwmi.h:54
LONG WINAPI RegEnumKeyExW(_In_ HKEY hKey, _In_ DWORD dwIndex, _Out_ LPWSTR lpName, _Inout_ LPDWORD lpcbName, _Reserved_ LPDWORD lpReserved, _Out_opt_ LPWSTR lpClass, _Inout_opt_ LPDWORD lpcbClass, _Out_opt_ PFILETIME lpftLastWriteTime)
Definition: reg.c:2527
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define E_POINTER
Definition: winerror.h:2365
DWORD index
Definition: dmoreg.c:90
static ULONG WINAPI IEnumDMO_fnAddRef(IEnumDMO *iface)
Definition: dmoreg.c:456
#define TRACE_ON(x)
Definition: compat.h:65
#define IsEqualCLSID(rclsid1, rclsid2)
Definition: guiddef.h:96
LPVOID WINAPI CoTaskMemAlloc(SIZE_T size)
Definition: ifs.c:404
#define HeapFree(x, y, z)
Definition: compat.h:402
HRESULT WINAPI DMOGetTypes(REFCLSID clsidDMO, ULONG ulInputTypesRequested, ULONG *pulInputTypesSupplied, DMO_PARTIAL_MEDIATYPE *pInputTypes, ULONG ulOutputTypesRequested, ULONG *pulOutputTypesSupplied, DMO_PARTIAL_MEDIATYPE *pOutputTypes)
Definition: dmoreg.c:857
GLsizei GLenum * categories
Definition: glext.h:11561
#define IsEqualIID(riid1, riid2)
Definition: guiddef.h:95
Definition: path.c:42
#define KEY_ENUMERATE_SUB_KEYS
Definition: nt_native.h:1019
#define REG_SZ
Definition: layer.c:22