@@ -161,9 +161,10 @@ function extract(conn, xpc_object, dict) {
161
161
}
162
162
}
163
163
164
- function parseAndSendDictData ( fnName , conn , dict ) {
164
+ var ps = new NativeCallback ( ( fnName , conn , dict ) => {
165
165
var ret = { } ;
166
- ret [ "name" ] = fnName ;
166
+ var fname = rcstr ( fnName ) ;
167
+ ret [ "name" ] = fname ;
167
168
ret [ "connName" ] = "UNKNOWN" ;
168
169
ret [ "pid" ] = xpc_connection_get_pid ( conn ) ;
169
170
if ( conn != null ) {
@@ -172,52 +173,99 @@ function parseAndSendDictData(fnName, conn, dict) {
172
173
ret [ "connName" ] = rcstr ( connName ) ;
173
174
}
174
175
}
175
- if ( fnName == "xpc_connection_set_event_handler" ) {
176
+ if ( fname == "xpc_connection_set_event_handler" ) {
176
177
var data = { "blockImplementation" : dict . toString ( ) } ;
177
178
ret [ "dictionary" ] = data ;
178
179
} else {
179
180
ret [ "dictionary" ] = extract ( conn , dict , dict ) ;
180
181
}
181
182
send ( JSON . stringify ( ret ) ) ;
182
- }
183
+ } , "void" , [ "pointer" , "pointer" , "pointer" ] ) ;
183
184
184
- Interceptor . attach ( xpc_connection_send_notification , {
185
- onEnter ( args ) {
186
- parseAndSendDictData ( "xpc_connection_send_notification" , args [ 0 ] , args [ 1 ] ) ;
185
+ var cm_notification = new CModule ( `
186
+ #include <gum/guminterceptor.h>
187
+ extern void ps(void*,void*,void*);
188
+
189
+ void onEnter(GumInvocationContext * ic)
190
+ {
191
+ void * conn = gum_invocation_context_get_nth_argument(ic,0);
192
+ void * obj = gum_invocation_context_get_nth_argument(ic,1);
193
+ ps("xpc_connection_send_notification", conn, obj);
187
194
}
188
- } ) ;
195
+ ` , { ps } ) ;
189
196
190
- Interceptor . attach ( xpc_connection_send_message , {
191
- onEnter ( args ) {
192
- parseAndSendDictData ( "xpc_connection_send_message" , args [ 0 ] , args [ 1 ] ) ;
197
+ var cm_send_message = new CModule ( `
198
+ #include <gum/guminterceptor.h>
199
+ extern void ps(void*,void*,void*);
200
+
201
+ void onEnter(GumInvocationContext * ic)
202
+ {
203
+ void * conn = gum_invocation_context_get_nth_argument(ic,0);
204
+ void * obj = gum_invocation_context_get_nth_argument(ic,1);
205
+ ps("xpc_connection_send_message", conn, obj);
193
206
}
194
- } ) ;
207
+ ` , { ps } ) ;
195
208
196
- Interceptor . attach ( xpc_connection_send_message_with_reply , {
197
- onEnter ( args ) {
198
- parseAndSendDictData ( "xpc_connection_send_message_with_reply" , args [ 0 ] , args [ 1 ] ) ;
209
+ var cm_send_message_with_reply = new CModule ( `
210
+ #include <gum/guminterceptor.h>
211
+ extern void ps(void*,void*,void*);
212
+
213
+ void onEnter(GumInvocationContext * ic)
214
+ {
215
+ void * conn = gum_invocation_context_get_nth_argument(ic,0);
216
+ void * obj = gum_invocation_context_get_nth_argument(ic,1);
217
+ ps("xpc_connection_send_message_with_reply", conn, obj);
199
218
}
200
- } )
219
+ ` , { ps } ) ;
201
220
202
- Interceptor . attach ( xpc_connection_send_message_with_reply_sync , {
203
- onEnter ( args ) {
204
- parseAndSendDictData ( "xpc_connection_send_message_with_reply_sync" , args [ 0 ] , args [ 1 ] ) ;
221
+ var cm_send_message_with_reply_sync = new CModule ( `
222
+ #include <gum/guminterceptor.h>
223
+ extern void ps(void*,void*,void*);
224
+
225
+ void onEnter(GumInvocationContext * ic)
226
+ {
227
+ void * conn = gum_invocation_context_get_nth_argument(ic,0);
228
+ void * obj = gum_invocation_context_get_nth_argument(ic,1);
229
+ ps("xpc_connection_send_message_with_reply_sync", conn, obj);
205
230
}
206
- } )
231
+ ` , { ps } ) ;
207
232
208
- Interceptor . attach ( xpc_connection_call_event_handler , {
209
- onEnter ( args ) {
210
- parseAndSendDictData ( "xpc_connection_call_event_handler" , args [ 0 ] , args [ 1 ] ) ;
233
+ var cm_call_event_handler = new CModule ( `
234
+ #include <gum/guminterceptor.h>
235
+ extern void ps(void*,void*,void*);
236
+
237
+ void onEnter(GumInvocationContext * ic)
238
+ {
239
+ void * conn = gum_invocation_context_get_nth_argument(ic,0);
240
+ void * obj = gum_invocation_context_get_nth_argument(ic,1);
241
+ ps("xpc_connection_call_event_handler", conn, obj);
211
242
}
212
- } ) ;
243
+ ` , { ps } ) ;
213
244
214
- Interceptor . attach ( xpc_connection_set_event_handler , {
215
- onEnter ( args ) {
216
- const implementationAddr = args [ 1 ] . add ( Process . pointerSize * 2 ) ;
217
- const implementation = Memory . readPointer ( implementationAddr ) ;
218
- parseAndSendDictData ( "xpc_connection_set_event_handler" , args [ 0 ] , implementation ) ;
245
+ var psize = Memory . alloc ( Process . pointerSize ) ;
246
+ Memory . writeInt ( psize , Process . pointerSize * 2 ) ;
247
+
248
+ var cm_set_event_handler = new CModule ( `
249
+ #include <gum/guminterceptor.h>
250
+ extern int pointerSize;
251
+ extern void ps(void*,void*,void*);
252
+
253
+ void onEnter(GumInvocationContext * ic)
254
+ {
255
+ void * conn = gum_invocation_context_get_nth_argument(ic,0);
256
+ void * obj = gum_invocation_context_get_nth_argument(ic,1);
257
+ void * impl = obj + (pointerSize*2);
258
+ ps("xpc_connection_set_event_handler", conn, impl);
219
259
}
220
- } )
260
+ ` , { pointerSize : psize , ps} ) ;
261
+
262
+ Interceptor . attach ( xpc_connection_send_notification , cm_notification ) ;
263
+ Interceptor . attach ( xpc_connection_send_message , cm_send_message ) ;
264
+ Interceptor . attach ( xpc_connection_send_message_with_reply , cm_send_message_with_reply ) ;
265
+ Interceptor . attach ( xpc_connection_send_message_with_reply_sync , cm_send_message_with_reply_sync ) ;
266
+ Interceptor . attach ( xpc_connection_call_event_handler , cm_call_event_handler ) ;
267
+
268
+ Interceptor . attach ( xpc_connection_set_event_handler , cm_set_event_handler ) ;
221
269
222
270
Interceptor . attach ( xpc_connection_create_mach_service , {
223
271
onEnter ( args ) {
0 commit comments