From 61c952814d4db3253e50cb41be1526780eb05dfb Mon Sep 17 00:00:00 2001 From: Wu Yongzheng Date: Tue, 14 Aug 2012 15:01:29 +0800 Subject: [PATCH] minor --- README.txt | 4 ++-- gimgunlock.c | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/README.txt b/README.txt index b3faa35..9e7f94c 100644 --- a/README.txt +++ b/README.txt @@ -3,9 +3,9 @@ gimgtools is a set of command-line tools to examine and manipulate Garmin IMG * gimgunlock: Unlock a locked map so that it can be used on ALL devices. There is no need to specify your device ID or map keys. It works by decrypting - the TRE section. The decrypting key is the same for all maps. If you like - Garmin, please buy their map! + the TRE sections, since the encryption key is also stored in the maps! Usage: gimgunlock map.img + If you like Garmin, please buy their map! * gimgxor: Some maps have been scrambled by a trival XOR algorithm. They do not work with other gimg* tools. You can use gimgxor to unscramble them. Usage: gimgxor map.img diff --git a/gimgunlock.c b/gimgunlock.c index 3ebcb19..a050809 100644 --- a/gimgunlock.c +++ b/gimgunlock.c @@ -71,21 +71,21 @@ int read_byte_at (FILE *fp, unsigned long offset) return getc(fp); } -unsigned int read_2byte_at (FILE *fp, unsigned long offset) +int read_2byte_at (FILE *fp, unsigned long offset) { - unsigned int n = 0; + unsigned char buff[2]; if (fseek(fp, offset, SEEK_SET)) { perror(NULL); exit(1); } - if (fread(&n, 2, 1, fp) != 1) { + if (fread(&buff, 2, 1, fp) != 1) { perror(NULL); exit(1); } - return n; + return (buff[1] << 8) | buff[0]; } -unsigned int read_4byte_at (FILE *fp, unsigned long offset) +unsigned int read_4byte_at (FILE *fp, unsigned long offset) //FIXME: doesn't work on bigendian { unsigned int n = 0; if (fseek(fp, offset, SEEK_SET)) {