Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

processes: Make get_symbol_address() also resolve DarwinSymbol #377

Merged
merged 1 commit into from
Feb 12, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions src/rpcclient/rpcclient/darwin/processes.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from collections.abc import Generator
from datetime import datetime
from pathlib import Path
from typing import Optional
from typing import Optional, Union

from cached_property import cached_property
from construct import Array, Container, Int32ul
Expand Down Expand Up @@ -412,11 +412,12 @@ def get_symbol_image(self, name: str) -> Image:
def get_symbol_class_info(self, address: int) -> DarwinSymbol:
return self.vmu_object_identifier.objc_call('classInfoForMemory:length:', address, 8)

def get_symbol_address(self, name: str, lib: str = None) -> ProcessSymbol:
def get_symbol_address(self, name: str, lib: str = None) -> Union[DarwinSymbol, ProcessSymbol]:
if lib is not None:
return ProcessSymbol.create(
self.vmu_object_identifier.objc_call('addressOfSymbol:inLibrary:', name, lib).c_uint64, self._client,
self)
address = self.vmu_object_identifier.objc_call('addressOfSymbol:inLibrary:', name, lib).c_uint64
if self.pid == self._client.pid:
return self._client.symbol(address)
return ProcessSymbol.create(address, self._client, self)

image = self.get_symbol_image(name)
return self.get_symbol_address(name, posixpath.basename(image.path))
Expand Down