@@ -8,12 +8,12 @@ const {
8
8
} = ObjC . classes ;
9
9
10
10
// Intercept these functions
11
- const xpc_connection_send_notification = Module . findExportByName ( LIBXPC_PATH , "xpc_connection_send_notification" ) ;
12
- const xpc_connection_send_message = Module . findExportByName ( LIBXPC_PATH , "xpc_connection_send_message" ) ;
13
- const xpc_connection_send_message_with_reply = Module . findExportByName ( LIBXPC_PATH , "xpc_connection_send_message_with_reply" ) ;
14
- const xpc_connection_send_message_with_reply_sync = Module . findExportByName ( LIBXPC_PATH , "xpc_connection_send_message_with_reply_sync" ) ;
15
- const xpc_connection_create_mach_service = Module . findExportByName ( LIBXPC_PATH , "xpc_connection_create_mach_service" ) ;
16
- const xpc_connection_set_event_handler = Module . findExportByName ( LIBXPC_PATH , "xpc_connection_set_event_handler" ) ;
11
+ const xpc_connection_send_notification = Module . getExportByName ( LIBXPC_PATH , "xpc_connection_send_notification" ) ;
12
+ const xpc_connection_send_message = Module . getExportByName ( LIBXPC_PATH , "xpc_connection_send_message" ) ;
13
+ const xpc_connection_send_message_with_reply = Module . getExportByName ( LIBXPC_PATH , "xpc_connection_send_message_with_reply" ) ;
14
+ const xpc_connection_send_message_with_reply_sync = Module . getExportByName ( LIBXPC_PATH , "xpc_connection_send_message_with_reply_sync" ) ;
15
+ const xpc_connection_create_mach_service = Module . getExportByName ( LIBXPC_PATH , "xpc_connection_create_mach_service" ) ;
16
+ const xpc_connection_set_event_handler = Module . getExportByName ( LIBXPC_PATH , "xpc_connection_set_event_handler" ) ;
17
17
18
18
const __CFBinaryPlistCreate15 = DebugSymbol . fromName ( '__CFBinaryPlistCreate15' ) . address ;
19
19
const _xpc_connection_call_event_handler = DebugSymbol . fromName ( "_xpc_connection_call_event_handler" ) . address ;
@@ -23,7 +23,6 @@ const xpc_connection_call_event_handler = new NativeFunction(_xpc_connection_cal
23
23
// Use these functions to make sense out of xpc_object_t and xpc_connection_t
24
24
const xpc_connection_get_name = getFunc ( "xpc_connection_get_name" , "pointer" , [ "pointer" ] ) ;
25
25
const xpc_get_type = getFunc ( "xpc_get_type" , "pointer" , [ "pointer" ] ) ;
26
- const xpc_type_get_name = getFunc ( "xpc_type_get_name" , "pointer" , [ "pointer" ] ) ;
27
26
const xpc_dictionary_get_value = getFunc ( "xpc_dictionary_get_value" , "pointer" , [ "pointer" , "pointer" ] ) ;
28
27
const xpc_string_get_string_ptr = getFunc ( "xpc_string_get_string_ptr" , "pointer" , [ "pointer" ] ) ;
29
28
const xpc_copy_description = getFunc ( "xpc_copy_description" , "pointer" , [ "pointer" ] ) ;
@@ -44,16 +43,42 @@ const xpc_date_get_value = getFunc("xpc_date_get_value", "int64", ["pointer"]);
44
43
45
44
const xpc_connection_get_pid = getFunc ( "xpc_connection_get_pid" , "int" , [ "pointer" ] ) ;
46
45
46
+ const xpc_type_activity = getPtr ( "_xpc_type_activity" ) ;
47
+ const xpc_type_array = getPtr ( "_xpc_type_array" ) ;
48
+ const xpc_type_base = getPtr ( "_xpc_type_base" ) ;
49
+ const xpc_type_bool = getPtr ( "_xpc_type_bool" ) ;
50
+ const xpc_type_bundle = getPtr ( "_xpc_type_bundle" ) ;
51
+ const xpc_type_connection = getPtr ( "_xpc_type_connection" ) ;
52
+ const xpc_type_data = getPtr ( "_xpc_type_data" ) ;
53
+ const xpc_type_date = getPtr ( "_xpc_type_date" ) ;
54
+ const xpc_type_dictionary = getPtr ( "_xpc_type_dictionary" ) ;
55
+ const xpc_type_double = getPtr ( "_xpc_type_double" ) ;
56
+ const xpc_type_endpoint = getPtr ( "_xpc_type_endpoint" ) ;
57
+ const xpc_type_error = getPtr ( "_xpc_type_error" ) ;
58
+ const xpc_type_fd = getPtr ( "_xpc_type_fd" ) ;
59
+ const xpc_type_file_transfer = getPtr ( "_xpc_type_file_transfer" ) ;
60
+ const xpc_type_int64 = getPtr ( "_xpc_type_int64" ) ;
61
+ const xpc_type_mach_recv = getPtr ( "_xpc_type_mach_recv" ) ;
62
+ const xpc_type_mach_send = getPtr ( "_xpc_type_mach_send" ) ;
63
+ const xpc_type_null = getPtr ( "_xpc_type_null" ) ;
64
+ const xpc_type_pipe = getPtr ( "_xpc_type_pipe" ) ;
65
+ const xpc_type_pointer = getPtr ( "_xpc_type_pointer" ) ;
66
+ const xpc_type_serializer = getPtr ( "_xpc_type_serializer" ) ;
67
+ const xpc_type_service = getPtr ( "_xpc_type_service" ) ;
68
+ const xpc_type_service_instance = getPtr ( "_xpc_type_service_instance" ) ;
69
+ const xpc_type_shmem = getPtr ( "_xpc_type_shmem" ) ;
70
+ const xpc_type_string = getPtr ( "_xpc_type_string" ) ;
71
+ const xpc_type_uint64 = getPtr ( "_xpc_type_uint64" ) ;
72
+ const xpc_type_uuid = getPtr ( "_xpc_type_uuid" ) ;
73
+
47
74
// helper function that will create new NativeFunction
48
75
function getFunc ( name , ret_type , args ) {
49
- return new NativeFunction ( Module . findExportByName ( null , name ) , ret_type , args ) ;
76
+ return new NativeFunction ( Module . getExportByName ( null , name ) , ret_type , args ) ;
50
77
}
51
78
52
- // get value type name from xpc_object_t
53
- function getValueTypeName ( val ) {
54
- var valueType = xpc_get_type ( val ) ;
55
- var name = xpc_type_get_name ( valueType ) ;
56
- return Memory . readCString ( name ) ;
79
+ // helper function that will create new NativePointer
80
+ function getPtr ( name ) {
81
+ return new NativePointer ( Module . getExportByName ( null , name ) ) ;
57
82
}
58
83
59
84
// create C string from JavaScript string
@@ -66,6 +91,66 @@ function rcstr(cstr) {
66
91
return Memory . readCString ( cstr ) ;
67
92
}
68
93
94
+ // get value type name from xpc_object_t
95
+ function getValueTypeName ( val ) {
96
+ var valueType = xpc_get_type ( val ) ;
97
+ if ( xpc_type_activity . equals ( valueType ) )
98
+ return "activity" ;
99
+ if ( xpc_type_array . equals ( valueType ) )
100
+ return "array" ;
101
+ if ( xpc_type_base . equals ( valueType ) )
102
+ return "base" ;
103
+ if ( xpc_type_bool . equals ( valueType ) )
104
+ return "bool" ;
105
+ if ( xpc_type_bundle . equals ( valueType ) )
106
+ return "bundle" ;
107
+ if ( xpc_type_connection . equals ( valueType ) )
108
+ return "connection" ;
109
+ if ( xpc_type_data . equals ( valueType ) )
110
+ return "data" ;
111
+ if ( xpc_type_date . equals ( valueType ) )
112
+ return "date" ;
113
+ if ( xpc_type_dictionary . equals ( valueType ) )
114
+ return "dictionary" ;
115
+ if ( xpc_type_double . equals ( valueType ) )
116
+ return "double" ;
117
+ if ( xpc_type_endpoint . equals ( valueType ) )
118
+ return "endpoint" ;
119
+ if ( xpc_type_error . equals ( valueType ) )
120
+ return "error" ;
121
+ if ( xpc_type_fd . equals ( valueType ) )
122
+ return "fd" ;
123
+ if ( xpc_type_file_transfer . equals ( valueType ) )
124
+ return "file_transfer" ;
125
+ if ( xpc_type_int64 . equals ( valueType ) )
126
+ return "int64" ;
127
+ if ( xpc_type_mach_recv . equals ( valueType ) )
128
+ return "mach_recv" ;
129
+ if ( xpc_type_mach_send . equals ( valueType ) )
130
+ return "mach_send" ;
131
+ if ( xpc_type_null . equals ( valueType ) )
132
+ return "null" ;
133
+ if ( xpc_type_pipe . equals ( valueType ) )
134
+ return "pipe" ;
135
+ if ( xpc_type_pointer . equals ( valueType ) )
136
+ return "pointer" ;
137
+ if ( xpc_type_serializer . equals ( valueType ) )
138
+ return "serializer" ;
139
+ if ( xpc_type_service . equals ( valueType ) )
140
+ return "service" ;
141
+ if ( xpc_type_service_instance . equals ( valueType ) )
142
+ return "service_instance" ;
143
+ if ( xpc_type_shmem . equals ( valueType ) )
144
+ return "shmem" ;
145
+ if ( xpc_type_string . equals ( valueType ) )
146
+ return "string" ;
147
+ if ( xpc_type_uint64 . equals ( valueType ) )
148
+ return "uint64" ;
149
+ if ( xpc_type_uuid . equals ( valueType ) )
150
+ return "uuid" ;
151
+ return null ;
152
+ }
153
+
69
154
// get C string from XPC string
70
155
function getXPCString ( val ) {
71
156
var content = xpc_string_get_string_ptr ( val ) ;
0 commit comments