1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
|
#include<cstdio>
#include<cstdlib>
#include"badmath.h"
using namespace std;
void errormsg()
{
printf("%s","Syntax error. Syntax is:\n");
printf("%s","corrupt <ifile> <ofile> <strt> <stop> <every> <operation> <additional>\n");
printf("%s","ifile is the path to the input file.\n");
printf("%s","ofile is the path to the output file.\n");
printf("%s","strt or \"start\" is the position in the file to start corrupting.\n");
printf("%s","stop is the position in the file to stop corrupting.\n");
printf("%s","every is the frequency of memory to ignore.\n");
printf("%s","\n");
printf("%s","Operations:\n");
printf("%s","add\n");
printf("%s","\n");
printf("%s","Extra:\n");
printf("%s","When writing numbers, write them in hexadecimal (1956) being (00000007A4). This program supports files up to 1TB.\n");
}
bool read;
unsigned char argcount;
FILE* ifile;
FILE* ofile;
long long int strt;
long long int stop;
unsigned char frequency;
int main(int argc, char* argv[])
{
if(argc < 8){errormsg();return 1;}
ifile = fopen(argv[1],"rb");
if(ifile == NULL){printf("%s","ifile does not exist.\n");return 1;}
ofile = fopen(argv[2],"wb");
strt = atoi(argv[3]);
stop = atoi(argv[4]);
frequency = atoi(argv[5]);
char addative = atoi(argv[7]);
char reg;
unsigned char countr = 0;
printf("%s",argv[6]);
if(argv[6] == "add"){
while((reg = fgetc(ifile)) != EOF){if(frequency == countr){fputc(reg + addative, ofile);}countr = countr +1;}
}
else{errormsg();return 1;}
printf("%s","The file seems to have been successfully corrupted...\n");
return 0;
}
|