870c58619d
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@19666 a1c6a512-1295-4272-9138-f99709370657
143 lines
7.7 KiB
C
143 lines
7.7 KiB
C
#include <stdio.h>
|
|
#include <string.h>
|
|
#include <stdlib.h>
|
|
|
|
#define NK_SIZE 12965335
|
|
#define READ_SIZE 1024
|
|
|
|
FILE *in, *out;
|
|
|
|
int bytes_read, bytes_writen, ret;
|
|
|
|
char header[]={0x42, 0x30, 0x30, 0x30, 0x46, 0x46, 0x0A, 0x00, 0x00, 0x20, 0x88, 0x84, 0x3C, 0xCD, 0x00, 0x00,
|
|
0x00, 0x20, 0x88, 0x04, 0x00, 0x00, 0x00, 0xEB, 0x01, 0x00, 0x00, 0xFE, 0x03, 0x00, 0xEA, 0x40,
|
|
0x00, 0x20, 0x88, 0x08, 0x00, 0x00, 0x00, 0xC7, 0x02, 0x00, 0x00, 0x45, 0x43, 0x45, 0x43, 0x20,
|
|
0x22, 0xED, 0x88, 0x48, 0x00, 0x20, 0x88, 0x04, 0x00, 0x00, 0x00, 0x0F, 0x01, 0x00, 0x00, 0x20,
|
|
0x22, 0xCD, 0x00, 0x00, 0x10, 0x20, 0x88, 0xDC, 0x73, 0x04, 0x00, 0x70, 0xAE, 0xC4, 0x01, 0x00,
|
|
0x00, 0x0F, 0xE1, 0x13, 0x00, 0xA0, 0xE3, 0x80, 0x00, 0x80, 0xE3, 0x40, 0x00, 0x80, 0xE3, 0x00,
|
|
0xF0, 0x23, 0xE1, 0x30, 0x0F, 0x11, 0xEE, 0x02, 0x01, 0x80, 0xE3, 0x30, 0x0F, 0x01, 0xEE, 0x10,
|
|
0x0F, 0x11, 0xEE, 0x01, 0x0A, 0xC0, 0xE3, 0x04, 0x00, 0xC0, 0xE3, 0x01, 0x00, 0xC0, 0xE3, 0x02,
|
|
0x0A, 0xC0, 0xE3, 0x02, 0x06, 0x80, 0xE3, 0x10, 0x0F, 0x01, 0xEE, 0x55, 0x01, 0xA0, 0xE3, 0x92,
|
|
0x0F, 0x0F, 0xEE, 0x03, 0x12, 0xA0, 0xE3, 0x00, 0x00, 0xA0, 0xE3, 0x00, 0x01, 0x81, 0xE5, 0x0F,
|
|
0x06, 0xA0, 0xE3, 0x50, 0x0F, 0x01, 0xEE, 0x1C, 0x1B, 0x9F, 0xE5, 0x1C, 0x2B, 0x9F, 0xE5, 0x00,
|
|
0x00, 0xA0, 0xE3, 0x24, 0x00, 0x81, 0xE5, 0x28, 0x00, 0x81, 0xE5, 0x2C, 0x00, 0x81, 0xE5, 0x40,
|
|
0x00, 0x81, 0xE5, 0x44, 0x00, 0x81, 0xE5, 0x48, 0x00, 0x81, 0xE5, 0x4C, 0x00, 0x81, 0xE5, 0x50,
|
|
0x00, 0x81, 0xE5, 0x24, 0x00, 0x82, 0xE5, 0x28, 0x00, 0x82, 0xE5, 0x2C, 0x00, 0x82, 0xE5, 0x40,
|
|
0x00, 0x82, 0xE5, 0x44, 0x00, 0x82, 0xE5, 0x48, 0x00, 0x82, 0xE5, 0x4C, 0x00, 0x82, 0xE5, 0x50,
|
|
0x00, 0x82, 0xE5, 0x01, 0x01, 0x80, 0xE3, 0x20, 0x00, 0x81, 0xE5, 0x20, 0x00, 0x82, 0xE5, 0xCC,
|
|
0x0A, 0x9F, 0xE5, 0x00, 0x00, 0x81, 0xE5, 0x04, 0x00, 0x81, 0xE5, 0x00, 0x00, 0x82, 0xE5, 0x04,
|
|
0x00, 0x82, 0xE5, 0xBC, 0x1A, 0x9F, 0xE5, 0xBC, 0x0A, 0x9F, 0xE5, 0x00, 0x00, 0x81, 0xE5, 0x00,
|
|
0x01, 0x81, 0xE5, 0x00, 0x02, 0x81, 0xE5, 0x00, 0x03, 0x81, 0xE5, 0x00, 0x04, 0x81, 0xE5, 0x10,
|
|
0x00, 0xA0, 0xE3, 0x10, 0x00, 0x81, 0xE5, 0x10, 0x01, 0x81, 0xE5, 0x10, 0x02, 0x81, 0xE5, 0x10,
|
|
0x03, 0x81, 0xE5, 0x10, 0x04, 0x81, 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0x9F, 0xE5, 0x70,
|
|
0x00, 0x81, 0xE5, 0x08, 0x09, 0x9F, 0xE5, 0x74, 0x00, 0x81, 0xE5, 0x04, 0x09, 0x9F, 0xE5, 0x78,
|
|
0x00, 0x81, 0xE5, 0x00, 0x09, 0x9F, 0xE5, 0x7C, 0x00, 0x81, 0xE5, 0xFC, 0x08, 0x9F, 0xE5, 0x80,
|
|
0x00, 0x81, 0xE5, 0xF8, 0x08, 0x9F, 0xE5, 0x84, 0x00, 0x81, 0xE5, 0x12, 0x00, 0xA0, 0xE3, 0x88,
|
|
0x00, 0x81, 0xE5, 0x00, 0x00, 0xA0, 0xE3, 0x8C, 0x00, 0x81, 0xE5, 0xB0, 0x08, 0x9F, 0xE5, 0x90,
|
|
0x00, 0x81, 0xE5, 0xDC, 0x08, 0x9F, 0xE5, 0x94, 0x00, 0x81, 0xE5, 0xAC, 0x08, 0x9F, 0xE5, 0x98,
|
|
0x00, 0x81, 0xE5, 0xA4, 0x08, 0x9F, 0xE5, 0x9C, 0x00, 0x81, 0xE5, 0xC8, 0x08, 0x9F, 0xE5, 0xA0,
|
|
0x00, 0x81, 0xE5, 0x88, 0x08, 0x9F, 0xE5, 0xA4, 0x00, 0x81, 0xE5, 0x80, 0x08, 0x9F, 0xE5, 0xA8,
|
|
0x00, 0x81, 0xE5, 0x78, 0x08, 0x9F, 0xE5, 0xAC, 0x00, 0x81, 0xE5, 0xAC, 0x08, 0x9F, 0xE5, 0xB0,
|
|
0x00, 0x81, 0xE5, 0xA8, 0x08, 0x9F, 0xE5, 0xB4, 0x00, 0x81, 0xE5, 0xA4, 0x08, 0x9F, 0xE5, 0xB8,
|
|
0x00, 0x81, 0xE5, 0x12, 0x04, 0xA0, 0xE3, 0xBC, 0x00, 0x81, 0xE5, 0x5C, 0x08, 0x9F, 0xE5, 0xC0
|
|
};
|
|
|
|
|
|
|
|
char buf2[NK_SIZE];
|
|
char buf[READ_SIZE];
|
|
|
|
void usage(void)
|
|
{
|
|
fprintf(stderr, "usage: sudo beastdump <path_to_gigabeat>\ne.g. /dev/sdb \n");
|
|
}
|
|
|
|
/*search through an image looking for header_string*/
|
|
int main(int argc, char **argv)
|
|
{
|
|
if (argc < 2)
|
|
{
|
|
usage();
|
|
return 1;
|
|
}
|
|
|
|
|
|
if((in=fopen(argv[1], "r"))==NULL){
|
|
printf("file open error. Probably invalid path or lack of root/sudo\n");
|
|
return -1;
|
|
}
|
|
|
|
|
|
|
|
while((ret=fread(buf, READ_SIZE, 1, in))){
|
|
|
|
|
|
|
|
if(!memcmp(header, buf, READ_SIZE)){
|
|
printf("Found header at offset: 0x%x\n",(int) (ftell(in)-READ_SIZE));
|
|
break;
|
|
}
|
|
else
|
|
{
|
|
// printf("fail\n");
|
|
|
|
//return -1;
|
|
}
|
|
memset(buf,0,READ_SIZE);
|
|
|
|
if(ftell(in)%(READ_SIZE*1000)==0)
|
|
printf("checking %d\n",(int)ftell(in));
|
|
|
|
}
|
|
|
|
|
|
if(!ret) {
|
|
printf("read error or end of file\n");
|
|
return -1;
|
|
}
|
|
fseek(in, -READ_SIZE, SEEK_CUR);
|
|
|
|
out= fopen("nk.bin", "w");
|
|
bytes_read = fread(buf2, sizeof(buf2), 1, in);
|
|
bytes_writen= fwrite(buf2, sizeof(buf2),1,out);
|
|
fclose(in);
|
|
fclose(out);
|
|
printf("Successfully created file. Please run md5sum to confirm hash:\nfb76b0025cd6bd2cc7512620ebf30b81 nk_orig.bin\n");
|
|
return 0;
|
|
|
|
}
|
|
|
|
|