View previous topic :: View next topic |
Author |
Message |
Diambro Newbie cheater
Reputation: 0
Joined: 12 Sep 2023 Posts: 23 Location: Austria
|
Posted: Sun Sep 29, 2024 10:58 am Post subject: Alloc for variables |
|
|
Hey Community!
Im fond of adding my variables in the already allocated memory. However when im doing Pointers, they sometimes overwrite stuff since they do add/sub ect. commands.
Code: |
alloc(code,$1000)
....
somevar:
dd 0 //say for a check - switches 0 and 1
somepointer:
dd 0 //gets some address
somepointer2:
dd 0 //sometimes gets overwritten by above one
|
Is there a way to bypass that, or should i just alloc new memory for the Pointers?
Thanks in advance!
|
|
Back to top |
|
 |
ParkourPenguin I post too much
Reputation: 152
Joined: 06 Jul 2014 Posts: 4695
|
Posted: Sun Sep 29, 2024 11:25 am Post subject: |
|
|
Pointers are 8 bytes in 64-bit processes. Use `dq 0` instead
Also if those are allocs and not labels, allocate 8 bytes instead of 4
_________________
I don't know where I'm going, but I'll figure it out when I get there. |
|
Back to top |
|
 |
Diambro Newbie cheater
Reputation: 0
Joined: 12 Sep 2023 Posts: 23 Location: Austria
|
Posted: Mon Sep 30, 2024 3:43 am Post subject: |
|
|
Thanks for the reply!
ParkourPenguin wrote: | Pointers are 8 bytes in 64-bit processes. Use `dq 0` instead... |
Overwrite probably was the wrong description, cause i use dq when necessary, but maybe i didnt see it or had a brainlag, ill remember that in the future!
ParkourPenguin wrote: | ...Also if those are allocs and not labels, allocate 8 bytes instead of 4 |
Thats the thing, i never alloc anything extra for these pointers. I let them use the memory under the normal code. So i shouldnt do that?
Thanks!
|
|
Back to top |
|
 |
ParkourPenguin I post too much
Reputation: 152
Joined: 06 Jul 2014 Posts: 4695
|
Posted: Mon Sep 30, 2024 10:16 am Post subject: |
|
|
Using labels is fine, but you have to use `dq` so CE places the labels at the correct addresses
Code: | alloc(newmem,1024)
label(foo)
label(bar)
newmem: // 07C00000
foo: // 07C00000
dd 0 // 4 bytes
bar: // 07C00004
dd 0 | Storing an 8-byte value at `foo` will overwrite the value in `bar`. Use `dq 0` instead and the label `bar` would've been assigned the address 8 bytes after `foo`.
_________________
I don't know where I'm going, but I'll figure it out when I get there. |
|
Back to top |
|
 |
Diambro Newbie cheater
Reputation: 0
Joined: 12 Sep 2023 Posts: 23 Location: Austria
|
Posted: Mon Sep 30, 2024 11:38 am Post subject: |
|
|
Thanks for the easy to understand explanation, gonna remember that.
Thanks again ParkourPenguin!
|
|
Back to top |
|
 |
|