 |
Cheat Engine The Official Site of Cheat Engine
|
View previous topic :: View next topic |
Author |
Message |
Faloop How do I cheat?
Reputation: 0
Joined: 07 Jul 2021 Posts: 7 Location: EUA
|
Posted: Fri Jun 16, 2023 9:27 pm Post subject: [SOLVED] Creating a Loop to check a value and change it !!! |
|
|
I'm trying to create a Loop, to check if the value of an andress is 0, if it's equal to zero, change it to the value of x, and so on little by little
I've been trying this
Code: | newmem:
xor eax,eax
mov eax,[eax*4+tests]
cmp eax,[eax*4+tests]
jne endpop
inc eax
mov [eax*4+tests],1
endpop:
popad
tests:
dd 0000000000
dd 0000000000
dd 0000000000
dd 0000000000
dd 0000000000
|
so that I didn't have to extend the code infinitely for this:
Code: | cmp byte ptr [ADP],0
jne ARP_01
mov byte ptr [ADP],1
mov ecx,FFCCAA00
jmp _endfinal
ARP_01:
cmp byte ptr [ADP+4],0
jne ARP_02
mov byte ptr [ADP+4],1
mov ecx,FFCCAA01
jmp _endfinal
ARP_02:
cmp byte ptr [ADP+8],0
jne ARP_03
mov byte ptr [ADP+8],1
mov ecx,FFCCAA02
jmp _endfinal
exit:
jmp returnhere
_endfinal:
mov [esp+2C],ecx
push ecx
mov ebx,00000010+4
jmp exit
|
Last edited by Faloop on Fri Jun 16, 2023 11:36 pm; edited 1 time in total |
|
Back to top |
|
 |
ParkourPenguin I post too much
Reputation: 150
Joined: 06 Jul 2014 Posts: 4641
|
Posted: Fri Jun 16, 2023 10:35 pm Post subject: |
|
|
If you want to learn more about assembly, you can put code into a compiler and see what assembly it generates. C code:
Code: | #include <stddef.h>
const size_t N = 500;
extern void _endfinal(), _return(unsigned);
void foo(char *a, unsigned ecx_val) {
for (size_t i = 0; i < N; ++i) {
if (a[i] == 0) {
a[i] = 1;
ecx_val = 0xFFCCAA00+i;
break;
}
}
_endfinal();
_return(ecx_val);
} | GCC 13.1, arguments -O2 -m32
Code: | foo:
push ebx
xor eax, eax
sub esp, 8
mov edx, DWORD PTR [esp+16]
mov ebx, DWORD PTR [esp+20]
jmp .L4
.L2:
add eax, 1
cmp eax, 500
je .L3
.L4:
cmp BYTE PTR [edx+eax], 0
jne .L2
mov BYTE PTR [edx+eax], 1
lea ebx, [eax-3364352]
.L3:
call _endfinal
mov DWORD PTR [esp+16], ebx
add esp, 8
pop ebx
jmp _return
N:
.long 500 | (64-bit code would be different)
You could also use {$ccode} to avoid assembly:
https://forum.cheatengine.org/viewtopic.php?t=618134
_________________
I don't know where I'm going, but I'll figure it out when I get there. |
|
Back to top |
|
 |
Faloop How do I cheat?
Reputation: 0
Joined: 07 Jul 2021 Posts: 7 Location: EUA
|
Posted: Fri Jun 16, 2023 11:36 pm Post subject: |
|
|
ParkourPenguin wrote: | If you want to learn more about assembly, you can put code into a compiler and see what assembly it generates. C code:
Code: | #include <stddef.h>
const size_t N = 500;
extern void _endfinal(), _return(unsigned);
void foo(char *a, unsigned ecx_val) {
for (size_t i = 0; i < N; ++i) {
if (a[i] == 0) {
a[i] = 1;
ecx_val = 0xFFCCAA00+i;
break;
}
}
_endfinal();
_return(ecx_val);
} | GCC 13.1, arguments -O2 -m32
Code: | foo:
push ebx
xor eax, eax
sub esp, 8
mov edx, DWORD PTR [esp+16]
mov ebx, DWORD PTR [esp+20]
jmp .L4
.L2:
add eax, 1
cmp eax, 500
je .L3
.L4:
cmp BYTE PTR [edx+eax], 0
jne .L2
mov BYTE PTR [edx+eax], 1
lea ebx, [eax-3364352]
.L3:
call _endfinal
mov DWORD PTR [esp+16], ebx
add esp, 8
pop ebx
jmp _return
N:
.long 500 | (64-bit code would be different)
You could also use {$ccode} to avoid assembly: |
Thanks
|
|
Back to top |
|
 |
|
|
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
|
|