Skip to content

chore(repo): reorganize directories + rewrite AGENTS.md/README.md #7

chore(repo): reorganize directories + rewrite AGENTS.md/README.md

chore(repo): reorganize directories + rewrite AGENTS.md/README.md #7

Workflow file for this run

# Component A (MSVC native) — builds the mixed DLL on a Windows runner.
#
# Mirrors the MinGW path with the MSVC toolchain: the Rust staticlib targets
# x86_64-pc-windows-msvc, and the C shell/MinHook are compiled with cl.exe and
# linked with the staticlib + the MSVC C runtime. (Cannot run MSVC on the Linux
# dev box; this workflow is the authoritative MSVC validation.)
name: msvc-build
on:
push:
branches: [main, spike/001-component-a]
pull_request:
branches: [main, spike/001-component-a]
workflow_dispatch:
jobs:
msvc:
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
- name: Install Rust toolchain (rustup, MSVC)
uses: dtolnay/rust-toolchain@stable
with:
targets: x86_64-pc-windows-msvc
- name: Cache cargo registry
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: msvc-${{ runner.os }}-${{ hashFiles('Cargo.lock') }}
- name: Lint with clippy (deny warnings)
run: cargo clippy --all-targets --features test-hooks -- -D warnings
- name: Build Rust staticlib (x86_64-pc-windows-msvc)
run: cargo build --release -p magos-discovery --target x86_64-pc-windows-msvc
- name: Set up MSVC dev environment
uses: ilammy/msvc-dev-cmd@v1
- name: Build mixed DLL + launcher (cl/link)
shell: cmd
run: |
set REL=target\x86_64-pc-windows-msvc\release
:: Compile the C shell + MinHook to objects.
cl /nologo /O2 /c /I runtime\shell\include /I runtime\shell\vendor\minhook\include ^
runtime\shell\src\dllmain.c ^
runtime\shell\vendor\minhook\src\buffer.c ^
runtime\shell\vendor\minhook\src\hook.c ^
runtime\shell\vendor\minhook\src\trampoline.c ^
runtime\shell\vendor\minhook\src\hde\hde64.c
:: Link the DLL against the Rust staticlib + system libs.
link /nologo /DLL /OUT:magos_shell.dll ^
dllmain.obj buffer.obj hook.obj trampoline.obj hde64.obj ^
%REL%\magos_discovery.lib ^
psapi.lib kernel32.lib user32.lib ws2_32.lib userenv.lib bcrypt.lib ntdll.lib ^
/NODEFAULTLIB:libgcc.lib
:: Launcher.
cl /nologo /O2 /Fe:magos_launcher.exe runtime\launcher\src\launcher.c /link kernel32.lib
- name: Build C tests (cl/link)
shell: cmd
run: |
set REL=target\x86_64-pc-windows-msvc\release
:: Test runner object.
cl /nologo /O2 /c runtime\tests\test_runner.c
:: Launcher object for test linking — compiled with MAGOS_TEST_BUILD so
:: launcher.c's main() is excluded (each test exe provides its own main).
:: Mirrors the Makefile's runtime/tests/launcher.o rule. The production
:: magos_launcher.exe (built above) is compiled WITHOUT the guard.
cl /nologo /O2 /I runtime\launcher\src /DMAGOS_TEST_BUILD /c runtime\launcher\src\launcher.c /Fo:launcher_test.obj
:: Stub target — minimal GUI exe (/SUBSYSTEM:WINDOWS is a linker flag,
:: so it goes after /link, not on the cl compile line).
cl /nologo /O2 /Fe:runtime\tests\stub_target.exe runtime\tests\stub_target.c /link /SUBSYSTEM:WINDOWS
:: Stub shell — minimal DLL.
cl /nologo /O2 /c runtime\tests\stub_shell.c
link /nologo /DLL /OUT:runtime\tests\stub_shell.dll stub_shell.obj kernel32.lib
:: test_steam_env.exe — links the guarded launcher_test.obj (no main).
cl /nologo /O2 /I runtime\launcher\src /Fe:runtime\tests\test_steam_env.exe ^
runtime\tests\test_steam_env.c test_runner.obj launcher_test.obj kernel32.lib
:: test_injection.exe — links the guarded launcher_test.obj (no main).
cl /nologo /O2 /I runtime\launcher\src /Fe:runtime\tests\test_injection.exe ^
runtime\tests\test_injection.c test_runner.obj launcher_test.obj kernel32.lib
- name: Run C unit tests (native)
shell: cmd
run: |
echo === C unit tests ===
runtime\tests\test_steam_env.exe
runtime\tests\test_injection.exe
- name: Verify valid PE with DllMain
shell: pwsh
run: |
$pe = [System.IO.BinaryReader]::new([System.IO.File]::OpenRead("magos_shell.dll"))
$mz = $pe.ReadBytes(2); if (($mz[0] -ne 0x4D) -or ($mz[1] -ne 0x5A)) { throw "not MZ" }
Write-Host "magos_shell.dll is a valid PE (MZ header)"
$pe.Close()
& dumpbin /exports magos_shell.dll | Select-String "DllMain|magos_discover"
if ($LASTEXITCODE -ne 0) { throw "dumpbin failed" }
- name: Run host-side discovery tests (cargo test)
env:
MAGOS_CI: "1"
run: cargo test --features test-hooks -p magos-discovery
- name: Upload PE artifacts
uses: actions/upload-artifact@v4
with:
name: magos-shell-msvc
path: |
magos_shell.dll
magos_launcher.exe