mirror of
https://github.com/glest/glest-source.git
synced 2025-08-24 08:52:49 +02:00
- speed improvement for anti-hack checking
This commit is contained in:
@@ -992,14 +992,13 @@ string ModeInfo::getString() const{
|
||||
|
||||
void ValueCheckerVault::addItemToVault(const void *ptr,int value) {
|
||||
Checksum checksum;
|
||||
checksum.addString(intToStr(value));
|
||||
vaultList[ptr] = intToStr(checksum.getSum());
|
||||
vaultList[ptr] = checksum.addInt(value);
|
||||
|
||||
// if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d] add vault key [%p] value [%s] [%d]\n",__FILE__,__FUNCTION__,__LINE__,ptr,intToStr(checksum.getSum()).c_str(),value);
|
||||
}
|
||||
|
||||
void ValueCheckerVault::checkItemInVault(const void *ptr,int value) const {
|
||||
map<const void *,string>::const_iterator iterFind = vaultList.find(ptr);
|
||||
map<const void *,int32>::const_iterator iterFind = vaultList.find(ptr);
|
||||
if(iterFind == vaultList.end()) {
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED) {
|
||||
// printf("In [%s::%s Line: %d] check vault key [%p] value [%d]\n",__FILE__,__FUNCTION__,__LINE__,ptr,value);
|
||||
@@ -1011,8 +1010,7 @@ void ValueCheckerVault::checkItemInVault(const void *ptr,int value) const {
|
||||
throw std::runtime_error("memory value has been unexpectedly modified (not found)!");
|
||||
}
|
||||
Checksum checksum;
|
||||
checksum.addString(intToStr(value));
|
||||
if(iterFind->second != intToStr(checksum.getSum())) {
|
||||
if(iterFind->second != checksum.addInt(value)) {
|
||||
// if(SystemFlags::VERBOSE_MODE_ENABLED) {
|
||||
// printf("In [%s::%s Line: %d] check vault key [%p] value [%s] [%d]\n",__FILE__,__FUNCTION__,__LINE__,ptr,intToStr(checksum.getSum()).c_str(),value);
|
||||
// for(map<const void *,string>::const_iterator iterFind = vaultList.begin();
|
||||
|
@@ -47,26 +47,39 @@ void Checksum::addByte(int8 value) {
|
||||
int32 cipher= (value ^ (r >> 8));
|
||||
|
||||
r= (cipher + r) * c1 + c2;
|
||||
sum+= cipher;
|
||||
sum += cipher;
|
||||
}
|
||||
|
||||
void Checksum::addSum(int32 value) {
|
||||
sum+= value;
|
||||
sum += value;
|
||||
}
|
||||
|
||||
void Checksum::addString(const string &value){
|
||||
for(unsigned int i= 0; i<value.size(); ++i){
|
||||
int32 Checksum::addInt(const int32 &value) {
|
||||
int8 byte = (value >> 0) & 0xFF;
|
||||
addByte(byte);
|
||||
byte = (value >> 8) & 0xFF;
|
||||
addByte(byte);
|
||||
byte = (value >> 16) & 0xFF;
|
||||
addByte(byte);
|
||||
byte = (value >> 24) & 0xFF;
|
||||
addByte(byte);
|
||||
|
||||
return sum;
|
||||
}
|
||||
|
||||
void Checksum::addString(const string &value) {
|
||||
for(unsigned int i = 0; i < value.size(); ++i) {
|
||||
addByte(value[i]);
|
||||
}
|
||||
}
|
||||
|
||||
void Checksum::addFile(const string &path){
|
||||
void Checksum::addFile(const string &path) {
|
||||
if(path != "") {
|
||||
fileList[path] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
bool Checksum::addFileToSum(const string &path){
|
||||
bool Checksum::addFileToSum(const string &path) {
|
||||
|
||||
// OLD SLOW FILE I/O
|
||||
/*
|
||||
|
Reference in New Issue
Block a user