I've gotten "recover"recover
to work... sort of. The problem is difficult to describe without posting my code, but here's an attempt:
My program can find all the jpg signatures (in GDB, my jpeg-finding line returns yes each time) but it only creates 2 jpg files, both of which are viewable images. The first file seems fine but the second contains all of the rest of the data to EOFEOF
.
From trying to debug in GDB, I believe the problem is in the implementation of my file naming scheme. The first file is called correctly called "000.jpg"000.jpg
and the second file is correctly called "001.jpg" 001.jpg
(hooray!) but when it comes time to create the third file, it also calls that one "001.jpg"001.jpg
and thus just appends the new jpg to the old jpg file.
I'm creating the filenames with sprintfsprintf
, using a counter that is initially set to "0"0
like this:
int counter = 0;
int counter = 0;
and which is incremented after the previous filename is created, like this:
counter++;
counter++;
Then I tried initializing the counter to "5"5
instead of "0"0
. That resulted one jpeg named 005.jpg005.jpg
and a second one called 001.jpg001.jpg
so it seems that when I increment the counter it only ever just sets the counter equal to 11
.
Give that limited information, anyone have an idea what's going wrong?
Thanks in advance!
Editing to add:
I think I just found the answer to my problem. It seems to be a memory allocation issue. I had declared another variable with too small an array size right before I declared my counter variable, so the first variable started running over into the second variable. (Maybe?)
In any case, I increased the array size of the first variable and now my counter increments properly. Yay!!