Skip to content

Commit

Permalink
Still have errors, but cutting down on unneeded code and undergoing f…
Browse files Browse the repository at this point in the history
…urther robustification
  • Loading branch information
Sparen committed Jun 23, 2015
1 parent dc5f610 commit 2162e1c
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions dnhobf_fxn.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ using std::cout;
using std::endl;
using std::fstream;

//Removal of Block Comments MUST come before Removal of Single Line Comments

//Only removes comments
int ObfuscateA1(char* infile){
RemoveBlockComments(infile);
Expand All @@ -29,10 +31,10 @@ int RemoveSingleLineComments(char* infile){
char c;

fstream orig;
orig.open(infile, std::fstream::in | std::fstream::out);
orig.open(infile, std::fstream::in);

fstream tmp;
tmp.open(infile, std::fstream::in | std::fstream::out | std::fstream::app);
tmp.open(infile, std::fstream::in | std::fstream::out);

while(!orig.eof()){
orig.get(c);
Expand All @@ -45,7 +47,14 @@ int RemoveSingleLineComments(char* infile){
tmp.put(c); //Not a comment, put both chars down
tmp.put(tempchar);
}else{//it's a comment
while(orig.get()!='\n'){}//move to new line marker
bool satisfied = false;
char temp2;
while(!satisfied){
orig.get(temp2);
if(temp2 == '\n' || temp2 == '\r'){//move to new line marker
satisfied = true;
}
}
orig.seekg(-1, std::ios_base::cur);//Move back one char
}
}else{
Expand Down Expand Up @@ -78,15 +87,15 @@ int RemoveBlockComments(char* infile){
char c;

fstream orig;
orig.open(infile, std::fstream::in | std::fstream::out);
orig.open(infile, std::fstream::in);

fstream tmp;
tmp.open(infile, std::fstream::in | std::fstream::out | std::fstream::app);

while(!orig.eof()){
orig.get(c);
if(orig.eof()){break;}//get will never throw an EOF, and will duplicate the last character instead.
//cout << c; //debug
cout << c; //debug
if(c=='/'){
char tempchar;
orig.get(tempchar);
Expand Down Expand Up @@ -120,7 +129,7 @@ int RemoveBlockComments(char* infile){
while (!tmp.eof()){
tmp.get(a);
if(tmp.eof()){break;}//get will never throw an EOF, and will duplicate the last character instead.
//cout << a; //debug
cout << a; //debug
orig.put(a);
}

Expand Down

0 comments on commit 2162e1c

Please sign in to comment.