$ show elishacloud/dxwrapper
dxwrapper is a system-level DLL proxy and compatibility layer for legacy DirectX games and applications on modern Windows (10/11). It intercepts calls to DirectDraw (1-7), Direct3D (7/8/9), DirectInput, DirectSound, and GDI, translating them to newer APIs (primarily Direct3D9) and applying numerous workarounds for rendering, input, and window management issues. The architecture is a hybrid of multiple integrated sub-projects: a core wrapper that loads real system DLLs and forwards exports while wrapping COM interfaces, plus three bundled versions of DDrawCompat (v0.2.0b, v0.2.1, v0.3.2) that hook at the user-mode display driver (D3dDdi) and GDI level. Key entry points include DllMain for each stub DLL (ddraw.dll, d3d8.dll, d3d9.dll, dsound.dll, dinput8.dll), the IClassFactory interception for COM object creation, and the configuration-driven Settings module. External dependencies include Microsoft Detours for function hooking, MemoryModule for loading DLLs from memory, and DirectXMath. The codebase is large and complex, with extensive use of COM proxy patterns, vtable hooking, and low-level Windows API patching.
The LLM identified 6 files worth highlighting for reuse:
Implements a reusable function hooking engine with trampolines, IAT patching, export-table parsing, and shim removal. Can be extracted for any Windows DLL interception project.
Template-based bidirectional map between real COM interface pointers and wrapper objects, used across all DirectX wrappers to avoid duplicate instances. Thread-safe and supports safe deletion.
Highly optimized SIMD (SSE2) blitter for surface copies with color-key, mirroring, stretching, and format conversion. Template-dispatch on pixel size and flags makes it reusable for any 2D blitting need.
Collection of RAII utilities: scoped critical sections, atomic flag setters, aligned allocator, and scope guards. Clean, header-only, and independent of the rest of the codebase.
Uses X-macro (VISIT_CONFIG_SETTINGS) to drive parsing, defaults, and legacy migration for a large configuration struct. Reduces boilerplate and ensures consistency across settings.
Generic DLL proxy stub generator using macros (CREATE_PROC_STUB, LOAD_ORIGINAL_PROC) to forward exports to real system DLLs. Reusable for any proxy DLL that needs to intercept a subset of exports.