summaryrefslogtreecommitdiffstats
path: root/src/file_gm6.c
diff options
context:
space:
mode:
authorDickson Law <dicksonlaw583@gmail.com>2015-08-26 10:03:08 +0200
committerChristophe Grenier <grenier@cgsecurity.org>2015-08-26 10:03:08 +0200
commit5fedcb4831c2099ebc9facde742fb204ffd11c7c (patch)
tree8dee776bf35b888ec4e0f93acbb889d0f320507c /src/file_gm6.c
parent58fe4a3cb53f4034c53b75d097b9b9281a3e28a4 (diff)
PhotoRec: update Game Maker support to recover versions from 4.3 to 8.1
Diffstat (limited to 'src/file_gm6.c')
-rw-r--r--src/file_gm6.c88
1 files changed, 81 insertions, 7 deletions
diff --git a/src/file_gm6.c b/src/file_gm6.c
index 1a01b8c..536eeca 100644
--- a/src/file_gm6.c
+++ b/src/file_gm6.c
@@ -33,21 +33,39 @@
static void register_header_check_gm6(file_stat_t *file_stat);
const file_hint_t file_hint_gm6= {
- .extension="gm6",
- .description="Game Maker",
+ .extension="gm*",
+ .description="Game Maker (4.3 - 8.1)",
.max_filesize=PHOTOREC_MAX_FILE_SIZE,
.recover=1,
.enable_by_default=1,
.register_header_check=&register_header_check_gm6
};
+//Version 8.1 file (.gm81)
+static int header_check_gm81(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)
+{
+ reset_file_recovery(file_recovery_new);
+ file_recovery_new->extension="gm81";
+ return 1;
+}
+
+//Version 7.0-8.0 file (.gmk)
+static int header_check_gmk(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)
+{
+ reset_file_recovery(file_recovery_new);
+ file_recovery_new->extension="gmk";
+ return 1;
+}
+
+//Version 6.0-6.1 file (.gm6)
static int header_check_gm6(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)
{
reset_file_recovery(file_recovery_new);
- file_recovery_new->extension=file_hint_gm6.extension;
+ file_recovery_new->extension="gm6";
return 1;
}
+//Version 4.3-5.3A file (.gmd)
static int header_check_gmd(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)
{
reset_file_recovery(file_recovery_new);
@@ -57,12 +75,68 @@ static int header_check_gmd(const unsigned char *buffer, const unsigned int buff
static void register_header_check_gm6(file_stat_t *file_stat)
{
- static const unsigned char gm6_header[8]= {
+ /*
+ These are the headers that identify Game Maker files for 8.1 and earlier.
+ First set of 4 bytes: Little-endian, constant 1234321 (decimal)
+ Second set of 4 bytes: Little-endian, Version identifier
+ Source: "Binary Format of GameMaker Save Files (gmd, gm6, gmk)" by IsmAvatar
+ URL: http://ismavatar.com/lgm/formats/gmformat7.txt
+ */
+ //Version 8.1 (.gm81)
+ static const unsigned char gm81_header[8] = {
+ 0x91, 0xd5, 0x12, 0x00, 0x2a, 0x03, 0x00, 0x00
+ };
+ //Version 8.0 (.gmk)
+ static const unsigned char gm80_header[8] = {
+ 0x91, 0xd5, 0x12, 0x00, 0x20, 0x03, 0x00, 0x00
+ };
+ //Version 7.0 variant 2 (.gmk)
+ static const unsigned char gm72_header[8] = {
+ 0x91, 0xd5, 0x12, 0x00, 0xbe, 0x02, 0x00, 0x00
+ };
+ //Version 7.0 variant 1 (.gmk)
+ static const unsigned char gm71_header[8] = {
+ 0x91, 0xd5, 0x12, 0x00, 0xbd, 0x02, 0x00, 0x00
+ };
+ //Version 7.0 early variant (.gmk)
+ static const unsigned char gm62_header[8] = {
+ 0x91, 0xd5, 0x12, 0x00, 0x6c, 0x02, 0x00, 0x00
+ };
+ //Version 6.0-6.1 (.gm6)
+ static const unsigned char gm60_header[8] = {
0x91, 0xd5, 0x12, 0x00, 0x58, 0x02, 0x00, 0x00
};
- static const unsigned char gmd_header[8]= {
+ //Version 5.3 (.gmd)
+ static const unsigned char gm53_header[8] = {
+ 0x91, 0xd5, 0x12, 0x00, 0x12, 0x02, 0x00, 0x00
+ };
+ //Version 5.2 (.gmd)
+ static const unsigned char gm52_header[8] = {
+ 0x91, 0xd5, 0x12, 0x00, 0x08, 0x02, 0x00, 0x00
+ };
+ //Version 5.1 (.gmd)
+ static const unsigned char gm51_header[8] = {
+ 0x91, 0xd5, 0x12, 0x00, 0xfe, 0x01, 0x00, 0x00
+ };
+ //Version 5.0 (.gmd)
+ static const unsigned char gm50_header[8] = {
0x91, 0xd5, 0x12, 0x00, 0xf4, 0x01, 0x00, 0x00
};
- register_header_check(0, gm6_header, sizeof(gm6_header), &header_check_gm6, file_stat);
- register_header_check(0, gmd_header, sizeof(gmd_header), &header_check_gmd, file_stat);
+ //Version 4.3 (.gmd)
+ static const unsigned char gm43_header[8] = {
+ 0x91, 0xd5, 0x12, 0x00, 0xae, 0x01, 0x00, 0x00
+ };
+
+ //Register all variant header signatures with respective extensions
+ register_header_check(0, gm81_header, sizeof(gm81_header), &header_check_gm81, file_stat);
+ register_header_check(0, gm80_header, sizeof(gm80_header), &header_check_gmk, file_stat);
+ register_header_check(0, gm72_header, sizeof(gm72_header), &header_check_gmk, file_stat);
+ register_header_check(0, gm71_header, sizeof(gm71_header), &header_check_gmk, file_stat);
+ register_header_check(0, gm62_header, sizeof(gm62_header), &header_check_gmk, file_stat);
+ register_header_check(0, gm60_header, sizeof(gm60_header), &header_check_gm6, file_stat);
+ register_header_check(0, gm53_header, sizeof(gm53_header), &header_check_gmd, file_stat);
+ register_header_check(0, gm52_header, sizeof(gm52_header), &header_check_gmd, file_stat);
+ register_header_check(0, gm51_header, sizeof(gm51_header), &header_check_gmd, file_stat);
+ register_header_check(0, gm50_header, sizeof(gm50_header), &header_check_gmd, file_stat);
+ register_header_check(0, gm43_header, sizeof(gm43_header), &header_check_gmd, file_stat);
}