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 


Globalalloc

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

Joined: 07 Sep 2013
Posts: 120
Location: Bulgaria

PostPosted: Sat Dec 20, 2014 6:30 am    Post subject: Globalalloc Reply with quote

Does anyone know how to use the globalalloc command correctly? Here's some code that uses it correctly but I can't seem to reproduce it on my own. Can anyone explain how this works? Here's an example of a good use of the globalalloc command in isaac rebirth -
Code:
define(address,"isaac-ng.exe"+12D6DE)
define(bytes,8B B8 A0 0B 00 00)

[ENABLE]

assert(address,bytes)
alloc(newmem,$1000)

globalalloc(pHearts,4)

label(code)
label(return)

newmem:

code:
  mov edi,[eax+00000BA0]
  mov [pHearts],eax
  jmp return

address:
  jmp code
  nop
return:

[DISABLE]

address:
  db bytes
  // mov edi,[eax+00000BA0]

dealloc(newmem)
dealloc(pHearts)

And after this you can just add more addresses by adding a pointer with the address pHearts+offset. Credit for the code goes to AikonCWD

_________________
Silence will fall when the question is asked...
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 458

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

PostPosted: Sat Dec 20, 2014 6:38 am    Post subject: Reply with quote

globalalloc allocates a block of memory and registers the given name. That means the addresslist and other parts of CE can reference it.
Every time a script globalallocs pHearts it will give it the same address (It won't allocate it again)
This is useful for multiple scripts that can be executed in a random order

it's similar to
Code:

alloc(pHearts,4)
registersymbol(pHearts)

but there it will allocate a new memory block, and dealloc will work (the dealloc in the first script has no use)

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

Joined: 07 Nov 2008
Posts: 4438
Location: W kraju nad Wisla. UTC+01:00

PostPosted: Sat Dec 20, 2014 7:16 am    Post subject: Reply with quote

Dark Byte wrote:
(the dealloc in the first script has no use)


dealloc(newmem) - still has
dealloc(pHearts) - has no use


Just to be clear.

_________________


Last edited by mgr.inz.Player on Sat Dec 20, 2014 4:58 pm; edited 1 time in total
Back to top
View user's profile Send private message MSN Messenger
kik4444
Expert Cheater
Reputation: 0

Joined: 07 Sep 2013
Posts: 120
Location: Bulgaria

PostPosted: Sat Dec 20, 2014 10:29 am    Post subject: Reply with quote

So here's my code that I tried to reproduce based on the code I posted up there. So far it works, but I haven't done any extensive playtesting.
Code:
define(addr,"isaac-ng.exe"+E2808)
define(byte,FF 8E 70 0B 00 00)
[ENABLE]
assert(addr,byte)
alloc(newmem,$1000)
label(return)
label(code)
globalalloc(test,4)

newmem:
code:
dec [esi+00000B70]
mov [test],esi
jmp return

addr:
jmp code
nop
return:

[DISABLE]
addr:
dealloc(newmem)
db byte
After this I just added new address manually with the address test+B70 and it seems to have worked, however I'm not sure if my code is entirely well written.
_________________
Silence will fall when the question is asked...
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 458

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

PostPosted: Sat Dec 20, 2014 11:24 am    Post subject: Reply with quote

if it works and doesn't crash it's good enough
but for cleaner code: the code label isn't needed. just jmp to newmem

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

Joined: 07 Nov 2008
Posts: 4438
Location: W kraju nad Wisla. UTC+01:00

PostPosted: Sat Dec 20, 2014 5:00 pm    Post subject: Reply with quote

kik4444 wrote:

Code:
[DISABLE]
addr:
dealloc(newmem)
db byte




for better readability should be:
Code:
[DISABLE]
addr:
db byte

dealloc(newmem)

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

Joined: 07 Sep 2013
Posts: 120
Location: Bulgaria

PostPosted: Sat Dec 20, 2014 5:17 pm    Post subject: Reply with quote

True, but as long the code works, I don't really bother actually opening it again, besides - in this type of code, once you finally make sure it works, all you need to do is add more values to your table with the address (name given in code)+offset, without having to open the script again.
_________________
Silence will fall when the question is asked...
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