Rockbox mail archive
Subject: RE: descramble
From: Andy Choi (AndyC_at_CoManage.net)
Date: 2001-12-10
> Hi as anyone try to descramble the .mod and modify some stuff like :
> Jukebox MP3
> ( C3C0H )
> or
> BìVer : 5.03a
> ( 5D40H )
Yes, i can do that, using the checksum approach described in the previous
email (sum of all unscrambed bytes, plus a version-specific offset). I can
change any of the string constants, or even tack new string constants to the
end of the file (and modify the load addresses appropriately).
> Then rescramble it to see if there is checksum control ????
There's definitely checksum control. If the checksum's wrong, the code
won't get loaded. A previous poster pointed out that the checksum offset i
mentioned must be somewhere in the code, since it's version-dependent. (I
don't think it's size-dependent, since i can add junk to the end of the
file.) But it's not obvious where in the code it is.
FWIW, here's java code that scrambles and computes the checksum for version
5.03a:
------------
import java.io.*;
public class Scramble
{
public static void main(String[] args)
throws Exception
{
if (args.length != 2) {
System.out.println("usage: Scramble <input file> <output
file>");
System.exit(1);
}
// open input file
String inFname = args[0];
File inFile = new File(inFname);
FileInputStream in = new FileInputStream(inFile);
// read input
int len = (int) inFile.length();
byte[] inbuf = new byte[len];
in.read(inbuf, 0, len);
// compute checksum
int cksum = 0;
for (int i = 0; i < len; i++) {
cksum = cksum + inbuf[i];
}
// scramble
byte[] outbuf = new byte[len];
int slen = len/4;
for (int i = 0; i < len; i++) {
int addr = (i % 4) * slen + (i / 4);
byte data = inbuf[i];
data = (byte) ~(((data >> 7) & 0x01) | (data << 1));
outbuf[addr] = data;
}
// open output file
String outFname = args[1];
File outFile = new File(outFname);
FileOutputStream out = new FileOutputStream(outFile);
// write header length field
byte[] lenBytes = { (byte) (len >> 24),
(byte) (len >> 16),
(byte) (len >> 8),
(byte) len };
out.write(lenBytes);
// write header checksum field
byte[] cksumBytes = { (byte) ((cksum >>> 8) - 0x2b), (byte) cksum };
out.write(cksumBytes);
// note: offset 0x2b is for version 5.03a.
// 5.01h uses 0x90. 5.02a uses 0x72.
// write contents
out.write(outbuf);
// close files
in.close();
out.close();
}
}
Page was last modified "Jan 10 2012" The Rockbox Crew
|