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 


Pointer isn't updating when dependant address is updated

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

Joined: 12 May 2011
Posts: 199

PostPosted: Tue Oct 01, 2019 10:32 pm    Post subject: Pointer isn't updating when dependant address is updated Reply with quote

I have a address where i'm editing a value, and this value should be used to update pointer offsets. Problem is, the updating of pointer offset never seems to occur. Below is a shortened snippet of my ct file.

Code:

<CheatEntry>
<ID>5486</ID>
<Description>"Character"</Description>
<DropDownList DescriptionOnly="1" DisplayValueAsItem="1">
1:Test
2:Second Test
</DropDownList>
<LastState Value="00000000" RealAddress="09410000"/>
<ShowAsHex>1</ShowAsHex>
<VariableType>4 Bytes</VariableType>
<Address>iPartySlot</Address>
    <CheatEntries>
       <CheatEntry>
       <ID>5487</ID>
       <Description>"Level"</Description>
       <VariableType>2 Bytes</VariableType>
       <Address>pOffsetPtr</Address>
       <Offsets>
            <Offset>[QtyOffset]+[iPartySlot]-1C</Offset>
         </Offsets>
       </CheatEntry>



So, when i change my dropdown, it should update where the second cheat entry is pointing to, but it doesn't update the value for [iPartySlot]. IPartySlot stays equal to 0.
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 470

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

PostPosted: Tue Oct 01, 2019 11:26 pm    Post subject: Reply with quote

Rightclick the offset and choose the way it should update.
_________________
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
makotech222
Expert Cheater
Reputation: 0

Joined: 12 May 2011
Posts: 199

PostPosted: Tue Oct 01, 2019 11:44 pm    Post subject: Reply with quote

Slightly better. I changed the offset to use both ways to update

<Offset Interval="1000" UpdateOnFullRefresh="1">

It still doesn't really update automatically. I have to double click on the address and then close the window before the value updates. The timer doesn't seem to force update either.

Edit: Side note, why is this window popup not resizeable? Its so tiny! This is the updating address window you get when you double click on an address.
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 470

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

PostPosted: Wed Oct 02, 2019 1:38 am    Post subject: Reply with quote

Try interval only

Also, does it update when you cancel the change? because it can be a display thing and internally it does the right address

_________________
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
makotech222
Expert Cheater
Reputation: 0

Joined: 12 May 2011
Posts: 199

PostPosted: Wed Oct 02, 2019 9:05 am    Post subject: Reply with quote

Tried interval only. No go. If I press cancel on the window, it doesn't update. If I press Okay, it updates.

This is on CE 7.0 x64, btw.
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: Wed Oct 02, 2019 5:26 pm    Post subject: Reply with quote

makotech222 wrote:
Edit: Side note, why is this window popup not resizeable? Its so tiny!

I'm using custom CE where that window is bigger (edtOffset width * 8):


I ported it to Lua extension. Create .lua file inside autorun folder and paste this code (CE7.0):
Code:
if cheatEngineIs64Bit() then
local script=[[aobscanmodule(edtOffset_GetTextWidth,00400000,48 8D 15 xx xx xx xx E8 xx xx xx xx 89 C2 48 8B 4B 38 E8)
registersymbol(edtOffset_GetTextWidth)
alloc(newmem,$1000,00400000)
label(return)

newmem:
  imul eax,eax,8  // multiply calculated value by 8
  mov edx,eax
  mov rcx,[rbx+38]
  jmp return

edtOffset_GetTextWidth+C:
  jmp newmem
  nop
return:]]
autoAssemble(script,true)
else
local script=[[aobscanmodule(edtOffset_GetTextWidth,00400000,BA xx xx xx xx E8 xx xx xx xx 89 C2 8B 43 1C E8)
registersymbol(edtOffset_GetTextWidth)
alloc(newmem,$1000)
label(return)

newmem:
  imul eax,eax,8  // multiply calculated value by 8
  mov edx,eax
  mov eax,[ebx+1C]
  jmp return

edtOffset_GetTextWidth+A:
  jmp newmem
return:]]
autoAssemble(script,true)
end


_________________
Back to top
View user's profile Send private message MSN Messenger
makotech222
Expert Cheater
Reputation: 0

Joined: 12 May 2011
Posts: 199

PostPosted: Thu Oct 03, 2019 4:36 pm    Post subject: Reply with quote

Nice, thanks for that!
Back to top
View user's profile Send private message
makotech222
Expert Cheater
Reputation: 0

Joined: 12 May 2011
Posts: 199

PostPosted: Fri Oct 04, 2019 8:30 am    Post subject: Reply with quote

Okay can confirm this is a regression in CE 7.0. I downgraded to 6.7, and it was working properly.
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: Fri Oct 04, 2019 2:36 pm    Post subject: Reply with quote

pOffsetPtr
QtyOffset
iPartySlot

All of them are user registered symbols? Registered with AA command registersymbol() or Lua function registerSymbol().

Keep in mind that [iPartySlot] used in offset will read 4bytes in 32bit targets and 8bytes in 64bit targets.

What is iPartySlot? Is it address of your allocated memory? If yes, make sure you use it as 4bytes for 32bit targets, or just use 8bytes for 32bit and 64bit targets.
Code:

iPartySlot:
dd 0

or

iPartySlot:
dq 0




EDIT:
OK I created a script to test this issue with any process attached:

Code:
<?xml version="1.0" encoding="utf-8"?>
<CheatTable>
  <CheatEntries>
    <CheatEntry>
      <ID>1</ID>
      <Description>"test complex PTR"</Description>
      <LastState/>
      <VariableType>Auto Assembler Script</VariableType>
      <AssemblerScript>{$strict}

[ENABLE]
alloc(newmem,$1000)

label(pOffsetPtr)
label(QtyOffset)
label(iPartySlot)
registersymbol(pOffsetPtr)
registersymbol(QtyOffset)
registersymbol(iPartySlot)

newmem:

pOffsetPtr:
dq newmem+600

QtyOffset:
dq 100


newmem+700:
dd #5  //iPartySlot 0 level

dd #8  //iPartySlot 1 level

dd #13 //iPartySlot 2 level

dd #21 //iPartySlot 3 level

newmem+F00:
iPartySlot:
dq 0

[DISABLE]
dealloc(newmem)

unregistersymbol(pOffsetPtr)
unregistersymbol(QtyOffset)
unregistersymbol(iPartySlot)

</AssemblerScript>
      <CheatEntries>
        <CheatEntry>
          <ID>2</ID>
          <Description>"iPartySlot"</Description>
          <DropDownList ReadOnly="1" DescriptionOnly="1" DisplayValueAsItem="1">0:slot0
1:slot1
2:slot2
3:slot3
</DropDownList>
          <VariableType>8 Bytes</VariableType>
          <Address>iPartySlot</Address>
        </CheatEntry>
        <CheatEntry>
          <ID>3</ID>
          <Description>"complex ptr"</Description>
          <VariableType>4 Bytes</VariableType>
          <Address>pOffsetPtr</Address>
          <Offsets>
            <Offset Interval="100">[QtyOffset]+[iPartySlot]*4</Offset>
          </Offsets>
        </CheatEntry>
        <CheatEntry>
          <ID>4</ID>
          <Description>"complex address"</Description>
          <VariableType>4 Bytes</VariableType>
          <Address>[pOffsetPtr]+[QtyOffset]+[iPartySlot]*4</Address>
        </CheatEntry>
      </CheatEntries>
    </CheatEntry>
  </CheatEntries>
</CheatTable>



I also tested my older scripts with complex PTRs. Looks like something is wrong with CE.




"complex ptr" doesn't work

"complex address" works




EDIT2:


@DB

MemoryRecordUnit.pas
Code:
procedure TMemrecOffset.setOffsetText(s: string);
var
  e: boolean;
  s2: string;
  stack: integer;
begin
  funparsed:=true;
  cleanupluaref;
  text:=s;

  special:=false;

  try
    foffset:=StrToQWordEx(ConvertHexStrToRealStr(s));
    funparsed:=false;
    exit;
  except
    foffset:=symhandler.getAddressFromNameShallow(s, false, e);
    if not e then
    begin
      funparsed:=false;
      exit;
    end;
  end;

...
...


Looks like more complex offsets, such as this one "[QtyOffset]+[iPartySlot]*4", are not treated as "special".

But, the same offset in formAddressChangeUnit form is treated as "special" (because StrToQWordEx failed).




What do you think about this patch:
Code:
Index: MemoryRecordUnit.pas
===================================================================
--- MemoryRecordUnit.pas   (wersja 4442)
+++ MemoryRecordUnit.pas   (kopia robocza)
@@ -621,10 +621,11 @@
   cleanupluaref;
   text:=s;
 
-  special:=false;
+  special:=true;
 
   try
     foffset:=StrToQWordEx(ConvertHexStrToRealStr(s));
+    special:=false;
     funparsed:=false;
     exit;
   except
@@ -637,8 +638,6 @@
   end;
 
 
-  special:=true;
-
   //parse it as lua (because that can be called by ref, which is faster, and gets the memrec and address variables), if that fails, try the symbolhandler
   s2:='local memrec, address=... ; return '+s;
   stack:=lua_Gettop(luavm);

_________________
Back to top
View user's profile Send private message MSN Messenger
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 Oct 06, 2019 4:05 am    Post subject: Reply with quote

@makotech222

For now, just use this:



Or this:

_________________
Back to top
View user's profile Send private message MSN Messenger
Dark Byte
Site Admin
Reputation: 470

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

PostPosted: Sun Oct 06, 2019 5:32 am    Post subject: Reply with quote

I'll look into it (when i have time, likely after my wedding)
_________________
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
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 Oct 06, 2019 7:28 am    Post subject: Reply with quote

Don't know if you want to treat all offsets which are successfully parsed by getAddressFromNameShallow function as special.
I think we can add another MemoryRecord property: fThisOffsetIsFrequentlyUpdatedByUser.

I think I can prepare a PR commit today.

_________________
Back to top
View user's profile Send private message MSN Messenger
Dark Byte
Site Admin
Reputation: 470

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

PostPosted: Sun Oct 06, 2019 8:58 am    Post subject: Reply with quote

we have to be careful with this as reinterpreting is slow and some tables have a thousand pointers each with 5 offsets or more

Only reinterpret offsets when it is absolutely necesary

_________________
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
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 Oct 06, 2019 11:02 am    Post subject: Reply with quote

Currently, all MemrecOffset which are Lua scripts are reinterpreted (and there's no "no-update" rule set by default).


OK, Instead of MemoryRecord property, it will be MemrecOffset property. I think this would be OK.

MemrecOffset property "FrequentlyUpdatedByUser" set to false by default. XML attribute - "FrequentlyUpdated".




If user has much more pointers with offset FrequentlyUpdatedByUser set to true, then we can suggest to also use one of "no-update" (OnlyUpdateAfterInterval or OnlyUpdateWithReinterpret) rules.

The patch will be (waiting to send this PR): https://github.com/cheat-engine/cheat-engine/compare/master...mgrinzPlayer:MemrecOffsetFrequentlyUpdatedByUser?expand=1
It is backward compatible with older CT files.


 

_________________
Back to top
View user's profile Send private message MSN Messenger
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