Start using some C++ 14 features.

This commit is contained in:
Markus F.X.J. Oberhumer 2020-12-08 05:40:17 +01:00
parent 361a3056cb
commit f7e2266c3f
62 changed files with 971 additions and 960 deletions

View File

@ -44,10 +44,10 @@ public:
~BoundedPtr() { }
explicit BoundedPtr(void* base, size_t size_in_bytes, T* ptr=0)
BoundedPtr(void* base, size_t size_in_bytes, T* ptr=nullptr)
: ptr_(ptr), base_(base), size_in_bytes_(0)
{
assert(base_ != NULL);
assert(base_ != nullptr);
size_in_bytes_ = mem_size(1, size_in_bytes);
check();
}
@ -86,7 +86,7 @@ private:
throwCantUnpack("pointer out of range; take care!");
}
void check() const { // check ptr_ invariant: either NULL or valid checkRange()
if (ptr_ != NULL)
if (ptr_ != nullptr)
checkRange();
}
@ -95,7 +95,7 @@ private:
size_t size_in_bytes_;
// disable copy
BoundedPtr(const BoundedPtr&); // {}
BoundedPtr(const BoundedPtr&) = delete;
// disable dynamic allocation
DISABLE_NEW_DELETE
};

View File

@ -28,7 +28,7 @@
#include "conf.h"
FILE *con_term = NULL;
FILE *con_term = nullptr;
#if (USE_CONSOLE)
@ -60,7 +60,7 @@ static void try_init(console_t *c, FILE *f)
{
con_mode = k;
con = c;
con->init = 0;
con->init = nullptr;
if (!con->set_fg)
con->set_fg = console_none.set_fg;
if (!con->print0)
@ -137,7 +137,7 @@ console_t console_init =
{
init,
set_fg,
0,
nullptr,
intro
};

View File

@ -72,11 +72,11 @@ static int do_init(screen_t *s, int fd)
static screen_t *do_construct(screen_t *s, int fd)
{
if (!s)
return NULL;
return nullptr;
if (do_init(s,fd) != 0)
{
s->destroy(s);
return NULL;
return nullptr;
}
return s;
}
@ -86,7 +86,7 @@ static screen_t *do_construct(screen_t *s, int fd)
//
**************************************************************************/
static screen_t *screen = NULL;
static screen_t *screen = nullptr;
static void __acc_cdecl_atexit do_destroy(void)
{
@ -95,7 +95,7 @@ static void __acc_cdecl_atexit do_destroy(void)
if (screen->atExit)
screen->atExit();
screen->destroy(screen);
screen = NULL;
screen = nullptr;
}
}
@ -113,7 +113,7 @@ static int init(FILE *f, int o, int now)
int n;
UNUSED(now);
assert(screen == NULL);
assert(screen == nullptr);
if (o == CON_SCREEN)
n = CON_SCREEN;

View File

@ -39,7 +39,7 @@ unsigned upx_adler32(const void *buf, unsigned len, unsigned adler)
{
if (len == 0)
return adler;
assert(buf != NULL);
assert(buf != nullptr);
#if 1
return upx_ucl_adler32(buf, len, adler);
#else
@ -53,7 +53,7 @@ unsigned upx_crc32(const void *buf, unsigned len, unsigned crc)
{
if (len == 0)
return crc;
assert(buf != NULL);
assert(buf != nullptr);
#if 1
return upx_ucl_crc32(buf, len, crc);
#else
@ -145,7 +145,7 @@ int upx_decompress ( const upx_bytep src, unsigned src_len,
assert(src_len < *dst_len); // must be compressed
if (cresult && cresult->method == 0)
cresult = NULL;
cresult = nullptr;
if __acc_cte(0) {
}
@ -187,7 +187,7 @@ int upx_test_overlap ( const upx_bytep buf,
int r = UPX_E_ERROR;
if (cresult && cresult->method == 0)
cresult = NULL;
cresult = nullptr;
assert(*dst_len > 0);
assert(src_len < *dst_len); // must be compressed

View File

@ -230,6 +230,8 @@ error:
#undef _WIN32_WCE
#undef COMPRESS_MF_MT
#undef _NO_EXCEPTIONS
#undef NULL
#define NULL nullptr
#include "C/Common/MyInitGuid.h"
//#include "C/7zip/Compress/LZMA/LZMADecoder.h"
#include "C/7zip/Compress/LZMA/LZMAEncoder.h"
@ -253,7 +255,7 @@ STDMETHODIMP InStream::Read(void *data, UInt32 size, UInt32 *processedSize)
if (size > remain) size = (UInt32) remain;
memmove(data, b_buf + b_pos, size);
b_pos += size;
if (processedSize != NULL) *processedSize = size;
if (processedSize != nullptr) *processedSize = size;
return S_OK;
}
@ -279,7 +281,7 @@ STDMETHODIMP OutStream::Write(const void *data, UInt32 size, UInt32 *processedSi
if (size > remain) size = (UInt32) remain, overflow = true;
memmove(b_buf + b_pos, data, size);
b_pos += size;
if (processedSize != NULL) *processedSize = size;
if (processedSize != nullptr) *processedSize = size;
return overflow ? E_FAIL : S_OK;
}
@ -321,11 +323,11 @@ int upx_lzma_compress ( const upx_bytep src, unsigned src_len,
upx_compress_result_t *cresult )
{
assert(M_IS_LZMA(method));
assert(level > 0); assert(cresult != NULL);
assert(level > 0); assert(cresult != nullptr);
int r = UPX_E_ERROR;
HRESULT rh;
const lzma_compress_config_t *lcconf = cconf_parm ? &cconf_parm->conf_lzma : NULL;
const lzma_compress_config_t *lcconf = cconf_parm ? &cconf_parm->conf_lzma : nullptr;
lzma_compress_result_t *res = &cresult->result_lzma;
MyLzma::InStream is; is.AddRef();
@ -382,7 +384,7 @@ int upx_lzma_compress ( const upx_bytep src, unsigned src_len,
os.WriteByte(Byte((t << 3) | res->pos_bits));
os.WriteByte(Byte((res->lit_pos_bits << 4) | (res->lit_context_bits)));
rh = enc.Code(&is, &os, NULL, NULL, &progress);
rh = enc.Code(&is, &os, nullptr, nullptr, &progress);
} catch (...) {
rh = E_OUTOFMEMORY;
@ -509,7 +511,7 @@ int upx_lzma_test_overlap ( const upx_bytep buf,
// NOTE: there is a very tiny possibility that decompression has
// succeeded but the data is not restored correctly because of
// in-place buffer overlapping, so we use an extra memcmp().
if (tbuf != NULL && memcmp(tbuf, b, *dst_len) != 0)
if (tbuf != nullptr && memcmp(tbuf, b, *dst_len) != 0)
return UPX_E_ERROR;
return UPX_E_OK;
}
@ -530,7 +532,7 @@ const char *upx_lzma_version_string(void)
return "4.43";
#else
# error "unknown WITH_LZMA version"
return NULL;
return nullptr;
#endif
}

View File

@ -106,13 +106,13 @@ int upx_ucl_compress ( const upx_bytep src, unsigned src_len,
upx_compress_result_t *cresult )
{
int r;
assert(level > 0); assert(cresult != NULL);
assert(level > 0); assert(cresult != nullptr);
COMPILE_TIME_ASSERT(sizeof(ucl_compress_config_t) == sizeof(REAL_ucl_compress_config_t))
ucl_progress_callback_t cb;
cb.callback = 0;
cb.user = NULL;
cb.callback = nullptr;
cb.user = nullptr;
if (cb_parm && cb_parm->nprogress) {
cb.callback = wrap_nprogress_ucl;
cb.user = cb_parm;
@ -188,31 +188,31 @@ int upx_ucl_decompress ( const upx_bytep src, unsigned src_len,
switch (method)
{
case M_NRV2B_8:
r = ucl_nrv2b_decompress_safe_8(src,src_len,dst,dst_len,NULL);
r = ucl_nrv2b_decompress_safe_8(src,src_len,dst,dst_len,nullptr);
break;
case M_NRV2B_LE16:
r = ucl_nrv2b_decompress_safe_le16(src,src_len,dst,dst_len,NULL);
r = ucl_nrv2b_decompress_safe_le16(src,src_len,dst,dst_len,nullptr);
break;
case M_NRV2B_LE32:
r = ucl_nrv2b_decompress_safe_le32(src,src_len,dst,dst_len,NULL);
r = ucl_nrv2b_decompress_safe_le32(src,src_len,dst,dst_len,nullptr);
break;
case M_NRV2D_8:
r = ucl_nrv2d_decompress_safe_8(src,src_len,dst,dst_len,NULL);
r = ucl_nrv2d_decompress_safe_8(src,src_len,dst,dst_len,nullptr);
break;
case M_NRV2D_LE16:
r = ucl_nrv2d_decompress_safe_le16(src,src_len,dst,dst_len,NULL);
r = ucl_nrv2d_decompress_safe_le16(src,src_len,dst,dst_len,nullptr);
break;
case M_NRV2D_LE32:
r = ucl_nrv2d_decompress_safe_le32(src,src_len,dst,dst_len,NULL);
r = ucl_nrv2d_decompress_safe_le32(src,src_len,dst,dst_len,nullptr);
break;
case M_NRV2E_8:
r = ucl_nrv2e_decompress_safe_8(src,src_len,dst,dst_len,NULL);
r = ucl_nrv2e_decompress_safe_8(src,src_len,dst,dst_len,nullptr);
break;
case M_NRV2E_LE16:
r = ucl_nrv2e_decompress_safe_le16(src,src_len,dst,dst_len,NULL);
r = ucl_nrv2e_decompress_safe_le16(src,src_len,dst,dst_len,nullptr);
break;
case M_NRV2E_LE32:
r = ucl_nrv2e_decompress_safe_le32(src,src_len,dst,dst_len,NULL);
r = ucl_nrv2e_decompress_safe_le32(src,src_len,dst,dst_len,nullptr);
break;
default:
throwInternalError("unknown decompression method");
@ -241,31 +241,31 @@ int upx_ucl_test_overlap ( const upx_bytep buf,
switch (method)
{
case M_NRV2B_8:
r = ucl_nrv2b_test_overlap_8(buf,src_off,src_len,dst_len,NULL);
r = ucl_nrv2b_test_overlap_8(buf,src_off,src_len,dst_len,nullptr);
break;
case M_NRV2B_LE16:
r = ucl_nrv2b_test_overlap_le16(buf,src_off,src_len,dst_len,NULL);
r = ucl_nrv2b_test_overlap_le16(buf,src_off,src_len,dst_len,nullptr);
break;
case M_NRV2B_LE32:
r = ucl_nrv2b_test_overlap_le32(buf,src_off,src_len,dst_len,NULL);
r = ucl_nrv2b_test_overlap_le32(buf,src_off,src_len,dst_len,nullptr);
break;
case M_NRV2D_8:
r = ucl_nrv2d_test_overlap_8(buf,src_off,src_len,dst_len,NULL);
r = ucl_nrv2d_test_overlap_8(buf,src_off,src_len,dst_len,nullptr);
break;
case M_NRV2D_LE16:
r = ucl_nrv2d_test_overlap_le16(buf,src_off,src_len,dst_len,NULL);
r = ucl_nrv2d_test_overlap_le16(buf,src_off,src_len,dst_len,nullptr);
break;
case M_NRV2D_LE32:
r = ucl_nrv2d_test_overlap_le32(buf,src_off,src_len,dst_len,NULL);
r = ucl_nrv2d_test_overlap_le32(buf,src_off,src_len,dst_len,nullptr);
break;
case M_NRV2E_8:
r = ucl_nrv2e_test_overlap_8(buf,src_off,src_len,dst_len,NULL);
r = ucl_nrv2e_test_overlap_8(buf,src_off,src_len,dst_len,nullptr);
break;
case M_NRV2E_LE16:
r = ucl_nrv2e_test_overlap_le16(buf,src_off,src_len,dst_len,NULL);
r = ucl_nrv2e_test_overlap_le16(buf,src_off,src_len,dst_len,nullptr);
break;
case M_NRV2E_LE32:
r = ucl_nrv2e_test_overlap_le32(buf,src_off,src_len,dst_len,NULL);
r = ucl_nrv2e_test_overlap_le32(buf,src_off,src_len,dst_len,nullptr);
break;
default:
throwInternalError("unknown decompression method");

View File

@ -73,11 +73,11 @@ int upx_zlib_compress ( const upx_bytep src, unsigned src_len,
upx_compress_result_t *cresult )
{
assert(method == M_DEFLATE);
assert(level > 0); assert(cresult != NULL);
assert(level > 0); assert(cresult != nullptr);
UNUSED(cb_parm);
int r = UPX_E_ERROR;
int zr;
const zlib_compress_config_t *lcconf = cconf_parm ? &cconf_parm->conf_zlib : NULL;
const zlib_compress_config_t *lcconf = cconf_parm ? &cconf_parm->conf_zlib : nullptr;
zlib_compress_result_t *res = &cresult->result_zlib;
if (level == 10)
@ -97,8 +97,8 @@ int upx_zlib_compress ( const upx_bytep src, unsigned src_len,
res->dummy = 0;
z_stream s;
s.zalloc = (alloc_func) 0;
s.zfree = (free_func) 0;
s.zalloc = (alloc_func) nullptr;
s.zfree = (free_func) nullptr;
s.next_in = ACC_UNCONST_CAST(upx_bytep, src);
s.avail_in = src_len;
s.next_out = dst;
@ -151,8 +151,8 @@ int upx_zlib_decompress ( const upx_bytep src, unsigned src_len,
int zr;
z_stream s;
s.zalloc = (alloc_func) 0;
s.zfree = (free_func) 0;
s.zalloc = (alloc_func) nullptr;
s.zfree = (free_func) nullptr;
s.next_in = ACC_UNCONST_CAST(upx_bytep, src);
s.avail_in = src_len;
s.next_out = dst;
@ -212,7 +212,7 @@ int upx_zlib_test_overlap ( const upx_bytep buf,
// NOTE: there is a very tiny possibility that decompression has
// succeeded but the data is not restored correctly because of
// in-place buffer overlapping, so we use an extra memcmp().
if (tbuf != NULL && memcmp(tbuf, b, *dst_len) != 0)
if (tbuf != nullptr && memcmp(tbuf, b, *dst_len) != 0)
return UPX_E_ERROR;
return UPX_E_OK;
}

View File

@ -65,11 +65,16 @@
# error "UINT_MAX"
#endif
ACC_COMPILE_TIME_ASSERT_HEADER(sizeof(int) == 4)
ACC_COMPILE_TIME_ASSERT_HEADER(-1 == ~0) // two's complement - see http://wg21.link/P0907R4
ACC_COMPILE_TIME_ASSERT_HEADER(0u-1 == ~0u) // two's complement - see http://wg21.link/P0907R4
ACC_COMPILE_TIME_ASSERT_HEADER((1u << 31) << 1 == 0)
ACC_COMPILE_TIME_ASSERT_HEADER(((int)(1u << 31)) >> 31 == -1) // arithmetic right shift
ACC_COMPILE_TIME_ASSERT_HEADER(CHAR_MAX == 255) // -funsigned-char
ACC_COMPILE_TIME_ASSERT_HEADER((char)(-1) > 0) // -funsigned-char
#if (ACC_CC_GNUC >= 0x040700)
# pragma GCC diagnostic error "-Wzero-as-null-pointer-constant"
#endif
#if (ACC_CC_MSC)
# pragma warning(error: 4127)
# pragma warning(error: 4146)
@ -585,7 +590,7 @@ struct upx_compress_config_t
void reset() { conf_lzma.reset(); conf_ucl.reset(); conf_zlib.reset(); }
};
#define NULL_cconf ((upx_compress_config_t *) NULL)
#define NULL_cconf ((upx_compress_config_t *) nullptr)
/*************************************************************************
@ -670,7 +675,7 @@ void e_exit(int ec);
// msg.cpp
void printSetNl(int need_nl);
void printClearLine(FILE *f = NULL);
void printClearLine(FILE *f = nullptr);
void printErr(const char *iname, const Throwable *e);
void printUnhandledException(const char *iname, const std::exception *e);
#if (ACC_CC_CLANG || ACC_CC_GNUC || ACC_CC_LLVM || ACC_CC_PATHSCALE)

View File

@ -36,7 +36,7 @@
unsigned long Throwable::counter = 0;
Throwable::Throwable(const char *m, int e, bool w) noexcept
: super(), msg(NULL), err(e), is_warning(w)
: super(), msg(nullptr), err(e), is_warning(w)
{
if (m)
msg = strdup(m);
@ -48,7 +48,7 @@ Throwable::Throwable(const char *m, int e, bool w) noexcept
Throwable::Throwable(const Throwable &other) noexcept
: super(other), msg(NULL), err(other.err), is_warning(other.is_warning)
: super(other), msg(nullptr), err(other.err), is_warning(other.is_warning)
{
if (other.msg)
msg = strdup(other.msg);
@ -112,7 +112,7 @@ void throwAlreadyPacked(const char *msg)
void throwAlreadyPackedByUPX(const char *msg)
{
if (msg == NULL)
if (msg == nullptr)
msg = "already packed by UPX";
throwAlreadyPacked(msg);
}
@ -130,7 +130,7 @@ void throwCantUnpack(const char *msg)
void throwNotPacked(const char *msg)
{
if (msg == NULL)
if (msg == nullptr)
msg = "not packed by UPX";
throw NotPackedException(msg);
}
@ -163,7 +163,7 @@ void throwBadLoader()
void throwOutOfMemoryException(const char *msg)
{
if (msg == NULL)
if (msg == nullptr)
msg = "out of memory";
throw OutOfMemoryException(msg);
}
@ -177,7 +177,7 @@ void throwIOException(const char *msg, int e)
void throwEOFException(const char *msg, int e)
{
if (msg == NULL && e == 0)
if (msg == nullptr && e == 0)
msg = "premature end of file";
throw EOFException(msg, e);
}
@ -189,7 +189,7 @@ void throwEOFException(const char *msg, int e)
const char *prettyName(const char *n) noexcept
{
if (n == NULL)
if (n == nullptr)
return "(null)";
while (*n)
{

View File

@ -42,7 +42,7 @@ class Throwable : public std::exception
{
typedef std::exception super;
protected:
Throwable(const char *m = 0, int e = 0, bool w = false) noexcept;
Throwable(const char *m = nullptr, int e = 0, bool w = false) noexcept;
public:
Throwable(const Throwable &) noexcept;
virtual ~Throwable() noexcept;
@ -71,7 +71,7 @@ class Exception : public Throwable
{
typedef Throwable super;
public:
Exception(const char *m = 0, int e = 0, bool w = false) noexcept : super(m,e,w) { }
Exception(const char *m = nullptr, int e = 0, bool w = false) noexcept : super(m,e,w) { }
};
@ -80,7 +80,7 @@ class Error : public Throwable
{
typedef Throwable super;
public:
Error(const char *m = 0, int e = 0) noexcept : super(m,e) { }
Error(const char *m = nullptr, int e = 0) noexcept : super(m,e) { }
};
@ -92,7 +92,7 @@ class OutOfMemoryException : public Exception
{
typedef Exception super;
public:
OutOfMemoryException(const char *m = 0, int e = 0) noexcept : super(m,e) { }
OutOfMemoryException(const char *m = nullptr, int e = 0) noexcept : super(m,e) { }
};
@ -100,7 +100,7 @@ class IOException : public Exception
{
typedef Exception super;
public:
IOException(const char *m = 0, int e = 0) noexcept : super(m,e) { }
IOException(const char *m = nullptr, int e = 0) noexcept : super(m,e) { }
};
@ -108,7 +108,7 @@ class EOFException : public IOException
{
typedef IOException super;
public:
EOFException(const char *m = 0, int e = 0) noexcept : super(m,e) { }
EOFException(const char *m = nullptr, int e = 0) noexcept : super(m,e) { }
};
@ -116,7 +116,7 @@ class FileNotFoundException : public IOException
{
typedef IOException super;
public:
FileNotFoundException(const char *m = 0, int e = 0) noexcept : super(m,e) { }
FileNotFoundException(const char *m = nullptr, int e = 0) noexcept : super(m,e) { }
};
@ -124,7 +124,7 @@ class FileAlreadyExistsException : public IOException
{
typedef IOException super;
public:
FileAlreadyExistsException(const char *m = 0, int e = 0) noexcept : super(m,e) { }
FileAlreadyExistsException(const char *m = nullptr, int e = 0) noexcept : super(m,e) { }
};
@ -136,35 +136,35 @@ class OverlayException : public Exception
{
typedef Exception super;
public:
OverlayException(const char *m = 0, bool w = false) noexcept : super(m,0,w) { }
OverlayException(const char *m = nullptr, bool w = false) noexcept : super(m,0,w) { }
};
class CantPackException : public Exception
{
typedef Exception super;
public:
CantPackException(const char *m = 0, bool w = false) noexcept : super(m,0,w) { }
CantPackException(const char *m = nullptr, bool w = false) noexcept : super(m,0,w) { }
};
class UnknownExecutableFormatException : public CantPackException
{
typedef CantPackException super;
public:
UnknownExecutableFormatException(const char *m = 0, bool w = false) noexcept : super(m,w) { }
UnknownExecutableFormatException(const char *m = nullptr, bool w = false) noexcept : super(m,w) { }
};
class AlreadyPackedException : public CantPackException
{
typedef CantPackException super;
public:
AlreadyPackedException(const char *m = 0) noexcept : super(m) { is_warning = true; }
AlreadyPackedException(const char *m = nullptr) noexcept : super(m) { is_warning = true; }
};
class NotCompressibleException : public CantPackException
{
typedef CantPackException super;
public:
NotCompressibleException(const char *m = 0) noexcept : super(m) { }
NotCompressibleException(const char *m = nullptr) noexcept : super(m) { }
};
@ -172,14 +172,14 @@ class CantUnpackException : public Exception
{
typedef Exception super;
public:
CantUnpackException(const char *m = 0, bool w = false) noexcept : super(m,0,w) { }
CantUnpackException(const char *m = nullptr, bool w = false) noexcept : super(m,0,w) { }
};
class NotPackedException : public CantUnpackException
{
typedef CantUnpackException super;
public:
NotPackedException(const char *m = 0) noexcept : super(m,true) { }
NotPackedException(const char *m = nullptr) noexcept : super(m,true) { }
};
@ -191,7 +191,7 @@ class InternalError : public Error
{
typedef Error super;
public:
InternalError(const char *m = 0) noexcept : super(m,0) { }
InternalError(const char *m = nullptr) noexcept : super(m,0) { }
};
@ -208,20 +208,20 @@ public:
void throwCantPack(const char *msg) NORET;
void throwCantPackExact() NORET;
void throwUnknownExecutableFormat(const char *msg = NULL, bool warn = false) NORET;
void throwNotCompressible(const char *msg = NULL) NORET;
void throwAlreadyPacked(const char *msg = NULL) NORET;
void throwAlreadyPackedByUPX(const char *msg = NULL) NORET;
void throwUnknownExecutableFormat(const char *msg = nullptr, bool warn = false) NORET;
void throwNotCompressible(const char *msg = nullptr) NORET;
void throwAlreadyPacked(const char *msg = nullptr) NORET;
void throwAlreadyPackedByUPX(const char *msg = nullptr) NORET;
void throwCantUnpack(const char *msg) NORET;
void throwNotPacked(const char *msg = NULL) NORET;
void throwNotPacked(const char *msg = nullptr) NORET;
void throwFilterException() NORET;
void throwBadLoader() NORET;
void throwChecksumError() NORET;
void throwCompressedDataViolation() NORET;
void throwInternalError(const char *msg) NORET;
void throwOutOfMemoryException(const char *msg = NULL) NORET;
void throwIOException(const char *msg = NULL, int e = 0) NORET;
void throwEOFException(const char *msg = NULL, int e = 0) NORET;
void throwOutOfMemoryException(const char *msg = nullptr) NORET;
void throwIOException(const char *msg = nullptr, int e = 0) NORET;
void throwEOFException(const char *msg = nullptr, int e = 0) NORET;
#undef NORET

View File

@ -69,7 +69,7 @@ void File::unlink(const char *name)
**************************************************************************/
FileBase::FileBase() :
_fd(-1), _flags(0), _shflags(0), _mode(0), _name(NULL), _offset(0), _length(0)
_fd(-1), _flags(0), _shflags(0), _mode(0), _name(nullptr), _offset(0), _length(0)
{
memset(&st,0,sizeof(st));
}
@ -122,7 +122,7 @@ bool FileBase::close()
_fd = -1;
_flags = 0;
_mode = 0;
_name = NULL;
_name = nullptr;
_offset = 0;
_length = 0;
return ok;
@ -477,7 +477,7 @@ void OutputFile::dump(const char *name, const void *buf, int len, int flags)
#if 0
MemoryOutputFile::MemoryOutputFile() :
b(NULL), b_size(0), b_pos(0), bytes_written(0)
b(nullptr), b_size(0), b_pos(0), bytes_written(0)
{
}

View File

@ -163,10 +163,10 @@ class MemoryOutputFile : public FileBase
typedef FileBase super;
public:
MemoryOutputFile();
virtual ~MemoryOutputFile() { b = NULL; }
virtual ~MemoryOutputFile() { b = nullptr; }
virtual bool close() { b = NULL; return true; }
virtual bool isOpen() const { return b != NULL; }
virtual bool close() { b = nullptr; return true; }
virtual bool isOpen() const { return b != nullptr; }
virtual void open(void *buf, unsigned size)
{ b = (upx_bytep) buf; b_size = size; }

View File

@ -70,10 +70,10 @@ const FilterImp::FilterEntry *FilterImp::getFilter(int id)
}
if (id < 0 || id > 255)
return NULL;
return nullptr;
unsigned index = filter_map[id];
if (index == 0xff) // empty slot
return NULL;
return nullptr;
assert(filters[index].id == id);
return &filters[index];
}
@ -82,7 +82,7 @@ const FilterImp::FilterEntry *FilterImp::getFilter(int id)
bool Filter::isValidFilter(int filter_id)
{
const FilterImp::FilterEntry * const fe = FilterImp::getFilter(filter_id);
return fe != NULL;
return fe != nullptr;
}
bool Filter::isValidFilter(int filter_id, const int *allowed_filters)
@ -91,7 +91,7 @@ bool Filter::isValidFilter(int filter_id, const int *allowed_filters)
return false;
if (filter_id == 0)
return true;
if (allowed_filters == NULL)
if (allowed_filters == nullptr)
return false;
while (*allowed_filters != FT_END)
if (*allowed_filters++ == filter_id)
@ -107,10 +107,10 @@ bool Filter::isValidFilter(int filter_id, const int *allowed_filters)
void Filter::init(int id_, unsigned addvalue_)
{
this->id = id_;
initFilter(this, NULL, 0);
initFilter(this, nullptr, 0);
// clear input parameters
this->addvalue = addvalue_;
this->preferred_ctos = NULL;
this->preferred_ctos = nullptr;
// clear input/output parameters
this->cto = 0;
this->n_mru = 0;
@ -122,7 +122,7 @@ bool Filter::filter(upx_byte *buf_, unsigned buf_len_)
initFilter(this, buf_, buf_len_);
const FilterImp::FilterEntry * const fe = FilterImp::getFilter(id);
if (fe == NULL)
if (fe == nullptr)
throwInternalError("filter-1");
if (fe->id == 0)
return true;
@ -155,7 +155,7 @@ void Filter::unfilter(upx_byte *buf_, unsigned buf_len_, bool verify_checksum)
initFilter(this, buf_, buf_len_);
const FilterImp::FilterEntry * const fe = FilterImp::getFilter(id);
if (fe == NULL)
if (fe == nullptr)
throwInternalError("unfilter-1");
if (fe->id == 0)
return;
@ -207,7 +207,7 @@ bool Filter::scan(const upx_byte *buf_, unsigned buf_len_)
initFilter(this, b, buf_len_);
const FilterImp::FilterEntry * const fe = FilterImp::getFilter(id);
if (fe == NULL)
if (fe == nullptr)
throwInternalError("scan-1");
if (fe->id == 0)
return true;

View File

@ -170,7 +170,7 @@ umin(unsigned const a, unsigned const b)
const FilterImp::FilterEntry FilterImp::filters[] = {
// no filter
{ 0x00, 0, 0, NULL, NULL, NULL },
{ 0x00, 0, 0, nullptr, nullptr, nullptr },
// 16-bit calltrick
{ 0x01, 4, 0, f_ct16_e8, u_ct16_e8, s_ct16_e8 },

View File

@ -107,7 +107,7 @@ struct PackerNames
Entry names[64];
size_t names_count;
const options_t *o;
PackerNames() : names_count(0), o(NULL) { }
PackerNames() : names_count(0), o(nullptr) { }
void add(const Packer *p)
{
p->assertPacker();
@ -120,8 +120,8 @@ struct PackerNames
{
PackerNames *self = (PackerNames *) user;
self->add(p);
delete p; p = NULL;
return NULL;
delete p; p = nullptr;
return nullptr;
}
static int __acc_cdecl_qsort cmp_fname(const void *a, const void *b) {
return strcmp(((const Entry *) a)->fname, ((const Entry *) b)->fname);
@ -135,7 +135,7 @@ static void show_all_packers(FILE *f, int verbose)
{
options_t o; o.reset();
PackerNames pn; pn.o = &o;
PackMaster::visitAllPackers(PackerNames::visit, NULL, &o, &pn);
PackMaster::visitAllPackers(PackerNames::visit, nullptr, &o, &pn);
qsort(pn.names, pn.names_count, sizeof(PackerNames::Entry), PackerNames::cmp_fname);
size_t pos = 0;
for (size_t i = 0; i < pn.names_count; ++i)
@ -389,22 +389,22 @@ void show_version(int x)
);
#if (WITH_NRV)
v = upx_nrv_version_string();
if (v != NULL && v[0])
if (v != nullptr && v[0])
fprintf(fp, "NRV data compression library %s\n", v);
#endif
#if (WITH_UCL)
v = upx_ucl_version_string();
if (v != NULL && v[0])
if (v != nullptr && v[0])
fprintf(fp, "UCL data compression library %s\n", v);
#endif
#if (WITH_ZLIB)
v = upx_zlib_version_string();
if (v != NULL && v[0])
if (v != nullptr && v[0])
fprintf(fp, "zlib data compression library %s\n", v);
#endif
#if (WITH_LZMA)
v = upx_lzma_version_string();
if (v != NULL && v[0])
if (v != nullptr && v[0])
fprintf(fp, "LZMA SDK version %s\n", v);
#endif
fprintf(fp, "Copyright (C) 1996-2020 Markus Franz Xaver Johannes Oberhumer\n");

View File

@ -33,7 +33,7 @@
LeFile::LeFile(InputFile *f) :
fif(f), fof(NULL),
fif(f), fof(nullptr),
le_offset(0), exe_offset(0)
{
COMPILE_TIME_ASSERT(sizeof(le_header_t) == 196);
@ -41,13 +41,13 @@ LeFile::LeFile(InputFile *f) :
COMPILE_TIME_ASSERT(sizeof(le_pagemap_entry_t) == 4);
memset(&ih,0,sizeof ih);
memset(&oh,0,sizeof oh);
iobject_table = oobject_table = NULL;
ifpage_table = ofpage_table = NULL;
ipm_entries = opm_entries = NULL;
ires_names = ores_names = NULL;
ifixups = ofixups = NULL;
inonres_names = ononres_names = NULL;
ientries = oentries = NULL;
iobject_table = oobject_table = nullptr;
ifpage_table = ofpage_table = nullptr;
ipm_entries = opm_entries = nullptr;
ires_names = ores_names = nullptr;
ifixups = ofixups = nullptr;
inonres_names = ononres_names = nullptr;
ientries = oentries = nullptr;
}
@ -206,7 +206,7 @@ void LeFile::readImage()
void LeFile::writeImage()
{
if (fof && oimage != NULL)
if (fof && oimage != nullptr)
fof->write(oimage, soimage);
}

View File

@ -137,42 +137,42 @@ protected:
virtual void readObjectTable();
virtual void writeObjectTable();
//virtual void encodeObjectTable(){oobject_table = iobject_table; iobject_table = NULL;}
//virtual void encodeObjectTable(){oobject_table = iobject_table; iobject_table = nullptr;}
//virtual void decodeObjectTable(){encodeObjectTable();}
virtual void readFixupPageTable();
virtual void writeFixupPageTable();
//virtual void encodeFixupPageTable(){ofpage_table = ifpage_table; ifpage_table = NULL;}
//virtual void encodeFixupPageTable(){ofpage_table = ifpage_table; ifpage_table = nullptr;}
//virtual void decodeFixupPageTable(){encodeFixupPageTable();}
virtual void readPageMap();
virtual void writePageMap();
virtual void encodePageMap(){opm_entries = ipm_entries; ipm_entries = NULL;}
virtual void encodePageMap(){opm_entries = ipm_entries; ipm_entries = nullptr;}
virtual void decodePageMap(){encodePageMap();}
virtual void readResidentNames();
virtual void writeResidentNames();
virtual void encodeResidentNames(){ores_names = ires_names; ires_names = NULL;}
virtual void encodeResidentNames(){ores_names = ires_names; ires_names = nullptr;}
virtual void decodeResidentNames(){encodeResidentNames();}
virtual void readNonResidentNames();
virtual void writeNonResidentNames();
virtual void encodeNonResidentNames(){ononres_names = inonres_names; inonres_names = NULL;}
virtual void encodeNonResidentNames(){ononres_names = inonres_names; inonres_names = nullptr;}
virtual void decodeNonResidentNames(){encodeNonResidentNames();}
virtual void readEntryTable();
virtual void writeEntryTable();
//virtual void encodeEntryTable(){oentries = ientries; ientries = NULL;}
//virtual void encodeEntryTable(){oentries = ientries; ientries = nullptr;}
//virtual void decodeEntryTable(){encodeEntryTable();}
virtual void readFixups();
virtual void writeFixups();
//virtual void encodeFixups(){ofixups = ifixups; ifixups = NULL;}
//virtual void encodeFixups(){ofixups = ifixups; ifixups = nullptr;}
//virtual void decodeFixups(){encodeFixups();}
virtual void readImage();
virtual void writeImage();
//virtual void encodeImage(){oimage = iimage; iimage = NULL;}
//virtual void encodeImage(){oimage = iimage; iimage = nullptr;}
//virtual void decodeImage(){encodeImage();}
void countFixups(unsigned *) const;
@ -214,8 +214,8 @@ protected:
private:
// disable copy and assignment
LeFile(const LeFile &); // {}
LeFile& operator= (const LeFile &); // { return *this; }
LeFile(const LeFile &) = delete;
LeFile& operator= (const LeFile &) = delete;
};

View File

@ -56,11 +56,11 @@ static void __acc_cdecl_va internal_error(const char *format, ...) {
**************************************************************************/
ElfLinker::Section::Section(const char *n, const void *i, unsigned s, unsigned a)
: name(NULL), output(NULL), size(s), offset(0), p2align(a), next(NULL) {
: name(nullptr), output(nullptr), size(s), offset(0), p2align(a), next(nullptr) {
name = strdup(n);
assert(name != NULL);
assert(name != nullptr);
input = malloc(s + 1);
assert(input != NULL);
assert(input != nullptr);
if (s != 0)
memcpy(input, i, s);
((char *) input)[s] = 0;
@ -76,10 +76,10 @@ ElfLinker::Section::~Section() {
**************************************************************************/
ElfLinker::Symbol::Symbol(const char *n, Section *s, upx_uint64_t o)
: name(NULL), section(s), offset(o) {
: name(nullptr), section(s), offset(o) {
name = strdup(n);
assert(name != NULL);
assert(section != NULL);
assert(name != nullptr);
assert(section != nullptr);
}
ElfLinker::Symbol::~Symbol() { free(name); }
@ -91,7 +91,7 @@ ElfLinker::Symbol::~Symbol() { free(name); }
ElfLinker::Relocation::Relocation(const Section *s, unsigned o, const char *t, const Symbol *v,
upx_uint64_t a)
: section(s), offset(o), type(t), value(v), add(a) {
assert(section != NULL);
assert(section != nullptr);
}
/*************************************************************************
@ -99,10 +99,10 @@ ElfLinker::Relocation::Relocation(const Section *s, unsigned o, const char *t, c
**************************************************************************/
ElfLinker::ElfLinker()
: bele(&N_BELE_RTP::le_policy), input(NULL), output(NULL), head(NULL), tail(NULL),
sections(NULL), symbols(NULL), relocations(NULL), nsections(0), nsections_capacity(0),
nsymbols(0), nsymbols_capacity(0), nrelocations(0), nrelocations_capacity(0),
reloc_done(false) {}
: bele(&N_BELE_RTP::le_policy), input(nullptr), output(nullptr), head(nullptr), tail(nullptr),
sections(nullptr), symbols(nullptr), relocations(nullptr), nsections(0),
nsections_capacity(0), nsymbols(0), nsymbols_capacity(0), nrelocations(0),
nrelocations_capacity(0), reloc_done(false) {}
ElfLinker::~ElfLinker() {
delete[] input;
@ -143,7 +143,7 @@ void ElfLinker::init(const void *pdata_v, int plen) {
inputlen = u_len;
input = new upx_byte[inputlen + 1];
unsigned new_len = u_len;
int r = upx_decompress(pdata, c_len, input, &new_len, method, NULL);
int r = upx_decompress(pdata, c_len, input, &new_len, method, nullptr);
if (r == UPX_E_OUT_OF_MEMORY)
throwOutOfMemoryException();
if (r != UPX_E_OK || new_len != u_len)
@ -167,10 +167,10 @@ void ElfLinker::init(const void *pdata_v, int plen) {
char *psections = (char *) input + pos;
char *psymbols = strstr(psections, "SYMBOL TABLE:\n");
assert(psymbols != NULL);
assert(psymbols != nullptr);
char *prelocs = strstr(psymbols, "RELOCATION RECORDS FOR ");
assert(prelocs != NULL);
assert(prelocs != nullptr);
preprocessSections(psections, psymbols);
preprocessSymbols(psymbols, prelocs);
@ -183,7 +183,7 @@ void ElfLinker::preprocessSections(char *start, char *end) {
char *nextl;
for (nsections = 0; start < end; start = 1 + nextl) {
nextl = strchr(start, '\n');
assert(nextl != NULL);
assert(nextl != nullptr);
*nextl = '\0'; // a record is a line
unsigned offset, size, align;
@ -197,15 +197,15 @@ void ElfLinker::preprocessSections(char *start, char *end) {
// printf("section %s preprocessed\n", n);
}
}
addSection("*ABS*", NULL, 0, 0);
addSection("*UND*", NULL, 0, 0);
addSection("*ABS*", nullptr, 0, 0);
addSection("*UND*", nullptr, 0, 0);
}
void ElfLinker::preprocessSymbols(char *start, char *end) {
char *nextl;
for (nsymbols = 0; start < end; start = 1 + nextl) {
nextl = strchr(start, '\n');
assert(nextl != NULL);
assert(nextl != nullptr);
*nextl = '\0'; // a record is a line
unsigned value, offset;
@ -238,11 +238,11 @@ void ElfLinker::preprocessSymbols(char *start, char *end) {
}
void ElfLinker::preprocessRelocations(char *start, char *end) {
Section *section = NULL;
Section *section = nullptr;
char *nextl;
for (nrelocations = 0; start < end; start = 1 + nextl) {
nextl = strchr(start, '\n');
assert(nextl != NULL);
assert(nextl != nullptr);
*nextl = '\0'; // a record is a line
{
@ -261,7 +261,7 @@ void ElfLinker::preprocessRelocations(char *start, char *end) {
upx_uint64_t add = 0;
char *p = strstr(symbol, "+0x");
if (p == NULL)
if (p == nullptr)
p = strstr(symbol, "-0x");
if (p) {
char sign = *p;
@ -275,7 +275,7 @@ void ElfLinker::preprocessRelocations(char *start, char *end) {
else
add = a;
#else
char *endptr = NULL;
char *endptr = nullptr;
add = strtoull(p, &endptr, 16);
assert(endptr && *endptr == '\0');
#endif
@ -298,7 +298,7 @@ ElfLinker::Section *ElfLinker::findSection(const char *name, bool fatal) const {
return sections[ic];
if (fatal)
internal_error("unknown section %s\n", name);
return NULL;
return nullptr;
}
ElfLinker::Symbol *ElfLinker::findSymbol(const char *name, bool fatal) const {
@ -307,7 +307,7 @@ ElfLinker::Symbol *ElfLinker::findSymbol(const char *name, bool fatal) const {
return symbols[ic];
if (fatal)
internal_error("unknown symbol %s\n", name);
return NULL;
return nullptr;
}
ElfLinker::Section *ElfLinker::addSection(const char *sname, const void *sdata, int slen,
@ -320,7 +320,7 @@ ElfLinker::Section *ElfLinker::addSection(const char *sname, const void *sdata,
assert(sname);
assert(sname[0]);
assert(sname[strlen(sname) - 1] != ':');
assert(findSection(sname, false) == NULL);
assert(findSection(sname, false) == nullptr);
Section *sec = new Section(sname, sdata, slen, p2align);
sections[nsections++] = sec;
return sec;
@ -331,11 +331,11 @@ ElfLinker::Symbol *ElfLinker::addSymbol(const char *name, const char *section,
// printf("addSymbol: %s %s 0x%x\n", name, section, offset);
if (update_capacity(nsymbols, &nsymbols_capacity))
symbols = static_cast<Symbol **>(realloc(symbols, nsymbols_capacity * sizeof(Symbol *)));
assert(symbols != NULL);
assert(symbols != nullptr);
assert(name);
assert(name[0]);
assert(name[strlen(name) - 1] != ':');
assert(findSymbol(name, false) == NULL);
assert(findSymbol(name, false) == nullptr);
Symbol *sym = new Symbol(name, findSection(section), offset);
symbols[nsymbols++] = sym;
return sym;
@ -346,7 +346,7 @@ ElfLinker::Relocation *ElfLinker::addRelocation(const char *section, unsigned of
if (update_capacity(nrelocations, &nrelocations_capacity))
relocations = static_cast<Relocation **>(
realloc(relocations, (nrelocations_capacity) * sizeof(Relocation *)));
assert(relocations != NULL);
assert(relocations != nullptr);
Relocation *rel = new Relocation(findSection(section), off, type, findSymbol(symbol), add);
relocations[nrelocations++] = rel;
return rel;
@ -361,7 +361,7 @@ void ElfLinker::setLoaderAlignOffset(int phase)
#endif
int ElfLinker::addLoader(const char *sname) {
assert(sname != NULL);
assert(sname != nullptr);
if (!sname[0])
return outputlen;
@ -420,7 +420,7 @@ int ElfLinker::addLoader(const char *sname) {
}
void ElfLinker::addLoader(const char *s, va_list ap) {
while (s != NULL) {
while (s != nullptr) {
addLoader(s);
s = va_arg(ap, const char *);
}
@ -458,14 +458,14 @@ void ElfLinker::relocate() {
const Relocation *rel = relocations[ic];
upx_uint64_t value = 0;
if (rel->section->output == NULL)
if (rel->section->output == nullptr)
continue;
if (strcmp(rel->value->section->name, "*ABS*") == 0) {
value = rel->value->offset;
} else if (strcmp(rel->value->section->name, "*UND*") == 0 &&
rel->value->offset == 0xdeaddead)
internal_error("undefined symbol '%s' referenced\n", rel->value->name);
else if (rel->value->section->output == NULL)
else if (rel->value->section->output == nullptr)
internal_error("can not apply reloc '%s:%x' without section '%s'\n", rel->section->name,
rel->offset, rel->value->section->name);
else {
@ -500,7 +500,7 @@ void ElfLinker::defineSymbol(const char *name, upx_uint64_t value) {
// debugging support
void ElfLinker::dumpSymbol(const Symbol *symbol, unsigned flags, FILE *fp) const {
if ((flags & 1) && symbol->section->output == NULL)
if ((flags & 1) && symbol->section->output == nullptr)
return;
char d0[16 + 1], d1[16 + 1];
upx_snprintf(d0, sizeof(d0), "%016llx", (upx_uint64_t) symbol->offset);
@ -508,7 +508,7 @@ void ElfLinker::dumpSymbol(const Symbol *symbol, unsigned flags, FILE *fp) const
fprintf(fp, "%-28s 0x%-16s | %-28s 0x%-16s\n", symbol->name, d0, symbol->section->name, d1);
}
void ElfLinker::dumpSymbols(unsigned flags, FILE *fp) const {
if (fp == NULL)
if (fp == nullptr)
fp = stdout;
if ((flags & 2) == 0) {
// default: dump symbols in used section order
@ -531,7 +531,7 @@ void ElfLinker::dumpSymbols(unsigned flags, FILE *fp) const {
upx_uint64_t ElfLinker::getSymbolOffset(const char *name) const {
const Symbol *symbol = findSymbol(name);
if (symbol->section->output == NULL)
if (symbol->section->output == nullptr)
return 0xdeaddead;
return symbol->section->offset + symbol->offset;
}

View File

@ -88,14 +88,14 @@ public:
void __acc_cdecl_va addLoaderVA(const char *s, ...);
#endif
virtual Section *addSection(const char *sname, const void *sdata, int slen, unsigned p2align);
virtual int getSection(const char *sname, int *slen = NULL) const;
virtual int getSection(const char *sname, int *slen = nullptr) const;
virtual int getSectionSize(const char *sname) const;
virtual upx_byte *getLoader(int *llen = NULL) const;
virtual upx_byte *getLoader(int *llen = nullptr) const;
virtual void defineSymbol(const char *name, upx_uint64_t value);
virtual upx_uint64_t getSymbolOffset(const char *) const;
virtual void dumpSymbol(const Symbol *, unsigned flags, FILE *fp) const;
virtual void dumpSymbols(unsigned flags = 0, FILE *fp = NULL) const;
virtual void dumpSymbols(unsigned flags = 0, FILE *fp = nullptr) const;
void alignWithByte(unsigned len, unsigned char b);
virtual void alignCode(unsigned len) { alignWithByte(len, 0); }

View File

@ -280,7 +280,7 @@ static void check_options(int i, int argc)
if (!(opt->cmd == CMD_COMPRESS || opt->cmd == CMD_DECOMPRESS))
opt->backup = 1;
check_not_both(opt->to_stdout, opt->output_name != NULL, "--stdout", "-o");
check_not_both(opt->to_stdout, opt->output_name != nullptr, "--stdout", "-o");
if (opt->to_stdout && opt->cmd == CMD_COMPRESS)
{
fprintf(stderr,"%s: cannot use '--stdout' when compressing\n", argv0);
@ -393,12 +393,12 @@ char* prepare_shortopts(char *buf, const char *n,
static char vopts[1024];
if (v > 0 && v < 1024)
{
if (vopts[v] && strchr(buf,v) == NULL)
if (vopts[v] && strchr(buf,v) == nullptr)
printf("warning: duplicate option %d ('%c')!\n", v, v & 127);
vopts[v] = 1;
}
#endif
if (v > 0 && v < 256 && strchr(buf,v) == NULL)
if (v > 0 && v < 256 && strchr(buf,v) == nullptr)
{
*o++ = (char) v;
if ((longopts->has_arg & 0xf) >= 1)
@ -439,7 +439,7 @@ static int getoptvar(T *var, const T min_value, const T max_value, const char *a
*var = v;
goto done;
error:
if (arg_fatal != NULL)
if (arg_fatal != nullptr)
e_optval(arg_fatal);
done:
return r;
@ -889,163 +889,164 @@ static int do_option(int optc, const char *arg)
static int get_options(int argc, char **argv)
{
constexpr int *N = nullptr;
static const struct mfx_option longopts[] =
{
// commands
{"best", 0x10, 0, 900}, // compress best
{"brute", 0x10, 0, 901}, // compress best, brute force
{"ultra-brute", 0x10, 0, 902}, // compress best, brute force
{"decompress", 0, 0, 'd'}, // decompress
{"fast", 0x10, 0, '1'}, // compress faster
{"fileinfo", 0x10, 0, 909}, // display info about file
{"file-info", 0x10, 0, 909}, // display info about file
{"help", 0, 0, 'h'+256}, // give help
{"license", 0, 0, 'L'}, // display software license
{"list", 0, 0, 'l'}, // list compressed exe
{"test", 0, 0, 't'}, // test compressed file integrity
{"uncompress", 0, 0, 'd'}, // decompress
{"version", 0, 0, 'V'+256}, // display version number
{"best", 0x10, N, 900}, // compress best
{"brute", 0x10, N, 901}, // compress best, brute force
{"ultra-brute", 0x10, N, 902}, // compress best, brute force
{"decompress", 0, N, 'd'}, // decompress
{"fast", 0x10, N, '1'}, // compress faster
{"fileinfo", 0x10, N, 909}, // display info about file
{"file-info", 0x10, N, 909}, // display info about file
{"help", 0, N, 'h'+256}, // give help
{"license", 0, N, 'L'}, // display software license
{"list", 0, N, 'l'}, // list compressed exe
{"test", 0, N, 't'}, // test compressed file integrity
{"uncompress", 0, N, 'd'}, // decompress
{"version", 0, N, 'V'+256}, // display version number
// options
{"force", 0, 0, 'f'}, // force overwrite of output files
{"force-compress", 0, 0, 'f'}, // and compression of suspicious files
{"info", 0, 0, 'i'}, // info mode
{"no-env", 0x10, 0, 519}, // no environment var
{"no-mode", 0x10, 0, 526}, // do not preserve mode (permissions)
{"no-owner", 0x10, 0, 527}, // do not preserve ownership
{"no-progress", 0, 0, 516}, // no progress bar
{"no-time", 0x10, 0, 528}, // do not preserve timestamp
{"output", 0x21, 0, 'o'},
{"quiet", 0, 0, 'q'}, // quiet mode
{"silent", 0, 0, 'q'}, // quiet mode
{"force", 0, N, 'f'}, // force overwrite of output files
{"force-compress", 0, N, 'f'}, // and compression of suspicious files
{"info", 0, N, 'i'}, // info mode
{"no-env", 0x10, N, 519}, // no environment var
{"no-mode", 0x10, N, 526}, // do not preserve mode (permissions)
{"no-owner", 0x10, N, 527}, // do not preserve ownership
{"no-progress", 0, N, 516}, // no progress bar
{"no-time", 0x10, N, 528}, // do not preserve timestamp
{"output", 0x21, N, 'o'},
{"quiet", 0, N, 'q'}, // quiet mode
{"silent", 0, N, 'q'}, // quiet mode
#if 0
// FIXME: to_stdout doesn't work because of console code mess
{"stdout", 0x10, 0, 517}, // write output on standard output
{"to-stdout", 0x10, 0, 517}, // write output on standard output
{"stdout", 0x10, N, 517}, // write output on standard output
{"to-stdout", 0x10, N, 517}, // write output on standard output
#endif
{"verbose", 0, 0, 'v'}, // verbose mode
{"verbose", 0, N, 'v'}, // verbose mode
// debug options
{"debug", 0x10, 0, 'D'},
{"dump-stub-loader" ,0x31, 0, 544}, // for internal debugging
{"fake-stub-version",0x31, 0, 542}, // for internal debugging
{"fake-stub-year" ,0x31, 0, 543}, // for internal debugging
{"disable-random-id",0x10, 0, 545}, // for internal debugging
{"debug", 0x10, N, 'D'},
{"dump-stub-loader" ,0x31, N, 544}, // for internal debugging
{"fake-stub-version",0x31, N, 542}, // for internal debugging
{"fake-stub-year" ,0x31, N, 543}, // for internal debugging
{"disable-random-id",0x10, N, 545}, // for internal debugging
// backup options
{"backup", 0x10, 0, 'k'},
{"keep", 0x10, 0, 'k'},
{"no-backup", 0x10, 0, 541},
{"backup", 0x10, N, 'k'},
{"keep", 0x10, N, 'k'},
{"no-backup", 0x10, N, 541},
// overlay options
{"overlay", 0x31, 0, 551}, // --overlay=
{"skip-overlay", 0x10, 0, 552},
{"no-overlay", 0x10, 0, 552}, // old name
{"copy-overlay", 0x10, 0, 553},
{"strip-overlay", 0x10, 0, 554},
{"overlay", 0x31, N, 551}, // --overlay=
{"skip-overlay", 0x10, N, 552},
{"no-overlay", 0x10, N, 552}, // old name
{"copy-overlay", 0x10, N, 553},
{"strip-overlay", 0x10, N, 554},
// CPU options
{"cpu", 0x31, 0, 560}, // --cpu=
{"8086", 0x10, 0, 561},
{"386", 0x10, 0, 563},
{"486", 0x10, 0, 564},
{"cpu", 0x31, N, 560}, // --cpu=
{"8086", 0x10, N, 561},
{"386", 0x10, N, 563},
{"486", 0x10, N, 564},
// color options
{"no-color", 0x10, 0, 512},
{"mono", 0x10, 0, 513},
{"color", 0x10, 0, 514},
{"no-color", 0x10, N, 512},
{"mono", 0x10, N, 513},
{"color", 0x10, N, 514},
// compression method
{"nrv2b", 0x10, 0, 702}, // --nrv2b
{"nrv2d", 0x10, 0, 704}, // --nrv2d
{"nrv2e", 0x10, 0, 705}, // --nrv2e
{"lzma", 0x10, 0, 721}, // --lzma
{"no-lzma", 0x10, 0, 722}, // disable all_methods_use_lzma
{"prefer-nrv", 0x10, 0, 723},
{"prefer-ucl", 0x10, 0, 724},
{"nrv2b", 0x10, N, 702}, // --nrv2b
{"nrv2d", 0x10, N, 704}, // --nrv2d
{"nrv2e", 0x10, N, 705}, // --nrv2e
{"lzma", 0x10, N, 721}, // --lzma
{"no-lzma", 0x10, N, 722}, // disable all_methods_use_lzma
{"prefer-nrv", 0x10, N, 723},
{"prefer-ucl", 0x10, N, 724},
// compression settings
{"all-filters", 0x10, 0, 523},
{"all-methods", 0x10, 0, 524},
{"exact", 0x10, 0, 525}, // user requires byte-identical decompression
{"filter", 0x31, 0, 521}, // --filter=
{"no-filter", 0x10, 0, 522},
{"small", 0x10, 0, 520},
{"all-filters", 0x10, N, 523},
{"all-methods", 0x10, N, 524},
{"exact", 0x10, N, 525}, // user requires byte-identical decompression
{"filter", 0x31, N, 521}, // --filter=
{"no-filter", 0x10, N, 522},
{"small", 0x10, N, 520},
// compression runtime parameters
{"crp-nrv-cf", 0x31, 0, 801},
{"crp-nrv-sl", 0x31, 0, 802},
{"crp-nrv-hl", 0x31, 0, 803},
{"crp-nrv-pl", 0x31, 0, 804},
{"crp-nrv-mo", 0x31, 0, 805},
{"crp-nrv-mm", 0x31, 0, 806},
{"crp-nrv-ms", 0x31, 0, 807},
{"crp-ucl-cf", 0x31, 0, 801},
{"crp-ucl-sl", 0x31, 0, 802},
{"crp-ucl-hl", 0x31, 0, 803},
{"crp-ucl-pl", 0x31, 0, 804},
{"crp-ucl-mo", 0x31, 0, 805},
{"crp-ucl-mm", 0x31, 0, 806},
{"crp-ucl-ms", 0x31, 0, 807},
{"crp-lzma-pb", 0x31, 0, 811},
{"crp-lzma-lp", 0x31, 0, 812},
{"crp-lzma-lc", 0x31, 0, 813},
{"crp-lzma-ds", 0x31, 0, 814},
{"crp-lzma-fb", 0x31, 0, 816},
{"crp-zlib-ml", 0x31, 0, 821},
{"crp-zlib-wb", 0x31, 0, 822},
{"crp-zlib-st", 0x31, 0, 823},
{"crp-nrv-cf", 0x31, N, 801},
{"crp-nrv-sl", 0x31, N, 802},
{"crp-nrv-hl", 0x31, N, 803},
{"crp-nrv-pl", 0x31, N, 804},
{"crp-nrv-mo", 0x31, N, 805},
{"crp-nrv-mm", 0x31, N, 806},
{"crp-nrv-ms", 0x31, N, 807},
{"crp-ucl-cf", 0x31, N, 801},
{"crp-ucl-sl", 0x31, N, 802},
{"crp-ucl-hl", 0x31, N, 803},
{"crp-ucl-pl", 0x31, N, 804},
{"crp-ucl-mo", 0x31, N, 805},
{"crp-ucl-mm", 0x31, N, 806},
{"crp-ucl-ms", 0x31, N, 807},
{"crp-lzma-pb", 0x31, N, 811},
{"crp-lzma-lp", 0x31, N, 812},
{"crp-lzma-lc", 0x31, N, 813},
{"crp-lzma-ds", 0x31, N, 814},
{"crp-lzma-fb", 0x31, N, 816},
{"crp-zlib-ml", 0x31, N, 821},
{"crp-zlib-wb", 0x31, N, 822},
{"crp-zlib-st", 0x31, N, 823},
// [deprecated - only for compatibility with UPX 2.0x]
{"crp-ms", 0x31, 0, 807},
{"crp-ms", 0x31, N, 807},
// atari/tos
{"split-segments", 0x10, 0, 650},
{"split-segments", 0x10, N, 650},
// djgpp2/coff
{"coff", 0x10, 0, 610}, // produce COFF output
{"coff", 0x10, N, 610}, // produce COFF output
// dos/com
// dos/exe
//{"force-stub", 0x10, 0, 600},
{"no-reloc", 0x10, 0, 601}, // no reloc. record into packer dos/exe
{"no-reloc", 0x10, N, 601}, // no reloc. record into packer dos/exe
// dos/sys
// unix
{"blocksize", 0x31, 0, 660}, // --blocksize=
{"force-execve", 0x10, 0, 661}, // force linux/386 execve format
{"is_ptinterp", 0x10, 0, 663}, // linux/elf386 PT_INTERP program
{"use_ptinterp", 0x10, 0, 664}, // linux/elf386 PT_INTERP program
{"make_ptinterp", 0x10, 0, 665}, // linux/elf386 PT_INTERP program
{"Linux", 0x10, 0, 666},
{"linux", 0x10, 0, 666},
{"FreeBSD", 0x10, 0, 667},
{"freebsd", 0x10, 0, 667},
{"NetBSD", 0x10, 0, 668},
{"netbsd", 0x10, 0, 668},
{"OpenBSD", 0x10, 0, 669},
{"openbsd", 0x10, 0, 669},
{"unmap-all-pages", 0x10, 0, 674}, // linux /proc/self/exe vanishes
{"preserve-build-id", 0, 0, 675},
{"android-shlib", 0, 0, 676},
{"force-pie", 0, 0, 677},
{"blocksize", 0x31, N, 660}, // --blocksize=
{"force-execve", 0x10, N, 661}, // force linux/386 execve format
{"is_ptinterp", 0x10, N, 663}, // linux/elf386 PT_INTERP program
{"use_ptinterp", 0x10, N, 664}, // linux/elf386 PT_INTERP program
{"make_ptinterp", 0x10, N, 665}, // linux/elf386 PT_INTERP program
{"Linux", 0x10, N, 666},
{"linux", 0x10, N, 666},
{"FreeBSD", 0x10, N, 667},
{"freebsd", 0x10, N, 667},
{"NetBSD", 0x10, N, 668},
{"netbsd", 0x10, N, 668},
{"OpenBSD", 0x10, N, 669},
{"openbsd", 0x10, N, 669},
{"unmap-all-pages", 0x10, N, 674}, // linux /proc/self/exe vanishes
{"preserve-build-id", 0, N, 675},
{"android-shlib", 0, N, 676},
{"force-pie", 0, N, 677},
// watcom/le
{"le", 0x10, 0, 620}, // produce LE output
{"le", 0x10, N, 620}, // produce LE output
// win32/pe
{"compress-exports", 2, 0, 630},
{"compress-icons", 2, 0, 631},
{"compress-resources", 2, 0, 632},
{"strip-loadconf", 0x12, 0, 633}, // OBSOLETE - IGNORED
{"strip-relocs", 0x12, 0, 634},
{"keep-resource", 0x31, 0, 635},
{"compress-exports", 2, N, 630},
{"compress-icons", 2, N, 631},
{"compress-resources", 2, N, 632},
{"strip-loadconf", 0x12, N, 633}, // OBSOLETE - IGNORED
{"strip-relocs", 0x12, N, 634},
{"keep-resource", 0x31, N, 635},
// ps1/exe
{"boot-only", 0x10, 0, 670},
{"no-align", 0x10, 0, 671},
{"8-bit", 0x10, 0, 672},
{"8mib-ram", 0x10, 0, 673},
{"8mb-ram", 0x10, 0, 673},
{"boot-only", 0x10, N, 670},
{"no-align", 0x10, N, 671},
{"8-bit", 0x10, N, 672},
{"8mib-ram", 0x10, N, 673},
{"8mb-ram", 0x10, N, 673},
// mp (meta) options
{"mp-compress-task", 0x31, 0, 501},
{"mp-query-format", 0x10, 0, 502},
{"mp-query-num-tasks", 0x10, 0, 503},
{"mp-compress-task", 0x31, N, 501},
{"mp-query-format", 0x10, N, 502},
{"mp-query-num-tasks", 0x10, N, 503},
{ NULL, 0, NULL, 0 }
{ nullptr, 0, nullptr, 0 }
};
int optc, longind;
@ -1069,88 +1070,89 @@ static const struct mfx_option longopts[] =
#if defined(OPTIONS_VAR)
static void get_envoptions(int argc, char **argv)
{
constexpr int *N = nullptr;
/* only some options are allowed in the environment variable */
static const struct mfx_option longopts[] =
{
// commands
{"best", 0x10, 0, 900}, // compress best
{"brute", 0x10, 0, 901}, // compress best, brute force
{"ultra-brute", 0x10, 0, 902}, // compress best, brute force
{"fast", 0x10, 0, '1'}, // compress faster
{"best", 0x10, N, 900}, // compress best
{"brute", 0x10, N, 901}, // compress best, brute force
{"ultra-brute", 0x10, N, 902}, // compress best, brute force
{"fast", 0x10, N, '1'}, // compress faster
// options
{"info", 0, 0, 'i'}, // info mode
{"no-progress", 0, 0, 516}, // no progress bar
{"quiet", 0, 0, 'q'}, // quiet mode
{"silent", 0, 0, 'q'}, // quiet mode
{"verbose", 0, 0, 'v'}, // verbose mode
{"info", 0, N, 'i'}, // info mode
{"no-progress", 0, N, 516}, // no progress bar
{"quiet", 0, N, 'q'}, // quiet mode
{"silent", 0, N, 'q'}, // quiet mode
{"verbose", 0, N, 'v'}, // verbose mode
// debug options
{"disable-random-id",0x10, 0, 545}, // for internal debugging
{"disable-random-id",0x10, N, 545}, // for internal debugging
// backup options
{"backup", 0x10, 0, 'k'},
{"keep", 0x10, 0, 'k'},
{"no-backup", 0x10, 0, 541},
{"backup", 0x10, N, 'k'},
{"keep", 0x10, N, 'k'},
{"no-backup", 0x10, N, 541},
// overlay options
{"overlay", 0x31, 0, 551}, // --overlay=
{"skip-overlay", 0x10, 0, 552},
{"no-overlay", 0x10, 0, 552}, // old name
{"copy-overlay", 0x10, 0, 553},
{"strip-overlay", 0x10, 0, 554},
{"overlay", 0x31, N, 551}, // --overlay=
{"skip-overlay", 0x10, N, 552},
{"no-overlay", 0x10, N, 552}, // old name
{"copy-overlay", 0x10, N, 553},
{"strip-overlay", 0x10, N, 554},
// CPU options
{"cpu", 0x31, 0, 560}, // --cpu=
{"8086", 0x10, 0, 561},
{"386", 0x10, 0, 563},
{"486", 0x10, 0, 564},
{"cpu", 0x31, N, 560}, // --cpu=
{"8086", 0x10, N, 561},
{"386", 0x10, N, 563},
{"486", 0x10, N, 564},
// color options
{"no-color", 0x10, 0, 512},
{"mono", 0x10, 0, 513},
{"color", 0x10, 0, 514},
{"no-color", 0x10, N, 512},
{"mono", 0x10, N, 513},
{"color", 0x10, N, 514},
// compression settings
{"exact", 0x10, 0, 525}, // user requires byte-identical decompression
{"exact", 0x10, N, 525}, // user requires byte-identical decompression
// compression method
{"nrv2b", 0x10, 0, 702}, // --nrv2b
{"nrv2d", 0x10, 0, 704}, // --nrv2d
{"nrv2e", 0x10, 0, 705}, // --nrv2e
{"lzma", 0x10, 0, 721}, // --lzma
{"no-lzma", 0x10, 0, 722}, // disable all_methods_use_lzma
{"prefer-nrv", 0x10, 0, 723},
{"prefer-ucl", 0x10, 0, 724},
{"nrv2b", 0x10, N, 702}, // --nrv2b
{"nrv2d", 0x10, N, 704}, // --nrv2d
{"nrv2e", 0x10, N, 705}, // --nrv2e
{"lzma", 0x10, N, 721}, // --lzma
{"no-lzma", 0x10, N, 722}, // disable all_methods_use_lzma
{"prefer-nrv", 0x10, N, 723},
{"prefer-ucl", 0x10, N, 724},
// compression settings
// compression runtime parameters
// win32/pe
{"compress-exports", 2, 0, 630},
{"compress-icons", 2, 0, 631},
{"compress-resources", 2, 0, 632},
{"strip-loadconf", 0x12, 0, 633}, // OBSOLETE - IGNORED
{"strip-relocs", 0x12, 0, 634},
{"keep-resource", 0x31, 0, 635},
{"compress-exports", 2, N, 630},
{"compress-icons", 2, N, 631},
{"compress-resources", 2, N, 632},
{"strip-loadconf", 0x12, N, 633}, // OBSOLETE - IGNORED
{"strip-relocs", 0x12, N, 634},
{"keep-resource", 0x31, N, 635},
{ NULL, 0, NULL, 0 }
{ nullptr, 0, nullptr, 0 }
};
char *env, *p;
const char *var;
int i, optc, longind;
int targc;
char **targv = NULL;
char **targv = nullptr;
static const char sep[] = " \t";
char shortopts[256];
var = getenv(OPTIONS_VAR);
if (var == NULL || !var[0])
if (var == nullptr || !var[0])
return;
env = strdup(var);
if (env == NULL)
if (env == nullptr)
return;
/* count arguments */
@ -1171,7 +1173,7 @@ static const struct mfx_option longopts[] =
/* alloc temp argv */
if (targc > 1)
targv = (char **) calloc(targc+1,sizeof(char *));
if (targv == NULL)
if (targv == nullptr)
{
free(env);
return;
@ -1192,7 +1194,7 @@ static const struct mfx_option longopts[] =
break;
*p++ = '\0';
}
targv[targc] = NULL;
targv[targc] = nullptr;
/* check that only options are in temp argv */
for (i = 1; i < targc; i++)
@ -1207,7 +1209,7 @@ static const struct mfx_option longopts[] =
while ((optc = acc_getopt(&mfx_getopt, shortopts, longopts, &longind)) >= 0)
{
if (do_option(optc, targv[mfx_optind-1]) != 0)
e_envopt(NULL);
e_envopt(nullptr);
}
if (mfx_optind < targc)
@ -1472,7 +1474,7 @@ int __acc_cdecl_main main(int argc, char *argv[])
assert(upx_nrv_init() == 0);
#endif
//srand((int) time(NULL));
//srand((int) time(nullptr));
srand((int) clock());
/* get options */
@ -1484,7 +1486,7 @@ int __acc_cdecl_main main(int argc, char *argv[])
i = get_options(argc,argv);
assert(i <= argc);
set_term(NULL);
set_term(nullptr);
// cmdline_cmd = opt->cmd;
switch (opt->cmd)
{

View File

@ -62,7 +62,7 @@ __acc_static_forceinline bool use_simple_mcheck() { return true; }
**************************************************************************/
MemBuffer::MemBuffer(upx_uint64_t size) :
b(NULL), b_size(0)
b(nullptr), b_size(0)
{
alloc(size);
}
@ -87,7 +87,7 @@ unsigned char *MemBuffer::subref(char const *errfmt, unsigned skip, unsigned tak
void MemBuffer::dealloc()
{
if (b != NULL)
if (b != nullptr)
{
checkState();
if (use_simple_mcheck())
@ -102,7 +102,7 @@ void MemBuffer::dealloc()
}
else
::free(b);
b = NULL;
b = nullptr;
b_size = 0;
}
else
@ -186,7 +186,7 @@ void MemBuffer::checkState() const
void MemBuffer::alloc(upx_uint64_t size)
{
// NOTE: we don't automatically free a used buffer
assert(b == NULL);
assert(b == nullptr);
assert(b_size == 0);
//
assert(size > 0);

View File

@ -37,7 +37,7 @@
class MemBuffer
{
public:
MemBuffer() : b(NULL), b_size(0) { }
MemBuffer() : b(nullptr), b_size(0) { }
explicit MemBuffer(upx_uint64_t size);
~MemBuffer();
@ -76,8 +76,8 @@ private:
static unsigned global_alloc_counter;
// disable copy and assignment
MemBuffer(const MemBuffer &); // {}
MemBuffer& operator= (const MemBuffer &); // { return *this; }
MemBuffer(const MemBuffer &) = delete;
MemBuffer& operator= (const MemBuffer &) = delete;
// disable dynamic allocation
DISABLE_NEW_DELETE

View File

@ -4812,13 +4812,13 @@ typedef unsigned short wchar_t;
#define _WCHAR_T_DEFINED 1
#endif
#endif
#ifndef NULL
#ifndef nullptr
#if defined(__cplusplus) && defined(__GNUC__) && (__GNUC__ >= 4)
#define NULL __null
#define nullptr __null
#elif defined(__cplusplus)
#define NULL 0
#define nullptr 0
#else
#define NULL ((void*)0)
#define nullptr ((void*)0)
#endif
#endif
#ifndef offsetof
@ -6756,7 +6756,7 @@ static int __ACCLIB_FUNCNAME(acc_getopt_perror) (acc_getopt_p g, int ret, const
g->opterr(g, f, &s);
va_end(s.ap);
#else
g->opterr(g, f, NULL);
g->opterr(g, f, nullptr);
#endif
}
++g->errcount;
@ -6777,7 +6777,7 @@ ACCLIB_PUBLIC(int, acc_getopt) (acc_getopt_p g,
if (*shortopts == ':')
missing_arg_ret = *shortopts++;
}
g->optarg = NULL;
g->optarg = nullptr;
if (g->optopt == -1)
g->optopt = g->bad_option;
if (longind)
@ -6801,8 +6801,8 @@ ACCLIB_PUBLIC(int, acc_getopt) (acc_getopt_p g,
if (a[0] == '-' && a[1] == '-') {
size_t l = 0;
const acc_getopt_longopt_p o;
const acc_getopt_longopt_p o1 = NULL;
const acc_getopt_longopt_p o2 = NULL;
const acc_getopt_longopt_p o1 = nullptr;
const acc_getopt_longopt_p o2 = nullptr;
int need_exact = 0;
++g->optind;
if (!a[2])
@ -6864,7 +6864,7 @@ ACCLIB_PUBLIC(int, acc_getopt) (acc_getopt_p g,
const char *s;
acc_label_next_shortopt:
a = g->argv[g->optind] + ++g->shortpos;
c = (unsigned char) *a++; s = NULL;
c = (unsigned char) *a++; s = nullptr;
if (c != ':' && shortopts)
s = strchr(shortopts, c);
if (!s || s[1] != ':') {
@ -7235,7 +7235,7 @@ static int acc_pclock_read_clock_gettime_r_syscall(acc_pclock_handle_p h, acc_pc
static int acc_pclock_read_gettimeofday(acc_pclock_handle_p h, acc_pclock_p c)
{
struct timeval tv;
if (gettimeofday(&tv, NULL) != 0)
if (gettimeofday(&tv, nullptr) != 0)
return -1;
#if defined(acc_int64l_t)
c->tv_sec = tv.tv_sec;
@ -7428,7 +7428,7 @@ ACCLIB_PUBLIC(int, acc_pclock_open) (acc_pclock_handle_p h, int mode)
h->h = ACC_STATIC_CAST(acclib_handle_t, 0);
h->mode = -1;
h->read_error = 2;
h->name = NULL;
h->name = nullptr;
h->gettime = ACC_STATIC_CAST(acc_pclock_gettime_t, 0);
#if defined(acc_int64l_t)
h->ticks_base = 0;
@ -7556,7 +7556,7 @@ ACCLIB_PUBLIC(int, acc_pclock_close) (acc_pclock_handle_p h)
{
h->h = ACC_STATIC_CAST(acclib_handle_t, 0);
h->mode = -1;
h->name = NULL;
h->name = nullptr;
h->gettime = ACC_STATIC_CAST(acc_pclock_gettime_t, 0);
return 0;
}

View File

@ -55,7 +55,7 @@ void printClearLine(FILE *f)
}
fflush(stdout); fflush(stderr);
if (f == NULL)
if (f == nullptr)
f = stdout;
con_fprintf(f, "%s", clear_line_msg);
fflush(f);

View File

@ -145,38 +145,38 @@ void PackArmPe::buildLoader(const Filter *ft)
initLoader(loader, size);
if (isdll)
addLoader("DllStart", NULL);
addLoader("ExeStart", NULL);
addLoader("DllStart", nullptr);
addLoader("ExeStart", nullptr);
if (ph.method == M_NRV2E_8)
addLoader("Call2E", NULL);
addLoader("Call2E", nullptr);
else if (ph.method == M_NRV2B_8)
addLoader("Call2B", NULL);
addLoader("Call2B", nullptr);
else if (ph.method == M_NRV2D_8)
addLoader("Call2D", NULL);
addLoader("Call2D", nullptr);
else if (M_IS_LZMA(ph.method))
addLoader("+40C,CallLZMA", NULL);
addLoader("+40C,CallLZMA", nullptr);
if (ft->id == 0x50)
addLoader("+40C,Unfilter_0x50", NULL);
addLoader("+40C,Unfilter_0x50", nullptr);
if (sorelocs)
addLoader("+40C,Relocs", NULL);
addLoader("+40C,Relocs", nullptr);
addLoader("+40C,Imports", NULL);
addLoader("ProcessEnd", NULL);
addLoader("+40C,Imports", nullptr);
addLoader("ProcessEnd", nullptr);
if (ph.method == M_NRV2E_8)
addLoader(".ucl_nrv2e_decompress_8", NULL);
addLoader(".ucl_nrv2e_decompress_8", nullptr);
else if (ph.method == M_NRV2B_8)
addLoader(".ucl_nrv2b_decompress_8", NULL);
addLoader(".ucl_nrv2b_decompress_8", nullptr);
else if (ph.method == M_NRV2D_8)
addLoader(".ucl_nrv2d_decompress_8", NULL);
addLoader(".ucl_nrv2d_decompress_8", nullptr);
else if (M_IS_LZMA(ph.method))
addLoader("+40C,LZMA_DECODE,LZMA_DEC10", NULL);
addLoader("+40C,LZMA_DECODE,LZMA_DEC10", nullptr);
addLoader("IDENTSTR,UPX1HEAD", NULL);
addLoader("IDENTSTR,UPX1HEAD", nullptr);
}
bool PackArmPe::handleForceOption()
@ -197,7 +197,7 @@ void PackArmPe::callCompressWithFilters(Filter &ft, int filter_strategy, unsigne
upx_compress_config_t cconf; cconf.reset();
cconf.conf_lzma.max_num_probs = 1846 + (768 << 4); // ushort: ~28 KiB stack
compressWithFilters(&ft, 2048, &cconf, filter_strategy,
ih_codebase, rvamin, 0, NULL, 0);
ih_codebase, rvamin, 0, nullptr, 0);
}
void PackArmPe::addNewRelocations(Reloc &rel, unsigned upxsection)

View File

@ -143,7 +143,7 @@ void PackCom::buildLoader(const Filter *ft)
"NRVDECO1",
ph.max_offset_found <= 0xd00 ? "NRVLED00" : "NRVGTD00",
"NRVDECO2",
NULL
nullptr
);
if (ft->id)
{
@ -164,7 +164,7 @@ void PackCom::addFilter16(int filter_id)
filter_id < 4 ? "" : (opt->cpu == opt->CPU_8086 ? "CT16I086" : "CT16I286,CT16SUB0"),
"CALLTRI2",
getFormat() == UPX_F_DOS_COM ? "CORETURN" : "",
NULL
nullptr
);
else
addLoader(filter_id%3 == 1 ? "CT16E800" : "CT16E900",
@ -173,7 +173,7 @@ void PackCom::addFilter16(int filter_id)
filter_id < 4 ? "CT16SUB1" : "",
filter_id < 4 ? "" : (opt->cpu == opt->CPU_8086 ? "CT16I087" : "CT16I287,CT16SUB1"),
"CALLTRI6",
NULL
nullptr
);
}

View File

@ -103,15 +103,15 @@ void PackDjgpp2::buildLoader(const Filter *ft)
getDecompressorSections(),
M_IS_LZMA(ph.method) ? "LZMA_DONE_STACK" : "",
"DJ2BSS00",
NULL
nullptr
);
if (ft->id)
{
assert(ft->calls > 0);
addLoader("DJCALLT2", NULL);
addLoader("DJCALLT2", nullptr);
addFilter32(ft->id);
}
addLoader("DJRETURN,+40C,UPX1HEAD", NULL);
addLoader("DJRETURN,+40C,UPX1HEAD", nullptr);
}

View File

@ -72,7 +72,7 @@ const int *PackExe::getCompressionMethods(int method, int level) const
const int *PackExe::getFilters() const
{
return NULL;
return nullptr;
}
@ -119,7 +119,7 @@ int PackExe::fillExeHeader(struct exe_header_t *eh) const
void PackExe::addLoaderEpilogue(int flag)
{
addLoader("EXEMAIN5", NULL);
addLoader("EXEMAIN5", nullptr);
if (relocsize)
addLoader(ph.u_len <= DI_LIMIT || (ph.u_len & 0x7fff) >= relocsize ? "EXENOADJ" : "EXEADJUS",
"EXERELO1",
@ -127,19 +127,19 @@ void PackExe::addLoaderEpilogue(int flag)
"EXERELO2",
ih_exesize > 0xFE00 ? "EXEREBIG" : "",
"EXERELO3",
NULL
nullptr
);
addLoader("EXEMAIN8",
device_driver ? "DEVICEEND" : "",
(flag & SS) ? "EXESTACK" : "",
(flag & SP) ? "EXESTASP" : "",
(flag & USEJUMP) ? "EXEJUMPF" : "",
NULL
nullptr
);
if (!(flag & USEJUMP))
addLoader(ih.cs ? "EXERCSPO" : "",
"EXERETIP",
NULL
nullptr
);
linker->defineSymbol("original_cs", ih.cs);
@ -167,7 +167,7 @@ void PackExe::buildLoader(const Filter *)
use_clear_dirty_stack ? "LZMA_DEC31" : "",
"LZMA_DEC32",
ph.u_len > 0xffff ? "LZMA_DEC33" : "",
NULL
nullptr
);
addLoaderEpilogue(flag);
@ -196,7 +196,7 @@ void PackExe::buildLoader(const Filter *)
compressed_lzma.allocForCompression(lsize);
unsigned c_len_lzma = MemBuffer::getSizeForCompression(lsize);
int r = upx_compress(loader, lsize, compressed_lzma, &c_len_lzma,
NULL, M_NRV2B_LE16, 9, NULL, NULL);
nullptr, M_NRV2B_LE16, 9, nullptr, nullptr);
assert(r == UPX_E_OK); assert(c_len_lzma < lsize);
info("lzma+relocator code compressed: %u -> %u", lsize, c_len_lzma);
@ -204,15 +204,15 @@ void PackExe::buildLoader(const Filter *)
initLoader(stub_i086_dos16_exe, sizeof(stub_i086_dos16_exe));
// prepare loader
if (device_driver)
addLoader("DEVICEENTRY,LZMADEVICE,DEVICEENTRY2", NULL);
addLoader("DEVICEENTRY,LZMADEVICE,DEVICEENTRY2", nullptr);
linker->addSection("COMPRESSED_LZMA", compressed_lzma, c_len_lzma, 0);
addLoader("LZMAENTRY,NRV2B160,NRVDDONE,NRVDECO1,NRVGTD00,NRVDECO2",
NULL);
nullptr);
}
else if (device_driver)
addLoader("DEVICEENTRY,DEVICEENTRY2", NULL);
addLoader("DEVICEENTRY,DEVICEENTRY2", nullptr);
addLoader("EXEENTRY",
M_IS_LZMA(ph.method) && device_driver ? "LONGSUB" : "SHORTSUB",
@ -223,7 +223,7 @@ void PackExe::buildLoader(const Filter *)
"EXEMAIN4C",
M_IS_LZMA(ph.method) ? "COMPRESSED_LZMA_START,COMPRESSED_LZMA" : "",
"+G5DXXXX,UPX1HEAD,EXECUTPO",
NULL
nullptr
);
if (ph.method == M_NRV2B_8)
addLoader("NRV2B16S", // decompressor
@ -235,7 +235,7 @@ void PackExe::buildLoader(const Filter *)
"NRV2BEX3",
ph.c_len > 0xffff ? "N2B64K02" : "",
"NRV2BEX9",
NULL
nullptr
);
else if (ph.method == M_NRV2D_8)
addLoader("NRV2D16S",
@ -247,7 +247,7 @@ void PackExe::buildLoader(const Filter *)
"NRV2DEX3",
ph.c_len > 0xffff ? "N2D64K02" : "",
"NRV2DEX9",
NULL
nullptr
);
else if (ph.method == M_NRV2E_8)
addLoader("NRV2E16S",
@ -259,7 +259,7 @@ void PackExe::buildLoader(const Filter *)
"NRV2EEX3",
ph.c_len > 0xffff ? "N2E64K02" : "",
"NRV2EEX9",
NULL
nullptr
);
else if M_IS_LZMA(ph.method)
return;
@ -495,7 +495,7 @@ void PackExe::pack(OutputFile *fo)
upx_byte out[9*relocsize/8+1024];
unsigned in_len = relocsize;
unsigned out_len = 0;
ucl_nrv2b_99_compress(w, in_len, out, &out_len, NULL, 9, NULL, NULL);
ucl_nrv2b_99_compress(w, in_len, out, &out_len, nullptr, 9, nullptr, nullptr);
printf("reloc compress: %d -> %d\n", in_len, out_len);
#endif
}

View File

@ -120,7 +120,7 @@ funpad4(InputFile *fi)
static void alloc_file_image(MemBuffer &mb, off_t size)
{
assert(mem_size_valid_bytes(size));
if (mb.getVoidPtr() == NULL) {
if (mb.getVoidPtr() == nullptr) {
mb.alloc(size);
} else {
assert((u32_t)size <= mb.getSize());
@ -225,13 +225,13 @@ PackLinuxElf64::checkEhdr(Elf64_Ehdr const *ehdr) const
}
PackLinuxElf::PackLinuxElf(InputFile *f)
: super(f), e_phnum(0), dynstr(NULL),
: super(f), e_phnum(0), dynstr(nullptr),
sz_phdrs(0), sz_elf_hdrs(0), sz_pack2(0), sz_pack2a(0),
lg2_page(12), page_size(1u<<lg2_page), is_pie(0),
xct_off(0), xct_va(0), jni_onload_va(0),
user_init_va(0), user_init_off(0),
e_machine(0), ei_class(0), ei_data(0), ei_osabi(0), osabi_note(NULL),
shstrtab(NULL),
e_machine(0), ei_class(0), ei_data(0), ei_osabi(0), osabi_note(nullptr),
shstrtab(nullptr),
o_elf_shnum(0)
{
memset(dt_table, 0, sizeof(dt_table));
@ -293,7 +293,7 @@ PackLinuxElf32::PackLinuxElf32help1(InputFile *f)
phdri= (Elf32_Phdr *)(e_phoff + file_image); // do not free() !!
shdri= (Elf32_Shdr *)(e_shoff + file_image); // do not free() !!
if (opt->cmd != CMD_COMPRESS) {
shdri = NULL;
shdri = nullptr;
}
sec_dynsym = elf_find_section_type(Elf32_Shdr::SHT_DYNSYM);
if (sec_dynsym) {
@ -409,7 +409,7 @@ off_t PackLinuxElf32::pack3(OutputFile *fo, Filter &ft)
if (x.size) {
x.offset = get_te32(&phdri[k].p_offset) +
get_te32(&phdri[k].p_filesz);
packExtent(x, total_in, total_out, 0, fo);
packExtent(x, total_in, total_out, nullptr, fo);
}
}
// write block end marker (uncompressed size 0)
@ -533,7 +533,7 @@ off_t PackLinuxElf64::pack3(OutputFile *fo, Filter &ft)
if (x.size) {
x.offset = get_te64(&phdri[k].p_offset) +
get_te64(&phdri[k].p_filesz);
packExtent(x, total_in, total_out, 0, fo);
packExtent(x, total_in, total_out, nullptr, fo);
}
}
// write block end marker (uncompressed size 0)
@ -651,38 +651,38 @@ off_t PackLinuxElf64::pack3(OutputFile *fo, Filter &ft)
void
PackLinuxElf::addStubEntrySections(Filter const *)
{
addLoader("ELFMAINX", NULL);
addLoader("ELFMAINX", nullptr);
if (hasLoaderSection("ELFMAINXu")) {
// brk() trouble if static
addLoader("ELFMAINXu", NULL);
addLoader("ELFMAINXu", nullptr);
}
//addLoader(getDecompressorSections(), NULL);
//addLoader(getDecompressorSections(), nullptr);
addLoader(
( M_IS_NRV2E(ph.method) ? "NRV_HEAD,NRV2E,NRV_TAIL"
: M_IS_NRV2D(ph.method) ? "NRV_HEAD,NRV2D,NRV_TAIL"
: M_IS_NRV2B(ph.method) ? "NRV_HEAD,NRV2B,NRV_TAIL"
: M_IS_LZMA(ph.method) ? "LZMA_ELF00,LZMA_DEC20,LZMA_DEC30"
: NULL), NULL);
: nullptr), nullptr);
if (hasLoaderSection("CFLUSH"))
addLoader("CFLUSH");
addLoader("ELFMAINY,IDENTSTR", NULL);
addLoader("ELFMAINY,IDENTSTR", nullptr);
if (hasLoaderSection("ELFMAINZe")) { // ppc64 big-endian only
addLoader("ELFMAINZe", NULL);
addLoader("ELFMAINZe", nullptr);
}
addLoader("+40,ELFMAINZ", NULL);
addLoader("+40,ELFMAINZ", nullptr);
if (hasLoaderSection("ANDMAJNZ")) { // Android trouble with args to DT_INIT
if (opt->o_unix.android_shlib) {
addLoader("ANDMAJNZ", NULL); // constant PAGE_SIZE
addLoader("ANDMAJNZ", nullptr); // constant PAGE_SIZE
}
else {
addLoader("ELFMAJNZ", NULL); // PAGE_SIZE from AT_PAGESZ
addLoader("ELFMAJNZ", nullptr); // PAGE_SIZE from AT_PAGESZ
}
addLoader("ELFMAKNZ", NULL);
addLoader("ELFMAKNZ", nullptr);
}
if (hasLoaderSection("ELFMAINZu")) {
addLoader("ELFMAINZu", NULL);
addLoader("ELFMAINZu", nullptr);
}
addLoader("FOLDEXEC", NULL);
addLoader("FOLDEXEC", nullptr);
}
@ -702,12 +702,12 @@ void PackLinuxElf64::defineSymbols(Filter const *ft)
}
PackLinuxElf32::PackLinuxElf32(InputFile *f)
: super(f), phdri(NULL), shdri(NULL),
gnu_stack(NULL),
: super(f), phdri(nullptr), shdri(nullptr),
gnu_stack(nullptr),
page_mask(~0u<<lg2_page),
dynseg(NULL), hashtab(NULL), gashtab(NULL), dynsym(NULL),
jni_onload_sym(NULL),
sec_strndx(NULL), sec_dynsym(NULL), sec_dynstr(NULL)
dynseg(nullptr), hashtab(nullptr), gashtab(nullptr), dynsym(nullptr),
jni_onload_sym(nullptr),
sec_strndx(nullptr), sec_dynsym(nullptr), sec_dynstr(nullptr)
, symnum_end(0)
{
memset(&ehdri, 0, sizeof(ehdri));
@ -722,12 +722,12 @@ PackLinuxElf32::~PackLinuxElf32()
}
PackLinuxElf64::PackLinuxElf64(InputFile *f)
: super(f), phdri(NULL), shdri(NULL),
gnu_stack(NULL),
: super(f), phdri(nullptr), shdri(nullptr),
gnu_stack(nullptr),
page_mask(~0ull<<lg2_page),
dynseg(NULL), hashtab(NULL), gashtab(NULL), dynsym(NULL),
jni_onload_sym(NULL),
sec_strndx(NULL), sec_dynsym(NULL), sec_dynstr(NULL)
dynseg(nullptr), hashtab(nullptr), gashtab(nullptr), dynsym(nullptr),
jni_onload_sym(nullptr),
sec_strndx(nullptr), sec_dynsym(nullptr), sec_dynstr(nullptr)
, symnum_end(0)
{
memset(&ehdri, 0, sizeof(ehdri));
@ -794,7 +794,7 @@ PackLinuxElf64::PackLinuxElf64help1(InputFile *f)
phdri= (Elf64_Phdr *)(e_phoff + file_image); // do not free() !!
shdri= (Elf64_Shdr *)(e_shoff + file_image); // do not free() !!
if (opt->cmd != CMD_COMPRESS) {
shdri = NULL;
shdri = nullptr;
}
sec_dynsym = elf_find_section_type(Elf64_Shdr::SHT_DYNSYM);
if (sec_dynsym) {
@ -1084,61 +1084,61 @@ void PackLinuxElf32x86::addStubEntrySections(Filter const *ft)
// b_len + ph.c_len );
// entry to stub
addLoader("LEXEC000", NULL);
addLoader("LEXEC000", nullptr);
if (ft->id) {
{ // decompr, unfilter are separate
addLoader("LXUNF000", NULL);
addLoader("LXUNF002", NULL);
addLoader("LXUNF000", nullptr);
addLoader("LXUNF002", nullptr);
if (0x80==(ft->id & 0xF0)) {
if (256==n_mru) {
addLoader("MRUBYTE0", NULL);
addLoader("MRUBYTE0", nullptr);
}
else if (n_mru) {
addLoader("LXMRU005", NULL);
addLoader("LXMRU005", nullptr);
}
if (n_mru) {
addLoader("LXMRU006", NULL);
addLoader("LXMRU006", nullptr);
}
else {
addLoader("LXMRU007", NULL);
addLoader("LXMRU007", nullptr);
}
}
else if (0x40==(ft->id & 0xF0)) {
addLoader("LXUNF008", NULL);
addLoader("LXUNF008", nullptr);
}
addLoader("LXUNF010", NULL);
addLoader("LXUNF010", nullptr);
}
if (n_mru) {
addLoader("LEXEC009", NULL);
addLoader("LEXEC009", nullptr);
}
}
addLoader("LEXEC010", NULL);
addLoader(getDecompressorSections(), NULL);
addLoader("LEXEC015", NULL);
addLoader("LEXEC010", nullptr);
addLoader(getDecompressorSections(), nullptr);
addLoader("LEXEC015", nullptr);
if (ft->id) {
{ // decompr, unfilter are separate
if (0x80!=(ft->id & 0xF0)) {
addLoader("LXUNF042", NULL);
addLoader("LXUNF042", nullptr);
}
}
addFilter32(ft->id);
{ // decompr, unfilter are separate
if (0x80==(ft->id & 0xF0)) {
if (0==n_mru) {
addLoader("LXMRU058", NULL);
addLoader("LXMRU058", nullptr);
}
}
addLoader("LXUNF035", NULL);
addLoader("LXUNF035", nullptr);
}
}
else {
addLoader("LEXEC017", NULL);
addLoader("LEXEC017", nullptr);
}
addLoader("IDENTSTR", NULL);
addLoader("LEXEC020", NULL);
addLoader("FOLDEXEC", NULL);
addLoader("IDENTSTR", nullptr);
addLoader("LEXEC020", nullptr);
addLoader("FOLDEXEC", nullptr);
}
void PackLinuxElf32x86::defineSymbols(Filter const *const ft)
@ -1185,7 +1185,7 @@ PackLinuxElf32::buildLinuxLoader(
{
unsigned h_sz_cpr = h.sz_cpr;
int r = upx_compress(uncLoader, h.sz_unc, sizeof(h) + cprLoader, &h_sz_cpr,
NULL, ph.method, 10, NULL, NULL );
nullptr, ph.method, 10, nullptr, nullptr );
h.sz_cpr = h_sz_cpr;
if (r != UPX_E_OK || h.sz_cpr >= h.sz_unc)
throwInternalError("loader compression failed");
@ -1196,7 +1196,7 @@ PackLinuxElf32::buildLinuxLoader(
MemBuffer mb_tmp(tmp_len);
unsigned char *tmp = (unsigned char *)mb_tmp;
memset(tmp, 0, tmp_len);
int r = upx_decompress(sizeof(h) + cprLoader, h.sz_cpr, tmp, &tmp_len, h.b_method, NULL);
int r = upx_decompress(sizeof(h) + cprLoader, h.sz_cpr, tmp, &tmp_len, h.b_method, nullptr);
if (r == UPX_E_OUT_OF_MEMORY)
throwOutOfMemoryException();
printf("\n%d %d: %d %d %d\n", h.b_method, r, h.sz_cpr, h.sz_unc, tmp_len);
@ -1255,7 +1255,7 @@ PackLinuxElf64::buildLinuxLoader(
{
unsigned h_sz_cpr = h.sz_cpr;
int r = upx_compress(uncLoader, h.sz_unc, sizeof(h) + cprLoader, &h_sz_cpr,
NULL, ph.method, 10, NULL, NULL );
nullptr, ph.method, 10, nullptr, nullptr );
h.sz_cpr = h_sz_cpr;
if (r != UPX_E_OK || h.sz_cpr >= h.sz_unc)
throwInternalError("loader compression failed");
@ -1266,7 +1266,7 @@ PackLinuxElf64::buildLinuxLoader(
MemBuffer mb_tmp(tmp_len);
unsigned char *tmp = (unsigned char *)mb_tmp;
memset(tmp, 0, tmp_len);
int r = upx_decompress(sizeof(h) + cprLoader, h.sz_cpr, tmp, &tmp_len, h.b_method, NULL);
int r = upx_decompress(sizeof(h) + cprLoader, h.sz_cpr, tmp, &tmp_len, h.b_method, nullptr);
if (r == UPX_E_OUT_OF_MEMORY)
throwOutOfMemoryException();
printf("\n%d %d: %d %d %d\n", h.b_method, r, h.sz_cpr, h.sz_unc, tmp_len);
@ -1313,12 +1313,12 @@ PackLinuxElf32x86::buildLoader(const Filter *ft)
if (0!=xct_off) { // shared library
buildLinuxLoader(
stub_i386_linux_shlib_init, sizeof(stub_i386_linux_shlib_init),
NULL, 0, ft );
nullptr, 0, ft );
return;
}
unsigned char tmp[sizeof(stub_i386_linux_elf_fold)];
memcpy(tmp, stub_i386_linux_elf_fold, sizeof(stub_i386_linux_elf_fold));
checkPatch(NULL, 0, 0, 0); // reset
checkPatch(nullptr, 0, 0, 0); // reset
if (opt->o_unix.is_ptinterp) {
unsigned j;
for (j = 0; j < sizeof(stub_i386_linux_elf_fold)-1; ++j) {
@ -1346,7 +1346,7 @@ PackBSDElf32x86::buildLoader(const Filter *ft)
{
unsigned char tmp[sizeof(stub_i386_bsd_elf_fold)];
memcpy(tmp, stub_i386_bsd_elf_fold, sizeof(stub_i386_bsd_elf_fold));
checkPatch(NULL, 0, 0, 0); // reset
checkPatch(nullptr, 0, 0, 0); // reset
if (opt->o_unix.is_ptinterp) {
unsigned j;
for (j = 0; j < sizeof(stub_i386_bsd_elf_fold)-1; ++j) {
@ -1378,7 +1378,7 @@ PackNetBSDElf32x86::buildLoader(const Filter *ft)
{
unsigned char tmp[sizeof(stub_i386_netbsd_elf_fold)];
memcpy(tmp, stub_i386_netbsd_elf_fold, sizeof(stub_i386_netbsd_elf_fold));
checkPatch(NULL, 0, 0, 0); // reset
checkPatch(nullptr, 0, 0, 0); // reset
if (opt->o_unix.is_ptinterp) {
unsigned j;
for (j = 0; j < sizeof(stub_i386_netbsd_elf_fold)-1; ++j) {
@ -1404,7 +1404,7 @@ PackOpenBSDElf32x86::buildLoader(const Filter *ft)
{
unsigned char tmp[sizeof(stub_i386_openbsd_elf_fold)];
memcpy(tmp, stub_i386_openbsd_elf_fold, sizeof(stub_i386_openbsd_elf_fold));
checkPatch(NULL, 0, 0, 0); // reset
checkPatch(nullptr, 0, 0, 0); // reset
if (opt->o_unix.is_ptinterp) {
unsigned j;
for (j = 0; j < sizeof(stub_i386_openbsd_elf_fold)-1; ++j) {
@ -1461,7 +1461,7 @@ PackLinuxElf32armLe::buildLoader(Filter const *ft)
if (0!=xct_off) { // shared library
buildLinuxLoader(
stub_arm_v5t_linux_shlib_init, sizeof(stub_arm_v5t_linux_shlib_init),
NULL, 0, ft );
nullptr, 0, ft );
return;
}
buildLinuxLoader(
@ -1488,7 +1488,7 @@ PackLinuxElf32mipsel::buildLoader(Filter const *ft)
if (0!=xct_off) { // shared library
buildLinuxLoader(
stub_mipsel_r3000_linux_shlib_init, sizeof(stub_mipsel_r3000_linux_shlib_init),
NULL, 0, ft );
nullptr, 0, ft );
return;
}
buildLinuxLoader(
@ -1509,7 +1509,7 @@ PackLinuxElf32mipseb::buildLoader(Filter const *ft)
if (0!=xct_off) { // shared library
buildLinuxLoader(
stub_mips_r3000_linux_shlib_init, sizeof(stub_mips_r3000_linux_shlib_init),
NULL, 0, ft );
nullptr, 0, ft );
return;
}
buildLinuxLoader(
@ -1569,7 +1569,7 @@ PackLinuxElf64amd::buildLoader(const Filter *ft)
if (0!=xct_off) { // shared library
buildLinuxLoader(
stub_amd64_linux_shlib_init, sizeof(stub_amd64_linux_shlib_init),
NULL, 0, ft );
nullptr, 0, ft );
return;
}
buildLinuxLoader(
@ -1590,7 +1590,7 @@ PackLinuxElf64arm::buildLoader(const Filter *ft)
if (0!=xct_off) { // shared library
buildLinuxLoader(
stub_arm64_linux_shlib_init, sizeof(stub_arm64_linux_shlib_init),
NULL, 0, ft );
nullptr, 0, ft );
return;
}
buildLinuxLoader(
@ -1787,7 +1787,7 @@ PackLinuxElf32::elf_find_ptype(unsigned type, Elf32_Phdr const *phdr, unsigned p
return phdr;
}
}
return 0;
return nullptr;
}
Elf64_Phdr const *
@ -1798,7 +1798,7 @@ PackLinuxElf64::elf_find_ptype(unsigned type, Elf64_Phdr const *phdr, unsigned p
return phdr;
}
}
return 0;
return nullptr;
}
Elf32_Shdr const *PackLinuxElf32::elf_find_section_name(
@ -1807,7 +1807,7 @@ Elf32_Shdr const *PackLinuxElf32::elf_find_section_name(
{
Elf32_Shdr const *shdr = shdri;
if (!shdr) {
return 0;
return nullptr;
}
int j = e_shnum;
for (; 0 <=--j; ++shdr) {
@ -1822,7 +1822,7 @@ Elf32_Shdr const *PackLinuxElf32::elf_find_section_name(
return shdr;
}
}
return 0;
return nullptr;
}
Elf64_Shdr const *PackLinuxElf64::elf_find_section_name(
@ -1831,7 +1831,7 @@ Elf64_Shdr const *PackLinuxElf64::elf_find_section_name(
{
Elf64_Shdr const *shdr = shdri;
if (!shdr) {
return 0;
return nullptr;
}
int j = e_shnum;
for (; 0 <=--j; ++shdr) {
@ -1846,7 +1846,7 @@ Elf64_Shdr const *PackLinuxElf64::elf_find_section_name(
return shdr;
}
}
return 0;
return nullptr;
}
Elf32_Shdr const *PackLinuxElf32::elf_find_section_type(
@ -1855,7 +1855,7 @@ Elf32_Shdr const *PackLinuxElf32::elf_find_section_type(
{
Elf32_Shdr const *shdr = shdri;
if (!shdr) {
return 0;
return nullptr;
}
int j = e_shnum;
for (; 0 <=--j; ++shdr) {
@ -1863,7 +1863,7 @@ Elf32_Shdr const *PackLinuxElf32::elf_find_section_type(
return shdr;
}
}
return 0;
return nullptr;
}
Elf64_Shdr const *PackLinuxElf64::elf_find_section_type(
@ -1872,7 +1872,7 @@ Elf64_Shdr const *PackLinuxElf64::elf_find_section_type(
{
Elf64_Shdr const *shdr = shdri;
if (!shdr) {
return 0;
return nullptr;
}
int j = e_shnum;
for (; 0 <=--j; ++shdr) {
@ -1880,7 +1880,7 @@ Elf64_Shdr const *PackLinuxElf64::elf_find_section_type(
return shdr;
}
}
return 0;
return nullptr;
}
char const *PackLinuxElf64::get_str_name(unsigned st_name, unsigned symnum) const
@ -2087,8 +2087,8 @@ bool PackLinuxElf32::canPack()
phdri= (Elf32_Phdr *)((size_t)e_phoff + file_image); // do not free() !!
shdri= (Elf32_Shdr *)((size_t)e_shoff + file_image); // do not free() !!
sec_strndx = NULL;
shstrtab = NULL;
sec_strndx = nullptr;
shstrtab = nullptr;
if (e_shnum) {
unsigned const e_shstrndx = get_te16(&ehdr->e_shstrndx);
if (e_shstrndx) {
@ -2129,7 +2129,7 @@ bool PackLinuxElf32::canPack()
}
}
Elf32_Phdr const *pload_x0(0); // first eXecutable PT_LOAD
Elf32_Phdr const *pload_x0(nullptr); // first eXecutable PT_LOAD
phdr= phdri;
for (int j= e_phnum; --j>=0; ++phdr)
if (Elf32_Phdr::PT_DYNAMIC==get_te32(&phdr->p_type)) {
@ -2437,8 +2437,8 @@ PackLinuxElf64::canPack()
phdri= (Elf64_Phdr *)((size_t)e_phoff + file_image); // do not free() !!
shdri= (Elf64_Shdr *)((size_t)e_shoff + file_image); // do not free() !!
sec_strndx = NULL;
shstrtab = NULL;
sec_strndx = nullptr;
shstrtab = nullptr;
if (e_shnum) {
unsigned const e_shstrndx = get_te16(&ehdr->e_shstrndx);
if (e_shstrndx) {
@ -2479,7 +2479,7 @@ PackLinuxElf64::canPack()
}
}
Elf64_Phdr const *pload_x0(0); // first eXecutable PT_LOAD
Elf64_Phdr const *pload_x0(nullptr); // first eXecutable PT_LOAD
phdr= phdri;
for (int j= e_phnum; --j>=0; ++phdr)
if (Elf64_Phdr::PT_DYNAMIC==get_te32(&phdr->p_type)) {
@ -2864,8 +2864,8 @@ PackNetBSDElf32x86::generateElfHdr(
unsigned note_offset = sz_elf_hdrs;
// Find the NetBSD PT_NOTE and the PaX PT_NOTE.
Elf32_Nhdr const *np_NetBSD = 0; unsigned sz_NetBSD = 0;
Elf32_Nhdr const *np_PaX = 0; unsigned sz_PaX = 0;
Elf32_Nhdr const *np_NetBSD = nullptr; unsigned sz_NetBSD = 0;
Elf32_Nhdr const *np_PaX = nullptr; unsigned sz_PaX = 0;
unsigned char *cp = (unsigned char *)note_body;
unsigned j;
for (j=0; j < note_size; ) {
@ -2942,7 +2942,7 @@ PackNetBSDElf32x86::generateElfHdr(
// The 'if' guards on these two calls to memcpy are required
// because the C Standard Committee did not debug the Standard
// before publishing. An empty region (0==size) must nevertheless
// have a valid (non-NULL) pointer.
// have a valid (non-nullptr) pointer.
if (sz_NetBSD) memcpy(&((char *)phdr)[0], np_NetBSD, sz_NetBSD);
if (sz_PaX) memcpy(&((char *)phdr)[sz_NetBSD], np_PaX, sz_PaX);
@ -4031,7 +4031,7 @@ int PackLinuxElf32::pack2(OutputFile *fo, Filter &ft)
// sometimes marks as PF_X anyway. So filter only first segment.
if (k == nk_f || !is_shlib) {
packExtent(x, total_in, total_out,
(k==nk_f ? &ft : 0 ), fo, hdr_u_len);
(k==nk_f ? &ft : nullptr ), fo, hdr_u_len);
}
else {
total_in += x.size;
@ -4162,7 +4162,7 @@ int PackLinuxElf64::pack2(OutputFile *fo, Filter &ft)
// sometimes marks as PF_X anyway. So filter only first segment.
if (k == nk_f || !is_shlib) {
packExtent(x, total_in, total_out,
(k==nk_f ? &ft : 0 ), fo, hdr_u_len);
(k==nk_f ? &ft : nullptr ), fo, hdr_u_len);
}
else {
total_in += x.size;
@ -4553,7 +4553,7 @@ void PackLinuxElf64::unpack(OutputFile *fo)
MemBuffer u(ph.u_len);
Elf64_Ehdr *const ehdr = (Elf64_Ehdr *)&u[0];
Elf64_Phdr const *phdr = 0;
Elf64_Phdr const *phdr = nullptr;
// Uncompress Ehdr and Phdrs.
if (ibuf.getSize() < ph.c_len)
@ -4576,8 +4576,8 @@ void PackLinuxElf64::unpack(OutputFile *fo)
unsigned const u_phnum = get_te16(&ehdr->e_phnum);
unsigned total_in = 0;
unsigned total_out = 0;
unsigned c_adler = upx_adler32(NULL, 0);
unsigned u_adler = upx_adler32(NULL, 0);
unsigned c_adler = upx_adler32(nullptr, 0);
unsigned u_adler = upx_adler32(nullptr, 0);
#define MAX_ELF_HDR 1024
if ((umin64(MAX_ELF_HDR, ph.u_len) - sizeof(Elf64_Ehdr))/sizeof(Elf64_Phdr) < u_phnum) {
throwCantUnpack("bad compressed e_phnum");
@ -5071,7 +5071,7 @@ PackLinuxElf32::elf_has_dynamic(unsigned int key) const
for (; Elf32_Dyn::DT_NULL!=dynp->d_tag; ++dynp) if (get_te32(&dynp->d_tag)==key) {
return dynp;
}
return 0;
return nullptr;
}
unsigned // checked .p_offset; sz_dynseg set
@ -5109,7 +5109,7 @@ PackLinuxElf32::elf_find_dynamic(unsigned int key) const
}
break;
}
return 0;
return nullptr;
}
upx_uint64_t
@ -5173,7 +5173,7 @@ PackLinuxElf64::elf_has_dynamic(unsigned int key) const
for (; Elf64_Dyn::DT_NULL!=dynp->d_tag; ++dynp) if (get_te64(&dynp->d_tag)==key) {
return dynp;
}
return 0;
return nullptr;
}
upx_uint64_t // checked .p_offset; sz_dynseg set
@ -5399,7 +5399,7 @@ PackLinuxElf64::elf_find_dynamic(unsigned int key) const
}
break;
}
return 0;
return nullptr;
}
upx_uint64_t
@ -5512,7 +5512,7 @@ Elf32_Sym const *PackLinuxElf32::elf_lookup(char const *name) const
}
}
}
return 0;
return nullptr;
}
@ -5589,7 +5589,7 @@ Elf64_Sym const *PackLinuxElf64::elf_lookup(char const *name) const
}
}
}
return 0;
return nullptr;
}
@ -5640,7 +5640,7 @@ void PackLinuxElf32::unpack(OutputFile *fo)
MemBuffer u(ph.u_len);
Elf32_Ehdr *const ehdr = (Elf32_Ehdr *)&u[0];
Elf32_Phdr const *phdr = 0;
Elf32_Phdr const *phdr = nullptr;
// Uncompress Ehdr and Phdrs.
if (ibuf.getSize() < ph.c_len) {
@ -5662,8 +5662,8 @@ void PackLinuxElf32::unpack(OutputFile *fo)
unsigned const u_phnum = get_te16(&ehdr->e_phnum);
unsigned total_in = 0;
unsigned total_out = 0;
unsigned c_adler = upx_adler32(NULL, 0);
unsigned u_adler = upx_adler32(NULL, 0);
unsigned c_adler = upx_adler32(nullptr, 0);
unsigned u_adler = upx_adler32(nullptr, 0);
#define MAX_ELF_HDR 512
if ((umin(MAX_ELF_HDR, ph.u_len) - sizeof(Elf32_Ehdr))/sizeof(Elf32_Phdr) < u_phnum) {
throwCantUnpack("bad compressed e_phnum");

View File

@ -55,7 +55,7 @@
**************************************************************************/
PackLinuxI386::PackLinuxI386(InputFile *f) : super(f),
ei_osabi(Elf32_Ehdr::ELFOSABI_LINUX), osabi_note(NULL)
ei_osabi(Elf32_Ehdr::ELFOSABI_LINUX), osabi_note(nullptr)
{
bele = &N_BELE_RTP::le_policy;
}
@ -336,43 +336,43 @@ PackLinuxI386::buildLinuxLoader(
// // compressed data
// b_len + ph.c_len );
// // entry to stub
addLoader("LEXEC000", NULL);
addLoader("LEXEC000", nullptr);
if (ft->id) {
if (n_mru) {
addLoader("LEXEC009", NULL);
addLoader("LEXEC009", nullptr);
}
}
addLoader("LEXEC010", NULL);
addLoader("LEXEC010", nullptr);
linker->defineSymbol("filter_cto", ft->cto);
linker->defineSymbol("filter_length",
(ft->id & 0xf) % 3 == 0 ? ft->calls :
ft->lastcall - ft->calls * 4);
addLoader(getDecompressorSections(), NULL);
addLoader("LEXEC015", NULL);
addLoader(getDecompressorSections(), nullptr);
addLoader("LEXEC015", nullptr);
if (ft->id) {
{ // decompr, unfilter not separate
if (0x80==(ft->id & 0xF0)) {
addLoader("LEXEC110", NULL);
addLoader("LEXEC110", nullptr);
if (n_mru) {
addLoader("LEXEC100", NULL);
addLoader("LEXEC100", nullptr);
}
// bug in APP: jmp and label must be in same .asx/.asy
addLoader("LEXEC016", NULL);
addLoader("LEXEC016", nullptr);
}
}
addFilter32(ft->id);
{ // decompr always unfilters
addLoader("LEXEC017", NULL);
addLoader("LEXEC017", nullptr);
}
}
else {
addLoader("LEXEC017", NULL);
addLoader("LEXEC017", nullptr);
}
addLoader("IDENTSTR", NULL);
addLoader("LEXEC020", NULL);
addLoader("FOLDEXEC", NULL);
addLoader("IDENTSTR", nullptr);
addLoader("LEXEC020", nullptr);
addLoader("FOLDEXEC", nullptr);
if (M_IS_LZMA(ph.method)) {
const lzma_compress_result_t *res = &ph.compress_result.result_lzma;
upx_uint32_t properties = // lc, lp, pb, dummy
@ -408,7 +408,7 @@ PackLinuxI386::buildLoader(Filter const *ft)
// patch loader
// note: we only can use /proc/<pid>/fd when exetype > 0.
// also, we sleep much longer when compressing a script.
checkPatch(NULL, 0, 0, 0); // reset
checkPatch(nullptr, 0, 0, 0); // reset
patch_le32(buf,sz_fold,"UPX4",exetype > 0 ? 3 : 15); // sleep time
patch_le32(buf,sz_fold,"UPX3",progid);
patch_le32(buf,sz_fold,"UPX2",exetype > 0 ? 0 : 0x7fffffff);
@ -428,7 +428,7 @@ PackBSDI386::buildLoader(Filter const *ft)
// patch loader
// note: we only can use /proc/<pid>/fd when exetype > 0.
// also, we sleep much longer when compressing a script.
checkPatch(NULL, 0, 0, 0); // reset
checkPatch(nullptr, 0, 0, 0); // reset
patch_le32(buf,sz_fold,"UPX4",exetype > 0 ? 3 : 15); // sleep time
patch_le32(buf,sz_fold,"UPX3",progid);
patch_le32(buf,sz_fold,"UPX2",exetype > 0 ? 0 : 0x7fffffff);

View File

@ -150,38 +150,38 @@ off_t PackLinuxElf32x86interp::pack3(OutputFile *fo, Filter &/*ft*/)
initLoader(stub_i386_linux_elf_interp_entry, sizeof(stub_i386_linux_elf_interp_entry));
linker->addSection("FOLDEXEC", stub_i386_linux_elf_interp_fold, sizeof(stub_i386_linux_elf_interp_fold), 0);
addLoader("LXPTI000", NULL);
addLoader("LXPTI000", nullptr);
addLoader("LXPTI040", NULL);
ph.method = M_NRV2B_LE32; addLoader(getDecompressorSections(), NULL);
addLoader("LXPTI090", NULL);
addLoader("LXPTI040", nullptr);
ph.method = M_NRV2B_LE32; addLoader(getDecompressorSections(), nullptr);
addLoader("LXPTI090", nullptr);
addLoader("LXPTI041", NULL);
ph.method = M_NRV2D_LE32; addLoader(getDecompressorSections(), NULL);
addLoader("LXPTI090", NULL);
addLoader("LXPTI041", nullptr);
ph.method = M_NRV2D_LE32; addLoader(getDecompressorSections(), nullptr);
addLoader("LXPTI090", nullptr);
addLoader("LXPTI042", NULL);
ph.method = M_NRV2E_LE32; addLoader(getDecompressorSections(), NULL);
addLoader("LXPTI090", NULL);
addLoader("LXPTI042", nullptr);
ph.method = M_NRV2E_LE32; addLoader(getDecompressorSections(), nullptr);
addLoader("LXPTI090", nullptr);
//addLoader("LXPTI043", NULL);
//ph.method = M_CL1B_LE32; addLoader(getDecompressorSections(), NULL);
//addLoader("LXPTI090", NULL);
//addLoader("LXPTI043", nullptr);
//ph.method = M_CL1B_LE32; addLoader(getDecompressorSections(), nullptr);
//addLoader("LXPTI090", nullptr);
addLoader("LXPTI091", NULL);
addLoader("LXPTI091", nullptr);
addLoader("LXPTI140", NULL);
addLoader("LXPTI140", nullptr);
addLoader("LXUNF002,LXUNF008,LXUNF010", NULL);
addLoader("LXUNF002,LXUNF008,LXUNF010", nullptr);
addFilter32(0x46);
addLoader("LXUNF042,LXUNF035", NULL);
addLoader("LXUNF042,LXUNF035", nullptr);
addLoader("LXUNF002,LXUNF008,LXUNF010", NULL);
addLoader("LXUNF002,LXUNF008,LXUNF010", nullptr);
addFilter32(0x49);
addLoader("LXUNF042,LXUNF035", NULL);
addLoader("LXUNF042,LXUNF035", nullptr);
addLoader("LXPTI200", NULL);
addLoader("FOLDEXEC", NULL);
addLoader("LXPTI200", nullptr);
addLoader("FOLDEXEC", nullptr);
upx_byte const *p = getLoader();
lsize = getLoaderSize();
updateLoader(fo);
@ -236,8 +236,8 @@ void PackLinuxElf32x86interp::unpack(OutputFile *fo)
unsigned total_in = 0;
unsigned total_out = 0;
unsigned c_adler = upx_adler32(NULL, 0);
unsigned u_adler = upx_adler32(NULL, 0);
unsigned c_adler = upx_adler32(nullptr, 0);
unsigned u_adler = upx_adler32(nullptr, 0);
off_t ptload0hi=0, ptload1lo=0, ptload1sz=0;
// decompress PT_LOAD

View File

@ -78,7 +78,7 @@ PackLinuxI386sh::buildLoader(Filter const *ft)
MemBuffer buf(sz_fold);
memcpy(buf, stub_i386_linux_elf_shell_fold, sz_fold);
checkPatch(NULL, 0, 0, 0); // reset
checkPatch(nullptr, 0, 0, 0); // reset
patch_le32(buf,sz_fold,"UPX3",l_shname);
patch_le32(buf,sz_fold,"UPX2",o_shname);
@ -115,12 +115,12 @@ bool PackLinuxI386sh::getShellName(char *buf)
static char const *const shname[] = { // known shells that accept "-c" arg
"ash", "bash", "bsh", "csh", "ksh", "pdksh", "sh", "tcsh", "zsh",
"python", "python2", "python3",
NULL
nullptr
};
const char *bname = strrchr(buf, '/');
if (bname == NULL)
if (bname == nullptr)
return false;
for (int j = 0; NULL != shname[j]; ++j) {
for (int j = 0; nullptr != shname[j]; ++j) {
if (0 == strcmp(shname[j], bname + 1)) {
bool const s = super::canPack();
if (s) {

View File

@ -48,7 +48,7 @@ public:
virtual int getFormat() const { return UPX_F_LINUX_SH_i386; }
virtual const char *getName() const { return "linux.sh/i386"; }
virtual const char *getFullName(const options_t *) const { return "i386-linux.elf.shell"; }
virtual const int *getFilters() const { return NULL; }
virtual const int *getFilters() const { return nullptr; }
virtual void buildLoader(const Filter *);
virtual void pack1(OutputFile *fo, Filter &ft);

View File

@ -106,11 +106,11 @@ PackMachBase<T>::PackMachBase(InputFile *f, unsigned cputype, unsigned filetype,
unsigned flavor, unsigned count, unsigned size) :
super(f), my_cputype(cputype), my_filetype(filetype), my_thread_flavor(flavor),
my_thread_state_word_count(count), my_thread_command_size(size),
n_segment(0), rawmseg(NULL), msegcmd(NULL), o__mod_init_func(0),
n_segment(0), rawmseg(nullptr), msegcmd(nullptr), o__mod_init_func(0),
prev_mod_init_func(0), pagezero_vmsize(0)
{
MachClass::compileTimeAssertions();
bele = N_BELE_CTP::getRTP((const BeLePolicy*) NULL);
bele = N_BELE_CTP::getRTP((const BeLePolicy*) nullptr);
memset(&cmdUUID, 0, sizeof(cmdUUID));
memset(&cmdSRCVER, 0, sizeof(cmdSRCVER));
memset(&cmdVERMIN, 0, sizeof(cmdVERMIN));
@ -254,107 +254,107 @@ template <class T>
void
PackMachBase<T>::addStubEntrySections(Filter const *)
{
addLoader("MACOS000", NULL);
//addLoader(getDecompressorSections(), NULL);
addLoader("MACOS000", nullptr);
//addLoader(getDecompressorSections(), nullptr);
addLoader(
( M_IS_NRV2E(ph.method) ? "NRV_HEAD,NRV2E,NRV_TAIL"
: M_IS_NRV2D(ph.method) ? "NRV_HEAD,NRV2D,NRV_TAIL"
: M_IS_NRV2B(ph.method) ? "NRV_HEAD,NRV2B,NRV_TAIL"
: M_IS_LZMA(ph.method) ? "LZMA_ELF00,LZMA_DEC20,LZMA_DEC30"
: NULL), NULL);
: nullptr), nullptr);
if (hasLoaderSection("CFLUSH"))
addLoader("CFLUSH");
addLoader("ELFMAINY,IDENTSTR,+40,ELFMAINZ,FOLDEXEC", NULL);
addLoader("ELFMAINY,IDENTSTR,+40,ELFMAINZ,FOLDEXEC", nullptr);
}
void PackMachI386::addStubEntrySections(Filter const * /*ft*/)
{
addLoader("MACHMAINX", NULL); // different for MY_DYLIB vs MH_EXECUTE
addLoader("MACHMAINX", nullptr); // different for MY_DYLIB vs MH_EXECUTE
if (my_filetype==Mach_header::MH_EXECUTE) {
addLoader("MACH_UNC", NULL);
addLoader("MACH_UNC", nullptr);
}
//addLoader(getDecompressorSections(), NULL);
//addLoader(getDecompressorSections(), nullptr);
addLoader(
( M_IS_NRV2E(ph.method) ? "NRV_HEAD,NRV2E,NRV_TAIL"
: M_IS_NRV2D(ph.method) ? "NRV_HEAD,NRV2D,NRV_TAIL"
: M_IS_NRV2B(ph.method) ? "NRV_HEAD,NRV2B,NRV_TAIL"
: M_IS_LZMA(ph.method) ? "LZMA_ELF00,LZMA_DEC20,LZMA_DEC30"
: NULL), NULL);
: nullptr), nullptr);
if (hasLoaderSection("CFLUSH"))
addLoader("CFLUSH");
addLoader("MACHMAINY,IDENTSTR,+40,MACHMAINZ,FOLDEXEC", NULL);
addLoader("MACHMAINY,IDENTSTR,+40,MACHMAINZ,FOLDEXEC", nullptr);
}
void PackMachAMD64::addStubEntrySections(Filter const * /*ft*/)
{
addLoader("MACHMAINX", NULL); // different for MY_DYLIB vs MH_EXECUTE
addLoader("MACHMAINX", nullptr); // different for MY_DYLIB vs MH_EXECUTE
if (my_filetype==Mach_header::MH_EXECUTE) {
addLoader("MACH_UNC", NULL);
addLoader("MACH_UNC", nullptr);
}
//addLoader(getDecompressorSections(), NULL);
//addLoader(getDecompressorSections(), nullptr);
addLoader(
( M_IS_NRV2E(ph.method) ? "NRV_HEAD,NRV2E,NRV_TAIL"
: M_IS_NRV2D(ph.method) ? "NRV_HEAD,NRV2D,NRV_TAIL"
: M_IS_NRV2B(ph.method) ? "NRV_HEAD,NRV2B,NRV_TAIL"
: M_IS_LZMA(ph.method) ? "LZMA_ELF00,LZMA_DEC20,LZMA_DEC30"
: NULL), NULL);
: nullptr), nullptr);
if (hasLoaderSection("CFLUSH"))
addLoader("CFLUSH");
addLoader("MACHMAINY,IDENTSTR,+40,MACHMAINZ,FOLDEXEC", NULL);
addLoader("MACHMAINY,IDENTSTR,+40,MACHMAINZ,FOLDEXEC", nullptr);
}
void PackMachPPC32::addStubEntrySections(Filter const * /*ft*/)
{
if (my_filetype!=Mach_header::MH_EXECUTE) {
addLoader("MACHMAINX", NULL);
addLoader("MACHMAINX", nullptr);
}
else {
addLoader("PPC32BXX", NULL);
addLoader("PPC32BXX", nullptr);
}
addLoader("MACH_UNC", NULL);
//addLoader(getDecompressorSections(), NULL);
addLoader("MACH_UNC", nullptr);
//addLoader(getDecompressorSections(), nullptr);
addLoader(
( M_IS_NRV2E(ph.method) ? "NRV_HEAD,NRV2E,NRV_TAIL"
: M_IS_NRV2D(ph.method) ? "NRV_HEAD,NRV2D,NRV_TAIL"
: M_IS_NRV2B(ph.method) ? "NRV_HEAD,NRV2B,NRV_TAIL"
: M_IS_LZMA(ph.method) ? "LZMA_ELF00,LZMA_DEC20,LZMA_DEC30"
: NULL), NULL);
: nullptr), nullptr);
if (hasLoaderSection("CFLUSH"))
addLoader("CFLUSH");
addLoader("MACHMAINY,IDENTSTR,+40,MACHMAINZ", NULL);
addLoader("MACHMAINY,IDENTSTR,+40,MACHMAINZ", nullptr);
if (my_filetype!=Mach_header::MH_EXECUTE) {
addLoader("FOLDEXEC", NULL);
addLoader("FOLDEXEC", nullptr);
}
}
void PackMachARMEL::addStubEntrySections(Filter const * /*ft*/)
{
addLoader("MACHMAINX", NULL);
//addLoader(getDecompressorSections(), NULL);
addLoader("MACHMAINX", nullptr);
//addLoader(getDecompressorSections(), nullptr);
addLoader(
( M_IS_NRV2E(ph.method) ? "NRV_HEAD,NRV2E,NRV_TAIL"
: M_IS_NRV2D(ph.method) ? "NRV_HEAD,NRV2D,NRV_TAIL"
: M_IS_NRV2B(ph.method) ? "NRV_HEAD,NRV2B,NRV_TAIL"
: M_IS_LZMA(ph.method) ? "LZMA_ELF00,LZMA_DEC20,LZMA_DEC30"
: NULL), NULL);
: nullptr), nullptr);
if (hasLoaderSection("CFLUSH"))
addLoader("CFLUSH");
addLoader("MACHMAINY,IDENTSTR,+40,MACHMAINZ,FOLDEXEC", NULL);
addLoader("MACHMAINY,IDENTSTR,+40,MACHMAINZ,FOLDEXEC", nullptr);
}
void PackMachARM64EL::addStubEntrySections(Filter const * /*ft*/)
{
addLoader("MACHMAINX", NULL);
//addLoader(getDecompressorSections(), NULL);
addLoader("MACHMAINX", nullptr);
//addLoader(getDecompressorSections(), nullptr);
addLoader(
( M_IS_NRV2E(ph.method) ? "NRV_HEAD,NRV2E,NRV_TAIL"
: M_IS_NRV2D(ph.method) ? "NRV_HEAD,NRV2D,NRV_TAIL"
: M_IS_NRV2B(ph.method) ? "NRV_HEAD,NRV2B,NRV_TAIL"
: M_IS_LZMA(ph.method) ? "LZMA_ELF00,LZMA_DEC20,LZMA_DEC30"
: NULL), NULL);
: nullptr), nullptr);
if (hasLoaderSection("CFLUSH"))
addLoader("CFLUSH");
addLoader("MACHMAINY,IDENTSTR,+40,MACHMAINZ,FOLDEXEC", NULL);
addLoader("MACHMAINY,IDENTSTR,+40,MACHMAINZ,FOLDEXEC", nullptr);
}
template <class T>
@ -391,7 +391,7 @@ PackMachBase<T>::buildMachLoader(
if (0 < szfold) {
unsigned sz_cpr = 0;
int r = upx_compress(uncLoader, h.sz_unc, sizeof(h) + cprLoader, &sz_cpr,
NULL, ph.method, 10, NULL, NULL );
nullptr, ph.method, 10, nullptr, nullptr );
h.sz_cpr = sz_cpr;
if (r != UPX_E_OK || h.sz_cpr >= h.sz_unc)
throwInternalError("loader compression failed");
@ -1099,7 +1099,7 @@ int PackMachBase<T>::pack2(OutputFile *fo, Filter &ft) // append compressed bo
ptr = (Mach_segment_command const *)(ptr->cmdsize + (char const *)ptr);
}
packExtent(x, total_in, total_out,
(do_filter ? &ft : 0 ), fo, hdr_u_len, b_extra );
(do_filter ? &ft : nullptr), fo, hdr_u_len, b_extra );
if (do_filter) {
exe_filesize_max = 0;
}
@ -1114,7 +1114,7 @@ int PackMachBase<T>::pack2(OutputFile *fo, Filter &ft) // append compressed bo
x.size = find_SEGMENT_gap(k, fi->st_size());
if (x.size) {
x.offset = msegcmd[k].fileoff +msegcmd[k].filesize;
packExtent(x, total_in, total_out, 0, fo);
packExtent(x, total_in, total_out, nullptr, fo);
}
}
@ -1452,8 +1452,8 @@ void PackMachBase<T>::unpack(OutputFile *fo)
unsigned total_in = 0;
unsigned total_out = 0;
unsigned c_adler = upx_adler32(NULL, 0);
unsigned u_adler = upx_adler32(NULL, 0);
unsigned c_adler = upx_adler32(nullptr, 0);
unsigned u_adler = upx_adler32(nullptr, 0);
fi->seek(- (off_t)(sizeof(bhdr) + ph.c_len), SEEK_CUR);
for (unsigned k = 0; k < ncmds; ++k) {
@ -1546,7 +1546,7 @@ int PackMachBase<T>::canUnpack()
rawmseg = (Mach_segment_command *)rawmseg_buf.getVoidPtr();
fi->readx(rawmseg, mhdri.sizeofcmds);
Mach_segment_command const *ptrTEXT = 0;
Mach_segment_command const *ptrTEXT = nullptr;
upx_uint64_t rip = 0;
unsigned style = 0;
off_t offLINK = 0;
@ -1903,7 +1903,7 @@ bool PackMachBase<T>::canPack()
if (!n_segment) {
return false;
}
struct {
static struct {
unsigned cputype;
unsigned short filetype;
unsigned short sz_stub_entry;
@ -1923,7 +1923,7 @@ bool PackMachBase<T>::canPack()
},
{CPU_TYPE_I386, MH_DYLIB,
sizeof(stub_i386_darwin_dylib_entry), 0, 0,
stub_i386_darwin_dylib_entry, 0, 0
stub_i386_darwin_dylib_entry, nullptr, nullptr
},
{CPU_TYPE_X86_64, MH_EXECUTE,
sizeof(stub_amd64_darwin_macho_entry),
@ -1931,11 +1931,11 @@ bool PackMachBase<T>::canPack()
0, //sizeof(stub_amd64_darwin_macho_upxmain_exe),
stub_amd64_darwin_macho_entry,
stub_amd64_darwin_macho_fold,
0 // stub_amd64_darwin_macho_upxmain_exe
nullptr // stub_amd64_darwin_macho_upxmain_exe
},
{CPU_TYPE_X86_64, MH_DYLIB,
sizeof(stub_amd64_darwin_dylib_entry), 0, 0,
stub_amd64_darwin_dylib_entry, 0, 0
stub_amd64_darwin_dylib_entry, nullptr, nullptr
},
{CPU_TYPE_ARM, MH_EXECUTE,
sizeof(stub_arm_v5a_darwin_macho_entry),
@ -1943,7 +1943,7 @@ bool PackMachBase<T>::canPack()
0,
stub_arm_v5a_darwin_macho_entry,
stub_arm_v5a_darwin_macho_fold,
0
nullptr
},
{CPU_TYPE_ARM64, MH_EXECUTE,
sizeof(stub_arm64_darwin_macho_entry),
@ -1951,7 +1951,7 @@ bool PackMachBase<T>::canPack()
0,
stub_arm64_darwin_macho_entry,
stub_arm64_darwin_macho_fold,
0
nullptr
},
{CPU_TYPE_POWERPC, MH_EXECUTE,
sizeof(stub_powerpc_darwin_macho_entry),
@ -1963,7 +1963,7 @@ bool PackMachBase<T>::canPack()
},
{CPU_TYPE_POWERPC, MH_DYLIB,
sizeof(stub_powerpc_darwin_dylib_entry), 0, 0,
stub_powerpc_darwin_dylib_entry, 0, 0
stub_powerpc_darwin_dylib_entry, nullptr, nullptr
},
{CPU_TYPE_POWERPC64LE, MH_EXECUTE,
sizeof(stub_powerpc64le_darwin_macho_entry),
@ -1971,13 +1971,13 @@ bool PackMachBase<T>::canPack()
0,
stub_powerpc64le_darwin_macho_entry,
stub_powerpc64le_darwin_macho_fold,
0
nullptr
},
{CPU_TYPE_POWERPC64LE, MH_DYLIB,
sizeof(stub_powerpc64le_darwin_dylib_entry), 0, 0,
stub_powerpc64le_darwin_dylib_entry, 0, 0
stub_powerpc64le_darwin_dylib_entry, nullptr, nullptr
},
{0,0, 0,0,0, 0,0,0}
{0,0, 0,0,0, nullptr,nullptr,nullptr}
};
for (unsigned j = 0; stub_list[j].cputype; ++j) {
if (stub_list[j].cputype == my_cputype
@ -2236,7 +2236,7 @@ void PackMachFat::pack(OutputFile *fo)
void PackMachFat::unpack(OutputFile *fo)
{
if (fo) { // test mode ("-t") sets fo = NULL
if (fo) { // test mode ("-t") sets fo = nullptr
fo->seek(0, SEEK_SET);
fo->write(&fat_head, sizeof(fat_head.fat) +
fat_head.fat.nfat_arch * sizeof(fat_head.arch[0]));

View File

@ -108,7 +108,7 @@ const int *PackPs1::getCompressionMethods(int method, int level) const
const int *PackPs1::getFilters() const
{
return NULL;
return nullptr;
}
Linker* PackPs1::newLinker() const
@ -166,7 +166,7 @@ void PackPs1::putBkupHeader(const unsigned char *src, unsigned char *dst, unsign
ps1_exe_chb_t * p = (ps1_exe_chb_t * )cpr_bh;
int r = upx_compress(src, SZ_IH_BKUP,
&p->ih_bkup, &sz_cbh, NULL, M_NRV2E_8, 10, NULL, NULL );
&p->ih_bkup, &sz_cbh, nullptr, M_NRV2E_8, 10, nullptr, nullptr );
if (r != UPX_E_OK || sz_cbh >= SZ_IH_BKUP)
throwInternalError("header compression failed");
INIT_BH_BKUP(p, sz_cbh);
@ -193,7 +193,7 @@ bool PackPs1::getBkupHeader(unsigned char *p, unsigned char *dst)
unsigned sz_bh = SZ_IH_BKUP;
int r = upx_decompress((const unsigned char *)&src->ih_bkup, src->len,
unc_bh, &sz_bh, M_NRV2E_8, NULL );
unc_bh, &sz_bh, M_NRV2E_8, nullptr );
if (r == UPX_E_OUT_OF_MEMORY)
throwOutOfMemoryException();
if (r != UPX_E_OK || sz_bh != SZ_IH_BKUP)
@ -285,7 +285,7 @@ bool PackPs1::canPack()
void PackPs1::buildLoader(const Filter *)
{
const char *method = NULL;
const char *method = nullptr;
if (ph.method == M_NRV2B_8)
method = isCon ? "nrv2b.small,8bit.sub,nrv.done" :
@ -329,9 +329,9 @@ void PackPs1::buildLoader(const Filter *)
{
initLoader(stub_mipsel_r3000_ps1, sizeof(stub_mipsel_r3000_ps1));
addLoader("decompressor.start",
isCon ? "LZMA_DEC20" : "LZMA_DEC10", "lzma.init", NULL);
isCon ? "LZMA_DEC20" : "LZMA_DEC10", "lzma.init", nullptr);
addLoader(sa_tmp > (0x10000 << 2) ? "memset.long" : "memset.short",
!foundBss ? "con.exit" : "bss.exit", NULL);
!foundBss ? "con.exit" : "bss.exit", nullptr);
}
else
{
@ -340,7 +340,7 @@ void PackPs1::buildLoader(const Filter *)
sz_lcpr = MemBuffer::getSizeForCompression(sz_lunc);
unsigned char *cprLoader = New(unsigned char, sz_lcpr);
int r = upx_compress(getLoader(), sz_lunc, cprLoader, &sz_lcpr,
NULL, M_NRV2B_8, 10, NULL, NULL );
nullptr, M_NRV2B_8, 10, nullptr, nullptr );
if (r != UPX_E_OK || sz_lcpr >= sz_lunc)
throwInternalError("loader compression failed");
initLoader(stub_mipsel_r3000_ps1, sizeof(stub_mipsel_r3000_ps1),
@ -362,7 +362,7 @@ void PackPs1::buildLoader(const Filter *)
addLoader(!foundBss ? "con.start" : "bss.con.start",
method,
ih.tx_ptr & 0xffff ? "dec.ptr" : "dec.ptr.hi",
"con.entry", "pad.code", "lzma.exec", NULL);
"con.entry", "pad.code", "lzma.exec", nullptr);
else
addLoader(!foundBss ? "con.start" : "bss.con.start", "con.mcpy",
ph.c_len & 3 ? "con.padcd" : "",
@ -370,7 +370,7 @@ void PackPs1::buildLoader(const Filter *)
"con.entry", method,
sa_cnt ? sa_cnt > (0x10000 << 2) ? "memset.long" : "memset.short" : "",
!foundBss ? "con.exit" : "bss.exit",
"pad.code", NULL);
"pad.code", nullptr);
}
else
{
@ -379,7 +379,7 @@ void PackPs1::buildLoader(const Filter *)
!foundBss ? "cdb.entry.lzma" : "bss.cdb.entry.lzma",
method, "cdb.lzma.cpr",
ih.tx_ptr & 0xffff ? "dec.ptr" : "dec.ptr.hi",
"lzma.exec", NULL);
"lzma.exec", nullptr);
else
{
assert(foundBss != true);
@ -387,10 +387,10 @@ void PackPs1::buildLoader(const Filter *)
ih.tx_ptr & 0xffff ? "cdb.dec.ptr" : "cdb.dec.ptr.hi",
method,
sa_cnt ? sa_cnt > (0x10000 << 2) ? "memset.long" : "memset.short" : "",
"cdb.exit", NULL);
"cdb.exit", nullptr);
}
}
addLoader("UPX1HEAD", "IDENTSTR", NULL);
addLoader("UPX1HEAD", "IDENTSTR", nullptr);
}
}

View File

@ -70,9 +70,9 @@ protected:
__packed_struct(ps1_exe_t)
// ident string
char id[8];
// is NULL
// is nullptr
LE32 text;
// is NULL
// is nullptr
LE32 data;
// initial program counter
LE32 epc;

View File

@ -111,7 +111,7 @@ void PackSys::buildLoader(const Filter *ft)
"SYSMAIN3,UPX1HEAD,SYSCUTPO,NRV2B160,NRVDDONE,NRVDECO1",
ph.max_offset_found <= 0xd00 ? "NRVLED00" : "NRVGTD00",
"NRVDECO2",
NULL
nullptr
);
if (ft->id)
{
@ -121,7 +121,7 @@ void PackSys::buildLoader(const Filter *ft)
addLoader("SYSMAIN5",
opt->cpu == opt->CPU_8086 ? "SYSI0862" : "SYSI2862",
"SYSJUMP1",
NULL
nullptr
);
}

View File

@ -93,22 +93,22 @@ void PackTmt::buildLoader(const Filter *ft)
"TMTMAIN1B",
ft->id ? "TMTCALT1" : "",
"TMTMAIN2,UPX1HEAD,TMTCUTPO",
NULL);
nullptr);
// fake alignment for the start of the decompressor
linker->defineSymbol("TMTCUTPO", 0x1000);
addLoader(getDecompressorSections(), "TMTMAIN5", NULL);
addLoader(getDecompressorSections(), "TMTMAIN5", nullptr);
if (ft->id)
{
assert(ft->calls > 0);
addLoader("TMTCALT2",NULL);
addLoader("TMTCALT2",nullptr);
addFilter32(ft->id);
}
addLoader("TMTRELOC,RELOC320",
big_relocs ? "REL32BIG" : "",
"RELOC32J,TMTJUMP1",
NULL
nullptr
);
}

View File

@ -63,7 +63,7 @@ const int *PackTos::getCompressionMethods(int method, int level) const
const int *PackTos::getFilters() const
{
return NULL;
return nullptr;
}

View File

@ -93,9 +93,9 @@ void PackUnix::writePackHeader(OutputFile *fo)
set_le32(buf+0, UPX_MAGIC_LE32);
set_le32(buf+4, UPX_MAGIC2_LE32);
checkPatch(NULL, 0, 0, 0); // reset
checkPatch(nullptr, 0, 0, 0); // reset
patchPackHeader(buf, hsize);
checkPatch(NULL, 0, 0, 0); // reset
checkPatch(nullptr, 0, 0, 0); // reset
fo->write(buf, hsize);
}
@ -179,7 +179,7 @@ int PackUnix::pack2(OutputFile *fo, Filter &ft)
!!n_block++); // check compression ratio only on first block
if (ph.c_len < ph.u_len) {
const upx_bytep tbuf = NULL;
const upx_bytep tbuf = nullptr;
if (ft.id == 0) tbuf = ibuf;
ph.overlap_overhead = OVERHEAD;
if (!testOverlappingDecompression(obuf, tbuf, ph.overlap_overhead)) {
@ -248,7 +248,7 @@ PackUnix::patchLoaderChecksum()
off_t PackUnix::pack3(OutputFile *fo, Filter &ft)
{
if (0==linker) {
if (nullptr==linker) {
// If no filter, then linker is not constructed by side effect
// of packExtent calling compressWithFilters.
// This is typical after "/usr/bin/patchelf --set-rpath".
@ -372,8 +372,8 @@ void PackUnix::packExtent(
}
if (ph.c_len < ph.u_len) {
const upx_bytep tbuf = NULL;
if (ft == NULL || ft->id == 0) tbuf = ibuf;
const upx_bytep tbuf = nullptr;
if (ft == nullptr || ft->id == 0) tbuf = ibuf;
ph.overlap_overhead = OVERHEAD;
if (!testOverlappingDecompression(obuf, tbuf, ph.overlap_overhead)) {
// not in-place compressible
@ -394,8 +394,8 @@ void PackUnix::packExtent(
unsigned hdr_c_len = 0;
MemBuffer hdr_obuf;
hdr_obuf.allocForCompression(hdr_u_len);
int r = upx_compress(hdr_ibuf, hdr_u_len, hdr_obuf, &hdr_c_len, 0,
ph.method, 10, NULL, NULL);
int r = upx_compress(hdr_ibuf, hdr_u_len, hdr_obuf, &hdr_c_len, nullptr,
ph.method, 10, nullptr, nullptr);
if (r != UPX_E_OK)
throwInternalError("header compression failed");
if (hdr_c_len >= hdr_u_len)
@ -566,8 +566,8 @@ void PackUnix::unpack(OutputFile *fo)
? sizeof(bhdr.sz_unc) + sizeof(bhdr.sz_cpr) // old style
: sizeof(bhdr);
unsigned c_adler = upx_adler32(NULL, 0);
unsigned u_adler = upx_adler32(NULL, 0);
unsigned c_adler = upx_adler32(nullptr, 0);
unsigned u_adler = upx_adler32(nullptr, 0);
// defaults for ph.version == 8
unsigned orig_file_size = 0;

View File

@ -42,7 +42,7 @@ protected:
PackUnix(InputFile *f);
public:
virtual int getVersion() const { return 13; }
virtual const int *getFilters() const { return NULL; }
virtual const int *getFilters() const { return nullptr; }
virtual int getStrategy(Filter &);
virtual void pack(OutputFile *fo);

View File

@ -61,10 +61,10 @@ PackVmlinuxBase<T>::PackVmlinuxBase(InputFile *f,
super(f),
my_e_machine(e_machine), my_elfclass(elfclass), my_elfdata(elfdata),
my_boot_label(boot_label),
n_ptload(0), phdri(NULL), shdri(NULL), shstrtab(NULL)
n_ptload(0), phdri(nullptr), shdri(nullptr), shstrtab(nullptr)
{
ElfClass::compileTimeAssertions();
bele = N_BELE_CTP::getRTP((const BeLePolicy*) NULL);
bele = N_BELE_CTP::getRTP((const BeLePolicy*) nullptr);
}
template <class T>
@ -140,7 +140,7 @@ typename T::Shdr const *PackVmlinuxBase<T>::getElfSections()
return p;
}
}
return 0;
return nullptr;
}
template <class T>
@ -173,7 +173,7 @@ bool PackVmlinuxBase<T>::canPack()
// A Linux kernel must have a __ksymtab section. [??]
Shdr const *p, *const shstrsec = getElfSections();
if (0==shstrsec) {
if (nullptr==shstrsec) {
return false;
}
{
@ -230,7 +230,7 @@ void PackVmlinuxBase<T>::pack(OutputFile *fo)
Ehdr ehdro;
TE32 tmp_u32;
// NULL
// nullptr
// .text(PT_LOADs) .note(1st page) .note(rest)
// .shstrtab .symtab .strtab
Shdr shdro[1+3+3];
@ -313,7 +313,7 @@ void PackVmlinuxBase<T>::pack(OutputFile *fo)
memcpy(&unc_hdr[sizeof(ehdri)], phdri, sizeof(Phdr) * ehdri.e_phnum);
unsigned len_cpr = 0;
int const r = upx_compress(unc_hdr, len_unc, cpr_hdr, &len_cpr,
NULL, ph.method, 10, NULL, NULL );
nullptr, ph.method, 10, nullptr, nullptr );
if (UPX_E_OK!=r || len_unc<=len_cpr) // FIXME: allow no compression
throwInternalError("Ehdr compression failed");
@ -371,7 +371,7 @@ void PackVmlinuxBase<T>::pack(OutputFile *fo)
}
compressWithFilters(ibuf, ph.u_len, obuf,
f_ptr, f_len, // filter range
NULL, 0, // hdr_ptr, hdr_len
nullptr, 0, // hdr_ptr, hdr_len
&ft, 512, &cconf, getStrategy(ft));
set_be32(&hdr_info.sz_unc, ph.u_len);
@ -581,12 +581,12 @@ int PackVmlinuxBase<T>::canUnpack()
// find the .shstrtab section
Shdr const *const shstrsec = getElfSections();
if (0==shstrsec) {
if (nullptr==shstrsec) {
return false;
}
// check for .text .note .note and sane (.sh_size + .sh_offset)
p_note0 = p_note1 = p_text = 0;
p_note0 = p_note1 = p_text = nullptr;
int j;
Shdr *p;
for (p= shdri, j= ehdri.e_shnum; --j>=0; ++p) {
@ -599,15 +599,15 @@ int PackVmlinuxBase<T>::canUnpack()
p_text = p;
}
if (0==strcmp(".note", shstrtab + p->sh_name)) {
if (0==p_note0) {
if (nullptr==p_note0) {
p_note0 = p;
} else
if (0==p_note1) {
if (nullptr==p_note1) {
p_note1 = p;
}
}
}
if (0==p_text || 0==p_note0 || 0==p_note1) {
if (nullptr==p_text || nullptr==p_note0 || nullptr==p_note1) {
return false;
}
@ -781,21 +781,21 @@ void PackVmlinuxI386::buildLoader(const Filter *ft)
(0x40==(0xf0 & ft->id)) ? "LXCKLLT1" : (ft->id ? "LXCALLT1" : ""),
"LXMOVEUP",
getDecompressorSections(),
NULL
nullptr
);
if (ft->id) {
assert(ft->calls > 0);
if (0x40==(0xf0 & ft->id)) {
addLoader("LXCKLLT9", NULL);
addLoader("LXCKLLT9", nullptr);
}
else {
addLoader("LXCALLT9", NULL);
addLoader("LXCALLT9", nullptr);
}
addFilter32(ft->id);
}
addLoader("LINUX990",
((ph.first_offset_found == 1) ? "LINUX991" : ""),
"LINUX992,IDENTSTR,UPX1HEAD", NULL);
"LINUX992,IDENTSTR,UPX1HEAD", nullptr);
}
void PackVmlinuxAMD64::buildLoader(const Filter *ft)
@ -806,21 +806,21 @@ void PackVmlinuxAMD64::buildLoader(const Filter *ft)
(0x40==(0xf0 & ft->id)) ? "LXCKLLT1" : (ft->id ? "LXCALLT1" : ""),
"LXMOVEUP",
getDecompressorSections(),
NULL
nullptr
);
if (ft->id) {
assert(ft->calls > 0);
if (0x40==(0xf0 & ft->id)) {
addLoader("LXCKLLT9", NULL);
addLoader("LXCKLLT9", nullptr);
}
else {
addLoader("LXCALLT9", NULL);
addLoader("LXCALLT9", nullptr);
}
addFilter32(ft->id);
}
addLoader("LINUX990",
((ph.first_offset_found == 1) ? "LINUX991" : ""),
"LINUX992,IDENTSTR,UPX1HEAD", NULL);
"LINUX992,IDENTSTR,UPX1HEAD", nullptr);
}
bool PackVmlinuxARMEL::is_valid_e_entry(Addr e_entry)
@ -868,69 +868,69 @@ void PackVmlinuxARMEL::buildLoader(const Filter *ft)
{
// prepare loader
initLoader(stub_arm_v5a_linux_kernel_vmlinux, sizeof(stub_arm_v5a_linux_kernel_vmlinux));
addLoader("LINUX000", NULL);
addLoader("LINUX000", nullptr);
if (ft->id) {
assert(ft->calls > 0);
addLoader("LINUX010", NULL);
addLoader("LINUX010", nullptr);
}
addLoader("LINUX020", NULL);
addLoader("LINUX020", nullptr);
if (ft->id) {
addFilter32(ft->id);
}
addLoader("LINUX030", NULL);
if (ph.method == M_NRV2E_8) addLoader("NRV2E", NULL);
else if (ph.method == M_NRV2B_8) addLoader("NRV2B", NULL);
else if (ph.method == M_NRV2D_8) addLoader("NRV2D", NULL);
else if (M_IS_LZMA(ph.method)) addLoader("LZMA_ELF00,LZMA_DEC10,LZMA_DEC30", NULL);
addLoader("LINUX030", nullptr);
if (ph.method == M_NRV2E_8) addLoader("NRV2E", nullptr);
else if (ph.method == M_NRV2B_8) addLoader("NRV2B", nullptr);
else if (ph.method == M_NRV2D_8) addLoader("NRV2D", nullptr);
else if (M_IS_LZMA(ph.method)) addLoader("LZMA_ELF00,LZMA_DEC10,LZMA_DEC30", nullptr);
else throwBadLoader();
addLoader("IDENTSTR,UPX1HEAD", NULL);
addLoader("IDENTSTR,UPX1HEAD", nullptr);
}
void PackVmlinuxARMEB::buildLoader(const Filter *ft)
{
// prepare loader
initLoader(stub_armeb_v5a_linux_kernel_vmlinux, sizeof(stub_armeb_v5a_linux_kernel_vmlinux));
addLoader("LINUX000", NULL);
addLoader("LINUX000", nullptr);
if (ft->id) {
assert(ft->calls > 0);
addLoader("LINUX010", NULL);
addLoader("LINUX010", nullptr);
}
addLoader("LINUX020", NULL);
addLoader("LINUX020", nullptr);
if (ft->id) {
addFilter32(ft->id);
}
addLoader("LINUX030", NULL);
if (ph.method == M_NRV2E_8) addLoader("NRV2E", NULL);
else if (ph.method == M_NRV2B_8) addLoader("NRV2B", NULL);
else if (ph.method == M_NRV2D_8) addLoader("NRV2D", NULL);
else if (M_IS_LZMA(ph.method)) addLoader("LZMA_ELF00,LZMA_DEC10,LZMA_DEC30", NULL);
addLoader("LINUX030", nullptr);
if (ph.method == M_NRV2E_8) addLoader("NRV2E", nullptr);
else if (ph.method == M_NRV2B_8) addLoader("NRV2B", nullptr);
else if (ph.method == M_NRV2D_8) addLoader("NRV2D", nullptr);
else if (M_IS_LZMA(ph.method)) addLoader("LZMA_ELF00,LZMA_DEC10,LZMA_DEC30", nullptr);
else throwBadLoader();
addLoader("IDENTSTR,UPX1HEAD", NULL);
addLoader("IDENTSTR,UPX1HEAD", nullptr);
}
void PackVmlinuxPPC32::buildLoader(const Filter *ft)
{
// prepare loader
initLoader(stub_powerpc_linux_kernel_vmlinux, sizeof(stub_powerpc_linux_kernel_vmlinux));
addLoader("LINUX000", NULL);
addLoader("LINUX000", nullptr);
if (ft->id) {
assert(ft->calls > 0);
addLoader("LINUX010", NULL);
addLoader("LINUX010", nullptr);
}
addLoader("LINUX020", NULL);
addLoader("LINUX020", nullptr);
if (ft->id) {
addFilter32(ft->id);
}
addLoader("LINUX030", NULL);
if (ph.method == M_NRV2E_LE32) addLoader("NRV2E,NRV_TAIL", NULL);
else if (ph.method == M_NRV2B_LE32) addLoader("NRV2B,NRV_TAIL", NULL);
else if (ph.method == M_NRV2D_LE32) addLoader("NRV2D,NRV_TAIL", NULL);
else if (M_IS_LZMA(ph.method)) addLoader("LZMA_ELF00,LZMA_DEC10,LZMA_DEC30", NULL);
addLoader("LINUX030", nullptr);
if (ph.method == M_NRV2E_LE32) addLoader("NRV2E,NRV_TAIL", nullptr);
else if (ph.method == M_NRV2B_LE32) addLoader("NRV2B,NRV_TAIL", nullptr);
else if (ph.method == M_NRV2D_LE32) addLoader("NRV2D,NRV_TAIL", nullptr);
else if (M_IS_LZMA(ph.method)) addLoader("LZMA_ELF00,LZMA_DEC10,LZMA_DEC30", nullptr);
else throwBadLoader();
if (hasLoaderSection("CFLUSH"))
addLoader("CFLUSH");
addLoader("IDENTSTR,UPX1HEAD", NULL);
addLoader("IDENTSTR,UPX1HEAD", nullptr);
}
static const
@ -939,25 +939,25 @@ void PackVmlinuxPPC64LE::buildLoader(const Filter *ft)
{
// prepare loader
initLoader(stub_powerpc64le_linux_kernel_vmlinux, sizeof(stub_powerpc64le_linux_kernel_vmlinux));
addLoader("LINUX000", NULL);
addLoader("LINUX000", nullptr);
if (ft->id) {
assert(ft->calls > 0);
addLoader("LINUX010", NULL);
addLoader("LINUX010", nullptr);
}
addLoader("LINUX020", NULL);
addLoader("LINUX020", nullptr);
if (ft->id) {
addFilter32(ft->id);
}
addLoader("LINUX030", NULL);
if (ph.method == M_NRV2E_LE32) addLoader("NRV2E,NRV_TAIL", NULL);
else if (ph.method == M_NRV2B_LE32) addLoader("NRV2B,NRV_TAIL", NULL);
else if (ph.method == M_NRV2D_LE32) addLoader("NRV2D,NRV_TAIL", NULL);
else if (M_IS_LZMA(ph.method)) addLoader("LZMA_ELF00,LZMA_DEC10,LZMA_DEC30", NULL);
addLoader("LINUX030", nullptr);
if (ph.method == M_NRV2E_LE32) addLoader("NRV2E,NRV_TAIL", nullptr);
else if (ph.method == M_NRV2B_LE32) addLoader("NRV2B,NRV_TAIL", nullptr);
else if (ph.method == M_NRV2D_LE32) addLoader("NRV2D,NRV_TAIL", nullptr);
else if (M_IS_LZMA(ph.method)) addLoader("LZMA_ELF00,LZMA_DEC10,LZMA_DEC30", nullptr);
else throwBadLoader();
if (hasLoaderSection("CFLUSH"))
addLoader("CFLUSH");
addLoader("IDENTSTR,UPX1HEAD", NULL);
addLoader("IDENTSTR,UPX1HEAD", nullptr);
}

View File

@ -159,7 +159,7 @@ int PackVmlinuzI386::decompressKernel()
fi->readx(obuf, file_size);
{
const upx_byte *base = NULL;
const upx_byte *base = nullptr;
unsigned relocated = 0;
// See startup_32: in linux/arch/i386/boot/compressed/head.S
@ -270,7 +270,7 @@ int PackVmlinuzI386::decompressKernel()
if (fd < 0)
break;
gzFile zf = gzdopen(fd, "rb");
if (zf == NULL)
if (zf == nullptr)
break;
// estimate gzip-decompressed kernel size & alloc buffer
if (ibuf.getSize() == 0)
@ -434,15 +434,15 @@ void PackVmlinuzI386::buildLoader(const Filter *ft)
ft->id ? "LZCALLT1" : "",
"LZIMAGE0",
getDecompressorSections(),
NULL
nullptr
);
if (ft->id)
{
assert(ft->calls > 0);
addLoader("LZCALLT9", NULL);
addLoader("LZCALLT9", nullptr);
addFilter32(ft->id);
}
addLoader("LINUZ990,IDENTSTR,UPX1HEAD", NULL);
addLoader("LINUZ990,IDENTSTR,UPX1HEAD", nullptr);
}
@ -511,7 +511,7 @@ void PackBvmlinuzI386::buildLoader(const Filter *ft)
"LINUZ140,LZCUTPOI,LINUZ141",
(ft->id ? "LINUZ145" : ""),
(ph.first_offset_found == 1 ? "LINUZ010" : ""),
NULL);
nullptr);
}
else {
addLoader("LINUZ000,LINUZ001,LINUZVGA,LINUZ005",
@ -521,26 +521,26 @@ void PackBvmlinuzI386::buildLoader(const Filter *ft)
"+40", // align the stuff to 4 byte boundary
"UPX1HEAD", // 32 byte
"LZCUTPOI",
NULL);
nullptr);
// fake alignment for the start of the decompressor
//linker->defineSymbol("LZCUTPOI", 0x1000);
}
addLoader(getDecompressorSections(), NULL);
addLoader(getDecompressorSections(), nullptr);
if (ft->id)
{
assert(ft->calls > 0);
if (0x40==(0xf0 & ft->id)) {
addLoader("LZCKLLT9", NULL);
addLoader("LZCKLLT9", nullptr);
}
else {
addLoader("LZCALLT9", NULL);
addLoader("LZCALLT9", nullptr);
}
addFilter32(ft->id);
}
if (0!=page_offset) {
addLoader("LINUZ150,IDENTSTR,+40,UPX1HEAD", NULL);
addLoader("LINUZ150,IDENTSTR,+40,UPX1HEAD", nullptr);
unsigned const l_len = getLoaderSize();
unsigned const c_len = ALIGN_UP(ph.c_len, 4u);
unsigned const e_len = getLoaderSectionStart("LINUZ141") -
@ -558,7 +558,7 @@ void PackBvmlinuzI386::buildLoader(const Filter *ft)
linker->defineSymbol("unc_offset", ph.overlap_overhead + ph.u_len - c_len);
}
else {
addLoader("LINUZ990", NULL);
addLoader("LINUZ990", nullptr);
}
}
@ -852,7 +852,7 @@ int PackVmlinuzARMEL::decompressKernel()
if (fd < 0)
break;
gzFile zf = gzdopen(fd, "rb");
if (zf == NULL)
if (zf == nullptr)
break;
// estimate gzip-decompressed kernel size & alloc buffer
if (ibuf.getSize() == 0)
@ -929,23 +929,23 @@ void PackVmlinuzARMEL::buildLoader(const Filter *ft)
{
// prepare loader; same as vmlinux (with 'x')
initLoader(stub_arm_v5a_linux_kernel_vmlinux, sizeof(stub_arm_v5a_linux_kernel_vmlinux));
addLoader("LINUX000", NULL);
addLoader("LINUX000", nullptr);
if (ft->id) {
assert(ft->calls > 0);
addLoader("LINUX010", NULL);
addLoader("LINUX010", nullptr);
}
addLoader("LINUX020", NULL);
addLoader("LINUX020", nullptr);
if (ft->id) {
addFilter32(ft->id);
}
addLoader("LINUX030", NULL);
if (ph.method == M_NRV2E_8) addLoader("NRV2E", NULL);
else if (ph.method == M_NRV2B_8) addLoader("NRV2B", NULL);
else if (ph.method == M_NRV2D_8) addLoader("NRV2D", NULL);
addLoader("LINUX030", nullptr);
if (ph.method == M_NRV2E_8) addLoader("NRV2E", nullptr);
else if (ph.method == M_NRV2B_8) addLoader("NRV2B", nullptr);
else if (ph.method == M_NRV2D_8) addLoader("NRV2D", nullptr);
else if (M_IS_LZMA(ph.method)) addLoader("LZMA_ELF00",
(opt->small ? "LZMA_DEC10" : "LZMA_DEC20"), "LZMA_DEC30", NULL);
(opt->small ? "LZMA_DEC10" : "LZMA_DEC20"), "LZMA_DEC30", nullptr);
else throwBadLoader();
addLoader("IDENTSTR,UPX1HEAD", NULL);
addLoader("IDENTSTR,UPX1HEAD", nullptr);
// To debug (2008-09-14):
// Build gdb-6.8-21.fc9.src.rpm; ./configure --target=arm-none-elf; make

View File

@ -117,13 +117,13 @@ void PackW32Pe::buildLoader(const Filter *ft)
getDecompressorSections(),
/*multipass ? "PEMULTIP" : */ "",
"PEMAIN10",
NULL
nullptr
);
if (ft->id)
{
const unsigned texv = ih.codebase - rvamin;
assert(ft->calls > 0);
addLoader(texv ? "PECTTPOS" : "PECTTNUL",NULL);
addLoader(texv ? "PECTTPOS" : "PECTTNUL",nullptr);
addFilter32(ft->id);
}
if (soimport)
@ -134,7 +134,7 @@ void PackW32Pe::buildLoader(const Filter *ft)
"PEIMPOR2",
isdll ? "PEIERDLL" : "PEIEREXE",
"PEIMDONE",
NULL
nullptr
);
if (sorelocs)
{
@ -142,34 +142,34 @@ void PackW32Pe::buildLoader(const Filter *ft)
"PERELOC3,RELOC320",
big_relocs ? "REL32BIG" : "",
"RELOC32J",
NULL
nullptr
);
//FIXME: the following should be moved out of the above if
addLoader(big_relocs&6 ? "PERLOHI0" : "",
big_relocs&4 ? "PERELLO0" : "",
big_relocs&2 ? "PERELHI0" : "",
NULL
nullptr
);
}
if (use_dep_hack)
addLoader("PEDEPHAK", NULL);
addLoader("PEDEPHAK", nullptr);
//NEW: TLS callback support PART 1, the callback handler installation - Stefan Widmann
if(use_tls_callbacks)
addLoader("PETLSC", NULL);
addLoader("PETLSC", nullptr);
addLoader("PEMAIN20", NULL);
addLoader("PEMAIN20", nullptr);
if (use_clear_dirty_stack)
addLoader("CLEARSTACK", NULL);
addLoader("PEMAIN21", NULL);
addLoader("CLEARSTACK", nullptr);
addLoader("PEMAIN21", nullptr);
//NEW: last loader sections split up to insert TLS callback handler - Stefan Widmann
addLoader(ih.entry ? "PEDOJUMP" : "PERETURN", NULL);
addLoader(ih.entry ? "PEDOJUMP" : "PERETURN", nullptr);
//NEW: TLS callback support PART 2, the callback handler - Stefan Widmann
if(use_tls_callbacks)
addLoader("PETLSC2", NULL);
addLoader("PETLSC2", nullptr);
addLoader("IDENTSTR,UPX1HEAD", NULL);
addLoader("IDENTSTR,UPX1HEAD", nullptr);
}

View File

@ -114,14 +114,14 @@ void PackW64Pep::buildLoader(const Filter *ft)
//getDecompressorSections(),
/*multipass ? "PEMULTIP" : */ "",
"PEMAIN10",
NULL
nullptr
);
addLoader(tmp_tlsindex ? "PETLSHAK2" : "");
if (ft->id)
{
const unsigned texv = ih.codebase - rvamin;
assert(ft->calls > 0);
addLoader(texv ? "PECTTPOS" : "PECTTNUL",NULL);
addLoader(texv ? "PECTTPOS" : "PECTTNUL",nullptr);
addLoader("PEFILTER49");
}
if (soimport)
@ -132,7 +132,7 @@ void PackW64Pep::buildLoader(const Filter *ft)
"PEIMPOR2",
isdll ? "PEIERDLL" : "PEIEREXE",
"PEIMDONE",
NULL
nullptr
);
if (sorelocs)
{
@ -140,38 +140,38 @@ void PackW64Pep::buildLoader(const Filter *ft)
"PERELOC3",
big_relocs ? "REL64BIG" : "",
"RELOC64J",
NULL
nullptr
);
if __acc_cte(0)
{
addLoader(big_relocs&6 ? "PERLOHI0" : "",
big_relocs&4 ? "PERELLO0" : "",
big_relocs&2 ? "PERELHI0" : "",
NULL
nullptr
);
}
}
if (use_dep_hack)
addLoader("PEDEPHAK", NULL);
addLoader("PEDEPHAK", nullptr);
//NEW: TLS callback support PART 1, the callback handler installation - Stefan Widmann
if(use_tls_callbacks)
addLoader("PETLSC", NULL);
addLoader("PETLSC", nullptr);
addLoader("PEMAIN20", NULL);
addLoader("PEMAIN20", nullptr);
if (use_clear_dirty_stack)
addLoader("CLEARSTACK", NULL);
addLoader("PEMAIN21", NULL);
addLoader("CLEARSTACK", nullptr);
addLoader("PEMAIN21", nullptr);
if (ih.entry && isdll)
addLoader("PEISDLL9");
addLoader(ih.entry ? "PEDOJUMP" : "PERETURN", NULL);
addLoader(ih.entry ? "PEDOJUMP" : "PERETURN", nullptr);
//NEW: TLS callback support PART 2, the callback handler - Stefan Widmann
if(use_tls_callbacks)
addLoader("PETLSC2", NULL);
addLoader("PETLSC2", nullptr);
addLoader("IDENTSTR,UPX1HEAD", NULL);
addLoader("IDENTSTR,UPX1HEAD", nullptr);
}
bool PackW64Pep::handleForceOption()

View File

@ -95,16 +95,16 @@ void PackWcle::buildLoader(const Filter *ft)
initLoader(stub_i386_dos32_watcom_le, sizeof(stub_i386_dos32_watcom_le));
addLoader("IDENTSTR,WCLEMAIN",
ph.first_offset_found == 1 ? "WCLEMAIN02" : "",
"WCLEMAIN03,UPX1HEAD,WCLECUTP", NULL);
"WCLEMAIN03,UPX1HEAD,WCLECUTP", nullptr);
// fake alignment for the start of the decompressor
linker->defineSymbol("WCLECUTP", 0x1000);
addLoader(getDecompressorSections(), "WCLEMAI2", NULL);
addLoader(getDecompressorSections(), "WCLEMAI2", nullptr);
if (ft->id)
{
assert(ft->calls > 0);
addLoader(ft->addvalue ? "WCCTTPOS" : "WCCTTNUL", NULL);
addLoader(ft->addvalue ? "WCCTTPOS" : "WCCTTNUL", nullptr);
addFilter32(ft->id);
}
#if 1
@ -113,13 +113,13 @@ void PackWcle::buildLoader(const Filter *ft)
addLoader("WCRELOC1,RELOC320",
big_relocs ? "REL32BIG" : "",
"RELOC32J",
NULL
nullptr
);
}
#endif
addLoader(has_extra_code ? "WCRELSEL" : "",
"WCLEMAI4",
NULL
nullptr
);
}
@ -178,7 +178,7 @@ void PackWcle::encodeEntryTable()
soentries = ptr_diff(p, ientries) + 1;
oentries = ientries;
ientries = NULL;
ientries = nullptr;
}
@ -425,7 +425,7 @@ void PackWcle::encodeImage(Filter *ft)
memcpy(ibuf,iimage,soimage);
memcpy(ibuf+soimage,ifixups,sofixups);
delete[] ifixups; ifixups = NULL;
delete[] ifixups; ifixups = nullptr;
oimage.allocForCompression(isize, RESERVED+512);
// prepare packheader
@ -437,7 +437,7 @@ void PackWcle::encodeImage(Filter *ft)
compressWithFilters(ibuf, isize,
oimage + RESERVED,
ibuf + ft->addvalue, ft->buf_len,
NULL, 0,
nullptr, 0,
ft, 512, &cconf, 0);
ibuf.dealloc();
@ -766,7 +766,7 @@ void PackWcle::decodeEntryTable()
soentries = ptr_diff(p, ientries) + 1;
oentries = ientries;
ientries = NULL;
ientries = nullptr;
}

View File

@ -39,12 +39,12 @@
**************************************************************************/
Packer::Packer(InputFile *f) :
bele(NULL),
bele(nullptr),
fi(f), file_size(-1), ph_format(-1), ph_version(-1),
uip(NULL), linker(NULL),
last_patch(NULL), last_patch_len(0), last_patch_off(0)
uip(nullptr), linker(nullptr),
last_patch(nullptr), last_patch_len(0), last_patch_off(0)
{
if (fi != NULL)
if (fi != nullptr)
file_size = fi->st_size();
uip = new UiPacker(this);
mem_clear(&ph, sizeof(ph));
@ -53,8 +53,8 @@ Packer::Packer(InputFile *f) :
Packer::~Packer()
{
delete uip; uip = NULL;
delete linker; linker = NULL;
delete uip; uip = nullptr;
delete linker; linker = nullptr;
}
@ -68,9 +68,9 @@ void Packer::assertPacker() const
assert(strlen(getName()) <= 15);
// info: 36 is the limit for show_all_packers() in help.cpp
assert(strlen(getFullName(opt)) <= 32);
assert(strlen(getFullName(NULL)) <= 32);
if (bele == NULL) fprintf(stderr, "%s\n", getName());
assert(bele != NULL);
assert(strlen(getFullName(nullptr)) <= 32);
if (bele == nullptr) fprintf(stderr, "%s\n", getName());
assert(bele != nullptr);
if (getFormat() != UPX_F_MACH_FAT) // macho/fat is multiarch
{
const N_BELE_RTP::AbstractPolicy *format_bele;
@ -136,7 +136,7 @@ void Packer::doFileInfo()
void Packer::test()
{
unpack(NULL);
unpack(nullptr);
}
@ -639,11 +639,11 @@ unsigned Packer::getRandomId() const
while (id == 0)
{
#if !(HAVE_GETTIMEOFDAY) || ((ACC_OS_DOS32) && defined(__DJGPP__))
id ^= (unsigned) time(NULL);
id ^= (unsigned) time(nullptr);
id ^= ((unsigned) clock()) << 12;
#else
struct timeval tv;
gettimeofday(&tv, 0);
gettimeofday(&tv, nullptr);
id ^= (unsigned) tv.tv_sec;
id ^= ((unsigned) tv.tv_usec) << 12; // shift into high-bits
#endif
@ -670,7 +670,7 @@ void Packer::initPackHeader()
ph.format = getFormat();
ph.method = M_NONE;
ph.level = -1;
ph.u_adler = ph.c_adler = ph.saved_u_adler = ph.saved_c_adler = upx_adler32(NULL,0);
ph.u_adler = ph.c_adler = ph.saved_u_adler = ph.saved_c_adler = upx_adler32(nullptr,0);
ph.buf_offset = 0;
ph.u_file_size = file_size;
}
@ -788,15 +788,15 @@ void Packer::checkAlreadyPacked(const void *b, int blen)
void Packer::checkPatch(void *b, int blen, int boff, int size)
{
if (b == NULL && blen == 0 && boff == 0 && size == 0)
if (b == nullptr && blen == 0 && boff == 0 && size == 0)
{
// reset
last_patch = NULL;
last_patch = nullptr;
last_patch_len = 0;
last_patch_off = 0;
return;
}
if (b == NULL || blen <= 0 || boff < 0 || size <= 0)
if (b == nullptr || blen <= 0 || boff < 0 || size <= 0)
throwBadLoader();
if (boff + size <= 0 || boff + size > blen)
throwBadLoader();
@ -1091,7 +1091,7 @@ static const char *getIdentstr(unsigned *size, int small)
{ identbig, (int)sizeof(identbig) },
{ identsmall, (int)sizeof(identsmall) },
{ identtiny, (int)sizeof(identtiny) },
{ NULL, 0 } };
{ nullptr, 0 } };
const strinfo_t* iter;
for (iter = strlist; iter->s; ++iter)
@ -1139,7 +1139,7 @@ void Packer::initLoader(const void *pdata, int plen, int small)
#define C const char *
#define N ACC_STATIC_CAST(void *, 0)
#define N ACC_STATIC_CAST(void *, nullptr)
void Packer::addLoader(C a)
{ addLoaderVA(a, N); }
void Packer::addLoader(C a, C b)
@ -1175,7 +1175,7 @@ upx_byte *Packer::getLoader() const
{
int size = -1;
upx_byte *oloader = linker->getLoader(&size);
if (oloader == NULL || size <= 0)
if (oloader == nullptr || size <= 0)
throwBadLoader();
return oloader;
}
@ -1184,7 +1184,7 @@ int Packer::getLoaderSize() const
{
int size = -1;
upx_byte *oloader = linker->getLoader(&size);
if (oloader == NULL || size <= 0)
if (oloader == nullptr || size <= 0)
throwBadLoader();
return size;
}
@ -1192,7 +1192,7 @@ int Packer::getLoaderSize() const
bool Packer::hasLoaderSection(const char *name) const
{
void *section = linker->findSection(name, false);
return section != NULL;
return section != nullptr;
}
int Packer::getLoaderSection(const char *name, int *slen) const
@ -1289,7 +1289,7 @@ void Packer::relocateLoader()
static int prepareMethods(int *methods, int ph_method, const int *all_methods)
{
int nmethods = 0;
if (!opt->all_methods || all_methods == NULL)
if (!opt->all_methods || all_methods == nullptr)
{
methods[nmethods++] = ph_method;
return nmethods;
@ -1431,7 +1431,7 @@ void Packer::compressWithFilters(upx_bytep i_ptr, unsigned i_len,
{
assert(isValidCompressionMethod(methods[mm]));
unsigned hdr_c_len = 0;
if (hdr_ptr != NULL && hdr_len)
if (hdr_ptr != nullptr && hdr_len)
{
if (nfilters_success_total != 0 && o_tmp == o_ptr)
{
@ -1440,7 +1440,7 @@ void Packer::compressWithFilters(upx_bytep i_ptr, unsigned i_len,
o_tmp = o_tmp_buf;
}
int r = upx_compress(hdr_ptr, hdr_len, o_tmp, &hdr_c_len,
NULL, methods[mm], 10, NULL, NULL);
nullptr, methods[mm], 10, nullptr, nullptr);
if (r != UPX_E_OK)
throwInternalError("header compression failed");
if (hdr_c_len >= hdr_len)
@ -1584,7 +1584,7 @@ void Packer::compressWithFilters(Filter *ft,
bool inhibit_compression_check)
{
compressWithFilters(ft, overlap_range, cconf, filter_strategy,
0, 0, 0, NULL, 0, inhibit_compression_check);
0, 0, 0, nullptr, 0, inhibit_compression_check);
}

View File

@ -170,9 +170,9 @@ public:
protected:
// main compression drivers
virtual bool compress(upx_bytep i_ptr, unsigned i_len, upx_bytep o_ptr,
const upx_compress_config_t *cconf = NULL);
const upx_compress_config_t *cconf = nullptr);
virtual void decompress(const upx_bytep in, upx_bytep out,
bool verify_checksum = true, Filter *ft = NULL);
bool verify_checksum = true, Filter *ft = nullptr);
virtual bool checkDefaultCompressionRatio(unsigned u_len, unsigned c_len) const;
virtual bool checkCompressionRatio(unsigned u_len, unsigned c_len) const;
virtual bool checkFinalCompressionRatio(const OutputFile *fo) const;
@ -214,8 +214,8 @@ protected:
unsigned range = 0,
unsigned upper_limit = ~0u) const;
// destructive decompress + verify
void verifyOverlappingDecompression(Filter *ft = NULL);
void verifyOverlappingDecompression(upx_bytep o_ptr, unsigned o_size, Filter *ft = NULL);
void verifyOverlappingDecompression(Filter *ft = nullptr);
void verifyOverlappingDecompression(upx_bytep o_ptr, unsigned o_size, Filter *ft = nullptr);
// packheader handling
virtual int patchPackHeader(void *b, int blen);
@ -244,8 +244,8 @@ protected:
void __acc_cdecl_va addLoaderVA(const char *s, ...);
#endif
virtual bool hasLoaderSection(const char *name) const;
virtual int getLoaderSection(const char *name, int *slen=NULL) const;
virtual int getLoaderSectionStart(const char *name, int *slen=NULL) const;
virtual int getLoaderSection(const char *name, int *slen=nullptr) const;
virtual int getLoaderSectionStart(const char *name, int *slen=nullptr) const;
// compression handling [see packer_c.cpp]
public:
@ -325,8 +325,8 @@ private:
private:
// disable copy and assignment
Packer(const Packer &); // {}
Packer& operator= (const Packer &); // { return *this; }
Packer(const Packer &) = delete;
Packer& operator= (const Packer &) = delete;
};

View File

@ -228,7 +228,7 @@ const char *Packer::getDecompressorSections() const
return opt->small ? lzma_small : lzma_fast;
}
throwInternalError("bad decompressor");
return NULL;
return nullptr;
}

View File

@ -76,7 +76,7 @@ void Packer::addFilter32(int filter_id)
addLoader("ctok32.00",
((0x50==filter_id) ? "ctok32.50" :
(0x51==filter_id) ? "ctok32.51" : ""),
"ctok32.10", NULL);
"ctok32.10", nullptr);
}
else if ((filter_id & 0xf) % 3 == 0) {
if (filter_id < 0x40) {
@ -85,19 +85,19 @@ void Packer::addFilter32(int filter_id)
"CALLTR01",
(filter_id & 0xf) > 3 ? (filter_id > 0x20 ? "CTBSHR01,CTBSWA01" : "CTBROR01,CTBSWA01") : "",
"CALLTR02",
NULL
nullptr
);
}
else if (0x40==(0xF0 & filter_id)) {
addLoader("ctok32.00", NULL);
addLoader("ctok32.00", nullptr);
if (9<=(0xf & filter_id)) {
addLoader("ctok32.10", NULL);
addLoader("ctok32.10", nullptr);
}
addLoader("ctok32.20", NULL);
addLoader("ctok32.20", nullptr);
if (9<=(0xf & filter_id)) {
addLoader("ctok32.30", NULL);
addLoader("ctok32.30", nullptr);
}
addLoader("ctok32.40", NULL);
addLoader("ctok32.40", nullptr);
}
}
else
@ -108,7 +108,7 @@ void Packer::addFilter32(int filter_id)
"CALLTR12",
(filter_id & 0xf) > 3 ? (filter_id > 0x20 ? "CTBSHR11,CTBSWA11" : "CTBROR11,CTBSWA11") : "",
"CALLTR13",
NULL
nullptr
);
}
if (0x80==(filter_id & 0xF0)) {
@ -120,187 +120,187 @@ void Packer::addFilter32(int filter_id)
unsigned const f_jcc2 = f80_jcc2(filter_id);
if (NOFILT!=f_jcc2) {
addLoader("LXJCC010", NULL);
addLoader("LXJCC010", nullptr);
if (n_mru) {
addLoader("LXMRU045", NULL);
addLoader("LXMRU045", nullptr);
}
else {
addLoader("LXMRU046", NULL);
addLoader("LXMRU046", nullptr);
}
if (0==n_mru || MRUFLT!=f_jcc2) {
addLoader("LXJCC020", NULL);
addLoader("LXJCC020", nullptr);
}
else { // 0!=n_mru
addLoader("LXJCC021", NULL);
addLoader("LXJCC021", nullptr);
}
if (NOFILT!=f_jcc2) {
addLoader("LXJCC023", NULL);
addLoader("LXJCC023", nullptr);
}
}
addLoader("LXUNF037", NULL);
addLoader("LXUNF037", nullptr);
if (x386) {
if (n_mru) {
addLoader("LXUNF386", NULL);
addLoader("LXUNF386", nullptr);
}
addLoader("LXUNF387", NULL);
addLoader("LXUNF387", nullptr);
if (n_mru) {
addLoader("LXUNF388", NULL);
addLoader("LXUNF388", nullptr);
}
}
else {
addLoader("LXUNF486", NULL);
addLoader("LXUNF486", nullptr);
if (n_mru) {
addLoader("LXUNF487", NULL);
addLoader("LXUNF487", nullptr);
}
}
if (n_mru) {
addLoader("LXMRU065", NULL);
addLoader("LXMRU065", nullptr);
if (256==n_mru) {
addLoader("MRUBYTE3", NULL);
addLoader("MRUBYTE3", nullptr);
}
else {
addLoader("MRUARB30", NULL);
addLoader("MRUARB30", nullptr);
if (mrupwr2) {
addLoader("MRUBITS3", NULL);
addLoader("MRUBITS3", nullptr);
}
else {
addLoader("MRUARB40", NULL);
addLoader("MRUARB40", nullptr);
}
}
addLoader("LXMRU070", NULL);
addLoader("LXMRU070", nullptr);
if (256==n_mru) {
addLoader("MRUBYTE4", NULL);
addLoader("MRUBYTE4", nullptr);
}
else if (mrupwr2) {
addLoader("MRUBITS4", NULL);
addLoader("MRUBITS4", nullptr);
}
else {
addLoader("MRUARB50", NULL);
addLoader("MRUARB50", nullptr);
}
addLoader("LXMRU080", NULL);
addLoader("LXMRU080", nullptr);
if (256==n_mru) {
addLoader("MRUBYTE5", NULL);
addLoader("MRUBYTE5", nullptr);
}
else {
addLoader("MRUARB60", NULL);
addLoader("MRUARB60", nullptr);
if (mrupwr2) {
addLoader("MRUBITS5", NULL);
addLoader("MRUBITS5", nullptr);
}
else {
addLoader("MRUARB70", NULL);
addLoader("MRUARB70", nullptr);
}
}
addLoader("LXMRU090", NULL);
addLoader("LXMRU090", nullptr);
if (256==n_mru) {
addLoader("MRUBYTE6", NULL);
addLoader("MRUBYTE6", nullptr);
}
else {
addLoader("MRUARB80", NULL);
addLoader("MRUARB80", nullptr);
if (mrupwr2) {
addLoader("MRUBITS6", NULL);
addLoader("MRUBITS6", nullptr);
}
else {
addLoader("MRUARB90", NULL);
addLoader("MRUARB90", nullptr);
}
}
addLoader("LXMRU100", NULL);
addLoader("LXMRU100", nullptr);
}
addLoader("LXUNF040", NULL);
addLoader("LXUNF040", nullptr);
if (n_mru) {
addLoader("LXMRU110", NULL);
addLoader("LXMRU110", nullptr);
}
else {
addLoader("LXMRU111", NULL);
addLoader("LXMRU111", nullptr);
}
addLoader("LXUNF041", NULL);
addLoader("LXUNF042", NULL);
addLoader("LXUNF041", nullptr);
addLoader("LXUNF042", nullptr);
if (n_mru) {
addLoader("LXMRU010", NULL);
addLoader("LXMRU010", nullptr);
if (NOFILT!=f_jmp1 && NOFILT==f_call) {
addLoader("LXJMPA00", NULL);
addLoader("LXJMPA00", nullptr);
}
else {
addLoader("LXCALLB0", NULL);
addLoader("LXCALLB0", nullptr);
}
addLoader("LXUNF021", NULL);
addLoader("LXUNF021", nullptr);
}
else {
addLoader("LXMRU022", NULL);
addLoader("LXMRU022", nullptr);
if (NOFILT!=f_jmp1 && NOFILT==f_call) {
addLoader("LXJMPA01", NULL);
addLoader("LXJMPA01", nullptr);
}
else {
addLoader("LXCALLB1", NULL);
addLoader("LXCALLB1", nullptr);
}
}
if (n_mru) {
if (256!=n_mru && mrupwr2) {
addLoader("MRUBITS1", NULL);
addLoader("MRUBITS1", nullptr);
}
addLoader("LXMRU030", NULL);
addLoader("LXMRU030", nullptr);
if (256==n_mru) {
addLoader("MRUBYTE1", NULL);
addLoader("MRUBYTE1", nullptr);
}
else {
addLoader("MRUARB10", NULL);
addLoader("MRUARB10", nullptr);
}
addLoader("LXMRU040", NULL);
addLoader("LXMRU040", nullptr);
}
addLoader("LXUNF030", NULL);
addLoader("LXUNF030", nullptr);
if (NOFILT!=f_jcc2) {
addLoader("LXJCC000", NULL);
addLoader("LXJCC000", nullptr);
}
if (NOFILT!=f_call || NOFILT!=f_jmp1) { // at least one is filtered
// shift opcode origin to zero
if (0==n_mru) {
addLoader("LXCJ0MRU", NULL);
addLoader("LXCJ0MRU", nullptr);
}
else {
addLoader("LXCJ1MRU", NULL);
addLoader("LXCJ1MRU", nullptr);
}
// determine if in range
if ((NOFILT!=f_call) && (NOFILT!=f_jmp1)) { // unfilter both
addLoader("LXCALJMP", NULL);
addLoader("LXCALJMP", nullptr);
}
if ((NOFILT==f_call) ^ (NOFILT==f_jmp1)) { // unfilter just one
if (0==n_mru) {
addLoader("LXCALL00", NULL);
addLoader("LXCALL00", nullptr);
}
else {
addLoader("LXCALL01", NULL);
addLoader("LXCALL01", nullptr);
}
}
// determine if mru applies
if (0==n_mru || ! ((FNOMRU==f_call) || (FNOMRU==f_jmp1)) ) {
addLoader("LXCJ2MRU", NULL); // no mru, or no exceptions
addLoader("LXCJ2MRU", nullptr); // no mru, or no exceptions
}
else { // mru on one, but not the other
addLoader("LXCJ4MRU", NULL);
addLoader("LXCJ4MRU", nullptr);
if (MRUFLT==f_jmp1) { // JMP only
addLoader("LXCJ6MRU", NULL);
addLoader("LXCJ6MRU", nullptr);
} else
if (MRUFLT==f_call) { // CALL only
addLoader("LXCJ7MRU", NULL);
addLoader("LXCJ7MRU", nullptr);
}
addLoader("LXCJ8MRU", NULL);
addLoader("LXCJ8MRU", nullptr);
}
}
addLoader("LXUNF034", NULL);
addLoader("LXUNF034", nullptr);
if (n_mru) {
addLoader("LXMRU055", NULL);
addLoader("LXMRU055", nullptr);
if (256==n_mru) {
addLoader("MRUBYTE2", NULL);
addLoader("MRUBYTE2", nullptr);
}
else if (mrupwr2) {
addLoader("MRUBITS2", NULL);
addLoader("MRUBITS2", nullptr);
}
else if (n_mru) {
addLoader("MRUARB20", NULL);
addLoader("MRUARB20", nullptr);
}
addLoader("LXMRU057", NULL);
addLoader("LXMRU057", nullptr);
}
}
}

View File

@ -57,7 +57,7 @@
//
**************************************************************************/
PackMaster::PackMaster(InputFile *f, options_t *o) : fi(f), p(NULL) {
PackMaster::PackMaster(InputFile *f, options_t *o) : fi(f), p(nullptr) {
// replace global options with local options
saved_opt = o;
if (o) {
@ -67,13 +67,13 @@ PackMaster::PackMaster(InputFile *f, options_t *o) : fi(f), p(NULL) {
}
PackMaster::~PackMaster() {
fi = NULL;
fi = nullptr;
delete p;
p = NULL;
p = nullptr;
// restore global options
if (saved_opt)
opt = saved_opt;
saved_opt = NULL;
saved_opt = nullptr;
}
/*************************************************************************
@ -81,8 +81,8 @@ PackMaster::~PackMaster() {
**************************************************************************/
static Packer *try_pack(Packer *p, void *user) {
if (p == NULL)
return NULL;
if (p == nullptr)
return nullptr;
InputFile *f = (InputFile *) user;
p->assertPacker();
try {
@ -100,12 +100,12 @@ static Packer *try_pack(Packer *p, void *user) {
throw;
}
delete p;
return NULL;
return nullptr;
}
static Packer *try_unpack(Packer *p, void *user) {
if (p == NULL)
return NULL;
if (p == nullptr)
return nullptr;
InputFile *f = (InputFile *) user;
p->assertPacker();
try {
@ -126,7 +126,7 @@ static Packer *try_unpack(Packer *p, void *user) {
throw;
}
delete p;
return NULL;
return nullptr;
}
/*************************************************************************
@ -135,7 +135,7 @@ static Packer *try_unpack(Packer *p, void *user) {
Packer *PackMaster::visitAllPackers(visit_func_t func, InputFile *f, const options_t *o,
void *user) {
Packer *p = NULL;
Packer *p = nullptr;
#define D(Klass) \
ACC_BLOCK_BEGIN \
@ -143,7 +143,7 @@ Packer *PackMaster::visitAllPackers(visit_func_t func, InputFile *f, const optio
if (o->debug.debug_level) \
fprintf(stderr, "visitAllPackers: (ver=%d, fmt=%3d) %s\n", kp->getVersion(), \
kp->getFormat(), #Klass); \
if ((p = func(kp, user)) != NULL) \
if ((p = func(kp, user)) != nullptr) \
return p; \
ACC_BLOCK_END
@ -232,7 +232,7 @@ Packer *PackMaster::visitAllPackers(visit_func_t func, InputFile *f, const optio
// D(PackDylibI386);
// D(PackDylibPPC32);
return NULL;
return nullptr;
#undef D
}
@ -258,26 +258,26 @@ Packer *PackMaster::getUnpacker(InputFile *f) {
void PackMaster::pack(OutputFile *fo) {
p = getPacker(fi);
fi = NULL;
fi = nullptr;
p->doPack(fo);
}
void PackMaster::unpack(OutputFile *fo) {
p = getUnpacker(fi);
p->assertPacker();
fi = NULL;
fi = nullptr;
p->doUnpack(fo);
}
void PackMaster::test() {
p = getUnpacker(fi);
fi = NULL;
fi = nullptr;
p->doTest();
}
void PackMaster::list() {
p = getUnpacker(fi);
fi = NULL;
fi = nullptr;
p->doList();
}
@ -286,9 +286,9 @@ void PackMaster::fileInfo() {
if (!p)
p = visitAllPackers(try_pack, fi, opt, fi);
if (!p)
throwUnknownExecutableFormat(NULL, 1); // make a warning here
throwUnknownExecutableFormat(nullptr, 1); // make a warning here
p->assertPacker();
fi = NULL;
fi = nullptr;
p->doFileInfo();
}

View File

@ -38,7 +38,7 @@ class OutputFile;
class PackMaster {
public:
PackMaster(InputFile *f, options_t *o = NULL);
PackMaster(InputFile *f, options_t *o = nullptr);
virtual ~PackMaster();
void pack(OutputFile *fo);

View File

@ -52,7 +52,7 @@
static void xcheck(const void *p)
{
if (!p)
throwCantUnpack("unexpected NULL pointer; take care!");
throwCantUnpack("unexpected nullptr pointer; take care!");
}
static void xcheck(const void *p, size_t plen, const void *b, size_t blen)
{
@ -92,14 +92,14 @@ PeFile::PeFile(InputFile *f) : super(f)
COMPILE_TIME_ASSERT_ALIGNED1(pe_section_t)
COMPILE_TIME_ASSERT(RT_LAST == TABLESIZE(opt->win32_pe.compress_rt))
isection = NULL;
oimport = NULL;
oimpdlls = NULL;
orelocs = NULL;
oexport = NULL;
otls = NULL;
oresources = NULL;
oxrelocs = NULL;
isection = nullptr;
oimport = nullptr;
oimpdlls = nullptr;
orelocs = nullptr;
oexport = nullptr;
otls = nullptr;
oresources = nullptr;
oxrelocs = nullptr;
icondir_offset = 0;
icondir_count = 0;
importbyordinal = false;
@ -110,9 +110,9 @@ PeFile::PeFile(InputFile *f) : super(f)
soxrelocs = 0;
sotls = 0;
isdll = false;
ilinker = NULL;
ilinker = nullptr;
use_tls_callbacks = false;
oloadconf = NULL;
oloadconf = nullptr;
soloadconf = 0;
use_dep_hack = true;
@ -194,7 +194,7 @@ int PeFile::readFileHeader()
// interval handling
**************************************************************************/
PeFile::Interval::Interval(void *b) : capacity(0),base(b),ivarr(NULL),ivnum(0)
PeFile::Interval::Interval(void *b) : capacity(0),base(b),ivarr(nullptr),ivnum(0)
{}
PeFile::Interval::~Interval()
@ -286,7 +286,7 @@ void PeFile::Reloc::newRelocPos(void *p)
}
PeFile::Reloc::Reloc(upx_byte *s,unsigned si) :
start(s), size(si), rel(NULL), rel1(NULL)
start(s), size(si), rel(nullptr), rel1(nullptr)
{
COMPILE_TIME_ASSERT(sizeof(reloc) == 8)
COMPILE_TIME_ASSERT_ALIGNED1(reloc)
@ -297,7 +297,7 @@ PeFile::Reloc::Reloc(upx_byte *s,unsigned si) :
}
PeFile::Reloc::Reloc(unsigned rnum) :
start(NULL), size(0), rel(NULL), rel1(NULL)
start(nullptr), size(0), rel(nullptr), rel1(nullptr)
{
start = new upx_byte[mem_size(4, rnum, 8192)];
counts[0] = 0;
@ -307,8 +307,10 @@ bool PeFile::Reloc::next(unsigned &pos,unsigned &type)
{
if (!rel)
newRelocPos(start);
if (ptr_diff(rel, start) >= (int) size || rel->pagestart == 0)
return rel = 0,false; // rewind
if (ptr_diff(rel, start) >= (int) size || rel->pagestart == 0) {
rel = nullptr; // rewind
return false;
}
pos = rel->pagestart + (*rel1 & 0xfff);
type = *rel1++ >> 12;
@ -348,7 +350,7 @@ void PeFile::Reloc::finish(upx_byte *&p,unsigned &siz)
siz = ptr_diff(rel1,start) &~ 3;
siz -= 8;
// siz can be 0 in 64-bit mode // assert(siz > 0);
start = 0; // safety
start = nullptr; // safety
}
void PeFile::processRelocs(Reloc *rel) // pass2
@ -659,7 +661,7 @@ class PeFile::ImportLinker : public ElfLinkerAMD64
tstr desc_name(name_for_dll(dll, descriptor_id));
char tsep = thunk_separator;
if (findSection(sdll, false) == NULL)
if (findSection(sdll, false) == nullptr)
{
tsep = thunk_separator_first;
addSection(sdll, dll, strlen(dll) + 1, 0); // name of the dll
@ -670,7 +672,7 @@ class PeFile::ImportLinker : public ElfLinkerAMD64
"R_X86_64_32", sdll, 0);
}
tstr thunk(name_for_proc(dll, proc, thunk_id, tsep));
if (findSection(thunk, false) != NULL)
if (findSection(thunk, false) != nullptr)
return; // we already have this dll/proc
addSection(thunk, zeros, thunk_size, 0);
addSymbol(thunk, thunk, 0);
@ -722,9 +724,9 @@ public:
explicit ImportLinker(unsigned thunk_size_) : thunk_size(thunk_size_)
{
assert(thunk_size == 4 || thunk_size == 8);
addSection("*UND*", NULL, 0, 0);
addSection("*UND*", nullptr, 0, 0);
addSymbol("*UND*", "*UND*", 0);
addSection("*ZSTART", NULL, 0, 0);
addSection("*ZSTART", nullptr, 0, 0);
addSymbol("*ZSTART", "*ZSTART", 0);
Section *s = addSection("Dzero", zeros, sizeof(import_desc), 0);
assert(s->name[0] == descriptor_id);
@ -754,7 +756,7 @@ public:
unsigned build()
{
assert(output == NULL);
assert(output == nullptr);
int osize = 4 + 2 * nsections; // upper limit for alignments
for (unsigned ic = 0; ic < nsections; ic++)
osize += sections[ic]->size;
@ -789,8 +791,8 @@ public:
ACC_COMPILE_TIME_ASSERT(sizeof(C2) == 1) // "char" or "unsigned char"
const Section *s = getThunk((const char*) dll, (const char*) proc,
thunk_separator_first);
if (s == NULL && (s = getThunk((const char*) dll,(const char*) proc,
thunk_separator)) == NULL)
if (s == nullptr && (s = getThunk((const char*) dll,(const char*) proc,
thunk_separator)) == nullptr)
throwInternalError("entry not found");
return s->offset;
}
@ -804,8 +806,8 @@ public:
upx_snprintf(ord, sizeof(ord), "%c%05u", ordinal_id, ordinal);
const Section *s = getThunk((const char*) dll, ord, thunk_separator_first);
if (s == NULL
&& (s = getThunk((const char*) dll, ord, thunk_separator)) == NULL)
if (s == nullptr
&& (s = getThunk((const char*) dll, ord, thunk_separator)) == nullptr)
throwInternalError("entry not found");
return s->offset;
}
@ -823,7 +825,7 @@ public:
{
ACC_COMPILE_TIME_ASSERT(sizeof(C) == 1) // "char" or "unsigned char"
tstr sdll(name_for_dll((const char*) dll, dll_name_id));
return findSection(sdll, false) != NULL;
return findSection(sdll, false) != nullptr;
}
};
const char PeFile::ImportLinker::zeros[sizeof(import_desc)] = { 0 };
@ -913,7 +915,7 @@ unsigned PeFile::processImports0(ord_mask_t ord_mask) // pass 1
{
idlls[ic] = dlls + ic;
dlls[ic].name = ibuf.subref("bad dllname %#x", im->dllname, 1);
dlls[ic].shname = NULL;
dlls[ic].shname = nullptr;
dlls[ic].ordinal = 0;
dlls[ic].iat = im->iat;
unsigned const skip2 = (im->oft ? im->oft : im->iat);
@ -936,7 +938,7 @@ unsigned PeFile::processImports0(ord_mask_t ord_mask) // pass 1
IPTR_I(const upx_byte, n, ibuf + *tarr + 2);
unsigned len = strlen(n);
soimport += len + 1;
if (dlls[ic].shname == NULL || len < strlen (dlls[ic].shname))
if (dlls[ic].shname == nullptr || len < strlen (dlls[ic].shname))
dlls[ic].shname = ibuf + *tarr + 2;
}
soimport++; // separator
@ -1092,8 +1094,8 @@ PeFile::Export::Export(char *_base) : base(_base), iv(_base)
{
COMPILE_TIME_ASSERT(sizeof(export_dir_t) == 40)
COMPILE_TIME_ASSERT_ALIGNED1(export_dir_t)
ename = functionptrs = ordinals = NULL;
names = NULL;
ename = functionptrs = ordinals = nullptr;
names = nullptr;
memset(&edir,0,sizeof(edir));
size = 0;
}
@ -1158,7 +1160,7 @@ void PeFile::Export::convert(unsigned eoffs,unsigned esize)
names[ic + edir.names] = strdup(forw);
}
else
names[ic + edir.names] = NULL;
names[ic + edir.names] = nullptr;
len = 2 * edir.names;
ordinals = New(char, len + 1);
@ -1523,7 +1525,7 @@ struct PeFile::Resource::upx_rleaf : public PeFile::Resource::upx_rnode
};
PeFile::Resource::Resource(const upx_byte *ibufstart_,
const upx_byte *ibufend_) : root(NULL)
const upx_byte *ibufend_) : root(nullptr)
{
ibufstart = ibufstart_;
ibufend = ibufend_;
@ -1540,7 +1542,7 @@ PeFile::Resource::Resource(const upx_byte *p,
PeFile::Resource::~Resource()
{
if (root) { destroy(root, 0); root = NULL; }
if (root) { destroy(root, 0); root = nullptr; }
}
unsigned PeFile::Resource::dirsize() const
@ -1551,7 +1553,7 @@ unsigned PeFile::Resource::dirsize() const
bool PeFile::Resource::next()
{
// wow, builtin autorewind... :-)
return (current = current ? current->next : head) != NULL;
return (current = current ? current->next : head) != nullptr;
}
unsigned PeFile::Resource::itype() const
@ -1609,10 +1611,10 @@ void PeFile::Resource::init(const upx_byte *res)
COMPILE_TIME_ASSERT_ALIGNED1(res_data)
start = res;
root = head = current = NULL;
root = head = current = nullptr;
dsize = ssize = 0;
check((const res_dir*) start,0);
root = convert(start,NULL,0);
root = convert(start,nullptr,0);
}
void PeFile::Resource::check(const res_dir *node,unsigned level)
@ -1647,7 +1649,7 @@ PeFile::Resource::upx_rnode *PeFile::Resource::convert(const void *rnode,
ibufcheck(node, sizeof(*node));
upx_rleaf *leaf = new upx_rleaf;
leaf->id = 0;
leaf->name = NULL;
leaf->name = nullptr;
leaf->parent = parent;
leaf->next = head;
leaf->newoffset = 0;
@ -1662,11 +1664,11 @@ PeFile::Resource::upx_rnode *PeFile::Resource::convert(const void *rnode,
ibufcheck(node, sizeof(*node));
int ic = node->identr + node->namedentr;
if (ic == 0)
return NULL;
return nullptr;
upx_rbranch *branch = new upx_rbranch;
branch->id = 0;
branch->name = NULL;
branch->name = nullptr;
branch->parent = parent;
branch->nc = ic;
branch->children = New(upx_rnode *, ic);
@ -1724,7 +1726,7 @@ void PeFile::Resource::build(const upx_rnode *node, unsigned &bpos,
be->child = bpos + ((level < 2) ? 0x80000000 : 0);
const upx_byte *p;
if ((p = branch->children[ic]->name) != 0)
if ((p = branch->children[ic]->name) != nullptr)
{
be->tnl = spos + 0x80000000;
if (spos + get_le16(p) * 2 + 2 > dirsize())
@ -1762,16 +1764,16 @@ void PeFile::Resource::destroy(upx_rnode *node,unsigned level)
if (level == 3)
{
upx_rleaf *leaf = ACC_STATIC_CAST(upx_rleaf *, node);
delete [] leaf->name; leaf->name = NULL;
delete [] leaf->name; leaf->name = nullptr;
delete leaf;
}
else
{
upx_rbranch *branch = ACC_STATIC_CAST(upx_rbranch *, node);
delete [] branch->name; branch->name = NULL;
delete [] branch->name; branch->name = nullptr;
for (int ic = branch->nc; --ic >= 0; )
destroy(branch->children[ic], level + 1);
delete [] branch->children; branch->children = NULL;
delete [] branch->children; branch->children = nullptr;
delete branch;
}
}
@ -1883,7 +1885,7 @@ static bool match(unsigned itype, const unsigned char *ntype,
return true;
}
if (delim2 == NULL)
if (delim2 == nullptr)
break;
keep = delim2 + 1;
}
@ -1921,7 +1923,7 @@ void PeFile::processResources(Resource *res)
oresources = (upx_byte *)mb_oresources.getVoidPtr();
upx_byte *ores = oresources + res->dirsize();
char *keep_icons = NULL; // icon ids in the first icon group
char *keep_icons = nullptr; // icon ids in the first icon group
unsigned iconsin1stdir = 0;
if (opt->win32_pe.compress_icons == 2)
while (res->next()) // there is no rewind() in Resource
@ -2223,7 +2225,7 @@ unsigned PeFile::readSections(unsigned objs, unsigned usize,
void PeFile::callCompressWithFilters(Filter &ft, int filter_strategy, unsigned ih_codebase)
{
compressWithFilters(&ft, 2048, NULL_cconf, filter_strategy,
ih_codebase, rvamin, 0, NULL, 0);
ih_codebase, rvamin, 0, nullptr, 0);
}
void PeFile::callProcessRelocs(Reloc &rel, unsigned &ic)
@ -2722,7 +2724,7 @@ void PeFile::rebuildRelocs(upx_byte *& extrainfo, unsigned bits,
rel.finish (oxrelocs,soxrelocs);
omemcpy(obuf + ODADDR(PEDIR_RELOC) - rvamin,oxrelocs,soxrelocs);
delete [] oxrelocs; oxrelocs = NULL;
delete [] oxrelocs; oxrelocs = nullptr;
wrkmem.dealloc();
ODSIZE(PEDIR_RELOC) = soxrelocs;
@ -3088,7 +3090,7 @@ upx_uint64_t PeFile::ilinkerGetAddress(const char *d, const char *n) const
PeFile::~PeFile()
{
oimpdlls = NULL;
oimpdlls = nullptr;
delete [] oxrelocs;
delete ilinker;
//delete res;

View File

@ -97,7 +97,7 @@ static void sb_push(screen_t *this, const Cell *line, int len) {
static const Cell *sb_pop(screen_t *this) {
if (this->data->sb_sp == this->data->sb_base)
return NULL;
return nullptr;
sb_add(this, &this->data->sb_sp, -1);
return this->data->sb_buf[this->data->sb_sp];
}
@ -274,7 +274,7 @@ static int init(screen_t *this, int fd) {
return -1;
}
ScreenGetCursor(&this->data->cursor_y, &this->data->cursor_x);
getChar(this, NULL, &attr, this->data->cursor_x, this->data->cursor_y);
getChar(this, nullptr, &attr, this->data->cursor_x, this->data->cursor_y);
this->data->init_attr = attr;
if (mode != 7) {
/* Does it normally blink when bg has its 3rd bit set? */
@ -369,7 +369,7 @@ static int scrollDown(screen_t *this, int lines) {
for (y = lines; --y >= 0;) {
#if USE_SCROLLBACK
const Cell *buf = sb_pop(this);
if (buf == NULL)
if (buf == nullptr)
clearLine(this, y);
else
updateLineN(this, buf, y, sc * 2);
@ -417,10 +417,10 @@ static void atExit(void) {
return;
done = 1;
if (ae.cursor_shape >= 0)
setCursorShape(NULL, ae.cursor_shape);
setCursorShape(nullptr, ae.cursor_shape);
}
static const screen_t driver = {sobject_destroy, 0, /* finalize, */
static const screen_t driver = {sobject_destroy, nullptr, /* finalize */
atExit, init, refresh,
getMode, getPage, getRows,
getCols, isMono, getFg,
@ -430,7 +430,7 @@ static const screen_t driver = {sobject_destroy, 0, /* finalize, */
putCharAttr, putString, putStringAttr,
clear, clearLine, updateLineN,
scrollUp, scrollDown, getScrollCounter,
s_kbhit, intro, (struct screen_data_t *) 0};
s_kbhit, intro, (struct screen_data_t *) nullptr};
/* public constructor */
screen_t *screen_djgpp2_construct(void) { return sobject_construct(&driver, sizeof(*driver.data)); }

View File

@ -38,19 +38,19 @@
**************************************************************************/
// ugly hacks
static screen_t *last_screen = NULL;
static screen_t *last_screen = nullptr;
screen_t *sobject_get_screen(void) { return last_screen; }
void sobject_destroy(screen_t *this) {
last_screen = NULL;
last_screen = nullptr;
if (!this)
return;
if (this->data) {
if (this->finalize)
this->finalize(this);
free(this->data);
this->data = NULL;
this->data = nullptr;
}
free(this);
}
@ -58,12 +58,12 @@ void sobject_destroy(screen_t *this) {
screen_t *sobject_construct(const screen_t *c, size_t data_size) {
screen_t *this;
last_screen = NULL;
last_screen = nullptr;
/* allocate object */
this = (screen_t *) malloc(sizeof(*this));
if (!this)
return NULL;
return nullptr;
/* copy function table */
*this = *c;
@ -72,7 +72,7 @@ screen_t *sobject_construct(const screen_t *c, size_t data_size) {
this->data = (struct screen_data_t *) malloc(data_size);
if (!this->data) {
free(this);
return NULL;
return nullptr;
}
memset(this->data, 0, data_size);

View File

@ -89,7 +89,7 @@ static void sb_push(screen_t *this, const Cell *line, int len) {
static const Cell *sb_pop(screen_t *this) {
if (this->data->sb_sp == this->data->sb_base)
return NULL;
return nullptr;
sb_add(this, &this->data->sb_sp, -1);
return this->data->sb_buf[this->data->sb_sp];
}
@ -276,7 +276,7 @@ static int init(screen_t *this, int fd) {
this->data->map[i] = i;
i = init_scrnmap(this, this->data->fd) || init_scrnmap(this, STDIN_FILENO);
getChar(this, NULL, &attr, this->data->cursor_x, this->data->cursor_y);
getChar(this, nullptr, &attr, this->data->cursor_x, this->data->cursor_y);
this->data->init_attr = attr;
this->data->attr = attr;
a = make_cell(this, ' ', attr);
@ -384,7 +384,7 @@ static int scrollDown(screen_t *this, int lines) {
for (y = lines; --y >= 0;) {
#if USE_SCROLLBACK
const Cell *buf = sb_pop(this);
if (buf == NULL)
if (buf == nullptr)
clearLine(this, y);
else
updateLineN(this, buf, y, sc * 2);
@ -420,7 +420,7 @@ static int kbhit(screen_t *this) {
FD_SET(fd, &fds);
tv.tv_sec = usec / 1000000;
tv.tv_usec = usec % 1000000;
return (select(fd + 1, &fds, NULL, NULL, &tv) > 0);
return (select(fd + 1, &fds, nullptr, nullptr, &tv) > 0);
}
static int intro(screen_t *this, void (*show_frames)(screen_t *)) {
@ -455,7 +455,7 @@ static int intro(screen_t *this, void (*show_frames)(screen_t *)) {
static const screen_t driver = {sobject_destroy,
finalize,
0, /* atExit */
nullptr, /* atExit */
init,
refresh,
getMode,
@ -471,7 +471,7 @@ static const screen_t driver = {sobject_destroy,
setBg,
setCursor,
setCursorShape,
0, /* hideCursor */
nullptr, /* hideCursor */
putChar,
putCharAttr,
putString,
@ -484,7 +484,7 @@ static const screen_t driver = {sobject_destroy,
getScrollCounter,
kbhit,
intro,
(struct screen_data_t *) 0};
(struct screen_data_t *) nullptr};
/* public constructor */
screen_t *screen_vcsa_construct(void) { return sobject_construct(&driver, sizeof(*driver.data)); }

View File

@ -346,7 +346,7 @@ static int do_scroll(screen_t *this, int lines, int way) {
break;
}
// ScrollConsoleScreenBuffer(this->data->ho, &rect, &clip, dest, &this->data->empty_cell);
ScrollConsoleScreenBuffer(this->data->ho, &rect, NULL, dest, &this->data->empty_cell);
ScrollConsoleScreenBuffer(this->data->ho, &rect, nullptr, dest, &this->data->empty_cell);
return lines;
}
@ -395,7 +395,7 @@ static void atExit(void) {
}
}
static const screen_t driver = {sobject_destroy, 0, /* finalize, */
static const screen_t driver = {sobject_destroy, nullptr, /* finalize */
atExit, init, refresh,
getMode, getPage, getRows,
getCols, isMono, getFg,
@ -405,7 +405,7 @@ static const screen_t driver = {sobject_destroy, 0, /* finalize, */
putCharAttr, putString, putStringAttr,
clear, clearLine, updateLineN,
scrollUp, scrollDown, getScrollCounter,
s_kbhit, intro, (struct screen_data_t *) 0};
s_kbhit, intro, (struct screen_data_t *) nullptr};
/* public constructor */
screen_t *screen_win32_construct(void) { return sobject_construct(&driver, sizeof(*driver.data)); }

View File

@ -140,7 +140,7 @@ static void fmtstr(char *buffer, size_t *currsize, size_t maxsize, const char *s
#ifdef DEBUG_SNPRINTF
printf("fmtstr min=%d max=%d s=[%s]\n", min, max, strvalue);
#endif
assert(strvalue != NULL);
assert(strvalue != nullptr);
padlen = min - strln;
if (padlen < 0)
padlen = 0;
@ -677,27 +677,27 @@ static size_t dopr(char *buffer, size_t maxsize, const char *format, va_list arg
if (cflags == DP_C_CHAR) {
signed char *num;
num = va_arg(args, signed char *);
assert(num != NULL);
assert(num != nullptr);
*num = (signed char) currsize;
} else if (cflags == DP_C_SHORT) {
short *num;
num = va_arg(args, short *);
assert(num != NULL);
assert(num != nullptr);
*num = (short) currsize;
} else if (cflags == DP_C_LONG) {
long *num;
num = va_arg(args, long *);
assert(num != NULL);
assert(num != nullptr);
*num = (long) currsize;
} else if (cflags == DP_C_LLONG) {
LLONG *num;
num = va_arg(args, LLONG *);
assert(num != NULL);
assert(num != nullptr);
*num = (LLONG) currsize;
} else {
int *num;
num = va_arg(args, int *);
assert(num != NULL);
assert(num != nullptr);
*num = (int) currsize;
}
break;
@ -776,7 +776,7 @@ int upx_vsnprintf(char *str, upx_rsize_t max_size, const char *format, va_list a
// preconditions
assert(max_size <= UPX_RSIZE_MAX_STR);
if (str != NULL)
if (str != nullptr)
assert(max_size > 0);
else
assert(max_size == 0);
@ -786,7 +786,7 @@ int upx_vsnprintf(char *str, upx_rsize_t max_size, const char *format, va_list a
// postconditions
assert(size > 0);
assert(size <= UPX_RSIZE_MAX_STR);
if (str != NULL) {
if (str != nullptr) {
assert(size <= max_size);
assert(str[size - 1] == '\0');
}
@ -807,20 +807,20 @@ int __acc_cdecl_va upx_snprintf(char *str, upx_rsize_t max_size, const char *for
int upx_vasprintf(char **ptr, const char *format, va_list ap) {
int len;
assert(ptr != NULL);
*ptr = NULL;
assert(ptr != nullptr);
*ptr = nullptr;
#if defined(va_copy)
va_list ap_copy;
va_copy(ap_copy, ap);
len = upx_vsnprintf(NULL, 0, format, ap_copy);
len = upx_vsnprintf(nullptr, 0, format, ap_copy);
va_end(ap_copy);
#else
len = upx_vsnprintf(NULL, 0, format, ap);
len = upx_vsnprintf(nullptr, 0, format, ap);
#endif
if (len >= 0) {
*ptr = (char *) malloc(len + 1);
assert(*ptr != NULL);
if (*ptr == NULL)
assert(*ptr != nullptr);
if (*ptr == nullptr)
return -1;
int len2 = upx_vsnprintf(*ptr, len + 1, format, ap);
assert(len2 == len);
@ -840,7 +840,7 @@ int __acc_cdecl_va upx_asprintf(char **ptr, const char *format, ...) {
#undef strlen
upx_rsize_t upx_strlen(const char *s) {
assert(s != NULL);
assert(s != nullptr);
size_t len = strlen(s);
assert(len < UPX_RSIZE_MAX_STR);
return len;
@ -881,7 +881,7 @@ int main(void)
"%.0f",
"%f",
"-16.16f",
NULL
nullptr
};
const double fp_nums[] = {
6442452944.1234, -1.5, 134.21, 91340.2, 341.1234, 0203.9, 0.96, 0.996,
@ -898,7 +898,7 @@ int main(void)
"%01.3d",
"%4d",
"%d",
NULL
nullptr
};
const long int_nums[] = { -1, 134, 91340, 341, 0203, 0 };
const char *str_fmt[] = {
@ -914,7 +914,7 @@ int main(void)
"%10s",
0
};
const char *str_vals[] = {"hello", "a", "", "a longer string", NULL};
const char *str_vals[] = {"hello", "a", "", "a longer string", nullptr};
int x, y;
int fail = 0;
int num = 0;
@ -923,7 +923,7 @@ int main(void)
for (x = 0; fp_fmt[x] ; x++) {
for (y = 0; fp_nums[y] != 0 ; y++) {
int l1 = snprintf(NULL, 0, fp_fmt[x], fp_nums[y]);
int l1 = snprintf(nullptr, 0, fp_fmt[x], fp_nums[y]);
int l2 = snprintf(buf1, sizeof(buf1), fp_fmt[x], fp_nums[y]);
sprintf (buf2, fp_fmt[x], fp_nums[y]);
if (strcmp (buf1, buf2)) {
@ -959,7 +959,7 @@ int main(void)
for (x = 0; str_fmt[x] ; x++) {
for (y = 0; str_vals[y] != 0 ; y++) {
int l1 = snprintf(NULL, 0, str_fmt[x], str_vals[y]);
int l1 = snprintf(nullptr, 0, str_fmt[x], str_vals[y]);
int l2 = snprintf(buf1, sizeof(buf1), str_fmt[x], str_vals[y]);
sprintf (buf2, str_fmt[x], str_vals[y]);
if (strcmp (buf1, buf2)) {

View File

@ -38,7 +38,7 @@ char *__cxa_demangle(const char *mangled_name, char *buf, size_t *n, int *status
UNUSED(n);
if (status)
*status = -1; /* memory_allocation_failure */
return NULL;
return nullptr;
}
} /* extern "C" */
#endif

View File

@ -157,7 +157,7 @@ static const char *mkline(upx_uint64_t fu_len, upx_uint64_t fc_len, upx_uint64_t
//
**************************************************************************/
UiPacker::UiPacker(const Packer *p_) : ui_pass(0), ui_total_passes(0), p(p_), s(NULL) {
UiPacker::UiPacker(const Packer *p_) : ui_pass(0), ui_total_passes(0), p(p_), s(nullptr) {
init_global_constants();
cb.reset();
@ -177,7 +177,7 @@ UiPacker::UiPacker(const Packer *p_) : ui_pass(0), ui_total_passes(0), p(p_), s(
s->mode = M_INFO;
else if (opt->verbose == 1 || opt->no_progress)
s->mode = M_MSG;
else if (s->screen == NULL)
else if (s->screen == nullptr)
s->mode = M_CB_TERM;
else
s->mode = M_CB_SCREEN;
@ -186,7 +186,7 @@ UiPacker::UiPacker(const Packer *p_) : ui_pass(0), ui_total_passes(0), p(p_), s(
UiPacker::~UiPacker() {
cb.reset();
delete s;
s = NULL;
s = nullptr;
}
/*************************************************************************

View File

@ -99,8 +99,8 @@ bool mem_size_valid_bytes(upx_uint64_t bytes) {
}
int ptr_diff(const void *p1, const void *p2) {
assert(p1 != NULL);
assert(p2 != NULL);
assert(p1 != nullptr);
assert(p2 != nullptr);
ptrdiff_t d = (const char *) p1 - (const char *) p2;
if (p1 >= p2)
assert(mem_size_valid_bytes(d));
@ -239,7 +239,7 @@ int __acc_cdecl_qsort le64_compare_signed(const void *e1, const void *e2) {
**************************************************************************/
int find(const void *b, int blen, const void *what, int wlen) {
if (b == NULL || blen <= 0 || what == NULL || wlen <= 0)
if (b == nullptr || blen <= 0 || what == nullptr || wlen <= 0)
return -1;
// Fast exit if the wanted string is longer than the buffer.
if (wlen > blen)
@ -319,7 +319,7 @@ int mem_replace(void *bb, int blen, const void *what, int wlen, const void *r) {
static const char dir_sep[] = "/\\";
#define fn_is_drive(s) (s[0] && s[1] == ':')
#define fn_is_sep(c) (strchr(dir_sep, c) != NULL)
#define fn_is_sep(c) (strchr(dir_sep, c) != nullptr)
#define fn_skip_drive(s) (fn_is_drive(s) ? (s) + 2 : (s))
#define fn_tolower(c) (tolower(((unsigned char) (c))))
@ -443,7 +443,7 @@ bool file_exists(const char *name) {
bool maketempname(char *ofilename, size_t size, const char *ifilename, const char *ext,
bool force) {
char *ofext = NULL, *ofname;
char *ofext = nullptr, *ofname;
int ofile;
if (size <= 0)
@ -454,7 +454,7 @@ bool maketempname(char *ofilename, size_t size, const char *ifilename, const cha
if (*ofname == '.')
ofext = ofname;
}
if (ofext == NULL)
if (ofext == nullptr)
ofext = ofilename + strlen(ofilename);
strcpy(ofext, ext);
@ -472,7 +472,7 @@ bool maketempname(char *ofilename, size_t size, const char *ifilename, const cha
}
bool makebakname(char *ofilename, size_t size, const char *ifilename, bool force) {
char *ofext = NULL, *ofname;
char *ofext = nullptr, *ofname;
int ofile;
if (size <= 0)
@ -483,7 +483,7 @@ bool makebakname(char *ofilename, size_t size, const char *ifilename, bool force
if (*ofname == '.')
ofext = ofname;
}
if (ofext == NULL) {
if (ofext == nullptr) {
ofext = ofilename + strlen(ofilename);
strcpy(ofext, ".~");
} else if (strlen(ofext) < 1 + 3)

View File

@ -299,7 +299,7 @@ void do_files(int i, int argc, char *argv[]) {
e_exit(EXIT_ERROR);
} catch (...) {
unlink_ofile(oname);
printUnhandledException(iname, NULL);
printUnhandledException(iname, nullptr);
e_exit(EXIT_ERROR);
}
}