forked from len0rd/rockbox
Code Police raid: -W -Wall cleansing
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@17045 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
3e6280039e
commit
49e6a29828
4 changed files with 49 additions and 36 deletions
|
@ -17,40 +17,65 @@
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include "creative.h"
|
|
||||||
#include "hmac-sha1.h"
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
#include "creative.h"
|
||||||
|
#include "hmac-sha1.h"
|
||||||
|
|
||||||
|
static const char null_key_v1[] = "CTL:N0MAD|PDE0.SIGN.";
|
||||||
|
static const char null_key_v2[] = "CTL:N0MAD|PDE0.DPMP.";
|
||||||
|
static const char null_key_v3[] = "CTL:Z3N07|PDE0.DPMP.";
|
||||||
|
static const char null_key_v4[] = "CTL:N0MAD|PDE0.DPFP.";
|
||||||
|
|
||||||
|
static const struct device_info devices[] =
|
||||||
|
{
|
||||||
|
{"C\0r\0e\0a\0t\0i\0v\0e\0 \0Z\0e\0n\0 \0V\0i\0s\0i\0o\0n\0:\0M",
|
||||||
|
42, null_key_v2},
|
||||||
|
{"C\0r\0e\0a\0t\0i\0v\0e\0 \0Z\0e\0n\0 \0V\0i\0s\0i\0o\0n\0:\0M\0 \0G\0o\0!",
|
||||||
|
50, null_key_v2},
|
||||||
|
{"C\0r\0e\0a\0t\0i\0v\0e\0 \0Z\0e\0n\0 \0V\0i\0s\0i\0o\0n\0 \0©\0T\0L",
|
||||||
|
48, null_key_v2},
|
||||||
|
{"C\0r\0e\0a\0t\0i\0v\0e\0 \0Z\0E\0N\0 \0V", 42, null_key_v4}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Create a Zen Vision:M FRESCUE structure file
|
Create a Zen Vision:M FRESCUE structure file
|
||||||
*/
|
*/
|
||||||
|
extern void int2le(unsigned int val, unsigned char* addr);
|
||||||
|
extern unsigned int le2int(unsigned char* buf);
|
||||||
|
|
||||||
|
|
||||||
static int make_ciff_file(char *inbuf, int length, char *outbuf, int device)
|
static int make_ciff_file(unsigned char *inbuf, int length,
|
||||||
|
unsigned char *outbuf, int device)
|
||||||
{
|
{
|
||||||
|
char key[20];
|
||||||
memcpy(outbuf, "FFIC", 4);
|
memcpy(outbuf, "FFIC", 4);
|
||||||
int2le(length+90, &outbuf[4]);
|
int2le(length+90, &outbuf[4]);
|
||||||
memcpy(&outbuf[8], "FNIC", 4);
|
memcpy(&outbuf[8], "FNIC", 4);
|
||||||
int2le(96, &outbuf[0xC]);
|
int2le(96, &outbuf[0xC]);
|
||||||
memcpy(&outbuf[0x10], devices[device].cinf, devices[device].cinf_size);
|
memcpy(&outbuf[0x10], devices[device].cinf, devices[device].cinf_size);
|
||||||
memset(&outbuf[0x10+devices[device].cinf_size], 0, 96 - devices[device].cinf_size);
|
memset(&outbuf[0x10+devices[device].cinf_size], 0,
|
||||||
|
96 - devices[device].cinf_size);
|
||||||
memcpy(&outbuf[0x70], "ATAD", 4);
|
memcpy(&outbuf[0x70], "ATAD", 4);
|
||||||
int2le(length+32, &outbuf[0x74]);
|
int2le(length+32, &outbuf[0x74]);
|
||||||
memcpy(&outbuf[0x78], "H\0j\0u\0k\0e\0b\0o\0x\0\x32\0.\0j\0r\0m", 32); /*Unicode encoded*/
|
memcpy(&outbuf[0x78], "H\0j\0u\0k\0e\0b\0o\0x\0\x32\0.\0j\0r\0m",
|
||||||
|
32); /*Unicode encoded*/
|
||||||
memcpy(&outbuf[0x98], inbuf, length);
|
memcpy(&outbuf[0x98], inbuf, length);
|
||||||
memcpy(&outbuf[0x98+length], "LLUN", 4);
|
memcpy(&outbuf[0x98+length], "LLUN", 4);
|
||||||
int2le(20, &outbuf[0x98+length+4]);
|
int2le(20, &outbuf[0x98+length+4]);
|
||||||
/* Do checksum */
|
/* Do checksum */
|
||||||
char key[20];
|
hmac_sha((char *)devices[device].null, strlen(devices[device].null),
|
||||||
hmac_sha((char*)devices[device].null, strlen(devices[device].null), outbuf, 0x98+length, key, 20);
|
(char *)outbuf, 0x98+length, key, 20);
|
||||||
memcpy(&outbuf[0x98+length+8], key, 20);
|
memcpy(&outbuf[0x98+length+8], key, 20);
|
||||||
return length+0x90+0x1C+8;
|
return length+0x90+0x1C+8;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int make_jrm_file(char *inbuf, int length, char *outbuf)
|
static int make_jrm_file(unsigned char *inbuf, int length,
|
||||||
|
unsigned char *outbuf)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
unsigned int sum = 0;
|
unsigned int sum = 0;
|
||||||
|
@ -101,7 +126,6 @@ int zvm_encode(char *iname, char *oname, int device)
|
||||||
FILE *file;
|
FILE *file;
|
||||||
unsigned char *outbuf;
|
unsigned char *outbuf;
|
||||||
unsigned char *buf;
|
unsigned char *buf;
|
||||||
int i;
|
|
||||||
|
|
||||||
file = fopen(iname, "rb");
|
file = fopen(iname, "rb");
|
||||||
if (!file) {
|
if (!file) {
|
||||||
|
@ -120,7 +144,7 @@ int zvm_encode(char *iname, char *oname, int device)
|
||||||
}
|
}
|
||||||
|
|
||||||
len = fread(buf, 1, length, file);
|
len = fread(buf, 1, length, file);
|
||||||
if(len < length) {
|
if(len < (size_t)length) {
|
||||||
perror(iname);
|
perror(iname);
|
||||||
return -2;
|
return -2;
|
||||||
}
|
}
|
||||||
|
@ -147,7 +171,7 @@ int zvm_encode(char *iname, char *oname, int device)
|
||||||
}
|
}
|
||||||
|
|
||||||
len = fwrite(buf, 1, length, file);
|
len = fwrite(buf, 1, length, file);
|
||||||
if(len < length) {
|
if(len < (size_t)length) {
|
||||||
free(buf);
|
free(buf);
|
||||||
perror(oname);
|
perror(oname);
|
||||||
return -4;
|
return -4;
|
||||||
|
|
|
@ -28,26 +28,13 @@ enum
|
||||||
ZENV = 3
|
ZENV = 3
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct device_info
|
struct device_info
|
||||||
{
|
{
|
||||||
const char* cinf; /*Must be Unicode encoded*/
|
const char* cinf; /*Must be Unicode encoded*/
|
||||||
const int cinf_size;
|
const int cinf_size;
|
||||||
const char* null;
|
const char* null;
|
||||||
} device_info;
|
} device_info;
|
||||||
|
|
||||||
static const char null_key_v1[] = "CTL:N0MAD|PDE0.SIGN.";
|
|
||||||
static const char null_key_v2[] = "CTL:N0MAD|PDE0.DPMP.";
|
|
||||||
static const char null_key_v3[] = "CTL:Z3N07|PDE0.DPMP.";
|
|
||||||
static const char null_key_v4[] = "CTL:N0MAD|PDE0.DPFP.";
|
|
||||||
|
|
||||||
static const struct device_info devices[] =
|
|
||||||
{
|
|
||||||
{"C\0r\0e\0a\0t\0i\0v\0e\0 \0Z\0e\0n\0 \0V\0i\0s\0i\0o\0n\0:\0M", 42, null_key_v2},
|
|
||||||
{"C\0r\0e\0a\0t\0i\0v\0e\0 \0Z\0e\0n\0 \0V\0i\0s\0i\0o\0n\0:\0M\0 \0G\0o\0!", 50, null_key_v2},
|
|
||||||
{"C\0r\0e\0a\0t\0i\0v\0e\0 \0Z\0e\0n\0 \0V\0i\0s\0i\0o\0n\0 \0©\0T\0L", 48, null_key_v2},
|
|
||||||
{"C\0r\0e\0a\0t\0i\0v\0e\0 \0Z\0E\0N\0 \0V", 42, null_key_v4}
|
|
||||||
};
|
|
||||||
|
|
||||||
int zvm_encode(char *iname, char *oname, int device);
|
int zvm_encode(char *iname, char *oname, int device);
|
||||||
|
|
||||||
#endif /*CREATIVE_H_*/
|
#endif /*CREATIVE_H_*/
|
||||||
|
|
|
@ -273,8 +273,6 @@ int iriver_encode(char *infile_name, char *outfile_name, BOOL modify )
|
||||||
unsigned char * pChecksums, * ppChecksums;
|
unsigned char * pChecksums, * ppChecksums;
|
||||||
unsigned char ck;
|
unsigned char ck;
|
||||||
|
|
||||||
enum striptype stripmode = STRIP_NONE;
|
|
||||||
|
|
||||||
infile = openinfile(infile_name);
|
infile = openinfile(infile_name);
|
||||||
outfile = openoutfile(outfile_name);
|
outfile = openoutfile(outfile_name);
|
||||||
|
|
||||||
|
|
|
@ -41,7 +41,7 @@ enum
|
||||||
ARCHOS_ONDIO_FM
|
ARCHOS_ONDIO_FM
|
||||||
};
|
};
|
||||||
|
|
||||||
int size_limit[] =
|
static unsigned int size_limit[] =
|
||||||
{
|
{
|
||||||
0x32000, /* ARCHOS_PLAYER */
|
0x32000, /* ARCHOS_PLAYER */
|
||||||
0x64000, /* ARCHOS_V2RECORDER */
|
0x64000, /* ARCHOS_V2RECORDER */
|
||||||
|
@ -132,10 +132,10 @@ int main (int argc, char** argv)
|
||||||
unsigned char header[24];
|
unsigned char header[24];
|
||||||
char *iname = argv[1];
|
char *iname = argv[1];
|
||||||
char *oname = argv[2];
|
char *oname = argv[2];
|
||||||
char *xorstring;
|
char *xorstring=NULL;
|
||||||
int headerlen = 6;
|
int headerlen = 6;
|
||||||
FILE* file;
|
FILE* file;
|
||||||
int version;
|
int version=0;
|
||||||
unsigned long modelnum;
|
unsigned long modelnum;
|
||||||
char modelname[5];
|
char modelname[5];
|
||||||
int model_id;
|
int model_id;
|
||||||
|
@ -351,7 +351,6 @@ int main (int argc, char** argv)
|
||||||
}
|
}
|
||||||
else if(!strncmp(argv[1], "-mi4", 4)) {
|
else if(!strncmp(argv[1], "-mi4", 4)) {
|
||||||
int mi4magic;
|
int mi4magic;
|
||||||
int version;
|
|
||||||
char model[4] = "";
|
char model[4] = "";
|
||||||
char type[4] = "";
|
char type[4] = "";
|
||||||
|
|
||||||
|
@ -402,7 +401,7 @@ int main (int argc, char** argv)
|
||||||
|
|
||||||
if ((method == scramble) &&
|
if ((method == scramble) &&
|
||||||
((length + headerlen) >= size_limit[model_id])) {
|
((length + headerlen) >= size_limit[model_id])) {
|
||||||
printf("error: firmware image is %d bytes while max size is %d!\n",
|
printf("error: firmware image is %ld bytes while max size is %u!\n",
|
||||||
length + headerlen,
|
length + headerlen,
|
||||||
size_limit[model_id]);
|
size_limit[model_id]);
|
||||||
fclose(file);
|
fclose(file);
|
||||||
|
@ -462,6 +461,10 @@ int main (int argc, char** argv)
|
||||||
outbuf[slen++] = inbuf[i];
|
outbuf[slen++] = inbuf[i];
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case none:
|
||||||
|
default:
|
||||||
|
/* dummy case just to silence picky compilers */
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if((method == none) || (method == scramble) || (method == xor)) {
|
if((method == none) || (method == scramble) || (method == xor)) {
|
||||||
|
@ -598,7 +601,7 @@ int iaudio_encode(char *iname, char *oname, char *idstring)
|
||||||
}
|
}
|
||||||
|
|
||||||
len = fread(outbuf+0x1030, 1, length, file);
|
len = fread(outbuf+0x1030, 1, length, file);
|
||||||
if(len < length) {
|
if(len < (size_t) length) {
|
||||||
perror(iname);
|
perror(iname);
|
||||||
return -2;
|
return -2;
|
||||||
}
|
}
|
||||||
|
@ -626,12 +629,13 @@ int iaudio_encode(char *iname, char *oname, char *idstring)
|
||||||
}
|
}
|
||||||
|
|
||||||
len = fwrite(outbuf, 1, length+0x1030, file);
|
len = fwrite(outbuf, 1, length+0x1030, file);
|
||||||
if(len < length) {
|
if(len < (size_t)length) {
|
||||||
perror(oname);
|
perror(oname);
|
||||||
return -4;
|
return -4;
|
||||||
}
|
}
|
||||||
|
|
||||||
fclose(file);
|
fclose(file);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -697,7 +701,7 @@ int ipod_encode(char *iname, char *oname, int fw_ver, bool fake_rsrc)
|
||||||
}
|
}
|
||||||
|
|
||||||
len = fread(outbuf+0x4600, 1, length, file);
|
len = fread(outbuf+0x4600, 1, length, file);
|
||||||
if(len < length) {
|
if(len < (size_t)length) {
|
||||||
perror(iname);
|
perror(iname);
|
||||||
return -2;
|
return -2;
|
||||||
}
|
}
|
||||||
|
@ -754,7 +758,7 @@ int ipod_encode(char *iname, char *oname, int fw_ver, bool fake_rsrc)
|
||||||
}
|
}
|
||||||
|
|
||||||
len = fwrite(outbuf, 1, length+0x4600, file);
|
len = fwrite(outbuf, 1, length+0x4600, file);
|
||||||
if(len < length) {
|
if(len < (size_t)length) {
|
||||||
perror(oname);
|
perror(oname);
|
||||||
return -4;
|
return -4;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue