From 5b2f1b6d8b7b491e304fc2708e0a2f924538feba Mon Sep 17 00:00:00 2001 From: "Markus F.X.J. Oberhumer" Date: Mon, 13 Feb 2006 10:22:43 +0000 Subject: [PATCH] Introduced UPX_VERSION_YEAR. committer: mfx 1139826163 +0000 --- src/main.cpp | 3 +++ src/p_tos.cpp | 1 + src/packer.cpp | 22 +++++++++++++++++++--- src/packer.h | 1 + src/stub/ident_n.ash | 2 +- src/stub/ident_s.ash | 2 +- src/stub/l_t_n2b.h | 6 +++--- src/stub/l_t_n2bs.h | 6 +++--- src/stub/l_t_n2d.h | 6 +++--- src/stub/l_t_n2ds.h | 6 +++--- src/stub/l_t_n2e.h | 6 +++--- src/stub/l_t_n2es.h | 6 +++--- src/version.h | 1 + 13 files changed, 45 insertions(+), 23 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 1afc871c..f61ada0d 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1106,6 +1106,9 @@ void upx_sanity_check(void) COMPILE_TIME_ASSERT(sizeof(UPX_VERSION_STRING4) == 4 + 1) assert(strlen(UPX_VERSION_STRING4) == 4); assert(memcmp(UPX_VERSION_STRING4, UPX_VERSION_STRING, 4) == 0); + COMPILE_TIME_ASSERT(sizeof(UPX_VERSION_YEAR) == 4 + 1) + assert(strlen(UPX_VERSION_YEAR) == 4); + assert(memcmp(UPX_VERSION_DATE + strlen(UPX_VERSION_DATE) - 4, UPX_VERSION_YEAR, 4) == 0); #if 1 # if 1 diff --git a/src/p_tos.cpp b/src/p_tos.cpp index a45f1bcd..b1dd11bc 100644 --- a/src/p_tos.cpp +++ b/src/p_tos.cpp @@ -547,6 +547,7 @@ void PackTos::pack(OutputFile *fo) // patch loader int tmp = patchPackHeader(loader, o_text); assert(tmp + 32 == (int)o_text); UNUSED(tmp); + patchVersionYear(loader, o_text); if (!opt->small) patchVersion(loader, o_text); // patch "subq.l #1,d6" or "subq.w #1,d6" - see "up41" below diff --git a/src/packer.cpp b/src/packer.cpp index b1fde406..84add5c6 100644 --- a/src/packer.cpp +++ b/src/packer.cpp @@ -821,6 +821,22 @@ int Packer::patchVersion(void *b, int blen) } +// patch year into stub/ident_[ns].ash +int Packer::patchVersionYear(void *b, int blen) +{ + int boff = find(b, blen, " 1996-UPXY ", 11); + checkPatch(b, blen, boff, 11); + + unsigned char *p = (unsigned char *)b + boff + 6; + if (opt->fake_stub_year[0]) + memcpy(p, opt->fake_stub_year, 4); + else + memcpy(p, UPX_VERSION_YEAR, 4); + + return boff; +} + + /************************************************************************* // relocation util **************************************************************************/ @@ -986,12 +1002,12 @@ char const *Packer::getIdentstr(unsigned *size, int small) "\n\0" "$Id: UPX " UPX_VERSION_STRING4 - " Copyright (C) 1996-2006 the UPX Team. All Rights Reserved. $" + " Copyright (C) 1996-" UPX_VERSION_YEAR " the UPX Team. All Rights Reserved. $" "\n"; static char identsmall[] = "\n" "$Id: UPX " - "(C) 1996-2006 the UPX Team. All Rights Reserved. http://upx.sf.net $" + "(C) 1996-" UPX_VERSION_YEAR " the UPX Team. All Rights Reserved. http://upx.sf.net $" "\n"; static char identtiny[] = UPX_VERSION_STRING4; @@ -1011,7 +1027,7 @@ char const *Packer::getIdentstr(unsigned *size, int small) if (opt->fake_stub_version[0]) mem_replace(iter->s, iter->size, UPX_VERSION_STRING4, 4, opt->fake_stub_version); if (opt->fake_stub_year[0]) - mem_replace(iter->s, iter->size, "2006", 4, opt->fake_stub_year); + mem_replace(iter->s, iter->size, UPX_VERSION_YEAR, 4, opt->fake_stub_year); } done = 1; } diff --git a/src/packer.h b/src/packer.h index fbed6ad2..4eda5e25 100644 --- a/src/packer.h +++ b/src/packer.h @@ -233,6 +233,7 @@ protected: int patch_le32(void *b, int blen, unsigned old, unsigned new_); int patch_le32(void *b, int blen, const void * old, unsigned new_); int patchVersion(void *b, int blen); + int patchVersionYear(void *b, int blen); void checkPatch(void *b, int blen, int boff, int size); // relocation util diff --git a/src/stub/ident_n.ash b/src/stub/ident_n.ash index a4c86733..ca512d4c 100644 --- a/src/stub/ident_n.ash +++ b/src/stub/ident_n.ash @@ -35,7 +35,7 @@ db 10,0 db '$Id: UPX ' db 'UPXV' - db ' Copyright (C) 1996-2006 the UPX Team. All Rights Reserved. $' + db ' Copyright (C) 1996-UPXY the UPX Team. All Rights Reserved. $' db 10,0 diff --git a/src/stub/ident_s.ash b/src/stub/ident_s.ash index a4d9a728..2d070c98 100644 --- a/src/stub/ident_s.ash +++ b/src/stub/ident_s.ash @@ -29,7 +29,7 @@ ; ------------- COPYRIGHT ------------- db 10 - db '$Id: UPX (C) 1996-2006 the UPX Team. ' + db '$Id: UPX (C) 1996-UPXY the UPX Team. ' db 'All Rights Reserved. http://upx.sf.net $' db 10,0 diff --git a/src/stub/l_t_n2b.h b/src/stub/l_t_n2b.h index adcdb72d..ab9e6a7d 100644 --- a/src/stub/l_t_n2b.h +++ b/src/stub/l_t_n2b.h @@ -28,8 +28,8 @@ #define NRV2B_LOADER_SIZE 668 -#define NRV2B_LOADER_ADLER32 0xb149ee81 -#define NRV2B_LOADER_CRC32 0x8c9f9acd +#define NRV2B_LOADER_ADLER32 0x36bbef0f +#define NRV2B_LOADER_CRC32 0x4f682ad4 unsigned char nrv2b_loader[668] = { 32, 8,103, 6, 46,104, 0, 4, 96, 4, 32, 47, 0, 4, 72,231, /* 0x 0 */ @@ -58,7 +58,7 @@ unsigned char nrv2b_loader[668] = { 107,101,114, 32,104,116,116,112, 58, 47, 47,117,112,120, 46,115, /* 0x 170 */ 102, 46,110,101,116, 32, 36, 10, 0, 36, 73,100, 58, 32, 85, 80, /* 0x 180 */ 88, 32, 85, 80, 88, 86, 32, 67,111,112,121,114,105,103,104,116, /* 0x 190 */ - 32, 40, 67, 41, 32, 49, 57, 57, 54, 45, 50, 48, 48, 54, 32,116, /* 0x 1a0 */ + 32, 40, 67, 41, 32, 49, 57, 57, 54, 45, 85, 80, 88, 89, 32,116, /* 0x 1a0 */ 104,101, 32, 85, 80, 88, 32, 84,101, 97,109, 46, 32, 65,108,108, /* 0x 1b0 */ 32, 82,105,103,104,116,115, 32, 82,101,115,101,114,118,101,100, /* 0x 1c0 */ 46, 32, 36, 10, 0, 0, 0, 0, 85, 80, 88, 33,161,216,208,213, /* 0x 1d0 */ diff --git a/src/stub/l_t_n2bs.h b/src/stub/l_t_n2bs.h index 7108859f..69b2f087 100644 --- a/src/stub/l_t_n2bs.h +++ b/src/stub/l_t_n2bs.h @@ -28,8 +28,8 @@ #define NRV2B_LOADER_SMALL_SIZE 530 -#define NRV2B_LOADER_SMALL_ADLER32 0xdcb7b310 -#define NRV2B_LOADER_SMALL_CRC32 0x35164d24 +#define NRV2B_LOADER_SMALL_ADLER32 0x6843b39e +#define NRV2B_LOADER_SMALL_CRC32 0x68e5d2d4 unsigned char nrv2b_loader_small[530] = { 32, 8,103, 6, 46,104, 0, 4, 96, 4, 32, 47, 0, 4, 72,231, /* 0x 0 */ @@ -49,7 +49,7 @@ unsigned char nrv2b_loader_small[530] = { 33,223, 0,244, 33,223, 0, 44, 33,223, 0, 16, 78,113, 78,117, /* 0x e0 */ 78,117, 79,239, 0,146, 76,223,127,254, 32, 8,103, 2,159,207, /* 0x f0 */ 78,249, 10, 36, 73,100, 58, 32, 85, 80, 88, 32, 40, 67, 41, 32, /* 0x 100 */ - 49, 57, 57, 54, 45, 50, 48, 48, 54, 32,116,104,101, 32, 85, 80, /* 0x 110 */ + 49, 57, 57, 54, 45, 85, 80, 88, 89, 32,116,104,101, 32, 85, 80, /* 0x 110 */ 88, 32, 84,101, 97,109, 46, 32, 65,108,108, 32, 82,105,103,104, /* 0x 120 */ 116,115, 32, 82,101,115,101,114,118,101,100, 46, 32,104,116,116, /* 0x 130 */ 112, 58, 47, 47,117,112,120, 46,115,102, 46,110,101,116, 32, 36, /* 0x 140 */ diff --git a/src/stub/l_t_n2d.h b/src/stub/l_t_n2d.h index e9671c34..0adb04d7 100644 --- a/src/stub/l_t_n2d.h +++ b/src/stub/l_t_n2d.h @@ -28,8 +28,8 @@ #define NRV2D_LOADER_SIZE 688 -#define NRV2D_LOADER_ADLER32 0x86fbf45f -#define NRV2D_LOADER_CRC32 0x6902d666 +#define NRV2D_LOADER_ADLER32 0x1785f4ed +#define NRV2D_LOADER_CRC32 0xecd288cc unsigned char nrv2d_loader[688] = { 32, 8,103, 6, 46,104, 0, 4, 96, 4, 32, 47, 0, 4, 72,231, /* 0x 0 */ @@ -58,7 +58,7 @@ unsigned char nrv2d_loader[688] = { 107,101,114, 32,104,116,116,112, 58, 47, 47,117,112,120, 46,115, /* 0x 170 */ 102, 46,110,101,116, 32, 36, 10, 0, 36, 73,100, 58, 32, 85, 80, /* 0x 180 */ 88, 32, 85, 80, 88, 86, 32, 67,111,112,121,114,105,103,104,116, /* 0x 190 */ - 32, 40, 67, 41, 32, 49, 57, 57, 54, 45, 50, 48, 48, 54, 32,116, /* 0x 1a0 */ + 32, 40, 67, 41, 32, 49, 57, 57, 54, 45, 85, 80, 88, 89, 32,116, /* 0x 1a0 */ 104,101, 32, 85, 80, 88, 32, 84,101, 97,109, 46, 32, 65,108,108, /* 0x 1b0 */ 32, 82,105,103,104,116,115, 32, 82,101,115,101,114,118,101,100, /* 0x 1c0 */ 46, 32, 36, 10, 0, 0, 0, 0, 85, 80, 88, 33,161,216,208,213, /* 0x 1d0 */ diff --git a/src/stub/l_t_n2ds.h b/src/stub/l_t_n2ds.h index fca8d102..27e8d621 100644 --- a/src/stub/l_t_n2ds.h +++ b/src/stub/l_t_n2ds.h @@ -28,8 +28,8 @@ #define NRV2D_LOADER_SMALL_SIZE 550 -#define NRV2D_LOADER_SMALL_ADLER32 0x9fb1b9c8 -#define NRV2D_LOADER_SMALL_CRC32 0xc069fa07 +#define NRV2D_LOADER_SMALL_ADLER32 0x3655ba56 +#define NRV2D_LOADER_SMALL_CRC32 0x7bba64b7 unsigned char nrv2d_loader_small[550] = { 32, 8,103, 6, 46,104, 0, 4, 96, 4, 32, 47, 0, 4, 72,231, /* 0x 0 */ @@ -49,7 +49,7 @@ unsigned char nrv2d_loader_small[550] = { 33,223, 0,244, 33,223, 0, 44, 33,223, 0, 16, 78,113, 78,117, /* 0x e0 */ 78,117, 79,239, 0,146, 76,223,127,254, 32, 8,103, 2,159,207, /* 0x f0 */ 78,249, 10, 36, 73,100, 58, 32, 85, 80, 88, 32, 40, 67, 41, 32, /* 0x 100 */ - 49, 57, 57, 54, 45, 50, 48, 48, 54, 32,116,104,101, 32, 85, 80, /* 0x 110 */ + 49, 57, 57, 54, 45, 85, 80, 88, 89, 32,116,104,101, 32, 85, 80, /* 0x 110 */ 88, 32, 84,101, 97,109, 46, 32, 65,108,108, 32, 82,105,103,104, /* 0x 120 */ 116,115, 32, 82,101,115,101,114,118,101,100, 46, 32,104,116,116, /* 0x 130 */ 112, 58, 47, 47,117,112,120, 46,115,102, 46,110,101,116, 32, 36, /* 0x 140 */ diff --git a/src/stub/l_t_n2e.h b/src/stub/l_t_n2e.h index 04fc76c7..0e14a864 100644 --- a/src/stub/l_t_n2e.h +++ b/src/stub/l_t_n2e.h @@ -28,8 +28,8 @@ #define NRV2E_LOADER_SIZE 696 -#define NRV2E_LOADER_ADLER32 0x0bfbf673 -#define NRV2E_LOADER_CRC32 0x3e79ea40 +#define NRV2E_LOADER_ADLER32 0xa0e6f701 +#define NRV2E_LOADER_CRC32 0x1d26a023 unsigned char nrv2e_loader[696] = { 32, 8,103, 6, 46,104, 0, 4, 96, 4, 32, 47, 0, 4, 72,231, /* 0x 0 */ @@ -58,7 +58,7 @@ unsigned char nrv2e_loader[696] = { 107,101,114, 32,104,116,116,112, 58, 47, 47,117,112,120, 46,115, /* 0x 170 */ 102, 46,110,101,116, 32, 36, 10, 0, 36, 73,100, 58, 32, 85, 80, /* 0x 180 */ 88, 32, 85, 80, 88, 86, 32, 67,111,112,121,114,105,103,104,116, /* 0x 190 */ - 32, 40, 67, 41, 32, 49, 57, 57, 54, 45, 50, 48, 48, 54, 32,116, /* 0x 1a0 */ + 32, 40, 67, 41, 32, 49, 57, 57, 54, 45, 85, 80, 88, 89, 32,116, /* 0x 1a0 */ 104,101, 32, 85, 80, 88, 32, 84,101, 97,109, 46, 32, 65,108,108, /* 0x 1b0 */ 32, 82,105,103,104,116,115, 32, 82,101,115,101,114,118,101,100, /* 0x 1c0 */ 46, 32, 36, 10, 0, 0, 0, 0, 85, 80, 88, 33,161,216,208,213, /* 0x 1d0 */ diff --git a/src/stub/l_t_n2es.h b/src/stub/l_t_n2es.h index eb843de4..d669f352 100644 --- a/src/stub/l_t_n2es.h +++ b/src/stub/l_t_n2es.h @@ -28,8 +28,8 @@ #define NRV2E_LOADER_SMALL_SIZE 558 -#define NRV2E_LOADER_SMALL_ADLER32 0xb197bbdc -#define NRV2E_LOADER_SMALL_CRC32 0x4082eb7b +#define NRV2E_LOADER_SMALL_ADLER32 0x4cabbc6a +#define NRV2E_LOADER_SMALL_CRC32 0xda3e6739 unsigned char nrv2e_loader_small[558] = { 32, 8,103, 6, 46,104, 0, 4, 96, 4, 32, 47, 0, 4, 72,231, /* 0x 0 */ @@ -49,7 +49,7 @@ unsigned char nrv2e_loader_small[558] = { 33,223, 0,244, 33,223, 0, 44, 33,223, 0, 16, 78,113, 78,117, /* 0x e0 */ 78,117, 79,239, 0,146, 76,223,127,254, 32, 8,103, 2,159,207, /* 0x f0 */ 78,249, 10, 36, 73,100, 58, 32, 85, 80, 88, 32, 40, 67, 41, 32, /* 0x 100 */ - 49, 57, 57, 54, 45, 50, 48, 48, 54, 32,116,104,101, 32, 85, 80, /* 0x 110 */ + 49, 57, 57, 54, 45, 85, 80, 88, 89, 32,116,104,101, 32, 85, 80, /* 0x 110 */ 88, 32, 84,101, 97,109, 46, 32, 65,108,108, 32, 82,105,103,104, /* 0x 120 */ 116,115, 32, 82,101,115,101,114,118,101,100, 46, 32,104,116,116, /* 0x 130 */ 112, 58, 47, 47,117,112,120, 46,115,102, 46,110,101,116, 32, 36, /* 0x 140 */ diff --git a/src/version.h b/src/version.h index 91ccfa17..43807ad4 100644 --- a/src/version.h +++ b/src/version.h @@ -2,3 +2,4 @@ #define UPX_VERSION_STRING "1.94 beta" #define UPX_VERSION_STRING4 "1.94" #define UPX_VERSION_DATE "Feb 13th 2006" +#define UPX_VERSION_YEAR "2006"