|
|
|
@ -5,9 +5,25 @@ unsigned long strToLong(char*str) { |
|
|
|
|
int counter=0; |
|
|
|
|
char c; |
|
|
|
|
unsigned long val=0; |
|
|
|
|
int base=10; |
|
|
|
|
while ((c=str[counter++])!='\0') { |
|
|
|
|
val*=10; |
|
|
|
|
val+=c-'0'; |
|
|
|
|
if (counter==1&&c=='0') { |
|
|
|
|
base=8; |
|
|
|
|
continue; |
|
|
|
|
} else |
|
|
|
|
if (counter==2&&c=='x') { |
|
|
|
|
base=16; |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
val*=base; |
|
|
|
|
if (base==16&&c>='A'&&c<='F') { |
|
|
|
|
val+=c-'A'+10; |
|
|
|
|
} else |
|
|
|
|
if (base==16&&c>='a'&&c<='f') { |
|
|
|
|
val+=c-'a'+10; |
|
|
|
|
} else { |
|
|
|
|
val+=c-'0'; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
return val; |
|
|
|
|
} |
|
|
|
@ -16,12 +32,20 @@ int main(int argc,char**argv) { |
|
|
|
|
unsigned int pid; |
|
|
|
|
unsigned long addr; |
|
|
|
|
unsigned long val; |
|
|
|
|
if (argc<3) { |
|
|
|
|
printf("3 arguments required! Only %d specified.",argc); |
|
|
|
|
unsigned int interval=1000; |
|
|
|
|
if (argc<4) { |
|
|
|
|
printf("3 arguments required! %d specified.",argc-1); |
|
|
|
|
printf(" Format: memovr <pid> <addr> <val> [interval (ms)]"); |
|
|
|
|
} else { |
|
|
|
|
for (int i=1;i<argc;i++) { |
|
|
|
|
printf("\nArg %d: %lu",i+1,strToLong(argv[i])); |
|
|
|
|
pid=strToLong(argv[1]); |
|
|
|
|
addr=strToLong(argv[2]); |
|
|
|
|
val=strToLong(argv[3]); |
|
|
|
|
if (argc>=5) { |
|
|
|
|
interval=strToLong(argv[4]); |
|
|
|
|
} |
|
|
|
|
printf("\nPID: %lu",pid); |
|
|
|
|
printf("\nAddress: %lu",addr); |
|
|
|
|
printf("\nValue: %lu",val); |
|
|
|
|
printf("\nInterval: %lu",interval); |
|
|
|
|
} |
|
|
|
|
printf("\nHello World!"); |
|
|
|
|
} |