PhotoRec: find the filesize for Adobe Brush .abr
This commit is contained in:
parent
5e03dc19dc
commit
7bc1d5a6c2
1 changed files with 38 additions and 2 deletions
|
@ -2,7 +2,7 @@
|
|||
|
||||
File: file_abr.c
|
||||
|
||||
Copyright (C) 2012 Christophe GRENIER <grenier@cgsecurity.org>
|
||||
Copyright (C) 2012,2016 Christophe GRENIER <grenier@cgsecurity.org>
|
||||
|
||||
This software is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
@ -29,22 +29,58 @@
|
|||
#include <stdio.h>
|
||||
#include "types.h"
|
||||
#include "filegen.h"
|
||||
#include "common.h"
|
||||
|
||||
static void register_header_check_abr(file_stat_t *file_stat);
|
||||
struct abr_header
|
||||
{
|
||||
char magic[4];
|
||||
char info[4];
|
||||
uint32_t size;
|
||||
} __attribute__ ((gcc_struct, __packed__));
|
||||
|
||||
const file_hint_t file_hint_abr= {
|
||||
.extension="abr",
|
||||
.description="Adobe Brush",
|
||||
.max_filesize=100*1024*1024,
|
||||
.max_filesize=PHOTOREC_MAX_FILE_SIZE,
|
||||
.recover=1,
|
||||
.enable_by_default=1,
|
||||
.register_header_check=®ister_header_check_abr
|
||||
};
|
||||
|
||||
static data_check_t data_check_abr(const unsigned char *buffer, const unsigned int buffer_size, file_recovery_t *file_recovery)
|
||||
{
|
||||
while(file_recovery->calculated_file_size + buffer_size/2 >= file_recovery->file_size &&
|
||||
file_recovery->calculated_file_size + 12 < file_recovery->file_size + buffer_size/2)
|
||||
{
|
||||
const unsigned int i=file_recovery->calculated_file_size - file_recovery->file_size + buffer_size/2;
|
||||
const struct abr_header *hdr=(const struct abr_header*)&buffer[i];
|
||||
if(memcmp(hdr->magic, "8BIM", 4)!=0)
|
||||
return DC_STOP;
|
||||
file_recovery->calculated_file_size+=be32(hdr->size)+12;
|
||||
}
|
||||
return DC_CONTINUE;
|
||||
}
|
||||
|
||||
static int header_check_abr(const unsigned char *buffer, const unsigned int buffer_size, const unsigned int safe_header_only, const file_recovery_t *file_recovery, file_recovery_t *file_recovery_new)
|
||||
{
|
||||
const struct abr_header *hdr=(const struct abr_header*)&buffer[4];
|
||||
unsigned int i=4;
|
||||
while(i + 12 < buffer_size && i + 12 < 512)
|
||||
{
|
||||
const struct abr_header *h=(const struct abr_header*)&buffer[i];
|
||||
if(memcmp(h->magic, "8BIM", 4)!=0)
|
||||
return 0;
|
||||
i+=be32(h->size)+12;
|
||||
}
|
||||
reset_file_recovery(file_recovery_new);
|
||||
file_recovery_new->extension=file_hint_abr.extension;
|
||||
file_recovery_new->min_filesize=4+12+be32(hdr->size);
|
||||
file_recovery_new->calculated_file_size=4+12+be32(hdr->size);
|
||||
if(file_recovery_new->blocksize < 12)
|
||||
return 1;
|
||||
file_recovery_new->data_check=&data_check_abr;
|
||||
file_recovery_new->file_check=&file_check_size;
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue