From 401567f8528f3e765feefde1b3a49c40aa2cd0d3 Mon Sep 17 00:00:00 2001 From: "Markus F.X.J. Oberhumer" Date: Mon, 12 Feb 2001 12:50:00 +0000 Subject: [PATCH] Removed the optional `off' parameter from the [gs]et_[bl]e{16,24,32} functions. committer: mfx 981982200 +0000 --- src/bele.h | 40 ++++++++++++++++++++-------------------- src/p_tmt.cpp | 4 ++-- src/p_unix.h | 20 ++++++++++---------- src/packer.cpp | 5 ++++- 4 files changed, 36 insertions(+), 33 deletions(-) diff --git a/src/bele.h b/src/bele.h index 0e08f968..ef1cabb2 100644 --- a/src/bele.h +++ b/src/bele.h @@ -34,26 +34,26 @@ // access memory in BigEndian and LittleEndian byte order **************************************************************************/ -inline unsigned short get_be16(const void *bb, int off=0) +inline unsigned short get_be16(const void *bb) { - const upx_bytep const b = reinterpret_cast(bb) + off; + const upx_bytep const b = reinterpret_cast(bb); unsigned v; v = (unsigned) b[1] << 0; v |= (unsigned) b[0] << 8; return (unsigned short) v; } -inline void set_be16(void *bb, unsigned v, int off=0) +inline void set_be16(void *bb, unsigned v) { - upx_bytep const b = reinterpret_cast(bb) + off; + upx_bytep const b = reinterpret_cast(bb); b[1] = (unsigned char) (v >> 0); b[0] = (unsigned char) (v >> 8); } -inline unsigned get_be32(const void *bb, int off=0) +inline unsigned get_be32(const void *bb) { - const upx_bytep const b = reinterpret_cast(bb) + off; + const upx_bytep const b = reinterpret_cast(bb); unsigned v; v = (unsigned) b[3] << 0; v |= (unsigned) b[2] << 8; @@ -62,9 +62,9 @@ inline unsigned get_be32(const void *bb, int off=0) return v; } -inline void set_be32(void *bb, unsigned v, int off=0) +inline void set_be32(void *bb, unsigned v) { - upx_bytep const b = reinterpret_cast(bb) + off; + upx_bytep const b = reinterpret_cast(bb); b[3] = (unsigned char) (v >> 0); b[2] = (unsigned char) (v >> 8); b[1] = (unsigned char) (v >> 16); @@ -72,9 +72,9 @@ inline void set_be32(void *bb, unsigned v, int off=0) } -inline unsigned short get_le16(const void *bb, int off=0) +inline unsigned short get_le16(const void *bb) { - const upx_bytep const b = reinterpret_cast(bb) + off; + const upx_bytep const b = reinterpret_cast(bb); unsigned v; #if defined(__i386__) v = * (const unsigned short *) b; @@ -85,9 +85,9 @@ inline unsigned short get_le16(const void *bb, int off=0) return (unsigned short) v; } -inline void set_le16(void *bb, unsigned v, int off=0) +inline void set_le16(void *bb, unsigned v) { - upx_bytep const b = reinterpret_cast(bb) + off; + upx_bytep const b = reinterpret_cast(bb); #if defined(__i386__) (* (unsigned short *) b) = (unsigned short) v; #else @@ -97,9 +97,9 @@ inline void set_le16(void *bb, unsigned v, int off=0) } -inline unsigned get_le24(const void *bb, int off=0) +inline unsigned get_le24(const void *bb) { - const upx_bytep const b = reinterpret_cast(bb) + off; + const upx_bytep const b = reinterpret_cast(bb); unsigned v; v = (unsigned) b[0] << 0; v |= (unsigned) b[1] << 8; @@ -107,18 +107,18 @@ inline unsigned get_le24(const void *bb, int off=0) return v; } -inline void set_le24(void *bb, unsigned v, int off=0) +inline void set_le24(void *bb, unsigned v) { - upx_bytep const b = reinterpret_cast(bb) + off; + upx_bytep const b = reinterpret_cast(bb); b[0] = (unsigned char) (v >> 0); b[1] = (unsigned char) (v >> 8); b[2] = (unsigned char) (v >> 16); } -inline unsigned get_le32(const void *bb, int off=0) +inline unsigned get_le32(const void *bb) { - const upx_bytep const b = reinterpret_cast(bb) + off; + const upx_bytep const b = reinterpret_cast(bb); unsigned v; #if defined(__i386__) v = * (const unsigned *) b; @@ -131,9 +131,9 @@ inline unsigned get_le32(const void *bb, int off=0) return v; } -inline void set_le32(void *bb, unsigned v, int off=0) +inline void set_le32(void *bb, unsigned v) { - upx_bytep const b = reinterpret_cast(bb) + off; + upx_bytep const b = reinterpret_cast(bb); #if defined(__i386__) (* (unsigned *) b) = v; #else diff --git a/src/p_tmt.cpp b/src/p_tmt.cpp index ca5fb353..062c46cf 100644 --- a/src/p_tmt.cpp +++ b/src/p_tmt.cpp @@ -115,8 +115,8 @@ int PackTmt::buildLoader(const Filter *ft) int PackTmt::readFileHeader() { -#define H(x) get_le16(h,2*(x)) -#define H4(x) get_le32(h,x) +#define H(x) get_le16(h+2*(x)) +#define H4(x) get_le32(h+(x)) unsigned char h[0x40]; int ic; unsigned exe_offset = 0; diff --git a/src/p_unix.h b/src/p_unix.h index d3d6cbf1..65198f3d 100644 --- a/src/p_unix.h +++ b/src/p_unix.h @@ -66,8 +66,8 @@ protected: // in order too share as much code as possible we introduce // an endian abstraction here - virtual unsigned get_native32(const void *, int off=0) = 0; - virtual void set_native32(void *, unsigned, int off=0) = 0; + virtual unsigned get_native32(const void *) = 0; + virtual void set_native32(void *, unsigned) = 0; virtual bool checkCompressionRatio(unsigned, unsigned) const; @@ -121,13 +121,13 @@ class PackUnixBe32 : public PackUnix typedef PackUnix super; protected: PackUnixBe32(InputFile *f) : super(f) { } - virtual unsigned get_native32(const void * b, int off=0) + virtual unsigned get_native32(const void *b) { - return get_be32(b, off); + return get_be32(b); } - virtual void set_native32(void * b, unsigned v, int off=0) + virtual void set_native32(void *b, unsigned v) { - set_be32(b, v, off); + set_be32(b, v); } }; @@ -137,13 +137,13 @@ class PackUnixLe32 : public PackUnix typedef PackUnix super; protected: PackUnixLe32(InputFile *f) : super(f) { } - virtual unsigned get_native32(const void * b, int off=0) + virtual unsigned get_native32(const void *b) { - return get_le32(b, off); + return get_le32(b); } - virtual void set_native32(void * b, unsigned v, int off=0) + virtual void set_native32(void *b, unsigned v) { - set_le32(b, v, off); + set_le32(b, v); } }; diff --git a/src/packer.cpp b/src/packer.cpp index 02de2b89..932d3479 100644 --- a/src/packer.cpp +++ b/src/packer.cpp @@ -949,7 +949,10 @@ char const *Packer::identstr(unsigned &size) void Packer::initLoader(const void *pdata, int plen, int pinfo) { if (pinfo < 0) - pinfo = ~3 & (3 + get_le16(pdata, plen - 2)); + { + pinfo = get_le16((const unsigned char *)pdata + plen - 2); + pinfo = (pinfo + 3) &~ 3; + } delete linker; if (getFormat() < 128)