View previous topic :: View next topic |
Author |
Message |
kik4444 Expert Cheater Reputation: 0
Joined: 07 Sep 2013 Posts: 120 Location: Bulgaria
|
Posted: Sat Dec 20, 2014 6:30 am Post subject: Globalalloc |
|
|
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 |
|
|
Dark Byte Site Admin Reputation: 458
Joined: 09 May 2003 Posts: 25296 Location: The netherlands
|
Posted: Sat Dec 20, 2014 6:38 am Post subject: |
|
|
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 |
|
|
mgr.inz.Player I post too much Reputation: 218
Joined: 07 Nov 2008 Posts: 4438 Location: W kraju nad Wisla. UTC+01:00
|
Posted: Sat Dec 20, 2014 7:16 am Post subject: |
|
|
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 |
|
|
kik4444 Expert Cheater Reputation: 0
Joined: 07 Sep 2013 Posts: 120 Location: Bulgaria
|
Posted: Sat Dec 20, 2014 10:29 am Post subject: |
|
|
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 |
|
|
Dark Byte Site Admin Reputation: 458
Joined: 09 May 2003 Posts: 25296 Location: The netherlands
|
Posted: Sat Dec 20, 2014 11:24 am Post subject: |
|
|
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 |
|
|
mgr.inz.Player I post too much Reputation: 218
Joined: 07 Nov 2008 Posts: 4438 Location: W kraju nad Wisla. UTC+01:00
|
Posted: Sat Dec 20, 2014 5:00 pm Post subject: |
|
|
kik4444 wrote: |
Code: | [DISABLE]
addr:
dealloc(newmem)
db byte |
|
for better readability should be:
Code: | [DISABLE]
addr:
db byte
dealloc(newmem)
|
_________________
|
|
Back to top |
|
|
kik4444 Expert Cheater Reputation: 0
Joined: 07 Sep 2013 Posts: 120 Location: Bulgaria
|
Posted: Sat Dec 20, 2014 5:17 pm Post subject: |
|
|
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 |
|
|
|