From 433f4b8066b7a69046e7de4e748e016e12aa0f43 Mon Sep 17 00:00:00 2001 From: doronz88 Date: Mon, 1 Apr 2024 10:38:40 +0300 Subject: [PATCH] darwin: override `errno` to be thread-local --- src/rpcclient/rpcclient/client.py | 4 ++-- src/rpcclient/rpcclient/darwin/client.py | 12 ++++++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/rpcclient/rpcclient/client.py b/src/rpcclient/rpcclient/client.py index c9f48c98..ef9f8c81 100644 --- a/src/rpcclient/rpcclient/client.py +++ b/src/rpcclient/rpcclient/client.py @@ -301,11 +301,11 @@ def symbol(self, symbol: int): return Symbol.create(symbol, self) @property - def errno(self): + def errno(self) -> int: return self.symbols.errno[0] @errno.setter - def errno(self, value): + def errno(self, value: int) -> None: self.symbols.errno[0] = value @property diff --git a/src/rpcclient/rpcclient/darwin/client.py b/src/rpcclient/rpcclient/darwin/client.py index a38a5731..5556b05f 100644 --- a/src/rpcclient/rpcclient/darwin/client.py +++ b/src/rpcclient/rpcclient/darwin/client.py @@ -106,6 +106,18 @@ def interactive(self, additional_namespace: typing.Mapping = None): additional_namespace['CFSTR'] = self.cf super().interactive(additional_namespace=additional_namespace) + @property + def errno(self) -> int: + p_error = self.symbols['__error']() + p_error.item_size = 4 + return p_error[0] + + @errno.setter + def errno(self, value: int) -> None: + p_error = self.symbols['__error']() + p_error.item_size = 4 + p_error[0] = value + @property def images(self) -> typing.List[DyldImage]: m = []