Skip to content

Commit e884eeb

Browse files
committed
add CMakeLists.txt
hardcoded decode.bin into header file
1 parent e9fce1a commit e884eeb

4 files changed

Lines changed: 123 additions & 5 deletions

File tree

CMakeLists.txt

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
cmake_minimum_required(VERSION 3.10)
2+
project(tinyhook)
3+
4+
option(COMPACT "no error log output" OFF)
5+
option(NO_EXPORT "hide all symbols" OFF)
6+
7+
if(COMPACT)
8+
add_definitions(-DCOMPACT)
9+
endif()
10+
if(NO_EXPORT)
11+
add_definitions(-DNO_EXPORT)
12+
endif()
13+
14+
set(TH_SOURCES
15+
src/memory.c
16+
src/tinyhook.c
17+
src/interpose.c
18+
src/objcrt.c
19+
src/symsolve/symtable.c
20+
src/symsolve/symexport.c
21+
src/exhook.c
22+
)
23+
include_directories(src)
24+
add_compile_options(-fvisibility=hidden -Wall -Wshadow)
25+
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE)
26+
27+
add_library(tinyhook_static STATIC ${TH_SOURCES})
28+
target_include_directories(tinyhook_static PUBLIC include)
29+
set_target_properties(tinyhook_static PROPERTIES OUTPUT_NAME "tinyhook")
30+
31+
add_library(tinyhook_shared SHARED ${TH_SOURCES})
32+
target_include_directories(tinyhook_shared PUBLIC include)
33+
target_link_libraries(tinyhook_shared objc)
34+
set_target_properties(tinyhook_shared PROPERTIES OUTPUT_NAME "tinyhook")

Makefile

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
ARCH ?= $(shell uname -m)
22
TARGET ?= macosx
33

4-
CFLAGS := -Iinclude -arch $(ARCH) -fvisibility=hidden -Os -Wall -Wshadow
5-
LDFLAGS := -flto=full -lobjc
4+
CFLAGS := -arch $(ARCH) -Iinclude -flto=full -fvisibility=hidden -Os -Wall -Wshadow
5+
LDFLAGS := -arch $(ARCH) -flto=full -lobjc
66

77
SRC := $(shell find src -name "*.c")
88
OBJ := $(patsubst %.c,%.o,$(wildcard $(SRC)))
@@ -20,6 +20,7 @@ endif
2020

2121
ifeq ($(TARGET), iphoneos)
2222
CFLAGS += -isysroot $(shell xcrun --sdk $(TARGET) --show-sdk-path)
23+
LDFLAGS += -isysroot $(shell xcrun --sdk $(TARGET) --show-sdk-path)
2324
endif
2425

2526
CFLAGS += $(if $(DEBUG),-g -fsanitize=address)
@@ -37,7 +38,7 @@ $(LIB_STATIC): $(OBJ)
3738
ranlib $@
3839

3940
$(LIB_SHARED): $(OBJ)
40-
$(CC) $(CFLAGS) $(LDFLAGS) -shared -o $@ $^
41+
$(CC) $(LDFLAGS) -shared -o $@ $^
4142

4243
test: $(LIB_STATIC)
4344
cd test && $(MAKE) run ARCH=$(ARCH)

src/fde64/decode.bin

-1.6 KB
Binary file not shown.

src/fde64/fde64.h

Lines changed: 85 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,8 +242,91 @@ extern "C" {
242242

243243
// int encode(void *dest, struct fde64s *cmd);
244244
__attribute__((naked)) int decode(const void *src, struct fde64s *cmd) {
245-
asm(".incbin \"src/fde64/decode.bin\"");
246-
// this binary is from https://github.com/Antibioticss/fde64
245+
// from github.com/Antibioticss/fde64
246+
// asm (".incbin \"decode.bin\"");
247+
asm(".byte "
248+
"0x53,0x48,0x89,0xf9,0x48,0x89,0xf2,0x48,0x89,0xce,0x49,0x89,0xc8,0x31,0xc9,0x30,0xc0,0x48,0x89,0xd7,"
249+
"0xb1,0x39,0xf3,0xaa,0xac,0x88,0xc1,0x88,0xc5,0x80,0xe1,0xfe,0x80,0xe5,0xe7,0x3c,0xf0,0x74,0x20,0x80,"
250+
"0xf9,0xf2,0x74,0x24,0x3c,0x66,0x74,0x29,0x3c,0x67,0x74,0x2e,0x80,0xf9,0x64,0x74,0x05,0x80,0xfd,0x2e,"
251+
"0x75,0x2d,0x80,0x4a,0x01,0x04,0x88,0x42,0x04,0xeb,0xd1,0x80,0x4a,0x01,0x01,0x88,0x42,0x02,0xeb,0xc8,"
252+
"0x80,0x4a,0x01,0x02,0x88,0x42,0x03,0xeb,0xbf,0x80,0x4a,0x01,0x08,0x88,0x42,0x05,0xeb,0xb6,0x80,0x4a,"
253+
"0x01,0x10,0x88,0x42,0x06,0xeb,0xad,0x88,0xc1,0x80,0xe1,0xf0,0x80,0xf9,0x40,0x75,0x29,0x80,0x4a,0x01,"
254+
"0x20,0x88,0x42,0x07,0x88,0xc4,0x88,0xc1,0x88,0xc5,0xc0,0xe8,0x03,0xc0,0xec,0x02,0xd0,0xe9,0x24,0x01,"
255+
"0x80,0xe4,0x01,0x80,0xe1,0x01,0x80,0xe5,0x01,0x66,0x89,0x42,0x08,0x66,0x89,0x4a,0x0a,0xac,0x88,0xc1,"
256+
"0x80,0xe1,0xfe,0x80,0xf9,0xc4,0x0f,0x85,0xc2,0x00,0x00,0x00,0xc6,0x42,0x18,0x0f,0x80,0x4a,0x01,0x40,"
257+
"0x88,0x42,0x0c,0x88,0xc1,0xac,0x88,0x42,0x0d,0xf6,0x42,0x01,0x2b,0x74,0x07,0x81,0x4a,0x35,0x00,0x20,"
258+
"0x00,0x00,0x80,0xf9,0xc5,0x75,0x2c,0x88,0xc4,0x88,0xc1,0x88,0xc5,0xd0,0xe4,0xc0,0xe1,0x05,0xc0,0xe8,"
259+
"0x07,0xc0,0xec,0x04,0xc0,0xe9,0x07,0x80,0xe5,0x03,0x0c,0xfe,0x80,0xcc,0xf0,0xf6,0xd0,0xf6,0xd4,0x88,"
260+
"0x42,0x0f,0x88,0x62,0x14,0x66,0x89,0x4a,0x15,0xeb,0x5c,0x88,0xc4,0x88,0xc1,0x88,0xc5,0xd0,0xe4,0xc0,"
261+
"0xe1,0x02,0xc0,0xe8,0x07,0xc0,0xec,0x07,0xc0,0xe9,0x07,0x80,0xe5,0x1f,0x0c,0xfe,0x80,0xcc,0xfe,0x80,"
262+
"0xc9,0xfe,0xf6,0xd0,0xf6,0xd4,0xf6,0xd1,0x66,0x89,0x42,0x0f,0x66,0x89,0x4a,0x11,0xac,0x88,0x42,0x0e,"
263+
"0x88,0xc4,0x88,0xc1,0x88,0xc3,0xd0,0xe4,0xc0,0xe1,0x05,0xc0,0xe8,0x07,0xc0,0xec,0x04,0xc0,0xe9,0x07,"
264+
"0x80,0xe3,0x03,0x80,0xcc,0xf0,0xf6,0xd4,0x66,0x89,0x42,0x13,0x88,0x4a,0x15,0x88,0x5a,0x16,0x80,0xfd,"
265+
"0x01,0x75,0x04,0xb3,0xfd,0xeb,0x57,0xb3,0xfe,0xb7,0x38,0x88,0x7a,0x19,0x80,0xfd,0x02,0x74,0x61,0xb7,"
266+
"0x3a,0x88,0x7a,0x19,0xeb,0x5a,0xc6,0x42,0x17,0x01,0x88,0x42,0x18,0x48,0x8d,0x1d,0x5a,0x02,0x00,0x00,"
267+
"0x88,0xc4,0xd7,0x93,0x80,0xfb,0xff,0x75,0x0e,0x81,0x4a,0x35,0x00,0x00,0x02,0x00,0x30,0xdb,0xe9,0xb0,"
268+
"0x01,0x00,0x00,0x80,0xfb,0xfc,0x75,0x1a,0x81,0x4a,0x35,0x00,0x10,0x00,0x00,0x80,0x62,0x01,0xdf,0x31,"
269+
"0xc0,0x89,0x42,0x07,0x88,0x42,0x0b,0x88,0xf8,0xe9,0x67,0xfe,0xff,0xff,0x80,0xfb,0xfd,0x75,0x11,0xac,"
270+
"0xc6,0x42,0x17,0x02,0x88,0x42,0x19,0x48,0x8d,0x1d,0x10,0x03,0x00,0x00,0xeb,0xb4,0x80,0xfb,0xfe,0x75,"
271+
"0x45,0xac,0xc6,0x42,0x17,0x03,0x88,0x42,0x1a,0x31,0xc9,0xb4,0x43,0xb1,0x38,0xf6,0x42,0x01,0x40,0x74,"
272+
"0x02,0x88,0xe1,0x48,0x8d,0x3d,0xec,0x03,0x00,0x00,0xb3,0x01,0x80,0xff,0x38,0x74,0x15,0xb4,0x20,0xb1,"
273+
"0x18,0xf6,0x42,0x01,0x40,0x74,0x02,0x88,0xe1,0x48,0x8d,0x3d,0x15,0x04,0x00,0x00,0xb3,0x03,0xf2,0xae,"
274+
"0x0f,0x85,0x77,0xff,0xff,0xff,0x88,0xc7,0xeb,0x24,0x80,0xfb,0xfb,0x75,0x1f,0x48,0x8d,0x7a,0x23,0xf6,"
275+
"0x42,0x01,0x10,0x74,0x0a,0x83,0x4a,0x35,0x08,0xa5,0xe9,0x61,0xff,0xff,0xff,0x83,0x4a,0x35,0x10,0x48,"
276+
"0xa5,0xe9,0x56,0xff,0xff,0xff,0xf6,0xc3,0x01,0x0f,0x84,0xa0,0x00,0x00,0x00,0xac,0x83,0x4a,0x35,0x01,"
277+
"0x88,0x42,0x1b,0x88,0xc1,0x88,0xc5,0xc0,0xe5,0x02,0xc0,0xe9,0x06,0xc0,0xed,0x05,0x24,0x07,0x66,0x89,"
278+
"0x4a,0x1c,0x88,0x42,0x1e,0x8a,0x62,0x18,0x80,0xe4,0xfe,0x80,0xfc,0xf6,0x75,0x07,0x84,0xed,0x74,0x03,"
279+
"0x80,0xe3,0xf5,0x80,0xf9,0x02,0x74,0x14,0x80,0xf9,0x01,0x74,0x15,0x84,0xc9,0x75,0x15,0x3c,0x05,0x75,"
280+
"0x11,0x81,0x4a,0x35,0x00,0x06,0x00,0x00,0x83,0x4a,0x35,0x08,0xeb,0x04,0x83,0x4a,0x35,0x04,0x80,0xf9,"
281+
"0x03,0x74,0x30,0x3c,0x04,0x75,0x2c,0xac,0x83,0x4a,0x35,0x02,0x88,0x42,0x1f,0x88,0xc4,0x88,0xc5,0xc0,"
282+
"0xe4,0x02,0xc0,0xe8,0x06,0xc0,0xec,0x05,0x80,0xe5,0x07,0x66,0x89,0x42,0x20,0x88,0x6a,0x22,0x84,0xc9,"
283+
"0x75,0x09,0x80,0xfd,0x05,0x75,0x04,0x83,0x4a,0x35,0x08,0x48,0x8d,0x7a,0x23,0xf7,0x42,0x35,0x08,0x00,"
284+
"0x00,0x00,0x74,0x01,0xa5,0xf7,0x42,0x35,0x04,0x00,0x00,0x00,0x74,0x01,0xa4,0x48,0x8d,0x7a,0x2b,0xf6,"
285+
"0xc3,0x08,0x74,0x42,0x8a,0x42,0x18,0x24,0xf8,0x3c,0xb8,0x75,0x14,0x80,0x7a,0x08,0x01,0x75,0x0e,0x81,"
286+
"0x4a,0x35,0x00,0x01,0x00,0x00,0x48,0xa5,0xe9,0x87,0xfe,0xff,0xff,0xf6,0xc3,0x10,0x75,0x14,0x80,0x7a,"
287+
"0x08,0x01,0x74,0x0e,0xf6,0x42,0x01,0x08,0x74,0x08,0x83,0x4a,0x35,0x40,0x66,0xa5,0xeb,0x08,0x81,0x4a,"
288+
"0x35,0x80,0x00,0x00,0x00,0xa5,0x48,0x8d,0x7a,0x33,0xf6,0xc3,0x04,0x74,0x0a,0x83,0x4a,0x35,0x40,0x66,"
289+
"0xa5,0x48,0x8d,0x7a,0x33,0xf6,0xc3,0x02,0x74,0x05,0x83,0x4a,0x35,0x20,0xa4,0xf6,0x42,0x01,0x01,0x74,"
290+
"0x48,0xf6,0xc3,0x01,0x74,0x3c,0x80,0xf9,0x03,0x74,0x37,0xb9,0x12,0x00,0x00,0x00,0x48,0x8d,0x3d,0xf2,"
291+
"0x02,0x00,0x00,0x80,0x7a,0x18,0x0f,0x74,0x0f,0x80,0xe7,0xfe,0xb9,0x18,0x00,0x00,0x00,0x48,0x8d,0x3d,"
292+
"0xc5,0x02,0x00,0x00,0x38,0x3f,0x48,0x8d,0x7f,0x02,0xe0,0xf8,0x75,0x0c,0x8a,0x4a,0x1d,0x8a,0x47,0xff,"
293+
"0xfe,0xc1,0xd2,0xe8,0x73,0x07,0x81,0x4a,0x35,0x00,0x40,0x00,0x00,0xf6,0xc3,0x40,0x74,0x07,0x81,0x4a,"
294+
"0x35,0x00,0x80,0x00,0x00,0xf6,0xc3,0x10,0x74,0x07,0x81,0x4a,0x35,0x00,0x02,0x00,0x00,0xf6,0xc3,0x20,"
295+
"0x74,0x07,0x81,0x4a,0x35,0x00,0x08,0x00,0x00,0x4c,0x29,0xc6,0x40,0x88,0x32,0x40,0x80,0xfe,0x0f,0x72,"
296+
"0x07,0x81,0x4a,0x35,0x00,0x00,0x01,0x00,0x31,0xc0,0xf7,0x42,0x35,0x00,0xe0,0x03,0x00,0x0f,0x94,0xc0,"
297+
"0x5b,0xc3,0x01,0x01,0x01,0x01,0x02,0x08,0x40,0x40,0x01,0x01,0x01,0x01,0x02,0x08,0x40,0xfd,0x01,0x01,"
298+
"0x01,0x01,0x02,0x08,0x40,0x40,0x01,0x01,0x01,0x01,0x02,0x08,0x40,0x40,0x01,0x01,0x01,0x01,0x02,0x08,"
299+
"0xfc,0x40,0x01,0x01,0x01,0x01,0x02,0x08,0xfc,0x40,0x01,0x01,0x01,0x01,0x02,0x08,0xfc,0x40,0x01,0x01,"
300+
"0x01,0x01,0x02,0x08,0xfc,0x40,0xfc,0xfc,0xfc,0xfc,0xfc,0xfc,0xfc,0xfc,0xfc,0xfc,0xfc,0xfc,0xfc,0xfc,"
301+
"0xfc,0xfc,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x40,0x40,"
302+
"0x41,0x01,0xfc,0xfc,0xfc,0xfc,0x08,0x09,0x02,0x03,0x00,0x00,0x00,0x00,0x12,0x12,0x12,0x12,0x12,0x12,"
303+
"0x12,0x12,0x12,0x12,0x12,0x12,0x12,0x12,0x12,0x12,0x23,0x29,0x23,0x23,0x01,0x01,0x01,0x01,0x01,0x01,"
304+
"0x01,0x01,0x01,0x01,0x01,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x4c,0x00,0x00,0x00,"
305+
"0x00,0x00,0xfb,0xfb,0xfb,0xfb,0x00,0x00,0x00,0x00,0x02,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x02,"
306+
"0x02,0x02,0x02,0x02,0x02,0x02,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x23,0x23,0x04,0x00,0x41,0x41,"
307+
"0x03,0x09,0x06,0x00,0x04,0x00,0x00,0x02,0x40,0x00,0x21,0x21,0x21,0x21,0x42,0x42,0x00,0x00,0x21,0x21,"
308+
"0x21,0x21,0x21,0x21,0x21,0x21,0x12,0x12,0x12,0x12,0x02,0x02,0x02,0x02,0x18,0x18,0x4c,0x12,0x00,0x00,"
309+
"0x00,0x00,0xfc,0x00,0xfc,0xfc,0x00,0x00,0x23,0x29,0x00,0x00,0x00,0x00,0x00,0x00,0x21,0x21,0x21,0x21,"
310+
"0x01,0x01,0xff,0x00,0x00,0x00,0x00,0x00,0xff,0x00,0xff,0x21,0x00,0x03,0x01,0x01,0x01,0x01,0x01,0x01,"
311+
"0x01,0x01,0x00,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0xff,0xff,0xff,0xff,0x01,0x01,"
312+
"0x01,0x01,0x01,0x01,0x01,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0x00,0xfe,0xff,0xfe,0xff,0xff,0xff,"
313+
"0xff,0xff,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,"
314+
"0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,"
315+
"0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x03,0x23,0x23,0x23,0x01,0x01,0x01,0x00,0x01,0x01,"
316+
"0xff,0xff,0x01,0x01,0x01,0x01,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,"
317+
"0x18,0x18,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x00,0x00,"
318+
"0x00,0x01,0x03,0x01,0xff,0xff,0x00,0x00,0x40,0x01,0x03,0x01,0x21,0x01,0x01,0x01,0x01,0x01,0x01,0x01,"
319+
"0x01,0x01,0x01,0x01,0x23,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x03,0x01,0x03,0x03,0x03,0x21,0x00,0x00,"
320+
"0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,"
321+
"0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,"
322+
"0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x00,0x00,0x01,0x02,0x03,0x04,0x05,"
323+
"0x06,0x07,0x08,0x09,0x0a,0x0b,0x10,0x14,0x15,0x17,0x1c,0x1d,0x1e,0x20,0x21,0x22,0x23,0x24,0x25,0x28,"
324+
"0x29,0x2a,0x2b,0x30,0x31,0x32,0x33,0x34,0x35,0x37,0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f,0x40,0x41,"
325+
"0x80,0x81,0x82,0xdb,0xdc,0xdd,0xde,0xdf,0xf0,0xf1,0x0c,0x0d,0x0e,0x0f,0x18,0x19,0x1a,0x2c,0x2d,0x2e,"
326+
"0x2f,0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f,0x14,0x15,0x16,0x17,0x20,0x21,0x22,0x40,0x41,0x42,0x44,"
327+
"0x60,0x61,0x62,0x63,0xdf,0x04,0x05,0x06,0x18,0x19,0x4a,0x4b,0x4c,0x00,0x00,0x08,0x00,0x10,0x00,0x18,"
328+
"0x00,0x20,0x00,0x28,0x00,0x30,0x00,0x80,0x80,0x82,0x80,0x86,0x00,0xf6,0xf3,0xfe,0xfc,0xab,0x00,0xb0,"
329+
"0x00,0xb1,0x00,0xb3,0x00,0xba,0x1f,0xbb,0x00,0xc0,0x00,0xc1,0x00,0xc7,0xfd");
247330
}
248331

249332
#ifdef __cplusplus

0 commit comments

Comments
 (0)