src: use 'byte' instead of 'upx_byte'; NFCI
This commit is contained in:
+30
-30
@@ -127,7 +127,7 @@ bool PackWcle::canPack() {
|
||||
|
||||
void PackWcle::encodeEntryTable() {
|
||||
unsigned count, object, n;
|
||||
upx_byte *p = ientries;
|
||||
byte *p = ientries;
|
||||
n = 0;
|
||||
while (*p) {
|
||||
count = *p;
|
||||
@@ -208,8 +208,8 @@ void PackWcle::encodeObjectTable() {
|
||||
void PackWcle::encodePageMap() {
|
||||
opm_entries = New(le_pagemap_entry_t, sopm_entries = opages);
|
||||
for (unsigned ic = 0; ic < sopm_entries; ic++) {
|
||||
opm_entries[ic].l = (unsigned char) (ic + 1);
|
||||
opm_entries[ic].m = (unsigned char) ((ic + 1) >> 8);
|
||||
opm_entries[ic].l = (byte) (ic + 1);
|
||||
opm_entries[ic].m = (byte) ((ic + 1) >> 8);
|
||||
opm_entries[ic].h = 0;
|
||||
opm_entries[ic].type = 0;
|
||||
}
|
||||
@@ -224,7 +224,7 @@ void PackWcle::encodeFixupPageTable() {
|
||||
|
||||
void PackWcle::encodeFixups() {
|
||||
sofixups = 1 * 7 + FIXUP_EXTRA;
|
||||
ofixups = New(upx_byte, sofixups);
|
||||
ofixups = New(byte, sofixups);
|
||||
memset(ofixups, 0, sofixups);
|
||||
ofixups[0] = 7;
|
||||
set_le16(ofixups + 2, (LE_STUB_EDI + neweip) & (mps - 1));
|
||||
@@ -251,12 +251,12 @@ void PackWcle::preprocessFixups() {
|
||||
ByteArray(srf, counts[objects + 0] + 1);
|
||||
ByteArray(slf, counts[objects + 1] + 1);
|
||||
|
||||
SPAN_S_VAR(upx_byte, relocs, mb_relocs);
|
||||
SPAN_S_VAR(upx_byte, selector_fixups, srf_membuf);
|
||||
SPAN_S_VAR(upx_byte, selfrel_fixups, slf_membuf);
|
||||
SPAN_S_VAR(byte, relocs, mb_relocs);
|
||||
SPAN_S_VAR(byte, selector_fixups, srf_membuf);
|
||||
SPAN_S_VAR(byte, selfrel_fixups, slf_membuf);
|
||||
unsigned relocnum = 0;
|
||||
|
||||
upx_byte *fix = ifixups;
|
||||
byte *fix = ifixups;
|
||||
for (ic = jc = 0; ic < pages; ic++) {
|
||||
while (ptr_udiff_bytes(fix, ifixups) < get_le32(ifpage_table + (ic + 1))) {
|
||||
const int fixp2 = get_le16_signed(fix + 2);
|
||||
@@ -351,9 +351,9 @@ void PackWcle::preprocessFixups() {
|
||||
if (sofixups < 4 * relocnum + 8192) {
|
||||
delete[] ifixups;
|
||||
sofixups = 4 * relocnum + 8192;
|
||||
ifixups = New(upx_byte, sofixups);
|
||||
ifixups = New(byte, sofixups);
|
||||
}
|
||||
SPAN_S_VAR(upx_byte, orelocs, ifixups, sofixups);
|
||||
SPAN_S_VAR(byte, orelocs, ifixups, sofixups);
|
||||
fix =
|
||||
ifixups + optimizeReloc(relocnum, relocs, orelocs, iimage, soimage, 32, true, &big_relocs);
|
||||
has_extra_code = ptr_udiff_bytes(selector_fixups, srf) != 0;
|
||||
@@ -431,7 +431,7 @@ void PackWcle::pack(OutputFile *fo) {
|
||||
const unsigned text_vaddr = IOT(ih.init_cs_object - 1, my_base_address);
|
||||
|
||||
// attach some useful data at the end of preprocessed fixups
|
||||
ifixups[sofixups++] = (unsigned char) (ih.automatic_data_object & 0xff);
|
||||
ifixups[sofixups++] = (byte) (ih.automatic_data_object & 0xff);
|
||||
unsigned ic = objects * sizeof(*iobject_table);
|
||||
memcpy(ifixups + sofixups, iobject_desc, ic);
|
||||
iobject_desc.dealloc();
|
||||
@@ -442,7 +442,7 @@ void PackWcle::pack(OutputFile *fo) {
|
||||
set_le32(ifixups + sofixups + 4, ih.init_eip_offset + text_vaddr); // real entry point
|
||||
set_le32(ifixups + sofixups + 8,
|
||||
mem_size(mps, pages)); // virtual address of unpacked relocations
|
||||
ifixups[sofixups + 12] = (unsigned char) (unsigned) objects;
|
||||
ifixups[sofixups + 12] = (byte) (unsigned) objects;
|
||||
sofixups += 13;
|
||||
|
||||
// prepare filter
|
||||
@@ -525,7 +525,7 @@ void PackWcle::decodeFixups() {
|
||||
mb_iimage.dealloc();
|
||||
iimage = nullptr;
|
||||
|
||||
SPAN_S_VAR(const upx_byte, p, oimage + soimage);
|
||||
SPAN_S_VAR(const byte, p, oimage + soimage);
|
||||
MemBuffer mb_relocs;
|
||||
unsigned const fixupn = unoptimizeReloc(p, mb_relocs, oimage, soimage, 32, true);
|
||||
|
||||
@@ -544,10 +544,10 @@ void PackWcle::decodeFixups() {
|
||||
mb_relocs.dealloc(); // done
|
||||
|
||||
// selector fixups then self-relative fixups
|
||||
SPAN_S_VAR(const upx_byte, selector_fixups, p);
|
||||
SPAN_S_VAR(const byte, selector_fixups, p);
|
||||
|
||||
// Find selfrel_fixups by skipping over selector_fixups.
|
||||
SPAN_S_VAR(const upx_byte, q, selector_fixups);
|
||||
SPAN_S_VAR(const byte, q, selector_fixups);
|
||||
// The code is a subroutine that ends in RET (0xC3).
|
||||
while (*q != 0xC3) {
|
||||
// Defend against tampered selector_fixups; see PackWcle::preprocessFixups().
|
||||
@@ -557,14 +557,14 @@ void PackWcle::decodeFixups() {
|
||||
// and where byte [+1] also can be '\xDA' or '\xDB'.
|
||||
if (0x8C != q[0] || 0x66 != q[2] || 0x89 != q[3]) { // Unexpected; tampering?
|
||||
// Try to recover by looking for the RET.
|
||||
upx_byte const *q2 = (upx_byte const *) memchr(q, 0xC3, 9);
|
||||
const byte *q2 = (const byte *) memchr(q, 0xC3, 9);
|
||||
if (q2) { // Assume recovery
|
||||
q = q2;
|
||||
break;
|
||||
}
|
||||
}
|
||||
// Guard against run-away.
|
||||
static unsigned char const blank[9] = {0};
|
||||
static byte const blank[9] = {0};
|
||||
// catastrophic worst case or no-good early warning
|
||||
if (ptr_diff_bytes(oimage + ph.u_len - sizeof(blank), raw_bytes(q, 0)) < 0 ||
|
||||
!memcmp(blank, q, sizeof(blank))) {
|
||||
@@ -576,11 +576,11 @@ void PackWcle::decodeFixups() {
|
||||
q += 9;
|
||||
}
|
||||
unsigned selectlen = ptr_udiff_bytes(q, selector_fixups) / 9;
|
||||
SPAN_S_VAR(const upx_byte, selfrel_fixups, q + 1); // Skip the 0xC3
|
||||
SPAN_S_VAR(const byte, selfrel_fixups, q + 1); // Skip the 0xC3
|
||||
|
||||
const unsigned fbytes = fixupn * 9 + 1000 + selectlen * 5;
|
||||
ofixups = New(upx_byte, fbytes);
|
||||
SPAN_S_VAR(upx_byte, fp, ofixups, fbytes, ofixups);
|
||||
ofixups = New(byte, fbytes);
|
||||
SPAN_S_VAR(byte, fp, ofixups, fbytes, ofixups);
|
||||
|
||||
for (ic = 1, jc = 0; ic <= opages; ic++) {
|
||||
// self relative fixups
|
||||
@@ -592,9 +592,9 @@ void PackWcle::decodeFixups() {
|
||||
r += o;
|
||||
o = soobject_table;
|
||||
virt2rela(oobject_table, &o, &r);
|
||||
fp[4] = (unsigned char) o;
|
||||
fp[4] = (byte) o;
|
||||
set_le32(fp + 5, r);
|
||||
fp[1] = (unsigned char) (r > 0xFFFF ? 0x10 : 0);
|
||||
fp[1] = (byte) (r > 0xFFFF ? 0x10 : 0);
|
||||
fp += fp[1] ? 9 : 7;
|
||||
selfrel_fixups += 4;
|
||||
dputc('r', stdout);
|
||||
@@ -605,7 +605,7 @@ void PackWcle::decodeFixups() {
|
||||
fp[1] = 0;
|
||||
set_le16(fp + 2, r & (mps - 1));
|
||||
unsigned x = selector_fixups[1] > 0xD0 ? oh.init_ss_object : oh.init_cs_object;
|
||||
fp[4] = (unsigned char) x;
|
||||
fp[4] = (byte) x;
|
||||
fp += 5;
|
||||
selector_fixups += 9;
|
||||
selectlen--;
|
||||
@@ -618,13 +618,13 @@ void PackWcle::decodeFixups() {
|
||||
{
|
||||
r = get_le32(oimage + get_le32(wrkmem + 4 * (jc - 2)));
|
||||
fp[0] = 7;
|
||||
fp[1] = (unsigned char) (r > 0xFFFF ? 0x10 : 0);
|
||||
fp[1] = (byte) (r > 0xFFFF ? 0x10 : 0);
|
||||
set_le16(fp + 2, get_le32(wrkmem + 4 * (jc - 2)) | ~3);
|
||||
set_le32(fp + 5, r);
|
||||
o = soobject_table;
|
||||
r = get_le32(wrkmem + 4 * (jc - 1));
|
||||
virt2rela(oobject_table, &o, &r);
|
||||
fp[4] = (unsigned char) o;
|
||||
fp[4] = (byte) o;
|
||||
fp += fp[1] ? 9 : 7;
|
||||
dputc('0', stdout);
|
||||
}
|
||||
@@ -633,9 +633,9 @@ void PackWcle::decodeFixups() {
|
||||
virt2rela(oobject_table, &o, &r);
|
||||
r = get_le32(oimage + get_le32(wrkmem + 4 * jc));
|
||||
fp[0] = 7;
|
||||
fp[1] = (unsigned char) (r > 0xFFFF ? 0x10 : 0);
|
||||
fp[1] = (byte) (r > 0xFFFF ? 0x10 : 0);
|
||||
set_le16(fp + 2, get_le32(wrkmem + 4 * jc) & (mps - 1));
|
||||
fp[4] = (unsigned char) o;
|
||||
fp[4] = (byte) o;
|
||||
set_le32(fp + 5, r);
|
||||
fp += fp[1] ? 9 : 7;
|
||||
jc += 2;
|
||||
@@ -697,7 +697,7 @@ void PackWcle::decodeImage() {
|
||||
|
||||
void PackWcle::decodeEntryTable() {
|
||||
unsigned count, object, n, r;
|
||||
SPAN_S_VAR(upx_byte, p, ientries, soentries);
|
||||
SPAN_S_VAR(byte, p, ientries, soentries);
|
||||
n = 0;
|
||||
while (*p) {
|
||||
count = *p;
|
||||
@@ -776,9 +776,9 @@ void PackWcle::unpack(OutputFile *fo) {
|
||||
|
||||
Filter ft(ph.level);
|
||||
ft.init(ph.filter, text_vaddr);
|
||||
ft.cto = (unsigned char) ph.filter_cto;
|
||||
ft.cto = (byte) ph.filter_cto;
|
||||
if (ph.version < 11)
|
||||
ft.cto = (unsigned char) (get_le32(oimage + ph.u_len - 9) >> 24);
|
||||
ft.cto = (byte) (get_le32(oimage + ph.u_len - 9) >> 24);
|
||||
ft.unfilter(raw_bytes(oimage + text_vaddr, text_size), text_size);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user