4 * Copyright (C) 2007 Robert Shearman for CodeWeavers
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library 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 GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
23 #include <wine/debug.h>
25 WINE_DEFAULT_DEBUG_CHANNEL(ole
);
27 struct registered_ept_entry
31 RPC_SYNTAX_IDENTIFIER iface
;
32 RPC_SYNTAX_IDENTIFIER syntax
;
36 char annotation
[ept_max_annotation_size
];
39 static struct list registered_ept_entry_list
= LIST_INIT(registered_ept_entry_list
);
41 static CRITICAL_SECTION csEpm
;
42 static CRITICAL_SECTION_DEBUG critsect_debug
=
45 { &critsect_debug
.ProcessLocksList
, &critsect_debug
.ProcessLocksList
},
46 0, 0, { (DWORD_PTR
)(__FILE__
": csEpm") }
48 static CRITICAL_SECTION csEpm
= { &critsect_debug
, -1, 0, 0, 0, 0 };
50 static const UUID nil_object
;
52 /* must be called inside csEpm */
53 static void delete_registered_ept_entry(struct registered_ept_entry
*entry
)
55 I_RpcFree(entry
->protseq
);
56 I_RpcFree(entry
->endpoint
);
57 I_RpcFree(entry
->address
);
58 list_remove(&entry
->entry
);
59 HeapFree(GetProcessHeap(), 0, entry
);
62 static struct registered_ept_entry
*find_ept_entry(
63 const RPC_SYNTAX_IDENTIFIER
*iface
, const RPC_SYNTAX_IDENTIFIER
*syntax
,
64 const char *protseq
, const char *endpoint
, const char *address
,
67 struct registered_ept_entry
*entry
;
68 LIST_FOR_EACH_ENTRY(entry
, ®istered_ept_entry_list
, struct registered_ept_entry
, entry
)
70 if (memcmp(&entry
->iface
, iface
, sizeof(RPC_SYNTAX_IDENTIFIER
))) continue;
71 if (memcmp(&entry
->syntax
, syntax
, sizeof(RPC_SYNTAX_IDENTIFIER
))) continue;
72 if (strcmp(entry
->protseq
, protseq
)) continue;
73 if (memcmp(&entry
->object
, object
, sizeof(UUID
))) continue;
74 WINE_TRACE("found entry with iface %d.%d %s, syntax %d.%d %s, protseq %s, object %s\n",
75 entry
->iface
.SyntaxVersion
.MajorVersion
, entry
->iface
.SyntaxVersion
.MinorVersion
,
76 wine_dbgstr_guid(&entry
->iface
.SyntaxGUID
),
77 entry
->syntax
.SyntaxVersion
.MajorVersion
, entry
->syntax
.SyntaxVersion
.MinorVersion
,
78 wine_dbgstr_guid(&entry
->syntax
.SyntaxGUID
), protseq
,
79 wine_dbgstr_guid(&entry
->object
));
82 WINE_TRACE("not found\n");
86 void __RPC_USER
ept_lookup_handle_t_rundown(ept_lookup_handle_t entry_handle
)
88 WINE_FIXME("%p\n", entry_handle
);
91 void __cdecl
ept_insert(handle_t h
,
93 ept_entry_t entries
[],
95 error_status_t
*status
)
98 RPC_STATUS rpc_status
;
100 WINE_TRACE("(%p, %u, %p, %u, %p)\n", h
, num_ents
, entries
, replace
, status
);
104 EnterCriticalSection(&csEpm
);
106 for (i
= 0; i
< num_ents
; i
++)
108 struct registered_ept_entry
*entry
= HeapAlloc(GetProcessHeap(), 0, sizeof(*entry
));
111 /* FIXME: cleanup code to delete added entries */
112 *status
= EPT_S_CANT_PERFORM_OP
;
115 list_init(&entry
->entry
);
116 memcpy(entry
->annotation
, entries
[i
].annotation
, sizeof(entries
[i
].annotation
));
117 rpc_status
= TowerExplode(entries
[i
].tower
, &entry
->iface
, &entry
->syntax
,
118 &entry
->protseq
, &entry
->endpoint
,
120 if (rpc_status
!= RPC_S_OK
)
122 WINE_WARN("TowerExplode failed %u\n", rpc_status
);
123 *status
= rpc_status
;
124 break; /* FIXME: more cleanup? */
127 entry
->object
= entries
[i
].object
;
131 /* FIXME: correct find algorithm */
132 struct registered_ept_entry
*old_entry
= find_ept_entry(&entry
->iface
, &entry
->syntax
, entry
->protseq
, entry
->endpoint
, entry
->address
, &entry
->object
);
133 if (old_entry
) delete_registered_ept_entry(old_entry
);
135 list_add_tail(®istered_ept_entry_list
, &entry
->entry
);
138 LeaveCriticalSection(&csEpm
);
141 void __cdecl
ept_delete(handle_t h
,
143 ept_entry_t entries
[],
144 error_status_t
*status
)
147 RPC_STATUS rpc_status
;
151 WINE_TRACE("(%p, %u, %p, %p)\n", h
, num_ents
, entries
, status
);
153 EnterCriticalSection(&csEpm
);
155 for (i
= 0; i
< num_ents
; i
++)
157 struct registered_ept_entry
*entry
;
158 RPC_SYNTAX_IDENTIFIER iface
, syntax
;
162 rpc_status
= TowerExplode(entries
[i
].tower
, &iface
, &syntax
, &protseq
,
163 &endpoint
, &address
);
164 if (rpc_status
!= RPC_S_OK
)
166 entry
= find_ept_entry(&iface
, &syntax
, protseq
, endpoint
, address
, &entries
[i
].object
);
168 delete_registered_ept_entry(entry
);
171 *status
= EPT_S_NOT_REGISTERED
;
179 LeaveCriticalSection(&csEpm
);
182 void __cdecl
ept_lookup(handle_t h
,
183 unsigned32 inquiry_type
,
185 rpc_if_id_p_t interface_id
,
186 unsigned32 vers_option
,
187 ept_lookup_handle_t
*entry_handle
,
189 unsigned32
*num_ents
,
190 ept_entry_t entries
[],
191 error_status_t
*status
)
193 WINE_FIXME("(%p, %p, %p): stub\n", h
, entry_handle
, status
);
195 *status
= EPT_S_CANT_PERFORM_OP
;
198 void __cdecl
ept_map(handle_t h
,
201 ept_lookup_handle_t
*entry_handle
,
202 unsigned32 max_towers
,
203 unsigned32
*num_towers
,
205 error_status_t
*status
)
207 RPC_STATUS rpc_status
;
208 RPC_SYNTAX_IDENTIFIER iface
, syntax
;
210 struct registered_ept_entry
*entry
;
215 WINE_TRACE("(%p, %p, %p, %p, %u, %p, %p, %p)\n", h
, object
, map_tower
,
216 entry_handle
, max_towers
, num_towers
, towers
, status
);
218 rpc_status
= TowerExplode(map_tower
, &iface
, &syntax
, &protseq
,
220 if (rpc_status
!= RPC_S_OK
)
222 *status
= rpc_status
;
226 EnterCriticalSection(&csEpm
);
228 LIST_FOR_EACH_ENTRY(entry
, ®istered_ept_entry_list
, struct registered_ept_entry
, entry
)
230 if (IsEqualGUID(&entry
->iface
.SyntaxGUID
, &iface
.SyntaxGUID
) &&
231 (entry
->iface
.SyntaxVersion
.MajorVersion
== iface
.SyntaxVersion
.MajorVersion
) &&
232 (entry
->iface
.SyntaxVersion
.MinorVersion
>= iface
.SyntaxVersion
.MinorVersion
) &&
233 !memcmp(&entry
->syntax
, &syntax
, sizeof(syntax
)) &&
234 !strcmp(entry
->protseq
, protseq
) &&
235 ((!object
&& IsEqualGUID(&entry
->object
, &nil_object
)) || IsEqualGUID(object
, &entry
->object
)))
237 if (*num_towers
< max_towers
)
239 rpc_status
= TowerConstruct(&entry
->iface
, &entry
->syntax
,
240 entry
->protseq
, entry
->endpoint
,
242 &towers
[*num_towers
]);
243 if (rpc_status
!= RPC_S_OK
)
245 *status
= rpc_status
;
246 break; /* FIXME: more cleanup? */
253 LeaveCriticalSection(&csEpm
);
258 void __cdecl
ept_lookup_handle_free(handle_t h
,
259 ept_lookup_handle_t
*entry_handle
,
260 error_status_t
*status
)
262 WINE_FIXME("(%p, %p, %p): stub\n", h
, entry_handle
, status
);
264 *status
= EPT_S_CANT_PERFORM_OP
;
267 void __cdecl
ept_inq_object(handle_t h
,
269 error_status_t
*status
)
271 WINE_FIXME("(%p, %p, %p): stub\n", h
, ept_object
, status
);
273 *status
= EPT_S_CANT_PERFORM_OP
;
276 void __cdecl
ept_mgmt_delete(handle_t h
,
277 boolean32 object_speced
,
280 error_status_t
*status
)
282 WINE_FIXME("(%p, %d, %p, %p, %p): stub\n", h
, object_speced
, object
, tower
, status
);
284 *status
= EPT_S_CANT_PERFORM_OP
;