From 1f985d3fba8f3c9fc213fd81181bf8fb98ba844d Mon Sep 17 00:00:00 2001 From: rgimad Date: Fri, 18 Apr 2025 13:44:42 +0300 Subject: [PATCH] made it compile on gcc linux 64. segfault in preprocess calltrick todo fix --- kpack_c.c | 11 +++++++++-- lzma_c/LZMAEncoderApi.h | 2 ++ lzma_c/common.h | 4 ++++ 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/kpack_c.c b/kpack_c.c index 53c730f..1126dc0 100644 --- a/kpack_c.c +++ b/kpack_c.c @@ -5,6 +5,9 @@ #include #include #include +#define __USE_LARGEFILE64 +#define _LARGEFILE_SOURCE +#define _LARGEFILE64_SOURCE #include #include "lzma_c/LZMAEncoderApi.h" @@ -91,8 +94,8 @@ unsigned preprocess_calltrick(unsigned char *infile, unsigned insize, unsigned c unsigned tmp; while (buf_ptr != buf) { buf_ptr -= 8; - memcpy(&tmp, *buf_ptr, 4); - memcpy(tmp - 4, cti, 1); + memcpy(&tmp, buf_ptr, 4); + memcpy((unsigned char*)(size_t)(tmp - 4), cti, 1); } free(buf); return tmp; @@ -235,6 +238,10 @@ int main(int argc, char *argv[]) unsigned ctn; unsigned char cti; + unsigned prep_ct_res1 = preprocess_calltrick(infile_buf, infile_size, ct1, &ctn, &cti); + + // if (....) + // TODO ... return 0; diff --git a/lzma_c/LZMAEncoderApi.h b/lzma_c/LZMAEncoderApi.h index abb7e0b..dae65ca 100644 --- a/lzma_c/LZMAEncoderApi.h +++ b/lzma_c/LZMAEncoderApi.h @@ -1,6 +1,8 @@ #ifndef LZMA_ENCODER_API_H_ #define LZMA_ENCODER_API_H_ +#include "common.h" + void __stdcall lzma_set_dict_size(unsigned logdictsize); unsigned __stdcall lzma_compress( diff --git a/lzma_c/common.h b/lzma_c/common.h index 4db706e..3ad1455 100644 --- a/lzma_c/common.h +++ b/lzma_c/common.h @@ -17,6 +17,10 @@ // #define true 1 // #define false 0 +#ifndef __stdcall +#define __stdcall __attribute__((stdcall)) +#endif + typedef uint8_t byte; typedef uint16_t word; typedef uint64_t uint64;