-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathFCE Ultra Mario 2 Score.reg
More file actions
185 lines (88 loc) · 5.62 KB
/
FCE Ultra Mario 2 Score.reg
File metadata and controls
185 lines (88 loc) · 5.62 KB
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\Software\Cheat Engine\CustomTypes\FCE Ultra Mario 2 Score]
"Script"="alloc(TypeName,256)
alloc(ByteSize,4)
alloc(ConvertRoutine,1024)
alloc(ConvertBackRoutine,1024)
TypeName:
db 'FCE Ultra Mario 2 Score',0
ByteSize:
dd 2
//function declared as: stdcall int ConvertRoutine(unsigned char *input);
//Note: Keep in mind that this routine can be called by multiple threads at the same time.
ConvertRoutine:
[64-bit]
//parameters: (64-bit), rcx=address of input
mov eax, [rcx] //eax now contains the bytes 'input' pointed to
and eax, ffff
// eg. coins = 32, ah = 0x2 al = 0x3
push ax // save copy on stack, little endian so 0x3 0x2
mov ah, 0 // keep only al, 0x3
mov byte ptr [rsp], 0 // zero out 0x3 on stack
// multiply by 10 so that 0x3 becomes 30 = 0x1E
mov dx, #10
mul dx
// pop 0x0 0x2 off stack, into dx as dh = 0x2 dl = 0x0 aka 0x20 = 32
pop dx
// make dh = 0x0 and dl = 0x02 so dx = 2
xchg dh, dl
// add 2 to 30 to get 32
add ax, dx
ret
[/64-bit]
[32-bit]
// stack frame setup
push ebp
mov ebp,esp
//[ebp+8]=input
mov eax, [ebp+8] //place the address that contains the bytes into eax
mov eax, [eax]
// clean up extra bytes
and eax, ffff
// convert ah = 0x03 al = 0x02 to 0x20 = 32
push ax // save copy on stack, little endian so 0x3 0x2
mov ah, 0 // keep only al, 0x3
mov byte ptr [esp], 0 // zero out 0x3 on stack
// multiply by 10 so that 0x3 becomes 30 = 0x1E
mov dx, #10
mul dx
// pop 0x0 0x2 off stack, into dx as dh = 0x2 dl = 0x0 aka 0x20 = 32
pop dx
// make dh = 0x0 and dl = 0x02 so dx = 2
xchg dh, dl
// add 2 to 30 to get 32
add ax, dx
// stack frame teardown and ret
pop ebp
ret 4
[/32-bit]
//function declared as: stdcall void ConvertBackRoutine(int i, unsigned char *output);
ConvertBackRoutine:
[64-bit]
//parameters: (64-bit) ecx=input,rdx=address of output
// 32 = 0x20 to 0x3 0x2
// divide by 10 so 32 = 3 and 2
// move things around so div can work, exects value to divide in ax, overwrites dx
mov ax, cx // move 32 into ax
mov cl, #10 // move 10 into cl
mov r8, rdx // save address for output, dx used by div
div cl // divide ax by cl, 32 / 10 = 3 remainder 2
// AL = Quotient 3, AH = Remainder 2, ax = 0x2 0x3, little endian will write as 0x3 0x2
mov [r8],ax
ret
[/64-bit]
[32-bit]
push ebp
mov ebp,esp
//parameters: (32-bit) - [ebp+8]=input, [ebp+c]=address of output
mov eax,[ebp+8] //load the value into eax
mov ebx,[ebp+c] //load the address into ebx
//convert the value from 32 to 0x3 0x2 by dividing by 10
mov cl,#10
div cl // divide ax by cl, 32 / 10 = 3 remainder 2
// AL = Quotient 3, AH = Remainder 2, ax = 0x2 0x3, little endian will write as 0x3 0x2
mov [ebx], ax
pop ebp
ret 8
[/32-bit]
"