Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


(Solved)[ASM]"getTickCount", "srand", &q

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine
View previous topic :: View next topic  
Author Message
Dr.Disrespect
Grandmaster Cheater
Reputation: 3

Joined: 17 Feb 2016
Posts: 526

PostPosted: Mon Mar 20, 2017 1:11 pm    Post subject: (Solved)[ASM]"getTickCount", "srand", &q Reply with quote

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. Very Happy
Back to top
View user's profile Send private message
FreeER
Grandmaster Cheater Supreme
Reputation: 53

Joined: 09 Aug 2013
Posts: 1091

PostPosted: Wed Mar 22, 2017 9:03 pm    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites