Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Quick Search Algorithm:simplification of the Boyer-Moore alg

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
Alice0725
Expert Cheater
Reputation: 11

Joined: 24 Jul 2012
Posts: 145

PostPosted: Wed Nov 28, 2012 6:16 am    Post subject: Quick Search Algorithm:simplification of the Boyer-Moore alg Reply with quote

It's really a very quick search algorithm for simple aobscan.

Anyone know an other better quick search algorithm ?

http://www-igm.univ-mlv.fr/~lecroq/string/node19.html#SECTION00190

Code:
{
Quick Search Algorithm:
1.See QSA in   http://www-igm.univ-mlv.fr/~lecroq/string/node19.html#SECTION00190
2.Add wildcards support.wildcard=$0100;.
}
function PreQsBc(aob:PWord;aobSize:integer):TIntegers;
const
  ASIZE=256; //yes,a byte.
var
  shift:TIntegers;
   i,wcshift:integer;
   wildcard:boolean=false;
begin
  setlength(shift,ASIZE);
   for i:=0 to ASIZE-1 do
      shift[i]:= aobSize+1;

   for i:=0 to aobSize-1 do
   begin
      if (aob[i] <> $0100) then
    begin
      Shift[aob[i]]:=aobSize-i;
    end   else
    begin
         wildcard:=true;
         wcshift:=aobsize-i;
      end;
   end;

   if(wildcard=true)then
      for i:=0 to ASIZE-1 do
          if Shift[i]>wcshift   then
         Shift[i]:=wcshift;

  Exit(shift);
end;


function QS(aob:PWord;aobSize:integer;buffer:PByte;bufferSize:integer;Shift:PInteger):integer;
var
   i:integer = 0;
   j:integer = 0;
begin
   result := -1;
   while j <= bufferSize-aobSize do
   begin
      for i:=0 to (aobSize-1) do
      begin
         if(aob[i]=$0100)or(aob[i]=buffer[i+j])
         then   continue
      else    break;
      end;

      if i+1=aobSize then
      begin
      result := j;
         exit;
      end   else
      begin
          j:= j+shift[Buffer[j+aobSize]];
      end;
   end; //end of while
end; 
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites