-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdllmain.cpp
More file actions
47 lines (38 loc) · 1.05 KB
/
dllmain.cpp
File metadata and controls
47 lines (38 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
//
// NFSU2 EAXSound::Update Delta Time Fix
//
#include "framework.h"
#include "injector.hpp"
constexpr const float MinDeltaTime = (1.0f / 60.0f);
uintptr_t pEAXSound_Update;
#pragma runtime_checks("", off)
static void __stdcall EAXSound_Update_Hook(float t)
{
void* that;
_asm mov that, ecx
// clamp min deltatime to 1/60 to avoid slowness...
float newDT = t;
if ((newDT < MinDeltaTime) && (newDT > 0.0f))
newDT = MinDeltaTime;
return reinterpret_cast<void(__thiscall*)(void*, float)>(pEAXSound_Update)(that, newDT);
}
#pragma runtime_checks("", restore)
void Init()
{
uintptr_t loc_5814A8 = 0x5814A8;
pEAXSound_Update = static_cast<uintptr_t>(injector::GetBranchDestination(loc_5814A8));
injector::MakeCALL(loc_5814A8, EAXSound_Update_Hook);
}
BOOL APIENTRY DllMain( HMODULE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
switch (ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
Init();
break;
}
return TRUE;
}