Developers

From CGSecurity
Jump to: navigation, search

En.png English It.png Italiano


Using Git to get latest source code

Git is a modern source code manager

http://git.cgsecurity.org/testdisk.git is a Git repository to track TestDisk & PhotoRec source code, you can browse it using http://git.cgsecurity.org/cgit/testdisk/ or via github https://github.com/cgsecurity/testdisk

Install git using

  • yum install git for Fedora, RedHat, Centos
  • sudo apt-get install git-core for Debian, Ubuntu

Configure your local settings

$ git config --global user.name "Your Name"
$ git config --global user.email "Your Email"

Clone the current source code

$ git clone http://git.cgsecurity.org/testdisk.git

If you have already cloned the project, to update your local copy, run git pull from the testdisk directory.

Compile TestDisk & PhotoRec

$ cd testdisk
$ mkdir config
$ autoreconf --install -W all -I config
$ ./configure
$ make

If autoreconf is missing, check that automake and autoconf are present, otherwise you can replace the autoreconf command by

$ aclocal -I config
$ autoheader -W all
$ autoconf -W all
$ automake --gnits --add-missing --copy

Read TestDisk Compilation if you have problems to compile TestDisk & PhotoRec

It's time to make your own modifications and submit the patch

$ (edit files)
$ git add (files)
$ git commit -a
$ git format-patch origin/master
$ ls *.patch

Download source code

If you have been unable to install git, download a snapshot of TestDisk & PhotoRec latest source code. Get the beta version, the Work-In-Progress (WIP) one.

Adding a new file format to PhotoRec

The first step is to check if PhotoRec already identify the file. Run fidentify sample_file. If the file is identified with an incorrect extension, check if there is way to differentiate this file from files having the extension that has been found. If fidentify reports the format as unknown, you have found a candidate for inclusion.

If the file format specifications aren't available, compare several samples to identify constant fields. In example, PhotoRec identifies a JPEG file when a block begins with:

  • 0xff,0xd8,0xff,0xe0
  • 0xff,0xd8,0xff,0xe1
  • or 0xff,0xd8,0xff,0xfe


To add a new file format to PhotoRec,

  extern const file_hint_t file_hint_<EXTENSION>;
  • and in list_file_enable[]
  { .enable=0, .file_hint=&file_hint_<EXTENSION> },
       file_<EXTENSION>.c
  • If there is a header file, add it to file_H definition
  • Create a file name src/file_<EXTENSION>.c.
  • Register the various MAGIC header in register_header_check_EXTENSION()

In this example, file_check_EXTENSION() is used to check for a footer.

Check

qphotorec: PhotoRec with a Qt4 GUI

QPhotoRec is now build by default since TestDisk & PhotoRec 7.0 if Qt development package is available :

./configure && make