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 


Regular expressions

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General Discussions
View previous topic :: View next topic  
Author Message
Demonarke
Cheater
Reputation: 0

Joined: 12 Aug 2013
Posts: 31

PostPosted: Fri Jul 15, 2016 12:54 pm    Post subject: Regular expressions Reply with quote

Hey, I'm trying to do a scan search to replace "if" variables, the variable could be this :

if Strength>=40
goto
something

but the thing is that I can't just change all the variables it would take a tremendously amount of time, so what I wanted to do that you can do in notepad, is use [0-9] so I would want to search this on cheat engine >=[1-9] and it would scan every "skill check" basically. But cheat engine doesn't seem to be able to do it, or can it ?
Back to top
View user's profile Send private message
cooleko
Grandmaster Cheater
Reputation: 11

Joined: 04 May 2016
Posts: 717

PostPosted: Fri Jul 15, 2016 2:05 pm    Post subject: Reply with quote

Your request is vague, are you trying to search lua? Code that you have created or are you trying to search the game code?

If you are searching lua, then just paste your script into word or notepad and use replace all.

If you are searching game code, then you should not do what you are trying to do.

Strength, will likely have an address, but the game code CE sees isnt "If STR >= 40" it will likely be

Code:
mov eax, [Str Address]
cmp eax, [Str value]
jge StrCheckSucceeded


The above is simple, there are many ways, some much more complicated, for a game to implement an attribute check.

I recommend you brush up on the use of AOBs, in order to perform what you want.
http://forum.cheatengine.org/viewtopic.php?t=570083
Back to top
View user's profile Send private message
Demonarke
Cheater
Reputation: 0

Joined: 12 Aug 2013
Posts: 31

PostPosted: Fri Jul 15, 2016 2:19 pm    Post subject: Reply with quote

Sure probably the code is going to be like that, but couldn't I just change it's string with cheat engine ? Cause the code is definitely "if STR>=40" but, there are many checks in the game, some would be relationship checks, skill checks, and the thing is that they are all functioning on this ">=" so what i thought I could do would be to just search this on string ">=" and a number between [1-9] so it would show me >= 40, >=30, >=60 basically every possible combination of this string. I don't know if you get where I'm going but for those who know this regular expression it's really simple, it's like using [a-Z] searching for every possible letter possible.
Back to top
View user's profile Send private message
Zanzer
I post too much
Reputation: 126

Joined: 09 Jun 2013
Posts: 3278

PostPosted: Fri Jul 15, 2016 2:48 pm    Post subject: Reply with quote

Ctrl+Alt+L
Code:
local aob = AOBScan("3E 3D")
for i=1,aob.Count-1 do
  print(readString(aob[i], 32))
end
aob.Destroy()
Back to top
View user's profile Send private message
cooleko
Grandmaster Cheater
Reputation: 11

Joined: 04 May 2016
Posts: 717

PostPosted: Fri Jul 15, 2016 4:49 pm    Post subject: Reply with quote

Demonarke wrote:
Sure probably the code is going to be like that, but couldn't I just change it's string with cheat engine ? Cause the code is definitely "if STR>=40" but, there are many checks in the game, some would be relationship checks, skill checks, and the thing is that they are all functioning on this ">=" so what i thought I could do would be to just search this on string ">=" and a number between [1-9] so it would show me >= 40, >=30, >=60 basically every possible combination of this string. I don't know if you get where I'm going but for those who know this regular expression it's really simple, it's like using [a-Z] searching for every possible letter possible.


Why isnt the code "if str > 39" or "if not str < 40" there are going to be thousands of compares. Most of them are not going to be about ability checks.

I think you are tackling the problem from the wrong angle. However, you never told us the problem outside of you want to search high level code that isnt visible to cheat engine.
Back to top
View user's profile Send private message
Demonarke
Cheater
Reputation: 0

Joined: 12 Aug 2013
Posts: 31

PostPosted: Fri Jul 15, 2016 7:04 pm    Post subject: Reply with quote

Zanzer seems to be the person who is the closest of achieving what I want, problem is, I don't understand the code :-/ could you perhaps explain to me what the code does ? It's functions ?
Back to top
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 152

Joined: 06 Jul 2014
Posts: 4702

PostPosted: Fri Jul 15, 2016 8:08 pm    Post subject: Reply with quote

Code:
local aob = AOBScan("3E 3D")     -- scans for the string ">="
for i=1,aob.Count-1 do           -- loop through the results
  print(readString(aob[i], 32))  -- print the string representation of the results (max 32 chars)
end                              -- end loop
aob.Destroy()                    -- free the results

_________________
I don't know where I'm going, but I'll figure it out when I get there.
Back to top
View user's profile Send private message
Demonarke
Cheater
Reputation: 0

Joined: 12 Aug 2013
Posts: 31

PostPosted: Sat Jul 16, 2016 8:23 am    Post subject: Reply with quote

When I scan >=40 I find something, and when I go to memory view, i can see the string if STR>=40, I will edit it and I will get what I want, basically put if STR>=0 but there are too many variables for me to find them all, this is not always going to be 40, and it isn't always strength. What I wanted to know is if I could scan between a range of number [1-9] while having >= behind so I would scan >= "every number possible" and the list would show me >= and every number possible, and I would just edit them out so no checks in the game. When I do your aob scan I don't find any string that looks like the string I see in memory view.
Back to top
View user's profile Send private message
panraven
Grandmaster Cheater
Reputation: 62

Joined: 01 Oct 2008
Posts: 958

PostPosted: Sat Jul 16, 2016 10:32 am    Post subject: Reply with quote

May try like:
Code:

  local test = true -- no write to memory, but for debug print if true
  local aob = AOBScan(("if "):byte(1,-1))
  if aob~=nil then
    for i=0,aob.Count-1 do
-- read text from memory
      local code = readString(aob[i],32)
-- capture desired pattern
      local posBegin, LHS, cmpOps, RHS, posEnd, others = code:match('^if%s()(%s*.-%s*)([><=]+)(%s*%d+%s*)()%s(%S.*)')
-- do text modification if pattern matched
      if LHS~=nil  then
-- further extract pattern content, ie. this is for format: if [VarName] [compare ops] [number]
        local varname,number,newexp = LHS:match('^%s*(.-)%s*$'),tonumber(RHS:match('(%d+)') or '')
        if number then
          if varname=='STRENGTH' then
            newexp = 'true'
          elseif varname=='DAMAGE' then
            newexp = LHS..cmpOps..(number-10)
          end
          -- if no match, left newexp no value
        end-- if number
        if newexp then
-- space adjust, so that the modified text can be write back safely.         
          local spcAdjust = posEnd-posBegin - newexp:len()
          print(spcAdjust)
          if spcAdjust>= 0 then
            newexp = string.rep(' ',spcAdjust)..newexp
            if test==true then -- debug print
              print('aob #'..i)
              print('\t','if '..newexp..' '..others)
              print('\t',code)
            else -- write back memory
              writeString(tonumber(aob[i],16)+posBegin-1,newexp)
            end
          end
        end-- if newexp
      end-- if LHS
    end -- for aob
    aob.Destroy()
  end-- if aob


NOTE:
Lua 5.3 re pattern
https://www.lua.org/manual/5.3/manual.html#6.4.1
pattern () is for string position, check last paragraph of #6.4.1

_________________
- Retarded.
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 Discussions 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