forked from igroglaz/a2mgr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pack_scrolling.cpp
144 lines (125 loc) · 2.54 KB
/
pack_scrolling.cpp
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
#include <windows.h>
#include "utils.h"
unsigned long _stdcall PSCRL_rep(unsigned long parm1)
{
unsigned long pthis = _get_this();
bool ctrlp = (GetAsyncKeyState(VK_CONTROL));
if(parm1 == 0x21 && ctrlp)
{
for(int i = 0; i < 6; i++)
_call_member_func(0x004A937F, pthis);
_call_func(0x0043A790, 1, pthis + 0x20BC);
_call_func(0x0043A750, 1, pthis + 0x20BC);
return 1;
}
else if(parm1 == 0x22 && ctrlp)
{
for(int i = 0; i < 6; i++)
_call_member_func(0x004A91F8, pthis);
_call_func(0x0043A790, 1, pthis + 0x20BC);
_call_func(0x0043A750, 1, pthis + 0x20BC);
return 1;
}
return 0;
}
char logwhere[] = "ret = %08X\n";
void _declspec(naked) PSCRL_gameInventory()
{
__asm
{
push ebp
mov ebp, esp
sub esp, 0x0C
mov [ebp-4], ecx
push 0
mov eax, 0x0062B5E0
mov eax, [eax]
sub eax, 240
mov ecx, 80
xor edx, edx
div ecx
sub eax, 1
cmp eax, 1
jg gi_count_ok
mov eax, 1
gi_count_ok:
mov [ebp-0x0C], eax
mov eax, [ebp+8]
cmp eax, 0x21
jz gi_move_left
cmp eax, 0x22
jz gi_move_right
// cmp eax, 0x23
// jz gi_move_last
// cmp eax, 0x24
// jz gi_move_first
xor eax, eax
jmp gi_exit
gi_move_left:
xor eax, eax
mov [ebp-8], eax
gi_loop_left:
mov eax, [ebp-8]
cmp eax, [ebp-0x0c]
jge gi_exit_1
mov edx, 0x004A937F
mov ecx, [ebp-4]
call edx
inc dword ptr [ebp-8]
jmp gi_loop_left
gi_move_right:
xor eax, eax
mov [ebp-8], eax
gi_loop_right:
mov eax, [ebp-8]
cmp eax, [ebp-0x0c]
jge gi_exit_1
mov edx, 0x04A91F8
mov ecx, [ebp-4]
call edx
inc dword ptr [ebp-8]
jmp gi_loop_right
gi_exit_1:
mov eax, 1
gi_exit:
mov esp, ebp
pop ebp
retn 4
}
}
void _declspec(naked) PSCRL_shopShelfOnKeyDown()
{
__asm
{
push ebp
mov ebp, esp
sub esp, 8
mov [ebp-4], ecx
mov edx, 0x05A4D36 // GetAsyncKeyState
mov eax, VK_CONTROL
push eax
call edx
test eax, eax
jnz ss_continue
xor eax, eax
jmp ss_exit
ss_continue:
push dword ptr [ebp+8]
mov ecx, [ebp-4]
mov edx, 0x04BC146
call edx
ss_exit:
mov esp, ebp
pop ebp
retn 4
}
}
void PSCRL_InitializeInjection()
{
unsigned long func1 = (unsigned long)PSCRL_rep;
unsigned long func2 = (unsigned long)PSCRL_gameInventory;
unsigned long func3 = (unsigned long)PSCRL_shopShelfOnKeyDown;
memcpy((void*)0x005D92F4, &func1, 4);
memcpy((void*)0x005D8BAC, &func2, 4);
memcpy((void*)0x005D92F4, &func3, 4);
}