|
Cheat Engine The Official Site of Cheat Engine
|
View previous topic :: View next topic |
Author |
Message |
Dr.Disrespect Grandmaster Cheater Reputation: 3
Joined: 17 Feb 2016 Posts: 526
|
Posted: Mon Mar 20, 2017 1:11 pm Post subject: (Solved)[ASM]"getTickCount", "srand", &q |
|
|
Please take a look at the following code:
Code: |
call getTickCount
call srand
call rand <------------------ here here here
and eax,99
cmp eax,0
.......
|
After the "here" comment in the code, eax should have a random number, right? However, all I get are the same series of numbers.
Did I do something wrong?
Update:
I fixed the problem, please ignore this post, I'm so sorry.
_________________
**************
A simple example is better then ten links. |
|
Back to top |
|
|
FreeER Grandmaster Cheater Supreme Reputation: 53
Joined: 09 Aug 2013 Posts: 1091
|
Posted: Wed Mar 22, 2017 9:03 pm Post subject: |
|
|
It'd be more helpful for other people who happen to find this post if you also explained how you fixed it (and why it was needed).
At least that would prevent it from being a completely pointless post...
Off the top of my head I'm guessing srand needs a value passed to it to 'seed" rand with, in C you'd generally use the result of time if I recall correctly, while it looks like you tried using getTickCount you don't actually pass it's result so srand is using whatever happens to be on the stack (assuming x86 cdecl due to your reference to eax not rax, though even in x64 rcx is used for the first non-float argument and rax is still used as the register for the return value) which is quite possibly an address to return to or something similarly reused each time, thus giving srand the same seed value each time.
So you probably needed something more like this:
Code: |
call getTickCount // stores the tick count in eax
push eax // pushes eax (the tick count) onto the stack
call srand // uses (and pops) the pushed tick count
call rand // generates a random number based on seed set with srand
...
|
|
|
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
|
|