ReactOS 0.4.16-dev-2491-g3dc6630
uia_private.h
Go to the documentation of this file.
1/*
2 * Copyright 2022 Connor McAdams for CodeWeavers
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
17 */
18
19#define COBJMACROS
20
21#include "uiautomation.h"
22#include "uia_classes.h"
23#include "wine/list.h"
24#include "wine/rbtree.h"
25#include "assert.h"
26
27extern HMODULE huia_module;
28
34};
35
36/*
37 * HUIANODEs that have an associated HWND are able to pull data from up to 4
38 * different providers:
39 *
40 * - Override providers are used to override values from all other providers.
41 * - Main providers are the base provider for an HUIANODE.
42 * - Nonclient providers are used to represent the nonclient area of the HWND.
43 * - HWND providers are used to represent data from the HWND as a whole, such
44 * as the bounding box.
45 *
46 * When a property is requested from the node, each provider is queried in
47 * descending order starting with the override provider until either one
48 * returns a property or there are no more providers to query.
49 */
56};
57
62};
63
64struct uia_node {
65 IWineUiaNode IWineUiaNode_iface;
67
68 IWineUiaProvider *prov[PROV_TYPE_COUNT];
73
81
85};
86
87static inline struct uia_node *impl_from_IWineUiaNode(IWineUiaNode *iface)
88{
89 return CONTAINING_RECORD(iface, struct uia_node, IWineUiaNode_iface);
90}
91
93 IWineUiaProvider IWineUiaProvider_iface;
95
96 IRawElementProviderSimple *elprov;
102};
103
104static inline struct uia_provider *impl_from_IWineUiaProvider(IWineUiaProvider *iface)
105{
107}
108
110{
113};
114
118};
119
121{
122 IWineUiaEvent IWineUiaEvent_iface;
124
128 int scope;
129
130 IWineUiaEventAdviser **event_advisers;
133
137
140 union
141 {
142 struct {
143 struct UiaCacheRequest cache_req;
144 HRESULT (*event_callback)(struct uia_event *, struct uia_event_args *, SAFEARRAY *, BSTR);
146
147 struct rb_tree win_event_hwnd_map;
151 struct {
152 IWineUiaEvent *event_iface;
153
154 struct rb_entry serverside_event_entry;
157 } u;
158};
159
162
163static inline void variant_init_bool(VARIANT *v, BOOL val)
164{
165 V_VT(v) = VT_BOOL;
166 V_BOOL(v) = val ? VARIANT_TRUE : VARIANT_FALSE;
167}
168
169static inline void variant_init_i4(VARIANT *v, int val)
170{
171 V_VT(v) = VT_I4;
172 V_I4(v) = val;
173}
174
175static inline void get_variant_for_node(HUIANODE node, VARIANT *v)
176{
177#ifdef _WIN64
178 V_VT(v) = VT_I8;
179 V_I8(v) = (UINT64)node;
180#else
181 V_VT(v) = VT_I4;
182 V_I4(v) = (UINT32)node;
183#endif
184}
185
186static inline BOOL uia_array_reserve(void **elements, SIZE_T *capacity, SIZE_T count, SIZE_T size)
187{
188 SIZE_T max_capacity, new_capacity;
189 void *new_elements;
190
191 if (count <= *capacity)
192 return TRUE;
193
194 max_capacity = ~(SIZE_T)0 / size;
195 if (count > max_capacity)
196 return FALSE;
197
198 new_capacity = max(1, *capacity);
199 while (new_capacity < count && new_capacity <= max_capacity / 2)
200 new_capacity *= 2;
201 if (new_capacity < count)
202 new_capacity = count;
203
204 new_elements = _recalloc(*elements, new_capacity, size);
205 if (!new_elements)
206 return FALSE;
207
208 *elements = new_elements;
209 *capacity = new_capacity;
210 return TRUE;
211}
212
215};
216
217/* uia_client.c */
219HRESULT get_focus_from_node_provider(IWineUiaNode *node, int idx, LONG flags, VARIANT *ret_val);
220HRESULT respond_to_win_event_on_node_provider(IWineUiaNode *node, int idx, DWORD win_event, HWND hwnd, LONG obj_id,
221 LONG child_id, IProxyProviderWinEventSink *sink);
222HRESULT create_node_from_node_provider(IWineUiaNode *node, int idx, LONG flags, VARIANT *ret_val);
224HRESULT clone_uia_node(HUIANODE in_node, HUIANODE *out_node);
225HRESULT navigate_uia_node(struct uia_node *node, int nav_dir, HUIANODE *out_node);
226HRESULT create_uia_node_from_elprov(IRawElementProviderSimple *elprov, HUIANODE *out_node,
227 BOOL get_hwnd_providers, int node_flags);
228HRESULT uia_node_from_lresult(LRESULT lr, HUIANODE *huianode, int node_flags);
230HRESULT create_uia_node_from_hwnd(HWND hwnd, HUIANODE *out_node, int node_flags);
233
234/* uia_com_client.c */
236 DWORD event_time);
237HRESULT create_uia_iface(IUnknown **iface, BOOL is_cui8);
238
239/* uia_event.c */
242 BOOL clientside_only);
244HRESULT create_msaa_provider_from_hwnd(HWND hwnd, int in_child_id, IRawElementProviderSimple **ret_elprov);
245HRESULT create_serverside_uia_event(struct uia_event **out_event, LONG process_id, LONG event_cookie);
246HRESULT uia_event_add_provider_event_adviser(IRawElementProviderAdviseEvents *advise_events,
247 struct uia_event *event);
248HRESULT uia_event_add_serverside_event_adviser(IWineUiaEvent *serverside_event, struct uia_event *event);
250HRESULT uia_add_clientside_event(HUIANODE huianode, EVENTID event_id, enum TreeScope scope, PROPERTYID *prop_ids,
251 int prop_ids_count, struct UiaCacheRequest *cache_req, SAFEARRAY *rt_id, UiaWineEventCallback *cback,
252 void *cback_data, HUIAEVENT *huiaevent);
253HRESULT uia_event_invoke(HUIANODE node, HUIANODE nav_start_node, struct uia_event_args *args,
254 struct uia_event *event);
256 HUIANODE *clientside_nav_node_out);
257
258/* uia_ids.c */
263
264/* uia_provider.c */
265HRESULT create_base_hwnd_provider(HWND hwnd, IRawElementProviderSimple **elprov);
266void uia_stop_provider_thread(void);
268LRESULT uia_lresult_from_node(HUIANODE huianode);
269HRESULT create_msaa_provider(IAccessible *acc, LONG child_id, HWND hwnd, BOOL root_acc_known,
270 BOOL is_root_acc, IRawElementProviderSimple **elprov);
271
272/* uia_utils.c */
275HRESULT get_interface_in_git(REFIID riid, DWORD git_cookie, IUnknown **ret_iface);
277void uia_cache_request_destroy(struct UiaCacheRequest *cache_req);
281int uia_compare_safearrays(SAFEARRAY *sa1, SAFEARRAY *sa2, int prop_type);
284BOOL uia_hwnd_map_check_hwnd(struct rb_tree *hwnd_map, HWND hwnd);
286void uia_hwnd_map_remove_hwnd(struct rb_tree *hwnd_map, HWND hwnd);
287void uia_hwnd_map_init(struct rb_tree *hwnd_map);
288void uia_hwnd_map_destroy(struct rb_tree *hwnd_map);
COMPILER_DEPENDENT_UINT64 UINT64
Definition: actypes.h:131
static struct sockaddr_in sa
Definition: adnsresfilter.c:69
Definition: list.h:37
HRESULT hr
Definition: delayimp.cpp:573
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
unsigned int idx
Definition: utils.c:41
OLECHAR * BSTR
Definition: compat.h:2293
@ VT_I8
Definition: compat.h:2314
@ VT_I4
Definition: compat.h:2298
@ VT_BOOL
Definition: compat.h:2306
static void * user_data
Definition: metahost.c:106
_ACRTIMP void *__cdecl _recalloc(void *, size_t, size_t) __WINE_ALLOC_SIZE(2
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
const GLdouble * v
Definition: gl.h:2040
GLuint GLuint GLsizei count
Definition: gl.h:1545
struct _cl_event * event
Definition: glext.h:7739
GLenum src
Definition: glext.h:6340
GLsizeiptr size
Definition: glext.h:5919
GLenum condition
Definition: glext.h:9255
GLenum GLenum dst
Definition: glext.h:6340
GLbitfield flags
Definition: glext.h:7161
GLsizei GLenum GLboolean sink
Definition: glext.h:5672
GLuint GLfloat * val
Definition: glext.h:7180
REFIID riid
Definition: atlbase.h:39
LONG_PTR LRESULT
Definition: minwindef.h:176
static IPrintDialogCallback callback
Definition: printdlg.c:326
static DWORD thread_id
Definition: protocol.c:159
unsigned int UINT
Definition: ndis.h:50
#define V_I8(A)
Definition: oleauto.h:249
#define V_BOOL(A)
Definition: oleauto.h:224
#define V_VT(A)
Definition: oleauto.h:211
#define V_I4(A)
Definition: oleauto.h:247
long LONG
Definition: pedump.c:60
#define REFIID
Definition: guiddef.h:118
Definition: match.c:390
Definition: rbtree.h:30
Definition: rbtree.h:40
struct UiaEventArgs simple_args
Definition: uia_private.h:111
Definition: uia_event.c:108
struct uia_event::@594::@595 clientside
IWineUiaEventAdviser ** event_advisers
Definition: uia_private.h:130
IWineUiaEvent IWineUiaEvent_iface
Definition: uia_private.h:122
int event_id
Definition: uia_private.h:127
union uia_event::@594 u
struct uia_event_map_entry * event_map_entry
Definition: uia_private.h:135
LONG event_defunct
Definition: uia_private.h:136
SAFEARRAY * runtime_id
Definition: uia_private.h:126
int event_advisers_count
Definition: uia_private.h:131
BOOL event_thread_started
Definition: uia_private.h:148
BOOL desktop_subtree_event
Definition: uia_private.h:125
struct uia_event::@594::@596 serverside
LONG event_cookie
Definition: uia_private.h:138
int event_type
Definition: uia_private.h:139
SIZE_T event_advisers_arr_size
Definition: uia_private.h:132
IWineUiaEvent * event_iface
Definition: uia_private.h:152
LONG proc_id
Definition: uia_private.h:155
DWORD git_cookie
Definition: uia_private.h:149
void * callback_data
Definition: uia_private.h:145
struct list event_list_entry
Definition: uia_private.h:134
BOOL ignore_clientside_hwnd_provs
Definition: uia_private.h:80
int creator_prov_idx
Definition: uia_private.h:72
LONG ref
Definition: uia_private.h:66
BOOL no_prepare
Definition: uia_private.h:75
BOOL ignore_com_threading
Definition: uia_private.h:79
BOOL nested_node
Definition: uia_private.h:76
struct uia_provider_thread_map_entry * map
Definition: uia_private.h:84
IWineUiaProvider * prov[PROV_TYPE_COUNT]
Definition: uia_private.h:68
DWORD git_cookie[PROV_TYPE_COUNT]
Definition: uia_private.h:69
struct list prov_thread_list_entry
Definition: uia_private.h:82
IWineUiaNode IWineUiaNode_iface
Definition: uia_private.h:65
struct list node_map_list_entry
Definition: uia_private.h:83
BOOL disconnected
Definition: uia_private.h:77
int prov_count
Definition: uia_private.h:70
int parent_link_idx
Definition: uia_private.h:71
int creator_prov_type
Definition: uia_private.h:78
HWND hwnd
Definition: uia_private.h:74
IRawElementProviderSimple * elprov
Definition: uia_private.h:96
BOOL return_nested_node
Definition: uia_private.h:98
BOOL refuse_hwnd_node_providers
Definition: uia_private.h:97
IWineUiaProvider IWineUiaProvider_iface
Definition: uia_private.h:93
BOOL parent_check_ran
Definition: uia_private.h:99
#define max(a, b)
Definition: svc.c:63
ULONG_PTR SIZE_T
Definition: typedefs.h:80
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
uint32_t UINT32
Definition: typedefs.h:59
BOOL uia_hwnd_is_visible(HWND hwnd)
Definition: uia_utils.c:391
const struct uia_control_type_info * uia_control_type_info_from_id(CONTROLTYPEID control_type_id)
Definition: uia_ids.c:616
HRESULT uia_event_add_provider_event_adviser(IRawElementProviderAdviseEvents *advise_events, struct uia_event *event)
Definition: uia_event.c:1385
HMODULE huia_module
Definition: uia_main.c:29
void uia_hwnd_map_init(struct rb_tree *hwnd_map)
Definition: uia_utils.c:479
HRESULT uia_cache_request_clone(struct UiaCacheRequest *dst, struct UiaCacheRequest *src)
Definition: uia_utils.c:264
int get_node_provider_type_at_idx(struct uia_node *node, int idx)
Definition: uia_client.c:266
HRESULT uia_condition_check(HUIANODE node, struct UiaCondition *condition)
Definition: uia_client.c:3363
HRESULT create_serverside_uia_event(struct uia_event **out_event, LONG process_id, LONG event_cookie)
Definition: uia_event.c:1234
static struct uia_provider * impl_from_IWineUiaProvider(IWineUiaProvider *iface)
Definition: uia_private.h:104
HRESULT register_interface_in_git(IUnknown *iface, REFIID riid, DWORD *ret_cookie)
Definition: uia_utils.c:40
HRESULT create_msaa_provider(IAccessible *acc, LONG child_id, HWND hwnd, BOOL root_acc_known, BOOL is_root_acc, IRawElementProviderSimple **elprov)
const struct uia_event_info * uia_event_info_from_id(EVENTID event_id)
Definition: uia_ids.c:438
uia_event_type
Definition: uia_private.h:115
@ EVENT_TYPE_SERVERSIDE
Definition: uia_private.h:117
@ EVENT_TYPE_CLIENTSIDE
Definition: uia_private.h:116
HRESULT get_interface_in_git(REFIID riid, DWORD git_cookie, IUnknown **ret_iface)
Definition: uia_utils.c:79
static void get_variant_for_node(HUIANODE node, VARIANT *v)
Definition: uia_private.h:175
uia_node_flags
Definition: uia_private.h:58
@ NODE_FLAG_IGNORE_CLIENTSIDE_HWND_PROVS
Definition: uia_private.h:59
@ NODE_FLAG_IGNORE_COM_THREADING
Definition: uia_private.h:61
@ NODE_FLAG_NO_PREPARE
Definition: uia_private.h:60
void uia_stop_provider_thread(void)
BOOL uia_is_top_level_hwnd(HWND hwnd)
Definition: uia_utils.c:407
BOOL uia_hwnd_map_check_hwnd(struct rb_tree *hwnd_map, HWND hwnd)
Definition: uia_utils.c:437
uia_node_prov_type
Definition: uia_private.h:50
@ PROV_TYPE_OVERRIDE
Definition: uia_private.h:51
@ PROV_TYPE_MAIN
Definition: uia_private.h:52
@ PROV_TYPE_HWND
Definition: uia_private.h:54
@ PROV_TYPE_NONCLIENT
Definition: uia_private.h:53
@ PROV_TYPE_COUNT
Definition: uia_private.h:55
HRESULT UiaWineEventCallback(struct uia_event *, struct uia_event_args *, SAFEARRAY *, BSTR)
Definition: uia_private.h:160
HRESULT uia_add_clientside_event(HUIANODE huianode, EVENTID event_id, enum TreeScope scope, PROPERTYID *prop_ids, int prop_ids_count, struct UiaCacheRequest *cache_req, SAFEARRAY *rt_id, UiaWineEventCallback *cback, void *cback_data, HUIAEVENT *huiaevent)
Definition: uia_event.c:1628
HRESULT create_uia_iface(IUnknown **iface, BOOL is_cui8)
HRESULT uia_hwnd_map_add_hwnd(struct rb_tree *hwnd_map, HWND hwnd)
Definition: uia_utils.c:442
HRESULT attach_event_to_uia_node(HUIANODE node, struct uia_event *event)
Definition: uia_client.c:1337
LRESULT uia_lresult_from_node(HUIANODE huianode)
HRESULT respond_to_win_event_on_node_provider(IWineUiaNode *node, int idx, DWORD win_event, HWND hwnd, LONG obj_id, LONG child_id, IProxyProviderWinEventSink *sink)
Definition: uia_client.c:381
HRESULT get_safearray_bounds(SAFEARRAY *sa, LONG *lbound, LONG *elems)
Definition: uia_utils.c:319
HRESULT uia_event_add_win_event_hwnd(struct uia_event *event, HWND hwnd)
Definition: uia_event.c:83
HRESULT clone_uia_node(HUIANODE in_node, HUIANODE *out_node)
Definition: uia_client.c:738
void uia_hwnd_map_destroy(struct rb_tree *hwnd_map)
Definition: uia_utils.c:484
HRESULT write_runtime_id_base(SAFEARRAY *sa, HWND hwnd)
Definition: uia_utils.c:102
HRESULT create_uia_node_from_hwnd(HWND hwnd, HUIANODE *out_node, int node_flags)
Definition: uia_client.c:2721
void uia_provider_thread_remove_node(HUIANODE node)
HRESULT uia_event_check_node_within_event_scope(struct uia_event *event, HUIANODE node, SAFEARRAY *rt_id, HUIANODE *clientside_nav_node_out)
Definition: uia_event.c:1814
HRESULT uia_com_win_event_callback(DWORD event_id, HWND hwnd, LONG obj_id, LONG child_id, DWORD thread_id, DWORD event_time)
HRESULT navigate_uia_node(struct uia_node *node, int nav_dir, HUIANODE *out_node)
Definition: uia_client.c:914
void uia_hwnd_map_remove_hwnd(struct rb_tree *hwnd_map, HWND hwnd)
Definition: uia_utils.c:462
const struct uia_pattern_info * uia_pattern_info_from_id(PATTERNID pattern_id)
Definition: uia_ids.c:540
BOOL uia_clientside_event_start_event_thread(struct uia_event *event)
Definition: uia_event.c:988
static struct uia_node * impl_from_IWineUiaNode(IWineUiaNode *iface)
Definition: uia_private.h:87
HRESULT uia_node_from_lresult(LRESULT lr, HUIANODE *huianode, int node_flags)
Definition: uia_client.c:2642
uia_prop_type
Definition: uia_private.h:29
@ PROP_TYPE_ELEM_PROP
Definition: uia_private.h:31
@ PROP_TYPE_SPECIAL
Definition: uia_private.h:32
@ PROP_TYPE_UNKNOWN
Definition: uia_private.h:30
@ PROP_TYPE_PATTERN_PROP
Definition: uia_private.h:33
HRESULT create_msaa_provider_from_hwnd(HWND hwnd, int in_child_id, IRawElementProviderSimple **ret_elprov)
Definition: uia_event.c:677
static void variant_init_bool(VARIANT *v, BOOL val)
Definition: uia_private.h:163
HRESULT unregister_interface_in_git(DWORD git_cookie)
Definition: uia_utils.c:63
HRESULT UiaWineEventForEachCallback(struct uia_event *, void *)
Definition: uia_private.h:161
HRESULT get_safearray_dim_bounds(SAFEARRAY *sa, UINT dim, LONG *lbound, LONG *elems)
Definition: uia_utils.c:301
HRESULT uia_event_advise_node(struct uia_event *event, HUIANODE node)
Definition: uia_event.c:1577
HRESULT create_node_from_node_provider(IWineUiaNode *node, int idx, LONG flags, VARIANT *ret_val)
Definition: uia_client.c:397
const struct uia_prop_info * uia_prop_info_from_id(PROPERTYID prop_id)
Definition: uia_ids.c:332
void uia_node_lresult_release(LRESULT lr)
Definition: uia_client.c:2683
HRESULT create_uia_node_from_elprov(IRawElementProviderSimple *elprov, HUIANODE *out_node, BOOL get_hwnd_providers, int node_flags)
Definition: uia_client.c:2049
void uia_cache_request_destroy(struct UiaCacheRequest *cache_req)
Definition: uia_utils.c:257
HRESULT uia_event_for_each(int event_id, UiaWineEventForEachCallback *callback, void *user_data, BOOL clientside_only)
Definition: uia_event.c:255
HRESULT create_base_hwnd_provider(HWND hwnd, IRawElementProviderSimple **elprov)
HRESULT uia_event_invoke(HUIANODE node, HUIANODE nav_start_node, struct uia_event_args *args, struct uia_event *event)
Definition: uia_event.c:1738
provider_method_flags
Definition: uia_private.h:213
@ PROV_METHOD_FLAG_RETURN_NODE_LRES
Definition: uia_private.h:214
static void variant_init_i4(VARIANT *v, int val)
Definition: uia_private.h:169
int uia_compare_safearrays(SAFEARRAY *sa1, SAFEARRAY *sa2, int prop_type)
Definition: uia_utils.c:334
static BOOL uia_array_reserve(void **elements, SIZE_T *capacity, SIZE_T count, SIZE_T size)
Definition: uia_private.h:186
HRESULT get_focus_from_node_provider(IWineUiaNode *node, int idx, LONG flags, VARIANT *ret_val)
Definition: uia_client.c:350
BOOL uia_condition_matched(HRESULT hr)
Definition: uia_client.c:3302
HRESULT uia_event_add_serverside_event_adviser(IWineUiaEvent *serverside_event, struct uia_event *event)
Definition: uia_event.c:1519
int PATTERNID
int EVENTID
int PROPERTYID
int CONTROLTYPEID
Definition: dlist.c:348
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023
#define HRESULT
Definition: msvc.h:7