1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
|
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define _GNU_SOURCE /* See feature_test_macros(7) */
#include <dlfcn.h>
#include "wrappedlibs.h"
#include "debug.h"
#include "wrapper.h"
#include "bridge.h"
#include "librarian/library_private.h"
#include "x64emu.h"
#include "emu/x64emu_private.h"
#include "callback.h"
#include "librarian.h"
#include "box64context.h"
#include "emu/x64emu_private.h"
#include "callback.h"
const char* dbusglib1Name = "libdbus-glib-1.so.2";
#define LIBNAME dbusglib1
#include "generated/wrappeddbusglib1types.h"
#include "wrappercallback.h"
#define SUPER() \
GO(0) \
GO(1) \
GO(2) \
GO(3)
// GDestroyNotify
#define GO(A) \
static uintptr_t my_GDestroyNotify_fct_##A = 0; \
static void my_GDestroyNotify_##A(void* data) \
{ \
RunFunctionFmt(my_GDestroyNotify_fct_##A, "p", data); \
}
SUPER()
#undef GO
static void* findGDestroyNotifyFct(void* fct)
{
if(!fct) return NULL;
if(GetNativeFnc((uintptr_t)fct)) return GetNativeFnc((uintptr_t)fct);
#define GO(A) if(my_GDestroyNotify_fct_##A == (uintptr_t)fct) return my_GDestroyNotify_##A;
SUPER()
#undef GO
#define GO(A) if(my_GDestroyNotify_fct_##A == 0) {my_GDestroyNotify_fct_##A = (uintptr_t)fct; return my_GDestroyNotify_##A; }
SUPER()
#undef GO
printf_log(LOG_NONE, "Warning, no more slot for dbus-glib1 GDestroyNotify callback\n");
return NULL;
}
// GClosureNotify
#define GO(A) \
static uintptr_t my_GClosureNotify_fct_##A = 0; \
static void my_GClosureNotify_##A(void* data, void* closure) \
{ \
RunFunctionFmt(my_GClosureNotify_fct_##A, "pp", data, closure); \
}
SUPER()
#undef GO
static void* findGClosureNotifyFct(void* fct)
{
if(!fct) return NULL;
if(GetNativeFnc((uintptr_t)fct)) return GetNativeFnc((uintptr_t)fct);
#define GO(A) if(my_GClosureNotify_fct_##A == (uintptr_t)fct) return my_GClosureNotify_##A;
SUPER()
#undef GO
#define GO(A) if(my_GClosureNotify_fct_##A == 0) {my_GClosureNotify_fct_##A = (uintptr_t)fct; return my_GClosureNotify_##A; }
SUPER()
#undef GO
printf_log(LOG_NONE, "Warning, no more slot for dbus-glib1 GClosureNotify callback\n");
return NULL;
}
// DBusGProxyCallNotify
#define GO(A) \
static uintptr_t my_DBusGProxyCallNotify_fct_##A = 0; \
static void my_DBusGProxyCallNotify_##A(void* proxy, void* call_id, void* data) \
{ \
RunFunctionFmt(my_DBusGProxyCallNotify_fct_##A, "ppp", proxy, call_id, data); \
}
SUPER()
#undef GO
static void* findDBusGProxyCallNotifyFct(void* fct)
{
if(!fct) return NULL;
if(GetNativeFnc((uintptr_t)fct)) return GetNativeFnc((uintptr_t)fct);
#define GO(A) if(my_DBusGProxyCallNotify_fct_##A == (uintptr_t)fct) return my_DBusGProxyCallNotify_##A;
SUPER()
#undef GO
#define GO(A) if(my_DBusGProxyCallNotify_fct_##A == 0) {my_DBusGProxyCallNotify_fct_##A = (uintptr_t)fct; return my_DBusGProxyCallNotify_##A; }
SUPER()
#undef GO
printf_log(LOG_NONE, "Warning, no more slot for dbus-glib1 DBusGProxyCallNotify callback\n");
return NULL;
}
// GCallback
#define GO(A) \
static uintptr_t my_GCallback_fct_##A = 0; \
static void my_GCallback_##A(void* a, void* b, void* c, void* d) \
{ \
RunFunctionFmt(my_GCallback_fct_##A, "pppp", a, b, c, d); \
}
SUPER()
#undef GO
static void* findGCallbackFct(void* fct)
{
if(!fct) return NULL;
if(GetNativeFnc((uintptr_t)fct)) return GetNativeFnc((uintptr_t)fct);
#define GO(A) if(my_GCallback_fct_##A == (uintptr_t)fct) return my_GCallback_##A;
SUPER()
#undef GO
#define GO(A) if(my_GCallback_fct_##A == 0) {my_GCallback_fct_##A = (uintptr_t)fct; return my_GCallback_##A; }
SUPER()
#undef GO
printf_log(LOG_NONE, "Warning, no more slot for dbus-glib1 GCallback callback\n");
return NULL;
}
// DBusGTypeSpecializedCollectionIterator
#define GO(A) \
static uintptr_t my_DBusGTypeSpecializedCollectionIterator_fct_##A = 0; \
static void my_DBusGTypeSpecializedCollectionIterator_##A(void* a, void* b) \
{ \
RunFunctionFmt(my_DBusGTypeSpecializedCollectionIterator_fct_##A, "pp", a, b); \
}
SUPER()
#undef GO
static void* findDBusGTypeSpecializedCollectionIteratorFct(void* fct)
{
if(!fct) return NULL;
if(GetNativeFnc((uintptr_t)fct)) return GetNativeFnc((uintptr_t)fct);
#define GO(A) if(my_DBusGTypeSpecializedCollectionIterator_fct_##A == (uintptr_t)fct) return my_DBusGTypeSpecializedCollectionIterator_##A;
SUPER()
#undef GO
#define GO(A) if(my_DBusGTypeSpecializedCollectionIterator_fct_##A == 0) {my_DBusGTypeSpecializedCollectionIterator_fct_##A = (uintptr_t)fct; return my_DBusGTypeSpecializedCollectionIterator_##A; }
SUPER()
#undef GO
printf_log(LOG_NONE, "Warning, no more slot for dbus-glib1 DBusGTypeSpecializedCollectionIterator callback\n");
return NULL;
}
// DBusGTypeSpecializedMapIterator
#define GO(A) \
static uintptr_t my_DBusGTypeSpecializedMapIterator_fct_##A = 0; \
static void my_DBusGTypeSpecializedMapIterator_##A(void* a, void* b, void* c) \
{ \
RunFunctionFmt(my_DBusGTypeSpecializedMapIterator_fct_##A, "ppp", a, b, c); \
}
SUPER()
#undef GO
static void* findDBusGTypeSpecializedMapIteratorFct(void* fct)
{
if(!fct) return NULL;
if(GetNativeFnc((uintptr_t)fct)) return GetNativeFnc((uintptr_t)fct);
#define GO(A) if(my_DBusGTypeSpecializedMapIterator_fct_##A == (uintptr_t)fct) return my_DBusGTypeSpecializedMapIterator_##A;
SUPER()
#undef GO
#define GO(A) if(my_DBusGTypeSpecializedMapIterator_fct_##A == 0) {my_DBusGTypeSpecializedMapIterator_fct_##A = (uintptr_t)fct; return my_DBusGTypeSpecializedMapIterator_##A; }
SUPER()
#undef GO
printf_log(LOG_NONE, "Warning, no more slot for dbus-glib1 DBusGTypeSpecializedCollectionIterator callback\n");
return NULL;
}
#undef SUPER
EXPORT void my_dbus_g_type_collection_value_iterate(x64emu_t* emu, void* value, void* cb, void* data)
{
my->dbus_g_type_collection_value_iterate(value, findDBusGTypeSpecializedCollectionIteratorFct(cb), data);
}
EXPORT void my_dbus_g_type_map_value_iterate(x64emu_t* emu, void* value, void* cb, void* data)
{
my->dbus_g_type_map_value_iterate(value, findDBusGTypeSpecializedMapIteratorFct(cb), data);
}
EXPORT void* my_dbus_g_proxy_begin_call(x64emu_t* emu, void* proxy, void* method, void* notify, void* data, void* destroy, int first, int64_t* next)
{
int narg = 0;
if(first)
while(next[narg]) ++narg;
void* n = findDBusGProxyCallNotifyFct(notify);
void* d = findGDestroyNotifyFct(destroy);
switch (narg) {
case 0: return my->dbus_g_proxy_begin_call(proxy, method, n, data, d, first, 0); // just in case
case 1: return my->dbus_g_proxy_begin_call(proxy, method, n, data, d, first, next[0], 0);
case 2: return my->dbus_g_proxy_begin_call(proxy, method, n, data, d, first, next[0], next[1], 0);
default: printf_log(LOG_NONE, "Warning, no dbus-glib1 dbus_g_proxy_begin_call wrapper for %d args\n", narg);
}
return NULL; // faillure
}
EXPORT void* my_dbus_g_proxy_begin_call_with_timeout(x64emu_t* emu, void* proxy, void* method, void* notify, void* data, void* destroy, int timeout, int first, int64_t* next)
{
int narg = 0;
if(first)
while(next[narg]) ++narg;
void* n = findDBusGProxyCallNotifyFct(notify);
void* d = findGDestroyNotifyFct(destroy);
switch (narg) {
case 0: return my->dbus_g_proxy_begin_call_with_timeout(proxy, method, n, data, d, timeout, first, 0); // just in case
case 1: return my->dbus_g_proxy_begin_call_with_timeout(proxy, method, n, data, d, timeout, first, next[0], 0);
case 2: return my->dbus_g_proxy_begin_call_with_timeout(proxy, method, n, data, d, timeout, first, next[0], next[1], 0);
default: printf_log(LOG_NONE, "Warning, no dbus-glib1 dbus_g_proxy_begin_call_with_timeout wrapper for %d args\n", narg);
}
return NULL; // faillure
}
EXPORT void my_dbus_g_proxy_connect_signal(x64emu_t* emu, void* proxy, void* name, void* handler, void* data, void* free_fnc)
{
my->dbus_g_proxy_connect_signal(proxy, name, findGCallbackFct(handler), data, findGClosureNotifyFct(free_fnc));
}
EXPORT void my_dbus_g_proxy_disconnect_signal(x64emu_t* emu, void* proxy, void* name, void* handler, void* data)
{
my->dbus_g_proxy_disconnect_signal(proxy, name, findGCallbackFct(handler), data);
}
#define PRE_INIT \
if(BOX64ENV(nogtk)) \
return -1;
#include "wrappedlib_init.h"
|