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 


Referencing .NET is unreliable.

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine
View previous topic :: View next topic  
Author Message
Rydian
Grandmaster Cheater Supreme
Reputation: 31

Joined: 17 Sep 2012
Posts: 1358

PostPosted: Thu Jul 09, 2015 8:54 pm    Post subject: Referencing .NET is unreliable. Reply with quote

So I started changing over to .NET addresses instead of AOB scans for Terraria. However it seems unstable. Sometimes an address like Terraria.Player::ItemCheck+1D5 will work, sometimes it won't. People using the table/trainer are having the same issue.

Code:
[ENABLE]
Terraria.Player::ItemCheck+1D5:
db B8 3F 42 0F 00 90

[DISABLE]
Terraria.Player::ItemCheck+1D5:
db 8B 80 A4 00 00 00


That's valid, the problem is even though the code gets compiled when needed, the references/names/whatever aren't always there. Half the time it's fine, half the time it won't work.

Stuff "won't work" as in "this is not a valid address" when I go to use the name, and when this is happening, even valid code made by the game has no label on it... for certain functions, while others do.

When there's no label, I can still find and modify it with an AOB scan and it's the same code and works just fine. It's just missing the label/name, so referencing it via that won't work randomly.

Literally from one run of the game to the next, the result of an AOBscan will vary between a raw address and something like Terraria.Player::ItemCheck+x.


EDIT: So many explanations and typos fixed.

_________________


Last edited by Rydian on Fri Jul 10, 2015 10:17 am; edited 1 time in total
Back to top
View user's profile Send private message
BanCheese
Cheater
Reputation: 0

Joined: 22 Oct 2014
Posts: 49

PostPosted: Thu Jul 09, 2015 9:24 pm    Post subject: Reply with quote

The core problem here is that Cheat Engine doesn't update it's symbol database after you attach. You see, the .NET runtime will interpret the CIL (Common Intermediate Language) several times before it JIT (Just-in-time) compiles it. This is most likely the cause of your problems -- You are attaching CE before the process has used that routine enough to justify JITing it.
_________________
A guy who likes memory hacking.
Back to top
View user's profile Send private message
Rudo
Advanced Cheater
Reputation: 2

Joined: 27 Jun 2015
Posts: 80

PostPosted: Thu Jul 09, 2015 9:33 pm    Post subject: Reply with quote

Probably OS 32 bits problems. Same problem goes to justa_dude's CT. (I use 32 bits machine and I have this problem too)
Back to top
View user's profile Send private message
Rydian
Grandmaster Cheater Supreme
Reputation: 31

Joined: 17 Sep 2012
Posts: 1358

PostPosted: Thu Jul 09, 2015 10:13 pm    Post subject: Reply with quote

BanCheese wrote:
The core problem here is that Cheat Engine doesn't update it's symbol database after you attach. You see, the .NET runtime will interpret the CIL (Common Intermediate Language) several times before it JIT (Just-in-time) compiles it. This is most likely the cause of your problems -- You are attaching CE before the process has used that routine enough to justify JITing it.
That's actually some neat info, thank you.

Well unless there's some "force all things to JIT now" thing I can do then it looks like I'll be sticking with AOB scans for the actual scripts.


Rudo-kun wrote:
Probably OS 32 bits problems. Same problem goes to justa_dude's CT. (I use 32 bits machine and I have this problem too)
Nah, 64-bit machine here, and it's literally the same scripts I'm making versus reloading an hour later.
_________________
Back to top
View user's profile Send private message
Gniarf
Grandmaster Cheater Supreme
Reputation: 43

Joined: 12 Mar 2012
Posts: 1285

PostPosted: Thu Jul 09, 2015 11:59 pm    Post subject: Reply with quote

Try
Code:
reinitializeDotNetSymbolhandler(modulename OPTIONAL): Reinitializes only the DotNet part of the symbol list. (E.g After an ILCode has been JITed) (6.4+)

Contrary to what main.lua says, 6.4 non plus also has this function...This or the version on the main page is also 6.4+.

_________________
DO NOT PM me if you want help on making/fixing/using a hack.
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 468

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

PostPosted: Fri Jul 10, 2015 1:15 am    Post subject: Reply with quote

6.4+ means 6.4 and later.
And yes, if the symbol lookup fails, try calling that function(e.g if you attach ce when in the start screen you either have to reattach or reload the symbols later on)

you could learn IL bytecode and make the adjustment in Terraria.Player::ItemCheck_IL (but keep in mind that only works before it gets jitted)

Also, aobscan will fail as well when you do it to soon

_________________
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
Rydian
Grandmaster Cheater Supreme
Reputation: 31

Joined: 17 Sep 2012
Posts: 1358

PostPosted: Fri Jul 10, 2015 1:40 am    Post subject: Reply with quote

I know about the code not even existing until it's needed the first time, it's just without any sort of workaround to this, referencing code via labels like that is unreliable and I wasn't sure if this was a CE thing or what.

If I have to check for failure and run a separate function and such, I might as well just stick with AOBs for now. ^^;

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

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

PostPosted: Fri Jul 10, 2015 1:50 am    Post subject: Reply with quote

Or you can call that in your aa scripts when they run for the first time
Just use a {$lua} section

_________________
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
Rydian
Grandmaster Cheater Supreme
Reputation: 31

Joined: 17 Sep 2012
Posts: 1358

PostPosted: Fri Jul 10, 2015 3:59 am    Post subject: Reply with quote

Ohhh, I see, so once it's been compiled but CE doesn't know about the symbols for it, calling that will make the embedded CE find the symbols?

Could some menu function to run that be inserted to CE itself as well for when that needs to be done while finding/testing?

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

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

PostPosted: Fri Jul 10, 2015 4:36 am    Post subject: Reply with quote

I'm not 100% sure if the .net symbol handler is linked to it, but in the addresslist you can rightclick and choose to reload all symbols
_________________
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
Rydian
Grandmaster Cheater Supreme
Reputation: 31

Joined: 17 Sep 2012
Posts: 1358

PostPosted: Fri Jul 10, 2015 10:34 am    Post subject: Reply with quote

"Force recheck symbols" doesn't do that unfortunately.
_________________
Back to top
View user's profile Send private message
Rydian
Grandmaster Cheater Supreme
Reputation: 31

Joined: 17 Sep 2012
Posts: 1358

PostPosted: Wed Jul 15, 2015 1:04 am    Post subject: Reply with quote

Okay so executing that function does work while CE's running too which is nice, but could a faster way of doing it be added?

Adding it to the table's lua script and then executing it isn't always an option, and going to the memory browser in order to open up the Lua Engine window is a little cumbersome (it won't open unless you do it from the browser window, won't work from the main CE window here).

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

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

PostPosted: Wed Jul 15, 2015 4:05 am    Post subject: Reply with quote

If it's about cheat tables you share with other people, then you can add it to the table's AA scripts:

e.g:
Code:

{$lua}
errorOnLookupFailure(false)
if getAddress('classname::methodname')==0 then
  reinitializeDotNetSymbolhandler('dotnetmoduleelseignore')

  if getAddress('classname::methodname')==0 then
    showMessage('This function is not available yet. Please try again later')
    error() --prevents the aa entry from activating
  end
end

{$asm}

//asm stuff
alloc(something, 1234)
label(return)

something:
//do stuff

classname::methodname:
jmp something

return:




But if you mean when developing, you can add it to the main ce window:
Code:

mainmenu=getMainForm().Menu
netmi=createMenuItem(mainmenu)
netmi.Caption='.Net';

netreloadmi=createMenuItem(netmi)
netreloadmi.Caption='Reload symbols'
netreloadmi.OnClick=function() reinitializeDotNetSymbolhandler() end

netmi.add(netreloadmi)


mainmenu.Items.insert(mainmenu.Items.Count-1, netmi) --insert before help


or to the context menu of the addresslist:

Code:

pm=getAddressList().Popupmenu

reload=createMenuItem(mainmenu)
reload.Caption='Reload .net symbols';
reload.OnClick=function() reinitializeDotNetSymbolhandler() end

pm.Items.Add(reload)


Just save either (or both) of these scripts as a .lua file in the autorun folder of cheat engine and restart CE. You'll have a menu option to reload the .net symbols

And another tip: Ctrl+alt+shift+L in the main gui will open up the lua engine window

_________________
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
Rydian
Grandmaster Cheater Supreme
Reputation: 31

Joined: 17 Sep 2012
Posts: 1358

PostPosted: Wed Jul 15, 2015 5:22 am    Post subject: Reply with quote

Ahhh, didn't know about that shortcut for the engine, and thanks for the scripts.

I really like this feature for games it can dig up info on, but there's still a problem with using the symbols across different machines. Different CPU models can result in different assembly (due to different instruction set support), and the offset is a byte count from the start of the function. I've already seen a number of cases (generally +0x80 or more into a function) where the offsets differed because some instructions before the target differed and so the code was shifted, so to speak. As far as research and quick tests however, it's great to be able to do this stuff from within CE and have it integrated so well.

Also, reloading the stuff in trainers seems kinda' counter-productive since it seems to take around the same amount of time as an AOB scan anyways and can be less precise (in terms of the code to be targeted).

EDIT: When I mention it as being a problem, it's not a bug report or anything like that, I recognize that it's not something caused or influenced by CE and is just a result of how .NET (and supposedly other JIT-using things) work.

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

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

PostPosted: Wed Jul 15, 2015 5:32 am    Post subject: Reply with quote

I recommend entry point hooking of a function and just change the parameters in those cases

or else do an custom lua memory scan after getting the function start and scan for all known aob's in a small region

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