-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinject_speedrunners.cpp
More file actions
39 lines (34 loc) · 1.19 KB
/
Copy pathinject_speedrunners.cpp
File metadata and controls
39 lines (34 loc) · 1.19 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
#include <Windows.h>
#include "inject_speedrunners.h"
BOOL WINAPI DllMain(HINSTANCE hDLL, DWORD dwReason, LPVOID lpReserve)
{
/*if (dwReason == DLL_PROCESS_ATTACH)
{
::MessageBoxA(NULL, (LPCSTR)"My fucking code.", (LPCSTR)"Tired of this shit", NULL);
}*/
return true;
}
struct userdata {
char __unknown[0x70];
wchar_t* username; // wchar starts at offset +8 bytes
char __unknown2[0x23C - 0x70 - sizeof(username)];
float boost;
};
__declspec(dllexport) int dll_callback_impl(struct DllConfig* dllconfig, struct userdata* userdata, float* _new_value) {
if (lstrcmpW(userdata->username + 4, dllconfig->username)) {
return 0;
}
float new_value = *_new_value;
float old_value = userdata->boost;
float factor = dllconfig->boost_factor;
if (new_value < 0.001f) {
new_value = 0.0f;
} else if (new_value < old_value) {
new_value = old_value - ((old_value - new_value) * factor);
}
*_new_value = new_value;
return 0;
}
extern "C" __declspec(dllexport) int __stdcall dll_callback(struct DllConfig* dllconfig, struct userdata* userdata, float* _new_value) {
return dll_callback_impl(dllconfig, userdata, _new_value);
}