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 


AOBScan.. filter by bytes

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
DaSpamer
Grandmaster Cheater Supreme
Reputation: 52

Joined: 13 Sep 2011
Posts: 1578

PostPosted: Thu Aug 07, 2014 3:45 pm    Post subject: AOBScan.. filter by bytes Reply with quote

Saw few minutes ago a thread with request of how to filter the AoB based on bytes on specific location...
Anyhow here's the script to achieve so.. feel free to modify it.

added some info at th e bottom of the script.

Code:
function excludeAoBScan(AoB, replaceAoB, excludeBytes)
   local exclude_array;
   if(type(excludeBytes) == 'string') then
      exclude_array = {};
      local no_space_bytes = string.gsub(excludeBytes, "%s", "");
      for i=1,#no_space_bytes, 2 do
         local value = string.sub(no_space_bytes,i,i+1)
         exclude_array[#exclude_array+1] = tonumber((value == '??' and '' or '0x') .. value) or false;
      end
   end
   if (not exclude_array) then
      return showMessage('Not a valid table');
   elseif (not AoB) then
      return showMessage('No AoB was given');
   elseif (not replaceAoB) then
      return showMessage('No replace AoB was given');
   end
   local byteCount = #string.gsub(AoB, "%s", "")/2;
   local AoB_object = AOBScan(AoB);
   if (AoB_object) then
      local count_replace = 0;
      for i = 0, AoB_object.Count - 1 do
         local address = AoB_object.getString(i);
         local addressData = readBytes(address, byteCount,true);
         if (addressData) then
            local include = false;
            for index,byte in pairs(addressData) do
               if (byte ~= exclude_array[index] and exclude_array[index]) then
                  include = true;
               end
            end
            if (include) then
               local activate = '';
               for i = 1, string.len(replaceAoB), 3 do
                  local z = string.sub(replaceAoB, i, i+2);
                  local x, y = string.find(z, "%?+");
                  if (x == nil) then
                     activate = activate .. address .. "+" .. (string.format("%x",(i-1)/3)) .. ':\ndb ' .. z .. '\n';
                  end
               end
               if(autoAssemble(activate)) then
                  count_replace = count_replace + 1;
               end
            end
         end
      end
      if (count_replace and count_replace > 0) then
         showMessage("Replaced " .. count_replace .. " entries successfully!");
      end
      AoB_object.destroy();
   end
end

--[[
   Usage:
      excludeAoBScan(Search,Replace,Exclude)
      -- Search = The aob you seek to find (supports wild cards)
      -- Replace = The aob you want to replace with the result (supports wild cards)
      -- Exclude = The aob you want to ignore (checking byte by byte ignoring wild cards) (supports wild cards)
   Examples
      -- excludeAoBScan("11 34 ?? ?? 00 00 00 ??","10 34 ?? ?? 00 00 00 ??","11 34 7d ?? 00")
      -- seraching for "11 34 ?? ?? 00 00 00 ??" (finds 4 entries);
      -- read the entries data (checking byte by byte with "11 34 7d ?? 00") and filtering what address can be activated (3 out of 4 can be enabled)
      -- replacing all entires that can be replaced with "10 34 ?? ?? 00 00 00 ??";
   Notes:
      You cannot compare bytes that aren't are beyond the search aob length.
      The script does not check byte by byte (like 1 wildcard and 1 number)
--]]

_________________
HEY Hitler
Do you get lazy when making trainers?
Well no more!
My CETrainer will generate it for you in seconds, so you won't get lazy! Very Happy

http://forum.cheatengine.org/viewtopic.php?t=564919
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting 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