diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..4be9fc5 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,23 @@ +name: CI +on: [push, pull_request] +jobs: + build_and_test: + name: Build and test + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + + - name: Install GCC multilib + run: | + sudo apt-get update + sudo apt-get install -y gcc-multilib g++-multilib + + - name: Build + run: make -j + + - name: Test + run: | + wget https://cdn.discordapp.com/attachments/727918646525165659/917185027656286218/GC_WII_COMPILERS.zip + unzip GC_WII_COMPILERS.zip + MWCIncludes=. ./wibo GC/2.7/mwcceppc.exe -c test/test.c + file test.o diff --git a/.gitignore b/.gitignore index cd884b0..db166ac 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,5 @@ wibo build/ +*.o + +.vscode/ diff --git a/Makefile b/Makefile index 9cbf0eb..dc25bb9 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ all: wibo -CXXFLAGS = -Wall -g -m32 -std=c++20 -lstdc++ -MD +CXXFLAGS = -Wall -g -m32 -std=c++2a -lstdc++ -MD BUILD_DIR := build CPP_FILES := $(wildcard *.cpp) diff --git a/README.md b/README.md index 79b9710..c4b38a1 100644 --- a/README.md +++ b/README.md @@ -1,20 +1,22 @@ # WiBo -An experiment to try and write a minimal, low-fuss wrapper that can run really simple command-line 32-bit Windows binaries on Linux - with less faff and less dependencies than WINE. +A minimal, low-fuss wrapper that can run really simple command-line 32-bit Windows binaries on Linux - with less faff and less dependencies than WINE. Don't run this on any untrusted executables, I implore you. (Or probably just don't run it at all... :p) make && ./wibo -If you need something like this project (but more mature), you might find [taviso/loadlibrary](https://github.com/taviso/loadlibrary) more interesting. - --- Rough to-do list: - Implement more APIs - Do something intelligent with Windows `HANDLE`s -- Pass the command line properly - Convert paths in environment variables (and the structure of `PATH` itself, maybe) to Windows format - Implement PE relocations rather than just failing unceremoniously - Make the PE loader work for DLLs as well in case we ever want to load some + +--- + +Related projects: +* [taviso/loadlibrary](https://github.com/taviso/loadlibrary) \ No newline at end of file diff --git a/main.cpp b/main.cpp index d6f74f0..6b6528a 100644 --- a/main.cpp +++ b/main.cpp @@ -1,5 +1,6 @@ #include "common.h" #include +#include #include #include #include @@ -176,7 +177,14 @@ int main(int argc, char **argv) { wibo::Executable exec; wibo::mainModule = &exec; - FILE *f = fopen(argv[1], "rb"); + char* pe_path = argv[1]; + FILE *f = fopen(pe_path, "rb"); + if (!f) { + std::string mesg = std::string("Failed to open file ") + pe_path; + perror(mesg.c_str()); + return 1; + } + exec.loadPE(f); fclose(f); diff --git a/test/test.c b/test/test.c new file mode 100644 index 0000000..8cdc6ed --- /dev/null +++ b/test/test.c @@ -0,0 +1,6 @@ +float apple = 3.0f; +float banana = 65.32f; + +int something(void) { + return (int)(apple * banana) % 11; +}