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