MCPcopy Create free account
hub / github.com/alliedmodders/sourcemod / FindPattern

Method FindPattern

tools/gdc/MemoryUtils.cpp:77–112  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

75}*/
76
77void *MemoryUtils::FindPattern(const void *libPtr, const char *pattern, size_t len)
78{
79 DynLibInfo lib;
80 bool found;
81 char *ptr, *end;
82
83 memset(&lib, 0, sizeof(DynLibInfo));
84
85 if (!GetLibraryInfo(libPtr, lib))
86 {
87 return NULL;
88 }
89
90 ptr = reinterpret_cast<char *>(lib.baseAddress);
91 end = ptr + lib.memorySize;
92
93 while (ptr < end)
94 {
95 found = true;
96 for (register size_t i = 0; i < len; i++)
97 {
98 if (pattern[i] != '\x2A' && pattern[i] != ptr[i])
99 {
100 found = false;
101 break;
102 }
103 }
104
105 if (found)
106 return ptr;
107
108 ptr++;
109 }
110
111 return NULL;
112}
113
114void *MemoryUtils::ResolveSymbol(void *handle, const char *symbol)
115{

Callers 2

PrepSDKCall_SetSignatureFunction · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected