Skip to content

Sharpiro/tiny-wine

Repository files navigation

Tiny Wine

A simple and educational dynamic loader for Windows that runs on Linux

Limitations

  • Only works for toy programs created with MinGW and specific Clang versions in this repository
  • x64 only
  • No recursive dependencies
  • malloc leaks memory
  • Loaders use a lot of memory
  • Import Address Table limit is 512 entries
  • Windows header size limit is 4 KiB
  • No environment variables
  • No AVX
  • No Printing floats
  • Dlls must be in current working directory
  • ntdll.dll doesn't adhere to real Windows API
  • Calling into libntdll.so only supports at most 8 parameters

Prerequisites

All examples use Docker for compatibility, but should work on Linux machines with the necessary packages. See Dockerfile for necessary packages.

git clone https://github.com/Sharpiro/tiny-wine.git
cd tiny-wine
docker build -t tinywine $PWD

Building

docker run --rm -v $PWD:/home/tiny_wine tinywine make

Running Linux loader

docker run --rm -v $PWD:/home/tiny_wine -w /home/tiny_wine/build tinywine ./linloader ./tinyfetch

Example Output

tiny_wine@54510a2c9be4
--------------
OS: Ubuntu 22.04.5 LTS x86_64
Kernel: 6.11.9-100.fc39.x86_64
Uptime: 46 days, 18 hours, 52 minutes
Shell: /bin/sh

Running Windows loader

docker run --rm -v $PWD:/home/tiny_wine -w /home/tiny_wine/build tinywine ./winloader ./windynamic.exe

Tests

docker run --rm -v $PWD:/home/tiny_wine tinywine ./test.sh 1

Tools

Miscellaneous tools that assist with debugging dynamic loaders.

Readlin

Tool for reading the Linux ELF format. Shows more detail on things like GOT entries.

docker run --rm -v $PWD:/home/tiny_wine -w /home/tiny_wine/build tinywine ./readlin ./dynamic

Readwin

Tool for reading the Windows PE format.

docker run --rm -v $PWD:/home/tiny_wine -w /home/tiny_wine/build tinywine ./readwin ./windynamic.exe

Bonus

Read readwin.exe using readwin.exe using winloader

docker run --rm -v $PWD:/home/tiny_wine -w /home/tiny_wine/build tinywine ./winloader ./readwin.exe ./readwin.exe

Contributing

This repo is currently experimental and thus not taking contributions at this time.

About

A project to help understand how linkers and Wine work.

Resources

License

Stars

Watchers

Forks

Packages

No packages published