File tree Expand file tree Collapse file tree 2 files changed +19
-0
lines changed Expand file tree Collapse file tree 2 files changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -284,3 +284,21 @@ unsigned long HexEditor::countOccurrences(vector<uint8_t> &bytes) {
284284 }
285285 return matches;
286286}
287+
288+ unsigned long HexEditor::findOccurrence (vector<uint8_t > &bytes, unsigned long start) {
289+ unsigned long offset = 0 ;
290+ for (unsigned long i = 0 ; i < this ->loadedFileSize -bytes.size (); i++) {
291+ bool found = true ;
292+ for (size_t j = start; j < bytes.size (); j++) {
293+ if (this ->getCurrentData ()[i+j] != bytes[j]) {
294+ found = false ;
295+ break ;
296+ }
297+ }
298+ if (found) {
299+ offset = i-bytes.size ();
300+ break ;
301+ }
302+ }
303+ return offset;
304+ }
Original file line number Diff line number Diff line change @@ -48,6 +48,7 @@ class HexEditor
4848 void initCompare ();
4949 bool hasCompared ();
5050 unsigned long countOccurrences (vector<uint8_t > &bytes);
51+ unsigned long findOccurrence (vector<uint8_t > &bytes, unsigned long start);
5152
5253private:
5354 PatternMatching *patternMatching;
You can’t perform that action at this time.
0 commit comments