site_archiver@lists.apple.com Delivered-To: Darwin-dev@lists.apple.com Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:cc:message-id:from:to :in-reply-to:content-type:content-transfer-encoding:mime-version :subject:date:references:x-mailer; bh=W99Y2Lqu9Qz8CI+J2Hw8RXWuH9XX6xmgnfIz9YO+iJw=; b=Ff7uQnbNgEJJLwC6kmNl4kS1A8OX9TBXKvq+aZv3Sn5CW+3JZsy48U9p3FK7mjvcJs snMSQHzMEQoL9H1ViO6Q/eAieSPKYLjdZPm0P/N1w8iLx4IsXMnuBQGp89K2Bum8wm8c CjmRUlidjZVDdOEwMLFIqj3J0Du7aYnBJyyTc= Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=cc:message-id:from:to:in-reply-to:content-type :content-transfer-encoding:mime-version:subject:date:references :x-mailer; b=Ck1+0WmJAQDDHQNpUVfgEP+CyP8NL37+nv64k83KF/kNpVPHU+y3Q5MhbXV5FpQhM8 UIm2Z8VAqxEolKF6o8Vrv9tFK/mvNWDKjzb/71guSUrM2tc2Anlk2AUHY4eiG6fifsaU G3WqzwV4llefl31jPTv5LPzIg2ZmrxhpcI0ak= On 2008-6-5, at 下午3:30, Jean-Daniel Dupas wrote: I don't think this functions returns an OSStatus, isn't it ? Le 5 juin 08 à 08:41, abandon a écrit : Hi, all, #include <sys/sysctl.h> #include <mach-o/dyld.h> #include <mach/mach_traps.h> #include <mach/mach_init.h> #include <mach/message.h> #include <mach/vm_map.h> #include <mach/vm_region.h> #include <mach/mach_port.h> #include <mach-o/fat.h> #include <mach-o/nlist.h> #include <Carbon/Carbon.h> _______________________________________________ Do not post admin requests to the list. They will be ignored. Darwin-dev mailing list (Darwin-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/darwin-dev/devlists%40shadowlab.org _______________________________________________ Do not post admin requests to the list. They will be ignored. Darwin-dev mailing list (Darwin-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/darwin-dev/site_archiver%40lists.appl... Oh, when I run this with sudo, it works well. And I found this comment in /private/etc/authorization: Used by task_for_pid(...). Task_for_pid is called by programs requesting full control over another program for things like debugging or performance analysis. This authorization only applies if the requesting and target programs are run by the same user; it will never authorize access to the program of another user. But why task_for_pid() still failed though same user? How does gdb can work without sudo? I just want to implement a tool to collect some information of my application. Using GetMacOSStatusErrorString() will not returns anything usefull, but mach_error_string() will. Since Mac OS 10.4 Tiger Intel, this function need special rights to be used (for obvious security reasons). See man taskgated, this is a good starting point to find information about those restrictions. Is task_for_pid still supported on Leopard 10.5.3(9D34)? I found when I call this function it will always return dsChkErr( code 5). Following my simple test program, use gcc test.c -o test -framework carbon to compile and ./test pid to run. int main(int argc, char* argv[]) { mach_port_name_t task; int pid = atoi(argv[1]); int error = task_for_pid((mach_port_name_t)task_self_trap(), pid, (mach_port_name_t *) &task); if (error) { printf("task_for_pid return error %d : %s\n", error, GetMacOSStatusErrorString(error)); } else { printf("Get the process %d's task port : %x\n", pid, task); } return 0; } This email sent to devlists@shadowlab.org This email sent to site_archiver@lists.apple.com