-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCBasePattern.cpp
More file actions
58 lines (47 loc) · 1.45 KB
/
Copy pathCBasePattern.cpp
File metadata and controls
58 lines (47 loc) · 1.45 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
48
49
50
51
52
53
54
55
56
57
58
#include "CBasePattern.hpp"
#include <Common/MemoryEngine.hpp>
CBasePattern::CBasePattern( const char* szPatternName , const char* szPattern , const char* szDll , uint32_t Offset , eBasePatternSearchType Type )
{
PatternName = szPatternName;
Pattern = szPattern;
Dll = szDll;
dwOffset = Offset;
m_Type = Type;
}
auto CBasePattern::Search( bool SkipError ) -> bool
{
if ( m_Type != eBasePatternSearchType::SEARCH_TYPE_PROC )
{
pFunction = FindPattern( Dll , Pattern , dwOffset );
if ( !pFunction )
{
if ( !SkipError )
DEV_LOG( "[error] CBasePattern: %s\n" , PatternName );
return false;
}
}
if ( m_Type == eBasePatternSearchType::SEARCH_TYPE_PTR )
pFunction = reinterpret_cast<PVOID>( *reinterpret_cast<intptr_t*>( pFunction ) );
else if ( m_Type == eBasePatternSearchType::SEARCH_TYPE_CALL )
pFunction = GetCallAddress( reinterpret_cast<intptr_t>( pFunction ) );
else if ( m_Type == eBasePatternSearchType::SEARCH_TYPE_PTR2 )
pFunction = GetPtrAddress<PVOID>( (intptr_t)pFunction );
else if ( m_Type == eBasePatternSearchType::SEARCH_TYPE_PROC )
pFunction = GetProcAddress( GetModuleHandleA( Dll ) , Pattern );
#if LOG_SDK_PATTERN == 1
DEV_LOG( "[+] CBasePattern: %s -> %p\n" , PatternName , pFunction );
#endif
return true;
}
auto CBasePattern::GetPatternName() -> const char*
{
return PatternName;
}
auto CBasePattern::GetDllName() -> const char*
{
return Dll;
}
auto CBasePattern::GetFunction() -> PVOID
{
return pFunction;
}