ReactOS  0.4.14-dev-57-g333b8f1
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 IID_ITransferAdviseSink   IID_ITransferAdviseSinkPriv
 
#define IID_IDriveFolderExt   IID_IDriveFolderExtOld
 
#define INTF_NOT_EXPOSED   LONG_MAX
 

Typedefs

typedef struct _KNOWN_INTERFACE KNOWN_INTERFACE
 
typedef const KNOWN_INTERFACEPCKNOWN_INTERFACE
 

Functions

static PCKNOWN_INTERFACE FindInterface (_In_ const IID *iid)
 
static BOOLEAN IsInterfaceExpected (_In_ PCCLASS_AND_INTERFACES class, _In_ const IID *iid)
 
static LONG GetInterfaceOffset (_In_ PUNKNOWN pUnk, _In_ const IID *iid)
 
static VOID TestModuleInterfaces (_In_ PCCLASS_AND_INTERFACES ExpectedInterfaces, _In_ INT ExpectedInterfaceCount)
 
static VOID TestModuleRegistry (_In_ PCWSTR ModuleName, _In_ PCCLASS_AND_INTERFACES ExpectedInterfaces, _In_ INT ExpectedInterfaceCount)
 
static VOID TestManualInstantiation (_In_ PCWSTR ModuleName, _In_ PCCLASS_AND_INTERFACES ExpectedInterfaces, _In_ INT ExpectedInterfaceCount)
 
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.

◆ IID_IDriveFolderExt

#define IID_IDriveFolderExt   IID_IDriveFolderExtOld

◆ IID_ITransferAdviseSink

#define IID_ITransferAdviseSink   IID_ITransferAdviseSinkPriv

◆ INTF_NOT_EXPOSED

#define INTF_NOT_EXPOSED   LONG_MAX

Definition at line 522 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 { \
winetest_debug = 1; \
trace(__VA_ARGS__); \
winetest_debug = debug; \
} while (0)
int winetest_debug
#define debug(msg)
Definition: key_call.c:71

Definition at line 21 of file com_apitest.c.

◆ NDEBUG

#define NDEBUG

Definition at line 17 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 496 of file com_apitest.c.

498 {
499  INT i;
500 
501  for (i = 0; i < KnownInterfaceCount; i++)
502  if (IsEqualIID(KnownInterfaces[i].iid, iid))
503  return &KnownInterfaces[i];
505  return NULL;
506 }
int32_t INT
Definition: typedefs.h:56
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
static KNOWN_INTERFACE KnownInterfaces[]
Definition: com_apitest.c:39
smooth NULL
Definition: ftsmooth.c:416
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
static const INT KnownInterfaceCount
Definition: com_apitest.c:492
#define IsEqualIID(riid1, riid2)
Definition: guiddef.h:95

Referenced by TestModuleInterfaces().

◆ GetInterfaceOffset()

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

Definition at line 525 of file com_apitest.c.

528 {
529  HRESULT hr;
530  PVOID pObj;
531  PUNKNOWN pUnk2;
532  LONG offset;
533 
534  hr = IUnknown_QueryInterface(pUnk, iid, &pObj);
535  ok(hr == S_OK || hr == E_NOINTERFACE, "IUnknown::QueryInterface returned 0x%lx\n", hr);
536  if (FAILED(hr))
537  return INTF_NOT_EXPOSED;
538 
539  pUnk2 = pObj;
540  offset = (LONG_PTR)pObj - (LONG_PTR)pUnk;
541  IUnknown_Release(pUnk2);
542  return offset;
543 }
#define LONG_PTR
Definition: treelist.c:79
#define E_NOINTERFACE
Definition: winerror.h:2364
HRESULT hr
Definition: shlfolder.c:183
GLintptr offset
Definition: glext.h:5920
long LONG
Definition: pedump.c:60
LONG HRESULT
Definition: typedefs.h:77
#define INTF_NOT_EXPOSED
Definition: com_apitest.c:522
#define S_OK
Definition: intsafe.h:59
#define ok(value,...)
Definition: atltest.h:57
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
static void *static void *static LPDIRECTPLAY IUnknown * pUnk
Definition: dplayx.c:30

Referenced by TestModuleInterfaces().

◆ IsInterfaceExpected()

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

Definition at line 510 of file com_apitest.c.

513 {
514  INT i;
515 
516  for (i = 0; class->ifaces[i].iid; i++)
517  if (IsEqualIID(class->ifaces[i].iid, iid))
518  return TRUE;
519  return FALSE;
520 }
#define TRUE
Definition: types.h:120
int32_t INT
Definition: typedefs.h:56
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
const WCHAR * class
Definition: main.c:68
#define IsEqualIID(riid1, riid2)
Definition: guiddef.h:95

Referenced by TestModuleInterfaces().

◆ START_TEST()

START_TEST ( interfaces  )

Definition at line 820 of file com_apitest.c.

821 {
823 }
static KNOWN_INTERFACE KnownInterfaces[]
Definition: com_apitest.c:39
static VOID TestInterfaceRegistry(_In_ PCKNOWN_INTERFACE Interfaces, _In_ INT InterfaceCount)
Definition: com_apitest.c:754
static const INT KnownInterfaceCount
Definition: com_apitest.c:492

◆ TestClasses()

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

Definition at line 733 of file com_apitest.c.

737 {
738  HRESULT hr;
739 
741  ok(hr == S_OK, "CoInitializeEx failed. hr=0x%lx\n", hr);
742  if (myskip(SUCCEEDED(hr), "Failed to initialize COM. Cannot perform tests\n"))
743  return;
744 
748 
749  CoUninitialize();
750 }
HRESULT hr
Definition: shlfolder.c:183
static const CLASS_AND_INTERFACES ExpectedInterfaces[]
Definition: browseui.c:13
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:1264
smooth NULL
Definition: ftsmooth.c:416
LONG HRESULT
Definition: typedefs.h:77
static VOID TestModuleRegistry(_In_ PCWSTR ModuleName, _In_ PCCLASS_AND_INTERFACES ExpectedInterfaces, _In_ INT ExpectedInterfaceCount)
Definition: com_apitest.c:615
static const INT ExpectedInterfaceCount
Definition: browseui.c:412
#define S_OK
Definition: intsafe.h:59
void WINAPI DECLSPEC_HOTPATCH CoUninitialize(void)
Definition: compobj.c:1991
#define myskip(c,...)
Definition: com_apitest.c:20
#define ok(value,...)
Definition: atltest.h:57
static VOID TestManualInstantiation(_In_ PCWSTR ModuleName, _In_ PCCLASS_AND_INTERFACES ExpectedInterfaces, _In_ INT ExpectedInterfaceCount)
Definition: com_apitest.c:696
HRESULT WINAPI DECLSPEC_HOTPATCH CoInitializeEx(LPVOID lpReserved, DWORD dwCoInit)
Definition: compobj.c:1935
#define SUCCEEDED(hr)
Definition: intsafe.h:57
static VOID TestModuleInterfaces(_In_ PCCLASS_AND_INTERFACES ExpectedInterfaces, _In_ INT ExpectedInterfaceCount)
Definition: com_apitest.c:547

Referenced by START_TEST().

◆ TestInterfaceRegistry()

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

Definition at line 754 of file com_apitest.c.

757 {
758  INT i;
759  HKEY hKeyInterface;
760  LONG result;
761 
762  result = RegOpenKeyExW(HKEY_LOCAL_MACHINE, L"Software\\Classes\\Interface", 0, KEY_ENUMERATE_SUB_KEYS, &hKeyInterface);
763  ok(result == NO_ERROR, "Failed to open interface key, error %lu\n", result);
764  if (!myskip(result == NO_ERROR, "No interface key\n"))
765  {
766  for (i = 0; i < InterfaceCount; i++)
767  {
768  HKEY hKey;
770  UNICODE_STRING iid;
771  DWORD type;
772  WCHAR data[100];
773  DWORD dataSize;
774  PCKNOWN_INTERFACE iface;
775  PCWSTR expectedName;
776 
777  iface = &Interfaces[i];
778  status = RtlStringFromGUID(iface->iid, &iid);
779  ok(status == STATUS_SUCCESS, "Failed to convert guid to string for %s, status %lx\n", iface->name, status);
780  if (myskip(NT_SUCCESS(status), "No guid string\n"))
781  continue;
782 
783  result = RegOpenKeyExW(hKeyInterface, iid.Buffer, 0, KEY_QUERY_VALUE, &hKey);
784  if (iface->noreg)
785  {
786  ok(result == ERROR_FILE_NOT_FOUND, "RegOpenKeyEx returned %lu for %s\n", result, iface->name);
787  }
788  else
789  {
790  ok(result == NO_ERROR, "Failed to open key for %s, error %lu\n", iface->name, result);
791  (void)myskip(result == NO_ERROR, "No key\n");
792  }
793  RtlFreeUnicodeString(&iid);
794  if (result != NO_ERROR)
795  continue;
796 
797  dataSize = sizeof(data);
799  ok(result == NO_ERROR, "Failed to query value for %s, error %lu\n", iface->name, result);
800  if (!myskip(result == NO_ERROR, "No module name\n"))
801  {
802  ok(type == REG_SZ, "type %lu for %s\n", type, iface->name);
803  ok(dataSize % sizeof(WCHAR) == 0, "size %lu for %s\n", dataSize, iface->name);
804  ok(dataSize <= sizeof(data), "size %lu for %s\n", dataSize, iface->name);
805  ok(data[dataSize / sizeof(WCHAR) - 1] == UNICODE_NULL, "Not null terminated for %s\n", iface->name);
806  expectedName = wcschr(iface->wname, L'_');
807  if (expectedName)
808  expectedName++;
809  else
810  expectedName = iface->wname;
811  ok(!wcsicmp(data, expectedName), "Name is %ls, expected %ls\n", data, expectedName);
812  }
813 
814  RegCloseKey(hKey);
815  }
816  RegCloseKey(hKeyInterface);
817  }
818 }
const uint16_t * PCWSTR
Definition: typedefs.h:55
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:49
LONG NTSTATUS
Definition: precomp.h:26
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
#define NO_ERROR
Definition: dderror.h:5
int32_t INT
Definition: typedefs.h:56
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
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
#define UNICODE_NULL
long LONG
Definition: pedump.c:60
smooth NULL
Definition: ftsmooth.c:416
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
_CONST_RETURN wchar_t *__cdecl wcschr(_In_z_ const wchar_t *_Str, wchar_t _Ch)
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4116
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
unsigned long DWORD
Definition: ntddk_ex.h:95
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
static const WCHAR L[]
Definition: oid.c:1250
NTSYSAPI NTSTATUS WINAPI RtlStringFromGUID(REFGUID, PUNICODE_STRING)
#define wcsicmp
Definition: string.h:1152
#define KEY_QUERY_VALUE
Definition: nt_native.h:1016
#define myskip(c,...)
Definition: com_apitest.c:20
#define ok(value,...)
Definition: atltest.h:57
GLenum GLsizei dataSize
Definition: glext.h:11123
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3366
return STATUS_SUCCESS
Definition: btrfs.c:2966
GLuint64EXT * result
Definition: glext.h:11304
static SERVICE_STATUS status
Definition: service.c:31
BYTE * PBYTE
Definition: pedump.c:66
const IID * iid
Definition: com_apitest.c:30
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12
#define KEY_ENUMERATE_SUB_KEYS
Definition: nt_native.h:1019
#define REG_SZ
Definition: layer.c:22
Definition: ps.c:97

Referenced by START_TEST().

◆ TestManualInstantiation()

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

Definition at line 696 of file com_apitest.c.

700 {
701  INT iClass;
704 
706  ok(DllGetClassObject != NULL, "DllGetClassObject not found in %ls, error %lu\n", ModuleName, GetLastError());
707  if (myskip(DllGetClassObject != NULL, "No DllGetClassObject\n"))
708  return;
709 
710  for (iClass = 0; iClass < ExpectedInterfaceCount; iClass++)
711  {
712  PVOID pv;
713  HRESULT hr;
714  class = &ExpectedInterfaces[iClass];
715  hr = DllGetClassObject(class->clsid, &IID_IClassFactory, &pv);
716  ok(hr == S_OK, "DllGetClassObject failed for %s, hr = 0x%lx\n", class->name, hr);
717  if (!myskip(SUCCEEDED(hr), "No class factory\n"))
718  {
719  IClassFactory *pCF = pv;
720  hr = IClassFactory_CreateInstance(pCF, NULL, &IID_IUnknown, &pv);
721  ok(hr == S_OK, "IClassFactory::CreateInstance failed for %s, hr = 0x%lx\n", class->name, hr);
722  if (!myskip(SUCCEEDED(hr), "No instance\n"))
723  {
724  IUnknown *pUnk = pv;
725  IUnknown_Release(pUnk);
726  }
727  IClassFactory_Release(pCF);
728  }
729  }
730 }
#define HRESULT
Definition: msvc.h:9
#define REFIID
Definition: guiddef.h:118
HRESULT hr
Definition: shlfolder.c:183
#define REFCLSID
Definition: guiddef.h:117
static const CLASS_AND_INTERFACES ExpectedInterfaces[]
Definition: browseui.c:13
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
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:1264
int32_t INT
Definition: typedefs.h:56
HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
Definition: shsvcs.c:38
smooth NULL
Definition: ftsmooth.c:416
void * PVOID
Definition: retypes.h:9
LONG HRESULT
Definition: typedefs.h:77
const GUID IID_IUnknown
#define __stdcall
Definition: typedefs.h:25
static const INT ExpectedInterfaceCount
Definition: browseui.c:412
#define S_OK
Definition: intsafe.h:59
#define myskip(c,...)
Definition: com_apitest.c:20
#define ok(value,...)
Definition: atltest.h:57
const WCHAR * class
Definition: main.c:68
HMODULE WINAPI GetModuleHandleW(LPCWSTR lpModuleName)
Definition: loader.c:847
#define GetProcAddress(x, y)
Definition: compat.h:410
const GUID IID_IClassFactory
static void *static void *static LPDIRECTPLAY IUnknown * pUnk
Definition: dplayx.c:30
#define SUCCEEDED(hr)
Definition: intsafe.h:57

Referenced by TestClasses().

◆ TestModuleInterfaces()

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

Definition at line 547 of file com_apitest.c.

550 {
551  HRESULT hr;
552  PVOID pObj;
553  PUNKNOWN pUnk;
554  INT iClass, iIntf;
556 
557  for (iClass = 0; iClass < ExpectedInterfaceCount; iClass++)
558  {
559  class = &ExpectedInterfaces[iClass];
560  hr = CoCreateInstance(class->clsid,
561  NULL,
562  CLSCTX_INPROC_SERVER,
563  &IID_IUnknown,
564  &pObj);
565  ok(hr == S_OK, "CoCreateInstance failed. hr=0x%lx\n", hr);
566  if (FAILED(hr))
567  {
568  skip("Failed to instantiate %s.\n", class->name);
569  continue;
570  }
571 
572  pUnk = pObj;
573 
574  /* Check that all expected interfaces are present and have the right offset */
575  for (iIntf = 0; class->ifaces[iIntf].iid; iIntf++)
576  {
577  PCKNOWN_INTERFACE iface = FindInterface(class->ifaces[iIntf].iid);
579  if (offset == INTF_NOT_EXPOSED)
580  ok(0, "%s is missing %s (offset %ld)\n", class->name, iface->name, class->ifaces[iIntf].offset);
581  else if (class->ifaces[iIntf].offset != FARAWY)
582  {
583 #ifdef FAIL_WRONG_OFFSET
584  ok(offset == class->ifaces[iIntf].offset, "%s, %s offset is %ld, expected %ld\n", class->name, iface->name, offset, class->ifaces[iIntf].offset);
585 #else
586  if (offset != class->ifaces[iIntf].offset)
587  mytrace("%s, %s offset is %ld, expected %ld\n", class->name, iface->name, offset, class->ifaces[iIntf].offset);
588 #endif
589  }
590  }
591 
592  /* Check that none other than the expected interfaces are present */
593  for (iIntf = 0; iIntf < KnownInterfaceCount; iIntf++)
594  {
595  PCKNOWN_INTERFACE iface = &KnownInterfaces[iIntf];
596  LONG offset;
597  if (IsInterfaceExpected(class, iface->iid))
598  continue;
599  offset = GetInterfaceOffset(pUnk, iface->iid);
600 #ifdef GENERATE_TABLE_ENTRIES
601  ok(offset == INTF_NOT_EXPOSED, "%s: { %s0x%lx, &%s },\n", class->name, offset < 0 ? "-" : "", offset < 0 ? -offset : offset, iface->name);
602 #else
603  ok(offset == INTF_NOT_EXPOSED, "%s exposes %s (offset %ld), but shouldn't\n", class->name, iface->name, offset);
604 #endif
605  }
606 
607  // TODO: do some aggregation
608 
609  IUnknown_Release(pUnk);
610  }
611 }
HRESULT hr
Definition: shlfolder.c:183
GLintptr offset
Definition: glext.h:5920
static const CLASS_AND_INTERFACES ExpectedInterfaces[]
Definition: browseui.c:13
int32_t INT
Definition: typedefs.h:56
long LONG
Definition: pedump.c:60
static KNOWN_INTERFACE KnownInterfaces[]
Definition: com_apitest.c:39
smooth NULL
Definition: ftsmooth.c:416
static PCKNOWN_INTERFACE FindInterface(_In_ const IID *iid)
Definition: com_apitest.c:496
LONG HRESULT
Definition: typedefs.h:77
#define INTF_NOT_EXPOSED
Definition: com_apitest.c:522
const GUID IID_IUnknown
static BOOLEAN IsInterfaceExpected(_In_ PCCLASS_AND_INTERFACES class, _In_ const IID *iid)
Definition: com_apitest.c:510
#define FARAWY
Definition: com_apitest.h:70
static LONG GetInterfaceOffset(_In_ PUNKNOWN pUnk, _In_ const IID *iid)
Definition: com_apitest.c:525
HRESULT WINAPI DECLSPEC_HOTPATCH CoCreateInstance(REFCLSID rclsid, LPUNKNOWN pUnkOuter, DWORD dwClsContext, REFIID iid, LPVOID *ppv)
Definition: compobj.c:3234
static const INT ExpectedInterfaceCount
Definition: browseui.c:412
#define S_OK
Definition: intsafe.h:59
#define ok(value,...)
Definition: atltest.h:57
static const INT KnownInterfaceCount
Definition: com_apitest.c:492
#define skip(...)
Definition: atltest.h:64
Definition: name.c:36
#define mytrace(...)
Definition: com_apitest.c:21
const WCHAR * class
Definition: main.c:68
static void *static void *static LPDIRECTPLAY IUnknown * pUnk
Definition: dplayx.c:30
const IID * iid
Definition: com_apitest.c:30

Referenced by TestClasses().

◆ TestModuleRegistry()

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

Definition at line 615 of file com_apitest.c.

619 {
620  INT iClass;
622  HKEY hKeyClasses;
623  LONG result;
624 
625  result = RegOpenKeyExW(HKEY_LOCAL_MACHINE, L"Software\\Classes\\CLSID", 0, KEY_ENUMERATE_SUB_KEYS, &hKeyClasses);
626  ok(result == NO_ERROR, "Failed to open classes key, error %lu\n", result);
627  if (!myskip(result == NO_ERROR, "No classes key\n"))
628  {
629  for (iClass = 0; iClass < ExpectedInterfaceCount; iClass++)
630  {
631  HKEY hKey;
632  HKEY hKeyServer;
635  DWORD type;
636  WCHAR data[100];
637  DWORD dataSize;
638  PCWSTR expectedThreadingModel;
639 
640  class = &ExpectedInterfaces[iClass];
641  status = RtlStringFromGUID(class->clsid, &clsid);
642  ok(status == STATUS_SUCCESS, "Failed to convert guid to string for %s, status %lx\n", class->name, status);
643  if (myskip(NT_SUCCESS(status), "No guid string\n"))
644  continue;
645 
646  result = RegOpenKeyExW(hKeyClasses, clsid.Buffer, 0, KEY_ENUMERATE_SUB_KEYS, &hKey);
647  ok(result == NO_ERROR, "Failed to open key for %s, error %lu\n", class->name, result);
649  if (myskip(result == NO_ERROR, "No key\n"))
650  continue;
651 
652  result = RegOpenKeyExW(hKey, L"InProcServer32", 0, KEY_QUERY_VALUE, &hKeyServer);
653  ok(result == NO_ERROR, "Failed to open key for %s, error %lu\n", class->name, result);
654  RegCloseKey(hKey);
655  if (myskip(result == NO_ERROR, "No key\n"))
656  continue;
657 
658  dataSize = sizeof(data);
659  result = RegQueryValueExW(hKeyServer, NULL, NULL, &type, (PBYTE)data, &dataSize);
660  ok(result == NO_ERROR, "Failed to query value for %s, error %lu\n", class->name, result);
661  if (!myskip(result == NO_ERROR, "No module name\n"))
662  {
663  ok(type == REG_SZ || type == REG_EXPAND_SZ, "type %lu for %s\n", type, class->name);
664  ok(dataSize % sizeof(WCHAR) == 0, "size %lu for %s\n", dataSize, class->name);
665  ok(dataSize <= sizeof(data), "size %lu for %s\n", dataSize, class->name);
666  ok(data[dataSize / sizeof(WCHAR) - 1] == UNICODE_NULL, "Not null terminated for %s\n", class->name);
667  // TODO: Use SearchPath (or assume everything's in system32) and do a proper full path compare
670  ok(!wcsicmp(data, ModuleName), "Server is %ls, expected %ls for %s\n", data, ModuleName, class->name);
671  }
672 
673  dataSize = sizeof(data);
674  result = RegQueryValueExW(hKeyServer, L"ThreadingModel", NULL, &type, (PBYTE)data, &dataSize);
675  ok(result == NO_ERROR, "Failed to query value for %s, error %lu\n", class->name, result);
676  if (!myskip(result == NO_ERROR, "No ThreadingModel\n"))
677  {
678  ok(type == REG_SZ || type == REG_EXPAND_SZ, "type %lu for %s\n", type, class->name);
679  ok(dataSize % sizeof(WCHAR) == 0, "size %lu for %s\n", dataSize, class->name);
680  ok(dataSize <= sizeof(data), "size %lu for %s\n", dataSize, class->name);
681  ok(data[dataSize / sizeof(WCHAR) - 1] == UNICODE_NULL, "Not null terminated for %s\n", class->name);
682  expectedThreadingModel = class->ThreadingModel;
683  if (!expectedThreadingModel)
684  expectedThreadingModel = L"Apartment";
685  ok(!wcsicmp(data, expectedThreadingModel), "Server is %ls, expected %ls for %s\n", data, expectedThreadingModel, class->name);
686  }
687 
688  RegCloseKey(hKeyServer);
689  }
690  RegCloseKey(hKeyClasses);
691  }
692 }
const uint16_t * PCWSTR
Definition: typedefs.h:55
void WINAPI PathStripPathW(LPWSTR lpszPath)
Definition: path.c:689
LONG NTSTATUS
Definition: precomp.h:26
static const CLASS_AND_INTERFACES ExpectedInterfaces[]
Definition: browseui.c:13
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
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:1264
#define NO_ERROR
Definition: dderror.h:5
int32_t INT
Definition: typedefs.h:56
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
#define UNICODE_NULL
void WINAPI PathRemoveExtensionW(LPWSTR lpszPath)
Definition: path.c:818
long LONG
Definition: pedump.c:60
smooth NULL
Definition: ftsmooth.c:416
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4116
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
unsigned long DWORD
Definition: ntddk_ex.h:95
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
REFCLSID clsid
Definition: msctf.c:84
static const WCHAR L[]
Definition: oid.c:1250
NTSYSAPI NTSTATUS WINAPI RtlStringFromGUID(REFGUID, PUNICODE_STRING)
#define wcsicmp
Definition: string.h:1152
static const INT ExpectedInterfaceCount
Definition: browseui.c:412
#define KEY_QUERY_VALUE
Definition: nt_native.h:1016
#define REG_EXPAND_SZ
Definition: nt_native.h:1494
#define myskip(c,...)
Definition: com_apitest.c:20
#define ok(value,...)
Definition: atltest.h:57
GLenum GLsizei dataSize
Definition: glext.h:11123
const WCHAR * class
Definition: main.c:68
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3366
return STATUS_SUCCESS
Definition: btrfs.c:2966
GLuint64EXT * result
Definition: glext.h:11304
static SERVICE_STATUS status
Definition: service.c:31
BYTE * PBYTE
Definition: pedump.c:66
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12
#define KEY_ENUMERATE_SUB_KEYS
Definition: nt_native.h:1019
#define REG_SZ
Definition: layer.c:22
Definition: ps.c:97

Referenced by TestClasses().

Variable Documentation

◆ KnownInterfaceCount

const INT KnownInterfaceCount = RTL_NUMBER_OF(KnownInterfaces)
static

Definition at line 492 of file com_apitest.c.

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

◆ KnownInterfaces

KNOWN_INTERFACE KnownInterfaces[]
static

Definition at line 39 of file com_apitest.c.

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