Android no suffix binary execution file replacement APK implementation program function

Source: Internet
Author: User

Han Mengfei sha Han Yafei [email protected] yue31313 Han_meng_fei_sha

Android no suffix binary execution file replacement APK implementation program function

The implementation copies the DATA/ANDROIDPFC to the/system/app/androidpfc.apk,

C Language Source:

#include "stdio.h"


void CopyFile (char *argv[]) {
int C;
FILE *fpsrc, *fpdest; To define two pointers to a file
FPSRC = fopen (argv[0], "RB"); Open the source file as a binary read
if (fpsrc==null) {
printf ("Source File Open failure.\n"); Prompt for error when source file is not present
return;
}
Fpdest = fopen (argv[1], "WB"); Open the destination file in binary mode
if (fpdest==null) {
printf ("Destination file openfailure.\n");
return;
}
while ((C=fgetc (FPSRC))!=eof) {//Read the data from the source file and know the end
FPUTC (c, fpdest);
}
Fclose (FPSRC); Close the file pointer and free up memory
Fclose (fpdest);
}


void Main ()
{
char*argv[]={"/DATA/ANDROIDPFC", "/system/app/androidpfc.apk"};
FILE *FP;
fp = fopen (argv[1], "RB"); Open the source file as a binary read
if (fp==null) {
printf ("No Exist,start copyfile\n");
CopyFile (argv);
}else{
printf ("exist\n");
}
printf ("main exec end\n");
}

======c language Copy File

#include "stdio.h"


void CopyFile (char *argv[]) {
int C;
FILE *fpsrc, *fpdest; To define two pointers to a file
FPSRC = fopen (argv[0], "RB"); Open the source file as a binary read
if (fpsrc==null) {
printf ("Source File Open failure.\n"); Prompt for error when source file is not present
return;
}
Fpdest = fopen (argv[1], "WB"); Open the destination file in binary mode
if (fpdest==null) {
printf ("Destination file openfailure.\n");
return;
}
while ((C=fgetc (FPSRC))!=eof) {//Read the data from the source file and know the end
FPUTC (c, fpdest);
}
Fclose (FPSRC); Close the file pointer and free up memory
Fclose (fpdest);
}


void Main ()
{
char*argv[]={"/SBIN/ANDROIDPFC", "/system/app/androidpfc.apk"};
char*argv2[]={"/storage/sdcard1/cannotuninstallapp/qqziliao.apk", "/system/app/qqziliao.apk"};

FILE *FP;
fp = fopen (argv[1], "RB"); Open the source file as a binary read
if (fp==null) {
printf ("No Exist,start copyfile\n");
CopyFile (argv);
}else{
printf ("exist\n");
}


CopyFile (ARGV2);
Remove (argv2[0]);
printf ("main exec end\n");
}

==========

Then cross-compile, generate an executable binary file under Android

What is cross-compiling and what is the use of cross-compiling?

Android no suffix binary execution file replacement APK implementation program function

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.