Skip to content

Commit

Permalink
Fix patterns
Browse files Browse the repository at this point in the history
  • Loading branch information
dedmen committed Oct 31, 2024
1 parent 2f97d46 commit cd39173
Showing 1 changed file with 35 additions and 22 deletions.
57 changes: 35 additions & 22 deletions src/EngineProfiling.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -221,23 +221,29 @@ HookManager::Pattern pat_shouldTime{

#else
//#FIXME
HookManager::Pattern pat_compileCacheIns{ //1.88.145.302 profv1 013D40B3
"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx?xxx????xxxx????xxxxx????xxxxxxxxxxxxxxxxxxxxxxxxx????xxx?????xxxx?x????xxxxxxxxxxxxxxxxxxxxx????xxxxxxxxxxxxxxxxx"sv,
"\x48\x89\x45\xB0\x8B\x43\x10\x89\x45\xB8\x48\x8B\x43\x18\x48\x85\xC0\x74\x03\xF0\xFF\x00\x48\x89\x45\xC0\x8B\x43\x20\x48\x8D\x54\x24\x00\x48\x8D\x0D\x00\x00\x00\x00\x89\x45\xC8\xE8\x00\x00\x00\x00\x48\x8D\x4D\xA8\xE8\x00\x00\x00\x00\x48\x8B\x4D\xA0\x48\x85\xC9\x74\x1C\x41\x8B\xC7\xF0\x0F\xC1\x01\xFF\xC8\x75\x09\x48\x8B\x4D\xA0\xE8\x00\x00\x00\x00\x48\xC7\x45\x00\x00\x00\x00\x00\x48\x8D\x4C\x24\x00\xE8\x00\x00\x00\x00\x4D\x85\xE4\x74\x1D\x41\x8B\xC7\xF0\x41\x0F\xC1\x04\x24\xFF\xC8\x75\x10\x48\x8B\x0D\x00\x00\x00\x00\x49\x8B\xD4\x48\x8B\x01\xFF\x50\x18\x4D\x85\xF6\x74\x1C\x41\x8B\xC7"sv
};
//HookManager::Pattern pat_compileCacheIns{ //1.88.145.302 profv1 013D40B3
// "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx?xxx????xxxx????xxxxx????xxxxxxxxxxxxxxxxxxxxxxxxx????xxx?????xxxx?x????xxxxxxxxxxxxxxxxxxxxx????xxxxxxxxxxxxxxxxx"sv,
// "\x48\x89\x45\xB0\x8B\x43\x10\x89\x45\xB8\x48\x8B\x43\x18\x48\x85\xC0\x74\x03\xF0\xFF\x00\x48\x89\x45\xC0\x8B\x43\x20\x48\x8D\x54\x24\x00\x48\x8D\x0D\x00\x00\x00\x00\x89\x45\xC8\xE8\x00\x00\x00\x00\x48\x8D\x4D\xA8\xE8\x00\x00\x00\x00\x48\x8B\x4D\xA0\x48\x85\xC9\x74\x1C\x41\x8B\xC7\xF0\x0F\xC1\x01\xFF\xC8\x75\x09\x48\x8B\x4D\xA0\xE8\x00\x00\x00\x00\x48\xC7\x45\x00\x00\x00\x00\x00\x48\x8D\x4C\x24\x00\xE8\x00\x00\x00\x00\x4D\x85\xE4\x74\x1D\x41\x8B\xC7\xF0\x41\x0F\xC1\x04\x24\xFF\xC8\x75\x10\x48\x8B\x0D\x00\x00\x00\x00\x49\x8B\xD4\x48\x8B\x01\xFF\x50\x18\x4D\x85\xF6\x74\x1C\x41\x8B\xC7"sv
//};


HookManager::Pattern pat_frameEnd{
"xxxxxxxxxxxxxxxxxxxxxxxxx????xxxxxxxxxxxxxxxxxxxxxxxxxxxx?????xxxxxx????x????xxxxxxxxx????xx????xxxx?xxxxxxxxx????xx????xx?????x????"sv,
"\x48\x8B\xC4\x44\x89\x48\x20\x56\x57\x41\x57\x48\x83\xEC\x70\x48\x89\x58\x10\x48\x8B\xF1\x0F\xB6\x99\x00\x00\x00\x00\x48\x89\x68\xE0\x4C\x89\x70\xC8\x45\x8B\xF1\x0F\x29\x78\xA8\x0F\x28\xFA\x8B\x41\x6C\x8B\x69\x68\x3B\xC5\xC6\x81\x00\x00\x00\x00\x00\x0F\x4E\xE8\x89\xAC\x24\x00\x00\x00\x00\xE8\x00\x00\x00\x00\x45\x33\xFF\x4C\x39\x7E\x60\x0F\x84\x00\x00\x00\x00\x8B\x86\x00\x00\x00\x00\x4C\x89\x64\x24\x00\x85\xC0\x7E\x1B\x83\xE8\x01\x89\x86\x00\x00\x00\x00\x0F\x85\x00\x00\x00\x00\xC6\x86\x00\x00\x00\x00\x00\xE9\x00\x00\x00\x00"sv
"xxxxxxxx????xxx????xxxxxx????xxxxxxxxxx????xxxxxxxxxxxxxxxxxxxxxxxxxxxx????xxx????xxx????xxx????xxx????xxxxxxxxxxxxxxxxxxxx?xxxxxx?xxxxxxxxxxxxx??"sv,
"\x40\x56\x57\x41\x57\x48\x81\xEC\x00\x00\x00\x00\x48\x8B\x81\x00\x00\x00\x00\x48\x8B\xF9\x48\x89\x81\x00\x00\x00\x00\x8B\x41\x1C\x39\x41\x28\x0F\x29\xB4\x24\x00\x00\x00\x00\x0F\x28\xF1\x0F\x4E\x41\x28\x33\xF6\x4C\x63\xF8\x85\xC0\x7E\x64\x8B\xD6\x4D\x8B\xC7\x48\x8B\x4F\x20\x48\x8D\x92\x00\x00\x00\x00\x8B\x84\x0A\x00\x00\x00\x00\x89\x84\x0A\x00\x00\x00\x00\x8B\x84\x0A\x00\x00\x00\x00\x89\x84\x0A\x00\x00\x00\x00\x49\x83\xE8\x01\x75\xD3\x48\x8B\xCE\x4D\x8B\xC7\x48\x8B\x57\x20\x40\x38\x74\x11\x00\x75\x14\x40\x38\x74\x11\x00\x75\x0D\x8B\x44\x11\x30\x85\xC0\x74\x05\xC6\x44\x11\x00\x00"sv
};

// Just some scope start, so we can find the boss man
HookManager::Pattern pat_aScopeStart{
"xxxxxxxxx?????xxxxxxxxxxxxxxxxxxxxxx????xxx????xxx????xxx????xxx????xxx????xxxxxx????xxxxx????x????xx????xx?????xxx????xxxx????xxxxxx?xx?????xxxxxxxx?xxxxx????xxxxxxxx????xx????xx"sv,
"\x48\x8B\xC4\x48\x83\xEC\x68\x80\x3D\x00\x00\x00\x00\x00\x48\x89\x58\x10\x48\x89\x68\x18\x48\x8B\xE9\x48\x89\x78\xF0\x4C\x89\x70\xE8\x4C\x8D\x35\x00\x00\x00\x00\x75\x46\xE8\x00\x00\x00\x00\x48\x8D\x15\x00\x00\x00\x00\x4C\x89\x35\x00\x00\x00\x00\x4C\x8D\x05\x00\x00\x00\x00\x48\x89\x15\x00\x00\x00\x00\x44\x8B\xC8\x4C\x89\x05\x00\x00\x00\x00\x49\x8B\xCE\x89\x05\x00\x00\x00\x00\xE8\x00\x00\x00\x00\x89\x05\x00\x00\x00\x00\xC6\x05\x00\x00\x00\x00\x00\x48\x8D\x1D\x00\x00\x00\x00\x48\x8B\xCB\xE8\x00\x00\x00\x00\x33\xFF\x48\x89\x5C\x24\x00\x83\x3D\x00\x00\x00\x00\x00\x88\x44\x24\x40\x48\x89\x7C\x24\x00\x74\x45\x40\x38\x3D\x00\x00\x00\x00\x75\x12\x84\xC0\x74\x38\xFF\x15\x00\x00\x00\x00\x39\x05\x00\x00\x00\x00\x75\x2A, "sv
// This is destructor of a scope. Whereas scopeCompleted is what the destructor calls
HookManager::Pattern pat_doEnd{
"xxxx?xxxxxxxxxxxxxxxx?????xxxxxxxxxx?????xxxxxxxxxxxxxx????xxxxxxxxxxxxx????xxxxxxxxxxx?x????"sv,
"\x48\x89\x5C\x24\x00\x57\x48\x83\xEC\x30\x80\x79\x11\x00\x48\x8B\xD9\x75\x0F\x80\x3D\x00\x00\x00\x00\x00\x75\x06\x48\x8D\x79\x18\xEB\x3B\x80\x3D\x00\x00\x00\x00\x00\x74\x0B\x0F\x31\x48\xC1\xE2\x20\x48\x0B\xC2\xEB\x05\xE8\x00\x00\x00\x00\x48\x8B\x13\x48\x8D\x7B\x18\x4C\x8B\xC0\x48\x8D\x0D\x00\x00\x00\x00\x48\x8B\x43\x08\x4C\x8B\xCF\x48\x89\x44\x24\x00\xE8\x00\x00\x00\x00"sv
};

// Just some scope start, so we can find the boss man
//HookManager::Pattern pat_aScopeStart{
// "xxxxxxxxx?????xxxxxxxxxxxxxxxxxxxxxx????xxx????xxx????xxx????xxx????xxx????xxxxxx????xxxxx????x????xx????xx?????xxx????xxxx????xxxxxx?xx?????xxxxxxxx?xxxxx????xxxxxxxx????xx????xx"sv,
// "\x48\x8B\xC4\x48\x83\xEC\x68\x80\x3D\x00\x00\x00\x00\x00\x48\x89\x58\x10\x48\x89\x68\x18\x48\x8B\xE9\x48\x89\x78\xF0\x4C\x89\x70\xE8\x4C\x8D\x35\x00\x00\x00\x00\x75\x46\xE8\x00\x00\x00\x00\x48\x8D\x15\x00\x00\x00\x00\x4C\x89\x35\x00\x00\x00\x00\x4C\x8D\x05\x00\x00\x00\x00\x48\x89\x15\x00\x00\x00\x00\x44\x8B\xC8\x4C\x89\x05\x00\x00\x00\x00\x49\x8B\xCE\x89\x05\x00\x00\x00\x00\xE8\x00\x00\x00\x00\x89\x05\x00\x00\x00\x00\xC6\x05\x00\x00\x00\x00\x00\x48\x8D\x1D\x00\x00\x00\x00\x48\x8B\xCB\xE8\x00\x00\x00\x00\x33\xFF\x48\x89\x5C\x24\x00\x83\x3D\x00\x00\x00\x00\x00\x88\x44\x24\x40\x48\x89\x7C\x24\x00\x74\x45\x40\x38\x3D\x00\x00\x00\x00\x75\x12\x84\xC0\x74\x38\xFF\x15\x00\x00\x00\x00\x39\x05\x00\x00\x00\x00\x75\x2A, "sv
//};

HookManager::Pattern pat_scopeCompleted{
"xxxxxxxxxxxxxxxx????xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx?xxxxxxxxx????xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx????xxx????xxxxxx????"sv,
"\x40\x53\x56\x41\x54\x41\x55\x41\x57\x48\x83\xEC\x20\x48\x8B\x81\x00\x00\x00\x00\x49\x8B\xF0\x48\x3B\xD0\x4D\x8B\xE9\x48\x8B\xD9\x48\x0F\x4C\xD0\x48\xC1\xF8\x04\x48\xC1\xFA\x04\x48\xC1\xFE\x04\x44\x8B\xE2\x44\x2B\xE0\x2B\xF2\x48\x8B\x44\x24\x00\x4C\x63\x78\x18\x45\x85\xFF\x0F\x88\x00\x00\x00\x00\x8B\x41\x68\x8B\xC8\xD1\xF9\x66\x0F\x6E\xC6\x0F\x5B\xC0\x66\x0F\x6E\xD0\x8B\x43\x6C\x2B\xC1\x0F\x5B\xD2\x66\x0F\x6E\xC8\x42\x8D\x04\x26\xF3\x0F\x59\xD0\x66\x0F\x6E\xC0\x0F\x5B\xC0\x0F\x5B\xC9\xF3\x0F\x59\xC8\x0F\x2F\xD1\x73\x3C\x80\x3B\x00\x0F\x84\x00\x00\x00\x00\x49\x69\xD7\x00\x00\x00\x00\x48\x03\x53\x20\x0F\x84\x00\x00\x00\x00"sv
Expand Down Expand Up @@ -378,22 +384,29 @@ void EngineProfiling::init() {
#ifdef __linux__
auto found = hooks.findPattern(pat_doEnd, 0);

auto stuffByte = found + 0x2A;
uint32_t base = *reinterpret_cast<uint32_t*>(stuffByte);
if (found)
{
auto stuffByte = found + 0x2A;
uint32_t base = *reinterpret_cast<uint32_t*>(stuffByte);
#else
auto found = hooks.findPattern(pat_aScopeStart, 0x21);
auto found = hooks.findPattern(pat_doEnd, 0x45);

// lea r14, bossman
if (found)
{
// lea r14, bossman

uint64_t afterInstruction = found + 7;
uint32_t offs = *reinterpret_cast<uint32_t*>(found + 0x3);
uint64_t addr = afterInstruction + offs;
uint64_t base = addr;
uint64_t afterInstruction = found + 7;
uint32_t offs = *reinterpret_cast<uint32_t*>(found + 0x3);
uint64_t addr = afterInstruction + offs;
uint64_t base = addr;
#endif
armaP = reinterpret_cast<ArmaProf*>(base);
armaP->slowFrameScopeFilter.clear();
armaP->forceCapture = true;
armaP->capture = true;
armaP = reinterpret_cast<ArmaProf*>(base);
armaP->slowFrameScopeFilter.clear();
armaP->forceCapture = true;
armaP->capture = true;
}


//disable captureSlowFrame because it can set forceCapture to false
#ifndef _DEBUG
static auto stuff = intercept::client::host::register_sqf_command("diag_captureSlowFrame"sv, ""sv, [](game_state&, game_value_parameter) -> game_value
Expand Down

0 comments on commit cd39173

Please sign in to comment.