-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Pattern Added, Check Ocurrences in Both Files
- Loading branch information
Showing
7 changed files
with
78 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,32 @@ | ||
#include "PatternEngine.h" | ||
#include "File.h" | ||
#include "Pattern.h" | ||
#include "Buffer.h" | ||
|
||
bool PatternEngine::CompareMem(const unsigned char* memChunk, const unsigned char* mask, const size_t len) | ||
{ | ||
for (size_t i = 0; i < len; i++) | ||
{ | ||
if (mask[i] != memChunk[i] && mask[i] != '?') | ||
return false; | ||
} | ||
|
||
return true; | ||
} | ||
|
||
void PatternEngine::FindPattern(const File* pFile, const Pattern& patternMask, std::vector<uintptr_t>& outResults) | ||
{ | ||
Buffer* pBuff = pFile->pBuff; | ||
const auto patternMaskBuff = patternMask.getBytes(); | ||
|
||
if (pBuff) FindPattern(pBuff->mBuff, pBuff->mBuff + pBuff->mSize, patternMaskBuff.data(), patternMaskBuff.size(), outResults); | ||
} | ||
|
||
void PatternEngine::FindPattern(const unsigned char* pStartAddr, const unsigned char* pEndAddr, const unsigned char* pMask, size_t maskLen, std::vector<uintptr_t>& outResults) | ||
{ | ||
for (const unsigned char* pCurr = pStartAddr; (pCurr + maskLen) < pEndAddr; pCurr++) | ||
{ | ||
if (CompareMem(pCurr, pMask, maskLen)) | ||
outResults.push_back((uintptr_t)(pStartAddr + (pEndAddr - pCurr))); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,15 @@ | ||
#pragma once | ||
|
||
#include <vector> | ||
|
||
struct File; | ||
struct Pattern; | ||
|
||
class PatternEngine | ||
{ | ||
|
||
public: | ||
static bool CompareMem(const unsigned char* memChunk, const unsigned char* mask, const size_t len); | ||
static void FindPattern(const File* pFile, const Pattern& pPatternMask, std::vector<uintptr_t>& outResults); | ||
static void FindPattern(const unsigned char* pStartAddr, const unsigned char* pEndAddr, const unsigned char* pMask, size_t maskLen, std::vector<uintptr_t>& outResults); | ||
}; | ||
|