ReactOS  0.4.14-dev-50-g13bb5e2
metahost.c File Reference
#include <stdarg.h>
#include "windef.h"
#include "ole2.h"
#include "corerror.h"
#include "ocidl.h"
#include "initguid.h"
#include "metahost.h"
#include "wine/test.h"
Include dependency graph for metahost.c:

Go to the source code of this file.

Macros

#define COBJMACROS
 

Functions

static HRESULT (WINAPI *pCLRCreateInstance)(REFCLSID clsid
 
static BOOL init_pointers (void)
 
static void cleanup (void)
 
static void test_enumruntimes (void)
 
static void test_getruntime (void)
 
 START_TEST (metahost)
 

Variables

static HMODULE hmscoree
 
static REFIID riid
 
static REFIID LPVOIDppInterface
 
static ICLRMetaHostmetahost
 

Macro Definition Documentation

◆ COBJMACROS

#define COBJMACROS

Definition at line 19 of file metahost.c.

Function Documentation

◆ cleanup()

static void cleanup ( void  )
static

Definition at line 60 of file metahost.c.

61 {
62  ICLRMetaHost_Release(metahost);
63 
65 }
static ICLRMetaHost * metahost
Definition: metahost.c:36
static HMODULE hmscoree
Definition: metahost.c:32
#define FreeLibrary(x)
Definition: compat.h:405

Referenced by START_TEST().

◆ HRESULT()

static HRESULT ( WINAPI pCLRCreateInstance)
static

◆ init_pointers()

static BOOL init_pointers ( void  )
static

Definition at line 38 of file metahost.c.

39 {
40  HRESULT hr = E_FAIL;
41 
42  hmscoree = LoadLibraryA("mscoree.dll");
43 
44  if (hmscoree)
45  pCLRCreateInstance = (void *)GetProcAddress(hmscoree, "CLRCreateInstance");
46 
47  if (pCLRCreateInstance)
48  hr = pCLRCreateInstance(&CLSID_CLRMetaHost, &IID_ICLRMetaHost, (void**)&metahost);
49 
50  if (FAILED(hr))
51  {
52  win_skip(".NET 4 is not installed\n");
54  return FALSE;
55  }
56 
57  return TRUE;
58 }
#define TRUE
Definition: types.h:120
HRESULT hr
Definition: shlfolder.c:183
#define E_FAIL
Definition: ddrawi.h:102
static ICLRMetaHost * metahost
Definition: metahost.c:36
HINSTANCE WINAPI DECLSPEC_HOTPATCH LoadLibraryA(LPCSTR lpLibFileName)
Definition: loader.c:111
static HMODULE hmscoree
Definition: metahost.c:32
#define FreeLibrary(x)
Definition: compat.h:405
LONG HRESULT
Definition: typedefs.h:77
#define GetProcAddress(x, y)
Definition: compat.h:410
#define win_skip
Definition: test.h:141

Referenced by START_TEST().

◆ START_TEST()

START_TEST ( metahost  )

Definition at line 145 of file metahost.c.

146 {
147  if (!init_pointers())
148  return;
149 
151 
152  test_getruntime();
153 
154  cleanup();
155 }
static BOOL init_pointers(void)
Definition: metahost.c:38
static void test_enumruntimes(void)
Definition: metahost.c:67
static void cleanup(void)
Definition: metahost.c:60
static void test_getruntime(void)
Definition: metahost.c:112

◆ test_enumruntimes()

static void test_enumruntimes ( void  )
static

Definition at line 67 of file metahost.c.

68 {
69  IEnumUnknown *runtime_enum;
70  IUnknown *unk;
71  DWORD count;
72  ICLRRuntimeInfo *runtime_info;
73  HRESULT hr;
75 
76  hr = ICLRMetaHost_EnumerateInstalledRuntimes(metahost, &runtime_enum);
77  ok(hr == S_OK, "EnumerateInstalledRuntimes returned %x\n", hr);
78  if (FAILED(hr)) return;
79 
80  while ((hr = IEnumUnknown_Next(runtime_enum, 1, &unk, &count)) == S_OK)
81  {
82  hr = IUnknown_QueryInterface(unk, &IID_ICLRRuntimeInfo, (void**)&runtime_info);
83  ok(hr == S_OK, "QueryInterface returned %x\n", hr);
84 
85  count = 1;
86  hr = ICLRRuntimeInfo_GetVersionString(runtime_info, buf, &count);
87  ok(hr == HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER), "GetVersionString returned %x\n", hr);
88  ok(count > 1, "GetVersionString returned count %u\n", count);
89 
90  count = 0xdeadbeef;
91  hr = ICLRRuntimeInfo_GetVersionString(runtime_info, NULL, &count);
92  ok(hr == S_OK, "GetVersionString returned %x\n", hr);
93  ok(count > 1 && count != 0xdeadbeef, "GetVersionString returned count %u\n", count);
94 
95  count = MAX_PATH;
96  hr = ICLRRuntimeInfo_GetVersionString(runtime_info, buf, &count);
97  ok(hr == S_OK, "GetVersionString returned %x\n", hr);
98  ok(count > 1, "GetVersionString returned count %u\n", count);
99 
100  trace("runtime found: %s\n", wine_dbgstr_w(buf));
101 
102  ICLRRuntimeInfo_Release(runtime_info);
103 
104  IUnknown_Release(unk);
105  }
106 
107  ok(hr == S_FALSE, "IEnumUnknown_Next returned %x\n", hr);
108 
109  IEnumUnknown_Release(runtime_enum);
110 }
#define HRESULT_FROM_WIN32(x)
Definition: winerror.h:92
HRESULT hr
Definition: shlfolder.c:183
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
char * wine_dbgstr_w(const wchar_t *wstr)
Definition: atltest.h:87
GLuint GLuint GLsizei count
Definition: gl.h:1545
static ICLRMetaHost * metahost
Definition: metahost.c:36
#define S_FALSE
Definition: winerror.h:2357
smooth NULL
Definition: ftsmooth.c:416
#define trace
Definition: atltest.h:70
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:77
#define MAX_PATH
Definition: compat.h:26
unsigned long DWORD
Definition: ntddk_ex.h:95
#define S_OK
Definition: intsafe.h:59
#define ok(value,...)
Definition: atltest.h:57
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10

Referenced by START_TEST().

◆ test_getruntime()

static void test_getruntime ( void  )
static

Definition at line 112 of file metahost.c.

113 {
114  static const WCHAR twodotzero[] = {'v','2','.','0','.','5','0','7','2','7',0};
115  static const WCHAR twodotzerodotzero[] = {'v','2','.','0','.','0',0};
116  HRESULT hr;
118  DWORD count;
119  WCHAR buf[MAX_PATH];
120 
121  hr = ICLRMetaHost_GetRuntime(metahost, NULL, &IID_ICLRRuntimeInfo, (void**)&info);
122  ok(hr == E_POINTER, "GetVersion failed, hr=%x\n", hr);
123 
124  hr = ICLRMetaHost_GetRuntime(metahost, twodotzero, &IID_ICLRRuntimeInfo, (void**)&info);
125  if (hr == CLR_E_SHIM_RUNTIME)
126  /* FIXME: Get Mono properly packaged so we can fail here. */
127  todo_wine ok(hr == S_OK, "GetVersion failed, hr=%x\n", hr);
128  else
129  ok(hr == S_OK, "GetVersion failed, hr=%x\n", hr);
130  if (hr != S_OK) return;
131 
132  count = MAX_PATH;
133  hr = ICLRRuntimeInfo_GetVersionString(info, buf, &count);
134  ok(hr == S_OK, "GetVersionString returned %x\n", hr);
135  ok(count == lstrlenW(buf)+1, "GetVersionString returned count %u but string of length %u\n", count, lstrlenW(buf)+1);
136  ok(lstrcmpW(buf, twodotzero) == 0, "got unexpected version %s\n", wine_dbgstr_w(buf));
137 
138  ICLRRuntimeInfo_Release(info);
139 
140  /* Versions must match exactly. */
141  hr = ICLRMetaHost_GetRuntime(metahost, twodotzerodotzero, &IID_ICLRRuntimeInfo, (void**)&info);
142  ok(hr == CLR_E_SHIM_RUNTIME, "GetVersion failed, hr=%x\n", hr);
143 }
HRESULT hr
Definition: shlfolder.c:183
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
char * wine_dbgstr_w(const wchar_t *wstr)
Definition: atltest.h:87
int WINAPI lstrcmpW(LPCWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:170
GLuint GLuint GLsizei count
Definition: gl.h:1545
#define lstrlenW
Definition: compat.h:407
struct _test_info info[]
Definition: SetCursorPos.c:19
static ICLRMetaHost * metahost
Definition: metahost.c:36
smooth NULL
Definition: ftsmooth.c:416
#define CLR_E_SHIM_RUNTIME
Definition: corerror.h:127
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:77
#define MAX_PATH
Definition: compat.h:26
unsigned long DWORD
Definition: ntddk_ex.h:95
#define todo_wine
Definition: test.h:154
#define S_OK
Definition: intsafe.h:59
#define ok(value,...)
Definition: atltest.h:57
#define E_POINTER
Definition: winerror.h:2365

Referenced by START_TEST().

Variable Documentation

◆ hmscoree

HMODULE hmscoree
static

Definition at line 32 of file metahost.c.

Referenced by cleanup(), and init_pointers().

◆ metahost

ICLRMetaHost* metahost
static

Definition at line 36 of file metahost.c.

Referenced by cleanup(), init_pointers(), test_enumruntimes(), and test_getruntime().

◆ ppInterface

REFIID LPVOID* ppInterface

Definition at line 34 of file metahost.c.

Referenced by CLRCreateInstance().

◆ riid

Definition at line 34 of file metahost.c.