From 207da3f47278cc9710b679baf931aea8bc8a7152 Mon Sep 17 00:00:00 2001 From: Simon Lindholm Date: Wed, 29 Jun 2022 00:28:09 +0200 Subject: [PATCH] "Better" LoadString stub, makefile --- .gitignore | 2 ++ Makefile | 26 ++++++++++++++++++++++++++ README.md | 2 +- user32.cpp | 3 ++- 4 files changed, 31 insertions(+), 2 deletions(-) create mode 100644 .gitignore create mode 100644 Makefile diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..cd884b0 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +wibo +build/ diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..e1b99fd --- /dev/null +++ b/Makefile @@ -0,0 +1,26 @@ +all: wibo + +CXXFLAGS = -Wall -g -m32 -std=c++20 -lstdc++ + +BUILD_DIR := build +CPP_FILES := $(wildcard *.cpp) +O_FILES := $(foreach file,$(CPP_FILES),$(BUILD_DIR)/$(file:.cpp=.o)) +DEP_FILES := $(O_FILES:.o=.d) + +$(BUILD_DIR): + mkdir -p $(BUILD_DIR) + +$(BUILD_DIR)/%.o: %.cpp | $(BUILD_DIR) + $(CXX) -c $(CXXFLAGS) $< -o $@ + +wibo: $(O_FILES) + $(CXX) $(CXXFLAGS) $^ -o $@ + +clean: + $(RM) -r $(BUILD_DIR) wibo + +.PHONY: all clean + +MAKEFLAGS += --no-builtin-rules + +-include $(DEP_FILES) diff --git a/README.md b/README.md index 55eba2c..79b9710 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ An experiment to try and write a minimal, low-fuss wrapper that can run really s Don't run this on any untrusted executables, I implore you. (Or probably just don't run it at all... :p) - g++ -g -m32 -std=c++20 -lstdc++ main.cpp version.cpp user32.cpp kernel32.cpp advapi32.cpp loader.cpp + make && ./wibo If you need something like this project (but more mature), you might find [taviso/loadlibrary](https://github.com/taviso/loadlibrary) more interesting. diff --git a/user32.cpp b/user32.cpp index e4877c8..4f1d95e 100644 --- a/user32.cpp +++ b/user32.cpp @@ -3,7 +3,8 @@ namespace user32 { int WIN_FUNC LoadStringA(void* hInstance, unsigned int uID, char* lpBuffer, int cchBufferMax) { printf("LoadStringA %p %d %d\n", hInstance, uID, cchBufferMax); - return 0; + strcpy(lpBuffer, "hello"); + return 5; } }