Rearranged debug options.
committer: mfx <mfx> 1139916141 +0000
This commit is contained in:
parent
304ba57dad
commit
cdd117bfb9
38
src/main.cpp
38
src/main.cpp
@ -443,7 +443,7 @@ static int do_option(int optc, const char *arg)
|
||||
set_cmd(CMD_DECOMPRESS);
|
||||
break;
|
||||
case 'D':
|
||||
opt->debug++;
|
||||
opt->debug.debug_level++;
|
||||
break;
|
||||
case 'f':
|
||||
opt->force++;
|
||||
@ -537,6 +537,23 @@ static int do_option(int optc, const char *arg)
|
||||
e_method(opt->method, 10);
|
||||
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
|
||||
case 512:
|
||||
opt->console = CON_FILE;
|
||||
@ -550,16 +567,6 @@ static int do_option(int optc, const char *arg)
|
||||
case 516:
|
||||
opt->no_progress = true;
|
||||
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:
|
||||
opt->no_env = true;
|
||||
break;
|
||||
@ -763,9 +770,6 @@ static const struct mfx_option longopts[] =
|
||||
{"version", 0, 0, 'V'+256}, // display version number
|
||||
|
||||
// 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-compress", 0, 0, 'f'}, // and compression of suspicious files
|
||||
{"info", 0, 0, 'i'}, // info mode
|
||||
@ -781,6 +785,12 @@ static const struct mfx_option longopts[] =
|
||||
#endif
|
||||
{"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", 0, 0, 'k'},
|
||||
{"keep", 0, 0, 'k'},
|
||||
|
||||
@ -56,9 +56,6 @@ struct options_t {
|
||||
// other options
|
||||
int backup;
|
||||
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 info_mode;
|
||||
bool ignorewarn;
|
||||
@ -69,6 +66,14 @@ struct options_t {
|
||||
int verbose;
|
||||
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
|
||||
enum {
|
||||
SKIP_OVERLAY = 0,
|
||||
|
||||
@ -411,7 +411,7 @@ void PackExe::pack(OutputFile *fo)
|
||||
throwCantPack("decompressor limit exceeded, send a bugreport");
|
||||
|
||||
#ifdef TESTING
|
||||
if (opt->debug)
|
||||
if (opt->debug.debug_level)
|
||||
{
|
||||
printf("image+relocs %d -> %d\n",ih_imagesize+relocsize,ph.c_len);
|
||||
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
|
||||
#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);
|
||||
#endif
|
||||
fo->write(&oh,sizeof(oh));
|
||||
|
||||
@ -2098,7 +2098,8 @@ void PackW32Pe::pack(OutputFile *fo)
|
||||
fo->write(obuf,clen);
|
||||
infoWriting("compressed data", clen);
|
||||
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)
|
||||
fo->write(ibuf,4 - ic);
|
||||
fo->write(otls,sotls);
|
||||
|
||||
@ -48,8 +48,8 @@ static const
|
||||
#define LE_STUB_EDI (1)
|
||||
|
||||
#ifdef TESTING
|
||||
# define dputc(x,y) do { if (opt->debug) putc(x,y); } while (0)
|
||||
# define Opt_debug opt->debug
|
||||
# define dputc(x,y) do { if (opt->debug.debug_level) putc(x,y); } while (0)
|
||||
# define Opt_debug opt->debug.debug_level
|
||||
#else
|
||||
# define dputc(x,y) ((void)0)
|
||||
# define Opt_debug 0
|
||||
|
||||
@ -812,8 +812,8 @@ int Packer::patchVersion(void *b, int blen)
|
||||
checkPatch(b, blen, boff, 14);
|
||||
|
||||
unsigned char *p = (unsigned char *)b + boff + 9;
|
||||
if (opt->fake_stub_version[0])
|
||||
memcpy(p, opt->fake_stub_version, 4);
|
||||
if (opt->debug.fake_stub_version[0])
|
||||
memcpy(p, opt->debug.fake_stub_version, 4);
|
||||
else
|
||||
memcpy(p, UPX_VERSION_STRING4, 4);
|
||||
|
||||
@ -828,8 +828,8 @@ int Packer::patchVersionYear(void *b, int blen)
|
||||
checkPatch(b, blen, boff, 11);
|
||||
|
||||
unsigned char *p = (unsigned char *)b + boff + 6;
|
||||
if (opt->fake_stub_year[0])
|
||||
memcpy(p, opt->fake_stub_year, 4);
|
||||
if (opt->debug.fake_stub_year[0])
|
||||
memcpy(p, opt->debug.fake_stub_year, 4);
|
||||
else
|
||||
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 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; };
|
||||
static const strinfo_t strlist[] = {
|
||||
@ -1024,10 +1024,10 @@ char const *Packer::getIdentstr(unsigned *size, int small)
|
||||
|
||||
for (iter = strlist; iter->s; ++iter)
|
||||
{
|
||||
if (opt->fake_stub_version[0])
|
||||
mem_replace(iter->s, iter->size, UPX_VERSION_STRING4, 4, opt->fake_stub_version);
|
||||
if (opt->fake_stub_year[0])
|
||||
mem_replace(iter->s, iter->size, UPX_VERSION_YEAR, 4, opt->fake_stub_year);
|
||||
if (opt->debug.fake_stub_version[0])
|
||||
mem_replace(iter->s, iter->size, UPX_VERSION_STRING4, 4, opt->debug.fake_stub_version);
|
||||
if (opt->debug.fake_stub_year[0])
|
||||
mem_replace(iter->s, iter->size, UPX_VERSION_YEAR, 4, opt->debug.fake_stub_year);
|
||||
}
|
||||
done = 1;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user