Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
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-cw
Commits
42f51185
Commit
42f51185
authored
Jun 13, 2014
by
Andrew Eikum
Committed by
Alexandre Julliard
Jun 16, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ole32: Implement CoTreatAsClass for classes without AutoTreatAs.
parent
be583662
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
59 additions
and
8 deletions
+59
-8
compobj.c
dlls/ole32/compobj.c
+20
-6
compobj.c
dlls/ole32/tests/compobj.c
+39
-2
No files found.
dlls/ole32/compobj.c
View file @
42f51185
...
...
@@ -3731,7 +3731,8 @@ HRESULT WINAPI CoTreatAsClass(REFCLSID clsidOld, REFCLSID clsidNew)
res
=
COM_OpenKeyForCLSID
(
clsidOld
,
NULL
,
KEY_READ
|
KEY_WRITE
,
&
hkey
);
if
(
FAILED
(
res
))
goto
done
;
if
(
!
memcmp
(
clsidOld
,
clsidNew
,
sizeof
(
*
clsidOld
)
))
if
(
IsEqualGUID
(
clsidOld
,
clsidNew
))
{
if
(
!
RegQueryValueW
(
hkey
,
wszAutoTreatAs
,
auto_treat_as
,
&
auto_treat_as_size
)
&&
CLSIDFromString
(
auto_treat_as
,
&
id
)
==
S_OK
)
...
...
@@ -3744,15 +3745,28 @@ HRESULT WINAPI CoTreatAsClass(REFCLSID clsidOld, REFCLSID clsidNew)
}
else
{
RegDeleteKeyW
(
hkey
,
wszTreatAs
);
if
(
RegDeleteKeyW
(
hkey
,
wszTreatAs
))
res
=
REGDB_E_WRITEREGDB
;
goto
done
;
}
}
else
if
(
!
StringFromGUID2
(
clsidNew
,
szClsidNew
,
ARRAYSIZE
(
szClsidNew
))
&&
!
RegSetValueW
(
hkey
,
wszTreatAs
,
REG_SZ
,
szClsidNew
,
sizeof
(
szClsidNew
)))
else
{
res
=
REGDB_E_WRITEREGDB
;
goto
done
;
if
(
IsEqualGUID
(
clsidNew
,
&
CLSID_NULL
)){
RegDeleteKeyW
(
hkey
,
wszTreatAs
);
}
else
{
if
(
!
StringFromGUID2
(
clsidNew
,
szClsidNew
,
ARRAYSIZE
(
szClsidNew
))){
WARN
(
"StringFromGUID2 failed
\n
"
);
res
=
E_FAIL
;
goto
done
;
}
if
(
RegSetValueW
(
hkey
,
wszTreatAs
,
REG_SZ
,
szClsidNew
,
sizeof
(
szClsidNew
))
!=
ERROR_SUCCESS
){
WARN
(
"RegSetValue failed
\n
"
);
res
=
REGDB_E_WRITEREGDB
;
goto
done
;
}
}
}
done:
...
...
dlls/ole32/tests/compobj.c
View file @
42f51185
...
...
@@ -41,6 +41,7 @@ static HRESULT (WINAPI * pCoInitializeEx)(LPVOID lpReserved, DWORD dwCoInit);
static
HRESULT
(
WINAPI
*
pCoGetObjectContext
)(
REFIID
riid
,
LPVOID
*
ppv
);
static
HRESULT
(
WINAPI
*
pCoSwitchCallContext
)(
IUnknown
*
pObject
,
IUnknown
**
ppOldObject
);
static
HRESULT
(
WINAPI
*
pCoGetTreatAsClass
)(
REFCLSID
clsidOld
,
LPCLSID
pClsidNew
);
static
HRESULT
(
WINAPI
*
pCoTreatAsClass
)(
REFCLSID
clsidOld
,
REFCLSID
pClsidNew
);
static
HRESULT
(
WINAPI
*
pCoGetContextToken
)(
ULONG_PTR
*
token
);
static
LONG
(
WINAPI
*
pRegOverridePredefKey
)(
HKEY
key
,
HKEY
override
);
...
...
@@ -1896,11 +1897,14 @@ static void test_CoGetContextToken(void)
CoUninitialize
();
}
static
void
test_
CoGet
TreatAsClass
(
void
)
static
void
test_TreatAsClass
(
void
)
{
HRESULT
hr
;
CLSID
out
;
static
GUID
deadbeef
=
{
0xdeadbeef
,
0xdead
,
0xbeef
,{
0xde
,
0xad
,
0xbe
,
0xef
,
0xde
,
0xad
,
0xbe
,
0xef
}};
static
const
char
deadbeefA
[]
=
"{DEADBEEF-DEAD-BEEF-DEAD-BEEFDEADBEEF}"
;
HKEY
clsidkey
,
deadbeefkey
;
LONG
lr
;
if
(
!
pCoGetTreatAsClass
)
{
...
...
@@ -1910,6 +1914,38 @@ static void test_CoGetTreatAsClass(void)
hr
=
pCoGetTreatAsClass
(
&
deadbeef
,
&
out
);
ok
(
hr
==
S_FALSE
,
"expected S_FALSE got %x
\n
"
,
hr
);
ok
(
IsEqualGUID
(
&
out
,
&
deadbeef
),
"expected to get same clsid back
\n
"
);
lr
=
RegOpenKeyExA
(
HKEY_CLASSES_ROOT
,
"CLSID"
,
0
,
KEY_READ
,
&
clsidkey
);
ok
(
lr
==
ERROR_SUCCESS
,
"Couldn't open CLSID key
\n
"
);
lr
=
RegCreateKeyExA
(
clsidkey
,
deadbeefA
,
0
,
NULL
,
0
,
KEY_WRITE
,
NULL
,
&
deadbeefkey
,
NULL
);
ok
(
lr
==
ERROR_SUCCESS
,
"Couldn't create class key
\n
"
);
hr
=
pCoTreatAsClass
(
&
deadbeef
,
&
deadbeef
);
ok
(
hr
==
REGDB_E_WRITEREGDB
,
"CoTreatAsClass gave wrong error: %08x
\n
"
,
hr
);
hr
=
pCoTreatAsClass
(
&
deadbeef
,
&
CLSID_FileProtocol
);
if
(
hr
==
REGDB_E_WRITEREGDB
){
win_skip
(
"Insufficient privileges to use CoTreatAsClass
\n
"
);
goto
exit
;
}
ok
(
hr
==
S_OK
,
"CoTreatAsClass failed: %08x
\n
"
,
hr
);
hr
=
pCoGetTreatAsClass
(
&
deadbeef
,
&
out
);
ok
(
hr
==
S_OK
,
"CoGetTreatAsClass failed: %08x
\n
"
,
hr
);
ok
(
IsEqualGUID
(
&
out
,
&
CLSID_FileProtocol
),
"expected to get substituted clsid
\n
"
);
hr
=
pCoTreatAsClass
(
&
deadbeef
,
&
CLSID_NULL
);
ok
(
hr
==
S_OK
,
"CoTreatAsClass failed: %08x
\n
"
,
hr
);
hr
=
pCoGetTreatAsClass
(
&
deadbeef
,
&
out
);
ok
(
hr
==
S_FALSE
,
"expected S_FALSE got %08x
\n
"
,
hr
);
ok
(
IsEqualGUID
(
&
out
,
&
deadbeef
),
"expected to get same clsid back
\n
"
);
exit:
RegCloseKey
(
deadbeefkey
);
RegDeleteKeyA
(
clsidkey
,
deadbeefA
);
RegCloseKey
(
clsidkey
);
}
static
void
test_CoInitializeEx
(
void
)
...
...
@@ -1994,6 +2030,7 @@ static void init_funcs(void)
pCoGetObjectContext
=
(
void
*
)
GetProcAddress
(
hOle32
,
"CoGetObjectContext"
);
pCoSwitchCallContext
=
(
void
*
)
GetProcAddress
(
hOle32
,
"CoSwitchCallContext"
);
pCoGetTreatAsClass
=
(
void
*
)
GetProcAddress
(
hOle32
,
"CoGetTreatAsClass"
);
pCoTreatAsClass
=
(
void
*
)
GetProcAddress
(
hOle32
,
"CoTreatAsClass"
);
pCoGetContextToken
=
(
void
*
)
GetProcAddress
(
hOle32
,
"CoGetContextToken"
);
pRegOverridePredefKey
=
(
void
*
)
GetProcAddress
(
hAdvapi32
,
"RegOverridePredefKey"
);
pCoInitializeEx
=
(
void
*
)
GetProcAddress
(
hOle32
,
"CoInitializeEx"
);
...
...
@@ -2038,7 +2075,7 @@ START_TEST(compobj)
test_CoGetObjectContext
();
test_CoGetCallContext
();
test_CoGetContextToken
();
test_
CoGet
TreatAsClass
();
test_TreatAsClass
();
test_CoInitializeEx
();
test_OleRegGetMiscStatus
();
test_CoCreateGuid
();
...
...
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