Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
f49fc4c7
Commit
f49fc4c7
authored
Mar 06, 2018
by
Zebediah Figura
Committed by
Alexandre Julliard
Mar 07, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
devenum: Allow parsing display name without class ID.
Signed-off-by:
Zebediah Figura
<
z.figura12@gmail.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
f5c531bd
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
90 additions
and
51 deletions
+90
-51
devenum_private.h
dlls/devenum/devenum_private.h
+5
-0
mediacatenum.c
dlls/devenum/mediacatenum.c
+3
-0
parsedisplayname.c
dlls/devenum/parsedisplayname.c
+45
-51
devenum.c
dlls/devenum/tests/devenum.c
+37
-0
No files found.
dlls/devenum/devenum_private.h
View file @
f49fc4c7
...
...
@@ -71,6 +71,10 @@ typedef struct
IMoniker
IMoniker_iface
;
LONG
ref
;
HKEY
hkey
;
CLSID
class
;
BOOL
has_class
;
enum
device_type
type
;
WCHAR
*
name
;
}
MediaCatMoniker
;
MediaCatMoniker
*
DEVENUM_IMediaCatMoniker_Construct
(
void
)
DECLSPEC_HIDDEN
;
...
...
@@ -84,6 +88,7 @@ extern IParseDisplayName DEVENUM_ParseDisplayName DECLSPEC_HIDDEN;
* Global string constant declarations
*/
static
const
WCHAR
backslashW
[]
=
{
'\\'
,
0
};
static
const
WCHAR
clsidW
[]
=
{
'C'
,
'L'
,
'S'
,
'I'
,
'D'
,
'\\'
,
0
};
static
const
WCHAR
instanceW
[]
=
{
'\\'
,
'I'
,
'n'
,
's'
,
't'
,
'a'
,
'n'
,
'c'
,
'e'
,
0
};
static
const
WCHAR
wszActiveMovieKey
[]
=
{
'S'
,
'o'
,
'f'
,
't'
,
'w'
,
'a'
,
'r'
,
'e'
,
'\\'
,
...
...
dlls/devenum/mediacatenum.c
View file @
f49fc4c7
...
...
@@ -345,6 +345,7 @@ static ULONG WINAPI DEVENUM_IMediaCatMoniker_Release(IMoniker *iface)
if
(
ref
==
0
)
{
RegCloseKey
(
This
->
hkey
);
CoTaskMemFree
(
This
->
name
);
CoTaskMemFree
(
This
);
DEVENUM_UnlockModule
();
}
...
...
@@ -695,6 +696,8 @@ MediaCatMoniker * DEVENUM_IMediaCatMoniker_Construct(void)
pMoniker
->
IMoniker_iface
.
lpVtbl
=
&
IMoniker_Vtbl
;
pMoniker
->
ref
=
0
;
pMoniker
->
hkey
=
NULL
;
pMoniker
->
has_class
=
FALSE
;
pMoniker
->
name
=
NULL
;
DEVENUM_IMediaCatMoniker_AddRef
(
&
pMoniker
->
IMoniker_iface
);
...
...
dlls/devenum/parsedisplayname.c
View file @
f49fc4c7
...
...
@@ -76,87 +76,81 @@ static ULONG WINAPI DEVENUM_IParseDisplayName_Release(IParseDisplayName *iface)
* not in "@device:sw:{CLSID1}\<filter name or CLSID>" format
*/
static
HRESULT
WINAPI
DEVENUM_IParseDisplayName_ParseDisplayName
(
IParseDisplayName
*
iface
,
IBindCtx
*
pbc
,
LPOLESTR
pszDisplayName
,
ULONG
*
pchEaten
,
IMoniker
**
ppmkOu
t
)
IBindCtx
*
pbc
,
LPOLESTR
name
,
ULONG
*
eaten
,
IMoniker
**
re
t
)
{
LPOLESTR
pszBetween
=
NULL
;
LPOLESTR
pszClass
=
NULL
;
MediaCatMoniker
*
pMoniker
=
NULL
;
CLSID
clsidDevice
;
HRESULT
hr
=
S_OK
;
WCHAR
wszRegKeyName
[
MAX_PATH
];
WCHAR
buffer
[
MAX_PATH
];
enum
device_type
type
;
MediaCatMoniker
*
mon
;
HKEY
hbasekey
;
int
classlen
;
LONG
res
;
static
const
WCHAR
wszRegSeparator
[]
=
{
'\\'
,
0
};
CLSID
class
;
LRESULT
res
;
TRACE
(
"(%p, %s, %p, %p)
\n
"
,
pbc
,
debugstr_w
(
pszDisplayName
),
pchEaten
,
ppmkOu
t
);
TRACE
(
"(%p, %s, %p, %p)
\n
"
,
pbc
,
debugstr_w
(
name
),
eaten
,
re
t
);
*
ppmkOu
t
=
NULL
;
if
(
pchE
aten
)
*
pchEaten
=
strlenW
(
pszDisplayN
ame
);
*
re
t
=
NULL
;
if
(
e
aten
)
*
eaten
=
strlenW
(
n
ame
);
pszDisplayName
=
strchrW
(
pszDisplayName
,
':'
)
+
1
;
if
(
pszDisplayName
[
0
]
==
's'
&&
pszDisplayName
[
1
]
==
'w'
&&
pszDisplayName
[
2
]
==
':'
)
name
=
strchrW
(
name
,
':'
)
+
1
;
if
(
name
[
0
]
==
's'
&&
name
[
1
]
==
'w'
&&
name
[
2
]
==
':'
)
{
type
=
DEVICE_FILTER
;
if
((
res
=
RegOpenKeyExW
(
HKEY_CLASSES_ROOT
,
clsidW
,
0
,
0
,
&
hbasekey
)))
return
HRESULT_FROM_WIN32
(
res
);
name
+=
3
;
}
else
if
(
pszDisplayName
[
0
]
==
'c'
&&
pszDisplayName
[
1
]
==
'm'
&&
pszDisplayN
ame
[
2
]
==
':'
)
else
if
(
name
[
0
]
==
'c'
&&
name
[
1
]
==
'm'
&&
n
ame
[
2
]
==
':'
)
{
type
=
DEVICE_CODEC
;
if
((
res
=
RegOpenKeyExW
(
HKEY_CURRENT_USER
,
wszActiveMovieKey
,
0
,
0
,
&
hbasekey
)))
return
HRESULT_FROM_WIN32
(
res
);
name
+=
3
;
}
else
{
FIXME
(
"unhandled device type %s
\n
"
,
debugstr_w
(
pszDisplayName
+
1
));
FIXME
(
"unhandled device type %s
\n
"
,
debugstr_w
(
name
));
return
MK_E_SYNTAX
;
}
pszDisplayName
=
strchrW
(
pszDisplayName
,
'{'
);
pszBetween
=
strchrW
(
pszDisplayName
,
'}'
)
+
2
;
/* size = pszBetween - pszDisplayName - 1 (for '\\' after CLSID)
* + 1 (for NULL character)
*/
classlen
=
(
int
)(
pszBetween
-
pszDisplayName
-
1
);
pszClass
=
CoTaskMemAlloc
((
classlen
+
1
)
*
sizeof
(
WCHAR
));
if
(
!
pszClass
)
if
(
!
(
mon
=
DEVENUM_IMediaCatMoniker_Construct
()))
return
E_OUTOFMEMORY
;
memcpy
(
pszClass
,
pszDisplayName
,
classlen
*
sizeof
(
WCHAR
));
pszClass
[
classlen
]
=
0
;
TRACE
(
"Device CLSID: %s
\n
"
,
debugstr_w
(
pszClass
));
lstrcpynW
(
buffer
,
name
,
CHARS_IN_GUID
);
if
(
CLSIDFromString
(
buffer
,
&
class
)
==
S_OK
)
{
mon
->
has_class
=
TRUE
;
mon
->
class
=
class
;
name
+=
CHARS_IN_GUID
;
}
hr
=
CLSIDFromString
(
pszClass
,
&
clsidDevice
)
;
mon
->
type
=
type
;
if
(
SUCCEEDED
(
hr
))
{
pMoniker
=
DEVENUM_IMediaCatMoniker_Construct
();
if
(
pMoniker
)
{
strcpyW
(
wszRegKeyName
,
pszClass
);
if
(
type
==
DEVICE_FILTER
)
strcatW
(
wszRegKeyName
,
instanceW
);
strcatW
(
wszRegKeyName
,
wszRegSeparator
);
strcatW
(
wszRegKeyName
,
pszBetween
);
if
(
RegCreateKeyW
(
hbasekey
,
wszRegKeyName
,
&
pMoniker
->
hkey
)
==
ERROR_SUCCESS
)
*
ppmkOut
=
&
pMoniker
->
IMoniker_iface
;
else
if
(
!
(
mon
->
name
=
CoTaskMemAlloc
((
strlenW
(
name
)
+
1
)
*
sizeof
(
WCHAR
))))
{
IMoniker_Release
(
&
pMoniker
->
IMoniker_iface
);
hr
=
MK_E_NOOBJECT
;
}
IMoniker_Release
(
&
mon
->
IMoniker_iface
);
return
E_OUTOFMEMORY
;
}
strcpyW
(
mon
->
name
,
name
);
buffer
[
0
]
=
0
;
if
(
mon
->
has_class
)
{
StringFromGUID2
(
&
mon
->
class
,
buffer
,
CHARS_IN_GUID
);
if
(
mon
->
type
==
DEVICE_FILTER
)
strcatW
(
buffer
,
instanceW
);
strcatW
(
buffer
,
backslashW
);
}
strcatW
(
buffer
,
mon
->
name
);
CoTaskMemFree
(
pszClass
);
if
(
RegCreateKeyW
(
hbasekey
,
buffer
,
&
mon
->
hkey
))
{
IMoniker_Release
(
&
mon
->
IMoniker_iface
);
return
MK_E_NOOBJECT
;
}
*
ret
=
&
mon
->
IMoniker_iface
;
TRACE
(
"-- returning: %x
\n
"
,
hr
);
return
hr
;
return
S_OK
;
}
/**********************************************************************
...
...
dlls/devenum/tests/devenum.c
View file @
f49fc4c7
...
...
@@ -365,6 +365,43 @@ static void test_directshow_filter(void)
VariantClear
(
&
var
);
IPropertyBag_Release
(
prop_bag
);
/* name can be anything */
lstrcpyW
(
buffer
,
deviceW
);
lstrcatW
(
buffer
,
testW
+
1
);
mon
=
check_display_name
(
parser
,
buffer
);
hr
=
IMoniker_BindToStorage
(
mon
,
NULL
,
NULL
,
&
IID_IPropertyBag
,
(
void
**
)
&
prop_bag
);
ok
(
hr
==
S_OK
,
"BindToStorage failed: %#x
\n
"
,
hr
);
VariantClear
(
&
var
);
hr
=
IPropertyBag_Read
(
prop_bag
,
friendly_name
,
&
var
,
NULL
);
ok
(
hr
==
HRESULT_FROM_WIN32
(
ERROR_FILE_NOT_FOUND
),
"got %#x
\n
"
,
hr
);
V_VT
(
&
var
)
=
VT_BSTR
;
V_BSTR
(
&
var
)
=
SysAllocString
(
testW
);
hr
=
IPropertyBag_Write
(
prop_bag
,
friendly_name
,
&
var
);
if
(
hr
!=
E_ACCESSDENIED
)
{
ok
(
hr
==
S_OK
,
"Write failed: %#x
\n
"
,
hr
);
VariantClear
(
&
var
);
hr
=
IPropertyBag_Read
(
prop_bag
,
friendly_name
,
&
var
,
NULL
);
ok
(
hr
==
S_OK
,
"Read failed: %#x
\n
"
,
hr
);
ok
(
!
lstrcmpW
(
V_BSTR
(
&
var
),
testW
),
"got %s
\n
"
,
wine_dbgstr_w
(
V_BSTR
(
&
var
)));
IMoniker_Release
(
mon
);
/* vista+ stores it inside the Instance key */
RegDeleteKeyA
(
HKEY_CLASSES_ROOT
,
"CLSID
\\
test
\\
Instance"
);
res
=
RegDeleteKeyA
(
HKEY_CLASSES_ROOT
,
"CLSID
\\
test"
);
ok
(
!
res
,
"RegDeleteKey failed: %lu
\n
"
,
res
);
}
VariantClear
(
&
var
);
IPropertyBag_Release
(
prop_bag
);
IParseDisplayName_Release
(
parser
);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment