 |
Cheat Engine The Official Site of Cheat Engine
|
View previous topic :: View next topic |
Author |
Message |
deama1234 Master Cheater
Reputation: 3
Joined: 20 Dec 2014 Posts: 328
|
Posted: Wed Jan 28, 2015 8:36 am Post subject: Auto-Assembly - code problem... |
|
|
Code: | originalcode:
push ecx
push eax
push edx
push bx
jmp compare
calculate:
sub [ebx+00000480],01 //action to delay
pop bx
pop edx
pop eax
pop ecx
jmp exit
compare:
cmp bx,00
je delay
call gettickcount
mov ecx,eax
sub ecx,edx
cmp ecx,03E8
jae calculate
jmp compare
delay:
call gettickcount
mov edx,eax
inc bx
jmp compare
exit:
jmp returnhere |
I'm trying to delay the "sub [ebx+00000480],01" by a second, but the code at the top won't work...
did I miss something?
|
|
Back to top |
|
 |
SteveAndrew Master Cheater
Reputation: 30
Joined: 02 Sep 2012 Posts: 323
|
Posted: Wed Feb 04, 2015 10:41 am Post subject: Re: Auto-Assembly - code problem... |
|
|
deama1234 wrote: | Code: | originalcode:
push ecx
push eax
push edx
push bx
jmp compare
calculate:
sub [ebx+00000480],01 //action to delay
pop bx
pop edx
pop eax
pop ecx
jmp exit
compare:
cmp bx,00
je delay
call gettickcount
mov ecx,eax
sub ecx,edx
cmp ecx,03E8
jae calculate
jmp compare
delay:
call gettickcount
mov edx,eax
inc bx
jmp compare
exit:
jmp returnhere |
I'm trying to delay the "sub [ebx+00000480],01" by a second, but the code at the top won't work...
did I miss something? |
Well your code is a little convoluted, let me clean it up a bit... So from what I can see you need it to actually hold up the executing thread for a second? Or should the thread continue but that instruction "sub [ebx+x],1" should only run once a second, but still allow code after it? When does this get executed?
Something like this should work:
Code: |
[enable]
alloc(DelayCodeForASecond,1024)
label(DelayCodeLoop)
label(WaitASecond)
label(FinishTime)
label(returnhere)
DelayCodeForASecond:
pushad
DelayCodeLoop:
call kernel32.GetTickCount
cmp [FinishTime],0
jne WaitASecond
add eax,#1000 //I like to pre-add to the time so there's an "end time" instead of "start time"
mov [FinishTime],eax
jmp DelayCodeLoop //actually trap in this loop until a second has gone by
WaitASecond:
cmp eax,[FinishTime]
jb DelayCodeLoop //actually trap in this loop until a second has gone by
//A second has elapsed...
sub [ebx+480],1 //execute this instruction which has been delayed
mov [FinishTime],0 //reset so it can execute again in another second from the time it's attempted to be executed again
popad
jmp returnhere
FinishTime:
dd 0
Game.exe+4280f4:
jmp DelayCodeForASecond
db 90 90
returnhere:
[disable]
dealloc(DelayCodeForASecond)
|
replace "jmp DelayCodeForASecond" and "jb DelayCodeForASecond" with: jmp/jb returnhere to instead allow the code after "sub [ebx+x],1" to execute normally but only allow "sub [ebx+x],1" to execute once every time a second has passed
You'll have to try both ways and see which is what you're looking for...
Plus of course you could do it your way, with a start time instead of an end time, doesn't make a whole lot of difference I guess...
Code: |
[enable]
alloc(DelayCodeForASecond,1024)
label(DelayCodeLoop)
label(WaitASecond)
label(StartTime)
label(returnhere)
DelayCodeForASecond:
pushad
DelayCodeLoop:
call kernel32.GetTickCount
cmp [StartTime],0
jne WaitASecond
mov [StartTime],eax //I guess you could do start time also
popad
jmp returnhere
WaitASecond:
add eax,#1000
cmp eax,[StartTime]
popad
jb returnhere
//A second has elapsed...
sub [ebx+480],1
mov [StartTime],0 //reset so it can be set again
jmp returnhere
StartTime:
dd 0
Game.exe+4280f4:
jmp DelayCodeForASecond
db 90 90
returnhere:
[disable]
dealloc(DelayCodeForASecond)
|
There that should do it
_________________
|
|
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
|
|