ole32: Implement semi-stub for CoGetApartmentType.

Signed-off-by: Michael Müller <michael@fds-team.de>
Signed-off-by: Sebastian Lackner <sebastian@fds-team.de>
Signed-off-by: Huw Davies <huw@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Michael Müller 2016-03-02 16:19:53 +01:00 committed by Alexandre Julliard
parent c63d417222
commit 381ce2956b
9 changed files with 100 additions and 4 deletions

View File

@ -17,7 +17,7 @@
@ stub CoEnableCallCancellation
@ stdcall CoFreeUnusedLibraries() ole32.CoFreeUnusedLibraries
@ stdcall CoFreeUnusedLibrariesEx(long long) ole32.CoFreeUnusedLibrariesEx
@ stub CoGetApartmentType
@ stdcall CoGetApartmentType(ptr ptr) ole32.CoGetApartmentType
@ stdcall CoGetCallContext(ptr ptr) ole32.CoGetCallContext
@ stdcall CoGetCallerTID(ptr) ole32.CoGetCallerTID
@ stub CoGetCancelObject

View File

@ -17,7 +17,7 @@
@ stub CoEnableCallCancellation
@ stdcall CoFreeUnusedLibraries() ole32.CoFreeUnusedLibraries
@ stdcall CoFreeUnusedLibrariesEx(long long) ole32.CoFreeUnusedLibrariesEx
@ stub CoGetApartmentType
@ stdcall CoGetApartmentType(ptr ptr) ole32.CoGetApartmentType
@ stdcall CoGetCallContext(ptr ptr) ole32.CoGetCallContext
@ stdcall CoGetCallerTID(ptr) ole32.CoGetCallerTID
@ stub CoGetCancelObject

View File

@ -8,7 +8,7 @@
@ stdcall CoDisconnectObject(ptr long) ole32.CoDisconnectObject
@ stdcall CoFreeUnusedLibraries() ole32.CoFreeUnusedLibraries
@ stdcall CoFreeUnusedLibrariesEx(long long) ole32.CoFreeUnusedLibrariesEx
@ stub CoGetApartmentType
@ stdcall CoGetApartmentType(ptr ptr) ole32.CoGetApartmentType
@ stdcall CoGetClassObject(ptr long ptr ptr ptr) ole32.CoGetClassObject
@ stdcall CoGetCurrentLogicalThreadId(ptr) ole32.CoGetCurrentLogicalThreadId
@ stdcall CoGetInterfaceAndReleaseStream(ptr ptr ptr) ole32.CoGetInterfaceAndReleaseStream

View File

@ -90,7 +90,7 @@
@ stdcall CoFreeUnusedLibrariesEx(long long) ole32.CoFreeUnusedLibrariesEx
@ stdcall CoGetActivationState(int128 long ptr) ole32.CoGetActivationState
@ stub CoGetApartmentID
@ stub CoGetApartmentType
@ stdcall CoGetApartmentType(ptr ptr) ole32.CoGetApartmentType
@ stdcall CoGetCallContext(ptr ptr) ole32.CoGetCallContext
@ stdcall CoGetCallState(long ptr) ole32.CoGetCallState
@ stdcall CoGetCallerTID(ptr) ole32.CoGetCallerTID

View File

@ -5028,6 +5028,35 @@ HRESULT Handler_DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
return CLASS_E_CLASSNOTAVAILABLE;
}
/***********************************************************************
* CoGetApartmentType [OLE32.@]
*/
HRESULT WINAPI CoGetApartmentType(APTTYPE *type, APTTYPEQUALIFIER *qualifier)
{
struct oletls *info = COM_CurrentInfo();
FIXME("(%p, %p): semi-stub\n", type, qualifier);
if (!type || !qualifier)
return E_INVALIDARG;
if (!info)
return E_OUTOFMEMORY;
if (!info->apt)
*type = APTTYPE_CURRENT;
else if (info->apt->multi_threaded)
*type = APTTYPE_MTA;
else if (info->apt->main)
*type = APTTYPE_MAINSTA;
else
*type = APTTYPE_STA;
*qualifier = APTTYPEQUALIFIER_NONE;
return info->apt ? S_OK : CO_E_NOTINITIALIZED;
}
/***********************************************************************
* DllMain (OLE32.@)
*/

View File

@ -23,6 +23,7 @@
@ stdcall CoFreeUnusedLibraries()
@ stdcall CoFreeUnusedLibrariesEx(long long)
@ stdcall CoGetActivationState(int128 long ptr)
@ stdcall CoGetApartmentType(ptr ptr)
@ stdcall CoGetCallContext(ptr ptr)
@ stdcall CoGetCallState(long ptr)
@ stdcall CoGetCallerTID(ptr)

View File

@ -70,6 +70,7 @@ static HRESULT (WINAPI * pCoSwitchCallContext)(IUnknown *pObject, IUnknown **ppO
static HRESULT (WINAPI * pCoGetTreatAsClass)(REFCLSID clsidOld, LPCLSID pClsidNew);
static HRESULT (WINAPI * pCoTreatAsClass)(REFCLSID clsidOld, REFCLSID pClsidNew);
static HRESULT (WINAPI * pCoGetContextToken)(ULONG_PTR *token);
static HRESULT (WINAPI * pCoGetApartmentType)(APTTYPE *type, APTTYPEQUALIFIER *qualifier);
static LONG (WINAPI * pRegDeleteKeyExA)(HKEY, LPCSTR, REGSAM, DWORD);
static LONG (WINAPI * pRegOverridePredefKey)(HKEY key, HKEY override);
@ -2879,6 +2880,59 @@ if (0) /* crashes on native */
IMalloc_Release(imalloc);
}
static void test_CoGetApartmentType(void)
{
APTTYPEQUALIFIER qualifier;
APTTYPE type;
HRESULT hr;
if (!pCoGetApartmentType)
{
win_skip("CoGetApartmentType not present\n");
return;
}
hr = pCoGetApartmentType(NULL, NULL);
ok(hr == E_INVALIDARG, "CoGetApartmentType succeeded, error: 0x%08x\n", hr);
type = 0xdeadbeef;
hr = pCoGetApartmentType(&type, NULL);
ok(hr == E_INVALIDARG, "CoGetApartmentType succeeded, error: 0x%08x\n", hr);
ok(type == 0xdeadbeef, "Expected 0xdeadbeef, got %u\n", type);
qualifier = 0xdeadbeef;
hr = pCoGetApartmentType(NULL, &qualifier);
ok(hr == E_INVALIDARG, "CoGetApartmentType succeeded, error: 0x%08x\n", hr);
ok(qualifier == 0xdeadbeef, "Expected 0xdeadbeef, got %u\n", qualifier);
type = 0xdeadbeef;
qualifier = 0xdeadbeef;
hr = pCoGetApartmentType(&type, &qualifier);
ok(hr == CO_E_NOTINITIALIZED, "CoGetApartmentType succeeded, error: 0x%08x\n", hr);
ok(type == APTTYPE_CURRENT, "Expected APTTYPE_CURRENT, got %u\n", type);
ok(qualifier == APTTYPEQUALIFIER_NONE, "Expected APTTYPEQUALIFIER_NONE, got %u\n", qualifier);
type = 0xdeadbeef;
qualifier = 0xdeadbeef;
hr = pCoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
ok(hr == S_OK, "CoInitializeEx failed, error: 0x%08x\n", hr);
hr = pCoGetApartmentType(&type, &qualifier);
ok(hr == S_OK, "CoGetApartmentType failed, error: 0x%08x\n", hr);
ok(type == APTTYPE_MAINSTA, "Expected APTTYPE_MAINSTA, got %u\n", type);
ok(qualifier == APTTYPEQUALIFIER_NONE, "Expected APTTYPEQUALIFIER_NONE, got %u\n", qualifier);
CoUninitialize();
type = 0xdeadbeef;
qualifier = 0xdeadbeef;
hr = pCoInitializeEx(NULL, COINIT_MULTITHREADED);
ok(hr == S_OK, "CoInitializeEx failed, error: 0x%08x\n", hr);
hr = pCoGetApartmentType(&type, &qualifier);
ok(hr == S_OK, "CoGetApartmentType failed, error: 0x%08x\n", hr);
ok(type == APTTYPE_MTA, "Expected APTTYPE_MTA, got %u\n", type);
ok(qualifier == APTTYPEQUALIFIER_NONE, "Expected APTTYPEQUALIFIER_NONE, got %u\n", qualifier);
CoUninitialize();
}
static void init_funcs(void)
{
HMODULE hOle32 = GetModuleHandleA("ole32");
@ -2890,6 +2944,7 @@ static void init_funcs(void)
pCoGetTreatAsClass = (void*)GetProcAddress(hOle32,"CoGetTreatAsClass");
pCoTreatAsClass = (void*)GetProcAddress(hOle32,"CoTreatAsClass");
pCoGetContextToken = (void*)GetProcAddress(hOle32, "CoGetContextToken");
pCoGetApartmentType = (void*)GetProcAddress(hOle32, "CoGetApartmentType");
pRegDeleteKeyExA = (void*)GetProcAddress(hAdvapi32, "RegDeleteKeyExA");
pRegOverridePredefKey = (void*)GetProcAddress(hAdvapi32, "RegOverridePredefKey");
pCoInitializeEx = (void*)GetProcAddress(hOle32, "CoInitializeEx");
@ -2944,4 +2999,5 @@ START_TEST(compobj)
test_CoWaitForMultipleHandles();
test_CoGetMalloc();
test_OleRegGetUserType();
test_CoGetApartmentType();
}

View File

@ -285,6 +285,7 @@ HRESULT WINAPI CoInitialize(LPVOID lpReserved);
HRESULT WINAPI CoInitializeEx(LPVOID lpReserved, DWORD dwCoInit);
void WINAPI CoUninitialize(void);
DWORD WINAPI CoGetCurrentProcess(void);
HRESULT WINAPI CoGetApartmentType(APTTYPE *type, APTTYPEQUALIFIER *qualifier);
HINSTANCE WINAPI CoLoadLibrary(LPOLESTR lpszLibName, BOOL bAutoFree);
void WINAPI CoFreeAllLibraries(void);

View File

@ -2327,6 +2327,15 @@ typedef enum _APTTYPE {
APTTYPE_MAINSTA = 3
} APTTYPE;
typedef enum _APTTYPEQUALIFIER {
APTTYPEQUALIFIER_NONE,
APTTYPEQUALIFIER_IMPLICIT_MTA,
APTTYPEQUALIFIER_NA_ON_MTA,
APTTYPEQUALIFIER_NA_ON_STA,
APTTYPEQUALIFIER_NA_ON_IMPLICIT_MTA,
APTTYPEQUALIFIER_NA_ON_MAINSTA
} APTTYPEQUALIFIER;
typedef enum _THDTYPE {
THDTYPE_BLOCKMESSAGES = 0,
THDTYPE_PROCESSMESSAGES = 1