Build legacy drivers and publish per-OS packages with web activation and DEB
This commit is contained in:
23
cross/build-diag.sh
Executable file
23
cross/build-diag.sh
Executable file
@@ -0,0 +1,23 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
cd "$(dirname "$0")/.."
|
||||
for t in clang lld-link llvm-ar python3 objdump; do command -v "$t" >/dev/null || { echo "Missing $t" >&2; exit 1; }; done
|
||||
mkdir -p build/cross/diag
|
||||
rm -f build/cross/diag/IPXDIAG.EXE
|
||||
out=$PWD/build/cross/diag
|
||||
# COFF short import records, IMPORT_NAME_UNDECORATE strips x86 stdcall decoration.
|
||||
python3 - "$out" <<'PY'
|
||||
import pathlib,struct,sys
|
||||
p=pathlib.Path(sys.argv[1]);
|
||||
for dll, exports in {'KERNEL32.dll':{'ExitProcess':4,'GetStdHandle':4,'WriteFile':20},'WSOCK32.dll':{'WSAStartup':8,'WSACleanup':0,'WSAGetLastError':0,'socket':12,'closesocket':4,'getsockopt':20,'bind':12,'getsockname':12}}.items():
|
||||
for name, n in exports.items():
|
||||
data=f'_{name}@{n}\0{dll}\0'.encode('ascii')
|
||||
(p/(name+'.imp.obj')).write_bytes(struct.pack('<HHHHIIHH',0,0xffff,0,0x14c,0,len(data),0,3<<2)+data)
|
||||
PY
|
||||
rm -f "$out/imports.lib"
|
||||
llvm-ar rcs "$out/imports.lib" "$out"/*.imp.obj
|
||||
clang --target=i686-pc-windows-msvc -march=i386 -mno-sse -mno-sse2 -ffreestanding -fno-builtin -fno-stack-protector -Os -Wall -Wextra -c clients/windows/diag/ipxdiag.c -o "$out/ipxdiag.obj"
|
||||
lld-link /entry:start /subsystem:console,4.0 /osversion:4.0 /nodefaultlib /machine:x86 /safeseh:no /dynamicbase:no /nxcompat:no /timestamp:0 /out:"$out/IPXDIAG.EXE" "$out/ipxdiag.obj" "$out/imports.lib"
|
||||
objdump -p "$out/IPXDIAG.EXE" > "$out/imports.txt"
|
||||
python3 cross/verify-pe.py "$out/IPXDIAG.EXE" exe
|
||||
printf 'Diagnostic built: %s\n' "$out/IPXDIAG.EXE"
|
||||
22
cross/build-legacy-bridge.sh
Executable file
22
cross/build-legacy-bridge.sh
Executable file
@@ -0,0 +1,22 @@
|
||||
#!/usr/bin/env bash
|
||||
# CRT-free x86 executable. No historical Microsoft headers required for usermode.
|
||||
set -euo pipefail
|
||||
cd "$(dirname "$0")/.."
|
||||
for t in clang lld-link llvm-ar python3 objdump; do command -v "$t" >/dev/null; done
|
||||
out=$PWD/build/cross/legacy-bridge; mkdir -p "$out"; rm -f "$out"/{MARSNET.EXE,imports.lib}
|
||||
python3 - "$out" <<'PY'
|
||||
import pathlib,struct,sys
|
||||
p=pathlib.Path(sys.argv[1]);
|
||||
exports={'KERNEL32.dll':{'ExitProcess':4,'GetStdHandle':4,'WriteFile':20,'GetCommandLineA':0,'GetFullPathNameA':16,'GetPrivateProfileStringA':24,'GetSystemDirectoryA':8,'LoadLibraryA':4,'GetProcAddress':8,'FreeLibrary':4,'GetTickCount':0,'Sleep':4,'SetConsoleCtrlHandler':8,'CreateMutexA':12,'CloseHandle':4,'GetLastError':0},'WSOCK32.dll':{'WSAStartup':8,'WSACleanup':0,'WSAGetLastError':0,'socket':12,'closesocket':4,'setsockopt':20,'bind':12,'getsockname':12,'ioctlsocket':12,'sendto':24,'recvfrom':24}}
|
||||
for dll, funcs in exports.items():
|
||||
for name,n in funcs.items():
|
||||
data=f'_{name}@{n}\0{dll}\0'.encode('ascii');(p/(name+'.imp.obj')).write_bytes(struct.pack('<HHHHIIHH',0,0xffff,0,0x14c,0,len(data),0,3<<2)+data)
|
||||
PY
|
||||
llvm-ar rcs "$out/imports.lib" "$out"/*.imp.obj
|
||||
for f in src/ipxpkt.c clients/windows/client_core.c clients/windows/ndis3/legacy_bridge.c; do
|
||||
clang --target=i686-pc-windows-msvc -march=i386 -mno-sse -mno-sse2 -ffreestanding -fno-builtin -fno-stack-protector -Os -Wall -Wextra -Iclients/windows/ndis3/freestanding -Isrc -c "$f" -o "$out/$(basename "$f" .c).obj"
|
||||
done
|
||||
lld-link /entry:start /subsystem:console,4.0 /osversion:4.0 /nodefaultlib /machine:x86 /safeseh:no /dynamicbase:no /nxcompat:no /timestamp:0 /out:"$out/MARSNET.EXE" "$out/legacy_bridge.obj" "$out/client_core.obj" "$out/ipxpkt.obj" "$out/imports.lib"
|
||||
python3 cross/verify-pe.py "$out/MARSNET.EXE" exe
|
||||
objdump -p "$out/MARSNET.EXE" > "$out/MARSNET.imports.txt"
|
||||
echo 'CRT-free MARSNET.EXE built; still requires an NDIS3 miniport and WinPcap 3.1 at runtime.'
|
||||
24
cross/build-legacy.sh
Executable file
24
cross/build-legacy.sh
Executable file
@@ -0,0 +1,24 @@
|
||||
#!/usr/bin/env bash
|
||||
# NDIS 3 binary candidate using historical NT4 x86 DDK, not modern NDIS block layout.
|
||||
set -euo pipefail
|
||||
cd "$(dirname "$0")/.."
|
||||
out=$PWD/build/cross/legacy; mkdir -p "$out"; rm -f "$out"/{MARSNET3.SYS,MARSNET.EXE,MARSNET.INF}
|
||||
dump=${MINGW_OBJDUMP:-objdump}
|
||||
for t in "$dump" clang-cl lld-link python3; do command -v "$t" >/dev/null || { echo "Missing $t" >&2; exit 1; }; done
|
||||
cache=${MARS_TOOLCHAIN_DIR:-$PWD/.toolchains}; root=$cache/legacy/nt4-extracted
|
||||
if [[ -z ${NT4_DDK_INCLUDE:-} || -z ${NT4_NDIS_LIB:-} ]]; then [[ -f $root/READY ]] || ./cross/extract-nt4.sh; fi
|
||||
rm -rf "$out/include"; lib=$(python3 cross/prepare-nt4.py "$root" "$out/include")
|
||||
# Build without modern NTOSKRNL or CRT import libraries. Win9x NDIS loader only
|
||||
# supports a subset of NT imports; structural checks don't prove loader compatibility.
|
||||
for f in clients/windows/ndis3/miniport.c clients/windows/ndis3/legacy_core.c clients/windows/ndis5/frame_queue.c; do
|
||||
clang-cl --target=i686-pc-windows-msvc /nologo /c /TC /Gz /GS- /Zl /O1 /Oi- /clang:-ffreestanding /clang:-fno-builtin /D_X86_=1 /Di386=1 /DNDIS_MINIPORT_DRIVER /DNDIS30_MINIPORT /DMARS_LEGACY_KERNEL /I"$out/include" /imsvc/usr/i686-w64-mingw32/include /Fo"$out/$(basename "$f" .c).obj" "$f"
|
||||
done
|
||||
lld-link /nologo /driver /subsystem:native,4.0 /osversion:4.0 /entry:DriverEntry@8 /nodefaultlib /machine:x86 /base:0x10000 /dynamicbase:no /nxcompat:no /safeseh:no /out:"$out/MARSNET3.SYS" "$out/miniport.obj" "$out/legacy_core.obj" "$out/frame_queue.obj" "$lib"
|
||||
python3 cross/verify-pe.py "$out/MARSNET3.SYS" sys
|
||||
"$dump" -p "$out/MARSNET3.SYS" > "$out/MARSNET3.imports.txt"
|
||||
# Refuse unexpected DLL imports; older loaders cannot resolve newer kernel APIs.
|
||||
if grep 'DLL Name:' "$out/MARSNET3.imports.txt" | grep -Eiv 'DLL Name:[[:space:]]+ndis\.sys[[:space:]]*$'; then echo 'Unexpected legacy kernel import' >&2; exit 1; fi
|
||||
./cross/build-legacy-bridge.sh
|
||||
cp build/cross/legacy-bridge/{MARSNET.EXE,MARSNET.imports.txt} "$out/"
|
||||
cp clients/windows/ndis3/MARSNET.INF "$out/"
|
||||
echo 'NDIS3 build candidate. Requires OS-specific Packet.dll/driver and VM validation. NT4 OEMSETUP not included.'
|
||||
30
cross/build-nt5.sh
Executable file
30
cross/build-nt5.sh
Executable file
@@ -0,0 +1,30 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
cd "$(dirname "$0")/.."
|
||||
cc=${MINGW_CC:-i686-w64-mingw32-gcc}; cxx=${MINGW_CXX:-i686-w64-mingw32-g++}; dump=${MINGW_OBJDUMP:-i686-w64-mingw32-objdump}
|
||||
for t in "$cc" "$cxx" "$dump" python3; do command -v "$t" >/dev/null || { echo "Missing $t; run cross/install-tools.sh --apt-only" >&2; exit 1; }; done
|
||||
out=$PWD/build/cross/nt5; mkdir -p "$out"; rm -f "$out"/{MARSIPX.EXE,MARSTAP.EXE,MARSNDIS.SYS,MARSNDIS.INF}
|
||||
common=(-O2 -march=i386 -mno-sse -mno-sse2 -D_WIN32_WINNT=0x0500 -DWINVER=0x0500 -D_USE_32BIT_TIME_T -Isrc -Iclients/windows)
|
||||
"$cc" "${common[@]}" -c src/ipxpkt.c -o "$out/ipxpkt.o"
|
||||
"$cc" "${common[@]}" -c clients/windows/client_core.c -o "$out/client_core.o"
|
||||
for backend in NATIVE TAP; do
|
||||
name=MARSIPX; [[ $backend != TAP ]] || name=MARSTAP
|
||||
"$cxx" "${common[@]}" -DMARS_$backend -fno-exceptions -fno-rtti -c clients/windows/marsnet.cpp -o "$out/$name.o"
|
||||
"$cxx" -static -static-libgcc -static-libstdc++ -Wl,--subsystem,console:5.0,--major-os-version,5,--minor-os-version,0,--disable-dynamicbase,--disable-nxcompat -o "$out/$name.EXE" "$out/$name.o" "$out/ipxpkt.o" "$out/client_core.o" -lwsock32 -ladvapi32
|
||||
python3 cross/verify-pe.py "$out/$name.EXE" exe
|
||||
"$dump" -p "$out/$name.EXE" > "$out/$name.imports.txt"
|
||||
done
|
||||
# The free MinGW-w64 DDK headers and import libraries are included in the Debian dev package.
|
||||
ddk=${MINGW_DDK_INCLUDE:-/usr/i686-w64-mingw32/include/ddk}
|
||||
[[ -f $ddk/ndis.h && -f $ddk/ntddk.h ]] || { echo "Missing DDK headers in $ddk" >&2; exit 1; }
|
||||
# Work around known defects in the packaged MinGW DDK in a local copy.
|
||||
compat="$out/ddk"; mkdir -p "$compat"
|
||||
python3 cross/prepare-mingw-ddk.py "$ddk" "$compat"
|
||||
ddk=$compat
|
||||
kflags=(-O2 -march=i386 -mno-sse -mno-sse2 -ffreestanding -fno-builtin -fno-stack-protector -fno-asynchronous-unwind-tables -D_X86_=1 -Di386=1 -DNDIS_MINIPORT_DRIVER -DNDIS50_MINIPORT -DMARS_KERNEL -D_WIN32_WINNT=0x0500 -DNTDDI_VERSION=0x05000000 -I"$ddk" -Werror=incompatible-pointer-types)
|
||||
for f in miniport frame_queue; do "$cc" "${kflags[@]}" -c "clients/windows/ndis5/$f.c" -o "$out/$f.o"; done
|
||||
"$cc" -nostdlib -Wl,--entry,_DriverEntry@8,--subsystem,native:5.0,--major-os-version,5,--minor-os-version,0,--image-base,0x10000,--disable-dynamicbase,--disable-nxcompat,--disable-stdcall-fixup -o "$out/MARSNDIS.SYS" "$out/miniport.o" "$out/frame_queue.o" -lndis -lntoskrnl -lhal -lgcc
|
||||
python3 cross/verify-pe.py "$out/MARSNDIS.SYS" sys
|
||||
"$dump" -p "$out/MARSNDIS.SYS" > "$out/MARSNDIS.imports.txt"
|
||||
cp clients/windows/ndis5/MARSNDIS.INF "$out/"
|
||||
echo 'NT5 candidate built. Unsigned; imports and Windows VM tests still required.'
|
||||
59
cross/build-windows.sh
Executable file
59
cross/build-windows.sh
Executable file
@@ -0,0 +1,59 @@
|
||||
#!/usr/bin/env bash
|
||||
# Build what is available and write explicit per-platform status. No driver installation.
|
||||
set -euo pipefail
|
||||
cd "$(dirname "$0")/.."
|
||||
mode=${1:-all}; case $mode in all|WIN95|WIN98|WINME|WINNT40|WIN2000|WINXP) ;; *) echo 'Usage: cross/build-windows.sh [all|WIN95|WIN98|WINME|WINNT40|WIN2000|WINXP]' >&2; exit 2;; esac
|
||||
mkdir -p build/cross
|
||||
report=$PWD/build/cross/STATUS.txt
|
||||
: > "$report"
|
||||
log(){ printf '%s\n' "$*" | tee -a "$report"; }
|
||||
rc=0
|
||||
oses=(WIN95 WIN98 WINME WINNT40 WIN2000 WINXP); [[ $mode == all ]] || oses=("$mode")
|
||||
for os in "${oses[@]}"; do rm -rf -- "build/cross/packages/$os"; done
|
||||
if ./cross/build-diag.sh > build/cross/diag.log 2>&1; then
|
||||
for os in "${oses[@]}"; do mkdir -p "build/cross/packages/$os"; cp build/cross/diag/IPXDIAG.EXE "build/cross/packages/$os/"; done
|
||||
log 'IPXDIAG: built and structurally checked (all requested targets, runtime untested)'
|
||||
else log 'IPXDIAG: FAILED; see build/cross/diag.log'; rc=1; fi
|
||||
if [[ $mode == all ]]; then
|
||||
if ./cross/watcom-check.sh > build/cross/watcom.log 2>&1; then log 'Open Watcom: shared protocol objects built'; else log 'Open Watcom: FAILED; see build/cross/watcom.log'; rc=1; fi
|
||||
fi
|
||||
if [[ $mode == all || $mode == WIN2000 || $mode == WINXP ]]; then
|
||||
if ./cross/build-nt5.sh > build/cross/nt5.log 2>&1; then
|
||||
for os in "${oses[@]}"; do if [[ $os == WIN2000 || $os == WINXP ]]; then
|
||||
mkdir -p "build/cross/packages/$os"; cp build/cross/nt5/{MARSIPX.EXE,MARSTAP.EXE,MARSNDIS.SYS,MARSNDIS.INF} "build/cross/packages/$os/"
|
||||
log "$os: native candidate built; unsigned and VM-UNTESTED"
|
||||
fi; done
|
||||
else log 'NT5: FAILED; see build/cross/nt5.log; no native package exported'; rc=1; fi
|
||||
fi
|
||||
if [[ $mode == all || $mode == WIN95 || $mode == WIN98 || $mode == WINME || $mode == WINNT40 ]]; then
|
||||
winpcap_ok=0
|
||||
if ./cross/fetch-winpcap.sh > build/cross/winpcap.log 2>&1; then winpcap_ok=1; else log "WinPcap: FAILED; see build/cross/winpcap.log"; rc=1; fi
|
||||
if ./cross/build-legacy-bridge.sh > build/cross/legacy-bridge.log 2>&1; then log "NDIS3 user-mode bridge: PE32 candidate built (runtime UNTESTED)"; else log "Legacy bridge FAILED; see legacy-bridge.log"; rc=1; fi
|
||||
if ./cross/build-legacy.sh > build/cross/legacy.log 2>&1; then
|
||||
for os in "${oses[@]}"; do
|
||||
case $os in WIN95|WIN98|WINME|WINNT40)
|
||||
mkdir -p "build/cross/packages/$os"
|
||||
if (( winpcap_ok )); then
|
||||
cache=${MARS_TOOLCHAIN_DIR:-$PWD/.toolchains}
|
||||
cp "$cache/legacy/WinPcap_3_1.exe" "build/cross/packages/$os/WPCAP31.EXE"
|
||||
cp "$cache/legacy/WinPcap_3_1.exe.origin" "build/cross/packages/$os/WPCAP31.TXT"
|
||||
cp clients/windows/ndis3/INSTALL.BAT "build/cross/packages/$os/"
|
||||
fi
|
||||
cp build/cross/legacy/{MARSNET3.SYS,MARSNET.EXE,MARSNET3.imports.txt,MARSNET.imports.txt} "build/cross/packages/$os/"
|
||||
if [[ $os != WINNT40 ]]; then cp build/cross/legacy/MARSNET.INF "build/cross/packages/$os/"; else
|
||||
cache=${MARS_TOOLCHAIN_DIR:-$PWD/.toolchains}
|
||||
if python3 cross/generate-nt4-inf.py "$cache/legacy/nt4-extracted" "build/cross/packages/$os/OEMSETUP.INF"; then
|
||||
cp clients/windows/ndis3/NT4-INSTALL.txt "build/cross/packages/$os/"
|
||||
else rc=1; fi
|
||||
fi
|
||||
log "$os: NDIS3 candidate; WinPcap driver required, OS compatibility UNTESTED (NT4 OEMSETUP generated separately; installation UNTESTED)";;
|
||||
esac
|
||||
done
|
||||
else log 'NDIS3: FAILED; see build/cross/legacy.log; no legacy adapter exported'; rc=1; fi
|
||||
fi
|
||||
for os in "${oses[@]}"; do
|
||||
d=build/cross/packages/$os
|
||||
if [[ -d $d ]]; then printf '%s\r\n' 'MARS VME development preview. NOT a validated driver release.' 'See LEGACY-BUILD.md, CROSS-BUILD.md and WINDOWS.md. Use an isolated VM. IPXDIAG.EXE checks only local IPX.' > "$d/README.TXT"; fi
|
||||
done
|
||||
log "Result: $report (not an OS compatibility certification)"
|
||||
exit "$rc"
|
||||
20
cross/extract-nt4.sh
Executable file
20
cross/extract-nt4.sh
Executable file
@@ -0,0 +1,20 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
cd "$(dirname "$0")/.."
|
||||
cache=${MARS_TOOLCHAIN_DIR:-$PWD/.toolchains}; cache=$(realpath -m "$cache/legacy")
|
||||
[[ -f $cache/winnt40.ddk.iso ]] || { echo 'No NT4 ISO; run cross/fetch-legacy.sh --accept-archive' >&2; exit 1; }
|
||||
(cd "$cache"; sha256sum -c winnt40.ddk.iso.sha256)
|
||||
if [[ -e $cache/nt4-extracted/READY ]]; then echo "Cached NT4 files: $cache/nt4-extracted"; exit 0; fi
|
||||
[[ ! -e $cache/nt4-extracted ]] || { echo 'Incomplete extraction; move it aside first.' >&2; exit 1; }
|
||||
work=$(mktemp -d "$cache/.nt4.XXXXXX"); trap 'rm -rf -- "$work"' EXIT
|
||||
mkdir "$work/iso" "$work/expanded"; 7z x -y -o"$work/iso" "$cache/winnt40.ddk.iso" >/dev/null
|
||||
# Extract any cabinet groups without running setup.exe; keep paths separate.
|
||||
i=0
|
||||
while IFS= read -r -d '' f; do i=$((i+1)); mkdir "$work/expanded/$i"; cabextract -q -d "$work/expanded/$i" "$f" || echo "Cannot extract CAB: $f" >&2; done < <(find "$work/iso" -type f -iname '*.cab' -print0)
|
||||
# Some old DDKs store individual compressed files (NDIS.H_, etc.).
|
||||
while IFS= read -r -d '' f; do i=$((i+1)); mkdir "$work/expanded/$i"; 7z x -y -o"$work/expanded/$i" "$f" >/dev/null 2>&1 || true; done < <(find "$work/iso" -type f \( -iname '*.h_' -o -iname '*.li_' -o -iname '*.in_' \) -print0)
|
||||
find "$work" -type f \( -iname 'ndis.h' -o -iname 'ntddk.h' -o -iname 'ndis.lib' \) -printf '%P\n' | tee "$work/DDK-FILES.txt"
|
||||
if ! find "$work" -type f -iname ndis.h -print -quit | grep -q . || ! find "$work" -type f -iname ntddk.h -print -quit | grep -q . || ! find "$work" -type f -iname ndis.lib -print -quit | grep -q .; then
|
||||
echo 'Cannot find DDK components in this layout. Set NT4_DDK_INCLUDE and NT4_NDIS_LIB from your own extracted x86 DDK.' >&2; exit 1
|
||||
fi
|
||||
touch "$work/READY"; mv "$work" "$cache/nt4-extracted"; trap - EXIT
|
||||
92
cross/fetch-legacy.sh
Executable file
92
cross/fetch-legacy.sh
Executable file
@@ -0,0 +1,92 @@
|
||||
#!/usr/bin/env bash
|
||||
# Downloads only. No Windows executable is run; caches stay outside source packages.
|
||||
set -euo pipefail
|
||||
cd "$(dirname "$0")/.."
|
||||
[[ ${1:-} == --accept-archive ]] || { echo 'Review DDK archive licensing and provenance, then use --accept-archive. See LEGACY-BUILD.md.' >&2; exit 2; }
|
||||
cache=${MARS_TOOLCHAIN_DIR:-$PWD/.toolchains}; mkdir -p "$cache/legacy"; cache=$(realpath "$cache/legacy")
|
||||
for t in curl jq sha256sum sha512sum git; do
|
||||
command -v "$t" >/dev/null || { echo "Missing dependency: $t" >&2; exit 2; }
|
||||
done
|
||||
fetch(){ curl --fail --silent --show-error --location --retry 2 --connect-timeout 15 --max-time 1800 --proto '=https' --proto-redir '=https' "$@"; }
|
||||
asset(){
|
||||
local tag=$1 name=$2 key=$3 url digest actual meta tmp
|
||||
local envsha="${key}_SHA256"; digest=${!envsha:-}
|
||||
url="https://github.com/KunYi/WDK_DDKArchive/releases/download/$tag/$name"
|
||||
if [[ -z $digest ]]; then
|
||||
if meta=$(fetch "https://api.github.com/repos/KunYi/WDK_DDKArchive/releases/tags/$tag"); then
|
||||
digest=$(jq -r --arg name "$name" '.assets[]|select(.name==$name)|(.digest // "")|sub("^sha256:";"")' <<<"$meta")
|
||||
fi
|
||||
fi
|
||||
if [[ -e $cache/$name && -e $cache/$name.sha256 ]]; then (cd "$cache"; sha256sum -c "$name.sha256") || return 1; else
|
||||
tmp=$(mktemp "$cache/.download.XXXXXX"); if ! fetch "$url" -o "$tmp"; then rm -f "$tmp"; return 1; fi
|
||||
actual=$(sha256sum "$tmp" | cut -d' ' -f1)
|
||||
if [[ -n $digest && ${digest,,} != "$actual" ]]; then rm -f "$tmp"; echo "Hash mismatch: $name" >&2; return 1; fi
|
||||
mv "$tmp" "$cache/$name" || return 1; printf '%s %s\n' "$actual" "$name" > "$cache/$name.sha256"
|
||||
fi
|
||||
actual=$(sha256sum "$cache/$name"|cut -d' ' -f1)
|
||||
if [[ -n $digest && ${digest,,} != "$actual" ]]; then echo "Hash mismatch: $name" >&2; return 1; fi
|
||||
printf 'url=%s\nsha256=%s\nexpected=%s\n' "$url" "$actual" "${digest:-UNVERIFIED}" > "$cache/$name.origin"
|
||||
[[ -n $digest ]] || echo "WARNING $name: archive not independently verified; SHA256 records bytes only." >&2
|
||||
}
|
||||
rc=0
|
||||
asset NT4_DDK winnt40.ddk.iso NT4_DDK || rc=1
|
||||
asset Win98DDK win98ddk.exe WIN98_DDK || rc=1
|
||||
# WinWorld publishes this SHA-512 on the Windows 95 DDK download page.
|
||||
# Unofficial archival copy, not a signed Microsoft distribution.
|
||||
name=win95ddk.7z
|
||||
mirror2='https://git.iiot-factory.com/chris/mars_nwe_pcab/raw/branch/main/windll/Microsoft%20Windows%2095%20DDK.7z'
|
||||
mirror1='https://dl.winworldpc.com/Abandonware%20SDKs/Microsoft%20Windows%2095%20DDK.7z'
|
||||
sha512=${WIN95_DDK_SHA512:-119ed8a4361805ec8b36f227da741a864cad77586ff7f87c696a74d7d438b3253b643c97765414867575f1d20e65c9cd70762c7d8481108778a0af0c4c0061bf}
|
||||
if [[ ! $sha512 =~ ^[a-fA-F0-9]{128}$ ]]; then
|
||||
echo 'Invalid WIN95_DDK_SHA512' >&2; exit 2
|
||||
fi
|
||||
if [[ ${MARS_SKIP_WIN95_DDK:-0} == 1 && ${MARS_REQUIRE_WIN95_DDK:-0} == 1 ]]; then
|
||||
echo 'MARS_SKIP_WIN95_DDK and MARS_REQUIRE_WIN95_DDK conflict.' >&2; exit 2
|
||||
fi
|
||||
fetch_win95(){
|
||||
local url tmp mismatch=0
|
||||
local -a urls=()
|
||||
[[ -z ${WIN95_DDK_URL:-} ]] || urls+=("$WIN95_DDK_URL")
|
||||
[[ ${WIN95_DDK_URL:-} == "$mirror2" ]] || urls+=("$mirror2")
|
||||
[[ ${WIN95_DDK_URL:-} == "$mirror1" ]] || urls+=("$mirror1")
|
||||
if [[ -f $cache/$name ]]; then
|
||||
printf '%s %s\n' "$sha512" "$cache/$name" | sha512sum -c - || return 1
|
||||
echo "Using cached $cache/$name"
|
||||
[[ -f $cache/$name.origin ]] || printf 'url=LOCAL_CACHE\nsha512=%s\n' "$sha512" > "$cache/$name.origin"
|
||||
return 0
|
||||
fi
|
||||
for url in "${urls[@]}"; do
|
||||
echo "Trying Windows 95 DDK: $url"
|
||||
tmp=$(mktemp "$cache/.win95.XXXXXX") || return 1
|
||||
if fetch "$url" -o "$tmp"; then
|
||||
if printf '%s %s\n' "$sha512" "$tmp" | sha512sum -c -; then
|
||||
mv -- "$tmp" "$cache/$name" || { rm -f -- "$tmp"; return 1; }
|
||||
printf 'url=%s\nsha512=%s\n' "$url" "$sha512" > "$cache/$name.origin" || return 1
|
||||
echo "Downloaded and verified: $cache/$name"
|
||||
return 0
|
||||
fi
|
||||
mismatch=1
|
||||
echo 'WARNING: Windows 95 archive hash mismatch; trying next mirror.' >&2
|
||||
fi
|
||||
rm -f -- "$tmp"
|
||||
done
|
||||
if (( mismatch )); then
|
||||
echo 'ERROR: No mirror supplied a valid Windows 95 archive.' >&2; return 1
|
||||
fi
|
||||
echo 'WARNING: All Windows 95 DDK mirrors unavailable.' >&2
|
||||
if [[ ${MARS_REQUIRE_WIN95_DDK:-0} == 1 ]]; then return 1; fi
|
||||
echo 'Optional Windows 95 reference DDK skipped; NT4-based build can continue.' >&2
|
||||
return 0
|
||||
}
|
||||
if [[ ${MARS_SKIP_WIN95_DDK:-0} == 1 ]]; then
|
||||
echo 'Skipping optional Windows 95 reference DDK.'
|
||||
else
|
||||
fetch_win95 || rc=1
|
||||
fi
|
||||
# WinPcap is an open source reference and optional compatibility transport.
|
||||
if [[ ! -d $cache/winpcap31/.git ]]; then
|
||||
git clone --depth 1 --branch WINPCAP_3_1 https://github.com/wireshark/winpcap.git "$cache/winpcap31" || rc=1
|
||||
fi
|
||||
if [[ -d $cache/winpcap31/.git ]]; then git -C "$cache/winpcap31" rev-parse HEAD > "$cache/winpcap31.commit"; fi
|
||||
./cross/fetch-winpcap.sh || rc=1
|
||||
exit "$rc"
|
||||
38
cross/fetch-watcom.sh
Executable file
38
cross/fetch-watcom.sh
Executable file
@@ -0,0 +1,38 @@
|
||||
#!/usr/bin/env bash
|
||||
# Download official Open Watcom snapshot; no installer executed, local project cache.
|
||||
set -euo pipefail
|
||||
cd "$(dirname "$0")/.."
|
||||
for t in curl jq tar xz sha256sum; do command -v "$t" >/dev/null || { echo "Missing $t; run cross/install-tools.sh --apt-only" >&2; exit 1; }; done
|
||||
cache=${MARS_TOOLCHAIN_DIR:-$PWD/.toolchains}; mkdir -p "$cache"; cache=$(realpath "$cache")
|
||||
if [[ -f $cache/watcom/ROOT ]]; then
|
||||
root=$(cat "$cache/watcom/ROOT"); if [[ -x $cache/watcom/$root/binl64/wcc386 || -x $cache/watcom/$root/binl/wcc386 ]]; then echo "Using cached Open Watcom: $cache/watcom/$root"; exit 0; fi
|
||||
echo 'Incomplete cache; move the watcom directory aside first.' >&2; exit 1
|
||||
fi
|
||||
[[ ! -e $cache/watcom ]] || { echo 'Incomplete Watcom cache; move it aside first.' >&2; exit 1; }
|
||||
work=$(mktemp -d "$cache/.watcom.XXXXXXXX"); trap 'rm -rf -- "$work"' EXIT
|
||||
fetch(){ curl --fail --show-error --silent --location --retry 3 --connect-timeout 15 --max-time 1800 --proto '=https' --proto-redir '=https' "$@"; }
|
||||
tag=${WATCOM_TAG:-Current-build}
|
||||
[[ $tag =~ ^[A-Za-z0-9._-]+$ ]] || exit 2
|
||||
if [[ -n ${WATCOM_URL:-} ]]; then
|
||||
[[ ${WATCOM_SHA256:-} =~ ^[a-fA-F0-9]{64}$ ]] || { echo 'Custom WATCOM_URL requires WATCOM_SHA256.' >&2; exit 2; }
|
||||
url=$WATCOM_URL; digest=$WATCOM_SHA256
|
||||
else
|
||||
fetch "https://api.github.com/repos/open-watcom/open-watcom-v2/releases/tags/$tag" -o "$work/release.json"
|
||||
asset=$(jq -ce '[.assets[] | select(.name=="owsnapshot.tar.xz" or .name=="ow-snapshot.tar.xz")][0] // error("No snapshot for this release")' "$work/release.json")
|
||||
url=$(jq -er '.browser_download_url' <<<"$asset")
|
||||
[[ $url == https://github.com/open-watcom/open-watcom-v2/releases/download/* ]] || exit 2
|
||||
digest=${WATCOM_SHA256:-$(jq -r '(.digest // "") | sub("^sha256:"; "")' <<<"$asset")}
|
||||
fi
|
||||
fetch "$url" -o "$work/snapshot.tar.xz"
|
||||
actual=$(sha256sum "$work/snapshot.tar.xz" | cut -d' ' -f1)
|
||||
if [[ -n $digest ]]; then [[ ${digest,,} == "$actual" ]] || { echo 'Watcom SHA256 mismatch' >&2; exit 1; }; else echo 'WARNING: upstream supplied no digest. HTTPS transport only; recorded SHA256 is not independent verification.' >&2; fi
|
||||
mkdir "$work/extract"
|
||||
tar -xJf "$work/snapshot.tar.xz" --no-same-owner --no-same-permissions -C "$work/extract"
|
||||
root=''; for d in "$work/extract" "$work/extract"/*; do
|
||||
if [[ -d $d/h && ( -x $d/binl64/wcc386 || -x $d/binl/wcc386 ) ]]; then root=$d; break; fi
|
||||
done
|
||||
[[ -n $root ]] || { echo 'Open Watcom snapshot layout not recognized.' >&2; exit 1; }
|
||||
relative=${root#"$work/extract"}; relative=${relative#/}; printf '%s\n' "${relative:-.}" > "$work/extract/ROOT"
|
||||
printf 'url=%s\nsha256=%s\ntag=%s\n' "$url" "$actual" "$tag" > "$work/extract/ORIGIN.txt"
|
||||
mv -T "$work/extract" "$cache/watcom"
|
||||
echo "Open Watcom available in $cache/watcom/${relative:-.}"
|
||||
26
cross/fetch-winpcap.sh
Executable file
26
cross/fetch-winpcap.sh
Executable file
@@ -0,0 +1,26 @@
|
||||
#!/usr/bin/env bash
|
||||
# Extract the unmodified WinPcap 3.1 installer from the official Wireshark archive.
|
||||
set -euo pipefail
|
||||
cd "$(dirname "$0")/.."
|
||||
cache=${MARS_TOOLCHAIN_DIR:-$PWD/.toolchains}/legacy
|
||||
mkdir -p "$cache"
|
||||
url=https://www.wireshark.org/download/win32/all-versions/wireshark-setup-0.99.4.exe
|
||||
bundle=wireshark-setup-0.99.4.exe
|
||||
bundle_sha=c9afd4c81103b62ad95cbe12a30f81f18b847f95136267ca9af3b87c12abd50f
|
||||
installer_sha=cc3840c1b87fb73ce0f5612403d1fc0bbf192bde8639c81388133d80db59000d
|
||||
# SHA256 pins measured from the official HTTPS download on 2026-11-27;
|
||||
# reproducibility checks, not independently published vendor signatures.
|
||||
verify(){ printf '%s %s\n' "$1" "$2" | sha256sum -c -; }
|
||||
if [[ ! -f $cache/WinPcap_3_1.exe ]]; then
|
||||
if [[ ! -f $cache/$bundle ]]; then
|
||||
[[ ${MARS_OFFLINE:-0} != 1 ]] || { echo 'WinPcap missing: run cross/fetch-winpcap.sh online first' >&2; exit 1; }
|
||||
tmp=$(mktemp "$cache/.winpcap.XXXXXX"); trap 'rm -f "$tmp"' EXIT
|
||||
curl --fail --location --show-error --retry 2 --connect-timeout 15 --max-time 300 --proto '=https' --proto-redir '=https' "$url" -o "$tmp"
|
||||
verify "$bundle_sha" "$tmp"
|
||||
mv "$tmp" "$cache/$bundle"; trap - EXIT
|
||||
fi
|
||||
verify "$bundle_sha" "$cache/$bundle"
|
||||
7z e -y "-o$cache" "$cache/$bundle" WinPcap_3_1.exe >/dev/null
|
||||
fi
|
||||
verify "$installer_sha" "$cache/WinPcap_3_1.exe"
|
||||
printf 'source=%s\nbundle_sha256=%s\ninstaller_sha256=%s\nVerification=locally measured pins from official HTTPS archive; not vendor signature\n' "$url" "$bundle_sha" "$installer_sha" > "$cache/WinPcap_3_1.exe.origin"
|
||||
99
cross/generate-nt4-inf.py
Normal file
99
cross/generate-nt4-inf.py
Normal file
@@ -0,0 +1,99 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Generate a local NT4 installer from the operator's NT4 DDK sample.
|
||||
No DDK source is bundled with this generator. Output requires NT4 VM validation.
|
||||
"""
|
||||
import argparse, os, pathlib, re
|
||||
p=argparse.ArgumentParser()
|
||||
p.add_argument('ddk', type=pathlib.Path)
|
||||
p.add_argument('output', type=pathlib.Path)
|
||||
a=p.parse_args()
|
||||
mac=os.environ.get('MARS_NT4_NETWORK_ADDRESS', '')
|
||||
if mac and (not re.fullmatch(r'[0-9a-fA-F]{12}', mac) or int(mac[:2],16)&1 or int(mac,16)==0):
|
||||
p.error('MARS_NT4_NETWORK_ADDRESS must be a nonzero unicast MAC: 12 hex digits')
|
||||
paths=list(a.ddk.rglob('OEMNADE2.INF'))
|
||||
if len(paths)!=1: p.error('Expected one NT4 Ethernet installer sample OEMNADE2.INF')
|
||||
s=paths[0].read_text(encoding='latin1').replace('\x1a','')
|
||||
# Strip comments from template; retain a provenance notice for the generated file.
|
||||
s='\n'.join(line for line in s.splitlines() if not line.lstrip().startswith(';'))
|
||||
# No bus/resource detection for a software-only adapter.
|
||||
start=s.index(' Debug-Output "OEMNADE2.INF: ====')
|
||||
end=s.index('installadapter = +',start)
|
||||
s=s[:start]+' Goto $(StartLabel)\n\n'+s[end:]
|
||||
start=s.index(' Set CurrParamSettings = {}')
|
||||
end=s.index('configureadapter = +',start)
|
||||
s=s[:start]+' goto adaptersetup\n\n'+s[end:]
|
||||
start=s.index(' set ValueName = ""',s.index('configureadapter = +'))
|
||||
end=s.index('skipoptions =+',start)
|
||||
s=s[:start]+''' CloseRegKey $(KeyParameters)
|
||||
CloseRegKey $(KeyProduct)
|
||||
goto successful
|
||||
|
||||
adaptersetup = +
|
||||
Ifstr $(NetworkAddress) == ""
|
||||
set Error = "Set NetworkAddress in OEMSETUP.INF to the physical IPX node (12 hex digits), then install again."
|
||||
goto fatal
|
||||
endif
|
||||
goto skipoptions
|
||||
|
||||
'''+s[end:]
|
||||
start=s.index(' Set NewValueList = {{Transceiver',s.index('writeparameters = +'))
|
||||
end=s.index(' Shell $(UtilityInf), AddValueList',start)
|
||||
s=s[:start]+''' Set NewValueList = {{BusType,$(NoTitle),$(!REG_VT_DWORD),0},+
|
||||
{BusNumber,$(NoTitle),$(!REG_VT_DWORD),0},+
|
||||
{NetworkAddress,$(NoTitle),$(!REG_VT_SZ),$(NetworkAddress)}}
|
||||
|
||||
'''+s[end:]
|
||||
# Bindings are handled by NCPA's NetRules engine, not an ISA setup dialog.
|
||||
s=s.replace(' set Error = "Binding: Sorry, not yet implemented."\n goto fatal',' goto successful')
|
||||
start=s.index('[DebugConfiguration]'); end=s.index('[Install-Option]',start)
|
||||
s=s[:start]+s[end:]
|
||||
s=re.sub(r'\[PlatformsSupported\].*?\[Options\]', '[PlatformsSupported]\n ISA\n EISA\n PCI\n Internal\n\n[Options]',s,flags=re.S)
|
||||
s=re.sub('elnkii', 'MARSNET3',s,flags=re.I).replace('OEMNADE2.INF','OEMSETUP.INF').replace('Elink II','MARS Virtual Ethernet')
|
||||
s=s.replace('Manufacturer = "Microsoft"','Manufacturer = "MARS VME"')
|
||||
s=s.replace('ProductOpSupport = 134', 'ProductOpSupport = 130') # display/remove; no resource properties
|
||||
s=s.replace('NetRuleHardwareClass = {"MARSNET3Adapter basic"}', 'NetRuleHardwareClass = {"MARSNET3Adapter basic", "ndisEthernet basic"}')
|
||||
s=s.replace('[FileConstants]', '[FileConstants]\nNetworkAddress = "'+mac.upper()+'"')
|
||||
s=s.replace('ifstr(i) !(NTN_RegBase)', 'ifstr(i) $(!NTN_RegBase)')
|
||||
s=s.replace('successful = +\n goto end','successful = +\n set CommonStatus = STATUS_REBOOT\n goto end')
|
||||
s+='''
|
||||
[ProductType]
|
||||
STF_PRODUCT = Winnt
|
||||
STF_PLATFORM = I386
|
||||
[Source Media Descriptions]
|
||||
1 = "MARS NDIS3 NT4 driver", TAGFILE = MARSNET3.SYS
|
||||
[Files-MARSNET3]
|
||||
1, MARSNET3.SYS, SIZE=65536
|
||||
[LanguagesSupported]
|
||||
ENG, GER
|
||||
'''
|
||||
for lang in ('ENG','GER'):
|
||||
s+='''
|
||||
[OptionsTextLANG]
|
||||
MARSNET3 = "MARS Virtual IPX Ethernet NDIS3 (experimental)"
|
||||
[FileConstantsLANG]
|
||||
FunctionTitle = "MARS NDIS3 NT4 Setup"
|
||||
ProductSoftwareDescription = "MARS virtual Ethernet driver"
|
||||
ProductSoftwareTitle = "MARS NDIS3 driver"
|
||||
ProductHardwareMARSNET3Description = "MARS virtual Ethernet"
|
||||
ProductHardwareMARSNET3Title = "MARS virtual Ethernet adapter"
|
||||
ShellCodeErrorTitle = "MARS NT4 Setup error"
|
||||
ShellCodeErrorText = "NT4 setup helper failed. See setup log."
|
||||
ProCaption = "MARS NT4 Setup"
|
||||
ProCancel = "Cancel"
|
||||
ProCancelMsg = "Cancel driver setup?"
|
||||
ProCancelCap = "MARS NT4 Setup"
|
||||
ProText1 = "Copying:"
|
||||
ProText2 = "To:"
|
||||
[DialogConstantsLANG]
|
||||
OK = "OK"
|
||||
Continue = "Continue"
|
||||
Cancel = "Cancel"
|
||||
'''.replace('LANG',lang)
|
||||
s='; MARS NT4 x86 experimental installer. Runtime UNTESTED.\n; Adapted locally from Microsoft NT4 DDK OEMNADE2.INF.\n; Original sample provenance: Microsoft NT4 DDK, Ethernet setup example.\n'+s
|
||||
# Catch dangling static branches left by template surgery.
|
||||
labels={m.lower() for m in re.findall(r'^([A-Za-z][A-Za-z0-9_]*)\s*=\s*\+',s,re.M)}
|
||||
for target in re.findall(r'^\s*goto\s+([A-Za-z][A-Za-z0-9_]*)\s*$',s,re.M|re.I):
|
||||
if target.lower() not in labels: p.error('Unresolved branch: '+target)
|
||||
a.output.parent.mkdir(parents=True,exist_ok=True)
|
||||
a.output.write_bytes(s.replace('\n','\r\n').encode('ascii'))
|
||||
print(str(a.output)+': generated; NT4 installation/binding not runtime tested')
|
||||
13
cross/install-tools.sh
Executable file
13
cross/install-tools.sh
Executable file
@@ -0,0 +1,13 @@
|
||||
#!/usr/bin/env bash
|
||||
# Debian/Ubuntu. apt verifies its signed repository metadata.
|
||||
set -euo pipefail
|
||||
cd "$(dirname "$0")/.."
|
||||
mode=${1:---all}
|
||||
case "$mode" in --all|--apt-only|--watcom-only) ;; *) echo 'Usage: cross/install-tools.sh [--all|--apt-only|--watcom-only]' >&2; exit 2;; esac
|
||||
if [[ $mode != --watcom-only ]]; then
|
||||
command -v apt-get >/dev/null || { echo 'Install equivalent packages manually on non-Debian systems.' >&2; exit 1; }
|
||||
elevate=(); if (( EUID != 0 )); then elevate=(sudo); fi
|
||||
"${elevate[@]}" apt-get update
|
||||
"${elevate[@]}" apt-get install -y build-essential cmake git pkg-config curl ca-certificates jq xz-utils p7zip-full cabextract python3 clang lld llvm binutils gcc-mingw-w64-i686 g++-mingw-w64-i686 binutils-mingw-w64-i686 mingw-w64-i686-dev
|
||||
fi
|
||||
if [[ $mode != --apt-only ]]; then ./cross/fetch-watcom.sh; fi
|
||||
23
cross/package-drivers.py
Normal file
23
cross/package-drivers.py
Normal file
@@ -0,0 +1,23 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Package existing validated cross-builds using Python's standard ZIP library."""
|
||||
from pathlib import Path
|
||||
import hashlib, json, zipfile
|
||||
root=Path(__file__).resolve().parents[1]
|
||||
out=root/'releases/windows';out.mkdir(parents=True,exist_ok=True)
|
||||
manifest={}
|
||||
for os in ('WIN95','WIN98','WINME','WINNT40','WIN2000','WINXP'):
|
||||
src=root/'build/cross/packages'/os
|
||||
required=['IPXDIAG.EXE']+(['MARSNDIS.SYS','MARSNDIS.INF','MARSIPX.EXE','MARSTAP.EXE'] if os in ('WIN2000','WINXP') else ['MARSNET3.SYS','MARSNET.EXE','WPCAP31.EXE','INSTALL.BAT','OEMSETUP.INF' if os=='WINNT40' else 'MARSNET.INF'])
|
||||
for name in required:
|
||||
if not (src/name).is_file():raise SystemExit(f'Missing {os}/{name}; run build-windows.sh first')
|
||||
files={p.name:p for p in src.iterdir() if p.is_file()}
|
||||
for name in ('WINDOWS.md','LEGACY-BUILD.md','COPYING'):files[name]=root/name
|
||||
hashes={name:hashlib.sha256(p.read_bytes()).hexdigest() for name,p in sorted(files.items())}
|
||||
dest=out/(os+'.zip')
|
||||
with zipfile.ZipFile(dest,'w',zipfile.ZIP_DEFLATED) as z:
|
||||
for name,p in sorted(files.items()):
|
||||
info=zipfile.ZipInfo(os+'/'+name,(2026,11,27,0,0,0));info.external_attr=0o100644<<16;info.compress_type=zipfile.ZIP_DEFLATED;z.writestr(info,p.read_bytes())
|
||||
manifest[os]={'sha256':hashlib.sha256(dest.read_bytes()).hexdigest(),'files':hashes}
|
||||
(out/'manifest.json').write_text(json.dumps(manifest,indent=2)+'\n')
|
||||
(out/'SHA256SUMS').write_text(''.join(f'{v["sha256"]} {k}.zip\n' for k,v in manifest.items()))
|
||||
print('Packaged 6 OS ZIPs with file hashes')
|
||||
16
cross/prepare-mingw-ddk.py
Normal file
16
cross/prepare-mingw-ddk.py
Normal file
@@ -0,0 +1,16 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Patch packaged DDK header defects locally, preserving the NT5 target ABI."""
|
||||
import pathlib, sys, shutil, re
|
||||
src, dst = map(pathlib.Path, sys.argv[1:])
|
||||
shutil.copytree(src, dst, dirs_exist_ok=True)
|
||||
p = dst / 'wdm.h'
|
||||
s = p.read_text().replace('NTDDI_WINVISTA', 'NTDDI_VISTA')
|
||||
p.write_text(s)
|
||||
p = dst / 'ndis.h'
|
||||
s = p.read_text()
|
||||
# Modern ntddndis.h already declares the request enum.
|
||||
public = src.parent / 'ntddndis.h'
|
||||
if 'enum _NDIS_REQUEST_TYPE' in public.read_text():
|
||||
s = re.sub(r'typedef enum _NDIS_REQUEST_TYPE \{.*?\} NDIS_REQUEST_TYPE, \*PNDIS_REQUEST_TYPE;', '', s, flags=re.S)
|
||||
s = s.replace('IN NDIS_HANDLE MiniportAdapterHandle\n\tIN NDIS_HANDLE NdisLinkContext);', 'IN NDIS_HANDLE MiniportAdapterHandle,\n\tIN NDIS_HANDLE NdisLinkContext);')
|
||||
p.write_text(s)
|
||||
31
cross/prepare-nt4.py
Executable file
31
cross/prepare-nt4.py
Executable file
@@ -0,0 +1,31 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Prepare historical DDK includes. Refuse ambiguous header/library choices."""
|
||||
import os, pathlib, sys, shutil
|
||||
root, out = map(pathlib.Path,sys.argv[1:3]); out.mkdir(parents=True, exist_ok=True)
|
||||
inc=os.environ.get('NT4_DDK_INCLUDE'); lib=os.environ.get('NT4_NDIS_LIB')
|
||||
if inc:
|
||||
dirs=[pathlib.Path(p) for p in inc.split(':')]
|
||||
else:
|
||||
dirs=[]
|
||||
for name in ('ndis.h','ntddk.h'):
|
||||
matches=[p for p in root.rglob('*') if p.is_file() and p.name.lower()==name]
|
||||
if len(matches)!=1: sys.exit(f'{name}: ambiguous/missing {matches}; set NT4_DDK_INCLUDE (colon-separated directories)')
|
||||
if matches[0].parent not in dirs: dirs.append(matches[0].parent)
|
||||
# Lowercase aliases plus original basename, reject different contents for same name.
|
||||
for d in dirs:
|
||||
for p in d.iterdir():
|
||||
if not p.is_file() or p.suffix.lower() not in ('.h','.inc'): continue
|
||||
for name in {p.name,p.name.lower(),p.name.upper()}:
|
||||
dest=out/name
|
||||
if dest.exists() and dest.read_bytes()!=p.read_bytes(): sys.exit(f'Header conflict: {p} / {dest}')
|
||||
if not dest.exists(): shutil.copyfile(p,dest)
|
||||
if not lib:
|
||||
paths=[p for p in root.rglob('*') if p.is_file() and p.name.lower()=='ndis.lib']
|
||||
x86=[p for p in paths if any(s.lower() in ('i386','x86','386') for s in p.parts)]
|
||||
# Prefer the retail x86 library over checked/debug and other CPUs.
|
||||
free=[p for p in x86 if "free" in [s.lower() for s in p.parts]]
|
||||
paths=free if free else x86
|
||||
if len(paths)!=1: sys.exit(f'NDIS.LIB ambiguous/missing {paths}; set NT4_NDIS_LIB to x86 library')
|
||||
lib=str(paths[0])
|
||||
if not pathlib.Path(lib).is_file(): sys.exit('NDIS.LIB not found')
|
||||
print(str(pathlib.Path(lib).resolve()))
|
||||
17
cross/verify-pe.py
Executable file
17
cross/verify-pe.py
Executable file
@@ -0,0 +1,17 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Structural PE32 check; not a Windows ABI or execution test."""
|
||||
import pathlib, struct, sys
|
||||
p=pathlib.Path(sys.argv[1]); b=p.read_bytes(); kind=sys.argv[2]
|
||||
def u16(o): return struct.unpack_from('<H',b,o)[0]
|
||||
def u32(o): return struct.unpack_from('<I',b,o)[0]
|
||||
try:
|
||||
assert b[:2]==b'MZ', 'DOS signature'
|
||||
o=u32(0x3c); assert b[o:o+4]==b'PE\0\0', 'PE signature'
|
||||
assert u16(o+4)==0x14c, 'not x86'
|
||||
h=o+24; assert u16(h)==0x10b, 'not PE32'
|
||||
assert u32(h+16)>0, 'no entry point'
|
||||
sub=u16(h+68); assert sub==(1 if kind=='sys' else 3), 'unexpected subsystem'
|
||||
assert not u16(o+22)&0x2000, 'DLL rather than executable/driver'
|
||||
print(f'{p.name}: PE32 x86, subsystem {sub}, OS {u16(h+40)}.{u16(h+42)}, subsystem version {u16(h+48)}.{u16(h+50)}')
|
||||
except (AssertionError,struct.error) as e:
|
||||
sys.exit(f'{p}: invalid PE: {e}')
|
||||
17
cross/watcom-check.sh
Executable file
17
cross/watcom-check.sh
Executable file
@@ -0,0 +1,17 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
cd "$(dirname "$0")/.."
|
||||
cache=${MARS_TOOLCHAIN_DIR:-$PWD/.toolchains}
|
||||
if [[ -z ${WATCOM:-} ]]; then
|
||||
if [[ ! -f $cache/watcom/ROOT ]]; then
|
||||
[[ ${MARS_OFFLINE:-0} != 1 ]] || { echo "No cached Open Watcom; run make windows-tools" >&2; exit 1; }
|
||||
./cross/fetch-watcom.sh
|
||||
fi
|
||||
WATCOM=$(realpath "$cache/watcom/$(cat "$cache/watcom/ROOT")")
|
||||
fi
|
||||
export WATCOM PATH="$WATCOM/binl64:$WATCOM/binl:$PATH" INCLUDE="$WATCOM/h:$WATCOM/h/nt"
|
||||
mkdir -p build/cross/watcom
|
||||
# Compile actual shared IPXPKT sources as 32-bit Windows objects, not a driver.
|
||||
wcc386 -q -bt=nt -3 -i=src -fo=build/cross/watcom/ipxpkt.obj src/ipxpkt.c
|
||||
wcc386 -q -bt=nt -3 -i=src -i=clients/windows -fo=build/cross/watcom/client_core.obj clients/windows/client_core.c
|
||||
echo 'Watcom protocol objects built; not an installable adapter.'
|
||||
Reference in New Issue
Block a user