[idd] prevent races from corrupting the mode list and edid

This commit is contained in:
Geoffrey McRae
2026-07-16 15:26:21 +10:00
parent 0140a3f6fb
commit fbf564f2e1
4 changed files with 265 additions and 62 deletions

View File

@@ -267,14 +267,16 @@ NTSTATUS LGIddCreateDevice(_Inout_ PWDFDEVICE_INIT deviceInit)
return status;
/*
* Keep the WDF device cached so callbacks that do not provide an adapter or
* monitor context can still reach the device context on down-level IddCx.
* Construct the device context and cache the WDF device BEFORE calling
* IddCxDeviceInitialize. IddCxDeviceInitialize arms the IddCx callbacks, and
* callbacks that resolve the context via l_wdfDevice (down-level IddCx that
* provides no adapter/monitor context) must never observe a null context.
*/
auto wrapper = WdfObjectGet_CIndirectDeviceContextWrapper(device);
wrapper->context = new CIndirectDeviceContext(device);
l_wdfDevice = device;
status = IddCxDeviceInitialize(device);
auto wrapper = WdfObjectGet_CIndirectDeviceContextWrapper(device);
wrapper->context = new CIndirectDeviceContext(device);
return status;
}