ReactOS 0.4.16-dev-109-gf4cb10f
ole_server.c File Reference
#include <windows.h>
#include <exdisp.h>
#include <tlhelp32.h>
#include <stdio.h>
#include <assert.h>
#include "wine/test.h"
#include <initguid.h>
Include dependency graph for ole_server.c:

Go to the source code of this file.

Classes

struct  winetest_info
 
struct  UnknownImpl
 
struct  ClassFactoryImpl
 

Macros

#define COBJMACROS
 
#define CONST_VTABLE
 
#define GUID_NAME(guid)    { &IID_##guid, #guid }
 

Functions

 DEFINE_GUID (CLSID_WineTestObject, 0xdeadbeef, 0xdead, 0xbeef, 0xde, 0xad, 0xbe, 0xef, 0xde, 0xad, 0xbe, 0xef)
 
 DEFINE_GUID (CLSID_UnknownUnmarshal, 0x4c1e39e1, 0xe3e3, 0x4296, 0xaa, 0x86, 0xec, 0x93, 0x8d, 0x89, 0x6e, 0x92)
 
static const chardebugstr_guid (const GUID *guid)
 
static UnknownImplimpl_from_IUnknown (IUnknown *iface)
 
static HRESULT WINAPI UnknownImpl_QueryInterface (IUnknown *iface, REFIID iid, void **ppv)
 
static ULONG WINAPI UnknownImpl_AddRef (IUnknown *iface)
 
static ULONG WINAPI UnknownImpl_Release (IUnknown *iface)
 
static ClassFactoryImplimpl_from_IClassFactory (IClassFactory *iface)
 
static HRESULT WINAPI ClassFactoryImpl_QueryInterface (IClassFactory *iface, REFIID iid, void **ppv)
 
static ULONG WINAPI ClassFactoryImpl_AddRef (IClassFactory *iface)
 
static ULONG WINAPI ClassFactoryImpl_Release (IClassFactory *iface)
 
static HRESULT WINAPI ClassFactoryImpl_CreateInstance (IClassFactory *iface, IUnknown *punkouter, REFIID iid, void **ppv)
 
static HRESULT WINAPI ClassFactoryImpl_LockServer (IClassFactory *iface, BOOL lock)
 
static void ole_server (void)
 
static BOOL register_server (const char *server, BOOL inproc_handler)
 
static void unregister_server (void)
 
static HANDLE start_server (const char *argv0)
 
 START_TEST (ole_server)
 

Variables

struct {
   const GUID *   guid
 
   const char *   name
 
guid_name []
 
static LONG obj_ref
 
static LONG class_ref
 
static LONG server_locks
 
static const IUnknownVtbl UnknownImpl_Vtbl
 
static const IClassFactoryVtbl ClassFactoryImpl_Vtbl
 
static ClassFactoryImpl factory = { { &ClassFactoryImpl_Vtbl }, 0 }
 

Macro Definition Documentation

◆ COBJMACROS

#define COBJMACROS

Definition at line 21 of file ole_server.c.

◆ CONST_VTABLE

#define CONST_VTABLE

Definition at line 22 of file ole_server.c.

◆ GUID_NAME

#define GUID_NAME (   guid)     { &IID_##guid, #guid }

Function Documentation

◆ ClassFactoryImpl_AddRef()

static ULONG WINAPI ClassFactoryImpl_AddRef ( IClassFactory iface)
static

Definition at line 172 of file ole_server.c.

173{
176
178
179 trace("server: factory_AddRef: %p, ref %u\n", iface, ref);
180 return ref;
181}
#define InterlockedIncrement
Definition: armddk.h:53
#define trace
Definition: atltest.h:70
static ClassFactoryImpl * impl_from_IClassFactory(IClassFactory *iface)
Definition: ole_server.c:146
static LONG class_ref
Definition: ole_server.c:61
Definition: send.c:48
uint32_t ULONG
Definition: typedefs.h:59

◆ ClassFactoryImpl_CreateInstance()

static HRESULT WINAPI ClassFactoryImpl_CreateInstance ( IClassFactory iface,
IUnknown punkouter,
REFIID  iid,
void **  ppv 
)
static

Definition at line 194 of file ole_server.c.

196{
198 HRESULT hr;
199
200 trace("server: factory_CreateInstance: %p,%s,%p\n", iface, debugstr_guid(iid), ppv);
201
202 if (punkouter) return CLASS_E_NOAGGREGATION;
203
204 unknown = HeapAlloc(GetProcessHeap(), 0, sizeof(*unknown));
205 if (!unknown) return E_OUTOFMEMORY;
206
207 unknown->IUnknown_iface.lpVtbl = &UnknownImpl_Vtbl;
208 unknown->ref = 0;
209 IUnknown_AddRef(&unknown->IUnknown_iface);
210
211 hr = IUnknown_QueryInterface(&unknown->IUnknown_iface, iid, ppv);
212 IUnknown_Release(&unknown->IUnknown_iface);
213
214 return hr;
215}
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
static WCHAR unknown[MAX_STRING_RESOURCE_LEN]
Definition: object.c:1605
#define GetProcessHeap()
Definition: compat.h:736
#define HeapAlloc
Definition: compat.h:733
REFIID LPVOID * ppv
Definition: atlbase.h:39
#define debugstr_guid
Definition: kernel32.h:35
static const IUnknownVtbl UnknownImpl_Vtbl
Definition: ole_server.c:133
HRESULT hr
Definition: shlfolder.c:183
#define CLASS_E_NOAGGREGATION
Definition: winerror.h:2662

◆ ClassFactoryImpl_LockServer()

static HRESULT WINAPI ClassFactoryImpl_LockServer ( IClassFactory iface,
BOOL  lock 
)
static

Definition at line 217 of file ole_server.c.

218{
220
221 trace("server: factory_LockServer: %p,%d, ref %u\n", iface, lock, ref);
222 return S_OK;
223}
#define InterlockedDecrement
Definition: armddk.h:52
#define S_OK
Definition: intsafe.h:52
static LONG server_locks
Definition: ole_server.c:61
rwlock_t lock
Definition: tcpcore.h:0

◆ ClassFactoryImpl_QueryInterface()

static HRESULT WINAPI ClassFactoryImpl_QueryInterface ( IClassFactory iface,
REFIID  iid,
void **  ppv 
)
static

Definition at line 151 of file ole_server.c.

153{
155
156 trace("server: factory_QueryInterface: %p,%s,%p\n", iface, debugstr_guid(iid), ppv);
157
158 if (!ppv) return E_INVALIDARG;
159
160 if (IsEqualIID(&IID_IUnknown, iid) ||
162 {
163 IClassFactory_AddRef(&This->IClassFactory_iface);
164 *ppv = &This->IClassFactory_iface;
165 return S_OK;
166 }
167
168 *ppv = NULL;
169 return E_NOINTERFACE;
170}
const GUID IID_IUnknown
const GUID IID_IClassFactory
#define E_INVALIDARG
Definition: ddrawi.h:101
#define NULL
Definition: types.h:112
#define IsEqualIID(riid1, riid2)
Definition: guiddef.h:95
#define E_NOINTERFACE
Definition: winerror.h:2364

◆ ClassFactoryImpl_Release()

static ULONG WINAPI ClassFactoryImpl_Release ( IClassFactory iface)
static

Definition at line 183 of file ole_server.c.

184{
187
189
190 trace("server: factory_Release: %p, ref %u\n", iface, ref);
191 return ref;
192}

◆ debugstr_guid()

static const char * debugstr_guid ( const GUID guid)
static

Definition at line 63 of file ole_server.c.

64{
65 int i;
66
67 if (!guid) return "(null)";
68
69 for (i = 0; i < ARRAY_SIZE(guid_name); i++)
70 {
72 return guid_name[i].name;
73 }
74
75 return wine_dbgstr_guid(guid);
76}
#define ARRAY_SIZE(A)
Definition: main.h:20
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 const struct @1692 guid_name[]
const GUID * guid
Definition: ole_server.c:42
static __inline const char * wine_dbgstr_guid(const GUID *id)
Definition: debug.h:197
Definition: name.c:39

◆ DEFINE_GUID() [1/2]

DEFINE_GUID ( CLSID_UnknownUnmarshal  ,
0x4c1e39e1  ,
0xe3e3  ,
0x4296  ,
0xaa  ,
0x86  ,
0xec  ,
0x93  ,
0x8d  ,
0x89  ,
0x6e  ,
0x92   
)

◆ DEFINE_GUID() [2/2]

DEFINE_GUID ( CLSID_WineTestObject  ,
0xdeadbeef  ,
0xdead  ,
0xbeef  ,
0xde  ,
0xad  ,
0xbe  ,
0xef  ,
0xde  ,
0xad  ,
0xbe  ,
0xef   
)

◆ impl_from_IClassFactory()

static ClassFactoryImpl * impl_from_IClassFactory ( IClassFactory iface)
inlinestatic

Definition at line 146 of file ole_server.c.

147{
148 return CONTAINING_RECORD(iface, ClassFactoryImpl, IClassFactory_iface);
149}
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260

Referenced by ClassFactoryImpl_AddRef(), ClassFactoryImpl_QueryInterface(), and ClassFactoryImpl_Release().

◆ impl_from_IUnknown()

static UnknownImpl * impl_from_IUnknown ( IUnknown iface)
inlinestatic

Definition at line 85 of file ole_server.c.

86{
87 return CONTAINING_RECORD(iface, UnknownImpl, IUnknown_iface);
88}

Referenced by UnknownImpl_AddRef(), UnknownImpl_QueryInterface(), and UnknownImpl_Release().

◆ ole_server()

static void ole_server ( void  )
static

Definition at line 236 of file ole_server.c.

237{
238 HRESULT hr;
239 DWORD key;
240
241 trace("server: starting %u\n", GetCurrentProcessId());
242
244 if (hr == S_OK)
245 {
246 trace("server: registering class object\n");
247 hr = CoRegisterClassObject(&CLSID_WineTestObject, (IUnknown *)&factory.IClassFactory_iface,
248 CLSCTX_SERVER, REGCLS_MULTIPLEUSE, &key);
249 if (hr == S_OK)
250 {
251 HANDLE done_event, init_done_event;
252
253 done_event = OpenEventA(SYNCHRONIZE, FALSE, "ole_server_done_event");
254 ok(done_event != 0, "server: OpenEvent error %d\n", GetLastError());
255 init_done_event = OpenEventA(EVENT_MODIFY_STATE, FALSE, "ole_server_init_done_event");
256 ok(init_done_event != 0, "server: OpenEvent error %d\n", GetLastError());
257
258 SetEvent(init_done_event);
259
260 trace("server: waiting for requests\n");
261 WaitForSingleObject(done_event, INFINITE);
262
263 /* 1 remainining class ref is supposed to be cleared by CoRevokeClassObject */
264 ok(class_ref == 1, "expected 1 class refs, got %d\n", class_ref);
265 ok(!obj_ref, "expected 0 object refs, got %d\n", obj_ref);
266 ok(!server_locks, "expected 0 server locks, got %d\n", server_locks);
267
268 CloseHandle(done_event);
269 CloseHandle(init_done_event);
270 if (0)
271 {
272 /* calling CoRevokeClassObject terminates process under Win7 */
273 trace("call CoRevokeClassObject\n");
275 trace("ret CoRevokeClassObject\n");
276 }
277 }
278 trace("server: call CoUninitialize\n");
280 trace("server: ret CoUninitialize\n");
281 }
282
283 trace("server: exiting %u\n", GetCurrentProcessId());
284}
#define ok(value,...)
Definition: atltest.h:57
#define FALSE
Definition: types.h:117
#define CloseHandle
Definition: compat.h:739
HRESULT WINAPI CoRegisterClassObject(REFCLSID rclsid, LPUNKNOWN pUnk, DWORD dwClsContext, DWORD flags, LPDWORD lpdwRegister)
Definition: compobj.c:2897
HRESULT WINAPI DECLSPEC_HOTPATCH CoRevokeClassObject(DWORD dwRegister)
Definition: compobj.c:1086
HRESULT WINAPI DECLSPEC_HOTPATCH CoInitializeEx(LPVOID lpReserved, DWORD dwCoInit)
Definition: compobj.c:2002
void WINAPI DECLSPEC_HOTPATCH CoUninitialize(void)
Definition: compobj.c:2067
#define INFINITE
Definition: serial.h:102
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SYNCHRONIZE
Definition: nt_native.h:61
@ REGCLS_MULTIPLEUSE
Definition: objbase.h:393
@ COINIT_MULTITHREADED
Definition: objbase.h:279
static LONG obj_ref
Definition: ole_server.c:61
Definition: main.c:439
IClassFactory IClassFactory_iface
Definition: main.c:440
Definition: copy.c:22
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
BOOL WINAPI DECLSPEC_HOTPATCH SetEvent(IN HANDLE hEvent)
Definition: synch.c:733
HANDLE WINAPI DECLSPEC_HOTPATCH OpenEventA(IN DWORD dwDesiredAccess, IN BOOL bInheritHandle, IN LPCSTR lpName)
Definition: synch.c:669
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define EVENT_MODIFY_STATE
Definition: winbase.h:163
DWORD WINAPI GetCurrentProcessId(void)
Definition: proc.c:1158

Referenced by START_TEST().

◆ register_server()

static BOOL register_server ( const char server,
BOOL  inproc_handler 
)
static

Definition at line 287 of file ole_server.c.

288{
289 static const WCHAR clsidW[] = {'C','L','S','I','D','\\',0};
290 DWORD ret;
291 HKEY root;
292 WCHAR buf[39 + 6];
293 char server_path[MAX_PATH];
294
295 lstrcpyA(server_path, server);
296 lstrcatA(server_path, " ole_server");
297
299 StringFromGUID2(&CLSID_WineTestObject, buf + 6, 39);
300
303 if (ret == ERROR_SUCCESS)
304 {
305 ret = RegSetValueA(root, "LocalServer32", REG_SZ, server_path, strlen(server_path));
306 ok(ret == ERROR_SUCCESS, "RegSetValue error %u\n", ret);
307
308 if (inproc_handler)
309 {
310 ret = RegSetValueA(root, "InprocHandler32", REG_SZ, "ole32.dll", 9);
311 ok(ret == ERROR_SUCCESS, "RegSetValue error %u\n", ret);
312 }
313
315 }
316
317 return ret == ERROR_SUCCESS;
318}
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
#define RegCloseKey(hKey)
Definition: registry.h:49
struct _root root
#define ERROR_SUCCESS
Definition: deptool.c:10
static const WCHAR clsidW[]
LONG WINAPI RegCreateKeyExW(_In_ HKEY hKey, _In_ LPCWSTR lpSubKey, _In_ DWORD Reserved, _In_opt_ LPWSTR lpClass, _In_ DWORD dwOptions, _In_ REGSAM samDesired, _In_opt_ LPSECURITY_ATTRIBUTES lpSecurityAttributes, _Out_ PHKEY phkResult, _Out_opt_ LPDWORD lpdwDisposition)
Definition: reg.c:1096
LONG WINAPI RegSetValueA(HKEY hKeyOriginal, LPCSTR lpSubKey, DWORD dwType, LPCSTR lpData, DWORD cbData)
Definition: reg.c:4954
#define MAX_PATH
Definition: compat.h:34
#define lstrcpyW
Definition: compat.h:749
INT WINAPI StringFromGUID2(REFGUID id, LPOLESTR str, INT cmax)
Definition: compobj.c:2434
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
#define REG_SZ
Definition: layer.c:22
LPSTR WINAPI lstrcpyA(LPSTR lpString1, LPCSTR lpString2)
Definition: lstring.c:100
LPSTR WINAPI lstrcatA(LPSTR lpString1, LPCSTR lpString2)
Definition: lstring.c:123
#define KEY_READ
Definition: nt_native.h:1023
#define KEY_CREATE_SUB_KEY
Definition: nt_native.h:1018
#define KEY_WRITE
Definition: nt_native.h:1031
static rfbScreenInfoPtr server
Definition: vnc.c:74
int ret
#define HKEY_CLASSES_ROOT
Definition: winreg.h:10
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by START_TEST().

◆ start_server()

static HANDLE start_server ( const char argv0)
static

Definition at line 344 of file ole_server.c.

345{
347 STARTUPINFOA si;
349 char cmdline[MAX_PATH * 2];
350 BOOL ret;
351
352 memset(&si, 0, sizeof(si));
353 si.cb = sizeof(si);
357 si.hStdError = si.hStdOutput;
358
359 sa.nLength = sizeof(sa);
360 sa.lpSecurityDescriptor = NULL;
361 sa.bInheritHandle = TRUE;
362
363 sprintf(cmdline, "\"%s\" ole_server -server", argv0);
364 ret = CreateProcessA(argv0, cmdline, NULL, NULL, TRUE, 0, NULL, NULL, &si, &pi);
365 ok(ret, "CreateProcess(%s) error %d\n", cmdline, GetLastError());
366 if (!ret) return 0;
367
368 CloseHandle(pi.hThread);
369 return pi.hProcess;
370}
static struct sockaddr_in sa
Definition: adnsresfilter.c:69
HANDLE WINAPI GetStdHandle(IN DWORD nStdHandle)
Definition: console.c:203
#define TRUE
Definition: types.h:120
BOOL WINAPI DECLSPEC_HOTPATCH CreateProcessA(LPCSTR lpApplicationName, LPSTR lpCommandLine, LPSECURITY_ATTRIBUTES lpProcessAttributes, LPSECURITY_ATTRIBUTES lpThreadAttributes, BOOL bInheritHandles, DWORD dwCreationFlags, LPVOID lpEnvironment, LPCSTR lpCurrentDirectory, LPSTARTUPINFOA lpStartupInfo, LPPROCESS_INFORMATION lpProcessInformation)
Definition: proc.c:4747
unsigned int BOOL
Definition: ntddk_ex.h:94
#define sprintf(buf, format,...)
Definition: sprintf.c:55
static refpint_t pi[]
Definition: server.c:96
#define memset(x, y, z)
Definition: compat.h:39
static char argv0[MAX_PATH]
Definition: shlexec.c:49
TCHAR * cmdline
Definition: stretchblt.cpp:32
HANDLE hStdOutput
Definition: winbase.h:847
HANDLE hStdError
Definition: winbase.h:848
DWORD dwFlags
Definition: winbase.h:842
DWORD cb
Definition: winbase.h:831
HANDLE hStdInput
Definition: winbase.h:846
#define STD_OUTPUT_HANDLE
Definition: winbase.h:268
#define STD_INPUT_HANDLE
Definition: winbase.h:267
#define STARTF_USESTDHANDLES
Definition: winbase.h:499

Referenced by START_TEST().

◆ START_TEST()

START_TEST ( ole_server  )

Definition at line 372 of file ole_server.c.

373{
374 CLSID clsid = CLSID_WineTestObject;
375 HRESULT hr;
378 IOleObject *oleobj;
379 IRunnableObject *runobj;
380 DWORD ret;
381 HANDLE mapping, done_event, init_done_event, process;
382 struct winetest_info *info;
383 int argc;
384 char **argv;
385
386 mapping = CreateFileMappingA(INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, 0, 4096, "winetest_ole_server");
387 ok(mapping != 0, "CreateFileMapping failed\n");
389
391
392 done_event = CreateEventA(NULL, TRUE, FALSE, "ole_server_done_event");
393 ok(done_event != 0, "CreateEvent error %d\n", GetLastError());
394 init_done_event = CreateEventA(NULL, TRUE, FALSE, "ole_server_init_done_event");
395 ok(init_done_event != 0, "CreateEvent error %d\n", GetLastError());
396
397 if (argc > 2)
398 {
399 if (!lstrcmpiA(argv[2], "-Embedding"))
400 {
401 trace("server: Refusing to be run by ole32\n");
402 return;
403 }
404
405 if (!lstrcmpiA(argv[2], "-server"))
406 {
407 info->child_failures = 0;
408 ole_server();
409 info->child_failures = winetest_get_failures();
410 return;
411 }
412
413 trace("server: Unknown parameter: %s\n", argv[2]);
414 return;
415 }
416
417 if (!register_server(argv[0], FALSE))
418 {
419 win_skip("not enough permissions to create a server CLSID key\n");
420 return;
421 }
422
423 if (!(process = start_server(argv[0])))
424 {
426 return;
427 }
428 WaitForSingleObject(init_done_event, 5000);
429
431 ok(hr == S_OK, "OleInitialize error %#x\n", hr);
432
433 hr = CoCreateInstance(&clsid, NULL, CLSCTX_INPROC_HANDLER, &IID_IUnknown, (void **)&unknown);
434 ok(hr == REGDB_E_CLASSNOTREG, "expected REGDB_E_CLASSNOTREG, got %#x\n", hr);
435
436 if (!register_server(argv[0], TRUE))
437 {
438 win_skip("not enough permissions to create a server CLSID key\n");
440 return;
441 }
442
443 trace("call CoCreateInstance(&IID_NULL)\n");
444 hr = CoCreateInstance(&clsid, NULL, CLSCTX_LOCAL_SERVER, &IID_NULL, (void **)&unknown);
445 trace("ret CoCreateInstance(&IID_NULL)\n");
446 ok(hr == E_NOINTERFACE, "expected E_NOINTERFACE, got %#x\n", hr);
447
448 /* in-process handler supports IID_IUnknown starting from Vista */
449 trace("call CoCreateInstance(&IID_IUnknown)\n");
450 hr = CoCreateInstance(&clsid, NULL, CLSCTX_INPROC_HANDLER, &IID_IUnknown, (void **)&unknown);
451 trace("ret CoCreateInstance(&IID_IUnknown)\n");
452 ok(hr == S_OK || broken(hr == REGDB_E_CLASSNOTREG) /* XP,win2000 and earlier */, "CoCreateInstance(IID_IUnknown) error %#x\n", hr);
453 if (hr != S_OK)
454 {
455 win_skip("In-process handler doesn't support IID_IUnknown on this platform\n");
457 }
458
459 trace("call CoCreateInstance(&IID_IOleObject)\n");
460 hr = CoCreateInstance(&clsid, NULL, CLSCTX_LOCAL_SERVER, &IID_IOleObject, (void **)&oleobj);
461 trace("ret CoCreateInstance(&IID_IOleObject)\n");
462 ok(hr == E_NOINTERFACE, "expected E_NOINTERFACE, got %#x\n", hr);
463
464 trace("call IUnknown_QueryInterface(&IID_IRunnableObject)\n");
465 hr = IUnknown_QueryInterface(unknown, &IID_IRunnableObject, (void **)&runobj);
466 trace("ret IUnknown_QueryInterface(&IID_IRunnableObject)\n");
467 ok(hr == S_OK, "QueryInterface(&IID_IRunnableObject) error %#x\n", hr);
468
469 ret = IRunnableObject_IsRunning(runobj);
470 ok(!ret, "expected 0, got %d\n", ret);
471
472 trace("call OleRun\n");
473 hr = OleRun(unknown);
474 trace("ret OleRun\n");
476 ok(hr == S_OK, "OleRun error %#x\n", hr);
477
478 ret = IRunnableObject_IsRunning(runobj);
480 ok(ret == 1, "expected 1, got %d\n", ret);
481
482 trace("call IRunnableObject_Release\n");
483 ret = IRunnableObject_Release(runobj);
484 trace("ret IRunnableObject_Release\n");
485 ok(ret == 1, "expected ref 1, got %u\n", ret);
486
487 trace("call IUnknown_QueryInterface(&IID_IOleObject)\n");
488 hr = IUnknown_QueryInterface(unknown, &IID_IOleObject, (void **)&oleobj);
489 trace("ret IUnknown_QueryInterface(&IID_IOleObject)\n");
490 ok(hr == S_OK, "QueryInterface(&IID_IOleObject) error %#x\n", hr);
491
492 trace("call IOleObject_Release\n");
493 ret = IOleObject_Release(oleobj);
494 trace("ret IOleObject_Release\n");
495 ok(ret == 1, "expected ref 1, got %u\n", ret);
496
497 trace("call IUnknown_Release\n");
498 ret = IUnknown_Release(unknown);
499 trace("ret IUnknown_Release\n");
500 ok(!ret, "expected ref 0, got %u\n", ret);
501
503 /* local server supports IID_IUnknown */
504 trace("call CoCreateInstance(&IID_IUnknown)\n");
505 hr = CoCreateInstance(&clsid, NULL, CLSCTX_LOCAL_SERVER, &IID_IUnknown, (void **)&unknown);
506 trace("ret CoCreateInstance(&IID_IUnknown)\n");
507 ok(hr == S_OK, "CoCreateInstance(IID_IUnknown) error %#x\n", hr);
508
509 trace("call IUnknown_QueryInterface(&IID_IRunnableObject)\n");
510 hr = IUnknown_QueryInterface(unknown, &IID_IRunnableObject, (void **)&runobj);
511 trace("ret IUnknown_QueryInterface(&IID_IRunnableObject)\n");
512 ok(hr == E_NOINTERFACE, "expected E_NOINTERFACE, got %#x\n", hr);
513
514 trace("call OleRun\n");
515 hr = OleRun(unknown);
516 trace("ret OleRun\n");
517 ok(hr == S_OK, "OleRun error %#x\n", hr);
518
519 trace("call IUnknown_QueryInterface(&IID_IOleObject)\n");
520 hr = IUnknown_QueryInterface(unknown, &IID_IOleObject, (void **)&oleobj);
521 trace("ret IUnknown_QueryInterface(&IID_IOleObject)\n");
522 ok(hr == E_NOINTERFACE, "expected E_NOINTERFACE, got %#x\n", hr);
523
524 trace("call IUnknown_Release\n");
525 ret = IUnknown_Release(unknown);
526 trace("ret IUnknown_Release\n");
527 ok(!ret, "expected ref 0, got %u\n", ret);
528
529 trace("call CoGetClassObject(&IID_IClassFactory)\n");
530 hr = CoGetClassObject(&clsid, CLSCTX_LOCAL_SERVER, NULL, &IID_IClassFactory, (void **)&factory);
531 trace("ret CoGetClassObject(&IID_IClassFactory)\n");
532 ok(hr == S_OK, "CoGetClassObject error %#x\n", hr);
533
534 trace("call IClassFactory_CreateInstance(&IID_NULL)\n");
535 hr = IClassFactory_CreateInstance(factory, NULL, &IID_NULL, (void **)&oleobj);
536 trace("ret IClassFactory_CreateInstance(&IID_NULL)\n");
537 ok(hr == E_NOINTERFACE, "expected E_NOINTERFACE, got %#x\n", hr);
538
539 trace("call IClassFactory_CreateInstance(&IID_IOleObject)\n");
540 hr = IClassFactory_CreateInstance(factory, NULL, &IID_IOleObject, (void **)&oleobj);
541 trace("ret IClassFactory_CreateInstance(&IID_IOleObject)\n");
542 ok(hr == E_NOINTERFACE, "expected E_NOINTERFACE, got %#x\n", hr);
543
544 trace("call IClassFactory_Release\n");
545 ret = IClassFactory_Release(factory);
546 trace("ret IClassFactory_Release\n");
547 ok(!ret, "expected ref 0, got %u\n", ret);
548
549 trace("signalling termination\n");
550 SetEvent(done_event);
552 ok(ret == WAIT_OBJECT_0, "server failed to terminate\n");
553
555
557
558 if (info->child_failures)
559 {
560 trace("%d failures in child process\n", info->child_failures);
561 winetest_add_failures(info->child_failures);
562 }
563}
static int argc
Definition: ServiceArgs.c:12
#define broken(x)
Definition: atltest.h:178
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
#define FILE_MAP_READ
Definition: compat.h:776
#define MapViewOfFile
Definition: compat.h:745
int WINAPI lstrcmpiA(LPCSTR str1, LPCSTR str2)
Definition: locale.c:4223
HRESULT WINAPI DECLSPEC_HOTPATCH CoCreateInstance(REFCLSID rclsid, LPUNKNOWN pUnkOuter, DWORD dwClsContext, REFIID iid, LPVOID *ppv)
Definition: compobj.c:3325
HRESULT WINAPI DECLSPEC_HOTPATCH CoGetClassObject(REFCLSID rclsid, DWORD dwClsContext, COSERVERINFO *pServerInfo, REFIID iid, LPVOID *ppv)
Definition: compobj.c:3103
HRESULT WINAPI DECLSPEC_HOTPATCH OleRun(LPUNKNOWN pUnknown)
Definition: ole2.c:1205
void WINAPI DECLSPEC_HOTPATCH OleUninitialize(void)
Definition: ole2.c:230
HANDLE NTAPI CreateFileMappingA(IN HANDLE hFile, IN LPSECURITY_ATTRIBUTES lpFileMappingAttributes, IN DWORD flProtect, IN DWORD dwMaximumSizeHigh, IN DWORD dwMaximumSizeLow, IN LPCSTR lpName)
Definition: filemap.c:23
GLenum GLenum GLenum GLenum mapping
Definition: glext.h:9031
#define todo_wine
Definition: custom.c:89
static void test_local_server(void)
Definition: marshal.c:3824
#define argv
Definition: mplay32.c:18
REFCLSID clsid
Definition: msctf.c:82
#define PAGE_READWRITE
Definition: nt_native.h:1304
static ClassFactoryImpl factory
Definition: ole_server.c:234
static void ole_server(void)
Definition: ole_server.c:236
static void unregister_server(void)
Definition: ole_server.c:320
static BOOL register_server(const char *server, BOOL inproc_handler)
Definition: ole_server.c:287
static HANDLE start_server(const char *argv0)
Definition: ole_server.c:344
const GUID IID_IRunnableObject
const GUID IID_IOleObject
#define IID_NULL
Definition: guiddef.h:98
#define win_skip
Definition: test.h:163
LONG winetest_get_failures(void)
int winetest_get_mainargs(char ***pargv)
void winetest_add_failures(LONG new_failures)
HANDLE WINAPI DECLSPEC_HOTPATCH CreateEventA(IN LPSECURITY_ATTRIBUTES lpEventAttributes OPTIONAL, IN BOOL bManualReset, IN BOOL bInitialState, IN LPCSTR lpName OPTIONAL)
Definition: synch.c:637
#define FILE_MAP_WRITE
Definition: winbase.h:154
#define WAIT_OBJECT_0
Definition: winbase.h:406
#define REGDB_E_CLASSNOTREG
Definition: winerror.h:2696

◆ UnknownImpl_AddRef()

static ULONG WINAPI UnknownImpl_AddRef ( IUnknown iface)
static

Definition at line 110 of file ole_server.c.

111{
114
116
117 trace("server: unknown_AddRef: %p, ref %u\n", iface, ref);
118 return ref;
119}
static UnknownImpl * impl_from_IUnknown(IUnknown *iface)
Definition: ole_server.c:85

◆ UnknownImpl_QueryInterface()

static HRESULT WINAPI UnknownImpl_QueryInterface ( IUnknown iface,
REFIID  iid,
void **  ppv 
)
static

Definition at line 90 of file ole_server.c.

92{
94
95 trace("server: unknown_QueryInterface: %p,%s,%p\n", iface, debugstr_guid(iid), ppv);
96
97 if (!ppv) return E_INVALIDARG;
98
99 if (IsEqualIID(&IID_IUnknown, iid))
100 {
101 *ppv = &This->IUnknown_iface;
102 IUnknown_AddRef(&This->IUnknown_iface);
103 return S_OK;
104 }
105
106 *ppv = NULL;
107 return E_NOINTERFACE;
108}

◆ UnknownImpl_Release()

static ULONG WINAPI UnknownImpl_Release ( IUnknown iface)
static

Definition at line 121 of file ole_server.c.

122{
125
127
128 trace("server: unknown_Release: %p, ref %u\n", iface, ref);
129 if (ref == 0) HeapFree(GetProcessHeap(), 0, This);
130 return ref;
131}
#define HeapFree(x, y, z)
Definition: compat.h:735

◆ unregister_server()

static void unregister_server ( void  )
static

Definition at line 320 of file ole_server.c.

321{
322 static const WCHAR clsidW[] = {'C','L','S','I','D','\\',0};
323 DWORD ret;
324 HKEY root;
325 WCHAR buf[39 + 6];
326
328 StringFromGUID2(&CLSID_WineTestObject, buf + 6, 39);
329
331 DELETE, NULL, &root, NULL);
332 if (ret == ERROR_SUCCESS)
333 {
334 ret = RegDeleteKeyA(root, "InprocHandler32");
335 ok(ret == ERROR_SUCCESS, "RegDeleteKey error %u\n", ret);
336 ret = RegDeleteKeyA(root, "LocalServer32");
337 ok(ret == ERROR_SUCCESS, "RegDeleteKey error %u\n", ret);
338 ret = RegDeleteKeyA(root, "");
339 ok(ret == ERROR_SUCCESS, "RegDeleteKey error %u\n", ret);
341 }
342}
LONG WINAPI RegDeleteKeyA(_In_ HKEY hKey, _In_ LPCSTR lpSubKey)
Definition: reg.c:1224
#define DELETE
Definition: nt_native.h:57

Referenced by START_TEST().

Variable Documentation

◆ class_ref

LONG class_ref
static

Definition at line 61 of file ole_server.c.

Referenced by ClassFactoryImpl_AddRef(), ClassFactoryImpl_Release(), and ole_server().

◆ ClassFactoryImpl_Vtbl

const IClassFactoryVtbl ClassFactoryImpl_Vtbl
static
Initial value:
=
{
}
static ULONG WINAPI ClassFactoryImpl_Release(IClassFactory *iface)
Definition: ole_server.c:183
static HRESULT WINAPI ClassFactoryImpl_LockServer(IClassFactory *iface, BOOL lock)
Definition: ole_server.c:217
static ULONG WINAPI ClassFactoryImpl_AddRef(IClassFactory *iface)
Definition: ole_server.c:172
static HRESULT WINAPI ClassFactoryImpl_CreateInstance(IClassFactory *iface, IUnknown *punkouter, REFIID iid, void **ppv)
Definition: ole_server.c:194
static HRESULT WINAPI ClassFactoryImpl_QueryInterface(IClassFactory *iface, REFIID iid, void **ppv)
Definition: ole_server.c:151

Definition at line 225 of file ole_server.c.

◆ factory

Definition at line 234 of file ole_server.c.

Referenced by START_TEST().

◆ guid

const GUID* guid

Definition at line 42 of file ole_server.c.

Referenced by debugstr_guid().

◆ 

const struct { ... } guid_name[]
Initial value:
=
{
#define GUID_NAME(guid)
{ &CLSID_IdentityUnmarshal, "CLSID_IdentityUnmarshal" },
{ &CLSID_UnknownUnmarshal, "CLSID_UnknownUnmarshal" },
}
const CLSID CLSID_IdentityUnmarshal
#define GUID_NAME(guid)

Referenced by debugstr_guid().

◆ name

Definition at line 43 of file ole_server.c.

◆ obj_ref

LONG obj_ref
static

Definition at line 61 of file ole_server.c.

Referenced by ole_server(), UnknownImpl_AddRef(), and UnknownImpl_Release().

◆ server_locks

LONG server_locks
static

◆ UnknownImpl_Vtbl

const IUnknownVtbl UnknownImpl_Vtbl
static
Initial value:
=
{
}
static ULONG WINAPI UnknownImpl_AddRef(IUnknown *iface)
Definition: ole_server.c:110
static ULONG WINAPI UnknownImpl_Release(IUnknown *iface)
Definition: ole_server.c:121
static HRESULT WINAPI UnknownImpl_QueryInterface(IUnknown *iface, REFIID iid, void **ppv)
Definition: ole_server.c:90

Definition at line 133 of file ole_server.c.

Referenced by ClassFactoryImpl_CreateInstance().