1
0
mirror of synced 2024-11-23 22:41:00 +01:00

this wont compile someone pls halp

This commit is contained in:
doomertheboomer 2023-07-26 20:13:03 +07:00
parent 7a5beba9b7
commit f575830f56
5 changed files with 267 additions and 191 deletions

View File

@ -107,6 +107,7 @@
<InlineFunctionExpansion>Disabled</InlineFunctionExpansion> <InlineFunctionExpansion>Disabled</InlineFunctionExpansion>
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed> <FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
<OmitFramePointers>false</OmitFramePointers> <OmitFramePointers>false</OmitFramePointers>
<LanguageStandard>stdcpp20</LanguageStandard>
</ClCompile> </ClCompile>
<Link> <Link>
<SubSystem>Console</SubSystem> <SubSystem>Console</SubSystem>

View File

@ -1,10 +1,10 @@
#include "drs.h" #pragma pack(push)
#include "includes.h"
#include <windows.h> #include <windows.h>
#include <thread> #include <thread>
#include "includes.h"
#pragma pack(push) bool kinectRunning = false;
bool kinectStarted = false;
typedef struct { typedef struct {
union { union {
@ -48,182 +48,260 @@ void (*touch_callback)(
int unk1, int unk1,
const void *user_data); const void *user_data);
namespace drs {
void* TouchSDK_Constructor(void* in) {
return in;
void* TouchSDK_Constructor(void* in) {
return in;
}
bool TouchSDK_SendData(dev_info_t*,
unsigned char* const, int, unsigned char* const,
unsigned char* output, int output_size) {
// fake success
if (output_size >= 4) {
output[0] = 0xfc;
output[1] = 0xa5;
}
return true;
}
bool TouchSDK_SetSignalInit(dev_info_t*, int) {
return true;
}
void TouchSDK_Destructor(void* This) {
}
int TouchSDK_GetYLedTotal(dev_info_t*, int) {
return 53;
}
int TouchSDK_GetXLedTotal(dev_info_t*, int) {
return 41;
}
bool TouchSDK_DisableTouch(dev_info_t*, int) {
return true;
}
bool TouchSDK_DisableDrag(dev_info_t*, int) {
return true;
}
bool TouchSDK_DisableWheel(dev_info_t*, int) {
return true;
}
bool TouchSDK_DisableRightClick(dev_info_t*, int) {
return true;
}
bool TouchSDK_SetMultiTouchMode(dev_info_t*, int) {
return true;
}
bool TouchSDK_EnableTouchWidthData(dev_info_t*, int) {
return true;
}
bool TouchSDK_EnableRawData(dev_info_t*, int) {
return true;
}
bool TouchSDK_SetAllEnable(dev_info_t*, bool, int) {
return true;
}
int TouchSDK_GetTouchDeviceCount(void* This) {
return 1;
}
unsigned int TouchSDK_GetTouchSDKVersion(void) {
return 0x01030307;
}
int TouchSDK_InitTouch(void* This, dev_info_t* devices, int max_devices, void* touch_event_cb,
void* hotplug_callback, void* userdata) {
// fake touch device
memset(devices, 0, sizeof(devices[0].raw));
devices[0].unk1 = 0x1122;
devices[0].unk2 = 0x3344;
devices[0].device_id = 0;
devices[0].vid = 0xDEAD;
devices[0].pid = 0xBEEF;
devices[0].pvn = 0xC0DE;
devices[0].max_point_num = 16;
// remember provided callback and userdata
touch_callback = (decltype(touch_callback))touch_event_cb;
user_data = userdata;
// success
return 1;
}
inline DWORD scale_double_to_xy(double val) {
return static_cast<DWORD>(val * 32768);
}
inline DWORD scale_double_to_height(double val) {
return static_cast<DWORD>(val * 1312);
}
inline DWORD scale_double_to_width(double val) {
return static_cast<DWORD>(val * 1696);
}
void fire_touches(drs_touch_t* events, size_t event_count) {
// check callback first
if (!touch_callback) {
return;
} }
bool TouchSDK_SendData(dev_info_t*, // generate touch data
unsigned char* const, int, unsigned char* const, auto game_touches = std::make_unique<touch_data_t[]>(event_count);
unsigned char* output, int output_size) { for (size_t i = 0; i < event_count; i++) {
// fake success // initialize touch value
if (output_size >= 4) { game_touches[i].cid = (DWORD)events[i].id;
output[0] = 0xfc; game_touches[i].unk8 = 0;
output[1] = 0xa5;
// copy scaled values
game_touches[i].x = scale_double_to_xy(events[i].x);
game_touches[i].y = scale_double_to_xy(events[i].y);
game_touches[i].width = scale_double_to_width(events[i].width);
game_touches[i].height = scale_double_to_height(events[i].height);
// decide touch type
switch (events[i].type) {
case DRS_DOWN:
game_touches[i].type = TS_DOWN;
break;
case DRS_UP:
game_touches[i].type = TS_UP;
break;
case DRS_MOVE:
game_touches[i].type = TS_MOVE;
break;
default:
break;
} }
return true;
} }
bool TouchSDK_SetSignalInit(dev_info_t*, int) { // build device information
return true; dev_info_t dev;
} dev.unk1 = 0;
dev.unk2 = 0;
dev.device_id = 0;
dev.vid = 0xDEAD;
dev.pid = 0xBEEF;
dev.pvn = 0xC0DE;
dev.max_point_num = 16;
void TouchSDK_Destructor(void* This) { // fire callback
} touch_callback(&dev, game_touches.get(), (int)event_count, 0, user_data);
}
int TouchSDK_GetYLedTotal(dev_info_t*, int) { void start_kinect() {
return 53;
}
int TouchSDK_GetXLedTotal(dev_info_t*, int) { if (kinectRunning) return;
return 41; if (!kinectStarted) {
} kinectStarted = true;
std::thread t([] {
puts("starting kinect thread");
bool TouchSDK_DisableTouch(dev_info_t*, int) { // dance floor plane
return true; const float touch_width = 1.f;
} const float touch_height = 1.f;
bool TouchSDK_DisableDrag(dev_info_t*, int) { // main loop
return true; while (kinectRunning) {
}
bool TouchSDK_DisableWheel(dev_info_t*, int) { // iterate foots
return true; for (auto& foot : VR_FOOTS) {
}
bool TouchSDK_DisableRightClick(dev_info_t*, int) {
return true;
}
bool TouchSDK_SetMultiTouchMode(dev_info_t*, int) { // update event details
return true; foot.event.id = foot.id;
} foot.event.x = 0;
foot.event.y = 0;
foot.event.width = 100;
foot.event.height = foot.event.width;
foot.event.type = DRS_DOWN;
bool TouchSDK_EnableTouchWidthData(dev_info_t*, int) { // check previous event
return true; switch (foot.event.type) {
} case DRS_UP:
bool TouchSDK_EnableRawData(dev_info_t*, int) { // generate down event
return true; foot.event.type = DRS_DOWN;
} break;
bool TouchSDK_SetAllEnable(dev_info_t*, bool, int) { case DRS_DOWN:
return true; case DRS_MOVE:
}
int TouchSDK_GetTouchDeviceCount(void* This) { // generate move event
return 1; foot.event.type = DRS_MOVE;
} break;
unsigned int TouchSDK_GetTouchSDKVersion(void) { default:
return 0x01030307; break;
} }
int TouchSDK_InitTouch(void* This, dev_info_t* devices, int max_devices, void* touch_event_cb, // send event
void* hotplug_callback, void* userdata) { fire_touches(&foot.event, 1);
continue;
// fake touch device // foot not intersecting with plane
memset(devices, 0, sizeof(devices[0].raw)); switch (foot.event.type) {
devices[0].unk1 = 0x1122; case DRS_DOWN:
devices[0].unk2 = 0x3344; case DRS_MOVE:
devices[0].device_id = 0;
devices[0].vid = 0xDEAD;
devices[0].pid = 0xBEEF;
devices[0].pvn = 0xC0DE;
devices[0].max_point_num = 16;
// remember provided callback and userdata // generate up event
touch_callback = (decltype(touch_callback))touch_event_cb; foot.event.type = DRS_UP;
user_data = userdata; fire_touches(&foot.event, 1);
break;
// success case DRS_UP:
return 1; default:
} break;
}
}
inline DWORD scale_double_to_xy(double val) { // slow down
return static_cast<DWORD>(val * 32768); std::this_thread::sleep_for(std::chrono::milliseconds(1));
}
inline DWORD scale_double_to_height(double val) {
return static_cast<DWORD>(val * 1312);
}
inline DWORD scale_double_to_width(double val) {
return static_cast<DWORD>(val * 1696);
}
void fire_touches(drs_touch_t* events, size_t event_count) {
// check callback first
if (!touch_callback) {
return;
}
// generate touch data
auto game_touches = std::make_unique<touch_data_t[]>(event_count);
for (size_t i = 0; i < event_count; i++) {
// initialize touch value
game_touches[i].cid = (DWORD)events[i].id;
game_touches[i].unk8 = 0;
// copy scaled values
game_touches[i].x = scale_double_to_xy(events[i].x);
game_touches[i].y = scale_double_to_xy(events[i].y);
game_touches[i].width = scale_double_to_width(events[i].width);
game_touches[i].height = scale_double_to_height(events[i].height);
// decide touch type
switch (events[i].type) {
case DRS_DOWN:
game_touches[i].type = TS_DOWN;
break;
case DRS_UP:
game_touches[i].type = TS_UP;
break;
case DRS_MOVE:
game_touches[i].type = TS_MOVE;
break;
default:
break;
} }
} kinectStarted = false;
return nullptr;
// build device information });
dev_info_t dev; t.detach();
dev.unk1 = 0;
dev.unk2 = 0;
dev.device_id = 0;
dev.vid = 0xDEAD;
dev.pid = 0xBEEF;
dev.pvn = 0xC0DE;
dev.max_point_num = 16;
// fire callback
touch_callback(&dev, game_touches.get(), (int)event_count, 0, user_data);
} }
void hookDancepad() { }
MH_Initialize();
MH_CreateHookApi(L"TouchSDKDll.dll", "??0TouchSDK@@QEAA@XZ", TouchSDK_Constructor, NULL);
MH_CreateHookApi(L"TouchSDKDll.dll", "?SendData@TouchSDK@@QEAA_NU_DeviceInfo@@QEAEH1HH@Z", TouchSDK_SendData, NULL);
MH_CreateHookApi(L"TouchSDKDll.dll", "?SetSignalInit@TouchSDK@@QEAA_NU_DeviceInfo@@H@Z", TouchSDK_SetSignalInit, NULL);
MH_CreateHookApi(L"TouchSDKDll.dll", "?GetYLedTotal@TouchSDK@@QEAAHU_DeviceInfo@@H@Z", TouchSDK_GetYLedTotal, NULL);
MH_CreateHookApi(L"TouchSDKDll.dll", "?GetXLedTotal@TouchSDK@@QEAAHU_DeviceInfo@@H@Z", TouchSDK_GetXLedTotal, NULL);
MH_CreateHookApi(L"TouchSDKDll.dll", "?DisableTouch@TouchSDK@@QEAA_NU_DeviceInfo@@H@Z", TouchSDK_DisableTouch, NULL);
MH_CreateHookApi(L"TouchSDKDll.dll", "?DisableDrag@TouchSDK@@QEAA_NU_DeviceInfo@@H@Z", TouchSDK_DisableDrag, NULL);
MH_CreateHookApi(L"TouchSDKDll.dll", "?DisableWheel@TouchSDK@@QEAA_NU_DeviceInfo@@H@Z", TouchSDK_DisableWheel, NULL);
MH_CreateHookApi(L"TouchSDKDll.dll", "?DisableRightClick@TouchSDK@@QEAA_NU_DeviceInfo@@H@Z", TouchSDK_DisableRightClick, NULL);
MH_CreateHookApi(L"TouchSDKDll.dll", "?SetMultiTouchMode@TouchSDK@@QEAA_NU_DeviceInfo@@H@Z", TouchSDK_SetMultiTouchMode, NULL);
MH_CreateHookApi(L"TouchSDKDll.dll", "?EnableTouchWidthData@TouchSDK@@QEAA_NU_DeviceInfo@@H@Z", TouchSDK_EnableTouchWidthData, NULL);
MH_CreateHookApi(L"TouchSDKDll.dll", "?EnableRawData@TouchSDK@@QEAA_NU_DeviceInfo@@H@Z", TouchSDK_EnableRawData, NULL);
MH_CreateHookApi(L"TouchSDKDll.dll", "?SetAllEnable@TouchSDK@@QEAA_NU_DeviceInfo@@_NH@Z", TouchSDK_SetAllEnable, NULL);
MH_CreateHookApi(L"TouchSDKDll.dll", "?GetTouchDeviceCount@TouchSDK@@QEAAHXZ", TouchSDK_GetTouchDeviceCount, NULL);
MH_CreateHookApi(L"TouchSDKDll.dll", "?GetTouchSDKVersion@TouchSDK@@QEAAIXZ", TouchSDK_GetTouchSDKVersion, NULL);
MH_CreateHookApi(L"TouchSDKDll.dll", "?InitTouch@TouchSDK@@QEAAHPEAU_DeviceInfo@@HP6AXU2@PEBU_TouchPointData@@HHPEBX@ZP6AX1_N3@ZPEAX@Z", TouchSDK_InitTouch, NULL);
MH_EnableHook(MH_ALL_HOOKS); void hookDancepad() {
} MH_Initialize();
MH_CreateHookApi(L"TouchSDKDll.dll", "??0TouchSDK@@QEAA@XZ", TouchSDK_Constructor, NULL);
MH_CreateHookApi(L"TouchSDKDll.dll", "?SendData@TouchSDK@@QEAA_NU_DeviceInfo@@QEAEH1HH@Z", TouchSDK_SendData, NULL);
MH_CreateHookApi(L"TouchSDKDll.dll", "?SetSignalInit@TouchSDK@@QEAA_NU_DeviceInfo@@H@Z", TouchSDK_SetSignalInit, NULL);
MH_CreateHookApi(L"TouchSDKDll.dll", "?GetYLedTotal@TouchSDK@@QEAAHU_DeviceInfo@@H@Z", TouchSDK_GetYLedTotal, NULL);
MH_CreateHookApi(L"TouchSDKDll.dll", "?GetXLedTotal@TouchSDK@@QEAAHU_DeviceInfo@@H@Z", TouchSDK_GetXLedTotal, NULL);
MH_CreateHookApi(L"TouchSDKDll.dll", "?DisableTouch@TouchSDK@@QEAA_NU_DeviceInfo@@H@Z", TouchSDK_DisableTouch, NULL);
MH_CreateHookApi(L"TouchSDKDll.dll", "?DisableDrag@TouchSDK@@QEAA_NU_DeviceInfo@@H@Z", TouchSDK_DisableDrag, NULL);
MH_CreateHookApi(L"TouchSDKDll.dll", "?DisableWheel@TouchSDK@@QEAA_NU_DeviceInfo@@H@Z", TouchSDK_DisableWheel, NULL);
MH_CreateHookApi(L"TouchSDKDll.dll", "?DisableRightClick@TouchSDK@@QEAA_NU_DeviceInfo@@H@Z", TouchSDK_DisableRightClick, NULL);
MH_CreateHookApi(L"TouchSDKDll.dll", "?SetMultiTouchMode@TouchSDK@@QEAA_NU_DeviceInfo@@H@Z", TouchSDK_SetMultiTouchMode, NULL);
MH_CreateHookApi(L"TouchSDKDll.dll", "?EnableTouchWidthData@TouchSDK@@QEAA_NU_DeviceInfo@@H@Z", TouchSDK_EnableTouchWidthData, NULL);
MH_CreateHookApi(L"TouchSDKDll.dll", "?EnableRawData@TouchSDK@@QEAA_NU_DeviceInfo@@H@Z", TouchSDK_EnableRawData, NULL);
MH_CreateHookApi(L"TouchSDKDll.dll", "?SetAllEnable@TouchSDK@@QEAA_NU_DeviceInfo@@_NH@Z", TouchSDK_SetAllEnable, NULL);
MH_CreateHookApi(L"TouchSDKDll.dll", "?GetTouchDeviceCount@TouchSDK@@QEAAHXZ", TouchSDK_GetTouchDeviceCount, NULL);
MH_CreateHookApi(L"TouchSDKDll.dll", "?GetTouchSDKVersion@TouchSDK@@QEAAIXZ", TouchSDK_GetTouchSDKVersion, NULL);
MH_CreateHookApi(L"TouchSDKDll.dll", "?InitTouch@TouchSDK@@QEAAHPEAU_DeviceInfo@@HP6AXU2@PEBU_TouchPointData@@HHPEBX@ZP6AX1_N3@ZPEAX@Z", TouchSDK_InitTouch, NULL);
MH_EnableHook(MH_ALL_HOOKS);
} }

View File

@ -1,43 +1,41 @@
#pragma once #pragma once
namespace drs { enum DRS_TOUCH_TYPE {
DRS_DOWN = 0,
DRS_UP = 1,
DRS_MOVE = 2,
};
enum DRS_TOUCH_TYPE { typedef struct drs_touch_t {
DRS_DOWN = 0, int type = DRS_UP;
DRS_UP = 1, int id = 0;
DRS_MOVE = 2, double x = 0.0;
}; double y = 0.0;
double width = 1;
double height = 1;
};
typedef struct drs_touch_t { struct VRFoot {
int type = DRS_UP; unsigned int id;
int id = 0; unsigned int index = 2;
double x = 0.0; float length = 3.1;
double y = 0.0; float size_base = 0.05;
double width = 1; float size_scale = 0.1;
double height = 1; float height = 3;
}; //linalg::aliases::float4 rotation {0, 0, 0, 1};
drs_touch_t event{};
//linalg::aliases::float3 to_world(linalg::aliases::float3 pos);
};
struct VRFoot { extern char DRS_TAPELED[38 * 49][3];
unsigned int id; //extern linalg::aliases::float3 VR_SCALE;
unsigned int index = 2; //extern linalg::aliases::float3 VR_OFFSET;
float length = 3.1; extern float VR_ROTATION;
float size_base = 0.05; extern VRFoot VR_FOOTS[2];
float size_scale = 0.1;
float height = 3;
//linalg::aliases::float4 rotation {0, 0, 0, 1};
drs_touch_t event{};
//unsigned int get_index();
//linalg::aliases::float3 to_world(linalg::aliases::float3 pos);
};
extern char DRS_TAPELED[38 * 49][3];
//extern linalg::aliases::float3 VR_SCALE;
//extern linalg::aliases::float3 VR_OFFSET;
extern float VR_ROTATION;
extern VRFoot VR_FOOTS[2];
void fire_touches(drs_touch_t* events, size_t event_count);
//void start_vr();
void hookDancepad(); void fire_touches(drs_touch_t* events, size_t event_count);
} void start_kinect();
void hookDancepad();

View File

@ -7,7 +7,7 @@
#include "kiero/minhook/include/MinHook.h" #include "kiero/minhook/include/MinHook.h"
#include "kiero/injector/injector.hpp" #include "kiero/injector/injector.hpp"
#include "d3d9.h" #include "d3d9.h"
#include "drs.h"
typedef LRESULT(CALLBACK* WNDPROC)(HWND, UINT, WPARAM, LPARAM); typedef LRESULT(CALLBACK* WNDPROC)(HWND, UINT, WPARAM, LPARAM);
typedef uintptr_t PTR; typedef uintptr_t PTR;

View File

@ -1,5 +1,4 @@
#include "includes.h" #include "includes.h"
#include "drs.h"
static uintptr_t imageBase; static uintptr_t imageBase;
@ -45,7 +44,7 @@ BOOL WINAPI DllMain(HMODULE hMod, DWORD dwReason, LPVOID lpReserved)
case DLL_PROCESS_ATTACH: case DLL_PROCESS_ATTACH:
DisableThreadLibraryCalls(hMod); DisableThreadLibraryCalls(hMod);
imageBase = (uintptr_t)GetModuleHandleA(0); imageBase = (uintptr_t)GetModuleHandleA(0);
drs::hookDancepad(); hookDancepad();
break; break;
} }