Skip to content

Commit 2b54322

Browse files
committed
fix: first try to call setConnection on NSXPCDecoder
1 parent ac273e0 commit 2b54322

File tree

1 file changed

+3
-13
lines changed

1 file changed

+3
-13
lines changed

script.js

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -71,16 +71,6 @@ const xpc_type_string = getPtr("_xpc_type_string");
7171
const xpc_type_uint64 = getPtr("_xpc_type_uint64");
7272
const xpc_type_uuid = getPtr("_xpc_type_uuid");
7373

74-
// check which version of decoder we have
75-
var NSXPCDecoderDecodeMethod = "old"
76-
var connResult = null;
77-
78-
var decoder = NSXPCDecoder.alloc().init();
79-
80-
if ((connResult = decoder["- setConnection:"]) != null) {
81-
NSXPCDecoderDecodeMethod = "new";
82-
}
83-
8474
// helper function that will create new NativeFunction
8575
function getFunc(name, ret_type, args) {
8676
return new NativeFunction(Module.getExportByName(null, name), ret_type, args);
@@ -250,10 +240,10 @@ function getKeys(description) {
250240
// https://github.com/nst/iOS-Runtime-Headers/blob/master/Frameworks/Foundation.framework/NSXPCDecoder.h
251241
function parseBPList(conn, dict) {
252242
var decoder = NSXPCDecoder.alloc().init();
253-
if (NSXPCDecoderDecodeMethod == "old") {
243+
try {
244+
decoder["- _setConnection:"](conn);
245+
} catch (err) {
254246
decoder["- set_connection:"](conn);
255-
} else {
256-
decoder["- setConnection:"](conn);
257247
}
258248
decoder["- _startReadingFromXPCObject:"](dict);
259249
var debugDescription = decoder.debugDescription();

0 commit comments

Comments
 (0)