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 


autoAssemble dealloc won't work

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

Joined: 17 Sep 2018
Posts: 2

PostPosted: Tue Sep 18, 2018 3:58 am    Post subject: autoAssemble dealloc won't work Reply with quote

Code:
local script_on = [==[
alloc(newmem,$1000,"Game.exe"+1BDAD36)
]==]
local script_off = [==[
dealloc(newmem)
]==]
if(checkbox_getState(CETrainer.CECheckbox1)==1)then
      autoAssemble(scrip_on)
   else
      autoAssemble(script_off)
end

or

local scriptStr  = [==[
[ENABLE]
alloc(newmem,$1000,"Game.exe"+1BDAD36)

[DISABLE]
dealloc(newmem)
]==]

 ---- Enable script
 local enabledOk, disableInfo = autoAssemble(scriptStr)
 if enabledOk then
   print('The auto assembler script was enabled successfully.')
 else
   print('There was an error enabling the auto assembler script.')
 end
 ---- Disable script
 local disabledOk = autoAssemble(scriptStr, disableInfo)
 if disabledOk then
   disableInfo = nil
   print('The auto assembler script was disabled successfully.')
 else
   print('There was an error disabling the auto assembler script.')
 end
[/list]
Back to top
View user's profile Send private message
FreeER
Grandmaster Cheater Supreme
Reputation: 53

Joined: 09 Aug 2013
Posts: 1091

PostPosted: Tue Sep 18, 2018 5:22 am    Post subject: Reply with quote

Bottom one seems to work just fine when I remove the address or replace it with
Code:
local scriptStr  = ([==[
[ENABLE]
alloc(newmem,$1000,%s)

[DISABLE]
dealloc(newmem)
]==]):format(process)
so that it's always valid. It prints
Code:
The auto assembler script was enabled successfully.
The auto assembler script was disabled successfully.



If I change it to something like
Code:
local scriptStr  = ([==[
[ENABLE]
alloc(newmem,$1000,%s)

[DISABLE]
dealloc(newmem)
]==]):format(process)

 ---- Enable script
 local enabledOk, disableInfo = autoAssemble(scriptStr)
 if enabledOk then
   print('The auto assembler script was enabled successfully.')
 else
   print('There was an error enabling the auto assembler script.')
 end
print(disableInfo.allocs.newmem.address)
local val = readInteger(disableInfo.allocs.newmem.address)
print(tostring(val))
 ---- Disable script
 local disabledOk = autoAssemble(scriptStr, disableInfo)
 if disabledOk then
   --disableInfo = nil
   print('The auto assembler script was disabled successfully.')
 else
   print('There was an error disabling the auto assembler script.')
 end
local val = readInteger(disableInfo.allocs.newmem.address)
print('after disable', tostring(val))
I get
Code:
The auto assembler script was enabled successfully.
36110336
0
The auto assembler script was disabled successfully.
after disable nil

with the readInteger call returning nil clearly showing that the memory has been deallocated.


edit: hm, looking at the first one you can't just use dealloc in a separate script like that unless you register the memory as a symbol, without registering it it's just a label and labels aren't known to other scripts, which is why you can use the same names like newmem and originalcode and returnhere etc. in multiple scripts at the same time and still have them refer to different addresses.

_________________
https://github.com/FreeER/ has a few CE related repos
Back to top
View user's profile Send private message
hackasn
How do I cheat?
Reputation: 0

Joined: 17 Sep 2018
Posts: 2

PostPosted: Tue Sep 18, 2018 5:49 am    Post subject: Reply with quote

FreeER wrote:
Bottom one seems to work just fine when I remove the address or replace it with
Code:
local scriptStr  = ([==[
[ENABLE]
alloc(newmem,$1000,%s)

[DISABLE]
dealloc(newmem)
]==]):format(process)
so that it's always valid. It prints
Code:
The auto assembler script was enabled successfully.
The auto assembler script was disabled successfully.



If I change it to something like
Code:
local scriptStr  = ([==[
[ENABLE]
alloc(newmem,$1000,%s)

[DISABLE]
dealloc(newmem)
]==]):format(process)

 ---- Enable script
 local enabledOk, disableInfo = autoAssemble(scriptStr)
 if enabledOk then
   print('The auto assembler script was enabled successfully.')
 else
   print('There was an error enabling the auto assembler script.')
 end
print(disableInfo.allocs.newmem.address)
local val = readInteger(disableInfo.allocs.newmem.address)
print(tostring(val))
 ---- Disable script
 local disabledOk = autoAssemble(scriptStr, disableInfo)
 if disabledOk then
   --disableInfo = nil
   print('The auto assembler script was disabled successfully.')
 else
   print('There was an error disabling the auto assembler script.')
 end
local val = readInteger(disableInfo.allocs.newmem.address)
print('after disable', tostring(val))
I get
Code:
The auto assembler script was enabled successfully.
36110336
0
The auto assembler script was disabled successfully.
after disable nil

with the readInteger call returning nil clearly showing that the memory has been deallocated.


edit: hm, looking at the first one you can't just use dealloc in a separate script like that unless you register the memory as a symbol, without registering it it's just a label and labels aren't known to other scripts, which is why you can use the same names like newmem and originalcode and returnhere etc. in multiple scripts at the same time and still have them refer to different addresses.

Thanks for your help.I don’t know how to express my gratitude.
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