I'm a student doing a project where I have to interrupt the init process of Android. As we all know, init is the program that is run after the kernel boots up.
In the source code of init.c, I made the following changes to main():
int main(int argc, char **argv) { int fd_count = 0; struct pollfd ufds[4]; char *tmpdev; ...
// START OF MY EDIT IN PSEUDOCODE fputs("Press enter to start test tool\n", stdout); if (user input received) { execve("./system/bin/test_tool", NULL, NULL); } // END OF MY EDIT
// rest of init.c ...
}
Upon first boot up, I adb push test_tool (which is a properly compiled ARM executable for Linux) to system/bin/ and chmod it to 777, then do a reboot.
As far as I know, execve should never return if executed successfully. However, I'm still seeing the rest of the init process being executed, which should mean that execve is not working?
On Friday, August 3, 2012 5:04:21 AM UTC-7, Terence Yeong wrote:
> Hi guys,
> I'm a student doing a project where I have to interrupt the init process > of Android. As we all know, init is the program that is run after the > kernel boots up.
> In the source code of init.c, I made the following changes to main():
> // START OF MY EDIT IN PSEUDOCODE > fputs("Press enter to start test tool\n", stdout); > if (user input received) > { > execve("./system/bin/test_tool", NULL, NULL); > } > // END OF MY EDIT
> // rest of init.c > ... > }
> Upon first boot up, I adb push test_tool (which is a properly compiled ARM > executable for Linux) to system/bin/ and chmod it to 777, then do a reboot.
> As far as I know, execve should never return if executed successfully. > However, I'm still seeing the rest of the init process being executed, > which should mean that execve is not working?
On Fri, Aug 3, 2012 at 2:04 PM, Terence Yeong <terenceye...@gmail.com> wrote:
> // START OF MY EDIT IN PSEUDOCODE
> fputs("Press enter to start test tool\n", stdout);
> if (user input received)
> {
> execve("./system/bin/test_tool", NULL, NULL);
> }
> // END OF MY EDIT
Where is your gets()? Also when you do a fputs(), you need to call
fflush(). But in general, your gets() should help you with that.
@Luke: Yeap, my fputs is showing up. I have already solved the problem of execve-ing to my program. However, another problem has popped up. If user input is not received, my intention is for the rest of the init process to continue as normal so the phone can boot up. However I'm getting stuff like this: http://pastebin.com/XxCZeECs. I've tried to integrate my custom program code into init.c only to run into the same problem! Can anyone explain what's going on?
@Naresh: My apologies. The if (user input received) is in psuedocode. My fgets() stuff is all there, I just didn't type it out.
On Monday, August 13, 2012 11:19:32 AM UTC+5:30, Terence Yeong wrote:
> Hi guys,
> Sorry for the late reply.
> @Luke: Yeap, my fputs is showing up. I have already solved the problem of > execve-ing to my program. However, another problem has popped up. If user > input is not received, my intention is for the rest of the init process to > continue as normal so the phone can boot up. However I'm getting stuff like > this: http://pastebin.com/XxCZeECs. I've tried to integrate my custom > program code into init.c only to run into the same problem! Can anyone > explain what's going on?
> @Naresh: My apologies. The if (user input received) is in psuedocode. My > fgets() stuff is all there, I just didn't type it out.
But I need to run my test tool before Android boots up. I did explore running via the init.rc script, but I didn't know how to have the test tool take control of the console.
> On Monday, August 13, 2012 11:19:32 AM UTC+5:30, Terence Yeong wrote:
>> Hi guys,
>> Sorry for the late reply.
>> @Luke: Yeap, my fputs is showing up. I have already solved the problem of >> execve-ing to my program. However, another problem has popped up. If user >> input is not received, my intention is for the rest of the init process to >> continue as normal so the phone can boot up. However I'm getting stuff like >> this: http://pastebin.com/XxCZeECs. I've tried to integrate my custom >> program code into init.c only to run into the same problem! Can anyone >> explain what's going on?
>> @Naresh: My apologies. The if (user input received) is in psuedocode. My >> fgets() stuff is all there, I just didn't type it out.