Skip to content

Commit

Permalink
Merge pull request planqi#6 from BeLikeLeBron/dschu012-feature/show-m…
Browse files Browse the repository at this point in the history
…ore-items

Dschu012 feature/show more items
  • Loading branch information
BeLikeLeBron authored Sep 21, 2021
2 parents e9ab242 + 5d8d2d3 commit 76d567f
Show file tree
Hide file tree
Showing 3 changed files with 159 additions and 1 deletion.
149 changes: 149 additions & 0 deletions BH/Modules/Item/Item.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ unsigned int Item::trackerPingLevelSetting = -1;
int Item::statRangeColor = TextColor::DarkGreen;
UnitAny* Item::viewingUnit;

LPVOID Item::pItemBuf;


Patch* itemNamePatch = new Patch(Call, D2CLIENT, { 0x92366, 0x96736 }, (int)ItemName_Interception, 6);
Patch* itemPropertiesPatch = new Patch(Jump, D2CLIENT, { 0x5612C, 0x2E3FC }, (int)GetProperties_Interception, 6);
Patch* itemPropertyStringDamagePatch = new Patch(Call, D2CLIENT, { 0x55D7B, 0x2E04B }, (int)GetItemPropertyStringDamage_Interception, 5);
Expand All @@ -79,6 +82,19 @@ Patch* permShowItems3 = new Patch(Call, D2CLIENT, { 0x59483, 0x4EA13 }, (int)Per
Patch* permShowItems4 = new Patch(Call, D2CLIENT, { 0x5908A, 0x4E61A }, (int)PermShowItemsPatch3_ASM, 6);
Patch* permShowItems5 = new Patch(Call, D2CLIENT, { 0xA6BA3, 0x63443 }, (int)PermShowItemsPatch4_ASM, 6);

//credits to rnd2k in DiabloMods discord
Patch* showMoreItems1 = new Patch(Call, D2CLIENT, { 0x58E82, 0x4E412 }, (int)ShowMoreItemsItemsPatch1_ASM, 5);
Patch* showMoreItems2 = new Patch(Call, D2CLIENT, { 0x58F05, 0x4E495 }, (int)ShowMoreItemsItemsPatch2_ASM, 6);
Patch* showMoreItems3 = new Patch(Call, D2CLIENT, { 0x58F2D, 0x4E4BD }, (int)ShowMoreItemsItemsPatch3_ASM, 6);
Patch* showMoreItems4 = new Patch(Call, D2CLIENT, { 0x58F6E, 0x4E4FE }, (int)ShowMoreItemsItemsPatch4_ASM, 6);
Patch* showMoreItems5 = new Patch(Call, D2CLIENT, { 0x58F92, 0x4E522 }, (int)ShowMoreItemsItemsPatch5_ASM, 6);
Patch* showMoreItems6 = new Patch(Call, D2CLIENT, { 0x5909B, 0x4E62B }, (int)ShowMoreItemsItemsPatch6_ASM, 6);
Patch* showMoreItems7 = new Patch(Call, D2CLIENT, { 0x59447, 0x4E9D7 }, (int)ShowMoreItemsItemsPatch7_ASM, 5);

Patch* showMoreItems8 = new Patch(NOP, D2CLIENT, { 0x58E57, 0x4E3E7 }, 0, 3);
Patch* showMoreItems9 = new Patch(JumpRelative, D2CLIENT, { 0x58E5A, 0x4E3EA }, (int)0x1C, 2);
Patch* showMoreItems10 = new Patch(NOP, D2CLIENT, { 0x59087, 0x4E617 }, 0, 9);

using namespace Drawing;

void Item::OnLoad() {
Expand All @@ -98,6 +114,19 @@ void Item::OnLoad() {
itemPropertyStringDamagePatch->Install();
itemPropertyStringPatch->Install();

// 0x120 bytes per item = ~ maximum 3500 items per screen
Item::pItemBuf = VirtualAlloc(0, 0xF7000, MEM_COMMIT + MEM_RESERVE, PAGE_READWRITE);
showMoreItems1->Install();
showMoreItems2->Install();
showMoreItems3->Install();
showMoreItems4->Install();
showMoreItems5->Install();
showMoreItems6->Install();
showMoreItems7->Install();
showMoreItems8->Install();
showMoreItems9->Install();
showMoreItems10->Install();

if (Toggles["Show Ethereal"].state || Toggles["Show Sockets"].state || Toggles["Show iLvl"].state || Toggles["Color Mod"].state ||
Toggles["Show Rune Numbers"].state || Toggles["Alt Item Style"].state || Toggles["Shorten Item Names"].state || Toggles["Advanced Item Display"].state)
itemNamePatch->Install();
Expand Down Expand Up @@ -131,6 +160,7 @@ void Item::LoadConfig() {
BH::config->ReadToggle("Alt Item Style", "None", true, Toggles["Alt Item Style"]);
BH::config->ReadToggle("Color Mod", "None", false, Toggles["Color Mod"]);
BH::config->ReadToggle("Shorten Item Names", "None", false, Toggles["Shorten Item Names"]);
BH::config->ReadToggle("Show More Items", "None", true, Toggles["Show More Items"]);
BH::config->ReadToggle("Always Show Items", "None", false, Toggles["Always Show Items"]);
BH::config->ReadToggle("Advanced Item Display", "None", false, Toggles["Advanced Item Display"]);
BH::config->ReadToggle("Item Drop Notifications", "None", false, Toggles["Item Drop Notifications"]);
Expand Down Expand Up @@ -188,6 +218,30 @@ void Item::ResetPatches() {
permShowItems4->Remove();
permShowItems5->Remove();
}

if (Toggles["Show More Items"].state) {
showMoreItems1->Install();
showMoreItems2->Install();
showMoreItems3->Install();
showMoreItems4->Install();
showMoreItems5->Install();
showMoreItems6->Install();
showMoreItems7->Install();
showMoreItems8->Install();
showMoreItems9->Install();
showMoreItems10->Install();
} else {
showMoreItems1->Remove();
showMoreItems2->Remove();
showMoreItems3->Remove();
showMoreItems4->Remove();
showMoreItems5->Remove();
showMoreItems6->Remove();
showMoreItems7->Remove();
showMoreItems8->Remove();
showMoreItems9->Remove();
showMoreItems10->Remove();
}
}

void Item::DrawSettings() {
Expand Down Expand Up @@ -223,6 +277,10 @@ void Item::DrawSettings() {
new Keyhook(settingsTab, keyhook_x, y+2, &Toggles["Shorten Item Names"].toggle, "");
y += 15;

new Checkhook(settingsTab, 4, y, &Toggles["Show More Items"].state, "Show More Items");
new Keyhook(settingsTab, keyhook_x, y + 2, &Toggles["Show More Items"].toggle, "");
y += 15;

new Checkhook(settingsTab, 4, y, &Toggles["Always Show Items"].state, "Always Show Items");
new Keyhook(settingsTab, keyhook_x, y + 2, &Toggles["Always Show Items"].toggle, "");
y += 15;
Expand Down Expand Up @@ -1428,3 +1486,94 @@ void __declspec(naked) PermShowItemsPatch4_ASM()
ret
}
}

// MOV EAX,OFFSET pBuf
__declspec(naked) void ShowMoreItemsItemsPatch1_ASM() {
__asm
{
mov eax, Item::pItemBuf
retn
}
}

//MOV EAX,DWORD PTR DS:[EAX+pBuf]
__declspec(naked) void ShowMoreItemsItemsPatch2_ASM() {
__asm
{
pushfd
push esi
mov esi, Item::pItemBuf
mov eax, [eax + esi]
pop esi
popfd
retn
}
}

//MOV EAX,DWORD PTR DS:[ECX+pBuf+0x8]
__declspec(naked) void ShowMoreItemsItemsPatch3_ASM() {
__asm
{
pushfd
push esi
mov esi, Item::pItemBuf
add esi, 0x8
mov eax, [ecx + esi]
pop esi
popfd
retn
}
}

//MOV EAX,DWORD PTR DS:[EAX+pBuf+0x4]
__declspec(naked) void ShowMoreItemsItemsPatch4_ASM() {
__asm
{
pushfd
push esi
mov esi, Item::pItemBuf
add esi, 0x4
mov eax, [eax + esi]
pop esi
popfd
retn
}
}

//MOV EAX,DWORD PTR DS:[ECX+pBuf+0xC]
__declspec(naked) void ShowMoreItemsItemsPatch5_ASM() {
__asm
{
pushfd
push esi
mov esi, Item::pItemBuf
add esi, 0xC
mov eax, [ecx + esi]
pop esi
popfd
retn
}
}

//ADD EBP,OFFSET pBuf
__declspec(naked) void ShowMoreItemsItemsPatch6_ASM() {
__asm
{
pushfd
add ebp, Item::pItemBuf
popfd
retn
}
}

//MOV ESI,OFFSET pBuf+0x118
__declspec(naked) void ShowMoreItemsItemsPatch7_ASM() {
__asm
{
pushfd
mov esi, Item::pItemBuf
add esi, 0x118
popfd
retn
}
}
9 changes: 9 additions & 0 deletions BH/Modules/Item/Item.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ class Item : public Module {
static unsigned int pingLevelSetting;
static unsigned int trackerPingLevelSetting;
static int statRangeColor;
static LPVOID pItemBuf;

void ResetPatches();
public:
Expand Down Expand Up @@ -114,6 +115,14 @@ void PermShowItemsPatch2_ASM();
void PermShowItemsPatch3_ASM();
void PermShowItemsPatch4_ASM();

void ShowMoreItemsItemsPatch1_ASM();
void ShowMoreItemsItemsPatch2_ASM();
void ShowMoreItemsItemsPatch3_ASM();
void ShowMoreItemsItemsPatch4_ASM();
void ShowMoreItemsItemsPatch5_ASM();
void ShowMoreItemsItemsPatch6_ASM();
void ShowMoreItemsItemsPatch7_ASM();

struct UnitItemInfo;
int CreateUnitItemInfo(UnitItemInfo *uInfo, UnitAny *item);

Expand Down
2 changes: 1 addition & 1 deletion BH/Patch.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
class Patch;

enum Dll { D2CLIENT=0,D2COMMON,D2GFX,D2LANG,D2WIN,D2NET,D2GAME,D2LAUNCH,FOG,BNCLIENT, STORM, D2CMP, D2MULTI, D2MCPCLIENT};
enum PatchType { Jump=0xE9, Call=0xE8, NOP=0x90, Push=0x6A };
enum PatchType { Jump=0xE9, Call=0xE8, NOP=0x90, Push=0x6A, JumpRelative = 0xEB };

struct Offsets {
int _113c;
Expand Down

0 comments on commit 76d567f

Please sign in to comment.