From c6ac2488c9bfac7db4d5efdcac7a85449ef15d37 Mon Sep 17 00:00:00 2001 From: Nguyễn Gia Phong Date: Thu, 19 Dec 2024 13:36:42 +0900 Subject: Update E9Patch --- loftix/patching.scm | 6 ++--- patches/e9patch-check.patch | 36 +++++++++++++++++++++------ patches/e9patch-devendor.patch | 52 --------------------------------------- patches/e9patch-zydis-4.1.0.patch | 29 ++++++++++++++++++++++ 4 files changed, 61 insertions(+), 62 deletions(-) delete mode 100644 patches/e9patch-devendor.patch create mode 100644 patches/e9patch-zydis-4.1.0.patch diff --git a/loftix/patching.scm b/loftix/patching.scm index 26b25e2..71d30fa 100644 --- a/loftix/patching.scm +++ b/loftix/patching.scm @@ -30,7 +30,7 @@ #:use-module (guix packages)) (define-public e9patch - (let ((commit "840358a4aeeeb397fd10a34ae815b5bd33b73b19") + (let ((commit "a6d900b997942b124c2cdc9e164500052bbaec17") (revision "0")) (package (name "e9patch") @@ -42,11 +42,11 @@ (commit commit))) (sha256 (base32 - "04an37kny9aznizyy0l5djx1jvlgfn5k1z2kcva9bv3dz6ljhx99")) + "03gaf8scsmmfaxsmi5826ixnc5r7j6xaj0bq2fif633s82r7f7cg")) (file-name (git-file-name name version)) (patches (search-patches ;; https://github.com/GJDuck/e9patch/pull/94 - "patches/e9patch-devendor.patch" + "patches/e9patch-zydis-4.1.0.patch" ;; https://github.com/GJDuck/e9patch/pull/92 "patches/e9patch-check.patch" ;; https://github.com/GJDuck/e9patch/pull/95 diff --git a/patches/e9patch-check.patch b/patches/e9patch-check.patch index f149b78..f679db7 100644 --- a/patches/e9patch-check.patch +++ b/patches/e9patch-check.patch @@ -7,18 +7,40 @@ Date: 2024-11-18 14:06:32 +0900 The C++ script is rewritten in Makefile and shell script for concision. diff --git a/Makefile b/Makefile -index 1218c65d1818..6c786bb91a1d 100644 +index 754f5210b004..272e7bb4866f 100644 --- a/Makefile +++ b/Makefile -@@ -181,3 +181,8 @@ tool.sanitize: $(E9TOOL_OBJS) $(E9TOOL_LIBS) - $(CXX) $(CXXFLAGS) $(E9TOOL_OBJS) $(E9TOOL_LIBS) -o e9tool \ - $(E9TOOL_LDFLAGS) +@@ -1,4 +1,4 @@ +-.PHONY: all clean install dev release debug sanitize ++.PHONY: all clean install check dev release debug sanitize check-debug + .SECONDEXPANSION: -+check: e9tool + ######################################################################### +@@ -67,6 +67,7 @@ clean: + $(MAKE) -C contrib/zydis clean + rm -rf $(E9PATCH_OBJS) $(E9TOOL_OBJS) e9patch e9tool \ + src/e9patch/e9loader_*.c e9loader_*.o e9loader_*.bin ++ $(MAKE) -C test/regtest clean-check + + src/e9patch/e9loader_elf.c: src/e9patch/e9loader_elf.cpp + $(CXX) -std=c++11 -Wall -fno-stack-protector -Wno-unused-function -fPIC \ +@@ -83,6 +84,9 @@ src/e9patch/e9loader_pe.c: src/e9patch/e9loader_pe.cpp + src/e9patch/e9elf.o: src/e9patch/e9loader_elf.c + src/e9patch/e9pe.o: src/e9patch/e9loader_pe.c + ++check: all + $(MAKE) -C test/regtest + -+.PHONY: all clean install check\ -+ release debug sanitize tool tool.debug tool.sanitize + install: all + install -d "$(DESTDIR)$(PREFIX)/bin" + install -m 755 e9patch "$(DESTDIR)$(PREFIX)/bin/e9patch" +@@ -165,3 +169,6 @@ debug: dev + + sanitize: CXXFLAGS += -O0 -g -fsanitize=address + sanitize: dev ++ ++check-debug: debug ++ $(MAKE) -C test/regtest diff --git a/test/regtest/Makefile b/test/regtest/Makefile index 992b1bc40984..9b29e0f72408 100644 --- a/test/regtest/Makefile diff --git a/patches/e9patch-devendor.patch b/patches/e9patch-devendor.patch deleted file mode 100644 index e9ee292..0000000 --- a/patches/e9patch-devendor.patch +++ /dev/null @@ -1,52 +0,0 @@ -diff --git a/Makefile b/Makefile -index 1218c65d1818..0ebdf24ea259 100644 ---- a/Makefile -+++ b/Makefile -@@ -37,10 +37,7 @@ E9TOOL_OBJS=\ - E9TOOL_LIBS=\ - contrib/zydis/libZydis.a \ - contrib/libdw/libdw.a --E9TOOL_CXXFLAGS=\ -- -I src/e9tool/ -Wno-unused-function \ -- -I contrib/zydis/include/ \ -- -I contrib/zydis/dependencies/zycore/include/ -+E9TOOL_CXXFLAGS= -I src/e9tool/ -Wno-unused-function - E9TOOL_LDFLAGS=\ - -Wl,--dynamic-list=src/e9tool/e9tool.syms \ - -ldl -lz -@@ -52,9 +49,9 @@ E9TOOL_LDFLAGS=\ - all: e9tool e9patch - - e9tool: CXXFLAGS += -O2 -DSYSTEM_LIBDW $(E9TOOL_CXXFLAGS) --e9tool: contrib/zydis/libZydis.a $(E9TOOL_OBJS) -- $(CXX) $(CXXFLAGS) $(E9TOOL_OBJS) contrib/zydis/libZydis.a -o e9tool \ -- $(E9TOOL_LDFLAGS) -ldw -+e9tool: $(E9TOOL_OBJS) -+ $(CXX) $(CXXFLAGS) $(E9TOOL_OBJS) -o e9tool \ -+ $(E9TOOL_LDFLAGS) -ldw -lZydis - strip e9tool - - e9patch: CXXFLAGS += -O2 -diff --git a/src/e9tool/e9x86_64.cpp b/src/e9tool/e9x86_64.cpp -index 6a7f5cff3692..03eb3a41dd66 100644 ---- a/src/e9tool/e9x86_64.cpp -+++ b/src/e9tool/e9x86_64.cpp -@@ -152,8 +152,7 @@ void e9tool::getInstrInfo(const ELF *elf, const Instr *I, InstrInfo *info, - ZydisDecodedOperand operands[ZYDIS_MAX_OPERAND_COUNT]; - - ZyanStatus result = ZydisDecoderDecodeFull(&decoder, -- elf->data + I->offset, I->size, D, operands, ZYDIS_MAX_OPERAND_COUNT, -- 0); -+ elf->data + I->offset, I->size, D, operands); - if (!ZYAN_SUCCESS(result) || I->size != D->length || - D->operand_count > sizeof(info->op) / sizeof(info->op[0])) - error("failed to decompress instruction at address 0x%lx; decode " -@@ -336,7 +335,7 @@ void e9tool::getInstrInfo(const ELF *elf, const Instr *I, InstrInfo *info, - info->string.section = elf->strs + shdr->sh_name; - result = ZydisFormatterFormatInstruction(&formatter, D, operands, - D->operand_count_visible, info->string.instr, -- sizeof(info->string.instr)-1, I->address); -+ sizeof(info->string.instr)-1, I->address, ZYAN_NULL); - if (!ZYAN_SUCCESS(result)) - error("failed to decompress instruction at address 0x%lx; " - "formatting failed", I->address); diff --git a/patches/e9patch-zydis-4.1.0.patch b/patches/e9patch-zydis-4.1.0.patch new file mode 100644 index 0000000..9ce42d6 --- /dev/null +++ b/patches/e9patch-zydis-4.1.0.patch @@ -0,0 +1,29 @@ +commit c02dd23b12fd687a041ab3b872b3f989cd1342dc +Author: Nguyễn Gia Phong +Date: 2024-11-18 15:13:17 +0900 + + Make compatible with Zydis 4.1.0 + +diff --git a/src/e9tool/e9x86_64.cpp b/src/e9tool/e9x86_64.cpp +index 6a7f5cff3692..03eb3a41dd66 100644 +--- a/src/e9tool/e9x86_64.cpp ++++ b/src/e9tool/e9x86_64.cpp +@@ -152,8 +152,7 @@ void e9tool::getInstrInfo(const ELF *elf, const Instr *I, InstrInfo *info, + ZydisDecodedOperand operands[ZYDIS_MAX_OPERAND_COUNT]; + + ZyanStatus result = ZydisDecoderDecodeFull(&decoder, +- elf->data + I->offset, I->size, D, operands, ZYDIS_MAX_OPERAND_COUNT, +- 0); ++ elf->data + I->offset, I->size, D, operands); + if (!ZYAN_SUCCESS(result) || I->size != D->length || + D->operand_count > sizeof(info->op) / sizeof(info->op[0])) + error("failed to decompress instruction at address 0x%lx; decode " +@@ -336,7 +335,7 @@ void e9tool::getInstrInfo(const ELF *elf, const Instr *I, InstrInfo *info, + info->string.section = elf->strs + shdr->sh_name; + result = ZydisFormatterFormatInstruction(&formatter, D, operands, + D->operand_count_visible, info->string.instr, +- sizeof(info->string.instr)-1, I->address); ++ sizeof(info->string.instr)-1, I->address, ZYAN_NULL); + if (!ZYAN_SUCCESS(result)) + error("failed to decompress instruction at address 0x%lx; " + "formatting failed", I->address); -- cgit 1.4.1