|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
#include <stdio.h>
#include <stdint.h>
#include <string.h>
uint16_t r0;
uint16_t r1;
uint16_t r7;
uint16_t stack[429496729];
uint32_t stack_pos = 0;
void push(uint16_t value)
{
stack[stack_pos++] = value;
}
uint16_t pop()
{
return stack[--stack_pos];
}
void func1()
{
if(r0 == 0)
{
r0 = (r1 + 1) % 0x8000;
return;
}
if(r1 == 0)
{
r0 = (r0 + 0x7FFF) % 0x8000;
r1 = r7;
func1();
return;
}
push(r0);
r1 = (r1 + 0x7FFF) % 0x8000;
func1();
r1 = r0;
r0 = pop();
r0 = (r0 - 1) % 0x8000;
func1();
return;
}
int main()
{
int i;
for(i = 1; i < 32768; i++)
{
printf("Trying with %d... ",i);
memset(stack,0x00,32768);
stack_pos = 0;
r0 = 4;
r1 = 1;
r7 = i;
func1();
printf("%d\n",r0);
if(r0 == 6)
{
printf("===FOUND VALUE===\nr0: %d\nr1: %d\nr7: %d\n\n",r0,r1,r7);
}
}
return 0;
}
|