Rearranged debug options.
committer: mfx <mfx> 1139916141 +0000
This commit is contained in:
+24
-14
@@ -443,7 +443,7 @@ static int do_option(int optc, const char *arg)
|
|||||||
set_cmd(CMD_DECOMPRESS);
|
set_cmd(CMD_DECOMPRESS);
|
||||||
break;
|
break;
|
||||||
case 'D':
|
case 'D':
|
||||||
opt->debug++;
|
opt->debug.debug_level++;
|
||||||
break;
|
break;
|
||||||
case 'f':
|
case 'f':
|
||||||
opt->force++;
|
opt->force++;
|
||||||
@@ -537,6 +537,23 @@ static int do_option(int optc, const char *arg)
|
|||||||
e_method(opt->method, 10);
|
e_method(opt->method, 10);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
// debug
|
||||||
|
case 542:
|
||||||
|
if (!mfx_optarg || strlen(mfx_optarg) != 4)
|
||||||
|
e_optarg(arg);
|
||||||
|
memcpy(opt->debug.fake_stub_version, mfx_optarg, 4);
|
||||||
|
break;
|
||||||
|
case 543:
|
||||||
|
if (!mfx_optarg || strlen(mfx_optarg) != 4)
|
||||||
|
e_optarg(arg);
|
||||||
|
memcpy(opt->debug.fake_stub_year, mfx_optarg, 4);
|
||||||
|
break;
|
||||||
|
case 544:
|
||||||
|
if (!mfx_optarg || !mfx_optarg[0])
|
||||||
|
e_optarg(arg);
|
||||||
|
opt->debug.dump_stub_loader = mfx_optarg;
|
||||||
|
break;
|
||||||
|
|
||||||
// misc
|
// misc
|
||||||
case 512:
|
case 512:
|
||||||
opt->console = CON_FILE;
|
opt->console = CON_FILE;
|
||||||
@@ -550,16 +567,6 @@ static int do_option(int optc, const char *arg)
|
|||||||
case 516:
|
case 516:
|
||||||
opt->no_progress = true;
|
opt->no_progress = true;
|
||||||
break;
|
break;
|
||||||
case 542:
|
|
||||||
if (!mfx_optarg || strlen(mfx_optarg) != 4)
|
|
||||||
e_optarg(arg);
|
|
||||||
memcpy(opt->fake_stub_version, mfx_optarg, 4);
|
|
||||||
break;
|
|
||||||
case 543:
|
|
||||||
if (!mfx_optarg || strlen(mfx_optarg) != 4)
|
|
||||||
e_optarg(arg);
|
|
||||||
memcpy(opt->fake_stub_year, mfx_optarg, 4);
|
|
||||||
break;
|
|
||||||
case 519:
|
case 519:
|
||||||
opt->no_env = true;
|
opt->no_env = true;
|
||||||
break;
|
break;
|
||||||
@@ -763,9 +770,6 @@ static const struct mfx_option longopts[] =
|
|||||||
{"version", 0, 0, 'V'+256}, // display version number
|
{"version", 0, 0, 'V'+256}, // display version number
|
||||||
|
|
||||||
// options
|
// options
|
||||||
{"debug", 0x10, 0, 'D'},
|
|
||||||
{"fake-stub-version",0x31, 0, 542}, // for internal debugging
|
|
||||||
{"fake-stub-year" ,0x31, 0, 543}, // for internal debugging
|
|
||||||
{"force", 0, 0, 'f'}, // force overwrite of output files
|
{"force", 0, 0, 'f'}, // force overwrite of output files
|
||||||
{"force-compress", 0, 0, 'f'}, // and compression of suspicious files
|
{"force-compress", 0, 0, 'f'}, // and compression of suspicious files
|
||||||
{"info", 0, 0, 'i'}, // info mode
|
{"info", 0, 0, 'i'}, // info mode
|
||||||
@@ -781,6 +785,12 @@ static const struct mfx_option longopts[] =
|
|||||||
#endif
|
#endif
|
||||||
{"verbose", 0, 0, 'v'}, // verbose mode
|
{"verbose", 0, 0, '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
|
||||||
|
|
||||||
// backup options
|
// backup options
|
||||||
{"backup", 0, 0, 'k'},
|
{"backup", 0, 0, 'k'},
|
||||||
{"keep", 0, 0, 'k'},
|
{"keep", 0, 0, 'k'},
|
||||||
|
|||||||
+8
-3
@@ -56,9 +56,6 @@ struct options_t {
|
|||||||
// other options
|
// other options
|
||||||
int backup;
|
int backup;
|
||||||
int console;
|
int console;
|
||||||
int debug;
|
|
||||||
char fake_stub_version[4+1]; // for internal debugging
|
|
||||||
char fake_stub_year[4+1]; // for internal debugging
|
|
||||||
int force;
|
int force;
|
||||||
int info_mode;
|
int info_mode;
|
||||||
bool ignorewarn;
|
bool ignorewarn;
|
||||||
@@ -69,6 +66,14 @@ struct options_t {
|
|||||||
int verbose;
|
int verbose;
|
||||||
bool to_stdout;
|
bool to_stdout;
|
||||||
|
|
||||||
|
// debug options
|
||||||
|
struct {
|
||||||
|
int debug_level;
|
||||||
|
const char *dump_stub_loader;
|
||||||
|
char fake_stub_version[4+1]; // for internal debugging
|
||||||
|
char fake_stub_year[4+1]; // for internal debugging
|
||||||
|
} debug;
|
||||||
|
|
||||||
// overlay handling
|
// overlay handling
|
||||||
enum {
|
enum {
|
||||||
SKIP_OVERLAY = 0,
|
SKIP_OVERLAY = 0,
|
||||||
|
|||||||
+2
-2
@@ -411,7 +411,7 @@ void PackExe::pack(OutputFile *fo)
|
|||||||
throwCantPack("decompressor limit exceeded, send a bugreport");
|
throwCantPack("decompressor limit exceeded, send a bugreport");
|
||||||
|
|
||||||
#ifdef TESTING
|
#ifdef TESTING
|
||||||
if (opt->debug)
|
if (opt->debug.debug_level)
|
||||||
{
|
{
|
||||||
printf("image+relocs %d -> %d\n",ih_imagesize+relocsize,ph.c_len);
|
printf("image+relocs %d -> %d\n",ih_imagesize+relocsize,ph.c_len);
|
||||||
printf("offsets: %d - %d\nmatches: %d - %d\nruns: %d - %d\n",
|
printf("offsets: %d - %d\nmatches: %d - %d\nruns: %d - %d\n",
|
||||||
@@ -527,7 +527,7 @@ void PackExe::pack(OutputFile *fo)
|
|||||||
|
|
||||||
// write header + write loader + compressed file
|
// write header + write loader + compressed file
|
||||||
#ifdef TESTING
|
#ifdef TESTING
|
||||||
if (opt->debug)
|
if (opt->debug.debug_level)
|
||||||
printf("\n%d %d %d %d\n",(int)sizeof(oh),e_len,packedsize,d_len);
|
printf("\n%d %d %d %d\n",(int)sizeof(oh),e_len,packedsize,d_len);
|
||||||
#endif
|
#endif
|
||||||
fo->write(&oh,sizeof(oh));
|
fo->write(&oh,sizeof(oh));
|
||||||
|
|||||||
+2
-1
@@ -2098,7 +2098,8 @@ void PackW32Pe::pack(OutputFile *fo)
|
|||||||
fo->write(obuf,clen);
|
fo->write(obuf,clen);
|
||||||
infoWriting("compressed data", clen);
|
infoWriting("compressed data", clen);
|
||||||
fo->write(loader,codesize);
|
fo->write(loader,codesize);
|
||||||
//OutputFile::dump("loader.dat", loader, codesize);
|
if (opt->debug.dump_stub_loader)
|
||||||
|
OutputFile::dump(opt->debug.dump_stub_loader, loader, codesize);
|
||||||
if ((ic = fo->getBytesWritten() & 3) != 0)
|
if ((ic = fo->getBytesWritten() & 3) != 0)
|
||||||
fo->write(ibuf,4 - ic);
|
fo->write(ibuf,4 - ic);
|
||||||
fo->write(otls,sotls);
|
fo->write(otls,sotls);
|
||||||
|
|||||||
+2
-2
@@ -48,8 +48,8 @@ static const
|
|||||||
#define LE_STUB_EDI (1)
|
#define LE_STUB_EDI (1)
|
||||||
|
|
||||||
#ifdef TESTING
|
#ifdef TESTING
|
||||||
# define dputc(x,y) do { if (opt->debug) putc(x,y); } while (0)
|
# define dputc(x,y) do { if (opt->debug.debug_level) putc(x,y); } while (0)
|
||||||
# define Opt_debug opt->debug
|
# define Opt_debug opt->debug.debug_level
|
||||||
#else
|
#else
|
||||||
# define dputc(x,y) ((void)0)
|
# define dputc(x,y) ((void)0)
|
||||||
# define Opt_debug 0
|
# define Opt_debug 0
|
||||||
|
|||||||
+9
-9
@@ -812,8 +812,8 @@ int Packer::patchVersion(void *b, int blen)
|
|||||||
checkPatch(b, blen, boff, 14);
|
checkPatch(b, blen, boff, 14);
|
||||||
|
|
||||||
unsigned char *p = (unsigned char *)b + boff + 9;
|
unsigned char *p = (unsigned char *)b + boff + 9;
|
||||||
if (opt->fake_stub_version[0])
|
if (opt->debug.fake_stub_version[0])
|
||||||
memcpy(p, opt->fake_stub_version, 4);
|
memcpy(p, opt->debug.fake_stub_version, 4);
|
||||||
else
|
else
|
||||||
memcpy(p, UPX_VERSION_STRING4, 4);
|
memcpy(p, UPX_VERSION_STRING4, 4);
|
||||||
|
|
||||||
@@ -828,8 +828,8 @@ int Packer::patchVersionYear(void *b, int blen)
|
|||||||
checkPatch(b, blen, boff, 11);
|
checkPatch(b, blen, boff, 11);
|
||||||
|
|
||||||
unsigned char *p = (unsigned char *)b + boff + 6;
|
unsigned char *p = (unsigned char *)b + boff + 6;
|
||||||
if (opt->fake_stub_year[0])
|
if (opt->debug.fake_stub_year[0])
|
||||||
memcpy(p, opt->fake_stub_year, 4);
|
memcpy(p, opt->debug.fake_stub_year, 4);
|
||||||
else
|
else
|
||||||
memcpy(p, UPX_VERSION_YEAR, 4);
|
memcpy(p, UPX_VERSION_YEAR, 4);
|
||||||
|
|
||||||
@@ -1012,7 +1012,7 @@ char const *Packer::getIdentstr(unsigned *size, int small)
|
|||||||
static char identtiny[] = UPX_VERSION_STRING4;
|
static char identtiny[] = UPX_VERSION_STRING4;
|
||||||
|
|
||||||
static int done;
|
static int done;
|
||||||
if (!done && (opt->fake_stub_version[0] || opt->fake_stub_year[0]))
|
if (!done && (opt->debug.fake_stub_version[0] || opt->debug.fake_stub_year[0]))
|
||||||
{
|
{
|
||||||
struct strinfo_t { char *s; int size; };
|
struct strinfo_t { char *s; int size; };
|
||||||
static const strinfo_t strlist[] = {
|
static const strinfo_t strlist[] = {
|
||||||
@@ -1024,10 +1024,10 @@ char const *Packer::getIdentstr(unsigned *size, int small)
|
|||||||
|
|
||||||
for (iter = strlist; iter->s; ++iter)
|
for (iter = strlist; iter->s; ++iter)
|
||||||
{
|
{
|
||||||
if (opt->fake_stub_version[0])
|
if (opt->debug.fake_stub_version[0])
|
||||||
mem_replace(iter->s, iter->size, UPX_VERSION_STRING4, 4, opt->fake_stub_version);
|
mem_replace(iter->s, iter->size, UPX_VERSION_STRING4, 4, opt->debug.fake_stub_version);
|
||||||
if (opt->fake_stub_year[0])
|
if (opt->debug.fake_stub_year[0])
|
||||||
mem_replace(iter->s, iter->size, UPX_VERSION_YEAR, 4, opt->fake_stub_year);
|
mem_replace(iter->s, iter->size, UPX_VERSION_YEAR, 4, opt->debug.fake_stub_year);
|
||||||
}
|
}
|
||||||
done = 1;
|
done = 1;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user