Replace K with maximum value limit u want; in real u need code only from 'start' section; everything related to certain app replaced with '...' just to keep CE AA code structure
Code: Select all
[Enable]
alloc(start, 2048)
label(originalcode)
label(exit)
label(randomValue) // There stored generated random value
label(returnhere)
start:
pushad
mov eax, 0x2000001 // RDTSC (https://www.felixcloutier.com/x86/rdtsc)
cpuid
rdtsc
and eax, K // Modulo by 4 to get a number between N and K
mov [randomValue], eax // Remember generated value by writing it to cave's address
popad
originalcode:
mov eax, [randomValue] // In original code game wrote here into eax result of function which is an integer in range from N to K
mov ebp,eax
mov edi, [...]
exit:
jmp returnhere
randomValue:
dd 0
...:
jmp start
nop 3
returnhere:
[Disable]
dealloc(start)
...