Skip to content
This repository has been archived by the owner on Oct 15, 2024. It is now read-only.

Commit

Permalink
arm transform
Browse files Browse the repository at this point in the history
fix detection
enable arm,dec in main conf
  • Loading branch information
kaitz committed Jan 12, 2020
1 parent fe66d53 commit 93b567c
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 5 deletions.
32 changes: 32 additions & 0 deletions arm.dec
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// ARM call transform - decode
enum {BLOCK=0x10000};
char blk[BLOCK]={};
int min(int a, int b) {return a<b?a:b;}

int decode(int info,int len) {
int offset, i,j,op;
int size,bytesRead;
size=0;
for ( j=0; j<len; j=j+BLOCK) {
size=min((len-j), BLOCK);
bytesRead=read(blk, size);
if (bytesRead!=size) exit(-1);// read error
for ( i=0; i<bytesRead-3; i=i+4) {
op=blk[i]|(blk[i+1]<<8)|(blk[i+2]<<16)|(blk[i+3]<<24);
if ((op>>26)==0x25 ) {
offset=op&0x3FFFFFF;
offset=offset-(i/4);
op=op&(~0x3FFFFFF);
op=op|(offset&0x3FFFFFF);
}
blk[i]=op;
blk[i+1]=op>>8;
blk[i+2]=op>>16;
blk[i+3]=op>>24;
}
write(blk,bytesRead);
}
return len;
}
int main() {
}
2 changes: 1 addition & 1 deletion arm.det
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ int detect(int c4,int i) {
if (type==DEFAULT && ARMcount>=18 && ARMpos>16){
type=ARM;
state=START;
jstart=ARMpos-5;
jstart=ARMpos-(ARMpos%4);
//printf("DETECT: ARM start %d\n",jstart);
return state;
}
Expand Down
32 changes: 32 additions & 0 deletions arm.enc
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// ARM call transform - encode
enum {BLOCK=0x10000};
char blk[BLOCK]={};
int min(int a, int b) {return a<b?a:b;}

int encode(int info,int len) {
int offset,size,bytesRead;
int i,op,j;
// Transform
for (j=0; j<len; j=j+BLOCK) {
size=min((len-j), BLOCK);
bytesRead=read(blk, size);
if (bytesRead!=size) exit(-1);
for (i=0; i<bytesRead-3; i=i+4) {
op=blk[i]|(blk[i+1]<<8)|(blk[i+2]<<16)|(blk[i+3]<<24);//op=blk[i+3]|(blk[i+2]<<8)|(blk[i+1]<<16)|(blk[i]<<24);
if ((op>>26)==0x25) {
offset=op&0x3FFFFFF;
offset=offset+(i/4);
op=op&(~0x3FFFFFF);
op=op|(offset&0x3FFFFFF);
}
blk[i]=op;
blk[i+1]=op>>8;
blk[i+2]=op>>16;
blk[i+3]=op>>24;
}
write(blk,bytesRead);
}
}

int main() {
}
8 changes: 4 additions & 4 deletions conf.pxv
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ encode text.enc
compress 0
type 8
detect dec.det
decode -1 //dec.dec
encode -1 //dec.enc
decode dec.dec
encode dec.enc
compress 0
type 9
detect gif.det
Expand All @@ -77,6 +77,6 @@ encode -1
compress 0
type 10
detect arm.det
decode -1 //arm.dec
encode -1 //arm.enc
decode arm.dec
encode arm.enc
compress 0

0 comments on commit 93b567c

Please sign in to comment.