Skip to content

Instantly share code, notes, and snippets.

@nikolay-n
Created December 13, 2022 17:24
Show Gist options
  • Save nikolay-n/8efae55fa187f5caecbde044fa2f631b to your computer and use it in GitHub Desktop.
Save nikolay-n/8efae55fa187f5caecbde044fa2f631b to your computer and use it in GitHub Desktop.
xpc pid path
$dump = `launchctl dumpstate`;
%services = ();
%endpoints = ();
$service = "";
$current_service = "";
$endpoints_block = 0;
for(split("\n", $dump)){
$service = $1 if /^([^\s]+)\s=/;
if ($service and ($service ne $current_service)){
$current_service = $service;
$services{$service} = {};
}
$services{$current_service}->{pid} = $1 if /^\s+pid = (\d+)/;
$services{$current_service}->{program} = $1 if /^\s+program = (.+)/;
if ($endpoints_block){
$endpoints{$1} = $services{$current_service} if (/^\t\t"([^"]+)" = /);
$endpoints_block = 0 if /^ \}/;
}elsif(/endpoints =/){
$endpoints_block = 1;
}
}
$endpoint = shift();
print "xpc service: $endpoint\n";
print "pid: " .$endpoints{$endpoint}->{pid} . "\n" ;
print "path:" . $endpoints{$endpoint}->{program} . "\n";
@nikolay-n
Copy link
Author

nikolay-n commented Dec 13, 2022

Usage: perl xpc_info.pl com.apple.tccd.system

output:

xpc service: com.apple.tccd.system
pid: 275
path:/System/Library/PrivateFrameworks/TCC.framework/Resources/tccd

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment