Skip to main content
Pset was changed from 16 files to 50 for the 2016 class. Ignore prior edits.
Source Link
Cliff B
  • 69.3k
  • 4
  • 33
  • 56

Recover: all 1650 JPGs have "0" as first byte instead of 0xff

I've been stuck for days with this problem. My recover program creates 1650 jpgs but none of them show.

When I look at the first 4 bytes of each, bytes 2 - 4 are correct for JPG signature.

But byte 1 is always 0 instead of 0xff. I don't understand how this could be happening. What am I missing??? Thank you for suggestions!

int main(void)
 {
//open raw data file 
FILE* rawfile = fopen("card.raw", "r");

 // buffer to hold 512 bytes from fread 
    typedef uint8_t  BYTE;
    BYTE buffer[512]; 
    char title[7];
    FILE* img = NULL;
    int search = 0; 
    int picnumber = 0; 

  while (feof (rawfile) == 0)
  {
      fread(&buffer, 512, 1, rawfile);

   //check for next jpeg signature 
       
            
       if (buffer[0] == 0xff && buffer [1] == 0xd8 && buffer [2] == 0xff && (buffer [3] >> 4) == 0xe)
          {
              

          //close current
            if ( search > 0)
            {
             fclose(img);
            } 
            //open new JPG and how to display file name 
              sprintf(title, "%03d.jpg", picnumber); 
              img = fopen(title, "a" );
              
             //write from buffer to new jpg, 
            fwrite(&buffer, 512, 1, img);
            picnumber++;
            search = 1;
          }
      else if (search > 0)
         {  
        fwrite(&buffer, 512, 1, img);   
         }
  }

  

}

Recover: all 16 JPGs have "0" as first byte instead of 0xff

I've been stuck for days with this problem. My recover program creates 16 jpgs but none of them show.

When I look at the first 4 bytes of each, bytes 2 - 4 are correct for JPG signature.

But byte 1 is always 0 instead of 0xff. I don't understand how this could be happening. What am I missing??? Thank you for suggestions!

int main(void)
 {
//open raw data file 
FILE* rawfile = fopen("card.raw", "r");

 // buffer to hold 512 bytes from fread 
    typedef uint8_t  BYTE;
    BYTE buffer[512]; 
    char title[7];
    FILE* img = NULL;
    int search = 0; 
    int picnumber = 0; 

  while (feof (rawfile) == 0)
  {
      fread(&buffer, 512, 1, rawfile);

   //check for next jpeg signature 
       
            
       if (buffer[0] == 0xff && buffer [1] == 0xd8 && buffer [2] == 0xff && (buffer [3] >> 4) == 0xe)
          {
              

          //close current
            if ( search > 0)
            {
             fclose(img);
            } 
            //open new JPG and how to display file name 
              sprintf(title, "%03d.jpg", picnumber); 
              img = fopen(title, "a" );
              
             //write from buffer to new jpg, 
            fwrite(&buffer, 512, 1, img);
            picnumber++;
            search = 1;
          }
      else if (search > 0)
         {  
        fwrite(&buffer, 512, 1, img);   
         }
  }

  

}

Recover: all 50 JPGs have "0" as first byte instead of 0xff

I've been stuck for days with this problem. My recover program creates 50 jpgs but none of them show.

When I look at the first 4 bytes of each, bytes 2 - 4 are correct for JPG signature.

But byte 1 is always 0 instead of 0xff. I don't understand how this could be happening. What am I missing??? Thank you for suggestions!

int main(void)
 {
//open raw data file 
FILE* rawfile = fopen("card.raw", "r");

 // buffer to hold 512 bytes from fread 
    typedef uint8_t  BYTE;
    BYTE buffer[512]; 
    char title[7];
    FILE* img = NULL;
    int search = 0; 
    int picnumber = 0; 

  while (feof (rawfile) == 0)
  {
      fread(&buffer, 512, 1, rawfile);

   //check for next jpeg signature 
       
            
       if (buffer[0] == 0xff && buffer [1] == 0xd8 && buffer [2] == 0xff && (buffer [3] >> 4) == 0xe)
          {
              

          //close current
            if ( search > 0)
            {
             fclose(img);
            } 
            //open new JPG and how to display file name 
              sprintf(title, "%03d.jpg", picnumber); 
              img = fopen(title, "a" );
              
             //write from buffer to new jpg, 
            fwrite(&buffer, 512, 1, img);
            picnumber++;
            search = 1;
          }
      else if (search > 0)
         {  
        fwrite(&buffer, 512, 1, img);   
         }
  }

  

}

edited body; edited title
Source Link
Cliff B
  • 69.3k
  • 4
  • 33
  • 56

Recover: all 1516 JPGs have "0" as first byte instead of 0xff

I've been stuck for days with this problem. My recover program creates 1516 jpgs but none of them show.

When I look at the first 4 bytes of each, bytes 2 - 4 are correct for JPG signature.

But byte 1 is always 0 instead of 0xff. I don't understand how this could be happening. What am I missing??? Thank you for suggestions!

int main(void)
 {
//open raw data file 
FILE* rawfile = fopen("card.raw", "r");

 // buffer to hold 512 bytes from fread 
    typedef uint8_t  BYTE;
    BYTE buffer[512]; 
    char title[7];
    FILE* img = NULL;
    int search = 0; 
    int picnumber = 0; 

  while (feof (rawfile) == 0)
  {
      fread(&buffer, 512, 1, rawfile);

   //check for next jpeg signature 
       
            
       if (buffer[0] == 0xff && buffer [1] == 0xd8 && buffer [2] == 0xff && (buffer [3] >> 4) == 0xe)
          {
              

          //close current
            if ( search > 0)
            {
             fclose(img);
            } 
            //open new JPG and how to display file name 
              sprintf(title, "%03d.jpg", picnumber); 
              img = fopen(title, "a" );
              
             //write from buffer to new jpg, 
            fwrite(&buffer, 512, 1, img);
            picnumber++;
            search = 1;
          }
      else if (search > 0)
         {  
        fwrite(&buffer, 512, 1, img);   
         }
  }

  

}

Recover: all 15 JPGs have "0" as first byte instead of 0xff

I've been stuck for days with this problem. My recover program creates 15 jpgs but none of them show.

When I look at the first 4 bytes of each, bytes 2 - 4 are correct for JPG signature.

But byte 1 is always 0 instead of 0xff. I don't understand how this could be happening. What am I missing??? Thank you for suggestions!

int main(void)
 {
//open raw data file 
FILE* rawfile = fopen("card.raw", "r");

 // buffer to hold 512 bytes from fread 
    typedef uint8_t  BYTE;
    BYTE buffer[512]; 
    char title[7];
    FILE* img = NULL;
    int search = 0; 
    int picnumber = 0; 

  while (feof (rawfile) == 0)
  {
      fread(&buffer, 512, 1, rawfile);

   //check for next jpeg signature 
       
            
       if (buffer[0] == 0xff && buffer [1] == 0xd8 && buffer [2] == 0xff && (buffer [3] >> 4) == 0xe)
          {
              

          //close current
            if ( search > 0)
            {
             fclose(img);
            } 
            //open new JPG and how to display file name 
              sprintf(title, "%03d.jpg", picnumber); 
              img = fopen(title, "a" );
              
             //write from buffer to new jpg, 
            fwrite(&buffer, 512, 1, img);
            picnumber++;
            search = 1;
          }
      else if (search > 0)
         {  
        fwrite(&buffer, 512, 1, img);   
         }
  }

  

}

Recover: all 16 JPGs have "0" as first byte instead of 0xff

I've been stuck for days with this problem. My recover program creates 16 jpgs but none of them show.

When I look at the first 4 bytes of each, bytes 2 - 4 are correct for JPG signature.

But byte 1 is always 0 instead of 0xff. I don't understand how this could be happening. What am I missing??? Thank you for suggestions!

int main(void)
 {
//open raw data file 
FILE* rawfile = fopen("card.raw", "r");

 // buffer to hold 512 bytes from fread 
    typedef uint8_t  BYTE;
    BYTE buffer[512]; 
    char title[7];
    FILE* img = NULL;
    int search = 0; 
    int picnumber = 0; 

  while (feof (rawfile) == 0)
  {
      fread(&buffer, 512, 1, rawfile);

   //check for next jpeg signature 
       
            
       if (buffer[0] == 0xff && buffer [1] == 0xd8 && buffer [2] == 0xff && (buffer [3] >> 4) == 0xe)
          {
              

          //close current
            if ( search > 0)
            {
             fclose(img);
            } 
            //open new JPG and how to display file name 
              sprintf(title, "%03d.jpg", picnumber); 
              img = fopen(title, "a" );
              
             //write from buffer to new jpg, 
            fwrite(&buffer, 512, 1, img);
            picnumber++;
            search = 1;
          }
      else if (search > 0)
         {  
        fwrite(&buffer, 512, 1, img);   
         }
  }

  

}

edited body; edited title
Source Link
Cliff B
  • 69.3k
  • 4
  • 33
  • 56

Recover: all 5015 JPGs have "0" as first byte instead of 0xff

I've been stuck for days with this problem. My recover program creates 5015 jpgs but none of them show.

When I look at the first 4 bytes of each, bytes 2 - 4 are correct for JPG signature.

But byte 1 is always 0 instead of 0xff. I don't understand how this could be happening. What am I missing??? Thank you for suggestions!

int main(void)
 {
//open raw data file 
FILE* rawfile = fopen("card.raw", "r");

 // buffer to hold 512 bytes from fread 
    typedef uint8_t  BYTE;
    BYTE buffer[512]; 
    char title[7];
    FILE* img = NULL;
    int search = 0; 
    int picnumber = 0; 

  while (feof (rawfile) == 0)
  {
      fread(&buffer, 512, 1, rawfile);

   //check for next jpeg signature 
       
            
       if (buffer[0] == 0xff && buffer [1] == 0xd8 && buffer [2] == 0xff && (buffer [3] >> 4) == 0xe)
          {
              

          //close current
            if ( search > 0)
            {
             fclose(img);
            } 
            //open new JPG and how to display file name 
              sprintf(title, "%03d.jpg", picnumber); 
              img = fopen(title, "a" );
              
             //write from buffer to new jpg, 
            fwrite(&buffer, 512, 1, img);
            picnumber++;
            search = 1;
          }
      else if (search > 0)
         {  
        fwrite(&buffer, 512, 1, img);   
         }
  }

  

}

Recover: all 50 JPGs have "0" as first byte instead of 0xff

I've been stuck for days with this problem. My recover program creates 50 jpgs but none of them show.

When I look at the first 4 bytes of each, bytes 2 - 4 are correct for JPG signature.

But byte 1 is always 0 instead of 0xff. I don't understand how this could be happening. What am I missing??? Thank you for suggestions!

int main(void)
 {
//open raw data file 
FILE* rawfile = fopen("card.raw", "r");

 // buffer to hold 512 bytes from fread 
    typedef uint8_t  BYTE;
    BYTE buffer[512]; 
    char title[7];
    FILE* img = NULL;
    int search = 0; 
    int picnumber = 0; 

  while (feof (rawfile) == 0)
  {
      fread(&buffer, 512, 1, rawfile);

   //check for next jpeg signature 
       
            
       if (buffer[0] == 0xff && buffer [1] == 0xd8 && buffer [2] == 0xff && (buffer [3] >> 4) == 0xe)
          {
              

          //close current
            if ( search > 0)
            {
             fclose(img);
            } 
            //open new JPG and how to display file name 
              sprintf(title, "%03d.jpg", picnumber); 
              img = fopen(title, "a" );
              
             //write from buffer to new jpg, 
            fwrite(&buffer, 512, 1, img);
            picnumber++;
            search = 1;
          }
      else if (search > 0)
         {  
        fwrite(&buffer, 512, 1, img);   
         }
  }

  

}

Recover: all 15 JPGs have "0" as first byte instead of 0xff

I've been stuck for days with this problem. My recover program creates 15 jpgs but none of them show.

When I look at the first 4 bytes of each, bytes 2 - 4 are correct for JPG signature.

But byte 1 is always 0 instead of 0xff. I don't understand how this could be happening. What am I missing??? Thank you for suggestions!

int main(void)
 {
//open raw data file 
FILE* rawfile = fopen("card.raw", "r");

 // buffer to hold 512 bytes from fread 
    typedef uint8_t  BYTE;
    BYTE buffer[512]; 
    char title[7];
    FILE* img = NULL;
    int search = 0; 
    int picnumber = 0; 

  while (feof (rawfile) == 0)
  {
      fread(&buffer, 512, 1, rawfile);

   //check for next jpeg signature 
       
            
       if (buffer[0] == 0xff && buffer [1] == 0xd8 && buffer [2] == 0xff && (buffer [3] >> 4) == 0xe)
          {
              

          //close current
            if ( search > 0)
            {
             fclose(img);
            } 
            //open new JPG and how to display file name 
              sprintf(title, "%03d.jpg", picnumber); 
              img = fopen(title, "a" );
              
             //write from buffer to new jpg, 
            fwrite(&buffer, 512, 1, img);
            picnumber++;
            search = 1;
          }
      else if (search > 0)
         {  
        fwrite(&buffer, 512, 1, img);   
         }
  }

  

}

Source Link
Xia
  • 45
  • 4
Loading