Dance around early support (#897)

## Link to GitHub Issue or related Pull Request, if one exists
N/A

## Description of change
This PR add initial supports for running Dance aRound in window mode,
with keyboard, cardio supports.

## Testing
- Tested game play under Windows 10 using Kinect V1 with my visionpose
compatible layer (https://github.com/Avimitin/dance-around-anygear)


https://github.com/user-attachments/assets/4b821dcf-751d-4953-b626-4a9491569183

- Tested full game play, user profile saving with Asphyxia

Assisted by AI.

---------

Co-authored-by: Codex <codex@openai.com>
This commit is contained in:
Jiongjia LuandCodex authored and GitHub committed 2026-09-12 09:51:23 -07:00
1 parent 4042b77065
commit 2b6e76730b
24 files changed
+1567 -31

No files matched your search

+68
View File
@@ -1,5 +1,8 @@
#include "execexe.h"
#include <cstring>
#include "avs/game.h"
#include "util/logging.h"
#include "util/libutils.h"
#include "util/utils.h"
@@ -22,6 +25,23 @@ namespace execexe {
static bool port_opened = false;
static std::function<void()> deferred_function = nullptr;
template<typename T>
static T resolve_export_thunk(T entry) {
// Some execexe builds expose ordinal-only five-byte near jumps backed
// only by INT3 padding. MinHook cannot construct a trampoline from
// those tiny export stubs, while the jump destination has a normal
// prologue.
const auto bytes = reinterpret_cast<const uint8_t *>(entry);
if (!bytes || bytes[0] != 0xE9) {
return entry;
}
int32_t displacement = 0;
std::memcpy(&displacement, bytes + 1, sizeof(displacement));
return reinterpret_cast<T>(
const_cast<uint8_t *>(bytes + 5 + displacement));
}
static HANDLE WINAPI execexe_CreateFileA_hook(LPCSTR lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode,
LPSECURITY_ATTRIBUTES lpSecurityAttributes, DWORD dwCreationDisposition,
DWORD dwFlagsAndAttributes, HANDLE hTemplateFile) {
@@ -92,6 +112,13 @@ namespace execexe {
execexe_CreateFileW = libutils::get_proc<decltype(&CreateFileW)>(execexe_module, MAKEINTRESOURCE(11));
execexe_PreLoadLibraries = libutils::get_proc<decltype(execexe_PreLoadLibraries)>(execexe_module, MAKEINTRESOURCE(48));
if (avs::game::is_model("UDN")) {
execexe_CloseHandle = resolve_export_thunk(execexe_CloseHandle);
execexe_CreateFileA = resolve_export_thunk(execexe_CreateFileA);
execexe_CreateFileW = resolve_export_thunk(execexe_CreateFileW);
execexe_PreLoadLibraries = resolve_export_thunk(execexe_PreLoadLibraries);
}
auto module_path = libutils::module_file_name(nullptr);
module_path = module_path.replace_extension("");
module_path = module_path.replace_filename(module_path.filename().wstring() + L"_Data");
@@ -105,6 +132,30 @@ namespace execexe {
log_fatal("execexe", "deferred init function is already set");
}
deferred_function = std::move(init_func);
// DANCE aROUND calls PreLoadLibraries through kamunity's ordinal
// import. Hook that call site directly: execexe can be loaded in the
// low address range immediately next to the AVS heap, where MinHook
// may be unable to reserve a nearby trampoline page.
if (avs::game::is_model("UDN")) {
const auto kamunity_module = GetModuleHandleW(L"kamunity.dll");
const auto imported_pre_load_libraries = kamunity_module ? detour::iat_try_ordinal(
"execexe.dll",
48,
execexe_PreLoadLibraries_hook,
kamunity_module) : nullptr;
if (imported_pre_load_libraries) {
execexe_PreLoadLibraries = reinterpret_cast<decltype(execexe_PreLoadLibraries)>(
imported_pre_load_libraries);
log_info("execexe", "hooked PreLoadLibraries through kamunity import");
return;
}
detour::trampoline(execexe_PreLoadLibraries,
execexe_PreLoadLibraries_hook, &execexe_PreLoadLibraries);
return;
}
detour::trampoline("execexe.dll", MAKEINTRESOURCE(48),
execexe_PreLoadLibraries_hook, &execexe_PreLoadLibraries);
}
@@ -117,6 +168,16 @@ namespace execexe {
port_name = portName;
acio = acioHandle;
if (avs::game::is_model("UDN")) {
detour::trampoline_try(execexe_CloseHandle,
execexe_CloseHandle_hook, &execexe_CloseHandle);
detour::trampoline_try(execexe_CreateFileA,
execexe_CreateFileA_hook, &execexe_CreateFileA);
detour::trampoline_try(execexe_CreateFileW,
execexe_CreateFileW_hook, &execexe_CreateFileW);
return;
}
detour::trampoline_try("execexe.dll", MAKEINTRESOURCE(7),
execexe_CloseHandle_hook, &execexe_CloseHandle);
detour::trampoline_try("execexe.dll", MAKEINTRESOURCE(9),
@@ -183,6 +244,10 @@ namespace execexe {
HMODULE module = get_module(dll);
FARPROC proc = get_proc(module, func);
if (avs::game::is_model("UDN")) {
// The existing detour helper reads *orig as the target to enable.
*orig = reinterpret_cast<void *>(proc);
}
return detour::trampoline(
reinterpret_cast<void *>(proc),
hook,
@@ -201,6 +266,9 @@ namespace execexe {
return false;
}
if (avs::game::is_model("UDN")) {
*orig = reinterpret_cast<void *>(proc);
}
return detour::trampoline(
reinterpret_cast<void *>(proc),
hook,