2
Unix SMB/CIFS implementation.
4
Copyright (C) 2004 Jelmer Vernooij <jelmer@samba.org>
6
This program is free software; you can redistribute it and/or modify
7
it under the terms of the GNU General Public License as published by
8
the Free Software Foundation; either version 2 of the License, or
9
(at your option) any later version.
11
This program is distributed in the hope that it will be useful,
12
but WITHOUT ANY WARRANTY; without even the implied warranty of
13
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
GNU General Public License for more details.
16
You should have received a copy of the GNU General Public License
17
along with this program; if not, write to the Free Software
18
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22
#include "../lib/util/dlinklist.h"
23
#include "lib/com/com.h"
24
#include "lib/events/events.h"
25
#include "librpc/gen_ndr/com_dcom.h"
27
WERROR com_init_ctx(struct com_context **ctx, struct tevent_context *event_ctx)
29
*ctx = talloc(NULL, struct com_context);
30
if (event_ctx == NULL) {
31
event_ctx = event_context_init(*ctx);
33
(*ctx)->event_ctx = event_ctx;
37
WERROR com_create_object(struct com_context *ctx, struct GUID *clsid, int num_ifaces, struct GUID *iid, struct IUnknown **ip, WERROR *results)
39
struct IUnknown *iunk = NULL;
40
struct IClassFactory *factory;
43
struct GUID classfact_iid;
45
GUID_from_string(NDR_ICLASSFACTORY_UUID, &classfact_iid);
47
/* Obtain class object */
48
error = com_get_class_object(ctx, clsid, &classfact_iid, (struct IUnknown **)&factory);
49
if (!W_ERROR_IS_OK(error)) {
50
DEBUG(3, ("Unable to obtain class object for %s\n", GUID_string(NULL, clsid)));
54
/* Run IClassFactory::CreateInstance() */
55
error = IClassFactory_CreateInstance(factory, ctx, NULL, &classfact_iid, &iunk);
56
if (!W_ERROR_IS_OK(error)) {
57
DEBUG(3, ("Error while calling IClassFactory::CreateInstance : %s\n", win_errstr(error)));
62
DEBUG(0, ("IClassFactory_CreateInstance returned success but result pointer is still NULL!\n"));
63
return WERR_GENERAL_FAILURE;
66
/* Release class object */
67
IUnknown_Release(factory, ctx);
71
/* Do one or more QueryInterface calls */
72
for (i = 0; i < num_ifaces; i++) {
73
results[i] = IUnknown_QueryInterface(iunk, ctx, &iid[i], &ip[i]);
74
if (!W_ERROR_IS_OK(results[i])) error = results[i];
80
WERROR com_get_class_object(struct com_context *ctx, struct GUID *clsid, struct GUID *iid, struct IUnknown **ip)
84
iu = com_class_by_clsid(ctx, clsid);
86
return WERR_CLASS_NOT_REGISTERED;
89
return IUnknown_QueryInterface(iu, ctx, iid, ip);