refactorings, impl more todo check
This commit is contained in:
33
kpack_c.c
33
kpack_c.c
@@ -52,8 +52,7 @@ unsigned preprocess_calltrick(unsigned char *infile, unsigned insize, unsigned c
|
||||
|
||||
unsigned char *infile_ptr = infile;
|
||||
unsigned count = insize;
|
||||
unsigned edx = 0;
|
||||
unsigned char *ebx = buf;
|
||||
unsigned char *buf_ptr = buf;
|
||||
do {
|
||||
unsigned al = *infile_ptr++;
|
||||
al -= 0x0E8;
|
||||
@@ -67,21 +66,20 @@ unsigned preprocess_calltrick(unsigned char *infile, unsigned insize, unsigned c
|
||||
memcpy(&num, infile_ptr, 4);
|
||||
infile_ptr += 4;
|
||||
num += (infile_ptr - infile);
|
||||
if (num >= insize || num >= 0x1000000) {
|
||||
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);
|
||||
edx++;
|
||||
memcpy(ebx, &infile_ptr, 4);
|
||||
ebx += 8;
|
||||
(*ctn)++;
|
||||
memcpy(buf_ptr, &infile_ptr, 4);
|
||||
buf_ptr += 8;
|
||||
}
|
||||
|
||||
} while(count > 0);
|
||||
} while(count > 0); //
|
||||
|
||||
*ctn = edx;
|
||||
unsigned idx = 0;
|
||||
while (idx < 256 && ct1[idx] != 0) {
|
||||
idx++;
|
||||
@@ -91,10 +89,23 @@ unsigned preprocess_calltrick(unsigned char *infile, unsigned insize, unsigned c
|
||||
}
|
||||
*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 !
|
||||
|
||||
pack_calltrick_fail:
|
||||
// TODO
|
||||
pack_calltrick_fail:
|
||||
*ctn = 0;
|
||||
// ebx = 0; // TODO what
|
||||
return 0; // 0?
|
||||
}
|
||||
|
||||
|
||||
@@ -226,7 +237,7 @@ int main(int argc, char *argv[])
|
||||
outfilebest = outfile;
|
||||
unsigned method = METHOD_LZMA;
|
||||
|
||||
unsigned char ct1[256]; // TODO zero out or place it zeroable space
|
||||
unsigned char ct1[256];
|
||||
unsigned ctn;
|
||||
unsigned char cti;
|
||||
|
||||
|
Reference in New Issue
Block a user