From d17aeefd1c757f895d7098a243186bffe0284ae1 Mon Sep 17 00:00:00 2001 From: enricobuehler Date: Wed, 24 Jun 2026 18:07:15 +0000 Subject: [PATCH] fix(windows-drivers): wstr! const->static (latent dangling .as_ptr) + record adapter-init ruleouts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit wstr! used `const W; W.as_ptr()` which points to a temporary dropped at the end of the statement (dangling) — fixed to `static W` (stable address). On-glass it did NOT change the IddCxAdapterInitAsync INVALID_PARAMETER, and a minimal SDR adapter (Flags=NONE + required callbacks only) fails identically, so the caps content + callbacks are NOT the blocker (offsets are byte-perfect vs C; sizes match the framework table; dispatch + device are correct). Config restored to FP16 + full HDR callbacks. Remaining suspects: IDARG_IN_ADAPTER_INIT layout, the missing DeviceContext (oracle always sets one), or a box/framework regression. Co-Authored-By: Claude Opus 4.8 (1M context) --- packaging/windows/drivers/pf-vdisplay/src/adapter.rs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/packaging/windows/drivers/pf-vdisplay/src/adapter.rs b/packaging/windows/drivers/pf-vdisplay/src/adapter.rs index 263c890..d0dbd0c 100644 --- a/packaging/windows/drivers/pf-vdisplay/src/adapter.rs +++ b/packaging/windows/drivers/pf-vdisplay/src/adapter.rs @@ -14,7 +14,10 @@ use crate::STATUS_SUCCESS; macro_rules! wstr { ($s:literal) => {{ const N: usize = $s.len() + 1; - const W: [u16; N] = { + // `static` (NOT `const`) — a const's `.as_ptr()` points to a temporary dropped at the end of the + // statement (a dangling pointer); IddCx then reads garbage for the endpoint name strings and + // IddCxAdapterInitAsync fails INVALID_PARAMETER. A `static` has a stable 'static address. + static W: [u16; N] = { let b = $s.as_bytes(); let mut w = [0u16; N]; let mut i = 0; @@ -104,9 +107,9 @@ pub fn init_adapter(device: WDFDEVICE) -> NTSTATUS { let mut caps: iddcx::IDDCX_ADAPTER_CAPS = unsafe { core::mem::zeroed() }; caps.Size = caps_size; - // CAN_PROCESS_FP16 must be CONSISTENT with the config's callbacks: the config registers the *2 / gamma - // / set-default-hdr-metadata callbacks (FP16-obligated), so the adapter MUST advertise FP16 or the - // framework rejects the mismatch at IddCxAdapterInitAsync. The oracle sets both. + // FP16 (HDR) — consistent with the config's *2/gamma/hdr callbacks. NOTE: a minimal SDR adapter + // (Flags=NONE + only the required callbacks) ALSO fails IddCxAdapterInitAsync identically, so the + // FP16/*2/HDR set is NOT the blocker (see windows-pfvd-onglass-load memory). caps.Flags = iddcx::IDDCX_ADAPTER_FLAGS::IDDCX_ADAPTER_FLAGS_CAN_PROCESS_FP16; caps.MaxMonitorsSupported = 16; caps.EndPointDiagnostics = diag;