refactorings, impl more todo check

This commit is contained in:
2025-04-17 19:06:28 +03:00
parent 3abc8f278e
commit 33bb1e20db

View File

@@ -52,8 +52,7 @@ unsigned preprocess_calltrick(unsigned char *infile, unsigned insize, unsigned c
unsigned char *infile_ptr = infile; unsigned char *infile_ptr = infile;
unsigned count = insize; unsigned count = insize;
unsigned edx = 0; unsigned char *buf_ptr = buf;
unsigned char *ebx = buf;
do { do {
unsigned al = *infile_ptr++; unsigned al = *infile_ptr++;
al -= 0x0E8; al -= 0x0E8;
@@ -67,21 +66,20 @@ unsigned preprocess_calltrick(unsigned char *infile, unsigned insize, unsigned c
memcpy(&num, infile_ptr, 4); memcpy(&num, infile_ptr, 4);
infile_ptr += 4; infile_ptr += 4;
num += (infile_ptr - infile); num += (infile_ptr - infile);
if (num >= insize || num >= 0x1000000) { if (num >= insize || num >= 0x1000000) { // xxx:
infile_ptr -= 4; infile_ptr -= 4;
ct1[*infile_ptr] = 1; ct1[*infile_ptr] = 1;
} else { } else {
count -= 4; count -= 4;
num = byteswap(num); num = byteswap(num);
memcpy(infile_ptr - 4, &num, 4); memcpy(infile_ptr - 4, &num, 4);
edx++; (*ctn)++;
memcpy(ebx, &infile_ptr, 4); memcpy(buf_ptr, &infile_ptr, 4);
ebx += 8; buf_ptr += 8;
} }
} while(count > 0); } while(count > 0); //
*ctn = edx;
unsigned idx = 0; unsigned idx = 0;
while (idx < 256 && ct1[idx] != 0) { while (idx < 256 && ct1[idx] != 0) {
idx++; idx++;
@@ -91,10 +89,23 @@ unsigned preprocess_calltrick(unsigned char *infile, unsigned insize, unsigned c
} }
*cti = ~(unsigned char)256; *cti = ~(unsigned char)256;
if (buf_ptr == buf) {
free(buf);
return 0;
} else {
buf_ptr -= 8;
unsigned tmp;
memcpy(&tmp, *buf_ptr, 4);
memcpy(tmp - 4, cti, 1);
// TDOO here jmp @b
}
// TODO ! // TODO !
pack_calltrick_fail: pack_calltrick_fail:
// TODO *ctn = 0;
// ebx = 0; // TODO what
return 0; // 0?
} }
@@ -226,7 +237,7 @@ int main(int argc, char *argv[])
outfilebest = outfile; outfilebest = outfile;
unsigned method = METHOD_LZMA; unsigned method = METHOD_LZMA;
unsigned char ct1[256]; // TODO zero out or place it zeroable space unsigned char ct1[256];
unsigned ctn; unsigned ctn;
unsigned char cti; unsigned char cti;