From c8699adf66d8617843c35eb066237ce79a4f57e9 Mon Sep 17 00:00:00 2001 From: rgimad Date: Sat, 31 May 2025 11:37:06 +0300 Subject: [PATCH] add some comments, add todos --- kpack_c.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/kpack_c.c b/kpack_c.c index d9e4ccd..4c782c5 100644 --- a/kpack_c.c +++ b/kpack_c.c @@ -49,7 +49,7 @@ unsigned pack_lzma(unsigned char *infile, unsigned char *outfile, unsigned insiz unsigned preprocess_calltrick(unsigned char *infile, unsigned insize, unsigned char ct1[256], unsigned *ctn, unsigned char *cti) { - unsigned char *buf = malloc(2*insize); + unsigned char *buf = malloc(2*insize); // TODO WHERE it is used? if (buf == NULL) { goto pack_calltrick_fail; } @@ -70,17 +70,17 @@ unsigned preprocess_calltrick(unsigned char *infile, unsigned insize, unsigned c break; } unsigned num; - memcpy(&num, infile_ptr, 4); + memcpy(&num, infile_ptr, 4); // read relative jump/call offset infile_ptr += 4; - num += (infile_ptr - infile); + num += (infile_ptr - infile); // convert it to global offset inside file if (num >= insize || num >= 0x1000000) { // xxx: infile_ptr -= 4; ct1[*infile_ptr] = 1; } else { count -= 4; num = byteswap(num); - memcpy(infile_ptr - 4, &num, 4); - (*ctn)++; + memcpy(infile_ptr - 4, &num, 4); // substitute jmp/call offset with global offset + (*ctn)++; // update substitution counter memcpy(buf_ptr, &infile_ptr, sizeof(buf_ptr)); buf_ptr += sizeof(buf_ptr); }