Initial Commit
This commit is contained in:
142
library/library.cpp
Normal file
142
library/library.cpp
Normal file
@@ -0,0 +1,142 @@
|
||||
|
||||
#include <Windows.h>
|
||||
#include <iostream>
|
||||
|
||||
#include "library.h"
|
||||
#include "include/MinHook.h"
|
||||
|
||||
// f3 0f 11 8f 98 0b 00 00
|
||||
|
||||
byte orig_place[] = {0xf3, 0x0f, 0x11, 0x8f, 0x98, 0x0b, 0x00, 0x00};
|
||||
|
||||
byte* rekordbox_base;
|
||||
|
||||
|
||||
|
||||
struct ChannelInfo {
|
||||
byte unk[288];
|
||||
double bpm;
|
||||
UINT64 unk2[2];
|
||||
double secondsElapsed;
|
||||
UINT64 unk3;
|
||||
double beat; // 328 + 8 = 336
|
||||
double beatRounded; // 336 + 8 = 344
|
||||
byte unk4[76];
|
||||
byte isPlaying;
|
||||
};
|
||||
|
||||
typedef INT64(*updateChannelInfo)(ChannelInfo* channelInfo);
|
||||
updateChannelInfo pUpdateChannelInfo = nullptr;
|
||||
|
||||
UINT64 count = 0;
|
||||
BOOL shouldPrint = false;
|
||||
INT64 detourUpdateChannelInfo(ChannelInfo* channelInfo) {
|
||||
count++;
|
||||
|
||||
if(shouldPrint && count % 101 == 0) {
|
||||
printf("Channel: 0x%llx\n", (UINT64)channelInfo);
|
||||
printf("BPM: %f\n", channelInfo->bpm );
|
||||
printf("Time: %f\n", channelInfo->secondsElapsed );
|
||||
printf("Beat: %f\n", channelInfo->beat );
|
||||
printf("~Beat: %f\n", channelInfo->beatRounded );
|
||||
printf("RelBeat: %i/4\n", ((int)channelInfo->beatRounded) % 4);
|
||||
printf("RelBeatF: %f\n", (channelInfo->beat - channelInfo->beatRounded) + ((int)channelInfo->beatRounded) % 4 );
|
||||
printf("isPlaying: %i\n", channelInfo->isPlaying );
|
||||
printf("--------------------\n");
|
||||
}
|
||||
|
||||
INT64 result = pUpdateChannelInfo(channelInfo);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
// Hook SyncManager? function
|
||||
typedef UINT64(*syncManager)(UINT64* param1);
|
||||
syncManager pSyncManager = nullptr;
|
||||
|
||||
ChannelInfo* master = nullptr;
|
||||
|
||||
UINT64 detourSyncManager(UINT64* param1) {
|
||||
auto new_master = (ChannelInfo*)param1[0x1e];
|
||||
|
||||
if(master != new_master && new_master != nullptr) {
|
||||
master = new_master;
|
||||
printf("--------------------\n");
|
||||
printf("New master: %llx\n", (UINT64)master);
|
||||
printf("--------------------\n");
|
||||
}
|
||||
|
||||
UINT64 result = pSyncManager(param1);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
BOOL WINAPI DllMain(HMODULE hModule, DWORD dwReason, LPVOID lpReserved) {
|
||||
if (dwReason == DLL_PROCESS_ATTACH) {
|
||||
DisableThreadLibraryCalls(hModule); //disables attach and detach notifications
|
||||
CreateThread(NULL, NULL, (LPTHREAD_START_ROUTINE) entry, NULL, NULL, NULL); //creates a new thread and starts at function entry()
|
||||
}
|
||||
else if (dwReason == DLL_PROCESS_DETACH) {
|
||||
printf("Unloading RekordUnBox\n");
|
||||
MH_Uninitialize();
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
void entry() {
|
||||
AllocConsole();
|
||||
FILE* fp;
|
||||
freopen_s(&fp, "CONOUT$", "w", stdout);
|
||||
|
||||
rekordbox_base = (byte*) GetModuleHandleA("rekordbox.exe");
|
||||
|
||||
printf("Injected RekordUnBox\n");\
|
||||
printf("Rekordbox Base: 0x%ux\n", (unsigned long)rekordbox_base);
|
||||
|
||||
// Print 8 bytes at rekordbox.exe+0x193c8b0
|
||||
byte* updateChannelInfo_location = (byte*)(rekordbox_base + 0x1acd290);
|
||||
|
||||
if (MH_Initialize() != MH_OK) {
|
||||
printf("Failed to initialize MinHook\n");
|
||||
fclose(fp);
|
||||
return;
|
||||
}
|
||||
|
||||
printf("Successfully initialized MinHook\n");
|
||||
|
||||
|
||||
MH_STATUS status;
|
||||
|
||||
// Update loop
|
||||
status = MH_CreateHook(updateChannelInfo_location, &detourUpdateChannelInfo, reinterpret_cast<void**>(&pUpdateChannelInfo));
|
||||
if(status != MH_OK) {
|
||||
printf("Error: Couldn't hook updateChannelInfo!\nError: %s", MH_StatusToString(status));
|
||||
fclose(fp);
|
||||
return;
|
||||
}
|
||||
|
||||
// SyncManager
|
||||
status = MH_CreateHook((byte*)(rekordbox_base + 0x18f7630), &detourSyncManager, reinterpret_cast<void**>(&pSyncManager));
|
||||
if(status != MH_OK) {
|
||||
printf("Error: Couldn't hook syncManager!\nError: %s", MH_StatusToString(status));
|
||||
fclose(fp);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if(MH_EnableHook(MH_ALL_HOOKS) != MH_OK) {
|
||||
printf("Error: Couldn't enable hooks!\n");
|
||||
fclose(fp);
|
||||
return;
|
||||
}
|
||||
|
||||
while (true) {
|
||||
if (master != nullptr) {
|
||||
printf("Master: %f\n", master->beat);
|
||||
}
|
||||
|
||||
Sleep(1000);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user