Created
June 1, 2016 14:37
-
-
Save BrotherJing/1dcdebddbccd378f1272f47272101738 to your computer and use it in GitHub Desktop.
test write to process memory space
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<stdio.h> | |
#include<string.h> | |
int main(){ | |
FILE *fp; | |
int v=0; | |
int val; | |
char s[20],ch; | |
fp = fopen("/proc/mtest","w+"); | |
while(1){ | |
scanf("%s",s); | |
if(strcmp(s,"print")==0){ | |
rewind(fp); | |
while((ch=fgetc(fp))!=EOF){ | |
printf("%c",ch); | |
} | |
//ch=fgetc(fp); | |
printf("%d\n",v); | |
}else if(strncmp(s,"write",5)==0){ | |
scanf("%d",&val); | |
fprintf(fp,"writeval %lx %d\n",(unsigned long)&v,val); | |
//fprintf(fp,"findpage %lx\n",(unsigned long)&v); | |
fflush(fp); | |
} | |
else if(strcmp(s,"exit")==0)break; | |
} | |
fclose(fp); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment