mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-10-14 10:37:38 -04:00
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
This commit is contained in:
parent
074e48c08c
commit
ced10d4db1
3 changed files with 13 additions and 12 deletions
|
@ -411,6 +411,7 @@ Tadayuki Nishizono
|
||||||
Jun Gu
|
Jun Gu
|
||||||
Daniel Weck
|
Daniel Weck
|
||||||
Clément Pit-Claudel
|
Clément Pit-Claudel
|
||||||
|
Jelle Geerts
|
||||||
|
|
||||||
The libmad team
|
The libmad team
|
||||||
The wavpack team
|
The wavpack team
|
||||||
|
|
|
@ -39,7 +39,7 @@
|
||||||
# else
|
# else
|
||||||
# error Unknown CPU type in MetroWerks CodeWarrior
|
# error Unknown CPU type in MetroWerks CodeWarrior
|
||||||
# endif
|
# endif
|
||||||
#elif defined(_MSC_VER)
|
#elif defined(_MSC_VER) || defined(__MINGW32__)
|
||||||
# if defined(_M_IX86)
|
# if defined(_M_IX86)
|
||||||
# define WORDS_BIGENDIAN 0
|
# define WORDS_BIGENDIAN 0
|
||||||
# define ROTL32(x, s) _rotl(x, s)
|
# define ROTL32(x, s) _rotl(x, s)
|
||||||
|
@ -51,7 +51,7 @@
|
||||||
# error Unknown compiler for WIN32
|
# error Unknown compiler for WIN32
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(_MSC_VER) || __MWERKS__
|
#if defined(_MSC_VER) || defined(__MINGW32__) || __MWERKS__
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
@ -128,6 +128,8 @@ typedef unsigned __int64 uint64_t;
|
||||||
|
|
||||||
typedef long off_t;
|
typedef long off_t;
|
||||||
|
|
||||||
|
#elif defined(__MINGW32__)
|
||||||
|
#include <stdint.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define MP_WBITS 32U
|
#define MP_WBITS 32U
|
||||||
|
|
|
@ -50,11 +50,9 @@ const char* zen::find_firmware_key(const byte* buffer, size_t len)
|
||||||
|
|
||||||
dword zen::find_firmware_offset(byte* buffer, size_t len)
|
dword zen::find_firmware_offset(byte* buffer, size_t len)
|
||||||
{
|
{
|
||||||
for (dword i = 0; i < static_cast<dword>(len); i += 0x10)
|
for (dword i = 0; i < static_cast<dword>(len); i += 4)
|
||||||
{
|
{
|
||||||
dword size = *(dword*)&buffer[i];
|
dword size = *(dword*)&buffer[i];
|
||||||
if (size < (i + len) && size > (len >> 1))
|
|
||||||
{
|
|
||||||
if (buffer[i + sizeof(dword)] != 0
|
if (buffer[i + sizeof(dword)] != 0
|
||||||
&& buffer[i + sizeof(dword) + 1] != 0
|
&& buffer[i + sizeof(dword) + 1] != 0
|
||||||
&& buffer[i + sizeof(dword) + 2] != 0
|
&& buffer[i + sizeof(dword) + 2] != 0
|
||||||
|
@ -62,7 +60,8 @@ dword zen::find_firmware_offset(byte* buffer, size_t len)
|
||||||
{
|
{
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
}
|
if(i > 0xFF) /* Arbitrary guess */
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -105,7 +104,6 @@ bool zen::crypt_firmware(const char* key, byte* buffer, size_t len)
|
||||||
unsigned int tmp = 0;
|
unsigned int tmp = 0;
|
||||||
int key_length = strlen(key);
|
int key_length = strlen(key);
|
||||||
|
|
||||||
strcpy(key_cpy, key);
|
|
||||||
for(i=0; i < strlen(key); i++)
|
for(i=0; i < strlen(key); i++)
|
||||||
key_cpy[i] = key[i] - 1;
|
key_cpy[i] = key[i] - 1;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue