Closed

jailbreak developer iPhone (task_for_pid() expert)

Need to get task_for_pid() function to work on jailbreak iPhone under root.

My test environments iPhone 3GS 3.1.3 and iPhone 4 4.3.2.

Here is my sample code:

core line is this:

kr = task_for_pid(mach_task_self(), pid, &the_task);

according to FreeBSD and MacOS documentation if pid is correct it should return KERN_SUCCESS.

But in iOS in my case it returns KERN_FAILURE.

//pid.c

//-----------------

#include <stdlib.h>

#include <stdio.h>

#include <mach/mach.h>

int test_task_for_pid(pid_t pid)

{

kern_return_t kr;

task_t the_task;

printf ("Got PID: %d\n", pid);

printf ("The_task: 0x%x\n", the_task);

kr = task_for_pid(mach_task_self(), pid, &the_task);

if (kr != KERN_SUCCESS) {

printf ("kr: %d\n", kr);

printf ("The_task: 0x%x\n", the_task);

return -1;

}

printf ("SUCCES: The_task: 0x%x\n", the_task);

return 0;

}

int

main(int argc, char *argv[])

{

pid_t pid = strtol(argv[1], NULL, 10);

test_task_for_pid( pid );

return 0;

}

------------------------------

Compilation

------------------------------

devel-iPhone:/home/devel/pid root# gcc -c -I/var/toolchain/sys30/usr/include pid.c -o pid.o

devel-iPhone:/home/devel/pid root# gcc -L/var/toolchain/sys30/usr/lib -lSystem pid.o -o pid

Note: in my case I'm compiling everything on iPhone and path to toolchain is /var/toolchain/sys30/usr/include

Please change this to match your setup.

For cross compilation on Mac I don't know.

------------------------------

Signing

------------------------------

devel-iPhone:/home/devel/pid root# ldid -S pid

------------------------------

Testing

------------------------------

devel-iPhone:/home/devel/pid root# ps ax

select any process. For example 202.

202 ?? Ss 0:[url removed, login to view] /Applications/[url removed, login to view]

206 ?? S 0:[url removed, login to view] /usr/sbin/sshd -i

213 ?? Ss 0:[url removed, login to view] /usr/libexec/sftp-server

278 s001 R+ 0:[url removed, login to view] ps ax

devel-iPhone:/home/devel/pid root# ./pid 202

here PID: 202

the_task: 848085017

kr: 5 <- HERE SHOULD BE 0

the_task: 0

DELIVERY

executable or instructions to get this stuff working

Skills: C Programming, iPhone, Objective C

See more: iphone pid, iphone ldid, pid iphone, jailbreak pid, x developer, return path, programming instructions, printf programming, pid programming, line ios programming, ios x, developer line, developer jailbreak, programming printf, programming expert, programming char, char programming, app developer line, pid ios, iphone jailbreak developer, iphone sys30, iphone 4

About the Employer:
( 0 reviews ) Rijswijk, Netherlands

Project ID: #1110270

3 freelancers are bidding on average $150 for this job

vasanth204

check pvt message

$100 USD in 5 days
(0 Reviews)
2.8
ShraddhaAjit

Hi , We would like to take this opportunity to develop the application for you. We have good hands on experience in the CMM level 5 companies like Cognizant , TCS and PTC. This experience make us possible to achi More

$100 USD in 5 days
(0 Reviews)
0.0
iElegantIT

Respected Client, Please check our bid in your pmb. Sincerely, iElegantIT

$250 USD in 5 days
(0 Reviews)
0.0