-
Notifications
You must be signed in to change notification settings - Fork 1
/
ItemLevel.cpp
78 lines (61 loc) · 1.55 KB
/
ItemLevel.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
#include "DevilPK.h"
#define INITVAB(l,n) l=l+(DWORD)LoadLibrary(n);
DWORD addr=0xAC236/*76B66*/; // 76B66+6FAB0000=6FB26B66 ||6FB5C236-6FAB0000
byte Backup[6];
bool BackUped=false;
bool ItemLevel=false;
wchar_t * __cdecl wsprintfW2(wchar_t *dest, char *fmt, ...)
{
va_list va;
va_start(va, fmt);
int len = wvsprintf((char *)dest, fmt, va);
for (int i = len; i >= 0; i--) {
dest[i] = ((char *)dest)[i];
}
return dest;
}
void __fastcall ItemNamePatch(wchar_t *name, UnitAny *item)
{
wchar_t Buffer[100]={0};
wsprintfW2(Buffer," [%d]",item->pItemData->dwItemLevel);
wcscat(name,Buffer);
int nSockets = D2COMMON_GetUnitStat(item, 194, 0);
if (nSockets > 0 && (cfg.ItemSockets))
{
wchar_t Buffer[100]={0};
wsprintfW2(Buffer,"(%i)", nSockets);
wcscat(name,Buffer);
}
if (item->pItemData->dwFlags & 0x400000 && (cfg.ItemEth))
{
wchar_t Buffer[100];
wsprintfW2(Buffer,"(Eth)");
wcscat(name,Buffer);
}
// item level
// wsprintfW((name+wcslen(name)), " (%ld)", item->pItemData->nItemLevel);
}
void __declspec(naked) ItemNamePatch_ASM()
{
__asm {
//ebx = ptr unit item
//edi = ptr item name string
mov ecx, edi
mov edx, ebx
call ItemNamePatch
mov al, [ebp+0x12a]
ret
}
}
void InstallItemlvl() {
if(!BackUped) {
INITVAB(addr,"d2client.dll")
WriteBytes(&Backup,(void*)addr,6); BackUped=true;
}
PatchCall(addr,(DWORD)ItemNamePatch_ASM,6);
}
void UninstallItemlvl() {
if(BackUped) {
WriteBytes((void*)addr,&Backup,6);
}
}