diff --git a/docs/conf.py b/docs/conf.py index bcc66772..57d93e4e 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -18,7 +18,6 @@ import toml - # -- Project information ----------------------------------------------------- project = 'rpc-project' diff --git a/src/rpcclient/rpcclient/darwin/consts.py b/src/rpcclient/rpcclient/darwin/consts.py index 328e40ea..10bdecd9 100644 --- a/src/rpcclient/rpcclient/darwin/consts.py +++ b/src/rpcclient/rpcclient/darwin/consts.py @@ -2,6 +2,7 @@ kCFAllocatorDefault = 0 MACH_PORT_NULL = 0 +XPC_ARRAY_APPEND = 0xffffffffffffffff class AVAudioSessionRouteSharingPolicy(IntEnum): diff --git a/src/rpcclient/rpcclient/darwin/xpc.py b/src/rpcclient/rpcclient/darwin/xpc.py index 268eb752..793581c6 100644 --- a/src/rpcclient/rpcclient/darwin/xpc.py +++ b/src/rpcclient/rpcclient/darwin/xpc.py @@ -1,8 +1,10 @@ from datetime import datetime from functools import lru_cache from typing import List, Mapping +from uuid import UUID from rpcclient.darwin.common import CfSerializable +from rpcclient.darwin.consts import XPC_ARRAY_APPEND from rpcclient.darwin.symbol import DarwinSymbol from rpcclient.exceptions import MissingLibraryError, RpcXpcSerializationError from rpcclient.structs.consts import RTLD_NOW @@ -14,6 +16,14 @@ def type(self) -> int: return self._client.symbols.xpc_get_type(self) +class XPCArray(XPCObject): + def set_data(self, buf: bytes, index: int = XPC_ARRAY_APPEND) -> None: + """ + See https://developer.apple.com/documentation/xpc/1505937-xpc_array_set_data?language=objc + """ + self._client.symbols.xpc_array_set_data(self, index, buf, len(buf)) + + class XPCDictionary(XPCObject): def set_string(self, key: str, value: str) -> None: self._client.symbols.xpc_dictionary_set_string(self, key, value) @@ -33,8 +43,8 @@ def set_data(self, key: str, value: bytes) -> None: def set_fd(self, key: str, value: int) -> None: self._client.symbols.xpc_dictionary_set_fd(self, key, value) - def set_uuid(self, key: str, value: str) -> None: - self._client.symbols.xpc_dictionary_set_uuid(self, key, value) + def set_uuid(self, key: str, value: UUID) -> None: + self._client.symbols.xpc_dictionary_set_uuid(self, key, value.bytes) def set_dictionary(self, key: str, value: int) -> None: self._client.symbols.xpc_dictionary_set_dictionary(self, key, value) @@ -42,8 +52,8 @@ def set_dictionary(self, key: str, value: int) -> None: def set_object(self, obj: XPCObject) -> None: self._client.symbols.xpc_dictionary_set_object(self, obj) - def set_value(self, obj: XPCObject) -> None: - self._client.symbols.xpc_dictionary_set_value(self, obj) + def set_value(self, key: str, obj: XPCObject) -> None: + self._client.symbols.xpc_dictionary_set_value(self, key, obj) def get_string(self, key: str) -> str: return self._client.symbols.xpc_dictionary_get_string(self, key).peek_str() @@ -89,6 +99,9 @@ def __init__(self, client): def create_xpc_dictionary(self) -> XPCDictionary: return XPCDictionary.create(self._client.symbols.xpc_dictionary_create(0, 0, 0), self._client) + def create_xpc_array(self) -> XPCArray: + return XPCArray.create(self._client.symbols.xpc_array_create_empty(), self._client) + def send_xpc_dictionary(self, service_name: str, message: XPCDictionary) -> XPCDictionary: """ Send a native XPC dictionary to a XPC service synchronously and return result.