diff --git a/project/windll_winhook/Makefile b/project/windll_winhook/Makefile index fc7591d..8c8e6d2 100644 --- a/project/windll_winhook/Makefile +++ b/project/windll_winhook/Makefile @@ -1,15 +1,15 @@ # build example -# make libwinhook helloexe hellodll libwinhook_test CC=i686-w64-mingw32-gcc BUILD=32d -# make libwinhook helloexe hellodll libwinhook_test CC=x86_64-w64-mingw32-gcc BUILD=64d +# make libwinhook helloexe hellodll libwinhook_test CC=i686-w64-mingw32-gcc BUILD_TYPE=32d +# make libwinhook helloexe hellodll libwinhook_test CC=x86_64-w64-mingw32-gcc BUILD_TYPE=64d # wine build/libwinhook_test32d.exe && wine build/libwinhook_test64d.exe # general config CC:=gcc # clang (llvm-mingw), gcc (mingw-w64), tcc (x86 stdcall name has problem) -BUILD:=32# 32, 32d, 64, 64d +BUILD_TYPE:=32# 32, 32d, 64, 64d BUILD_DIR:=build INCS:=-I../../src LIBS:=-luser32 -lgdi32 -lpsapi -CFLAGS:=-fPIC -std=gnu99 \ +CFLAGS:=-fPIC -std=c99 \ -fvisibility=hidden \ -ffunction-sections -fdata-sections LDFLAGS:=-Wl,--enable-stdcall-fixup \ @@ -17,12 +17,12 @@ LDFLAGS:=-Wl,--enable-stdcall-fixup \ -Wl,--gc-sections # build config -ifneq (,$(findstring 64, $(BUILD))) +ifneq (,$(findstring 64, $(BUILD_TYPE))) CFLAGS+=-m64 else CFLAGS+=-m32 endif -ifneq (,$(findstring d, $(BUILD))) +ifneq (,$(findstring d, $(BUILD_TYPE))) CFLAGS+=-g -D_DEBUG else CFLAGS+=-Os @@ -44,28 +44,28 @@ prepare: libwinhook: src/libwinhook.c @echo "## $@" - $(CC) -shared $^ -o $(BUILD_DIR)/$@$(BUILD).dll \ + $(CC) -shared $^ -o $(BUILD_DIR)/$@$(BUILD_TYPE).dll \ $(INCS) $(LIBS) \ $(CFLAGS) $(LDFLAGS) libwinhook_test: src/libwinhook_test.c @echo "## $@" - $(CC) $< -o $(BUILD_DIR)/$@$(BUILD).exe \ - -L$(BUILD_DIR) -lwinhook$(BUILD) -DWINHOOK_NOINLINE \ + $(CC) $< -o $(BUILD_DIR)/$@$(BUILD_TYPE).exe \ + -L$(BUILD_DIR) -lwinhook$(BUILD_TYPE) -DWINHOOK_NOINLINE \ $(INCS) $(LIBS) \ $(CFLAGS) $(LDFLAGS) helloexe: src/helloexe.c @echo "## $@" @echo \#\#building $@ ... - $(CC) $< -o $(BUILD_DIR)/hello$(BUILD).exe \ + $(CC) $< -o $(BUILD_DIR)/hello$(BUILD_TYPE).exe \ $(CFLAGS) -lgdi32 -luser32 \ -Wl,-subsystem,windows -municode hellodll: src/hellodll.c @echo "## $@" @echo \#\#building $@ ... - $(CC) -shared $< -o $(BUILD_DIR)/hello$(BUILD).dll \ + $(CC) -shared $< -o $(BUILD_DIR)/hello$(BUILD_TYPE).dll \ $(CFLAGS) -luser32 .PHONY: all clean prepare libwinhook helloexe hellodll \ No newline at end of file diff --git a/project/windll_winpe/Makefile b/project/windll_winpe/Makefile index 51ed9e3..2cfbcc3 100644 --- a/project/windll_winpe/Makefile +++ b/project/windll_winpe/Makefile @@ -1,15 +1,15 @@ # build example -# make libwinpe libwinpe_test CC=i686-w64-mingw32-gcc BUILD=32d -# make libwinpe libwinpe_test CC=x86_64-w64-mingw32-gcc BUILD=64d +# make libwinpe libwinpe_test CC=i686-w64-mingw32-gcc BUILD_TYPE=32d +# make libwinpe libwinpe_test CC=x86_64-w64-mingw32-gcc BUILD_TYPE=64d # wine build/libwinpe_test32d.exe && wine build/libwinpe_test64d.exe # general config CC:=gcc # clang (llvm-mingw), gcc (mingw-w64), tcc (x86 stdcall name has problem) -BUILD:=32# 32, 32d, 64, 64d +BUILD_TYPE:=32# 32, 32d, 64, 64d BUILD_DIR:=build INCS:=-I../../src LIBS:=-luser32 -lgdi32 -lpsapi -CFLAGS:=-fPIC -std=c99 \ +CFLAGS:=-fPIC -std=gnu99 \ -fvisibility=hidden \ -ffunction-sections -fdata-sections LDFLAGS:=-Wl,--enable-stdcall-fixup \ @@ -17,12 +17,12 @@ LDFLAGS:=-Wl,--enable-stdcall-fixup \ -Wl,--gc-sections # build config -ifneq (,$(findstring 64, $(BUILD))) +ifneq (,$(findstring 64, $(BUILD_TYPE))) CFLAGS+=-m64 else CFLAGS+=-m32 endif -ifneq (,$(findstring d, $(BUILD))) +ifneq (,$(findstring d, $(BUILD_TYPE))) CFLAGS+=-g -D_DEBUG else CFLAGS+=-Os @@ -42,15 +42,15 @@ prepare: libwinpe: src/libwinpe.c @echo "## $@" - $(CC) -shared $^ -o $(BUILD_DIR)/$@$(BUILD).dll \ + $(CC) -shared $^ -o $(BUILD_DIR)/$@$(BUILD_TYPE).dll \ $(INCS) $(LIBS) \ $(CFLAGS) $(LDFLAGS) # can not use tcc here libwinpe_test: src/libwinpe_test.c @echo "## $@" - $(CC) $< -o $(BUILD_DIR)/$@$(BUILD).exe \ - -L$(BUILD_DIR) -lwinpe$(BUILD) -DWINPE_NOINLINE \ + $(CC) $< -o $(BUILD_DIR)/$@$(BUILD_TYPE).exe \ + -L$(BUILD_DIR) -lwinpe$(BUILD_TYPE) -DWINPE_NOINLINE \ $(INCS) $(LIBS) \ $(CFLAGS) $(LDFLAGS) diff --git a/project/winexe_winloader/Makefile b/project/winexe_winloader/Makefile index ba71d2b..648efb7 100644 --- a/project/winexe_winloader/Makefile +++ b/project/winexe_winloader/Makefile @@ -1,97 +1,54 @@ -# main config -LIBPREFIX?=./../../ -ARCH?=i686 -PREFIX?=./build - -CC:=clang -INCS:=-I$(LIBPREFIX)src -LIBDIRS:= +# build example +# make winloader CC=i686-w64-mingw32-gcc WINDRES=i686-w64-mingw32-windres BUILD_TYPE=32d +# make winloader CC=x86_64-w64-mingw32-gcc WINDRES=x86_64-w64-mingw32-windres BUILD_TYPE=64d + +# general config +CC:=gcc # clang (llvm-mingw), gcc (mingw-w64), tcc (x86 stdcall name has problem) +WINDRES:=windres +BUILD_TYPE:=32# 32, 32d, 64, 64d +BUILD_DIR:=build +INCS:=-I../../src LIBS:=-luser32 -lgdi32 -lpsapi -CFLAGS:=-ffunction-sections\ - -fdata-sections -std=c99 -LDFLAGS:= - -# arch config -ifeq ($(ARCH), x86_64) -ARCH_POSTFIX:=64 -LIBDIRS+=-L$(LIBPREFIX)lib64 -CFLAGS+=-D_WIN64 -ifdef DEBUG -BUILD_POSTFIX:=64d -else -BUILD_POSTFIX:=64 -endif -else # x86 -ARCH_POSTFIX:=32 -LIBDIRS+=-L$(LIBPREFIX)lib32 -ifdef DEBUG -BUILD_POSTFIX:=32d +CFLAGS:=-fPIC -std=c99 \ + -fvisibility=hidden \ + -ffunction-sections -fdata-sections +LDFLAGS:=-Wl,--enable-stdcall-fixup \ + -Wl,--kill-at \ + -Wl,--gc-sections + +# build config +ifneq (,$(findstring 64, $(BUILD_TYPE))) +CFLAGS+=-m64 +ARCH_WINDRES=pe-x86-64 else -BUILD_POSTFIX:=32 -endif -endif - -# compiler config -ifneq (,$(findstring clang, $(CC))) -CFLAGS+=-target $(ARCH)-pc-windows-msvc \ - -D_CRT_SECURE_NO_DEPRECATE -LDFLAGS+= -Wl,/OPT:REF\ - -Wno-undefined-inline -else # mingw -CFLAGS+=-m$(ARCH_POSTFIX) \ - -fPIC\ - -fvisibility=hidden\ - -fgnu89-inline\ - -DWINPE_NOASM -ifneq (,$(findstring gcc, $(CC))) -LDFLAGS+=-lwinpthread \ - -static-libgcc \ - -static-libstdc++ \ - -Wl,-Bstatic,--whole-archive \ - -Wl,--no-whole-archive\ - -Wl,--gc-sections\ - -Wl,--enable-stdcall-fixup\ - -Wl,--kill-at -endif +CFLAGS+=-m32 +ARCH_WINDRES=pe-i386 endif - -# optimization config -ifdef DEBUG +ifneq (,$(findstring d, $(BUILD_TYPE))) CFLAGS+=-g -D_DEBUG else CFLAGS+=-Os -endif -LIBDIRS+=-L$(PREFIX) - -# system config -ifeq ($(shell echo ${OS}), Windows_NT) -DLL_EXT=.dll -EXE_EXT=.exe -else -DLL_EXT?=.so -EXE_EXT?= endif - -# other config -ifneq (,$(findstring clang, $(CC))) +ifneq (,$(findstring tcc, $(CC))) +LDFLAGS= # tcc can not remove at at stdcall in i686 else -ifneq (,$(findstring gcc, $(CC))) -endif endif -all: prepare\ - winloader +all: prepare winloader clean: - rm -rf $(PREFIX)/*winloader* + @rm -rf $(BUILD_DIR)/*winloader* prepare: - @if ! [ -d $(PREFIX) ]; then mkdir -p $(PREFIX); fi + @if ! [ -d $(BUILD_DIR) ]; then mkdir -p $(BUILD_DIR); fi + +$(BUILD_DIR)/winloader$(BUILD_TYPE).res: src/winloader.rc + $(WINDRES) $< -F $(ARCH_WINDRES) -O coff -o $@ -winloader: src\winloader.c - @echo \#\#building $@ ... - $(CC) $< \ - -o $(PREFIX)/$@$(BUILD_POSTFIX)$(EXE_EXT) \ - $(CFLAGS) $(LDFLAGS) $(INCS) $(LIBS) $(LIBDIRS) +winloader: src/winloader.c $(BUILD_DIR)/winloader$(BUILD_TYPE).res + @echo "## $@" + $(CC) $^ -o $(BUILD_DIR)/$@$(BUILD_TYPE).exe \ + $(INCS) $(LIBS) \ + $(CFLAGS) $(LDFLAGS) .PHONY: all clean prepare winloader \ No newline at end of file diff --git a/project/winexe_winloader/src/resource.h b/project/winexe_winloader/src/resource.h index b6511e9..5ac77fd 100644 Binary files a/project/winexe_winloader/src/resource.h and b/project/winexe_winloader/src/resource.h differ diff --git a/project/winexe_winloader/src/winloader.aps b/project/winexe_winloader/src/winloader.aps deleted file mode 100644 index 83fd7e6..0000000 Binary files a/project/winexe_winloader/src/winloader.aps and /dev/null differ diff --git a/project/winexe_winloader/src/winloader.c b/project/winexe_winloader/src/winloader.c index 4a50132..ba4e580 100644 --- a/project/winexe_winloader/src/winloader.c +++ b/project/winexe_winloader/src/winloader.c @@ -1,6 +1,6 @@ #include #define WINHOOK_IMPLEMENTATION -#define WINHOOK_NOINLINEHOOK +#define WINHOOK_NO3RDLIB #include "winhook.h" #ifndef _DEBUG diff --git a/project/winexe_winloader/src/winloader.rc b/project/winexe_winloader/src/winloader.rc index c100ee6..61e3c26 100644 Binary files a/project/winexe_winloader/src/winloader.rc and b/project/winexe_winloader/src/winloader.rc differ