diff options
author | Maurus Cuelenaere <mcuelenaere@gmail.com> | 2008-08-24 21:15:29 +0000 |
---|---|---|
committer | Maurus Cuelenaere <mcuelenaere@gmail.com> | 2008-08-24 21:15:29 +0000 |
commit | ced10d4db18947c724d25dfc923a22c9aff3f629 (patch) | |
tree | bc93ad2e3bdf67240947b01c6f96026c89750f03 | |
parent | 074e48c08c439ef40416fb9b264a1f113c69a3b3 (diff) | |
download | rockbox-ced10d4db18947c724d25dfc923a22c9aff3f629.tar.gz rockbox-ced10d4db18947c724d25dfc923a22c9aff3f629.zip |
ZenUtils:
* Apply FS#9311 by Jelle Geerts: fix compiling on MingW
* Make zen::find_firmware_offset() detect the offset better
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@18340 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r-- | docs/CREDITS | 1 | ||||
-rw-r--r-- | utils/zenutils/libraries/beecrypt-4.1.2/beecrypt/win.h | 6 | ||||
-rw-r--r-- | utils/zenutils/source/shared/updater.cpp | 18 |
3 files changed, 13 insertions, 12 deletions
diff --git a/docs/CREDITS b/docs/CREDITS index 74f359c2c3..8e087e0655 100644 --- a/docs/CREDITS +++ b/docs/CREDITS | |||
@@ -411,6 +411,7 @@ Tadayuki Nishizono | |||
411 | Jun Gu | 411 | Jun Gu |
412 | Daniel Weck | 412 | Daniel Weck |
413 | Clément Pit-Claudel | 413 | Clément Pit-Claudel |
414 | Jelle Geerts | ||
414 | 415 | ||
415 | The libmad team | 416 | The libmad team |
416 | The wavpack team | 417 | The wavpack team |
diff --git a/utils/zenutils/libraries/beecrypt-4.1.2/beecrypt/win.h b/utils/zenutils/libraries/beecrypt-4.1.2/beecrypt/win.h index d578085c29..04a08c609f 100644 --- a/utils/zenutils/libraries/beecrypt-4.1.2/beecrypt/win.h +++ b/utils/zenutils/libraries/beecrypt-4.1.2/beecrypt/win.h | |||
@@ -39,7 +39,7 @@ | |||
39 | # else | 39 | # else |
40 | # error Unknown CPU type in MetroWerks CodeWarrior | 40 | # error Unknown CPU type in MetroWerks CodeWarrior |
41 | # endif | 41 | # endif |
42 | #elif defined(_MSC_VER) | 42 | #elif defined(_MSC_VER) || defined(__MINGW32__) |
43 | # if defined(_M_IX86) | 43 | # if defined(_M_IX86) |
44 | # define WORDS_BIGENDIAN 0 | 44 | # define WORDS_BIGENDIAN 0 |
45 | # define ROTL32(x, s) _rotl(x, s) | 45 | # define ROTL32(x, s) _rotl(x, s) |
@@ -51,7 +51,7 @@ | |||
51 | # error Unknown compiler for WIN32 | 51 | # error Unknown compiler for WIN32 |
52 | #endif | 52 | #endif |
53 | 53 | ||
54 | #if defined(_MSC_VER) || __MWERKS__ | 54 | #if defined(_MSC_VER) || defined(__MINGW32__) || __MWERKS__ |
55 | #include <stdio.h> | 55 | #include <stdio.h> |
56 | #include <stdlib.h> | 56 | #include <stdlib.h> |
57 | #include <string.h> | 57 | #include <string.h> |
@@ -128,6 +128,8 @@ typedef unsigned __int64 uint64_t; | |||
128 | 128 | ||
129 | typedef long off_t; | 129 | typedef long off_t; |
130 | 130 | ||
131 | #elif defined(__MINGW32__) | ||
132 | #include <stdint.h> | ||
131 | #endif | 133 | #endif |
132 | 134 | ||
133 | #define MP_WBITS 32U | 135 | #define MP_WBITS 32U |
diff --git a/utils/zenutils/source/shared/updater.cpp b/utils/zenutils/source/shared/updater.cpp index 3944863533..7efac3d373 100644 --- a/utils/zenutils/source/shared/updater.cpp +++ b/utils/zenutils/source/shared/updater.cpp | |||
@@ -50,19 +50,18 @@ const char* zen::find_firmware_key(const byte* buffer, size_t len) | |||
50 | 50 | ||
51 | dword zen::find_firmware_offset(byte* buffer, size_t len) | 51 | dword zen::find_firmware_offset(byte* buffer, size_t len) |
52 | { | 52 | { |
53 | for (dword i = 0; i < static_cast<dword>(len); i += 0x10) | 53 | for (dword i = 0; i < static_cast<dword>(len); i += 4) |
54 | { | 54 | { |
55 | dword size = *(dword*)&buffer[i]; | 55 | dword size = *(dword*)&buffer[i]; |
56 | if (size < (i + len) && size > (len >> 1)) | 56 | if (buffer[i + sizeof(dword)] != 0 |
57 | && buffer[i + sizeof(dword) + 1] != 0 | ||
58 | && buffer[i + sizeof(dword) + 2] != 0 | ||
59 | && buffer[i + sizeof(dword) + 3] != 0) | ||
57 | { | 60 | { |
58 | if (buffer[i + sizeof(dword)] != 0 | 61 | return i; |
59 | && buffer[i + sizeof(dword) + 1] != 0 | ||
60 | && buffer[i + sizeof(dword) + 2] != 0 | ||
61 | && buffer[i + sizeof(dword) + 3] != 0) | ||
62 | { | ||
63 | return i; | ||
64 | } | ||
65 | } | 62 | } |
63 | if(i > 0xFF) /* Arbitrary guess */ | ||
64 | return 0; | ||
66 | } | 65 | } |
67 | return 0; | 66 | return 0; |
68 | } | 67 | } |
@@ -105,7 +104,6 @@ bool zen::crypt_firmware(const char* key, byte* buffer, size_t len) | |||
105 | unsigned int tmp = 0; | 104 | unsigned int tmp = 0; |
106 | int key_length = strlen(key); | 105 | int key_length = strlen(key); |
107 | 106 | ||
108 | strcpy(key_cpy, key); | ||
109 | for(i=0; i < strlen(key); i++) | 107 | for(i=0; i < strlen(key); i++) |
110 | key_cpy[i] = key[i] - 1; | 108 | key_cpy[i] = key[i] - 1; |
111 | 109 | ||