From ec169053c36d86056b1980e8f2e2ef6a1b4f26f5 Mon Sep 17 00:00:00 2001 From: kinect-bot Date: Wed, 25 Nov 2026 15:20:55 -0500 Subject: [PATCH] fix(windows-nui): pin export ordinals to real Kinect10.dll (fixes ordinal 22 import), add 5 missing exports, MSVC-buildable --- fallback/windows-nui/CMakeLists.txt | 21 +++++++------ fallback/windows-nui/Kinect10.def | 47 +++++++++++++++------------- fallback/windows-nui/README.md | 31 +++++++++--------- fallback/windows-nui/src/exports.cpp | 40 +++++++++++++++++++++++ 4 files changed, 94 insertions(+), 45 deletions(-) diff --git a/fallback/windows-nui/CMakeLists.txt b/fallback/windows-nui/CMakeLists.txt index abb7d8d..e15b619 100644 --- a/fallback/windows-nui/CMakeLists.txt +++ b/fallback/windows-nui/CMakeLists.txt @@ -31,14 +31,17 @@ target_include_directories(kinect10 PRIVATE "${CORE_DIR}" ) -target_compile_options(kinect10 PRIVATE -O2 -Wall -Wextra) - -target_link_options(kinect10 PRIVATE - -static - -static-libgcc - -static-libstdc++ - -Wl,--enable-stdcall-fixup - -Wl,--kill-at -) +if(MSVC) + target_compile_options(kinect10 PRIVATE /O2 /W3) +else() + target_compile_options(kinect10 PRIVATE -O2 -Wall -Wextra) + target_link_options(kinect10 PRIVATE + -static + -static-libgcc + -static-libstdc++ + -Wl,--enable-stdcall-fixup + -Wl,--kill-at + ) +endif() target_link_libraries(kinect10 PRIVATE ole32 oleaut32 uuid) diff --git a/fallback/windows-nui/Kinect10.def b/fallback/windows-nui/Kinect10.def index 2363239..bb8f886 100644 --- a/fallback/windows-nui/Kinect10.def +++ b/fallback/windows-nui/Kinect10.def @@ -1,23 +1,28 @@ LIBRARY Kinect10 EXPORTS - NuiGetSensorCount - NuiCreateSensorByIndex - NuiCreateSensorById - NuiInitialize - NuiShutdown - NuiSetDeviceStatusCallback - NuiSkeletonTrackingEnable - NuiSkeletonTrackingDisable - NuiSkeletonGetNextFrame - NuiSkeletonSetTrackedSkeletons - NuiTransformSmooth - NuiTransformDepthImageToSkeleton - NuiImageStreamOpen - NuiImageStreamGetNextFrame - NuiImageStreamReleaseFrame - NuiImageStreamSetImageFrameFlags - NuiImageStreamGetImageFrameFlags - NuiImageGetColorPixelCoordinatesFromDepthPixel - NuiCameraElevationSetAngle - NuiCameraElevationGetAngle - NuiSetFrameEndEvent + KinectShimReserved1 @1 NONAME + NuiGetSensorCount @5 + NuiCreateSensorByIndex @6 + NuiCameraElevationGetAngle @7 + NuiCameraElevationSetAngle @8 + NuiImageGetColorPixelCoordinatesFromDepthPixel @9 + NuiImageGetColorPixelCoordinatesFromDepthPixelAtResolution @10 + NuiImageStreamGetNextFrame @11 + NuiImageStreamOpen @12 + NuiImageStreamReleaseFrame @13 + NuiInitialize @14 + NuiSetFrameEndEvent @15 + NuiShutdown @16 + NuiSkeletonGetNextFrame @17 + NuiSkeletonTrackingDisable @18 + NuiSkeletonTrackingEnable @19 + NuiTransformSmooth @20 + NuiCreateSensorById @21 + NuiSetDeviceStatusCallback @22 + NuiImageStreamSetImageFrameFlags @23 + NuiImageStreamGetImageFrameFlags @24 + NuiGetAudioSource @25 + NuiSkeletonSetTrackedSkeletons @26 + NuiSkeletonCalculateBoneOrientations @27 + NuiCreateCoordinateMapperFromParameters @28 + NuiCreateDepthFilter @29 diff --git a/fallback/windows-nui/README.md b/fallback/windows-nui/README.md index 3067f08..72b4566 100644 --- a/fallback/windows-nui/README.md +++ b/fallback/windows-nui/README.md @@ -69,23 +69,24 @@ publishes a no-player frame (`dwTrackingID = 0`, zeroed depth/color), so the hos app never blocks and `NuiSkeletonGetNextFrame` reports no tracked skeleton rather than hanging. -## Exported NUI surface (21 functions, undecorated) +## Exported NUI surface (25 named + 1 NONAME, pinned ordinals) -`NuiGetSensorCount`, `NuiCreateSensorByIndex`, `NuiCreateSensorById`, -`NuiInitialize`, `NuiShutdown`, `NuiSetDeviceStatusCallback`, -`NuiSkeletonTrackingEnable`, `NuiSkeletonTrackingDisable`, -`NuiSkeletonGetNextFrame`, `NuiSkeletonSetTrackedSkeletons`, `NuiTransformSmooth`, -`NuiTransformDepthImageToSkeleton`, `NuiImageStreamOpen`, -`NuiImageStreamGetNextFrame`, `NuiImageStreamReleaseFrame`, -`NuiImageStreamSetImageFrameFlags`, `NuiImageStreamGetImageFrameFlags`, -`NuiImageGetColorPixelCoordinatesFromDepthPixel`, `NuiCameraElevationSetAngle`, -`NuiCameraElevationGetAngle`, `NuiSetFrameEndEvent`. +The export ordinals match the real Kinect for Windows 1.8 `Kinect10.dll` +(v1.8.0.595) **exactly**, confirmed against a `dumpbin /exports` of the genuine +DLL: ordinal base 1, a NONAME function at ordinal 1, then ordinals 5-29 (2/3/4 +unused), e.g. `NuiInitialize @14`, `NuiSetDeviceStatusCallback @22`. This matters +because DEA imports by ordinal, not by name (the loader error "the ordinal 22 +could not be located" is a by-ordinal import of `NuiSetDeviceStatusCallback`); an +ordinal mismatch fails the import even when the name is present. The authoritative +map lives in `Kinect10.def`. -This is a **superset** of the minimum DEA imports named in the plan; the exact DEA -import list comes from spike todo 4 (`dumpbin /imports gamekdm.dll`), which is -Windows-gated. Over-exporting is safe (a drop-in must export *no fewer* than the -game imports); if the spike reveals an additional symbol, add it to `Kinect10.def` -and a stub in `src/exports.cpp`. +Functions whose synthesis is out of scope are present only so a by-ordinal import +resolves at load: `NuiGetAudioSource` (no audio) reports no source, +`NuiSkeletonCalculateBoneOrientations` returns S_OK (the game derives pose from +joint positions), and the undocumented `NuiCreateCoordinateMapperFromParameters` / +`NuiCreateDepthFilter` return E_NOTIMPL. This is a **superset** of the minimum DEA +imports; if a future `dumpbin /imports gamekdm.dll` reveals an additional symbol, +add it to `Kinect10.def` at its real ordinal and a stub in `src/exports.cpp`. ### Decoration diff --git a/fallback/windows-nui/src/exports.cpp b/fallback/windows-nui/src/exports.cpp index 54f26cc..f5e0b32 100644 --- a/fallback/windows-nui/src/exports.cpp +++ b/fallback/windows-nui/src/exports.cpp @@ -152,6 +152,46 @@ Vector4 WINAPI NuiTransformDepthImageToSkeleton(LONG lDepthX, HRESULT WINAPI NuiSetFrameEndEvent(HANDLE, DWORD) { return S_OK; } +HRESULT WINAPI NuiImageGetColorPixelCoordinatesFromDepthPixelAtResolution( + NUI_IMAGE_RESOLUTION eColorResolution, + NUI_IMAGE_RESOLUTION, + const NUI_IMAGE_VIEW_AREA*, + LONG lDepthX, + LONG lDepthY, + USHORT, + LONG* plColorX, + LONG* plColorY) { + return ColorCoordinatesFromDepthPixel(eColorResolution, lDepthX, lDepthY, + plColorX, plColorY); +} + +// Audio is not synthesized; report no audio source so the game skips it rather +// than dereferencing a bogus INuiAudioBeam. ppDmo is INuiAudioBeam**. +HRESULT WINAPI NuiGetAudioSource(void** ppDmo) { + if (ppDmo != nullptr) { + *ppDmo = nullptr; + } + return E_NUI_DEVICE_NOT_CONNECTED; +} + +// Bone orientations are derived by the game from joint positions when needed; +// the real export exists so a by-ordinal import (ordinal 27) resolves. +HRESULT WINAPI NuiSkeletonCalculateBoneOrientations(const NUI_SKELETON_DATA*, + void*) { + return S_OK; +} + +// Undocumented 1.8 exports (ordinals 28/29): present so a by-ordinal import +// resolves at load; DEA does not drive these. Signatures match arg counts only. +HRESULT WINAPI NuiCreateCoordinateMapperFromParameters(ULONG, void*, void**) { + return E_NOTIMPL; +} + +HRESULT WINAPI NuiCreateDepthFilter(void**) { return E_NOTIMPL; } + +// Ordinal 1 in the real DLL is NONAME; stubbed so the slot exists. +void* WINAPI KinectShimReserved1(void) { return nullptr; } + } BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD reason, LPVOID) {