From 554b2b1eee4d4fdbb00c25f7a414a71ff8b3ace8 Mon Sep 17 00:00:00 2001 From: devseed Date: Wed, 16 Oct 2024 17:03:22 +0900 Subject: [PATCH] make libwinpe_test compatible with tcc --- project/windll_winpe/Makefile | 2 +- project/windll_winpe/src/libwinpe_test.c | 5 ++--- src/commdef.h | 8 ++++---- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/project/windll_winpe/Makefile b/project/windll_winpe/Makefile index 43c0664..717e50b 100644 --- a/project/windll_winpe/Makefile +++ b/project/windll_winpe/Makefile @@ -28,7 +28,7 @@ endif ifneq (,$(findstring d, $(BUILD_TYPE))) CFLAGS+=-g -D_DEBUG else -CFLAGS+=-O3 +CFLAGS+=-O3 # winpe_memGetProcAddress might fail if use inline and -O3 by llvm-clang endif ifneq (,$(findstring tcc, $(CC))) LDFLAGS= # tcc can not remove at at stdcall in i686 diff --git a/project/windll_winpe/src/libwinpe_test.c b/project/windll_winpe/src/libwinpe_test.c index 55241d9..efef747 100644 --- a/project/windll_winpe/src/libwinpe_test.c +++ b/project/windll_winpe/src/libwinpe_test.c @@ -15,8 +15,7 @@ void test_findkernel32() void test_findloadlibrarya() { - - void *func = (void*)LoadLibraryA; + void *func = (void*)GetProcAddress(GetModuleHandleA("kernel32.dll"), "LoadLibraryA"); // compatible with tcc void *func2 = winpe_findloadlibrarya(); printf("[test_findloadlibrarya] LoadLibraryA=%p\n", func2); assert(func==func2); @@ -24,7 +23,7 @@ void test_findloadlibrarya() void test_findgetprocaddress() { - void *func = (void*)GetProcAddress; + void *func = (void*)GetProcAddress(GetModuleHandleA("kernel32.dll"), "GetProcAddress"); // compatible with tcc void *func2 = winpe_findgetprocaddress(); printf("[test_findgetprocaddress] GetProcAddress=%p\n", func2); assert(func==func2); diff --git a/src/commdef.h b/src/commdef.h index 33826db..605092c 100644 --- a/src/commdef.h +++ b/src/commdef.h @@ -67,12 +67,12 @@ #define LOG_LEVEL_INFO 3 #define LOG_LEVEL_DEBUG 4 #define LOG_LEVEL_VERBOSE 5 -#define LogTagPrintf(format, tag, ...) \ +#define LogTagPrintf(format, tag, ...) {\ printf("[%s,%d,%s,%s] ", __FILE__, __LINE__, __func__, tag);\ - printf(format, ##__VA_ARGS__); -#define LogTagWprintf(format, tag, ...) \ + printf(format, ##__VA_ARGS__);} +#define LogTagWprintf(format, tag, ...) {\ printf("[%s,%d,%s,%s] ", __FILE__, __LINE__, __func__, tag);\ - wprintf(format, ##__VA_ARGS__); + wprintf(format, ##__VA_ARGS__);} #define DummyPrintf(format, ...) #define LOG(format, ...) LogTagPrintf(format, "I", ##__VA_ARGS__) #define LOGL(format, ...) LogTagWprintf(format, "I", ##__VA_ARGS__)