Files
WoW-Hybrid-gateway/ops/windows_backend_runtime_check.py
2026-11-23 03:28:32 +02:00

27 lines
1020 B
Python

"""Check the packaged backend and codec with the native Windows DLL loader."""
import ctypes
from pathlib import Path
import sys
def check_runtime(directory):
directory = Path(directory).resolve(strict=True)
# Prevent a missing DLL or procedure from opening a modal loader dialog.
ctypes.WinDLL('kernel32.dll').SetErrorMode(0x0001 | 0x8000)
# Resolve dependencies beside the loaded DLL or in System32. A developer's
# toolchain directory on PATH could otherwise hide a broken release.
search_flags = 0x0100 | 0x0800 # DLL_LOAD_DIR | SYSTEM32
loaded = []
for name in ('forever_codec.dll', 'GWNativeBackend.dll'):
try:
loaded.append(ctypes.WinDLL(str(directory / name), winmode=search_flags))
except OSError as error:
raise RuntimeError(f'{name} failed to load from {directory}: {error}') from error
if __name__ == '__main__':
try:
check_runtime(sys.argv[1])
except (OSError, RuntimeError) as error:
sys.exit(str(error))