Skip to content

Commit 330a5e6

Browse files
committed
added singature list
1 parent 777d232 commit 330a5e6

1 file changed

Lines changed: 27 additions & 12 deletions

File tree

source/yail.cpp

Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@
44
#include <Windows.h>
55
#include <TlHelp32.h>
66
#include <winternl.h>
7+
#include <array>
8+
#include <fstream>
79
#include <omath/utility/pe_pattern_scan.hpp>
810
#include <yail/yail.hpp>
9-
#include <fstream>
1011
namespace
1112
{
1213
// Resolve MSVC incremental-link jump stubs (ILT): E9 xx xx xx xx → target
@@ -44,26 +45,40 @@ namespace
4445
[[nodiscard]]
4546
LdrpHandleTlsDataFn find_ldrp_handle_tls_data()
4647
{
47-
const auto result = omath::PePatternScanner::scan_for_pattern_in_loaded_module(
48-
GetModuleHandleA("ntdll.dll"), "4C 8B DC 49 89 5B ? 49 89 73 ? 57 41 54 41 55 41 56 41 57 48 81 EC ? ? ? ? 48 8B 05 ? ? "
49-
"? ? 48 33 C4 48 89 84 24 ? ? ? ? 48 8B F9");
48+
constexpr std::array signatures = {
49+
"4C 8B DC 49 89 5B ? 49 89 73 ? 57 41 54 41 55 41 56 41 57 48 81 EC ? ? ? ? 48 8B 05 ? ? ? ? 48 33 C4 48 89 84 24 ? ? ? ? 48 8B F9", // Windows 11 24H2
50+
"48 89 5C 24 ? 48 89 74 24 ? 48 89 7C 24 ? 41 55 41 56 41 57 48 81 EC",
5051

51-
if (!result)
52-
throw std::runtime_error{"Failed to find LdrpHandleTlsData"};
52+
};
5353

54-
return reinterpret_cast<LdrpHandleTlsDataFn>(result.value());
54+
const auto* ntdll = GetModuleHandleA("ntdll.dll");
55+
for (const auto* sig : signatures)
56+
{
57+
const auto result = omath::PePatternScanner::scan_for_pattern_in_loaded_module(ntdll, sig);
58+
if (result)
59+
return reinterpret_cast<LdrpHandleTlsDataFn>(result.value());
60+
}
61+
62+
throw std::runtime_error{"Failed to find LdrpHandleTlsData"};
5563
}
5664

5765
[[nodiscard]]
5866
RtlInsertInvertedFunctionTableFn find_rtl_insert_inverted_function_table()
5967
{
60-
const auto result = omath::PePatternScanner::scan_for_pattern_in_loaded_module(
61-
GetModuleHandleA("ntdll.dll"), "48 8B C4 48 89 58 ? 48 89 68 ? 48 89 70 ? 57 48 83 EC ? 83 60");
68+
constexpr std::array signatures = {
69+
"48 8B C4 48 89 58 ? 48 89 68 ? 48 89 70 ? 57 48 83 EC ? 83 60", // Windows 11 24H2
70+
"4C 8B DC 49 89 5B ? 49 89 73 ? 57 48 83 EC ? 8B FA"
71+
};
6272

63-
if (!result)
64-
throw std::runtime_error{"Failed to find RtlInsertInvertedFunctionTable"};
73+
const auto* ntdll = GetModuleHandleA("ntdll.dll");
74+
for (const auto* sig : signatures)
75+
{
76+
const auto result = omath::PePatternScanner::scan_for_pattern_in_loaded_module(ntdll, sig);
77+
if (result)
78+
return reinterpret_cast<RtlInsertInvertedFunctionTableFn>(result.value());
79+
}
6580

66-
return reinterpret_cast<RtlInsertInvertedFunctionTableFn>(result.value());
81+
throw std::runtime_error{"Failed to find RtlInsertInvertedFunctionTable"};
6782
}
6883
struct RemoteLoaderData final
6984
{

0 commit comments

Comments
 (0)