ReactOS  0.4.15-dev-3439-g2693a26
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 541 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 515 of file com_apitest.c.

517 {
518  INT i;
519 
520  for (i = 0; i < KnownInterfaceCount; i++)
521  if (IsEqualIID(KnownInterfaces[i].iid, iid))
522  return &KnownInterfaces[i];
524  return NULL;
525 }
int32_t INT
Definition: typedefs.h:58
static KNOWN_INTERFACE KnownInterfaces[]
Definition: com_apitest.c:39
#define ASSERT(a)
Definition: mode.c:44
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 NULL
Definition: types.h:112
static const INT KnownInterfaceCount
Definition: com_apitest.c:511
#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 544 of file com_apitest.c.

547 {
548  HRESULT hr;
549  PVOID pObj;
550  PUNKNOWN pUnk2;
551  LONG offset;
552 
553  hr = IUnknown_QueryInterface(pUnk, iid, &pObj);
554  ok(hr == S_OK || hr == E_NOINTERFACE, "IUnknown::QueryInterface returned 0x%lx\n", hr);
555  if (FAILED(hr))
556  return INTF_NOT_EXPOSED;
557 
558  pUnk2 = pObj;
559  offset = (LONG_PTR)pObj - (LONG_PTR)pUnk;
560  IUnknown_Release(pUnk2);
561  return offset;
562 }
#define LONG_PTR
Definition: treelist.c:79
#define E_NOINTERFACE
Definition: winerror.h:2364
HRESULT hr
Definition: shlfolder.c:183
long LONG
Definition: pedump.c:60
LONG HRESULT
Definition: typedefs.h:79
GLintptr offset
Definition: glext.h:5920
#define INTF_NOT_EXPOSED
Definition: com_apitest.c:541
#define S_OK
Definition: intsafe.h:52
#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 529 of file com_apitest.c.

532 {
533  INT i;
534 
535  for (i = 0; class->ifaces[i].iid; i++)
536  if (IsEqualIID(class->ifaces[i].iid, iid))
537  return TRUE;
538  return FALSE;
539 }
#define TRUE
Definition: types.h:120
int32_t INT
Definition: typedefs.h:58
#define FALSE
Definition: types.h:117
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 839 of file com_apitest.c.

840 {
842 }
static KNOWN_INTERFACE KnownInterfaces[]
Definition: com_apitest.c:39
static VOID TestInterfaceRegistry(_In_ PCKNOWN_INTERFACE Interfaces, _In_ INT InterfaceCount)
Definition: com_apitest.c:773
static const INT KnownInterfaceCount
Definition: com_apitest.c:511

◆ TestClasses()

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

Definition at line 752 of file com_apitest.c.

756 {
757  HRESULT hr;
758 
760  ok(hr == S_OK, "CoInitializeEx failed. hr=0x%lx\n", hr);
761  if (myskip(SUCCEEDED(hr), "Failed to initialize COM. Cannot perform tests\n"))
762  return;
763 
767 
768  CoUninitialize();
769 }
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:1274
if SUCCEEDED(hr)
LONG HRESULT
Definition: typedefs.h:79
static VOID TestModuleRegistry(_In_ PCWSTR ModuleName, _In_ PCCLASS_AND_INTERFACES ExpectedInterfaces, _In_ INT ExpectedInterfaceCount)
Definition: com_apitest.c:634
static const INT ExpectedInterfaceCount
Definition: browseui.c:412
#define S_OK
Definition: intsafe.h:52
void WINAPI DECLSPEC_HOTPATCH CoUninitialize(void)
Definition: compobj.c:2067
#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:715
HRESULT WINAPI DECLSPEC_HOTPATCH CoInitializeEx(LPVOID lpReserved, DWORD dwCoInit)
Definition: compobj.c:2002
#define NULL
Definition: types.h:112
static VOID TestModuleInterfaces(_In_ PCCLASS_AND_INTERFACES ExpectedInterfaces, _In_ INT ExpectedInterfaceCount)
Definition: com_apitest.c:566

Referenced by START_TEST().

◆ TestInterfaceRegistry()

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

Definition at line 773 of file com_apitest.c.

776 {
777  INT i;
778  HKEY hKeyInterface;
779  LONG result;
780 
781  result = RegOpenKeyExW(HKEY_LOCAL_MACHINE, L"Software\\Classes\\Interface", 0, KEY_ENUMERATE_SUB_KEYS, &hKeyInterface);
782  ok(result == NO_ERROR, "Failed to open interface key, error %lu\n", result);
783  if (!myskip(result == NO_ERROR, "No interface key\n"))
784  {
785  for (i = 0; i < InterfaceCount; i++)
786  {
787  HKEY hKey;
789  UNICODE_STRING iid;
790  DWORD type;
791  WCHAR data[100];
792  DWORD dataSize;
793  PCKNOWN_INTERFACE iface;
794  PCWSTR expectedName;
795 
796  iface = &Interfaces[i];
797  status = RtlStringFromGUID(iface->iid, &iid);
798  ok(status == STATUS_SUCCESS, "Failed to convert guid to string for %s, status %lx\n", iface->name, status);
799  if (myskip(NT_SUCCESS(status), "No guid string\n"))
800  continue;
801 
802  result = RegOpenKeyExW(hKeyInterface, iid.Buffer, 0, KEY_QUERY_VALUE, &hKey);
803  if (iface->noreg)
804  {
805  ok(result == ERROR_FILE_NOT_FOUND, "RegOpenKeyEx returned %lu for %s\n", result, iface->name);
806  }
807  else
808  {
809  ok(result == NO_ERROR, "Failed to open key for %s, error %lu\n", iface->name, result);
810  (void)myskip(result == NO_ERROR, "No key\n");
811  }
812  RtlFreeUnicodeString(&iid);
813  if (result != NO_ERROR)
814  continue;
815 
816  dataSize = sizeof(data);
818  ok(result == NO_ERROR, "Failed to query value for %s, error %lu\n", iface->name, result);
819  if (!myskip(result == NO_ERROR, "No module name\n"))
820  {
821  ok(type == REG_SZ, "type %lu for %s\n", type, iface->name);
822  ok(dataSize % sizeof(WCHAR) == 0, "size %lu for %s\n", dataSize, iface->name);
823  ok(dataSize <= sizeof(data), "size %lu for %s\n", dataSize, iface->name);
824  ok(data[dataSize / sizeof(WCHAR) - 1] == UNICODE_NULL, "Not null terminated for %s\n", iface->name);
825  expectedName = wcschr(iface->wname, L'_');
826  if (expectedName)
827  expectedName++;
828  else
829  expectedName = iface->wname;
830  ok(!wcsicmp(data, expectedName), "Name is %ls, expected %ls\n", data, expectedName);
831  }
832 
833  RegCloseKey(hKey);
834  }
835  RegCloseKey(hKeyInterface);
836  }
837 }
const uint16_t * PCWSTR
Definition: typedefs.h:57
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:49
GLuint64EXT * result
Definition: glext.h:11304
LONG NTSTATUS
Definition: precomp.h:26
#define NO_ERROR
Definition: dderror.h:5
int32_t INT
Definition: typedefs.h:58
#define L(x)
Definition: ntvdm.h:50
#define UNICODE_NULL
long LONG
Definition: pedump.c:60
#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:4120
__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
#define wcsicmp
Definition: compat.h:15
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
FxAutoRegKey hKey
#define KEY_QUERY_VALUE
Definition: nt_native.h:1016
#define myskip(c,...)
Definition: com_apitest.c:20
#define ok(value,...)
Definition: atltest.h:57
NTSYSAPI NTSTATUS WINAPI RtlStringFromGUID(REFGUID, PUNICODE_STRING)
#define NULL
Definition: types.h:112
GLenum GLsizei dataSize
Definition: glext.h:11123
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3356
#define STATUS_SUCCESS
Definition: shellext.h:65
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
static SERVICE_STATUS status
Definition: service.c:31
BYTE * PBYTE
Definition: pedump.c:66
#define RegCloseKey(hKey)
Definition: registry.h:40
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 715 of file com_apitest.c.

719 {
720  INT iClass;
723 
725  ok(DllGetClassObject != NULL, "DllGetClassObject not found in %ls, error %lu\n", ModuleName, GetLastError());
726  if (myskip(DllGetClassObject != NULL, "No DllGetClassObject\n"))
727  return;
728 
729  for (iClass = 0; iClass < ExpectedInterfaceCount; iClass++)
730  {
731  PVOID pv;
732  HRESULT hr;
733  class = &ExpectedInterfaces[iClass];
734  hr = DllGetClassObject(class->clsid, &IID_IClassFactory, &pv);
735  ok(hr == S_OK, "DllGetClassObject failed for %s, hr = 0x%lx\n", class->name, hr);
736  if (!myskip(SUCCEEDED(hr), "No class factory\n"))
737  {
738  IClassFactory *pCF = pv;
739  hr = IClassFactory_CreateInstance(pCF, NULL, &IID_IUnknown, &pv);
740  ok(hr == S_OK, "IClassFactory::CreateInstance failed for %s, hr = 0x%lx\n", class->name, hr);
741  if (!myskip(SUCCEEDED(hr), "No instance\n"))
742  {
743  IUnknown *pUnk = pv;
744  IUnknown_Release(pUnk);
745  }
746  IClassFactory_Release(pCF);
747  }
748  }
749 }
#define HRESULT
Definition: msvc.h:7
#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:1040
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:1274
int32_t INT
Definition: typedefs.h:58
HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
Definition: shsvcs.c:38
if SUCCEEDED(hr)
void * PVOID
Definition: retypes.h:9
LONG HRESULT
Definition: typedefs.h:79
const GUID IID_IUnknown
#define __stdcall
Definition: typedefs.h:25
static const INT ExpectedInterfaceCount
Definition: browseui.c:412
#define S_OK
Definition: intsafe.h:52
#define myskip(c,...)
Definition: com_apitest.c:20
#define ok(value,...)
Definition: atltest.h:57
#define NULL
Definition: types.h:112
const WCHAR * class
Definition: main.c:68
HMODULE WINAPI GetModuleHandleW(LPCWSTR lpModuleName)
Definition: loader.c:838
#define GetProcAddress(x, y)
Definition: compat.h:612
const GUID IID_IClassFactory
static void *static void *static LPDIRECTPLAY IUnknown * pUnk
Definition: dplayx.c:30

Referenced by TestClasses().

◆ TestModuleInterfaces()

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

Definition at line 566 of file com_apitest.c.

569 {
570  HRESULT hr;
571  PVOID pObj;
572  PUNKNOWN pUnk;
573  INT iClass, iIntf;
575 
576  for (iClass = 0; iClass < ExpectedInterfaceCount; iClass++)
577  {
578  class = &ExpectedInterfaces[iClass];
579  hr = CoCreateInstance(class->clsid,
580  NULL,
581  CLSCTX_INPROC_SERVER,
582  &IID_IUnknown,
583  &pObj);
584  ok(hr == S_OK, "CoCreateInstance failed. hr=0x%lx\n", hr);
585  if (FAILED(hr))
586  {
587  skip("Failed to instantiate %s.\n", class->name);
588  continue;
589  }
590 
591  pUnk = pObj;
592 
593  /* Check that all expected interfaces are present and have the right offset */
594  for (iIntf = 0; class->ifaces[iIntf].iid; iIntf++)
595  {
596  PCKNOWN_INTERFACE iface = FindInterface(class->ifaces[iIntf].iid);
598  if (offset == INTF_NOT_EXPOSED)
599  ok(0, "%s is missing %s (offset %ld)\n", class->name, iface->name, class->ifaces[iIntf].offset);
600  else if (class->ifaces[iIntf].offset != FARAWY)
601  {
602 #ifdef FAIL_WRONG_OFFSET
603  ok(offset == class->ifaces[iIntf].offset, "%s, %s offset is %ld, expected %ld\n", class->name, iface->name, offset, class->ifaces[iIntf].offset);
604 #else
605  if (offset != class->ifaces[iIntf].offset)
606  mytrace("%s, %s offset is %ld, expected %ld\n", class->name, iface->name, offset, class->ifaces[iIntf].offset);
607 #endif
608  }
609  }
610 
611  /* Check that none other than the expected interfaces are present */
612  for (iIntf = 0; iIntf < KnownInterfaceCount; iIntf++)
613  {
614  PCKNOWN_INTERFACE iface = &KnownInterfaces[iIntf];
615  LONG offset;
616  if (IsInterfaceExpected(class, iface->iid))
617  continue;
618  offset = GetInterfaceOffset(pUnk, iface->iid);
619 #ifdef GENERATE_TABLE_ENTRIES
620  ok(offset == INTF_NOT_EXPOSED, "%s: { %s0x%lx, &%s },\n", class->name, offset < 0 ? "-" : "", offset < 0 ? -offset : offset, iface->name);
621 #else
622  ok(offset == INTF_NOT_EXPOSED, "%s exposes %s (offset %ld), but shouldn't\n", class->name, iface->name, offset);
623 #endif
624  }
625 
626  // TODO: do some aggregation
627 
628  IUnknown_Release(pUnk);
629  }
630 }
HRESULT hr
Definition: shlfolder.c:183
static const CLASS_AND_INTERFACES ExpectedInterfaces[]
Definition: browseui.c:13
int32_t INT
Definition: typedefs.h:58
long LONG
Definition: pedump.c:60
static KNOWN_INTERFACE KnownInterfaces[]
Definition: com_apitest.c:39
static PCKNOWN_INTERFACE FindInterface(_In_ const IID *iid)
Definition: com_apitest.c:515
LONG HRESULT
Definition: typedefs.h:79
GLintptr offset
Definition: glext.h:5920
#define INTF_NOT_EXPOSED
Definition: com_apitest.c:541
const GUID IID_IUnknown
static BOOLEAN IsInterfaceExpected(_In_ PCCLASS_AND_INTERFACES class, _In_ const IID *iid)
Definition: com_apitest.c:529
#define FARAWY
Definition: com_apitest.h:70
static LONG GetInterfaceOffset(_In_ PUNKNOWN pUnk, _In_ const IID *iid)
Definition: com_apitest.c:544
HRESULT WINAPI DECLSPEC_HOTPATCH CoCreateInstance(REFCLSID rclsid, LPUNKNOWN pUnkOuter, DWORD dwClsContext, REFIID iid, LPVOID *ppv)
Definition: compobj.c:3325
static const INT ExpectedInterfaceCount
Definition: browseui.c:412
#define S_OK
Definition: intsafe.h:52
#define ok(value,...)
Definition: atltest.h:57
#define NULL
Definition: types.h:112
static const INT KnownInterfaceCount
Definition: com_apitest.c:511
#define skip(...)
Definition: atltest.h:64
Definition: name.c:38
#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 634 of file com_apitest.c.

638 {
639  INT iClass;
641  HKEY hKeyClasses;
642  LONG result;
643 
644  result = RegOpenKeyExW(HKEY_LOCAL_MACHINE, L"Software\\Classes\\CLSID", 0, KEY_ENUMERATE_SUB_KEYS, &hKeyClasses);
645  ok(result == NO_ERROR, "Failed to open classes key, error %lu\n", result);
646  if (!myskip(result == NO_ERROR, "No classes key\n"))
647  {
648  for (iClass = 0; iClass < ExpectedInterfaceCount; iClass++)
649  {
650  HKEY hKey;
651  HKEY hKeyServer;
654  DWORD type;
655  WCHAR data[100];
656  DWORD dataSize;
657  PCWSTR expectedThreadingModel;
658 
659  class = &ExpectedInterfaces[iClass];
660  status = RtlStringFromGUID(class->clsid, &clsid);
661  ok(status == STATUS_SUCCESS, "Failed to convert guid to string for %s, status %lx\n", class->name, status);
662  if (myskip(NT_SUCCESS(status), "No guid string\n"))
663  continue;
664 
665  result = RegOpenKeyExW(hKeyClasses, clsid.Buffer, 0, KEY_ENUMERATE_SUB_KEYS, &hKey);
666  ok(result == NO_ERROR, "Failed to open key for %s, error %lu\n", class->name, result);
668  if (myskip(result == NO_ERROR, "No key\n"))
669  continue;
670 
671  result = RegOpenKeyExW(hKey, L"InProcServer32", 0, KEY_QUERY_VALUE, &hKeyServer);
672  ok(result == NO_ERROR, "Failed to open key for %s, error %lu\n", class->name, result);
673  RegCloseKey(hKey);
674  if (myskip(result == NO_ERROR, "No key\n"))
675  continue;
676 
677  dataSize = sizeof(data);
678  result = RegQueryValueExW(hKeyServer, NULL, NULL, &type, (PBYTE)data, &dataSize);
679  ok(result == NO_ERROR, "Failed to query value for %s, error %lu\n", class->name, result);
680  if (!myskip(result == NO_ERROR, "No module name\n"))
681  {
682  ok(type == REG_SZ || type == REG_EXPAND_SZ, "type %lu for %s\n", type, class->name);
683  ok(dataSize % sizeof(WCHAR) == 0, "size %lu for %s\n", dataSize, class->name);
684  ok(dataSize <= sizeof(data), "size %lu for %s\n", dataSize, class->name);
685  ok(data[dataSize / sizeof(WCHAR) - 1] == UNICODE_NULL, "Not null terminated for %s\n", class->name);
686  // TODO: Use SearchPath (or assume everything's in system32) and do a proper full path compare
689  ok(!wcsicmp(data, ModuleName), "Server is %ls, expected %ls for %s\n", data, ModuleName, class->name);
690  }
691 
692  dataSize = sizeof(data);
693  result = RegQueryValueExW(hKeyServer, L"ThreadingModel", NULL, &type, (PBYTE)data, &dataSize);
694  ok(result == NO_ERROR, "Failed to query value for %s, error %lu\n", class->name, result);
695  if (!myskip(result == NO_ERROR, "No ThreadingModel\n"))
696  {
697  ok(type == REG_SZ || type == REG_EXPAND_SZ, "type %lu for %s\n", type, class->name);
698  ok(dataSize % sizeof(WCHAR) == 0, "size %lu for %s\n", dataSize, class->name);
699  ok(dataSize <= sizeof(data), "size %lu for %s\n", dataSize, class->name);
700  ok(data[dataSize / sizeof(WCHAR) - 1] == UNICODE_NULL, "Not null terminated for %s\n", class->name);
701  expectedThreadingModel = class->ThreadingModel;
702  if (!expectedThreadingModel)
703  expectedThreadingModel = L"Apartment";
704  ok(!wcsicmp(data, expectedThreadingModel), "Server is %ls, expected %ls for %s\n", data, expectedThreadingModel, class->name);
705  }
706 
707  RegCloseKey(hKeyServer);
708  }
709  RegCloseKey(hKeyClasses);
710  }
711 }
const uint16_t * PCWSTR
Definition: typedefs.h:57
void WINAPI PathStripPathW(LPWSTR lpszPath)
Definition: path.c:694
GLuint64EXT * result
Definition: glext.h:11304
LONG NTSTATUS
Definition: precomp.h:26
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:1274
#define NO_ERROR
Definition: dderror.h:5
int32_t INT
Definition: typedefs.h:58
#define L(x)
Definition: ntvdm.h:50
#define UNICODE_NULL
void WINAPI PathRemoveExtensionW(LPWSTR lpszPath)
Definition: path.c:823
long LONG
Definition: pedump.c:60
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4120
__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
#define wcsicmp
Definition: compat.h:15
REFCLSID clsid
Definition: msctf.c:82
static const INT ExpectedInterfaceCount
Definition: browseui.c:412
FxAutoRegKey hKey
#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
NTSYSAPI NTSTATUS WINAPI RtlStringFromGUID(REFGUID, PUNICODE_STRING)
#define NULL
Definition: types.h:112
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:3356
#define STATUS_SUCCESS
Definition: shellext.h:65
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
static SERVICE_STATUS status
Definition: service.c:31
BYTE * PBYTE
Definition: pedump.c:66
#define RegCloseKey(hKey)
Definition: registry.h:40
#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 511 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().