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 


getMemoryRecordByDescription no longer works for pointers

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine
View previous topic :: View next topic  
Author Message
S-nonymous027
How do I cheat?
Reputation: 0

Joined: 25 Jul 2021
Posts: 9
Location: Earth

PostPosted: Sun Jul 25, 2021 7:44 am    Post subject: getMemoryRecordByDescription no longer works for pointers Reply with quote

First of all, here's the problematic code:

Code:
function read()
keywaveaddress = addresslist_getMemoryRecordByDescription(getAddressList(), 'Correct key presses (wave)')
errwaveaddress = addresslist_getMemoryRecordByDescription(getAddressList(), 'Typing errors (wave)')
keylvladdress = addresslist_getMemoryRecordByDescription(getAddressList(), 'Correct key presses (level)')
errlvladdress = addresslist_getMemoryRecordByDescription(getAddressList(), 'Typing errors (level)')
keywavestr = memoryrecord_getValue(keywaveaddress)
errwavestr = memoryrecord_getValue(errwaveaddress)
keylvlstr = memoryrecord_getValue(keylvladdress)
errlvlstr = memoryrecord_getValue(errlvladdress)
   if keywavestr ~= "??" then
   keywave = tonumber(keywavestr)
   else
   keywave = 0
   end
   if errwavestr ~= "??" then
   errwave = tonumber(errwavestr)
   else
   errwave = 0
   end
   if keylvlstr ~= "??" then
   keylvl = tonumber(keylvlstr)
   else
   keylvl = 0
   end
   if errlvlstr ~= "??" then
   errlvl = tonumber(errlvlstr)
   else
   errlvl = 0
   end
end
read()
print("Address:",keywaveaddress)
print("Value:",keywave)


It works fine if I input a plain address into it (it prioritizes normal addresses over pointers, shown in addressinput.png)

But as soon as I input a pointer instead, it threw an error (shown in pointererror.png)

When I checked the "keywaveaddress = addresslist_getMemoryRecordByDescription(getAddressList(), 'Correct key presses (wave)')" part I noticed that it outputs a blank address... (shown in blankaddress.png)

I've never encountered this kind of error when I used older Cheat Engine versions. Any idea why this is the case and is this a bug?



blankaddress.png
 Description:
Huh? Blank address when reading a pointer?
 Filesize:  317.07 KB
 Viewed:  1405 Time(s)

blankaddress.png



pointererror.png
 Description:
Error thrown when a pointer is inputted
 Filesize:  330.96 KB
 Viewed:  1405 Time(s)

pointererror.png



addressinput.png
 Description:
Output obtained when a normal address is inputted
 Filesize:  320.68 KB
 Viewed:  1405 Time(s)

addressinput.png


Back to top
View user's profile Send private message
LeFiXER
Grandmaster Cheater Supreme
Reputation: 20

Joined: 02 Sep 2011
Posts: 1053
Location: 0x90

PostPosted: Sun Jul 25, 2021 9:46 am    Post subject: Reply with quote

Quote:

function read()
keywaveaddress = addresslist_getMemoryRecordByDescription(getAddressList(), 'Correct key presses (wave)')
errwaveaddress = addresslist_getMemoryRecordByDescription(getAddressList(), 'Typing errors (wave)')
keylvladdress = addresslist_getMemoryRecordByDescription(getAddressList(), 'Correct key presses (level)')
errlvladdress = addresslist_getMemoryRecordByDescription(getAddressList(), 'Typing errors (level)')


This is adding extra overhead, you can simplify it by doing this instead

Code:

...
function read()
local al = getAddressList()
keywaveaddress = al.getMemoryRecordByDescription('Correct key presses (wave)')
errwaveaddress = al.getMemoryRecordByDescription('Typing errors (wave)')
keylvladdress = al.getMemoryRecordByDescription('Correct key presses (level)')
errlvladdress = al.getMemoryRecordByDescription('Typing errors (level)')


Then you can access the returned memory records like so

Code:

-- CurrentAddress() - Returns an integer, but we're casting to string with the tostring function.
-- Can be used for simple addresses or pointers

keywavestr = tostring(keywaveaddress.CurrentAddress())
errwavestr = tostring(errwavestr.CurrentAddress())
keylvlstr = tostring(keylvlstr.CurrentAddress())
errlvlstr = tostring(errlvladdress.CurrentAddress())

   if keywavestr ~= "??" then
   keywave = tonumber(keywavestr)
   else
   keywave = 0
   end
   if errwavestr ~= "??" then
   errwave = tonumber(errwavestr)
   else
   errwave = 0
   end
   if keylvlstr ~= "??" then
   keylvl = tonumber(keylvlstr)
   else
   keylvl = 0
   end
   if errlvlstr ~= "??" then
   errlvl = tonumber(errlvlstr)
   else
   errlvl = 0
   end
 
   print("KeyWaveAddress is: " .. keywavestr .. "\n" .. "ErrWaveAddress is : " .. errwavestr .. "\n" .. "KeyLvlAddress is : " .. keylvlstr .. "\n" "ErrLevelAddress is : " .. errlvlstr)
end
...
read()


I didn't test this but it should work fine.
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 457

Joined: 09 May 2003
Posts: 25262
Location: The netherlands

PostPosted: Sun Jul 25, 2021 12:35 pm    Post subject: Reply with quote

If you have recently changed the descriptions call
Code:

AddressList.rebuildDescriptionCache()



also, this is shorter
Code:

keywaveaddress = al['Correct key presses (wave)']

_________________
Do not ask me about online cheats. I don't know any and wont help finding them.

Like my help? Join me on Patreon so i can keep helping
Back to top
View user's profile Send private message MSN Messenger
S-nonymous027
How do I cheat?
Reputation: 0

Joined: 25 Jul 2021
Posts: 9
Location: Earth

PostPosted: Sun Jul 25, 2021 7:07 pm    Post subject: Reply with quote

Follow up: Using Darkbyte's method I managed to restore it and made it work again. Thanks for the help.
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 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