Skip to content

Commit

Permalink
processes: support kqueue fds
Browse files Browse the repository at this point in the history
  • Loading branch information
doronz88 committed Apr 1, 2022
1 parent 237f8ad commit e1846f9
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/rpcclient/rpcclient/darwin/processes.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
vnode_fdinfowithpath, PROC_PIDFDVNODEPATHINFO, proc_taskallinfo, PROC_PIDTASKALLINFO, PROX_FDTYPE_SOCKET, \
PROC_PIDFDSOCKETINFO, socket_fdinfo, so_kind_t, so_family_t, PROX_FDTYPE_PIPE, PROC_PIDFDPIPEINFO, pipe_info, \
task_dyld_info_data_t, TASK_DYLD_INFO_COUNT, all_image_infos_t, dyld_image_info_t, x86_thread_state64_t, \
arm_thread_state64_t
arm_thread_state64_t, PROX_FDTYPE_KQUEUE
from rpcclient.darwin.symbol import DarwinSymbol
from rpcclient.exceptions import BadReturnValueError, ArgumentError, SymbolAbsentError, MissingLibraryError
from rpcclient.processes import Processes
Expand All @@ -34,6 +34,11 @@ class Fd:
fd: int


@dataclasses.dataclass()
class KQueueFd(Fd):
pass


@dataclasses.dataclass()
class PipeFd(Fd):
pass
Expand Down Expand Up @@ -341,6 +346,9 @@ def fds(self) -> List[Fd]:
if fd.proc_fdtype == PROX_FDTYPE_VNODE:
result.append(FileFd(fd=fd.proc_fd, path=parsed.pvip.vip_path))

elif fd.proc_fdtype == PROX_FDTYPE_KQUEUE:
result.append(KQueueFd(fd=fd.proc_fd))

elif fd.proc_fdtype == PROX_FDTYPE_PIPE:
result.append(PipeFd(fd=fd.proc_fd))

Expand Down Expand Up @@ -394,6 +402,9 @@ def fd_structs(self) -> List[FdStruct]:
FdStruct(fd=fd,
struct=vnode_fdinfowithpath.parse(vi_buf.peek(vnode_fdinfowithpath.sizeof()))))

elif fd.proc_fdtype == PROX_FDTYPE_KQUEUE:
result.append(FdStruct(fd=fd, struct=None))

elif fd.proc_fdtype == PROX_FDTYPE_SOCKET:
# socket
vs = self._client.symbols.proc_pidfdinfo(self.pid, fd.proc_fd, PROC_PIDFDSOCKETINFO, vi_buf,
Expand Down

0 comments on commit e1846f9

Please sign in to comment.