ReactOS 0.4.16-dev-1946-g52006dd
com_apitest.c File Reference
#include "com_apitest.h"
#include <winreg.h>
#include <mshtmhst.h>
#include <shlwapi.h>
#include <commoncontrols.h>
#include <activscp.h>
#include <ndk/rtlfuncs.h>
#include <debug.h>
Include dependency graph for com_apitest.c:

Go to the source code of this file.

Classes

struct  _KNOWN_INTERFACE
 

Macros

#define NDEBUG
 
#define myskip(c, ...)   ((c) ? 0 : (skip(__VA_ARGS__), 1))
 
#define mytrace(...)
 
#define ID_NAME(c)   &c, #c, L ## #c
 
#define ID_NAME_EX(c, d)   &c, #d, L ## #d
 
#define ValidClassForVersion(pClass, version)    ((pClass)->MinClassNTDDIVersion <= (version) && (pClass)->MaxClassNTDDIVersion >= (version))
 
#define ValidInterfaceForVersion(interface, version)    ((interface).MinInterfaceNTDDIVersion <= (version) && (interface).MaxInterfaceNTDDIVersion >= (version))
 
#define INTF_NOT_EXPOSED   LONG_MAX
 

Typedefs

typedef struct _KNOWN_INTERFACE KNOWN_INTERFACE
 
typedef const KNOWN_INTERFACEPCKNOWN_INTERFACE
 

Functions

BOOLEAN RegisteredAlways (ULONG version)
 
BOOLEAN RegisteredNever (ULONG version)
 
BOOLEAN RegisteredOnWS03AndVista (ULONG version)
 
BOOLEAN RegisteredOnVistaOrNewer (ULONG version)
 
BOOLEAN RegisteredOnVistaOnly (ULONG version)
 
BOOLEAN RegisteredOnVistaAndWin7 (ULONG version)
 
BOOLEAN RegisteredOnVistaToWin8Dot1 (ULONG version)
 
BOOLEAN RegisteredOnWin7OrNewer (ULONG version)
 
BOOLEAN RegisteredOnWin8OrNewer (ULONG version)
 
BOOLEAN RegisteredOnWS03OrOlder (ULONG version)
 
static PCKNOWN_INTERFACE FindInterface (_In_ const IID *iid)
 
static BOOLEAN IsInterfaceExpected (_In_ PCCLASS_AND_INTERFACES class, _In_ const IID *iid, _In_ ULONG NTDDIVersion)
 
static LONG GetInterfaceOffset (_In_ PUNKNOWN pUnk, _In_ const IID *iid)
 
static VOID TestModuleInterfaces (_In_ PCCLASS_AND_INTERFACES ExpectedInterfaces, _In_ INT ExpectedInterfaceCount, _In_ ULONG NTDDIVersion)
 
static VOID TestModuleRegistry (_In_ PCWSTR ModuleName, _In_ PCCLASS_AND_INTERFACES ExpectedInterfaces, _In_ INT ExpectedInterfaceCount, _In_ ULONG NTDDIVersion)
 
static VOID TestManualInstantiation (_In_ PCWSTR ModuleName, _In_ PCCLASS_AND_INTERFACES ExpectedInterfaces, _In_ INT ExpectedInterfaceCount, _In_ ULONG NTDDIVersion)
 
VOID TestClassesEx (_In_ PCWSTR ModuleName, _In_ PCCLASS_AND_INTERFACES ExpectedInterfaces, _In_ INT ExpectedInterfaceCount, _In_ ULONG MinimumNTDDIVersion, _In_ ULONG MaximumNTDDIVersion, _In_ BOOLEAN IsWinRT)
 
VOID TestClasses (_In_ PCWSTR ModuleName, _In_ PCCLASS_AND_INTERFACES ExpectedInterfaces, _In_ INT ExpectedInterfaceCount)
 
static VOID TestInterfaceRegistry (_In_ PCKNOWN_INTERFACE Interfaces, _In_ INT InterfaceCount)
 
 START_TEST (interfaces)
 

Variables

static KNOWN_INTERFACE KnownInterfaces []
 
static const INT KnownInterfaceCount = RTL_NUMBER_OF(KnownInterfaces)
 

Macro Definition Documentation

◆ ID_NAME

#define ID_NAME (   c)    &c, #c, L ## #c

Definition at line 38 of file com_apitest.c.

◆ ID_NAME_EX

#define ID_NAME_EX (   c,
  d 
)    &c, #d, L ## #d

Definition at line 39 of file com_apitest.c.

◆ INTF_NOT_EXPOSED

#define INTF_NOT_EXPOSED   LONG_MAX

Definition at line 566 of file com_apitest.c.

◆ myskip

#define myskip (   c,
  ... 
)    ((c) ? 0 : (skip(__VA_ARGS__), 1))

Definition at line 20 of file com_apitest.c.

◆ mytrace

#define mytrace (   ...)
Value:
do { \
trace(__VA_ARGS__); \
} while (0)
#define debug(msg)
Definition: key_call.c:71
int winetest_debug

Definition at line 21 of file com_apitest.c.

◆ NDEBUG

#define NDEBUG

Definition at line 17 of file com_apitest.c.

◆ ValidClassForVersion

#define ValidClassForVersion (   pClass,
  version 
)     ((pClass)->MinClassNTDDIVersion <= (version) && (pClass)->MaxClassNTDDIVersion >= (version))

Definition at line 527 of file com_apitest.c.

◆ ValidInterfaceForVersion

#define ValidInterfaceForVersion (   interface,
  version 
)     ((interface).MinInterfaceNTDDIVersion <= (version) && (interface).MaxInterfaceNTDDIVersion >= (version))

Definition at line 529 of file com_apitest.c.

Typedef Documentation

◆ KNOWN_INTERFACE

◆ PCKNOWN_INTERFACE

Definition at line 35 of file com_apitest.c.

Function Documentation

◆ FindInterface()

static PCKNOWN_INTERFACE FindInterface ( _In_ const IID iid)
static

Definition at line 534 of file com_apitest.c.

536{
537 INT i;
538
539 for (i = 0; i < KnownInterfaceCount; i++)
540 if (IsEqualIID(KnownInterfaces[i].iid, iid))
541 return &KnownInterfaces[i];
543 return NULL;
544}
static const INT KnownInterfaceCount
Definition: com_apitest.c:525
static KNOWN_INTERFACE KnownInterfaces[]
Definition: com_apitest.c:52
#define NULL
Definition: types.h:112
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
#define ASSERT(a)
Definition: mode.c:44
#define IsEqualIID(riid1, riid2)
Definition: guiddef.h:95
int32_t INT
Definition: typedefs.h:58

Referenced by TestModuleInterfaces().

◆ GetInterfaceOffset()

static LONG GetInterfaceOffset ( _In_ PUNKNOWN  pUnk,
_In_ const IID iid 
)
static

Definition at line 569 of file com_apitest.c.

572{
573 HRESULT hr;
574 PVOID pObj;
575 PUNKNOWN pUnk2;
576 LONG offset;
577
578 hr = IUnknown_QueryInterface(pUnk, iid, &pObj);
579 ok(hr == S_OK || hr == E_NOINTERFACE, "IUnknown::QueryInterface returned 0x%lx\n", hr);
580 if (FAILED(hr))
581 return INTF_NOT_EXPOSED;
582
583 pUnk2 = pObj;
584 offset = (LONG_PTR)pObj - (LONG_PTR)pUnk;
585 IUnknown_Release(pUnk2);
586 return offset;
587}
#define ok(value,...)
Definition: atltest.h:57
#define INTF_NOT_EXPOSED
Definition: com_apitest.c:566
static void *static void *static LPDIRECTPLAY IUnknown * pUnk
Definition: dplayx.c:30
GLintptr offset
Definition: glext.h:5920
#define S_OK
Definition: intsafe.h:52
#define FAILED(hr)
Definition: intsafe.h:51
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
long LONG
Definition: pedump.c:60
HRESULT hr
Definition: shlfolder.c:183
#define LONG_PTR
Definition: treelist.c:79
#define E_NOINTERFACE
Definition: winerror.h:3479

Referenced by TestModuleInterfaces().

◆ IsInterfaceExpected()

static BOOLEAN IsInterfaceExpected ( _In_ PCCLASS_AND_INTERFACES  class,
_In_ const IID iid,
_In_ ULONG  NTDDIVersion 
)
static

Definition at line 548 of file com_apitest.c.

552{
553 INT i;
554
555 for (i = 0; class->ifaces[i].iid; i++)
556 {
557 if (ValidInterfaceForVersion(class->ifaces[i], NTDDIVersion) &&
558 IsEqualIID(class->ifaces[i].iid, iid))
559 {
560 return TRUE;
561 }
562 }
563 return FALSE;
564}
const WCHAR * class
Definition: main.c:68
#define ValidInterfaceForVersion(interface, version)
Definition: com_apitest.c:529
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117

Referenced by TestModuleInterfaces().

◆ RegisteredAlways()

BOOLEAN RegisteredAlways ( ULONG  version)

Definition at line 41 of file com_apitest.c.

41{ return TRUE; }

◆ RegisteredNever()

BOOLEAN RegisteredNever ( ULONG  version)

Definition at line 42 of file com_apitest.c.

42{ return FALSE; }

◆ RegisteredOnVistaAndWin7()

BOOLEAN RegisteredOnVistaAndWin7 ( ULONG  version)

Definition at line 46 of file com_apitest.c.

46{ return version >= NTDDI_VISTA && version < NTDDI_WIN8; }
static const WCHAR version[]
Definition: asmname.c:66
#define NTDDI_WIN8
Definition: sdkddkver.h:114
#define NTDDI_VISTA
Definition: sdkddkver.h:103

◆ RegisteredOnVistaOnly()

BOOLEAN RegisteredOnVistaOnly ( ULONG  version)

Definition at line 45 of file com_apitest.c.

45{ return version >= NTDDI_VISTA && version < NTDDI_WIN7; }
#define NTDDI_WIN7
Definition: sdkddkver.h:112

◆ RegisteredOnVistaOrNewer()

BOOLEAN RegisteredOnVistaOrNewer ( ULONG  version)

Definition at line 44 of file com_apitest.c.

44{ return version >= NTDDI_VISTA; }

◆ RegisteredOnVistaToWin8Dot1()

BOOLEAN RegisteredOnVistaToWin8Dot1 ( ULONG  version)

Definition at line 47 of file com_apitest.c.

47{ return version >= NTDDI_VISTA && version < NTDDI_WIN10; }
#define NTDDI_WIN10
Definition: sdkddkver.h:117

◆ RegisteredOnWin7OrNewer()

BOOLEAN RegisteredOnWin7OrNewer ( ULONG  version)

Definition at line 48 of file com_apitest.c.

48{ return version >= NTDDI_WIN7; }

◆ RegisteredOnWin8OrNewer()

BOOLEAN RegisteredOnWin8OrNewer ( ULONG  version)

Definition at line 49 of file com_apitest.c.

49{ return version >= NTDDI_WIN8; }

◆ RegisteredOnWS03AndVista()

BOOLEAN RegisteredOnWS03AndVista ( ULONG  version)

Definition at line 43 of file com_apitest.c.

43{ return version >= NTDDI_WS03 && version < NTDDI_WIN7; }
#define NTDDI_WS03
Definition: sdkddkver.h:92

◆ RegisteredOnWS03OrOlder()

BOOLEAN RegisteredOnWS03OrOlder ( ULONG  version)

Definition at line 50 of file com_apitest.c.

50{ return version <= NTDDI_WS03SP4; }
#define NTDDI_WS03SP4
Definition: sdkddkver.h:96

◆ START_TEST()

START_TEST ( interfaces  )

Definition at line 894 of file com_apitest.c.

895{
897}
static VOID TestInterfaceRegistry(_In_ PCKNOWN_INTERFACE Interfaces, _In_ INT InterfaceCount)
Definition: com_apitest.c:825

◆ TestClasses()

VOID TestClasses ( _In_ PCWSTR  ModuleName,
_In_ PCCLASS_AND_INTERFACES  ExpectedInterfaces,
_In_ INT  ExpectedInterfaceCount 
)

Definition at line 815 of file com_apitest.c.

819{
821}
ACPI_BUFFER *RetBuffer ACPI_BUFFER *RetBuffer char ACPI_WALK_RESOURCE_CALLBACK void *Context ACPI_BUFFER *RetBuffer UINT16 ACPI_RESOURCE **ResourcePtr ACPI_GENERIC_ADDRESS *Reg UINT32 *ReturnValue UINT8 UINT8 *Slp_TypB ACPI_PHYSICAL_ADDRESS PhysicalAddress64 UINT32 UINT32 *TimeElapsed UINT32 ACPI_STATUS const char UINT32 ACPI_STATUS const char UINT32 const char const char * ModuleName
Definition: acpixf.h:1280
#define NTDDI_MIN
Definition: apitest.h:20
#define NTDDI_MAX
Definition: apitest.h:21
static const CLASS_AND_INTERFACES ExpectedInterfaces[]
Definition: browseui.c:14
VOID TestClassesEx(_In_ PCWSTR ModuleName, _In_ PCCLASS_AND_INTERFACES ExpectedInterfaces, _In_ INT ExpectedInterfaceCount, _In_ ULONG MinimumNTDDIVersion, _In_ ULONG MaximumNTDDIVersion, _In_ BOOLEAN IsWinRT)
Definition: com_apitest.c:779

Referenced by START_TEST().

◆ TestClassesEx()

VOID TestClassesEx ( _In_ PCWSTR  ModuleName,
_In_ PCCLASS_AND_INTERFACES  ExpectedInterfaces,
_In_ INT  ExpectedInterfaceCount,
_In_ ULONG  MinimumNTDDIVersion,
_In_ ULONG  MaximumNTDDIVersion,
_In_ BOOLEAN  IsWinRT 
)

Definition at line 779 of file com_apitest.c.

786{
787 HRESULT hr;
788 ULONG NTDDIVersion;
789
790 NTDDIVersion = GetNTDDIVersion();
791
792 if (NTDDIVersion < MinimumNTDDIVersion || NTDDIVersion > MaximumNTDDIVersion)
793 {
794 skip("Skipping all tests for module %S, NTDDI version (0x%08lx) is outside of the supported range (0x%08lx-0x%08lx).\n",
795 ModuleName, NTDDIVersion, MinimumNTDDIVersion, MaximumNTDDIVersion);
796 return;
797 }
798
800 ok(hr == S_OK, "CoInitializeEx failed. hr=0x%lx\n", hr);
801 if (myskip(SUCCEEDED(hr), "Failed to initialize COM. Cannot perform tests\n"))
802 return;
803
804 TestModuleInterfaces(ExpectedInterfaces, ExpectedInterfaceCount, NTDDIVersion);
805 TestModuleRegistry(ModuleName, ExpectedInterfaces, ExpectedInterfaceCount, NTDDIVersion);
806 if (IsWinRT)
807 skip("%S is a WinRT module, skipping manual instantiation tests.\n", ModuleName);
808 else
809 TestManualInstantiation(ModuleName, ExpectedInterfaces, ExpectedInterfaceCount, NTDDIVersion);
810
812}
static ULONG GetNTDDIVersion(VOID)
Definition: apitest.h:23
#define skip(...)
Definition: atltest.h:64
static VOID TestModuleRegistry(_In_ PCWSTR ModuleName, _In_ PCCLASS_AND_INTERFACES ExpectedInterfaces, _In_ INT ExpectedInterfaceCount, _In_ ULONG NTDDIVersion)
Definition: com_apitest.c:655
#define myskip(c,...)
Definition: com_apitest.c:20
static VOID TestModuleInterfaces(_In_ PCCLASS_AND_INTERFACES ExpectedInterfaces, _In_ INT ExpectedInterfaceCount, _In_ ULONG NTDDIVersion)
Definition: com_apitest.c:591
static VOID TestManualInstantiation(_In_ PCWSTR ModuleName, _In_ PCCLASS_AND_INTERFACES ExpectedInterfaces, _In_ INT ExpectedInterfaceCount, _In_ ULONG NTDDIVersion)
Definition: com_apitest.c:739
HRESULT WINAPI DECLSPEC_HOTPATCH CoInitializeEx(LPVOID lpReserved, DWORD dwCoInit)
Definition: compobj.c:2002
void WINAPI DECLSPEC_HOTPATCH CoUninitialize(void)
Definition: compobj.c:2067
#define SUCCEEDED(hr)
Definition: intsafe.h:50
@ COINIT_APARTMENTTHREADED
Definition: objbase.h:278
uint32_t ULONG
Definition: typedefs.h:59

Referenced by START_TEST(), and TestClasses().

◆ TestInterfaceRegistry()

static VOID TestInterfaceRegistry ( _In_ PCKNOWN_INTERFACE  Interfaces,
_In_ INT  InterfaceCount 
)
static

Definition at line 825 of file com_apitest.c.

828{
829 INT i;
830 HKEY hKeyInterface;
831 LONG result;
832 ULONG CurrentNTDDI;
833
834 result = RegOpenKeyExW(HKEY_LOCAL_MACHINE, L"Software\\Classes\\Interface", 0, KEY_ENUMERATE_SUB_KEYS, &hKeyInterface);
835 ok(result == NO_ERROR, "Failed to open interface key, error %lu\n", result);
836 if (!myskip(result == NO_ERROR, "No interface key\n"))
837 {
838 CurrentNTDDI = GetNTDDIVersion();
839
840 for (i = 0; i < InterfaceCount; i++)
841 {
842 HKEY hKey;
844 UNICODE_STRING iid;
845 DWORD type;
846 WCHAR data[100];
848 PCKNOWN_INTERFACE iface;
849 PCWSTR expectedName;
850
851 iface = &Interfaces[i];
852 status = RtlStringFromGUID(iface->iid, &iid);
853 ok(status == STATUS_SUCCESS, "Failed to convert guid to string for %s, status %lx\n", iface->name, status);
854 if (myskip(NT_SUCCESS(status), "No guid string\n"))
855 continue;
856
857 result = RegOpenKeyExW(hKeyInterface, iid.Buffer, 0, KEY_QUERY_VALUE, &hKey);
858 if (iface->IsRegistered(CurrentNTDDI))
859 {
860 ok(result == NO_ERROR, "%s should be registered. (Error %lu)\n", iface->name, result);
861 // (void)myskip(result == NO_ERROR, "No key\n");
862 }
863 else
864 {
865 ok(result == ERROR_FILE_NOT_FOUND, "%s should not be registered. (Error %lu)\n", iface->name, result);
866 }
868 if (result != NO_ERROR)
869 continue;
870
871 dataSize = sizeof(data);
873 ok(result == NO_ERROR, "Failed to query value for %s, error %lu\n", iface->name, result);
874 if (!myskip(result == NO_ERROR, "No module name\n"))
875 {
876 ok(type == REG_SZ, "type %lu for %s\n", type, iface->name);
877 ok(dataSize % sizeof(WCHAR) == 0, "size %lu for %s\n", dataSize, iface->name);
878 ok(dataSize <= sizeof(data), "size %lu for %s\n", dataSize, iface->name);
879 ok(data[dataSize / sizeof(WCHAR) - 1] == UNICODE_NULL, "Not null terminated for %s\n", iface->name);
880 expectedName = wcschr(iface->wname, L'_');
881 if (expectedName)
882 expectedName++;
883 else
884 expectedName = iface->wname;
885 ok(!_wcsicmp(data, expectedName), "Name is %ls, expected %ls\n", data, expectedName);
886 }
887
889 }
890 RegCloseKey(hKeyInterface);
891 }
892}
LONG NTSTATUS
Definition: precomp.h:26
#define RegCloseKey(hKey)
Definition: registry.h:49
#define NO_ERROR
Definition: dderror.h:5
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
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
#define wcschr
Definition: compat.h:17
#define L(x)
Definition: resources.c:13
unsigned long DWORD
Definition: ntddk_ex.h:95
FxAutoRegKey hKey
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
GLenum GLsizei dataSize
Definition: glext.h:11123
GLuint64EXT * result
Definition: glext.h:11304
NTSYSAPI NTSTATUS WINAPI RtlStringFromGUID(REFGUID, PUNICODE_STRING)
#define REG_SZ
Definition: layer.c:22
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
#define KEY_QUERY_VALUE
Definition: nt_native.h:1019
#define KEY_ENUMERATE_SUB_KEYS
Definition: nt_native.h:1022
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
#define UNICODE_NULL
BYTE * PBYTE
Definition: pedump.c:66
_Check_return_ _CRTIMP int __cdecl _wcsicmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
#define STATUS_SUCCESS
Definition: shellext.h:65
BOOLEAN(* IsRegistered)(ULONG version)
Definition: com_apitest.c:33
const IID * iid
Definition: com_apitest.c:30
Definition: ps.c:97
const uint16_t * PCWSTR
Definition: typedefs.h:57
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by START_TEST().

◆ TestManualInstantiation()

static VOID TestManualInstantiation ( _In_ PCWSTR  ModuleName,
_In_ PCCLASS_AND_INTERFACES  ExpectedInterfaces,
_In_ INT  ExpectedInterfaceCount,
_In_ ULONG  NTDDIVersion 
)
static

Definition at line 739 of file com_apitest.c.

744{
745 INT iClass;
748
750 ok(DllGetClassObject != NULL, "DllGetClassObject not found in %ls, error %lu\n", ModuleName, GetLastError());
751 if (myskip(DllGetClassObject != NULL, "No DllGetClassObject\n"))
752 return;
753
754 for (iClass = 0; iClass < ExpectedInterfaceCount; iClass++)
755 {
756 PVOID pv;
757 HRESULT hr;
758 class = &ExpectedInterfaces[iClass];
759 if (!ValidClassForVersion(class, NTDDIVersion))
760 continue;
762 ok(hr == S_OK, "DllGetClassObject failed for %s, hr = 0x%lx\n", class->name, hr);
763 if (!myskip(SUCCEEDED(hr), "No class factory\n"))
764 {
765 IClassFactory *pCF = pv;
766 hr = IClassFactory_CreateInstance(pCF, NULL, &IID_IUnknown, &pv);
767 ok(hr == S_OK, "IClassFactory::CreateInstance failed for %s, hr = 0x%lx\n", class->name, hr);
768 if (!myskip(SUCCEEDED(hr), "No instance\n"))
769 {
770 IUnknown *pUnk = pv;
771 IUnknown_Release(pUnk);
772 }
773 IClassFactory_Release(pCF);
774 }
775 }
776}
const GUID IID_IUnknown
const GUID IID_IClassFactory
#define ValidClassForVersion(pClass, version)
Definition: com_apitest.c:527
#define GetProcAddress(x, y)
Definition: compat.h:753
HMODULE WINAPI GetModuleHandleW(LPCWSTR lpModuleName)
Definition: loader.c:838
HRESULT WINAPI DllGetClassObject(REFCLSID clsid, REFIID iid, LPVOID *ppvOut)
Definition: msctf.cpp:566
#define REFIID
Definition: guiddef.h:118
#define REFCLSID
Definition: guiddef.h:117
void * PVOID
Definition: typedefs.h:50
#define __stdcall
Definition: typedefs.h:25
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define HRESULT
Definition: msvc.h:7

Referenced by TestClassesEx().

◆ TestModuleInterfaces()

static VOID TestModuleInterfaces ( _In_ PCCLASS_AND_INTERFACES  ExpectedInterfaces,
_In_ INT  ExpectedInterfaceCount,
_In_ ULONG  NTDDIVersion 
)
static

Definition at line 591 of file com_apitest.c.

595{
596 HRESULT hr;
597 PVOID pObj;
599 INT iClass, iIntf;
601
602 for (iClass = 0; iClass < ExpectedInterfaceCount; iClass++)
603 {
604 class = &ExpectedInterfaces[iClass];
605 if (!ValidClassForVersion(class, NTDDIVersion))
606 continue;
607 hr = CoCreateInstance(class->clsid,
608 NULL,
609 CLSCTX_INPROC_SERVER,
611 &pObj);
612 ok(hr == S_OK, "CoCreateInstance failed. hr=0x%lx\n", hr);
613 if (FAILED(hr))
614 {
615 skip("Failed to instantiate %s.\n", class->name);
616 continue;
617 }
618
619 pUnk = pObj;
620
621 /* Check that all expected interfaces are present */
622 for (iIntf = 0; class->ifaces[iIntf].iid; iIntf++)
623 {
624 if (!ValidInterfaceForVersion(class->ifaces[iIntf], NTDDIVersion))
625 continue;
626 PCKNOWN_INTERFACE iface = FindInterface(class->ifaces[iIntf].iid);
629 ok(0, "%s is missing %s\n", class->name, iface->name);
630#ifdef LOG_COM_INTERFACE_OFFSETS
631 else
632 mytrace("%s0x%lx, %s, %s\n", offset < 0 ? "-" : "", offset < 0 ? -offset : offset, class->name, iface->name);
633#endif
634 }
635
636 /* Check that none other than the expected interfaces are present */
637 for (iIntf = 0; iIntf < KnownInterfaceCount; iIntf++)
638 {
639 PCKNOWN_INTERFACE iface = &KnownInterfaces[iIntf];
640 LONG offset;
641 if (IsInterfaceExpected(class, iface->iid, NTDDIVersion))
642 continue;
644 ok(offset == INTF_NOT_EXPOSED, "%s exposes %s (offset %s0x%lx), but shouldn't\n", class->name, iface->name, offset < 0 ? "-" : "", offset < 0 ? -offset : offset);
645 }
646
647 // TODO: do some aggregation
648
649 IUnknown_Release(pUnk);
650 }
651}
static LONG GetInterfaceOffset(_In_ PUNKNOWN pUnk, _In_ const IID *iid)
Definition: com_apitest.c:569
static PCKNOWN_INTERFACE FindInterface(_In_ const IID *iid)
Definition: com_apitest.c:534
#define mytrace(...)
Definition: com_apitest.c:21
static BOOLEAN IsInterfaceExpected(_In_ PCCLASS_AND_INTERFACES class, _In_ const IID *iid, _In_ ULONG NTDDIVersion)
Definition: com_apitest.c:548
HRESULT WINAPI DECLSPEC_HOTPATCH CoCreateInstance(REFCLSID rclsid, LPUNKNOWN pUnkOuter, DWORD dwClsContext, REFIID iid, LPVOID *ppv)
Definition: compobj.c:3325
Definition: name.c:39

Referenced by TestClassesEx().

◆ TestModuleRegistry()

static VOID TestModuleRegistry ( _In_ PCWSTR  ModuleName,
_In_ PCCLASS_AND_INTERFACES  ExpectedInterfaces,
_In_ INT  ExpectedInterfaceCount,
_In_ ULONG  NTDDIVersion 
)
static

Definition at line 655 of file com_apitest.c.

660{
661 INT iClass;
663 HKEY hKeyClasses;
664 LONG result;
665
666 result = RegOpenKeyExW(HKEY_LOCAL_MACHINE, L"Software\\Classes\\CLSID", 0, KEY_ENUMERATE_SUB_KEYS, &hKeyClasses);
667 ok(result == NO_ERROR, "Failed to open classes key, error %lu\n", result);
668 if (!myskip(result == NO_ERROR, "No classes key\n"))
669 {
670 for (iClass = 0; iClass < ExpectedInterfaceCount; iClass++)
671 {
672 HKEY hKey;
673 HKEY hKeyServer;
676 DWORD type;
677 WCHAR data[100];
679 PCWSTR expectedThreadingModel;
680
681 class = &ExpectedInterfaces[iClass];
682 if (!ValidClassForVersion(class, NTDDIVersion))
683 continue;
685 ok(status == STATUS_SUCCESS, "Failed to convert guid to string for %s, status %lx\n", class->name, status);
686 if (myskip(NT_SUCCESS(status), "No guid string\n"))
687 continue;
688
689 result = RegOpenKeyExW(hKeyClasses, clsid.Buffer, 0, KEY_ENUMERATE_SUB_KEYS, &hKey);
690 ok(result == NO_ERROR, "Failed to open key for %s, error %lu\n", class->name, result);
692 if (myskip(result == NO_ERROR, "No key\n"))
693 continue;
694
695 result = RegOpenKeyExW(hKey, L"InProcServer32", 0, KEY_QUERY_VALUE, &hKeyServer);
696 ok(result == NO_ERROR, "Failed to open key for %s, error %lu\n", class->name, result);
698 if (myskip(result == NO_ERROR, "No key\n"))
699 continue;
700
701 dataSize = sizeof(data);
702 result = RegQueryValueExW(hKeyServer, NULL, NULL, &type, (PBYTE)data, &dataSize);
703 ok(result == NO_ERROR, "Failed to query value for %s, error %lu\n", class->name, result);
704 if (!myskip(result == NO_ERROR, "No module name\n"))
705 {
706 ok(type == REG_SZ || type == REG_EXPAND_SZ, "type %lu for %s\n", type, class->name);
707 ok(dataSize % sizeof(WCHAR) == 0, "size %lu for %s\n", dataSize, class->name);
708 ok(dataSize <= sizeof(data), "size %lu for %s\n", dataSize, class->name);
709 ok(data[dataSize / sizeof(WCHAR) - 1] == UNICODE_NULL, "Not null terminated for %s\n", class->name);
710 // TODO: Use SearchPath (or assume everything's in system32) and do a proper full path compare
713 ok(!_wcsicmp(data, ModuleName), "Server is %ls, expected %ls for %s\n", data, ModuleName, class->name);
714 }
715
716 dataSize = sizeof(data);
717 result = RegQueryValueExW(hKeyServer, L"ThreadingModel", NULL, &type, (PBYTE)data, &dataSize);
718 ok(result == NO_ERROR, "Failed to query value for %s, error %lu\n", class->name, result);
719 if (!myskip(result == NO_ERROR, "No ThreadingModel\n"))
720 {
721 ok(type == REG_SZ || type == REG_EXPAND_SZ, "type %lu for %s\n", type, class->name);
722 ok(dataSize % sizeof(WCHAR) == 0, "size %lu for %s\n", dataSize, class->name);
723 ok(dataSize <= sizeof(data), "size %lu for %s\n", dataSize, class->name);
724 ok(data[dataSize / sizeof(WCHAR) - 1] == UNICODE_NULL, "Not null terminated for %s\n", class->name);
725 expectedThreadingModel = class->ThreadingModel;
726 if (!expectedThreadingModel)
727 expectedThreadingModel = L"Apartment";
728 ok(!_wcsicmp(data, expectedThreadingModel), "Server is %ls, expected %ls for %s\n", data, expectedThreadingModel, class->name);
729 }
730
731 RegCloseKey(hKeyServer);
732 }
733 RegCloseKey(hKeyClasses);
734 }
735}
void WINAPI PathRemoveExtensionW(WCHAR *path)
Definition: path.c:1946
void WINAPI PathStripPathW(WCHAR *path)
Definition: path.c:2328
const CLSID * clsid
Definition: msctf.cpp:50
#define REG_EXPAND_SZ
Definition: nt_native.h:1497

Referenced by TestClassesEx().

Variable Documentation

◆ KnownInterfaceCount

const INT KnownInterfaceCount = RTL_NUMBER_OF(KnownInterfaces)
static

Definition at line 525 of file com_apitest.c.

Referenced by FindInterface(), START_TEST(), and TestModuleInterfaces().

◆ KnownInterfaces

KNOWN_INTERFACE KnownInterfaces[]
static

Definition at line 52 of file com_apitest.c.

Referenced by FindInterface(), START_TEST(), and TestModuleInterfaces().