ReactOS 0.4.17-dev-966-gf06eace
dmoreg.c File Reference
#include <stdarg.h>
#include "windef.h"
#include "winbase.h"
#include "winuser.h"
#include "winerror.h"
#include "winreg.h"
#include "objbase.h"
#include "wine/debug.h"
#include "dmo.h"
Include dependency graph for dmoreg.c:

Go to the source code of this file.

Classes

struct  IEnumDMOImpl
 

Macros

#define COBJMACROS
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (msdmo)
 
BOOL array_reserve (void **elements, unsigned int *capacity, unsigned int count, unsigned int size)
 
static IEnumDMOImpl * impl_from_IEnumDMO (IEnumDMO *iface)
 
static const WCHAR * GUIDToString (WCHAR *string, const GUID *guid)
 
static HRESULT string_to_guid (const WCHAR *string, GUID *guid)
 
static BOOL IsMediaTypeEqual (const DMO_PARTIAL_MEDIATYPE *mt1, const DMO_PARTIAL_MEDIATYPE *mt2)
 
static HRESULT write_types (HKEY hkey, LPCWSTR name, const DMO_PARTIAL_MEDIATYPE *types, DWORD count)
 
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)
 
static HRESULT unregister_dmo_from_category (const WCHAR *dmoW, const WCHAR *catW, HKEY categories)
 
HRESULT WINAPI DMOUnregister (REFCLSID dmo, REFGUID category)
 
HRESULT WINAPI DMOGetName (REFCLSID clsidDMO, WCHAR name[80])
 
static HRESULT dup_partial_mediatype (const DMO_PARTIAL_MEDIATYPE *types, DWORD count, DMO_PARTIAL_MEDIATYPE **ret)
 
static HRESULT IEnumDMO_Constructor (REFGUID guidCategory, DWORD dwFlags, DWORD cInTypes, const DMO_PARTIAL_MEDIATYPE *pInTypes, DWORD cOutTypes, const DMO_PARTIAL_MEDIATYPE *pOutTypes, IEnumDMO **obj)
 
static ULONG WINAPI IEnumDMO_fnAddRef (IEnumDMO *iface)
 
static HRESULT WINAPI IEnumDMO_fnQueryInterface (IEnumDMO *iface, REFIID riid, void **ppvObj)
 
static ULONG WINAPI IEnumDMO_fnRelease (IEnumDMO *iface)
 
static BOOL any_types_match (const DMO_PARTIAL_MEDIATYPE *a, unsigned int a_count, const DMO_PARTIAL_MEDIATYPE *b, unsigned int b_count)
 
static HRESULT WINAPI IEnumDMO_fnNext (IEnumDMO *iface, DWORD cItemsToFetch, CLSID *pCLSID, WCHAR **Names, DWORD *pcItemsFetched)
 
static HRESULT WINAPI IEnumDMO_fnSkip (IEnumDMO *iface, DWORD cItemsToSkip)
 
static HRESULT WINAPI IEnumDMO_fnReset (IEnumDMO *iface)
 
static HRESULT WINAPI IEnumDMO_fnClone (IEnumDMO *iface, IEnumDMO **ppEnum)
 
HRESULT WINAPI DMOEnum (REFGUID category, DWORD flags, DWORD cInTypes, const DMO_PARTIAL_MEDIATYPE *pInTypes, DWORD cOutTypes, const DMO_PARTIAL_MEDIATYPE *pOutTypes, IEnumDMO **ppEnum)
 
HRESULT WINAPI DMOGetTypes (REFCLSID clsid, ULONG input_count, ULONG *ret_input_count, DMO_PARTIAL_MEDIATYPE *input, ULONG output_count, ULONG *ret_output_count, DMO_PARTIAL_MEDIATYPE *output)
 

Variables

static const IEnumDMOVtbl edmovt
 

Macro Definition Documentation

◆ COBJMACROS

#define COBJMACROS

Definition at line 22 of file dmoreg.c.

Function Documentation

◆ any_types_match()

static BOOL any_types_match ( const DMO_PARTIAL_MEDIATYPE *  a,
unsigned int  a_count,
const DMO_PARTIAL_MEDIATYPE *  b,
unsigned int  b_count 
)
static

Definition at line 447 of file dmoreg.c.

449{
450 unsigned int i, j;
451
452 for (i = 0; i < a_count; ++i)
453 {
454 for (j = 0; j < b_count; ++j)
455 {
456 if (IsMediaTypeEqual(&a[i], &b[j]))
457 return TRUE;
458 }
459 }
460 return FALSE;
461}
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
static BOOL IsMediaTypeEqual(const DMO_PARTIAL_MEDIATYPE *mt1, const DMO_PARTIAL_MEDIATYPE *mt2)
Definition: dmoreg.c:104
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6204
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
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

Referenced by IEnumDMO_fnNext().

◆ array_reserve()

BOOL array_reserve ( void **  elements,
unsigned int *  capacity,
unsigned int  count,
unsigned int  size 
)

Definition at line 35 of file dmoreg.c.

36{
37 unsigned int max_capacity, new_capacity;
38 void *new_elements;
39
40 if (count <= *capacity)
41 return TRUE;
42
43 max_capacity = ~0u / size;
44 if (count > max_capacity)
45 return FALSE;
46
47 new_capacity = max(8, *capacity);
48 while (new_capacity < count && new_capacity <= max_capacity / 2)
49 new_capacity *= 2;
50 if (new_capacity < count)
51 new_capacity = count;
52
53 if (!(new_elements = realloc(*elements, new_capacity * size)))
54 {
55 ERR("Failed to allocate memory.\n");
56 return FALSE;
57 }
58
59 *elements = new_elements;
60 *capacity = new_capacity;
61 return TRUE;
62}
#define ERR(fmt,...)
Definition: precomp.h:57
#define realloc
Definition: debug_ros.c:6
GLuint GLuint GLsizei count
Definition: gl.h:1545
GLsizeiptr size
Definition: glext.h:5919
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 * u
Definition: glfuncs.h:240
#define max(a, b)
Definition: svc.c:63

Referenced by IEnumDMO_fnNext().

◆ DMOEnum()

HRESULT WINAPI DMOEnum ( REFGUID  category,
DWORD  flags,
DWORD  cInTypes,
const DMO_PARTIAL_MEDIATYPE *  pInTypes,
DWORD  cOutTypes,
const DMO_PARTIAL_MEDIATYPE *  pOutTypes,
IEnumDMO **  ppEnum 
)

Definition at line 674 of file dmoreg.c.

682{
683 TRACE("%s 0x%08lx %ld %p %ld %p %p\n", debugstr_guid(category), flags, cInTypes, pInTypes,
684 cOutTypes, pOutTypes, ppEnum);
685
686 if (TRACE_ON(msdmo))
687 {
688 DWORD i;
689 if (cInTypes)
690 {
691 for (i = 0; i < cInTypes; i++)
692 TRACE("intype %ld - type %s, subtype %s\n", i, debugstr_guid(&pInTypes[i].type),
693 debugstr_guid(&pInTypes[i].subtype));
694 }
695
696 if (cOutTypes) {
697 for (i = 0; i < cOutTypes; i++)
698 TRACE("outtype %ld - type %s, subtype %s\n", i, debugstr_guid(&pOutTypes[i].type),
699 debugstr_guid(&pOutTypes[i].subtype));
700 }
701 }
702
703 return IEnumDMO_Constructor(category, flags, cInTypes,
704 pInTypes, cOutTypes, pOutTypes, ppEnum);
705}
#define TRACE_ON(x)
Definition: compat.h:75
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:331
unsigned long DWORD
Definition: ntddk_ex.h:95
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
GLbitfield flags
Definition: glext.h:7161
#define debugstr_guid
Definition: kernel32.h:35
const GUID * subtype
Definition: mpegvideo.c:120
#define TRACE(s)
Definition: solgame.cpp:4

Referenced by enum_moniker_create(), and test_dmo().

◆ DMOGetName()

HRESULT WINAPI DMOGetName ( REFCLSID  clsidDMO,
WCHAR  name[80] 
)

Definition at line 282 of file dmoreg.c.

283{
284 static const INT max_name_len = 80*sizeof(WCHAR);
285 DWORD count = max_name_len;
286 WCHAR szguid[64];
287 HKEY hrkey, hkey;
288 LONG ret;
289
290 TRACE("%s %p\n", debugstr_guid(clsidDMO), name);
291
292 if (RegOpenKeyExW(HKEY_CLASSES_ROOT, L"DirectShow\\MediaObjects", 0, KEY_READ, &hrkey))
293 return E_FAIL;
294
295 ret = RegOpenKeyExW(hrkey, GUIDToString(szguid, clsidDMO), 0, KEY_READ, &hkey);
296 RegCloseKey(hrkey);
297 if (ret)
298 return E_FAIL;
299
301 RegCloseKey(hkey);
302
303 if (!ret && count > 1)
304 {
305 TRACE("name=%s\n", debugstr_w(name));
306 return S_OK;
307 }
308
309 name[0] = 0;
310 return S_FALSE;
311}
#define RegCloseKey(hKey)
Definition: registry.h:49
#define E_FAIL
Definition: ddrawi.h:102
#define NULL
Definition: types.h:112
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3333
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4103
static const WCHAR * GUIDToString(WCHAR *string, const GUID *guid)
Definition: dmoreg.c:85
return ret
Definition: mutex.c:147
#define L(x)
Definition: resources.c:13
#define S_OK
Definition: intsafe.h:52
#define debugstr_w
Definition: kernel32.h:32
#define KEY_READ
Definition: nt_native.h:1026
short WCHAR
Definition: pedump.c:58
long LONG
Definition: pedump.c:60
Definition: name.c:39
unsigned char * LPBYTE
Definition: typedefs.h:53
int32_t INT
Definition: typedefs.h:58
#define S_FALSE
Definition: winerror.h:3451
#define HKEY_CLASSES_ROOT
Definition: winreg.h:10

Referenced by property_bag_Read().

◆ DMOGetTypes()

HRESULT WINAPI DMOGetTypes ( REFCLSID  clsid,
ULONG  input_count,
ULONG *  ret_input_count,
DMO_PARTIAL_MEDIATYPE *  input,
ULONG  output_count,
ULONG *  ret_output_count,
DMO_PARTIAL_MEDIATYPE *  output 
)

Definition at line 722 of file dmoreg.c.

724{
725 WCHAR guidstr[64];
726 HKEY root, key;
727 LSTATUS ret;
728 DWORD size;
729
730 TRACE("clsid %s, input_count %lu, ret_input_count %p, input %p, output_count %lu, ret_output_count %p, output %p.\n",
731 debugstr_guid(clsid), input_count, ret_input_count, input, output_count, ret_output_count, output);
732
733 if (RegOpenKeyExW(HKEY_CLASSES_ROOT, L"DirectShow\\MediaObjects", 0, KEY_READ, &root))
734 return E_FAIL;
735
736 if (RegOpenKeyExW(root, GUIDToString(guidstr, clsid), 0, KEY_READ, &key))
737 {
739 return E_FAIL;
740 }
741
742 *ret_input_count = 0;
743 size = input_count * sizeof(DMO_PARTIAL_MEDIATYPE);
744 ret = RegQueryValueExW(key, L"InputTypes", NULL, NULL, (BYTE *)input, &size);
745 if (!ret || ret == ERROR_MORE_DATA)
746 *ret_input_count = min(input_count, size / sizeof(DMO_PARTIAL_MEDIATYPE));
747
748 *ret_output_count = 0;
749 size = output_count * sizeof(DMO_PARTIAL_MEDIATYPE);
750 ret = RegQueryValueExW(key, L"OutputTypes", NULL, NULL, (BYTE *)output, &size);
751 if (!ret || ret == ERROR_MORE_DATA)
752 *ret_output_count = min(output_count, size / sizeof(DMO_PARTIAL_MEDIATYPE));
753
756 return S_OK;
757}
struct _root root
#define ERROR_MORE_DATA
Definition: dderror.h:13
static LSTATUS(WINAPI *pRegDeleteTreeW)(HKEY
struct _DMO_PARTIAL_MEDIATYPE DMO_PARTIAL_MEDIATYPE
GLenum GLenum GLenum input
Definition: glext.h:9031
#define min(a, b)
Definition: monoChain.cc:55
const CLSID * clsid
Definition: msctf.cpp:50
Definition: copy.c:22
unsigned char BYTE
Definition: xxhash.c:193

Referenced by property_bag_Read().

◆ DMORegister()

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 at line 126 of file dmoreg.c.

136{
137 WCHAR szguid[64];
139 HKEY hrkey = 0;
140 HKEY hkey = 0;
141 HKEY hckey = 0;
142 HKEY hclskey = 0;
143 LONG ret;
144
145 TRACE("%s %s %s\n", debugstr_w(szName), debugstr_guid(clsidDMO), debugstr_guid(guidCategory));
146
147 if (IsEqualGUID(guidCategory, &GUID_NULL))
148 return E_INVALIDARG;
149
150 ret = RegCreateKeyExW(HKEY_CLASSES_ROOT, L"DirectShow\\MediaObjects", 0,
151 NULL, 0, KEY_WRITE, NULL, &hrkey, NULL);
152 if (ret)
153 return E_FAIL;
154
155 /* Create clsidDMO key under MediaObjects */
156 ret = RegCreateKeyExW(hrkey, GUIDToString(szguid, clsidDMO), 0, NULL,
158 if (ret)
159 goto lend;
160
161 /* Set default Name value */
162 ret = RegSetValueExW(hkey, NULL, 0, REG_SZ, (const BYTE*) szName,
163 (wcslen(szName) + 1) * sizeof(WCHAR));
164
165 /* Set InputTypes */
166 hres = write_types(hkey, L"InputTypes", pInTypes, cInTypes);
167
168 /* Set OutputTypes */
169 hres = write_types(hkey, L"OutputTypes", pOutTypes, cOutTypes);
170
172 {
173 /* Create Keyed key */
174 ret = RegCreateKeyExW(hkey, L"Keyed", 0, NULL, 0, KEY_WRITE, NULL, &hckey, NULL);
175 if (ret)
176 goto lend;
177 RegCloseKey(hckey);
178 }
179
180 /* Register the category */
181 ret = RegCreateKeyExW(hrkey, L"Categories", 0, NULL, 0, KEY_WRITE, NULL, &hckey, NULL);
182 if (ret)
183 goto lend;
184
185 RegCloseKey(hkey);
186
187 ret = RegCreateKeyExW(hckey, GUIDToString(szguid, guidCategory), 0, NULL,
189 if (ret)
190 goto lend;
191 ret = RegCreateKeyExW(hkey, GUIDToString(szguid, clsidDMO), 0, NULL,
193 if (ret)
194 goto lend;
195
196lend:
197 if (hkey)
198 RegCloseKey(hkey);
199 if (hckey)
200 RegCloseKey(hckey);
201 if (hclskey)
202 RegCloseKey(hclskey);
203 if (hrkey)
204 RegCloseKey(hrkey);
205
207 TRACE(" hresult=0x%08lx\n", hres);
208 return hres;
209}
#define REG_SZ
Definition: layer.c:22
#define E_INVALIDARG
Definition: ddrawi.h:101
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:1096
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:4882
_ACRTIMP size_t __cdecl wcslen(const wchar_t *)
Definition: wcs.c:2988
static HRESULT write_types(HKEY hkey, LPCWSTR name, const DMO_PARTIAL_MEDIATYPE *types, DWORD count)
Definition: dmoreg.c:115
@ DMO_REGISTERF_IS_KEYED
Definition: dmoreg.h:32
#define GUID_NULL
Definition: ks.h:106
HRESULT hres
Definition: protocol.c:432
_In_ LPWSTR _In_ DWORD _In_ DWORD _In_ DWORD dwFlags
Definition: netsh.h:141
#define REG_OPTION_NON_VOLATILE
Definition: nt_native.h:1060
#define KEY_WRITE
Definition: nt_native.h:1034
static const WCHAR szName[]
Definition: powrprof.c:45
#define IsEqualGUID(rguid1, rguid2)
Definition: guiddef.h:147
static HRESULT HRESULT_FROM_WIN32(unsigned int x)
Definition: winerror.h:210

Referenced by test_dmo().

◆ DMOUnregister()

HRESULT WINAPI DMOUnregister ( REFCLSID  dmo,
REFGUID  category 
)

Definition at line 231 of file dmoreg.c.

232{
233 HKEY rootkey = 0, categorieskey = 0;
234 WCHAR dmoW[64], catW[64];
236 LONG ret;
237
238 TRACE("%s %s\n", debugstr_guid(dmo), debugstr_guid(category));
239
240 if (RegOpenKeyExW(HKEY_CLASSES_ROOT, L"DirectShow\\MediaObjects", 0, KEY_WRITE, &rootkey))
241 return S_FALSE;
242
243 GUIDToString(dmoW, dmo);
244 RegDeleteKeyW(rootkey, dmoW);
245
246 /* open 'Categories' */
247 ret = RegOpenKeyExW(rootkey, L"Categories", 0, KEY_WRITE|KEY_ENUMERATE_SUB_KEYS, &categorieskey);
248 RegCloseKey(rootkey);
249 if (ret)
250 {
252 goto lend;
253 }
254
255 /* remove from all categories */
257 {
258 DWORD index = 0, len = ARRAY_SIZE(catW);
259
260 while (!RegEnumKeyExW(categorieskey, index++, catW, &len, NULL, NULL, NULL, NULL))
261 hr = unregister_dmo_from_category(dmoW, catW, categorieskey);
262 }
263 else
264 {
265 GUIDToString(catW, category);
266 hr = unregister_dmo_from_category(dmoW, catW, categorieskey);
267 }
268
269lend:
270 if (categorieskey)
271 RegCloseKey(categorieskey);
272
273 return hr;
274}
#define ARRAY_SIZE(A)
Definition: main.h:20
HRESULT hr
Definition: delayimp.cpp:582
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:2504
LONG WINAPI RegDeleteKeyW(_In_ HKEY hKey, _In_ LPCWSTR lpSubKey)
Definition: reg.c:1239
static HRESULT unregister_dmo_from_category(const WCHAR *dmoW, const WCHAR *catW, HKEY categories)
Definition: dmoreg.c:211
GLuint index
Definition: glext.h:6031
GLenum GLsizei len
Definition: glext.h:6722
#define KEY_ENUMERATE_SUB_KEYS
Definition: nt_native.h:1022

Referenced by test_dmo().

◆ dup_partial_mediatype()

static HRESULT dup_partial_mediatype ( const DMO_PARTIAL_MEDIATYPE *  types,
DWORD  count,
DMO_PARTIAL_MEDIATYPE **  ret 
)
static

Definition at line 313 of file dmoreg.c.

314{
315 *ret = NULL;
316
317 if (count == 0)
318 return S_OK;
319
320 *ret = HeapAlloc(GetProcessHeap(), 0, count*sizeof(*types));
321 if (!*ret)
322 return E_OUTOFMEMORY;
323
324 memcpy(*ret, types, count*sizeof(*types));
325 return S_OK;
326}
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define GetProcessHeap()
Definition: compat.h:736
#define HeapAlloc
Definition: compat.h:733
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
Definition: cmds.c:130

Referenced by IEnumDMO_Constructor().

◆ GUIDToString()

static const WCHAR * GUIDToString ( WCHAR *  string,
const GUID *  guid 
)
static

Definition at line 85 of file dmoreg.c.

86{
87 swprintf(string, 37, L"%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X",
88 guid->Data1, guid->Data2, guid->Data3,
89 guid->Data4[0], guid->Data4[1], guid->Data4[2], guid->Data4[3],
90 guid->Data4[4], guid->Data4[5], guid->Data4[6], guid->Data4[7]);
91 return string;
92}
GUID guid
Definition: version.c:147
#define swprintf
Definition: precomp.h:40
char string[160]
Definition: util.h:11

Referenced by DMOGetName(), DMOGetTypes(), DMORegister(), DMOUnregister(), and IEnumDMO_Constructor().

◆ IEnumDMO_Constructor()

static HRESULT IEnumDMO_Constructor ( REFGUID  guidCategory,
DWORD  dwFlags,
DWORD  cInTypes,
const DMO_PARTIAL_MEDIATYPE *  pInTypes,
DWORD  cOutTypes,
const DMO_PARTIAL_MEDIATYPE *  pOutTypes,
IEnumDMO **  obj 
)
static

Definition at line 331 of file dmoreg.c.

339{
340 IEnumDMOImpl* lpedmo;
341 HRESULT hr;
342
343 *obj = NULL;
344
346 if (!lpedmo)
347 return E_OUTOFMEMORY;
348
349 lpedmo->IEnumDMO_iface.lpVtbl = &edmovt;
350 lpedmo->ref = 1;
351 lpedmo->index = -1;
352 lpedmo->category = *guidCategory;
353 lpedmo->dwFlags = dwFlags;
354 lpedmo->cInTypes = cInTypes;
355 lpedmo->cOutTypes = cOutTypes;
356 lpedmo->hkey = NULL;
357
358 hr = dup_partial_mediatype(pInTypes, cInTypes, &lpedmo->pInTypes);
359 if (FAILED(hr))
360 goto lerr;
361
362 hr = dup_partial_mediatype(pOutTypes, cOutTypes, &lpedmo->pOutTypes);
363 if (FAILED(hr))
364 goto lerr;
365
366 /* If not filtering by category enum from media objects root */
367 if (IsEqualGUID(guidCategory, &GUID_NULL))
368 {
369 RegOpenKeyExW(HKEY_CLASSES_ROOT, L"DirectShow\\MediaObjects", 0, KEY_READ, &lpedmo->hkey);
370 }
371 else
372 {
373 WCHAR szguid[64];
374 WCHAR szKey[MAX_PATH];
375
376 swprintf(szKey, ARRAY_SIZE(szKey), L"DirectShow\\MediaObjects\\Categories\\%s",
377 GUIDToString(szguid, guidCategory));
378 RegOpenKeyExW(HKEY_CLASSES_ROOT, szKey, 0, KEY_READ, &lpedmo->hkey);
379 }
380
381lerr:
382
383 if (FAILED(hr))
384 IEnumDMO_Release(&lpedmo->IEnumDMO_iface);
385 else
386 {
387 TRACE("returning %p\n", lpedmo);
388 *obj = &lpedmo->IEnumDMO_iface;
389 }
390
391 return hr;
392}
#define MAX_PATH
Definition: compat.h:34
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
static const IEnumDMOVtbl edmovt
Definition: dmoreg.c:83
static HRESULT dup_partial_mediatype(const DMO_PARTIAL_MEDIATYPE *types, DWORD count, DMO_PARTIAL_MEDIATYPE **ret)
Definition: dmoreg.c:313
#define FAILED(hr)
Definition: intsafe.h:51
HKEY hkey
Definition: dmoreg.c:75
DWORD index
Definition: dmoreg.c:68
DWORD dwFlags
Definition: dmoreg.c:70
DMO_PARTIAL_MEDIATYPE * pOutTypes
Definition: dmoreg.c:74
GUID category
Definition: dmoreg.c:69
DWORD cOutTypes
Definition: dmoreg.c:73
IEnumDMO IEnumDMO_iface
Definition: dmoreg.c:66
LONG ref
Definition: dmoreg.c:67
DMO_PARTIAL_MEDIATYPE * pInTypes
Definition: dmoreg.c:72
DWORD cInTypes
Definition: dmoreg.c:71

Referenced by DMOEnum(), and IEnumDMO_fnClone().

◆ IEnumDMO_fnAddRef()

static ULONG WINAPI IEnumDMO_fnAddRef ( IEnumDMO *  iface)
static

Definition at line 397 of file dmoreg.c.

398{
400 ULONG refCount = InterlockedIncrement(&This->ref);
401 TRACE("(%p)->(%ld)\n", This, refCount);
402 return refCount;
403}
#define InterlockedIncrement
Definition: armddk.h:53
static IEnumDMOImpl * impl_from_IEnumDMO(IEnumDMO *iface)
Definition: dmoreg.c:78
uint32_t ULONG
Definition: typedefs.h:59

◆ IEnumDMO_fnClone()

static HRESULT WINAPI IEnumDMO_fnClone ( IEnumDMO *  iface,
IEnumDMO **  ppEnum 
)
static

Definition at line 660 of file dmoreg.c.

661{
663 TRACE("(%p)->(%p)\n", This, ppEnum);
664 return IEnumDMO_Constructor(&This->category, This->dwFlags, This->cInTypes, This->pInTypes,
665 This->cOutTypes, This->pOutTypes, ppEnum);
666}

◆ IEnumDMO_fnNext()

static HRESULT WINAPI IEnumDMO_fnNext ( IEnumDMO *  iface,
DWORD  cItemsToFetch,
CLSID *  pCLSID,
WCHAR **  Names,
DWORD *  pcItemsFetched 
)
static

Definition at line 466 of file dmoreg.c.

472{
474 unsigned int types_size = 0;
475 HKEY hkey;
476 WCHAR szNextKey[MAX_PATH];
478 WCHAR szValue[MAX_PATH];
479 DWORD len;
480 UINT count = 0;
481 HRESULT hres = S_OK;
482 LONG ret;
483
485
486 TRACE("(%p)->(%ld %p %p %p)\n", This, cItemsToFetch, pCLSID, Names, pcItemsFetched);
487
488 if (!pCLSID)
489 return E_POINTER;
490
491 if (!pcItemsFetched && cItemsToFetch > 1)
492 return E_INVALIDARG;
493
494 while (count < cItemsToFetch)
495 {
496 This->index++;
497
498 len = MAX_PATH;
499 ret = RegEnumKeyExW(This->hkey, This->index, szNextKey, &len, NULL, NULL, NULL, NULL);
500 if (ret != ERROR_SUCCESS)
501 {
503 break;
504 }
505
506 if (string_to_guid(szNextKey, &pCLSID[count]) != S_OK)
507 continue;
508
509 TRACE("found %s\n", debugstr_w(szNextKey));
510
511 if (!(This->dwFlags & DMO_ENUMF_INCLUDE_KEYED))
512 {
513 swprintf(path, ARRAY_SIZE(path), L"DirectShow\\MediaObjects\\%s\\Keyed", szNextKey);
515 if (ERROR_SUCCESS == ret)
516 {
517 RegCloseKey(hkey);
518 /* Skip Keyed entries */
519 continue;
520 }
521 }
522
523 swprintf(path, ARRAY_SIZE(path), L"DirectShow\\MediaObjects\\%s", szNextKey);
525 TRACE("Testing %s.\n", debugstr_w(path));
526
527 if (This->pInTypes)
528 {
529 DWORD size, i;
530
531 for (;;)
532 {
533 size = types_size;
534 ret = RegQueryValueExW(hkey, L"InputTypes", NULL, NULL, (BYTE *)types, &size);
536 break;
537 if (size <= types_size)
538 break;
539 if (!array_reserve((void **)&types, &types_size, size, 1))
540 {
541 RegCloseKey(hkey);
542 free(types);
543 return E_OUTOFMEMORY;
544 }
545 }
546 if (ret)
547 {
548 RegCloseKey(hkey);
549 continue;
550 }
551
552 for (i = 0; i < size / sizeof(DMO_PARTIAL_MEDIATYPE); ++i)
553 TRACE("intype %ld: type %s, subtype %s\n", i, debugstr_guid(&types[i].type),
555
556 if (!any_types_match(types, size / sizeof(DMO_PARTIAL_MEDIATYPE), This->pInTypes, This->cInTypes))
557 {
558 RegCloseKey(hkey);
559 continue;
560 }
561 }
562
563 if (This->pOutTypes)
564 {
565 DWORD size = types_size, i;
566
567 for (;;)
568 {
569 size = types_size;
570 ret = RegQueryValueExW(hkey, L"OutputTypes", NULL, NULL, (BYTE *)types, &size);
572 break;
573 if (size <= types_size)
574 break;
575 if (!array_reserve((void **)&types, &types_size, size, 1))
576 {
577 RegCloseKey(hkey);
578 free(types);
579 return E_OUTOFMEMORY;
580 }
581 }
582 if (ret)
583 {
584 RegCloseKey(hkey);
585 continue;
586 }
587
588 for (i = 0; i < size / sizeof(DMO_PARTIAL_MEDIATYPE); ++i)
589 TRACE("outtype %ld: type %s, subtype %s\n", i, debugstr_guid(&types[i].type),
591
592 if (!any_types_match(types, size / sizeof(DMO_PARTIAL_MEDIATYPE), This->pOutTypes, This->cOutTypes))
593 {
594 RegCloseKey(hkey);
595 continue;
596 }
597 }
598
599 /* Media object wasn't filtered so add it to return list */
600 len = MAX_PATH * sizeof(WCHAR);
601 ret = RegQueryValueExW(hkey, NULL, NULL, NULL, (LPBYTE)szValue, &len);
602 if (Names)
603 {
604 Names[count] = NULL;
605 if (ret == ERROR_SUCCESS)
606 {
607 Names[count] = CoTaskMemAlloc((wcslen(szValue) + 1) * sizeof(WCHAR));
608 if (Names[count])
609 wcscpy(Names[count], szValue);
610 }
611 }
612
613 TRACE("found match %s %s\n", debugstr_w(szValue), debugstr_w(szNextKey));
614 RegCloseKey(hkey);
615 count++;
616 }
617
618 free(types);
619
620 if (pcItemsFetched) *pcItemsFetched = count;
621 if (count < cItemsToFetch)
622 hres = S_FALSE;
623
624 TRACE("<-- %i found\n",count);
625 return hres;
626}
PWSTR Names[]
#define free
Definition: debug_ros.c:5
#define ERROR_SUCCESS
Definition: deptool.c:10
void *WINAPI CoTaskMemAlloc(SIZE_T size)
Definition: malloc.c:381
static BOOL any_types_match(const DMO_PARTIAL_MEDIATYPE *a, unsigned int a_count, const DMO_PARTIAL_MEDIATYPE *b, unsigned int b_count)
Definition: dmoreg.c:447
static HRESULT string_to_guid(const WCHAR *string, GUID *guid)
Definition: dmoreg.c:94
BOOL array_reserve(void **elements, unsigned int *capacity, unsigned int count, unsigned int size)
Definition: dmoreg.c:35
@ DMO_ENUMF_INCLUDE_KEYED
Definition: dmoreg.h:37
unsigned int UINT
Definition: sysinfo.c:13
wcscpy
#define E_POINTER
Definition: winerror.h:3480

◆ IEnumDMO_fnQueryInterface()

static HRESULT WINAPI IEnumDMO_fnQueryInterface ( IEnumDMO *  iface,
REFIID  riid,
void **  ppvObj 
)
static

Definition at line 408 of file dmoreg.c.

409{
411
412 TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppvObj);
413
414 *ppvObj = NULL;
415
416 if (IsEqualIID(riid, &IID_IEnumDMO) ||
418 {
419 *ppvObj = iface;
420 IEnumDMO_AddRef(iface);
421 }
422
423 return *ppvObj ? S_OK : E_NOINTERFACE;
424}
const GUID IID_IUnknown
REFIID riid
Definition: atlbase.h:39
#define IsEqualIID(riid1, riid2)
Definition: guiddef.h:95
#define E_NOINTERFACE
Definition: winerror.h:3479

◆ IEnumDMO_fnRelease()

static ULONG WINAPI IEnumDMO_fnRelease ( IEnumDMO *  iface)
static

Definition at line 429 of file dmoreg.c.

430{
432 ULONG refCount = InterlockedDecrement(&This->ref);
433
434 TRACE("(%p)->(%ld)\n", This, refCount);
435
436 if (!refCount)
437 {
438 if (This->hkey)
439 RegCloseKey(This->hkey);
440 HeapFree(GetProcessHeap(), 0, This->pInTypes);
441 HeapFree(GetProcessHeap(), 0, This->pOutTypes);
443 }
444 return refCount;
445}
#define InterlockedDecrement
Definition: armddk.h:52
#define HeapFree(x, y, z)
Definition: compat.h:735

◆ IEnumDMO_fnReset()

static HRESULT WINAPI IEnumDMO_fnReset ( IEnumDMO *  iface)
static

Definition at line 646 of file dmoreg.c.

647{
649
650 TRACE("(%p)\n", This);
651 This->index = -1;
652
653 return S_OK;
654}

◆ IEnumDMO_fnSkip()

static HRESULT WINAPI IEnumDMO_fnSkip ( IEnumDMO *  iface,
DWORD  cItemsToSkip 
)
static

Definition at line 632 of file dmoreg.c.

633{
635
636 TRACE("(%p)->(%ld)\n", This, cItemsToSkip);
637 This->index += cItemsToSkip;
638
639 return S_OK;
640}

◆ impl_from_IEnumDMO()

static IEnumDMOImpl * impl_from_IEnumDMO ( IEnumDMO *  iface)
inlinestatic

Definition at line 78 of file dmoreg.c.

79{
80 return CONTAINING_RECORD(iface, IEnumDMOImpl, IEnumDMO_iface);
81}
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260

Referenced by IEnumDMO_fnAddRef(), IEnumDMO_fnClone(), IEnumDMO_fnNext(), IEnumDMO_fnQueryInterface(), IEnumDMO_fnRelease(), IEnumDMO_fnReset(), and IEnumDMO_fnSkip().

◆ IsMediaTypeEqual()

static BOOL IsMediaTypeEqual ( const DMO_PARTIAL_MEDIATYPE *  mt1,
const DMO_PARTIAL_MEDIATYPE *  mt2 
)
static

Definition at line 104 of file dmoreg.c.

105{
106
107 return (IsEqualCLSID(&mt1->type, &mt2->type) ||
108 IsEqualCLSID(&mt2->type, &GUID_NULL) ||
109 IsEqualCLSID(&mt1->type, &GUID_NULL)) &&
110 (IsEqualCLSID(&mt1->subtype, &mt2->subtype) ||
111 IsEqualCLSID(&mt2->subtype, &GUID_NULL) ||
113}
#define IsEqualCLSID(rclsid1, rclsid2)
Definition: guiddef.h:96

Referenced by any_types_match().

◆ string_to_guid()

static HRESULT string_to_guid ( const WCHAR *  string,
GUID *  guid 
)
static

Definition at line 94 of file dmoreg.c.

95{
96 WCHAR buffer[39];
97 buffer[0] = '{';
98 wcscpy(buffer + 1, string);
99 buffer[37] = '}';
100 buffer[38] = 0;
101 return CLSIDFromString(buffer, guid);
102}
HRESULT WINAPI CLSIDFromString(LPCOLESTR str, LPCLSID clsid)
Definition: combase.c:1470
GLuint buffer
Definition: glext.h:5915

Referenced by IEnumDMO_fnNext().

◆ unregister_dmo_from_category()

static HRESULT unregister_dmo_from_category ( const WCHAR *  dmoW,
const WCHAR *  catW,
HKEY  categories 
)
static

Definition at line 211 of file dmoreg.c.

212{
213 HKEY catkey;
214 LONG ret;
215
216 ret = RegOpenKeyExW(categories, catW, 0, KEY_WRITE, &catkey);
217 if (!ret)
218 {
219 ret = RegDeleteKeyW(catkey, dmoW);
220 RegCloseKey(catkey);
221 }
222
223 return !ret ? S_OK : S_FALSE;
224}
GLsizei GLenum * categories
Definition: glext.h:11561

Referenced by DMOUnregister().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( msdmo  )

◆ write_types()

static HRESULT write_types ( HKEY  hkey,
LPCWSTR  name,
const DMO_PARTIAL_MEDIATYPE *  types,
DWORD  count 
)
static

Definition at line 115 of file dmoreg.c.

116{
118 (const BYTE *)types, count * sizeof(DMO_PARTIAL_MEDIATYPE)));
119}
#define REG_BINARY
Definition: nt_native.h:1499

Referenced by DMORegister().

Variable Documentation

◆ edmovt

static const IEnumDMOVtbl edmovt
static
Initial value:
=
{
}
static HRESULT WINAPI IEnumDMO_fnNext(IEnumDMO *iface, DWORD cItemsToFetch, CLSID *pCLSID, WCHAR **Names, DWORD *pcItemsFetched)
Definition: dmoreg.c:466
static HRESULT WINAPI IEnumDMO_fnClone(IEnumDMO *iface, IEnumDMO **ppEnum)
Definition: dmoreg.c:660
static HRESULT WINAPI IEnumDMO_fnReset(IEnumDMO *iface)
Definition: dmoreg.c:646
static HRESULT WINAPI IEnumDMO_fnQueryInterface(IEnumDMO *iface, REFIID riid, void **ppvObj)
Definition: dmoreg.c:408
static HRESULT WINAPI IEnumDMO_fnSkip(IEnumDMO *iface, DWORD cItemsToSkip)
Definition: dmoreg.c:632
static ULONG WINAPI IEnumDMO_fnRelease(IEnumDMO *iface)
Definition: dmoreg.c:429
static ULONG WINAPI IEnumDMO_fnAddRef(IEnumDMO *iface)
Definition: dmoreg.c:397

Definition at line 83 of file dmoreg.c.

Referenced by IEnumDMO_Constructor().