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 


define memory instead of alloc

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

Joined: 09 Dec 2020
Posts: 27

PostPosted: Sat Jul 29, 2023 11:15 am    Post subject: define memory instead of alloc Reply with quote

Hi,
I wanted to make a main script containing my main alloc
Code:

  alloc(MainMem,$1000,GameAssembly.dll)
  registersymbol(MainMem)

then in an other script i tried to define it's memory as a part of the already allocated mem, like i do when i want to add multiple function to a script
Code:

  define(Mem_PointerStats,MainMem+600)
  registersymbol(Mem_PointerStats)


In standalone with it's own alloc teh script compile and works fine but when i tried this way i got a compilation warning telling me :
Quote:
Error Line 161 jmp MainMem+600+20 : this instruction can't be compiled

Line 161:
Code:

   jmp FT_ModClamp_Vitality

Define of FT_ModClamp_Vitality
Code:

  define(FT_ModClamp_Vitality,Mem_PointerStats+20)
  registersymbol(FT_ModClamp_Vitality)

is there any way to bypass this warning without having to define FT_ModClamp_Vitality directly from MainMem

EDIT:
i tried to define Mem_PointerStats inside the main script and it changed the error inside the second script

Quote:
<<Error in line 98 (Mem_PointerStats+160:) :This address specifier is not valid>>

Line 98
Code:

ptr_Hunger:
  dd 00

Define of ptr_Hunger
Code:

  define(ptr_Hunger,Mem_PointerStats+160)
  registersymbol(ptr_Hunger)
Back to top
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 152

Joined: 06 Jul 2014
Posts: 4706

PostPosted: Sat Jul 29, 2023 12:10 pm    Post subject: Reply with quote

Works fine for me.
Script 1:
Code:
[ENABLE]
alloc(foo,4096,Tutorial-x86_64.exe)
registersymbol(foo)

[DISABLE]
dealloc(foo)
unregistersymbol(foo)
Script 2:
Code:
[ENABLE]
define(bar,foo+600)
registersymbol(bar)
[DISABLE]
unregistersymbol(bar)
Script 3:
Code:
[ENABLE]
assert(Tutorial-x86_64.exe+2B76, 00 00 00 00 00)

define(baz,bar+20)
registersymbol(baz)

Tutorial-x86_64.exe+2B76:
  jmp baz

[DISABLE]
unregistersymbol(baz)

Tutorial-x86_64.exe+2B76:
  db 00 00 00 00 00

Obviously, there's a dependency chain here. You need to enable scrips in the correct order. If script 2 isn't enabled, CE will even complain even when you try to edit script 3.

Interestingly, you can still enable script 2 even when script 1 isn't enabled. It doesn't work, as expected, but registersymbol failing doesn't seem to cause the script activation to fail. That's unexpected.

Why are you even doing this? If this is about wasted memory, this is a textbook case of premature optimization and you should learn to stop caring and get on with it.

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

Joined: 09 Dec 2020
Posts: 27

PostPosted: Sat Jul 29, 2023 1:04 pm    Post subject: Reply with quote

It's just because i like having my scripts organized in that way, having one parent script allocating memory for all the other script and having all the function to get all the needed pointers for every child script in that same parent script. then every child script doesn't need any alloc and can access needed pointers freely it's a bit annoying to have to manually look where i can put functions (im wondering if i can't use labels to delimits where a script start and where it ends) but it's more clean than having 100 alloc for 100 scripts
imo

btw i have found my error i did something like this
script 1:
Code:

define(inj_PointersStats,MainMem+600)
registersymbol(inj_PointerStats)

script 2:
Code:

define(Mem_PointersStats,inj_PointerStats)
registersymbol(Mem_PointersStats)


instead of just doing one define directly in mainscript:
script 1:
Code:

define(Mem_PointersStats,MainMem+600)
registersymbol(Mem_PointerStats)

and i removed the unregistersymbol in second script otherwise i could activate it once but not twice


seeing your exemple have you tried to merge your script 2 and 3 ? did it still worked ? if yes i don't understand why mine wasn't
and perhaps the symbol isn't correctly unregistered when you activate script 2 without script 1 because it shouldn't know what foo+600 is
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 Gamehacking 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