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
bfe01809
Commit
bfe01809
authored
May 04, 2023
by
Shaun Ren
Committed by
Alexandre Julliard
May 05, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
sapi: Implement ISpObjectToken::CreateInstance.
parent
26d60533
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
182 additions
and
2 deletions
+182
-2
token.c
dlls/sapi/tests/token.c
+149
-0
token.c
dlls/sapi/token.c
+33
-2
No files found.
dlls/sapi/tests/token.c
View file @
bfe01809
...
...
@@ -268,13 +268,117 @@ static void tests_token_voices(void)
IEnumSpObjectTokens_Release
(
tokens
);
}
#define TESTCLASS_CLSID L"{67DD26B6-50BA-3297-253E-619346F177F8}"
static
const
GUID
CLSID_TestClass
=
{
0x67DD26B6
,
0x50BA
,
0x3297
,{
0x25
,
0x3E
,
0x61
,
0x93
,
0x46
,
0xF1
,
0x77
,
0xF8
}};
static
ISpObjectToken
*
test_class_token
;
static
HRESULT
WINAPI
test_class_QueryInterface
(
ISpObjectWithToken
*
iface
,
REFIID
riid
,
void
**
ppv
)
{
if
(
IsEqualGUID
(
riid
,
&
IID_IUnknown
)
||
IsEqualGUID
(
riid
,
&
IID_ISpObjectWithToken
))
{
*
ppv
=
iface
;
return
S_OK
;
}
*
ppv
=
NULL
;
return
E_NOINTERFACE
;
}
static
ULONG
WINAPI
test_class_AddRef
(
ISpObjectWithToken
*
iface
)
{
return
2
;
}
static
ULONG
WINAPI
test_class_Release
(
ISpObjectWithToken
*
iface
)
{
return
1
;
}
static
HRESULT
WINAPI
test_class_SetObjectToken
(
ISpObjectWithToken
*
iface
,
ISpObjectToken
*
token
)
{
ok
(
token
!=
NULL
,
"token == NULL
\n
"
);
test_class_token
=
token
;
ISpObjectToken_AddRef
(
test_class_token
);
return
S_OK
;
}
static
HRESULT
WINAPI
test_class_GetObjectToken
(
ISpObjectWithToken
*
iface
,
ISpObjectToken
**
token
)
{
ok
(
0
,
"unexpected call
\n
"
);
return
E_NOTIMPL
;
}
static
const
ISpObjectWithTokenVtbl
test_class_vtbl
=
{
test_class_QueryInterface
,
test_class_AddRef
,
test_class_Release
,
test_class_SetObjectToken
,
test_class_GetObjectToken
};
static
ISpObjectWithToken
test_class
=
{
&
test_class_vtbl
};
static
HRESULT
WINAPI
ClassFactory_QueryInterface
(
IClassFactory
*
iface
,
REFIID
riid
,
void
**
ppv
)
{
if
(
IsEqualGUID
(
&
IID_IUnknown
,
riid
)
||
IsEqualGUID
(
&
IID_IClassFactory
,
riid
))
{
*
ppv
=
iface
;
return
S_OK
;
}
*
ppv
=
NULL
;
return
E_NOINTERFACE
;
}
static
ULONG
WINAPI
ClassFactory_AddRef
(
IClassFactory
*
iface
)
{
return
2
;
}
static
ULONG
WINAPI
ClassFactory_Release
(
IClassFactory
*
iface
)
{
return
1
;
}
static
HRESULT
WINAPI
ClassFactory_CreateInstance
(
IClassFactory
*
iface
,
IUnknown
*
pUnkOuter
,
REFIID
riid
,
void
**
ppv
)
{
ok
(
pUnkOuter
==
NULL
,
"pUnkOuter != NULL
\n
"
);
ok
(
IsEqualGUID
(
riid
,
&
IID_IUnknown
),
"riid = %s
\n
"
,
wine_dbgstr_guid
(
riid
)
);
*
ppv
=
&
test_class
;
return
S_OK
;
}
static
HRESULT
WINAPI
ClassFactory_LockServer
(
IClassFactory
*
iface
,
BOOL
fLock
)
{
ok
(
0
,
"unexpected call
\n
"
);
return
E_NOTIMPL
;
}
static
const
IClassFactoryVtbl
ClassFactoryVtbl
=
{
ClassFactory_QueryInterface
,
ClassFactory_AddRef
,
ClassFactory_Release
,
ClassFactory_CreateInstance
,
ClassFactory_LockServer
};
static
IClassFactory
test_class_cf
=
{
&
ClassFactoryVtbl
};
static
void
test_object_token
(
void
)
{
static
const
WCHAR
test_token_id
[]
=
L"HKEY_CURRENT_USER
\\
Software
\\
Winetest
\\
sapi
\\
TestToken"
;
ISpObjectToken
*
token
;
ISpDataKey
*
sub_key
;
HRESULT
hr
;
LPWSTR
tempW
,
token_id
;
ISpObjectTokenCategory
*
cat
;
DWORD
regid
;
IUnknown
*
obj
;
hr
=
CoCreateInstance
(
&
CLSID_SpObjectToken
,
NULL
,
CLSCTX_INPROC_SERVER
,
&
IID_ISpObjectToken
,
(
void
**
)
&
token
);
...
...
@@ -397,6 +501,51 @@ static void test_object_token(void)
ISpObjectTokenCategory_Release
(
cat
);
}
hr
=
CoRegisterClassObject
(
&
CLSID_TestClass
,
(
IUnknown
*
)
&
test_class_cf
,
CLSCTX_INPROC_SERVER
,
REGCLS_MULTIPLEUSE
,
&
regid
);
ok
(
hr
==
S_OK
,
"got %08lx
\n
"
,
hr
);
ISpObjectToken_Release
(
token
);
hr
=
CoCreateInstance
(
&
CLSID_SpObjectToken
,
NULL
,
CLSCTX_INPROC_SERVER
,
&
IID_ISpObjectToken
,
(
void
**
)
&
token
);
ok
(
hr
==
S_OK
,
"got %08lx
\n
"
,
hr
);
hr
=
ISpObjectToken_SetId
(
token
,
NULL
,
test_token_id
,
TRUE
);
ok
(
hr
==
S_OK
,
"got %08lx
\n
"
,
hr
);
hr
=
ISpObjectToken_SetStringValue
(
token
,
L"CLSID"
,
TESTCLASS_CLSID
);
ok
(
hr
==
S_OK
,
"got %08lx
\n
"
,
hr
);
tempW
=
NULL
;
hr
=
ISpObjectToken_GetStringValue
(
token
,
L"CLSID"
,
&
tempW
);
ok
(
hr
==
S_OK
,
"got %08lx
\n
"
,
hr
);
if
(
tempW
)
{
ok
(
!
wcsncmp
(
tempW
,
TESTCLASS_CLSID
,
wcslen
(
TESTCLASS_CLSID
)
),
"got %s (expected %s)
\n
"
,
wine_dbgstr_w
(
tempW
),
wine_dbgstr_w
(
TESTCLASS_CLSID
)
);
CoTaskMemFree
(
tempW
);
}
test_class_token
=
NULL
;
hr
=
ISpObjectToken_CreateInstance
(
token
,
NULL
,
CLSCTX_INPROC_SERVER
,
&
IID_IUnknown
,
(
void
**
)
&
obj
);
if
(
hr
==
E_ACCESSDENIED
)
{
win_skip
(
"ISpObjectToken_CreateInstance returned E_ACCESSDENIED
\n
"
);
return
;
}
ok
(
hr
==
S_OK
,
"got %08lx
\n
"
,
hr
);
ok
(
test_class_token
!=
NULL
,
"test_class_token not set
\n
"
);
tempW
=
NULL
;
hr
=
ISpObjectToken_GetId
(
test_class_token
,
&
tempW
);
ok
(
tempW
!=
NULL
,
"got %p
\n
"
,
tempW
);
if
(
tempW
)
{
ok
(
!
wcsncmp
(
tempW
,
test_token_id
,
wcslen
(
test_token_id
)),
"got %s (expected %s)
\n
"
,
wine_dbgstr_w
(
tempW
),
wine_dbgstr_w
(
test_token_id
)
);
CoTaskMemFree
(
tempW
);
}
ISpObjectToken_Release
(
test_class_token
);
IUnknown_Release
(
obj
);
ISpObjectToken_Release
(
token
);
}
...
...
dlls/sapi/token.c
View file @
bfe01809
...
...
@@ -1227,8 +1227,39 @@ static HRESULT WINAPI token_CreateInstance( ISpObjectToken *iface,
REFIID
riid
,
void
**
object
)
{
FIXME
(
"stub
\n
"
);
return
E_NOTIMPL
;
WCHAR
*
clsid_str
;
CLSID
clsid
;
IUnknown
*
unk
;
ISpObjectWithToken
*
obj_token_iface
;
HRESULT
hr
;
TRACE
(
"%p, %p, %#lx, %s, %p
\n
"
,
iface
,
outer
,
class_context
,
debugstr_guid
(
riid
),
object
);
if
(
FAILED
(
hr
=
ISpObjectToken_GetStringValue
(
iface
,
L"CLSID"
,
&
clsid_str
)))
return
hr
;
hr
=
CLSIDFromString
(
clsid_str
,
&
clsid
);
CoTaskMemFree
(
clsid_str
);
if
(
FAILED
(
hr
))
return
hr
;
if
(
FAILED
(
hr
=
CoCreateInstance
(
&
clsid
,
outer
,
class_context
,
&
IID_IUnknown
,
(
void
**
)
&
unk
)))
return
hr
;
/* Call ISpObjectWithToken::SetObjectToken if the interface is available. */
if
(
SUCCEEDED
(
IUnknown_QueryInterface
(
unk
,
&
IID_ISpObjectWithToken
,
(
void
**
)
&
obj_token_iface
)))
{
hr
=
ISpObjectWithToken_SetObjectToken
(
obj_token_iface
,
iface
);
ISpObjectWithToken_Release
(
obj_token_iface
);
if
(
FAILED
(
hr
))
goto
done
;
}
hr
=
IUnknown_QueryInterface
(
unk
,
riid
,
object
);
done:
IUnknown_Release
(
unk
);
return
hr
;
}
static
HRESULT
WINAPI
token_GetStorageFileName
(
ISpObjectToken
*
iface
,
...
...
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