Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/deepsource-transform-18fb2fbc'
Browse files Browse the repository at this point in the history
  • Loading branch information
kran27 committed Dec 10, 2024
2 parents 2edbece + dd0ba22 commit cfb1d39
Show file tree
Hide file tree
Showing 20 changed files with 12,745 additions and 12,590 deletions.
19,767 changes: 9,880 additions & 9,887 deletions VBExtender/byte_arrays.h

Large diffs are not rendered by default.

421 changes: 207 additions & 214 deletions VBExtender/defs.h

Large diffs are not rendered by default.

662 changes: 337 additions & 325 deletions VBExtender/functions.h

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion VBExtender/globals.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ constexpr auto version = "v0.1";
static bool useNames = false;

static int selEntity = 0;
const char* entities[64] = {""};
const char *entities[64] = {""};

float entPos[3];

Expand Down
77 changes: 45 additions & 32 deletions VBExtender/hooks.h
Original file line number Diff line number Diff line change
@@ -1,48 +1,61 @@
#pragma once
#include <iostream>

#include "speed.h"
#include "detours.h"
#include "functions.h"
#include "globals.h"
#include "imguiextensions.h"
#include "speed.h"

typedef void (WINAPI* OutputDebugStringAFunc)(LPCSTR lpOutputString);
typedef void(WINAPI *OutputDebugStringAFunc)(LPCSTR lpOutputString);
OutputDebugStringAFunc OriginalOutputDebugStringA;

bool initReady = false;

inline void WINAPI HookedOutputDebugStringA(const LPCSTR lpOutputString)
{
//Only initialize after Client is connected (probably should do this smarter than checking debug strings.)
if (!initReady && strcmp(lpOutputString, "DIALOGUEINTERFACE INSTANTIATED\n - This debug line is to double check that it's not being created more than once.") == 0) initReady = true;

logs.AddLog(lpOutputString);
inline void WINAPI HookedOutputDebugStringA(const LPCSTR lpOutputString) {
// Only initialize after Client is connected (probably should do this smarter
// than checking debug strings.)
if (!initReady &&
strcmp(lpOutputString,
"DIALOGUEINTERFACE INSTANTIATED\n - This debug line is to double "
"check that it's not being created more than once.") == 0)
initReady = true;

logs.AddLog(lpOutputString);

OriginalOutputDebugStringA(lpOutputString);
OriginalOutputDebugStringA(lpOutputString);
}

void InitHooks()
{
HMODULE kernel32 = GetModuleHandleA("kernel32.dll");
HMODULE winmm = GetModuleHandleA("winmm.dll");

OriginalOutputDebugStringA = reinterpret_cast<OutputDebugStringAFunc>(GetProcAddress(kernel32, "OutputDebugStringA"));
g_GetTickCountOriginal = (GetTickCountType)GetProcAddress(kernel32, "GetTickCount");
g_TimeGetTimeOriginal = (GetTickCountType)GetProcAddress(winmm, "timeGetTime");
g_QueryPerformanceCounterOriginal = (QueryPerformanceCounterType)GetProcAddress(kernel32, "QueryPerformanceCounter");

// Setup the speed hack object for the Performance Counter
LARGE_INTEGER performanceCounter;
g_QueryPerformanceCounterOriginal(&performanceCounter);

g_speedHackLL = SpeedHack<LONGLONG>(performanceCounter.QuadPart, kInitialSpeed);

DetourTransactionBegin();
DetourUpdateThread(GetCurrentThread());
DetourAttach(reinterpret_cast<PVOID*>(&OriginalOutputDebugStringA), HookedOutputDebugStringA);
DetourAttach(reinterpret_cast<PVOID*>(&g_GetTickCountOriginal), GetTickCountHacked);
DetourAttach(reinterpret_cast<PVOID*>(&g_TimeGetTimeOriginal), GetTickCountHacked);
DetourAttach(reinterpret_cast<PVOID*>(&g_QueryPerformanceCounterOriginal), QueryPerformanceCounterHacked);
DetourTransactionCommit();
void InitHooks() {
HMODULE kernel32 = GetModuleHandleA("kernel32.dll");
HMODULE winmm = GetModuleHandleA("winmm.dll");

OriginalOutputDebugStringA = reinterpret_cast<OutputDebugStringAFunc>(
GetProcAddress(kernel32, "OutputDebugStringA"));
g_GetTickCountOriginal =
(GetTickCountType)GetProcAddress(kernel32, "GetTickCount");
g_TimeGetTimeOriginal =
(GetTickCountType)GetProcAddress(winmm, "timeGetTime");
g_QueryPerformanceCounterOriginal =
(QueryPerformanceCounterType)GetProcAddress(kernel32,
"QueryPerformanceCounter");

// Setup the speed hack object for the Performance Counter
LARGE_INTEGER performanceCounter;
g_QueryPerformanceCounterOriginal(&performanceCounter);

g_speedHackLL =
SpeedHack<LONGLONG>(performanceCounter.QuadPart, kInitialSpeed);

DetourTransactionBegin();
DetourUpdateThread(GetCurrentThread());
DetourAttach(reinterpret_cast<PVOID *>(&OriginalOutputDebugStringA),
HookedOutputDebugStringA);
DetourAttach(reinterpret_cast<PVOID *>(&g_GetTickCountOriginal),
GetTickCountHacked);
DetourAttach(reinterpret_cast<PVOID *>(&g_TimeGetTimeOriginal),
GetTickCountHacked);
DetourAttach(reinterpret_cast<PVOID *>(&g_QueryPerformanceCounterOriginal),
QueryPerformanceCounterHacked);
DetourTransactionCommit();
}
Loading

0 comments on commit cfb1d39

Please sign in to comment.