rand() function in Kernel Mode [RESOLVED]

Discuss the development of new homebrew software, tools and libraries.

Moderators: cheriff, TyRaNiD

Post Reply
ADePSP
Posts: 58
Joined: Thu Jul 13, 2006 9:07 pm

rand() function in Kernel Mode [RESOLVED]

Post by ADePSP »

I'm current trying to capture the PSP_CTRL_NOTE button but have found I need to run in Kernel Mode to get it... All my code compiles as before (after a few changes) apart from it doesn't recognise the rand() function anymore...

Anybody know a way to get around this...?

I tried to make my own rand() function like this but had no luck because now it doesn't recognise the time() function,

Code: Select all

SceKernelUtilsMt19937Context ctx; 

int RandomInit(void) { 
  sceKernelUtilsMt19937Init(&ctx, time(NULL)); 
  return 0; 
} 

int get_random(int lo, int hi) { 
  u32 rand_val = sceKernelUtilsMt19937UInt(&ctx); 
  rand_val = lo + rand_val % (hi+1); 
  return (int)rand_val; 
}

int rand(void) {
  return get_random(0,RAND_MAX);
}
EDIT: I managed to get it working by declaring time as t_time in the RandomInit() function...

Thanks anyway...
Post Reply