Skip to content
This repository has been archived by the owner on Nov 21, 2020. It is now read-only.

Commit

Permalink
Fix Tar, do Tar64, fix PST non-U/A
Browse files Browse the repository at this point in the history
  • Loading branch information
dd86k committed Jun 4, 2019
1 parent 84702e1 commit e6003f3
Show file tree
Hide file tree
Showing 11 changed files with 53 additions and 41 deletions.
4 changes: 2 additions & 2 deletions src/archives/pst.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ void scan_pst() {
char *a, *c;

if (ansi)
a = "ANSI, ";
a = "ANSI";
else if (unicode)
a = "Unicode, ";
a = "Unicode";

switch (uh.crypt) {
case 0x01: c = "encrypted (Permutation algorithm)"; break;
Expand Down
22 changes: 10 additions & 12 deletions src/archives/rpf.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,17 @@ void scan_rpf(uint32_t s) {
struct rpf_hdr h;
_ddread(&h, sizeof(h));

char *e, *g;
char *g;

e = h.encrypted ? "encrypted" : "unencrypted";

switch (s) {
case 0x30465052: g = "Table Tennis"; break;
case 0x32465052: g = "GTA IV"; break;
case 0x33465052: g = "GTA IV:A&MC:LA"; break;
case 0x34465052: g = "Max Payne 3"; break;
case 0x36465052: g = "Red Dead Redemption"; break;
case 0x37465052: g = "GTA V"; break;
switch (s >>= 24) {
case 0x30: g = "Table Tennis"; break;
case 0x32: g = "GTA IV"; break;
case 0x33: g = "GTA IV:A&MC:LA"; break;
case 0x34: g = "Max Payne 3"; break;
case 0x36: g = "Red Dead Redemption"; break;
case 0x37: g = "GTA V"; break;
}

reportf("RPF %s archive v%u for %s, %u entries",
e, s >> 24, g, h.numentries);
reportf("RPF %sencrypted archive v%u for %s, %u entries",
h.encrypted ? "" : "un", s, g, h.numentries);
}
14 changes: 8 additions & 6 deletions src/archives/tar.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,43 +5,45 @@
#include "../ff.h"
#include "tar.h"

// https://www.gnu.org/software/tar/manual/html_node/Standard.html

void scan_tar() {
struct tar_hdr h;
_ddseek(0, SEEK_SET);
_ddread(&h, sizeof(h));

char *l;

switch (h.linkflag) {
case 0:
case '0': l = "Normal"; break;
switch (h.typeflag) {
case 0: case '0': l = "Normal"; break;
case '1': l = "Link"; break;
case '2': l = "Syslink"; break;
case '3': l = "Character special"; break;
case '4': l = "Block special"; break;
case '5': l = "Directory"; break;
case '6': l = "FIFO"; break;
case '7': l = "Contiguous"; break;
case 'x': l = "Extended Header"; break;
case 'g': l = "Global Extended Header"; break;
default: report("Tar archive?"); return;
}

long s = strtol(h.size, NULL, sizeof(h.size));

reportf("%s Tar archive, ", l);
reportf("Tar %s archive, \"%.100s\", ", l, h.name);
_printfd(s);
putchar('\n');

if (More) {
printf(
"Name: %.100s\n"
"Link name: %.100s\n"
"uname: %.32s\n"
"gname: %.32s\n"
"Magic: %.8s\n"
"Mode: %.8s\n"
"Checksum: %.8s\n"
"Version: %.8s.%.8s\n",
h.name, h.linkname, h.uname,
h.linkname, h.uname,
h.gname, h.magic, h.mode,
h.chksum, h.devmajor, h.devminor
);
Expand Down
26 changes: 16 additions & 10 deletions src/archives/tar.h
Original file line number Diff line number Diff line change
@@ -1,29 +1,35 @@
#define TAR "ustar\000"
#define GNUTAR "GNUtar\00"
//TODO: 64-bit number versions with conditional compile option

#define TAR32L 0x61747375
#define TAR32H 0x00202072
#define TAR32H 0x30300072
#define TAR64 0x3030007261747375LU

#define GNUTAR32L 0x74554E47
#define GNUTAR32H 0x20007261
#define GNUTAR32H 0x30007261
#define GNUTAR64 0x3000726174554E47LU

#define NAMSIZ 100
#define TUNMLEN 32
#define TGNMLEN 32

struct tar_hdr {
char name[NAMSIZ];
struct tar_hdr { // POSIX 1003.1-1990
char name[100];
char mode[8];
char uid[8];
char gid[8];
char size[12];
char mtime[12];
char chksum[8];
char linkflag;
char linkname[NAMSIZ];
char magic[8];
char uname[TUNMLEN];
char gname[TGNMLEN];
char typeflag;
char linkname[100];
char magic[6];
char version[2];
char uname[32];
char gname[32];
char devmajor[8];
char devminor[8];
// char prefix[155];
};

void scan_tar(void);
2 changes: 1 addition & 1 deletion src/documents/mobi.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ void scan_palmdoc() {
struct palmdoc_hdr h;
_ddread(&h, sizeof(h));

reportn("Palm document");
reportl("Palm document");

if (h.Compression == 0x0100) // Big Endian
printl(", PalmDOC compressed");
Expand Down
16 changes: 11 additions & 5 deletions src/etc.c
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ void scan_etc() {
break;
default: goto MOBI_OUT;
}
reportn(mt);
reportl(mt);
palmdb_name();
return;
MOBI_OUT:
Expand All @@ -127,7 +127,14 @@ void scan_etc() {
//

if (_ddseek(0x101, SEEK_SET)) goto _END;
uint32_t btar32[2];
uint64_t btar64;
_ddread(&btar64, 8);
switch (btar64) {
case TAR64: case GNUTAR64:
scan_tar();
return;
}
/*uint32_t btar32[2];
_ddread(btar32, 8);
switch (btar32[0]) {
case TAR32L: case GNUTAR32L:
Expand All @@ -136,7 +143,7 @@ void scan_etc() {
scan_tar(); return;
}
break;
}
}*/

//
// ISO-9660
Expand All @@ -161,7 +168,6 @@ void scan_etc() {
scan_iso(); return;
}

_END: // If file is smaller than our seeks and/or didn't find anything
//TODO: Detect text?
_END:
report_data();
}
2 changes: 1 addition & 1 deletion src/ff.c
Original file line number Diff line number Diff line change
Expand Up @@ -681,7 +681,7 @@ void report(char *s) {
* Report to stdout the filetype without a newline
* Params: s = Type
*/
void reportn(char *s) {
void reportl(char *s) {
if (ShowName)
printf(
#ifdef _WIN32
Expand Down
2 changes: 1 addition & 1 deletion src/ff.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ char *currFile;

void scan(int *);
void report(char *);
void reportn(char *);
void reportl(char *);
void reportf(char *, ...);
void report_data();
void report_text();
2 changes: 1 addition & 1 deletion src/utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ void isoslice(char *buffer, char *target, size_t max) {
} else *target = '\0';
}

void _printfd(unsigned long long l) {
void _printfd(uint64_t l) {
float f = l;
if (f >= GB) { // Lazy code, sorry
printf("%.2fG", f / GB);
Expand Down
2 changes: 1 addition & 1 deletion src/vdisk/qed.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ void scan_qed() {
struct qed_hdr h;
_ddread(&h, sizeof(h));

reportn("QEMU QED vdisk, ");
reportl("QEMU QED vdisk, ");
_printfd(h.image_size);

if (h.features & QED_F_BACKING_FILE) {
Expand Down
2 changes: 1 addition & 1 deletion src/vdisk/vdi.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ void scan_vdi() {
print_a("Modify UUID :", sh.uuidModify, 16);
print_a("Link UUID :", sh.uuidLinkage, 16);
if (h.majorv >= 1)
print_a("ParentModify UUID:", sh.uuidParentModify, 16);
print_a("Parent UUID :", sh.uuidParentModify, 16);
printf(
"Cylinders (Legacy) : %u\n"
"Heads (Legacy) : %u\n"
Expand Down

0 comments on commit e6003f3

Please # to comment.