-
Notifications
You must be signed in to change notification settings - Fork 3
/
D2Utils.cpp
150 lines (130 loc) · 2.26 KB
/
D2Utils.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
145
146
147
148
149
150
#include "D2Utils.h"
#include <Windows.h>
D2Utils::D2Utils(void)
{
}
D2Utils::~D2Utils(void)
{
}
bool D2Utils::initPatches( std::vector< Patch > patches)
{
unsigned long hold = NULL;
for( unsigned int i = 0; i < patches.size( ); i++ )
{
hold = NULL;
if( !VirtualProtect((void*)patches[ i ].address, patches[ i ].size, PAGE_EXECUTE_READWRITE, &hold ) )
return false;
//add other conditionals for other sizes
if( patches[ i ].size == 2 )
{
*(WORD*)patches[ i ].address = patches[ i ].newVal;
}
else if( patches[ i ].size == 4 )
{
*(DWORD*)patches[ i ].address = patches[ i ].newVal;
}
if( !VirtualProtect((void*)patches[ i ].address, patches[ i ].size, hold, &hold ) )
return false;
}
return true;
}
void D2Utils::displayGameText( wchar_t message[128], int x, int y, int color )
{
__asm {
pushad
pushfd
push 0
push color
push y
mov edx,x
mov ecx, dword ptr ds:[message]
mov esi, 0x6fabd298
call esi
popfd
popad
}
}
void D2Utils::drawLine( int x1, int y1, int x2, int y2, int color )
{
__asm {
pushad
pushfd
push 0x7f
push color
push y2
push x2
push y1
push x1
mov esi, 0x6fabd016
call esi
popfd
popad
}
}
void D2Utils::drawRectangle( int x1, int y1, int x2, int y2, int color, int trans )
{
__asm {
pushad
pushfd
push trans
push color
push y2
push x2
push y1
push x1
mov esi,0x6fabd02e
call esi
popfd
popad
}
}
void D2Utils::displayChatMessage( char message[128] )
{
__asm {
pushad
pushfd
push 0
mov eax, message
mov dword ptr ds:[ 0x6fbcd650 ], eax
mov ecx, 0x6fbcd650
mov edx, dword ptr ds:[ message ]
mov esi, 0x6FB61CE0
call esi
popfd
popad
}
}
int D2Utils::getMaxPlayerHp( )
{
DWORD maxHP = 0;
__asm {
pushad
pushfd
mov ecx, dword ptr ds:[0x6fbcd050]
push ecx
mov esi, 0x6fabc662
call esi
sar eax,8
mov maxHP,eax
popfd
popad
}
return maxHP;
}
int D2Utils::getCurPlayerInfo( int type )
{
DWORD curInfo = 0;
DWORD infoType = type;
__asm {
pushad
pushfd
mov eax, infoType
mov esi, 0x6fb1cc10
call esi
sar eax,8
mov curInfo,eax
popfd
popad
}
return curInfo;
}