Skip to content
This repository was archived by the owner on Apr 29, 2023. It is now read-only.

Commit a71f237

Browse files
committed
alter the timer to allow faster frame drawing
1 parent aa900fe commit a71f237

File tree

5 files changed

+49
-8
lines changed

5 files changed

+49
-8
lines changed

.vscode/settings.json

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"files.associations": {
3+
"ostream": "cpp"
4+
}
5+
}

config.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
22
"fake_cpu_count": 1024,
3-
"block_width": 43
3+
"block_width": 43,
4+
"modifed_time":5
45
}

src/dll/dllmain.cpp

+35-6
Original file line numberDiff line numberDiff line change
@@ -20,21 +20,26 @@ Repo: https://github.com/turtiustrek/taskmanager
2020
#include <shlwapi.h>
2121

2222
using namespace rapidjson;
23-
//you can change these
23+
2424
short fakeCores = 0;
2525
int blockWidth = 0;
26-
//#define SHOW_BITMAP_SCAN_MSG //shows what files are being loaded into memory. If you have alot of bitmaps keep this commented.
2726

2827
mem_voidptr_t UpdateData = (mem_voidptr_t)MEM_BAD;
2928
mem_voidptr_t GetBlockWidth = (mem_voidptr_t)MEM_BAD;
3029
mem_voidptr_t IsServer = (mem_voidptr_t)MEM_BAD;
30+
mem_voidptr_t SetRefreshRate = (mem_voidptr_t)MEM_BAD;
31+
3132
void *handler = (mem_voidptr_t)MEM_BAD;
3233
void *GlobalSettings = (mem_voidptr_t)MEM_BAD;
3334

3435
int __fastcall (*GetBlockColors)(void *, int core, long *background, long *border);
3536
int __fastcall (*SetBlockData)(void *, int, const wchar_t *string, long background, long border);
3637
//Position inside the GLOBAL_SETTINGS_TASKMGR
3738
#define GLOBAL_SETTINGS_CPU_OFFSET 0x944 //not relative to BaseAdress but GLOBAL_SETTINGS_TASKMGR
39+
//Global
40+
uint32_t actualTime;
41+
uint32_t modifedTime;
42+
mem_voidptr_t timeHandle;
3843
//task manager handle
3944
mem_module_t mod = {0};
4045
mem_tstring_t process_path = (mem_tstring_t)NULL;
@@ -85,6 +90,22 @@ int64_t __fastcall UpdateDataHook(void *ret)
8590

8691
return 1;
8792
}
93+
//This function alters the draw timer.
94+
//This also wrties to a global variable apparently, so on the next re-launch this value would be used for the timer instead in the task manager
95+
typedef bool (*SetRefreshRateOrig_t)(void *ret, uint32_t time);
96+
SetRefreshRateOrig_t SetRefreshRateOrig;
97+
int64_t __fastcall SetRefreshRateHook(void *ret, uint32_t time)
98+
{
99+
actualTime = time;
100+
if (modifedTime != 0)
101+
{
102+
return SetRefreshRateOrig(ret, modifedTime);
103+
}
104+
else
105+
{
106+
return SetRefreshRateOrig(ret, time);
107+
}
108+
}
88109
//Used to alter the size of the block
89110
int64_t __fastcall GetBlockWidthHook(void *ret)
90111
{
@@ -196,7 +217,10 @@ DWORD WINAPI attach(LPVOID dllHandle)
196217
std::cout << "Finding SetBlockData function...";
197218
SetBlockData = (decltype(SetBlockData))(mem::in::scan(table[i].SetBlockDataPattern, PATTERN_BYTES, mod.base, mod.end));
198219
printnullptr(hConsole, (void *)SetBlockData);
199-
if (UpdateData == (mem_voidptr_t)MEM_BAD || GetBlockWidth == (mem_voidptr_t)MEM_BAD || IsServer == (mem_voidptr_t)MEM_BAD || GetBlockColors == (mem_voidptr_t)MEM_BAD || SetBlockData == (mem_voidptr_t)MEM_BAD)
220+
std::cout << "Finding SetRefreshRate function...";
221+
SetRefreshRate = (decltype(SetRefreshRate))(mem::in::scan(table[i].SetRefreshRatePattern, PATTERN_BYTES, mod.base, mod.end));
222+
printnullptr(hConsole, (void *)SetBlockData);
223+
if (UpdateData == (mem_voidptr_t)MEM_BAD || GetBlockWidth == (mem_voidptr_t)MEM_BAD || IsServer == (mem_voidptr_t)MEM_BAD || GetBlockColors == (mem_voidptr_t)MEM_BAD || SetBlockData == (mem_voidptr_t)MEM_BAD || SetRefreshRate == (mem_voidptr_t)MEM_BAD)
200224
{
201225
//break if all tables have been checked
202226
if (i == (sizeof(table) / sizeof(table[0])) - 1)
@@ -215,7 +239,7 @@ DWORD WINAPI attach(LPVOID dllHandle)
215239
break;
216240
}
217241
}
218-
if (UpdateData == (mem_voidptr_t)MEM_BAD || GetBlockWidth == (mem_voidptr_t)MEM_BAD || IsServer == (mem_voidptr_t)MEM_BAD || GetBlockColors == (mem_voidptr_t)MEM_BAD || SetBlockData == (mem_voidptr_t)MEM_BAD)
242+
if (UpdateData == (mem_voidptr_t)MEM_BAD || GetBlockWidth == (mem_voidptr_t)MEM_BAD || IsServer == (mem_voidptr_t)MEM_BAD || GetBlockColors == (mem_voidptr_t)MEM_BAD || SetBlockData == (mem_voidptr_t)MEM_BAD || SetRefreshRate == (mem_voidptr_t)MEM_BAD)
219243
{
220244
SetConsoleTextAttribute(hConsole, 12);
221245
std::cout << "One or more functions were not found, waiting for exit" << std::endl;
@@ -251,6 +275,10 @@ DWORD WINAPI attach(LPVOID dllHandle)
251275
{
252276
blockWidth = 1;
253277
}
278+
modifedTime = configs["modifed_time"].GetInt();
279+
if(modifedTime < 1){
280+
modifedTime = actualTime;
281+
}
254282
free(fileptr);
255283
fileptr = NULL;
256284
}
@@ -276,10 +304,12 @@ DWORD WINAPI attach(LPVOID dllHandle)
276304
CloseHandle(hFile);
277305
std::cout << "Fake core count: " << fakeCores << std::endl;
278306
std::cout << "Block width: " << blockWidth << std::endl;
307+
std::cout << "Modified Time: " << modifedTime << "ms" << std::endl;
279308
//Gateway is NOT used! IsServer might be problamatic
280309
mem::in::detour_trampoline(UpdateData, (void *)UpdateDataHook, mem::in::detour_size(MEM_ASM_x86_JMP64), MEM_ASM_x86_JMP64);
281310
mem::in::detour_trampoline(IsServer, (void *)IsServerHook, mem::in::detour_size(MEM_ASM_x86_JMP64), MEM_ASM_x86_JMP64);
282311
mem::in::detour_trampoline(GetBlockWidth, (void *)GetBlockWidthHook, mem::in::detour_size(MEM_ASM_x86_JMP64), MEM_ASM_x86_JMP64);
312+
SetRefreshRateOrig = (SetRefreshRateOrig_t)mem::in::detour_trampoline(SetRefreshRate, (void *)SetRefreshRateHook, mem::in::detour_size(MEM_ASM_x86_JMP64) + 2, MEM_ASM_x86_JMP64);
283313
std::cout << "Waiting for GlobalSettings to populate...";
284314
while (GlobalSettings == (mem_voidptr_t)MEM_BAD)
285315
{
@@ -503,9 +533,8 @@ extern "C" BOOL APIENTRY DllMain(HMODULE hModule,
503533
if (bitmapPixels != (char *)MEM_BAD)
504534
{
505535
free(bitmapPixels);
506-
MessageBoxW(NULL, L"DLL exited successfully", L"Info", MB_ICONINFORMATION);
507536
}
508-
537+
MessageBoxW(NULL, L"DLL exited successfully", L"Info", MB_ICONINFORMATION);
509538
break;
510539
}
511540
return TRUE;

src/dll/pattern.hpp

+6
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ struct LookupPatternTable
1212
mem_byte_t GetBlockColorsPattern[PATTERN_BYTES]; //{void __fastcall CpuHeatMap::GetBlockColors(CpuHeatMap *this, int a2, unsigned int *a3, unsigned int *a4)}
1313
mem_byte_t SetBlockDataPattern[PATTERN_BYTES]; //{__int64 __fastcall CpuHeatMap::SetBlockData(CpuHeatMap *this, unsigned int a2, const unsigned __int16 *a3, unsigned int a4, unsigned int a5)}
1414
mem_byte_t IsServerPattern[PATTERN_BYTES]; //{bool __fastcall RunTimeSettings::IsServer(RunTimeSettings *this)}
15+
mem_byte_t SetRefreshRatePattern[PATTERN_BYTES]; //{__int64 __fastcall TmTraceControl::SetRefreshRate(__int64 a1, UINT time)}
1516
std::string version; //verison of task manager running; can be found under the details of TaskMgr.exe.
1617
};
1718
LookupPatternTable table[] = {
@@ -20,31 +21,36 @@ LookupPatternTable table[] = {
2021
{0x48, 0x89, 0x5C, 0x24, 0x08, 0x48, 0x89, 0x74, 0x24, 0x10, 0x57, 0x48, 0x83, 0xEC, 0x20, 0x65, 0x48, 0x8B, 0x04, 0x25, 0x58, 0x00, 0x00, 0x00, 0x8B, 0xDA, 0xBA, 0x04, 0x00, 0x00, 0x00, 0x49, 0x8B, 0xF9, 0x49, 0x8B, 0xF0, 0x48, 0x8B, 0x08},
2122
{0x48, 0x89, 0x5C, 0x24, 0x08, 0x48, 0x89, 0x6C, 0x24, 0x10, 0x48, 0x89, 0x74, 0x24, 0x18, 0x57, 0x41, 0x56, 0x41, 0x57, 0x48, 0x83, 0xEC, 0x30, 0x48, 0x8B, 0x41, 0x28, 0x48, 0x8B, 0xF9, 0x44, 0x8B, 0xDA, 0x41, 0x8B, 0xE9, 0x8B, 0xF2, 0x4D},
2223
{0x40, 0x53, 0x48, 0x81, 0xEC, 0x60, 0x01, 0x00, 0x00, 0x48, 0x8B, 0x05, 0xB4, 0xDB, 0x0F, 0x00, 0x48, 0x33, 0xC4, 0x48, 0x89, 0x84, 0x24, 0x50, 0x01, 0x00, 0x00, 0x83, 0xB9, 0x2C, 0x09, 0x00, 0x00, 0x00, 0x48, 0x8B, 0xD9, 0x74, 0x24, 0x83},
24+
{0x48, 0x89, 0x5C, 0x24, 0x08, 0x48, 0x89, 0x6C, 0x24, 0x10, 0x48, 0x89, 0x74, 0x24, 0x18, 0x57, 0x48, 0x83, 0xEC, 0x20, 0x89, 0x15, 0x2E, 0x9E, 0x0B, 0x00, 0x48, 0x8B, 0xE9, 0x48, 0x8B, 0x59, 0x60, 0x8B, 0xFA, 0x48, 0x8B, 0xCB, 0x33, 0xF6},
2325
"10.0.19041.844"},
2426
{{0x48, 0x89, 0x5C, 0x24, 0x10, 0x48, 0x89, 0x74, 0x24, 0x18, 0x55, 0x57, 0x41, 0x56, 0x48, 0x8D, 0x6C, 0x24, 0xC0, 0x48, 0x81, 0xEC, 0x40, 0x01, 0x00, 0x00, 0x48, 0x8B, 0x05, 0xB7, 0xD4, 0x04, 0x00, 0x48, 0x33, 0xC4, 0x48, 0x89, 0x45, 0x30},
2527
{0x48, 0x83, 0xEC, 0x58, 0x48, 0x8B, 0x05, 0xD9, 0xDE, 0x04, 0x00, 0x48, 0x33, 0xC4, 0x48, 0x89, 0x44, 0x24, 0x48, 0x66, 0x0F, 0x6F, 0x05, 0x99, 0xC5, 0x02, 0x00, 0x66, 0x0F, 0x6F, 0x0D, 0x81, 0xC5, 0x02, 0x00, 0x8B, 0x05, 0x53, 0x0C, 0x05},
2628
{0x48, 0x89, 0x5C, 0x24, 0x08, 0x48, 0x89, 0x74, 0x24, 0x10, 0x57, 0x48, 0x83, 0xEC, 0x20, 0x65, 0x48, 0x8B, 0x04, 0x25, 0x58, 0x00, 0x00, 0x00, 0x8B, 0xDA, 0xBA, 0x04, 0x00, 0x00, 0x00, 0x49, 0x8B, 0xF9, 0x49, 0x8B, 0xF0, 0x48, 0x8B, 0x08},
2729
{0x48, 0x89, 0x5C, 0x24, 0x08, 0x48, 0x89, 0x6C, 0x24, 0x10, 0x48, 0x89, 0x74, 0x24, 0x18, 0x57, 0x41, 0x56, 0x41, 0x57, 0x48, 0x83, 0xEC, 0x30, 0x48, 0x8B, 0x41, 0x28, 0x48, 0x8B, 0xF9, 0x44, 0x8B, 0xDA, 0x41, 0x8B, 0xE9, 0x8B, 0xF2, 0x4D},
2830
{0x40, 0x53, 0x48, 0x81, 0xEC, 0x60, 0x01, 0x00, 0x00, 0x48, 0x8B, 0x05, 0xB4, 0xDB, 0x0F, 0x00, 0x48, 0x33, 0xC4, 0x48, 0x89, 0x84, 0x24, 0x50, 0x01, 0x00, 0x00, 0x83, 0xB9, 0x2C, 0x09, 0x00, 0x00, 0x00, 0x48, 0x8B, 0xD9, 0x74, 0x24, 0x83},
31+
{0x48, 0x89, 0x5C, 0x24, 0x08, 0x48, 0x89, 0x6C, 0x24, 0x10, 0x48, 0x89, 0x74, 0x24, 0x18, 0x57, 0x48, 0x83, 0xEC, 0x20, 0x89, 0x15, 0x1E, 0xA1, 0x0B, 0x00, 0x48, 0x8B, 0xE9, 0x48, 0x8B, 0x59, 0x60, 0x8B, 0xFA, 0x48, 0x8B, 0xCB, 0x33, 0xF6},
2932
"10.0.19041.746"},
3033
{{0x48, 0x89, 0x5C, 0x24, 0x10, 0x48, 0x89, 0x74, 0x24, 0x18, 0x55, 0x57, 0x41, 0x56, 0x48, 0x8D, 0x6C, 0x24, 0xC0, 0x48, 0x81, 0xEC, 0x40, 0x01, 0x00, 0x00, 0x48, 0x8B, 0x05, 0x37, 0xB5, 0x04, 0x00, 0x48, 0x33, 0xC4, 0x48, 0x89, 0x45, 0x30},
3134
{0x48, 0x83, 0xEC, 0x58, 0x48, 0x8B, 0x05, 0x69, 0xBE, 0x04, 0x00, 0x48, 0x33, 0xC4, 0x48, 0x89, 0x44, 0x24, 0x48, 0x66, 0x0F, 0x6F, 0x05, 0xC9, 0xF4, 0x02, 0x00, 0x66, 0x0F, 0x6F, 0x0D, 0xB1, 0xF4, 0x02, 0x00, 0x8B, 0x05, 0x8B, 0xEB, 0x04},
3235
{0x48, 0x89, 0x5C, 0x24, 0x08, 0x48, 0x89, 0x74, 0x24, 0x10, 0x57, 0x48, 0x83, 0xEC, 0x20, 0x65, 0x48, 0x8B, 0x04, 0x25, 0x58, 0x00, 0x00, 0x00, 0x8B, 0xDA, 0xBA, 0x04, 0x00, 0x00, 0x00, 0x49, 0x8B, 0xF9, 0x49, 0x8B, 0xF0, 0x48, 0x8B, 0x08},
3336
{0x48, 0x89, 0x5C, 0x24, 0x08, 0x48, 0x89, 0x6C, 0x24, 0x10, 0x48, 0x89, 0x74, 0x24, 0x18, 0x57, 0x41, 0x56, 0x41, 0x57, 0x48, 0x83, 0xEC, 0x30, 0x48, 0x8B, 0x41, 0x28, 0x48, 0x8B, 0xF9, 0x8B, 0xF2, 0x41, 0x8B, 0xE9, 0x44, 0x8B, 0xDA, 0x4D},
3437
{0x40, 0x53, 0x48, 0x81, 0xEC, 0x60, 0x01, 0x00, 0x00, 0x48, 0x8B, 0x05, 0x4C, 0x9D, 0x0E, 0x00, 0x48, 0x33, 0xC4, 0x48, 0x89, 0x84, 0x24, 0x50, 0x01, 0x00, 0x00, 0x83, 0xB9, 0x2C, 0x09, 0x00, 0x00, 0x00, 0x48, 0x8B, 0xD9, 0x0F, 0x85, 0x83},
38+
{0x48, 0x89, 0x5C, 0x24, 0x08, 0x48, 0x89, 0x6C, 0x24, 0x10, 0x48, 0x89, 0x74, 0x24, 0x18, 0x57, 0x48, 0x83, 0xEC, 0x20, 0x89, 0x15, 0xF6, 0x81, 0x0B, 0x00, 0x48, 0x8B, 0xE9, 0x48, 0x8B, 0x59, 0x60, 0x8B, 0xFA, 0x48, 0x8B, 0xCB, 0x33, 0xF6},
3539
"10.0.18362.1316"},
3640
{{0x48, 0x89, 0x5C, 0x24, 0x10, 0x48, 0x89, 0x74, 0x24, 0x18, 0x55, 0x57, 0x41, 0x56, 0x48, 0x8D, 0x6C, 0x24, 0xC0, 0x48, 0x81, 0xEC, 0x40, 0x01, 0x00, 0x00, 0x48, 0x8B, 0x05, 0x87, 0xB4, 0x04, 0x00, 0x48, 0x33, 0xC4, 0x48, 0x89, 0x45, 0x30},
3741
{0x48, 0x83, 0xEC, 0x58, 0x48, 0x8B, 0x05, 0xB9, 0xBD, 0x04, 0x00, 0x48, 0x33, 0xC4, 0x48, 0x89, 0x44, 0x24, 0x48, 0x66, 0x0F, 0x6F, 0x05, 0xA9, 0xF5, 0x02, 0x00, 0x66, 0x0F, 0x6F, 0x0D, 0x91, 0xF5, 0x02, 0x00, 0x8B, 0x05, 0xDB, 0xEA, 0x04},
3842
{0x40, 0x53, 0x48, 0x81, 0xEC, 0x60, 0x01, 0x00, 0x00, 0x48, 0x8B, 0x05, 0x4C, 0xAD, 0x0E, 0x00, 0x48, 0x33, 0xC4, 0x48, 0x89, 0x84, 0x24, 0x50, 0x01, 0x00, 0x00, 0x83, 0xB9, 0x2C, 0x09, 0x00, 0x00, 0x00, 0x48, 0x8B, 0xD9, 0x0F, 0x85, 0x83},
3943
{0x48, 0x89, 0x5C, 0x24, 0x08, 0x48, 0x89, 0x6C, 0x24, 0x10, 0x48, 0x89, 0x74, 0x24, 0x18, 0x57, 0x41, 0x56, 0x41, 0x57, 0x48, 0x83, 0xEC, 0x30, 0x48, 0x8B, 0x41, 0x28, 0x48, 0x8B, 0xF9, 0x8B, 0xF2, 0x41, 0x8B, 0xE9, 0x44, 0x8B, 0xDA, 0x4D},
4044
{0x40, 0x53, 0x48, 0x81, 0xEC, 0x60, 0x01, 0x00, 0x00, 0x48, 0x8B, 0x05, 0x4C, 0x9D, 0x0E, 0x00, 0x48, 0x33, 0xC4, 0x48, 0x89, 0x84, 0x24, 0x50, 0x01, 0x00, 0x00, 0x83, 0xB9, 0x2C, 0x09, 0x00, 0x00, 0x00, 0x48, 0x8B, 0xD9, 0x0F, 0x85, 0x83},
45+
{0x48, 0x89, 0x5C, 0x24, 0x08, 0x48, 0x89, 0x6C, 0x24, 0x10, 0x48, 0x89, 0x74, 0x24, 0x18, 0x57, 0x48, 0x83, 0xEC, 0x20, 0x89, 0x15, 0x96, 0x87, 0x0B, 0x00, 0x48, 0x8B, 0xE9, 0x48, 0x8B, 0x59, 0x60, 0x8B, 0xFA, 0x48, 0x8B, 0xCB, 0x33, 0xF6},
4146
"10.0.18362.1 - UNTESTED"},
4247

4348
{{0x48, 0x89, 0x5C, 0x24, 0x10, 0x48, 0x89, 0x74, 0x24, 0x18, 0x55, 0x57, 0x41, 0x56, 0x48, 0x8D, 0x6C, 0x24, 0xC0, 0x48, 0x81, 0xEC, 0x40, 0x01, 0x00, 0x00, 0x48, 0x8B, 0x05, 0xB7, 0xD6, 0x04, 0x00, 0x48, 0x33, 0xC4, 0x48, 0x89, 0x45, 0x30},
4449
{0x48, 0x83, 0xEC, 0x58, 0x48, 0x8B, 0x05, 0xD9, 0xE0, 0x04, 0x00, 0x48, 0x33, 0xC4, 0x48, 0x89, 0x44, 0x24, 0x48, 0x66, 0x0F, 0x6F, 0x05, 0x99, 0xC6, 0x02, 0x00, 0x66, 0x0F, 0x6F, 0x0D, 0x81, 0xC6, 0x02, 0x00, 0x8B, 0x05, 0x53, 0x0E, 0x05},
4550
{0x48, 0x89, 0x5C, 0x24, 0x08, 0x48, 0x89, 0x74, 0x24, 0x10, 0x57, 0x48, 0x83, 0xEC, 0x20, 0x65, 0x48, 0x8B, 0x04, 0x25, 0x58, 0x00, 0x00, 0x00, 0x8B, 0xDA, 0xBA, 0x04, 0x00, 0x00, 0x00, 0x49, 0x8B, 0xF9, 0x49, 0x8B, 0xF0, 0x48, 0x8B, 0x08},
4651
{0x48, 0x89, 0x5C, 0x24, 0x08, 0x48, 0x89, 0x6C, 0x24, 0x10, 0x48, 0x89, 0x74, 0x24, 0x18, 0x57, 0x41, 0x56, 0x41, 0x57, 0x48, 0x83, 0xEC, 0x30, 0x48, 0x8B, 0x41, 0x28, 0x48, 0x8B, 0xF9, 0x44, 0x8B, 0xDA, 0x41, 0x8B, 0xE9, 0x8B, 0xF2, 0x4D},
4752
{0x40, 0x53, 0x48, 0x81, 0xEC, 0x60, 0x01, 0x00, 0x00, 0x48, 0x8B, 0x05, 0xB4, 0xDC, 0x0F, 0x00, 0x48, 0x33, 0xC4, 0x48, 0x89, 0x84, 0x24, 0x50, 0x01, 0x00, 0x00, 0x83, 0xB9, 0x2C, 0x09, 0x00, 0x00, 0x00, 0x48, 0x8B, 0xD9, 0x74, 0x24, 0x83},
53+
{0x48, 0x89, 0x5C, 0x24, 0x08, 0x48, 0x89, 0x6C, 0x24, 0x10, 0x48, 0x89, 0x74, 0x24, 0x18, 0x57, 0x48, 0x83, 0xEC, 0x20, 0x89, 0x15, 0x7E, 0xA2, 0x0B, 0x00, 0x48, 0x8B, 0xE9, 0x48, 0x8B, 0x59, 0x60, 0x8B, 0xFA, 0x48, 0x8B, 0xCB, 0x33, 0xF6},
4854
"10.0.19041.84 - UNTESTED"}};
4955

5056
#endif

0 commit comments

Comments
 (0)