From 00f64ab129d3a564f62d5ec81efbffcdeda620c3 Mon Sep 17 00:00:00 2001 From: kinect-bot Date: Wed, 25 Nov 2026 18:03:35 -0500 Subject: [PATCH] fix(windows-nui): fill NUI_IMAGE_FRAME by value in ImageStreamGetNextFrame DEA's HidNatalNuiThread uses a by-value frame ABI, not the standard runtime-returns-a-pointer one. Verified from gamekdm.dll disasm: updateStream (FUN_1000f400) passes the address of a 40-byte frame buffer (this+0xad8, sizeof NUI_IMAGE_FRAME) as ppcImageFrame and stores that same address as its outstanding marker; updateFrame (FUN_1000f0a0) copies 0x28 bytes straight from that buffer (single deref) into the display slot, and the renderer reads pFrameTexture/dwFrameNumber from it. The shim was only writing a 4-byte pointer, leaving dwFrameNumber=0/pFrameTexture=NULL, so the game never locked a texture -> Ready + player detected but no picture. Copy the frame struct into the caller's buffer instead. --- fallback/windows-nui/src/sensor.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/fallback/windows-nui/src/sensor.cpp b/fallback/windows-nui/src/sensor.cpp index 9ed8a4d..0a2369f 100644 --- a/fallback/windows-nui/src/sensor.cpp +++ b/fallback/windows-nui/src/sensor.cpp @@ -476,7 +476,19 @@ HRESULT VirtualKinectSensor::ImageStreamGetNextFrame( if (is_new) { stream->last_delivered_frame_number = frame_no; stream->outstanding = true; - *ppcImageFrame = &stream->frames[stream->latest_index]; + // DEA's HidNatalNuiThread uses a by-VALUE NUI_IMAGE_FRAME ABI, not the + // standard "runtime returns a pointer" one. Verified from gamekdm.dll + // disasm: NuiThread::updateStream (FUN_1000f400) passes the address of a + // 40-byte (sizeof NUI_IMAGE_FRAME) buffer at this+0xad8 as ppcImageFrame + // and stores that same address as its outstanding-frame marker; + // NuiThread::updateFrame (FUN_1000f0a0) then copies 0x28 bytes straight + // from that buffer (single deref) into the display slot and the renderer + // reads pFrameTexture/dwFrameNumber from it. Writing only a 4-byte pointer + // here left dwFrameNumber/pFrameTexture zero, so the game never locked a + // texture (no picture). Copy the frame struct into the caller's buffer. + std::memcpy(reinterpret_cast(ppcImageFrame), + &stream->frames[stream->latest_index], + sizeof(NUI_IMAGE_FRAME)); } LeaveCriticalSection(&lock_);