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 


About memscan CE 7.0. Did I made something wrong?

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

Joined: 10 Apr 2015
Posts: 1668

PostPosted: Sat Feb 15, 2020 6:08 am    Post subject: About memscan CE 7.0. Did I made something wrong? Reply with quote

Hi, if doing a scan manually for 4byte/exact value: '1075734118', then I got the results. It same if I make a scan for double value: 0.0111, I am also got the results. But if I am doing with Lua:

-- scan 4byte:

Code:
local memscan = createMemScan()
local foundlist = createFoundList(memscan)
memscan.firstScan(
  soValueBetween, vtDword, rtRounded,
  "1075734118", nil, 0, 0xffffffffffffffff, "+W-C",
  fsmAligned, "4", false, false, false, false)
memscan.waitTillDone()
foundlist.initialize()
local values = {}
local value = foundlist.Value
for i = 0, foundlist.Count - 1 do
  values[value[i]] = true
end
foundlist.destroy()
memscan.destroy()
for i in pairs(values) do
  print(i)
end


-- scan double value

Code:
findValue = 0.0111

memscan = createMemScan()
  foundlist = createFoundList(memscan)
  protectionflags = "-W*X-C"
  memscan.firstScan(soExactValue, vtDouble, rtTruncated, findValue, nil,
               "0","7fffffff",protectionflags,
               fsmAligned,"4",
               false, false, false, false)
  memscan.waitTillDone()
  foundlist.initialize()

 if foundlist ~=nil then
  local addresses = {}
  local address = foundlist.Address
  local values = {}
  local value = foundlist.Value
  cnt = 1
    for i = 0, foundlist.Count - 1 do
     addresses[address[i]] = true
     values[value[i]] = true
     print(cnt.." Address : "..address[i].." - Value : "..value[i])
    cnt = cnt + 1
    end
  foundlist.destroy()
  memscan.destroy()
 else
  showMessage("No results found");end


I don't get the results for both scan above. Did I made something wrong?.

_________________
Stealing Code From Stolen Code...
And Admit It.. Hmmm....Typically LOL
Back to top
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 152

Joined: 06 Jul 2014
Posts: 4710

PostPosted: Sat Feb 15, 2020 11:59 am    Post subject: Reply with quote

This looks like you copied and pasted code you didn't bother reading or understanding.

4 byte:
Code:
local memscan = createMemScan()
memscan.firstScan(
  soExactValue, vtDword, rtRounded,
  '1075734118', '', 0, 0xffffffffffffffff, '+W-X-C',
  fsmAligned, '4', false, false, false, false)
memscan.waitTillDone()

local foundlist = createFoundList(memscan)
foundlist.initialize()

local values = {}
local value = foundlist.Value
for i = 0, foundlist.Count - 1 do
  values[value[i]] = true
end

foundlist.destroy()
memscan.destroy()

for i in pairs(values) do
  print(i)
end

double:
Code:
local memscan = createMemScan()
memscan.firstScan(
  soExactValue, vtDouble, rtTruncated,
  '0.0111', '', 0, 0xffffffffffffffff, '+W-X-C',
  fsmAligned, '8', false, false, false, false)
memscan.waitTillDone()

local foundlist = createFoundList(memscan)
foundlist.initialize()

local addresses = {}
local address = foundlist.Address
local values = {}
local value = foundlist.Value
for i = 0, foundlist.Count - 1 do
  addresses[address[i]] = true
  values[value[i]] = true
  print(('%d Address : %s - Value : %s'):format(i+1, address[i], value[i]))
end

foundlist.destroy()
memscan.destroy()
(are you sure you want rtTruncated, and not rtRounded or rtExtremerounded?)

Edit: mixed up preferred alignment: 4 byte should be 4, double should be 8

_________________
I don't know where I'm going, but I'll figure it out when I get there.


Last edited by ParkourPenguin on Sat Feb 15, 2020 8:51 pm; edited 1 time in total
Back to top
View user's profile Send private message
Corroder
Grandmaster Cheater Supreme
Reputation: 75

Joined: 10 Apr 2015
Posts: 1668

PostPosted: Sat Feb 15, 2020 8:38 pm    Post subject: Reply with quote

ParkourPenguin wrote:
This looks like you copied and pasted code you didn't bother reading or understanding.


Yes, you are right. The script I copied from one of old my CT files and that works before. I do not have special programming skills that I get from school, courses or universities. Everything I do is trial and error. But I do not bother reading, especially for the codes/scripts that I try to use and I am not shy to ask some experts when I do not understand.

https://www.cheatengine.org/forum/viewtopic.php?t=602905&sid=5eccb12721bc06d947eae9db36b36ddf
https://forum.cheatengine.org/viewtopic.php?t=200819
https://wiki.cheatengine.org/index.php?title=Help_File:Value_types


CE Help File:

Code:
roundingtype: Defined the way scans for exact value floating points are handled
      rtRounded : Normal rounded scans. If exact value = "3" then it includes 3.0 to 3.49999999. If exact value is "3.0" it includes 3.00 to 3.0499999999
      rtTruncated: Truncated algorithm. If exact value = "3" then it includes 3.0 to 3.99999999. If exact value is "3.0" it includes 3.00 to 3.099999999
      rtExtremerounded: Rounded Extreme. If exact value = "3" then it includes 2.0000001 to 3.99999999. If exact value is "3.0" it includes 2.900000001 to 3.099999999


The value '1075734118' I try to find is without floating point and will only one result. So, what is better rounding type your suggestion?.

Thank you so much for help.

_________________
Stealing Code From Stolen Code...
And Admit It.. Hmmm....Typically LOL
Back to top
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 152

Joined: 06 Jul 2014
Posts: 4710

PostPosted: Sat Feb 15, 2020 8:59 pm    Post subject: Reply with quote

The rounding type parameter is only used for floating point types. It won't affect the 4 byte scan, but you should still set it to something.

For the double scan, what rounding type to use will depend on what the game is doing to the value. Generally, rtRounded is probably the default rounding most games use, rtTruncated is sometimes used, and rtExtremerounded should always work regardless of what the game does but might give more results than you want.

Also, I mixed up the alignment arguments on the scans. It's fixed now.

_________________
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
Corroder
Grandmaster Cheater Supreme
Reputation: 75

Joined: 10 Apr 2015
Posts: 1668

PostPosted: Sat Feb 15, 2020 9:14 pm    Post subject: Reply with quote

Thanks, @ParkourPenguin, it fixed now. I just change your code in this line.

from:

Code:
....fsmAligned, '8', false, false, false, false)....


to

Code:
....fsmAligned, '4', false, false, false, false)....


according to manual scan setting.



Capture.JPG
 Description:
 Filesize:  87.26 KB
 Viewed:  3672 Time(s)

Capture.JPG



_________________
Stealing Code From Stolen Code...
And Admit It.. Hmmm....Typically LOL
Back to top
View user's profile Send private message
mgr.inz.Player
I post too much
Reputation: 222

Joined: 07 Nov 2008
Posts: 4438
Location: W kraju nad Wisla. UTC+01:00

PostPosted: Sun Feb 16, 2020 4:04 am    Post subject: Reply with quote

ParkourPenguin wrote:
Edit: mixed up preferred alignment: 4 byte should be 4, double should be 8

Not quite. I saw many 8byte and double values at addresses not 8byte aligned.

_________________
Back to top
View user's profile Send private message MSN Messenger
ParkourPenguin
I post too much
Reputation: 152

Joined: 06 Jul 2014
Posts: 4710

PostPosted: Sun Feb 16, 2020 11:06 am    Post subject: Reply with quote

I've heard about it happening a long time ago but haven't seen it happen in the past decade. Then again, I haven't been looking.

Unless you're running something esoteric like an emulator or a really old game, most software written for contemporary 64-bit systems will do what both Intel and AMD recommend and use 8-byte alignment for doubles.

_________________
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
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