mirror of
https://github.com/0O0o0oOoO00/Alas.git
synced 2026-05-22 23:29:29 +08:00
add: migrate source code of luahook
This commit is contained in:
40
blcrack/cracker/Dobby/source/Interceptor.cpp
Normal file
40
blcrack/cracker/Dobby/source/Interceptor.cpp
Normal file
@@ -0,0 +1,40 @@
|
||||
#include "Interceptor.h"
|
||||
|
||||
Interceptor *Interceptor::instance = nullptr;
|
||||
|
||||
Interceptor *Interceptor::SharedInstance() {
|
||||
if (Interceptor::instance == nullptr) {
|
||||
Interceptor::instance = new Interceptor();
|
||||
}
|
||||
return Interceptor::instance;
|
||||
}
|
||||
|
||||
InterceptEntry *Interceptor::find(addr_t addr) {
|
||||
for (auto *entry : entries) {
|
||||
if (entry->patched_addr == addr) {
|
||||
return entry;
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void Interceptor::add(InterceptEntry *entry) {
|
||||
entries.push_back(entry);
|
||||
}
|
||||
|
||||
void Interceptor::remove(addr_t addr) {
|
||||
for (auto iter = entries.begin(); iter != entries.end(); iter++) {
|
||||
if ((*iter)->patched_addr == addr) {
|
||||
entries.erase(iter);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const InterceptEntry *Interceptor::getEntry(int i) {
|
||||
return entries[i];
|
||||
}
|
||||
|
||||
int Interceptor::count() {
|
||||
return entries.size();
|
||||
}
|
||||
Reference in New Issue
Block a user