"Better" LoadString stub, makefile

This commit is contained in:
Simon Lindholm 2022-06-29 00:28:09 +02:00
parent 3fd1f6a30c
commit 207da3f472
4 changed files with 31 additions and 2 deletions

2
.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
wibo
build/

26
Makefile Normal file
View File

@ -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)

View File

@ -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) 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. If you need something like this project (but more mature), you might find [taviso/loadlibrary](https://github.com/taviso/loadlibrary) more interesting.

View File

@ -3,7 +3,8 @@
namespace user32 { namespace user32 {
int WIN_FUNC LoadStringA(void* hInstance, unsigned int uID, char* lpBuffer, int cchBufferMax) { int WIN_FUNC LoadStringA(void* hInstance, unsigned int uID, char* lpBuffer, int cchBufferMax) {
printf("LoadStringA %p %d %d\n", hInstance, uID, cchBufferMax); printf("LoadStringA %p %d %d\n", hInstance, uID, cchBufferMax);
return 0; strcpy(lpBuffer, "hello");
return 5;
} }
} }