Added a simple delta filter.
committer: mfx <mfx> 978979757 +0000
This commit is contained in:
@@ -1,151 +0,0 @@
|
|||||||
/* sub.h -- simple delta filter
|
|
||||||
|
|
||||||
This file is part of the UPX executable compressor.
|
|
||||||
|
|
||||||
Copyright (C) 1996-2001 Markus Franz Xaver Johannes Oberhumer
|
|
||||||
Copyright (C) 1996-2001 Laszlo Molnar
|
|
||||||
All Rights Reserved.
|
|
||||||
|
|
||||||
UPX and the UCL library are free software; you can redistribute them
|
|
||||||
and/or modify them under the terms of the GNU General Public License as
|
|
||||||
published by the Free Software Foundation; either version 2 of
|
|
||||||
the License, or (at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with this program; see the file COPYING.
|
|
||||||
If not, write to the Free Software Foundation, Inc.,
|
|
||||||
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
||||||
|
|
||||||
Markus F.X.J. Oberhumer Laszlo Molnar
|
|
||||||
markus@oberhumer.com ml1050@cdata.tvnet.hu
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*************************************************************************
|
|
||||||
//
|
|
||||||
**************************************************************************/
|
|
||||||
|
|
||||||
#define SUB(f, N) \
|
|
||||||
upx_byte *b = f->buf; \
|
|
||||||
unsigned l = f->buf_len; \
|
|
||||||
int i; \
|
|
||||||
unsigned char d[N]; \
|
|
||||||
\
|
|
||||||
i = N - 1; do d[i] = 0; while (--i >= 0); \
|
|
||||||
\
|
|
||||||
i = N - 1; \
|
|
||||||
do { \
|
|
||||||
*b -= d[i]; \
|
|
||||||
d[i] += *b++; \
|
|
||||||
if (--i < 0) \
|
|
||||||
i = N - 1; \
|
|
||||||
} while (--l > 0); \
|
|
||||||
f->calls = f->buf_len - 1; \
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
|
|
||||||
#define ADD(f, N) \
|
|
||||||
upx_byte *b = f->buf; \
|
|
||||||
unsigned l = f->buf_len; \
|
|
||||||
int i; \
|
|
||||||
unsigned char d[N]; \
|
|
||||||
\
|
|
||||||
i = N - 1; do d[i] = 0; while (--i >= 0); \
|
|
||||||
\
|
|
||||||
i = N - 1; \
|
|
||||||
do { \
|
|
||||||
d[i] += *b; \
|
|
||||||
*b++ = d[i]; \
|
|
||||||
if (--i < 0) \
|
|
||||||
i = N - 1; \
|
|
||||||
} while (--l > 0); \
|
|
||||||
f->calls = f->buf_len - 1; \
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
|
|
||||||
#define SCAN(f, N) \
|
|
||||||
f->calls = f->buf_len - 1; \
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
|
|
||||||
// filter
|
|
||||||
static int f_sub1(Filter *f)
|
|
||||||
{
|
|
||||||
SUB(f, 1)
|
|
||||||
}
|
|
||||||
|
|
||||||
static int f_sub2(Filter *f)
|
|
||||||
{
|
|
||||||
SUB(f, 2)
|
|
||||||
}
|
|
||||||
|
|
||||||
static int f_sub3(Filter *f)
|
|
||||||
{
|
|
||||||
SUB(f, 3)
|
|
||||||
}
|
|
||||||
|
|
||||||
static int f_sub4(Filter *f)
|
|
||||||
{
|
|
||||||
SUB(f, 4)
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// unfilter
|
|
||||||
static int u_sub1(Filter *f)
|
|
||||||
{
|
|
||||||
ADD(f, 1)
|
|
||||||
}
|
|
||||||
|
|
||||||
static int u_sub2(Filter *f)
|
|
||||||
{
|
|
||||||
ADD(f, 2)
|
|
||||||
}
|
|
||||||
|
|
||||||
static int u_sub3(Filter *f)
|
|
||||||
{
|
|
||||||
ADD(f, 3)
|
|
||||||
}
|
|
||||||
|
|
||||||
static int u_sub4(Filter *f)
|
|
||||||
{
|
|
||||||
ADD(f, 4)
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// scan
|
|
||||||
static int s_sub1(Filter *f)
|
|
||||||
{
|
|
||||||
SCAN(f, 1)
|
|
||||||
}
|
|
||||||
|
|
||||||
static int s_sub2(Filter *f)
|
|
||||||
{
|
|
||||||
SCAN(f, 2)
|
|
||||||
}
|
|
||||||
|
|
||||||
static int s_sub3(Filter *f)
|
|
||||||
{
|
|
||||||
SCAN(f, 3)
|
|
||||||
}
|
|
||||||
|
|
||||||
static int s_sub4(Filter *f)
|
|
||||||
{
|
|
||||||
SCAN(f, 4)
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#undef SUB
|
|
||||||
#undef ADD
|
|
||||||
#undef SCAN
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
vi:ts=4:et:nowrap
|
|
||||||
*/
|
|
||||||
|
|
||||||
@@ -0,0 +1,122 @@
|
|||||||
|
/* sub16.h -- simple delta filter
|
||||||
|
|
||||||
|
This file is part of the UPX executable compressor.
|
||||||
|
|
||||||
|
Copyright (C) 1996-2001 Markus Franz Xaver Johannes Oberhumer
|
||||||
|
Copyright (C) 1996-2001 Laszlo Molnar
|
||||||
|
All Rights Reserved.
|
||||||
|
|
||||||
|
UPX and the UCL library are free software; you can redistribute them
|
||||||
|
and/or modify them under the terms of the GNU General Public License as
|
||||||
|
published by the Free Software Foundation; either version 2 of
|
||||||
|
the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; see the file COPYING.
|
||||||
|
If not, write to the Free Software Foundation, Inc.,
|
||||||
|
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
|
Markus F.X.J. Oberhumer Laszlo Molnar
|
||||||
|
markus@oberhumer.com ml1050@cdata.tvnet.hu
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*************************************************************************
|
||||||
|
//
|
||||||
|
**************************************************************************/
|
||||||
|
|
||||||
|
#include "filter/sub.hh"
|
||||||
|
|
||||||
|
#define SUB16(f, N) SUB(f, N, unsigned short, get_le16, set_le16)
|
||||||
|
#define ADD16(f, N) ADD(f, N, unsigned short, get_le16, set_le16)
|
||||||
|
#define SCAN16(f, N) SCAN(f, N, unsigned short, get_le16, set_le16)
|
||||||
|
|
||||||
|
|
||||||
|
/*************************************************************************
|
||||||
|
//
|
||||||
|
**************************************************************************/
|
||||||
|
|
||||||
|
// filter
|
||||||
|
static int f_sub16_1(Filter *f)
|
||||||
|
{
|
||||||
|
SUB16(f, 1)
|
||||||
|
}
|
||||||
|
|
||||||
|
static int f_sub16_2(Filter *f)
|
||||||
|
{
|
||||||
|
SUB16(f, 2)
|
||||||
|
}
|
||||||
|
|
||||||
|
static int f_sub16_3(Filter *f)
|
||||||
|
{
|
||||||
|
SUB16(f, 3)
|
||||||
|
}
|
||||||
|
|
||||||
|
static int f_sub16_4(Filter *f)
|
||||||
|
{
|
||||||
|
SUB16(f, 4)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// unfilter
|
||||||
|
static int u_sub16_1(Filter *f)
|
||||||
|
{
|
||||||
|
ADD16(f, 1)
|
||||||
|
}
|
||||||
|
|
||||||
|
static int u_sub16_2(Filter *f)
|
||||||
|
{
|
||||||
|
ADD16(f, 2)
|
||||||
|
}
|
||||||
|
|
||||||
|
static int u_sub16_3(Filter *f)
|
||||||
|
{
|
||||||
|
ADD16(f, 3)
|
||||||
|
}
|
||||||
|
|
||||||
|
static int u_sub16_4(Filter *f)
|
||||||
|
{
|
||||||
|
ADD16(f, 4)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// scan
|
||||||
|
static int s_sub16_1(Filter *f)
|
||||||
|
{
|
||||||
|
SCAN16(f, 1)
|
||||||
|
}
|
||||||
|
|
||||||
|
static int s_sub16_2(Filter *f)
|
||||||
|
{
|
||||||
|
SCAN16(f, 2)
|
||||||
|
}
|
||||||
|
|
||||||
|
static int s_sub16_3(Filter *f)
|
||||||
|
{
|
||||||
|
SCAN16(f, 3)
|
||||||
|
}
|
||||||
|
|
||||||
|
static int s_sub16_4(Filter *f)
|
||||||
|
{
|
||||||
|
SCAN16(f, 4)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#undef SUB
|
||||||
|
#undef ADD
|
||||||
|
#undef SCAN
|
||||||
|
#undef SUB16
|
||||||
|
#undef ADD16
|
||||||
|
#undef SCAN16
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
vi:ts=4:et:nowrap
|
||||||
|
*/
|
||||||
|
|
||||||
@@ -0,0 +1,122 @@
|
|||||||
|
/* sub32.h -- simple delta filter
|
||||||
|
|
||||||
|
This file is part of the UPX executable compressor.
|
||||||
|
|
||||||
|
Copyright (C) 1996-2001 Markus Franz Xaver Johannes Oberhumer
|
||||||
|
Copyright (C) 1996-2001 Laszlo Molnar
|
||||||
|
All Rights Reserved.
|
||||||
|
|
||||||
|
UPX and the UCL library are free software; you can redistribute them
|
||||||
|
and/or modify them under the terms of the GNU General Public License as
|
||||||
|
published by the Free Software Foundation; either version 2 of
|
||||||
|
the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; see the file COPYING.
|
||||||
|
If not, write to the Free Software Foundation, Inc.,
|
||||||
|
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
|
Markus F.X.J. Oberhumer Laszlo Molnar
|
||||||
|
markus@oberhumer.com ml1050@cdata.tvnet.hu
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*************************************************************************
|
||||||
|
//
|
||||||
|
**************************************************************************/
|
||||||
|
|
||||||
|
#include "filter/sub.hh"
|
||||||
|
|
||||||
|
#define SUB32(f, N) SUB(f, N, unsigned int, get_le32, set_le32)
|
||||||
|
#define ADD32(f, N) ADD(f, N, unsigned int, get_le32, set_le32)
|
||||||
|
#define SCAN32(f, N) SCAN(f, N, unsigned int, get_le32, set_le32)
|
||||||
|
|
||||||
|
|
||||||
|
/*************************************************************************
|
||||||
|
//
|
||||||
|
**************************************************************************/
|
||||||
|
|
||||||
|
// filter
|
||||||
|
static int f_sub32_1(Filter *f)
|
||||||
|
{
|
||||||
|
SUB32(f, 1)
|
||||||
|
}
|
||||||
|
|
||||||
|
static int f_sub32_2(Filter *f)
|
||||||
|
{
|
||||||
|
SUB32(f, 2)
|
||||||
|
}
|
||||||
|
|
||||||
|
static int f_sub32_3(Filter *f)
|
||||||
|
{
|
||||||
|
SUB32(f, 3)
|
||||||
|
}
|
||||||
|
|
||||||
|
static int f_sub32_4(Filter *f)
|
||||||
|
{
|
||||||
|
SUB32(f, 4)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// unfilter
|
||||||
|
static int u_sub32_1(Filter *f)
|
||||||
|
{
|
||||||
|
ADD32(f, 1)
|
||||||
|
}
|
||||||
|
|
||||||
|
static int u_sub32_2(Filter *f)
|
||||||
|
{
|
||||||
|
ADD32(f, 2)
|
||||||
|
}
|
||||||
|
|
||||||
|
static int u_sub32_3(Filter *f)
|
||||||
|
{
|
||||||
|
ADD32(f, 3)
|
||||||
|
}
|
||||||
|
|
||||||
|
static int u_sub32_4(Filter *f)
|
||||||
|
{
|
||||||
|
ADD32(f, 4)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// scan
|
||||||
|
static int s_sub32_1(Filter *f)
|
||||||
|
{
|
||||||
|
SCAN32(f, 1)
|
||||||
|
}
|
||||||
|
|
||||||
|
static int s_sub32_2(Filter *f)
|
||||||
|
{
|
||||||
|
SCAN32(f, 2)
|
||||||
|
}
|
||||||
|
|
||||||
|
static int s_sub32_3(Filter *f)
|
||||||
|
{
|
||||||
|
SCAN32(f, 3)
|
||||||
|
}
|
||||||
|
|
||||||
|
static int s_sub32_4(Filter *f)
|
||||||
|
{
|
||||||
|
SCAN32(f, 4)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#undef SUB
|
||||||
|
#undef ADD
|
||||||
|
#undef SCAN
|
||||||
|
#undef SUB32
|
||||||
|
#undef ADD32
|
||||||
|
#undef SCAN32
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
vi:ts=4:et:nowrap
|
||||||
|
*/
|
||||||
|
|
||||||
@@ -0,0 +1,122 @@
|
|||||||
|
/* sub8.h -- simple delta filter
|
||||||
|
|
||||||
|
This file is part of the UPX executable compressor.
|
||||||
|
|
||||||
|
Copyright (C) 1996-2001 Markus Franz Xaver Johannes Oberhumer
|
||||||
|
Copyright (C) 1996-2001 Laszlo Molnar
|
||||||
|
All Rights Reserved.
|
||||||
|
|
||||||
|
UPX and the UCL library are free software; you can redistribute them
|
||||||
|
and/or modify them under the terms of the GNU General Public License as
|
||||||
|
published by the Free Software Foundation; either version 2 of
|
||||||
|
the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; see the file COPYING.
|
||||||
|
If not, write to the Free Software Foundation, Inc.,
|
||||||
|
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
|
Markus F.X.J. Oberhumer Laszlo Molnar
|
||||||
|
markus@oberhumer.com ml1050@cdata.tvnet.hu
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*************************************************************************
|
||||||
|
//
|
||||||
|
**************************************************************************/
|
||||||
|
|
||||||
|
#include "filter/sub.hh"
|
||||||
|
|
||||||
|
#define SUB8(f, N) SUB(f, N, unsigned char, get_8, set_8)
|
||||||
|
#define ADD8(f, N) ADD(f, N, unsigned char, get_8, set_8)
|
||||||
|
#define SCAN8(f, N) SCAN(f, N, unsigned char, get_8, set_8)
|
||||||
|
|
||||||
|
|
||||||
|
/*************************************************************************
|
||||||
|
//
|
||||||
|
**************************************************************************/
|
||||||
|
|
||||||
|
// filter
|
||||||
|
static int f_sub8_1(Filter *f)
|
||||||
|
{
|
||||||
|
SUB8(f, 1)
|
||||||
|
}
|
||||||
|
|
||||||
|
static int f_sub8_2(Filter *f)
|
||||||
|
{
|
||||||
|
SUB8(f, 2)
|
||||||
|
}
|
||||||
|
|
||||||
|
static int f_sub8_3(Filter *f)
|
||||||
|
{
|
||||||
|
SUB8(f, 3)
|
||||||
|
}
|
||||||
|
|
||||||
|
static int f_sub8_4(Filter *f)
|
||||||
|
{
|
||||||
|
SUB8(f, 4)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// unfilter
|
||||||
|
static int u_sub8_1(Filter *f)
|
||||||
|
{
|
||||||
|
ADD8(f, 1)
|
||||||
|
}
|
||||||
|
|
||||||
|
static int u_sub8_2(Filter *f)
|
||||||
|
{
|
||||||
|
ADD8(f, 2)
|
||||||
|
}
|
||||||
|
|
||||||
|
static int u_sub8_3(Filter *f)
|
||||||
|
{
|
||||||
|
ADD8(f, 3)
|
||||||
|
}
|
||||||
|
|
||||||
|
static int u_sub8_4(Filter *f)
|
||||||
|
{
|
||||||
|
ADD8(f, 4)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// scan
|
||||||
|
static int s_sub8_1(Filter *f)
|
||||||
|
{
|
||||||
|
SCAN8(f, 1)
|
||||||
|
}
|
||||||
|
|
||||||
|
static int s_sub8_2(Filter *f)
|
||||||
|
{
|
||||||
|
SCAN8(f, 2)
|
||||||
|
}
|
||||||
|
|
||||||
|
static int s_sub8_3(Filter *f)
|
||||||
|
{
|
||||||
|
SCAN8(f, 3)
|
||||||
|
}
|
||||||
|
|
||||||
|
static int s_sub8_4(Filter *f)
|
||||||
|
{
|
||||||
|
SCAN8(f, 4)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#undef SUB
|
||||||
|
#undef ADD
|
||||||
|
#undef SCAN
|
||||||
|
#undef SUB8
|
||||||
|
#undef ADD8
|
||||||
|
#undef SCAN8
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
vi:ts=4:et:nowrap
|
||||||
|
*/
|
||||||
|
|
||||||
+20
-5
@@ -31,6 +31,8 @@
|
|||||||
|
|
||||||
|
|
||||||
#define set_dummy(p, v) ((void)0)
|
#define set_dummy(p, v) ((void)0)
|
||||||
|
#define get_8(p) (*(p))
|
||||||
|
#define set_8(p, v) (*(p) = (v))
|
||||||
|
|
||||||
|
|
||||||
/*************************************************************************
|
/*************************************************************************
|
||||||
@@ -47,7 +49,10 @@
|
|||||||
#include "filter/ct.h"
|
#include "filter/ct.h"
|
||||||
#include "filter/sw.h"
|
#include "filter/sw.h"
|
||||||
#include "filter/ctsw.h"
|
#include "filter/ctsw.h"
|
||||||
#include "filter/sub.h"
|
|
||||||
|
#include "filter/sub8.h"
|
||||||
|
#include "filter/sub16.h"
|
||||||
|
#include "filter/sub32.h"
|
||||||
|
|
||||||
|
|
||||||
/*************************************************************************
|
/*************************************************************************
|
||||||
@@ -177,10 +182,20 @@ const FilterImp::FilterEntry FilterImp::filters[] = {
|
|||||||
{ 0x80, 8, 0x00ffffff, f_ctojr32_e8e9_bswap_le, u_ctojr32_e8e9_bswap_le, s_ctojr32_e8e9_bswap_le },
|
{ 0x80, 8, 0x00ffffff, f_ctojr32_e8e9_bswap_le, u_ctojr32_e8e9_bswap_le, s_ctojr32_e8e9_bswap_le },
|
||||||
|
|
||||||
// simple delta filter
|
// simple delta filter
|
||||||
{ 0x90, 2, 0, f_sub1, u_sub1, s_sub1 },
|
{ 0x90, 2, 0, f_sub8_1, u_sub8_1, s_sub8_1 },
|
||||||
{ 0x91, 3, 0, f_sub2, u_sub2, s_sub2 },
|
{ 0x91, 3, 0, f_sub8_2, u_sub8_2, s_sub8_2 },
|
||||||
{ 0x92, 4, 0, f_sub3, u_sub3, s_sub3 },
|
{ 0x92, 4, 0, f_sub8_3, u_sub8_3, s_sub8_3 },
|
||||||
{ 0x93, 5, 0, f_sub4, u_sub4, s_sub4 },
|
{ 0x93, 5, 0, f_sub8_4, u_sub8_4, s_sub8_4 },
|
||||||
|
|
||||||
|
{ 0xa0,99, 0, f_sub16_1, u_sub16_1, s_sub16_1 },
|
||||||
|
{ 0xa1,99, 0, f_sub16_2, u_sub16_2, s_sub16_2 },
|
||||||
|
{ 0xa2,99, 0, f_sub16_3, u_sub16_3, s_sub16_3 },
|
||||||
|
{ 0xa3,99, 0, f_sub16_4, u_sub16_4, s_sub16_4 },
|
||||||
|
|
||||||
|
{ 0xb0,99, 0, f_sub32_1, u_sub32_1, s_sub32_1 },
|
||||||
|
{ 0xb1,99, 0, f_sub32_2, u_sub32_2, s_sub32_2 },
|
||||||
|
{ 0xb2,99, 0, f_sub32_3, u_sub32_3, s_sub32_3 },
|
||||||
|
{ 0xb3,99, 0, f_sub32_4, u_sub32_4, s_sub32_4 },
|
||||||
};
|
};
|
||||||
|
|
||||||
const int FilterImp::n_filters = HIGH(filters);
|
const int FilterImp::n_filters = HIGH(filters);
|
||||||
|
|||||||
Reference in New Issue
Block a user