added original source from http://plugy.free.fr

This commit is contained in:
ChaosMarc 2016-04-18 11:08:37 +02:00
parent deeb863aec
commit 32b737d55e
133 changed files with 24628 additions and 0 deletions

856
Commons/D2Funcs.h Normal file
View File

@ -0,0 +1,856 @@
/*======================================================================
File created by Yohann NICOLAS.
Declares the type for a STDCALL or FASTCALL function pointer
called N with arguments list P, returning R, namedInDLL D and at @A
======================================================================*/
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//D2Common :
////D2S(D2Common,10001, DWORD, D2GetActIDFromLevel, (DWORD levelID));
//D2S(D2Common,11084, DWORD, D2Common11084, (Room* ptRoom, DWORD zero));//use only in 1.11/1.11b
//D2S(D2Common,11021, DWORD, D2GetLevelID, (Room* ptRoom));//1.11b
//D2S(D2Common,10491, Room*, D2GetDropRoom, (Room* ptRoom, Position*, Position*, DWORD, DWORD, DWORD, DWORD));//1.11b
////D2S(D2Common,10149, Inventory*, D2GetInventory, (Unit* ptUnit));
//D2S(D2Common,10242, Unit*, D2Common10242, (Inventory* ptInventory, Unit* ptItem, DWORD bIsClient));
//D2S(D2Common,10813, Unit*, D2CanPutItemInInv, (Inventory* ptInventory, Unit* ptItem, DWORD p3, DWORD zero, Unit* ptUnit, const char* file, DWORD line));//ONLY 1.11b
//D2S(D2Common,10827, Unit*, D2InvRemoveItem, (Inventory* ptInventory, Unit* ptItem));//ONLY 1.11b
//D2S(D2Common,11068, DWORD, D2InvAddItem, (Inventory* ptInventory, Unit* ptItem, DWORD posX, DWORD posY, DWORD vValueC, DWORD bIsClient, BYTE page));//ONLY 1.11b result : boolean 0=echec ; vValueC = 0 for Game.dll, 1 for Clientdll
//D2S(D2Common,10250, DWORD, D2Common10250, (const char* file, DWORD line, Inventory* ptInventory, DWORD posX, DWORD posY, DWORD vValueC, DWORD bIsClient, BYTE page));// result : boolean 0=echec ; vValueC = 0 for Game.dll, 1 for Clientdll
////D2S(D2Common,10257, Unit*, D2GetItemFromBodyLoc, (Inventory* ptInventory, DWORD bodyloc));
//D2S(D2Common,10273, DWORD, D2Common10273, (Inventory* ptInventory, void* unknow));
//D2S(D2Common,10535, Unit*, D2InventoryGetFirstItem, (Inventory* ptInventory));//ONLY 1.11b
//D2S(D2Common,11140, Unit*, D2UnitGetNextItem, (Unit* ptItem));//ONLY 1.11b
//D2S(D2Common,10748, Unit*, D2GetRealItem, (Unit* ptUnit));//ONLY 1.11b
////D2S(D2Common,10321, SkillData*, D2GetLeftSkill, (Unit* ptChar));
////D2S(D2Common,10322, SkillData*, D2GetRightSkill, (Unit* ptChar));
//D2S(D2Common,10326, DWORD, D2GetPosX, (Unit* ptUnit));//NOT IN 1.10
////D2S(D2Common,10328, void, D2SetPosX, (Unit* ptUnit, DWORD pos));
//D2S(D2Common,10329, DWORD, D2GetPosY, (Unit* ptUnit));//NOT IN 1.10
////D2S(D2Common,10331, void, D2SetPosY, (Unit* ptUnit, DWORD pos));
//D2S(D2Common,10056, void, D2GetPosition, (Unit* ptUnit, Position* pos));//1.11b
//D2S(D2Common,10864, DWORD, D2GetMaxGoldBank, (Unit* ptUnit));//1.11b
//D2S(D2Common,10933, Room*, D2GetRoom, (Unit* ptUnit));//1.11b
////D2S(D2Common,10348, void, D2SetUnitMode, (Unit* ptUnit, DWORD mode));
//D2S(D2Common,10394, ObjectsBIN*,D2GetObjectsBIN, (Unit* ptObject));
//D2S(D2Common,10079, PlayerData*,D2InitPlayerData, (Unit* ptChar));//1.11b
//D2S(D2Common,10329, DWORD, D2FreePlayerData, (DWORD game1C, Unit* ptChar));//1.11b
//D2S(D2Common,10800, PlayerData*,D2GetPlayerData, (Unit* ptChar));//ONLY 1.11b
//D2S(D2Common,10431, DWORD, D2GetDefence, (Unit* ptChar));
//D2S(D2Common,10433, DWORD, D2GetChanceToBlock, (Unit* ptChar, DWORD isLODGame));
//D2S(D2Common,11131, DWORD, D2GetMaxGold, (Unit* ptUnit));//1.11b
//D2S(D2Common,10572, DWORD, D2Common10572, (Unit* ptObject, DWORD value));//use only in 1.11/1.11b
////D2S(D2Common,10463, DWORD, D2SetStatWithNoTest, ( Stats* ptStats, DWORD statID, DWORD statValue, DWORD statIndex));
////D2S(D2Common,10464, void, D2AddStat, (Stats* ptStats, DWORD statID, DWORD statValue, DWORD statIndex));
////D2S(D2Common,10465, DWORD, D2SetStat, (Stats* ptStats, DWORD statID, DWORD statValue, DWORD statIndex));
////D2S(D2Common,10466, int, D2GetStat, (Stats* ptStats, DWORD statID, DWORD statIndex));
////D2S(D2Common,10470, Stats*, D2AllocNewStats, (DWORD nUnitId, DWORD flags, DWORD uk18, DWORD nUnitType, DWORD nItemNum));
//D2S(D2Common,11160, BYTE, D2GetObjectFlags, (Unit* ptObject));
//D2S(D2Common,11048, void, D2SetObjectFlags, (Unit* ptObject, BYTE flags));
////D2S(D2Common,10471, DWORD, D2Common10471, (void*));//UNTL 1.10
////D2S(D2Common,10472, DWORD, D2Common10472, (void*));
////D2S(D2Common,10475, void, D2UpdateDisabledStat, (Stats* ptCharStats, Stats* ptStats, DWORD one));
////D2S(D2Common,10481, void*, D2Common10481, (Unit* ptUnit, DWORD flags));
////D2S(D2Common,10484, Stats*, D2GetAffixStats, (Unit* ptItem, DWORD, DWORD));
////D2S(D2Common,10485, void, D2FreeStats, (Stats* ptStats));
//D2S(D2Common,10487, DWORD, D2isInState, (Unit* ptChar, DWORD isLODGame));
////D2S(D2Common,10517, void, D2SetPlayerStat, (Unit* ptChar, DWORD statID, int amount, DWORD index));
//D2S(D2Common,10627, void, D2AddPlayerStat, (Unit* ptChar, DWORD statID, int amount, DWORD index));//ONLY 1.11b
//D2S(D2Common,10061, int, D2GetPlayerStat, (Unit* ptChar, DWORD statID, DWORD index));//ONLY 1.11b
////D2S(D2Common,10520, int, D2GetPlayerStat20, (Unit* ptChar, DWORD statID, DWORD index));
//D2S(D2Common,10550, int, D2GetPlayerBaseStat, (Unit* ptChar, DWORD statID, DWORD index));//ONLY 1.11b
////D2S(D2Common,10527, DWORD, D2Common10527, (Unit* ptUnit));
//D2S(D2Common,10539, DWORD, D2haveDefenceBonus, (Unit* ptChar));
//D2S(D2Common,10540, DWORD, D2haveFireResBonus, (Unit* ptChar));
//D2S(D2Common,10541, DWORD, D2haveColdResBonus, (Unit* ptChar));
//D2S(D2Common,10542, DWORD, D2haveLightResBonus, (Unit* ptChar));
//D2S(D2Common,10543, DWORD, D2havePoisonResBonus, (Unit* ptChar));
//D2S(D2Common,10546, DWORD, D2haveDefenceMalus, (Unit* ptChar));
//D2S(D2Common,10547, DWORD, D2haveFireResMalus, (Unit* ptChar));
//D2S(D2Common,10548, DWORD, D2haveColdResMalus, (Unit* ptChar));
//D2S(D2Common,10549, DWORD, D2haveLightResMalus, (Unit* ptChar));
//D2S(D2Common,10550, DWORD, D2havePoisonResMalus, (Unit* ptChar));
////D2S(D2Common,10552, DWORD, D2Common10552, (Unit* ptUnit));
////D2S(D2Common,10567, DWORD, D2CanBeBroken, (Unit* ptItem));
////D2S(D2Common,10573, void, D2CopyStats, (Stats* ptDestStats, Stats* ptSrcStats));
////D2S(D2Common,10574, void*, D2SetEnabledStat, (Unit* ptItem, DWORD statId, DWORD disabled));
////D2S(D2Common,10575, void, D2FreeBinFiles, ());
////D2S(D2Common,10576, void, D2LoadBinFiles, (DWORD zero1, DWORD zero2, bool));
////D2S(D2Common,10651, DWORD, D2CheckQuestState, (void* ptQuest, DWORD index, DWORD value));//ONLY 1.11
//D2S(D2Common,10496, void*, D2CompileTxtFile, (DWORD unused, const char* filename, BINField* ptFields, DWORD* ptRecordCount, DWORD recordLength));//ONLY 1.11b
//D2S(D2Common,10262, ItemsBIN*, D2GetItemsBIN, (DWORD itemID));//ONLY 1.11b
////D2S(D2Common,10601, ItemsBIN*, D2GetByCodeItemStatsBIN, (DWORD code, DWORD* itemID));
////D2S(D2Common,10604, AffixBIN*, D2GetAffixBIN, (int affixID));
//D2S(D2Common,10523, GemsBIN*, D2GetGemsBIN, (DWORD gemID));//1.11b
//D2S(D2Common,10258, CubeMainBIN*,D2GetCubeMainBIN, (DWORD cubemainID));//ONLY 1.11b
//D2S(D2Common,11135, int, D2GetNbCubeMainBIN, ());//ONLY 1.11b
////D2S(D2Common,10737, LevelsBIN*, D2GetLevelsBIN, (DWORD levelID));
//D2S(D2Common,10628, DWORD, D2GetNextLevelXP, (DWORD classID, DWORD level));
//D2S(D2Common,10629, DWORD, D2GetMaxLevel, (DWORD classID));
//D2S(D2Common,10309, DifficultyLevelsBIN*, D2GetDifficultyLevelsBIN, (DWORD difficultyLevel));
////D2S(D2Common,10659, TreasureClassBIN*, D2GetTreasureClassBIN, (WORD id, DWORD uk));
////D2S(D2Common,10953, SuperUniqueBIN*, D2GetSuperUniqueBIN, (WORD id));//1.11b
//D2S(D2Common,10899, DWORD, D2GetItemQuality, (Unit* ptItem));//1.11b
//D2S(D2Common,10303, DWORD, D2TestFlags, (Unit* ptUnit, DWORD flags, DWORD line, const char* file));//ONLY 1.11b
////D2S(D2Common,10708, void, D2SetFlags, (Unit* ptUnit, DWORD flags, DWORD bitNewValue));
////D2S(D2Common,10709, DWORD, D2GetFlags, (Unit* ptUnit));
////D2S(D2Common,10711, void, D2ItemSetFlags, (Unit* ptItem, DWORD flags, DWORD toSet));// toSet = 0 for set to 0 the selected flags else set to 1
//D2S(D2Common,10100, DWORD, D2GetItemLevel, (Unit* ptItem));//ONLY 1.11b
//D2S(D2Common,10505, BYTE, D2ItemGetPage, (Unit* ptUnit));//ONLY 1.11b
//D2S(D2Common,10608, void, D2ItemSetPage, (Unit* ptItem, BYTE page));//ONLY 1.11b
//D2S(D2Common,10890, DWORD, D2CheckItemType, (Unit* ptItem, DWORD itype));//ONLY 1.11b
//D2S(D2Common,10685, int, D2GetUniqueID, (Unit* ptItem));//1.11b
//D2S(D2Common,10734, void, D2SetAnim, (Unit* ptUnit, int anim));
////D2S(D2Common,10749, void, D2GetWidthHeight, (Unit* ptItem, BYTE* Width, BYTE* Height);
////D2S(D2Common,10751, DWORD, D2GetItemType, (Unit* ptUnit));
////D2S(D2Common,10757, DWORD, D2GetItemLevelReq, (Unit* ptChar, Unit* ptItem));
//D2S(D2Common,10877, int*, D2GetNbRunesBIN, ());//ONLY 1.11b //return the point on th number
//D2S(D2Common,10296, RunesBIN*, D2GetRunesBIN, (int runesID));//ONLY 1.11b
////D2S(D2Common,10792, DWORD, D2CanBeRare, (Unit* ptItem));
////D2S(D2Common,10810, BYTE, D2CheckHasInv, (Unit* ptItem));
////D2S(D2Common,10813, DWORD, D2GetStaffMods, (Unit* ptItem));
////D2S(D2Common,11085, DWORD, D2GetNbSocket, (Unit* ptItem));//1.11b
////D2S(D2Common,10840, DWORD, D2Common10840, (Unit* ptItem, Unit* ptChar));
////D2S(D2Common,10855, void, D2AddAffix, (DWORD, DWORD, Unit* ptItem, AffixBIN* ptAffix, DWORD, DWORD));
////D2S(D2Common,10872, DWORD, D2WarpPlayer, (Path* ptPath, Unit* ptChar, Room* ptRoom, DWORD x, DWORD y));
////D2S(D2Common,10875, WORD, D2GetItemVersion, (Unit* ptItem));
//D2S(D2Common,11068, DWORD, D2isEtheral, (Unit* ptItem));//ONLY UNTIL 1.10 //1.11b
//D2S(D2Common,11156, DWORD, D2SaveItem, (Unit* ptItem, saveBitField* data, DWORD startSize, DWORD p4, DWORD p5, DWORD p6));//1.11b
////D2S(D2Common,10916, void, DoNothing916, ());
////D2S(D2Common,10105, void, D2Common10027, (Unit* ptChar, DWORD skillID));//ONLY 1.11b
////D2S(D2Common,10950, SkillData*, D2GetSkillPointer, (Unit* ptChar, WORD SkillID));
////D2S(D2Common,10256, SkillData*, D2IncSkillBaseLevel, (Unit* ptChar, DWORD skillID));//ONLY 1.11b
//D2S(D2Common,10255, void, D2SetSkillBaseLevel,(Unit* ptChar, DWORD skillID, DWORD slvl, DWORD bRemove, char*, DWORD));//ONLY 1.11b
////D2S(D2Common,10963, DWORD, D2GetSkillID, (SkillData* ptSkill, const char* file, DWORD line));
////D2F(D2Common,10966, SkillsBIN*, D2GetSkillsBIN, (SkillData* ptSkill));
//D2S(D2Common,10109, DWORD, D2GetSkillLevel, (Unit* ptChar, SkillData* ptSkill, DWORD includingBonus));//ONLY 1.11b
////D2S(D2Common,11023, DWORD, D2GetCriticalStrikeFromMasteries, (Unit* ptChar, Unit* ptItem, DWORD zero, DWORD two));
////D2S(D2Common,11007, bool, D2TestQuestState, (void* ptQuest, DWORD QuestID, DWORD QuestState));
////D2S(D2Common,11041, int, D2GetPlayerSkillID, (DWORD playerID, DWORD skillNumber));
////D2S(D2Common,11042, int, D2GetNbSkillsPerPlayer, (DWORD playerID));
////D2S(D2Common,11269, DWORD, D2GetAllIndexFromStat, (Stats* ptStats, DWORD statID, D2Stat* allIndex, DWORD maxIndex));
////D2S(D2Common,11270, DWORD, D2GetAllIndexFromStatID, (Unit* ptItem, DWORD statID, D2Stat* allIndex, DWORD));
//D2S(D2Common,10074, DWORD, D2GetSkillCost, (Unit* ptChar, int skpoints, DWORD skillID, DWORD curSkillLevel));//ONLY 1.11b (not 10447)
//E2F(D2Common,1800, CharStatsBIN*, D2GetCharStatsBIN, (DWORD charID));//1.11b /NOT in 1.10
//E2F(D2Common,1A100, DWORD, D2CompileCubeInput, (CubeInput* cubeinput, char* s, DWORD p1, DWORD p2));//1.11b
//E2F(D2Common,19B40, DWORD, D2CompileCubeOutput, (CubeOutput* cubeoutput, char* s, DWORD p1, DWORD p2));//1.11b
//E2F(D2Common,1380, ItemTypesBIN*, D2GetItemTypesBIN, (DWORD itemTypesId));//ONLY 1.11b
////E2F(D2Common,62FD0, void, D2EncodeValueCheckMax, (saveBitField* data, DWORD value, DWORD bitSize));
//E2F(D2Common,12F0, ItemStatCostBIN*, D2GetItemStatCostBIN, (DWORD id));//ONLY 1.11b
////E2F(D2Common,764A0, void*, D2Common764A0, (Stats* ptStats, DWORD stat, ItemStatCostBIN* itemStatCost ,DWORD));
////E2S(D2Common,76E30, void, D2PreUpdateDisabledStat, (Stats* ptStats));
////E2F(D2Common,76C10, void, D2ApplyStat,(Stats* ptCharStats, DWORD statId, DWORD value, Unit* ptItem));
//E2F(D2Common,98D0, void*, D2ReadFile,(DWORD unused, char* filename, DWORD* size, const char*, DWORD));//1.11b
////E2F(D2Common,94D0, void*, D2GetStringIDForTxtFile,(const char * string));
//E2S(D2Common,32AA0, void, D2LoadSuperuniques,(DWORD mempool));//FASCALL UNTIL 1.10 (1.11b)
//F7(STD, D2Common,00000,00000,00000,00000,10001,00000,00000, DWORD, D2GetActIDFromLevel, (DWORD levelID));
F7(STD, D2Common,00000,00000,00000,10188,11084,11109,10346, DWORD, D2Common11084, (Room* ptRoom, DWORD zero));
F7(STD, D2Common,10057,10057,10057,10332,11021,10511,10826, DWORD, D2GetLevelID, (Room* ptRoom));
F7(STD, D2Common,10138,10138,10138,10623,10491,11043,10654, Room*, D2GetDropRoom, (Room* ptRoom, Position*, Position*, DWORD, DWORD, DWORD, DWORD));
//F7(STD, D2Common,10149,10149,10149,00000,00000,00000,00000, Inventory*, D2GetInventory, (Unit* ptUnit));
F7(STD, D2Common,10242,10242,10242,00000,00000,00000,00000, Unit*, D2Common10242, (Inventory* ptInventory, Unit* ptItem, DWORD bIsClient));
F7(STD, D2Common,10246,10246,10246,10855,10813,10289,10133, Unit*, D2CanPutItemInInv, (Inventory* ptInventory, Unit* ptItem, DWORD p3, DWORD zero, Unit* ptUnit, const char* file, DWORD line));
F7(STD, D2Common,10243,10243,10243,10461,10827,10936,10646, Unit*, D2InvRemoveItem, (Inventory* ptInventory, Unit* ptItem));
F7(STD, D2Common,10249,10249,10249,10880,11068,10436,11107, DWORD, D2InvAddItem, (Inventory* ptInventory, Unit* ptItem, DWORD posX, DWORD posY, DWORD vValueC, DWORD bIsClient, BYTE page));//result : boolean 0=echec ; vValueC = 0 for Game.dll, 1 for Clientdll
F7(STD, D2Common,10250,10250,10250,00000,00000,00000,00000, DWORD, D2Common10250, (const char* file, DWORD line, Inventory* ptInventory, DWORD posX, DWORD posY, DWORD vValueC, DWORD bIsClient, BYTE page));// result : boolean 0=echec ; vValueC = 0 for Game.dll, 1 for Clientdll
//F7(STD, D2Common,10257,10257,10257,00000,00000,00000,00000, Unit*, D2GetItemFromBodyLoc, (Inventory* ptInventory, DWORD bodyloc));
F7(STD, D2Common,10273,10273,10273,00000,00000,00000,00000, DWORD, D2Common10273, (Inventory* ptInventory, void* unknow));
F7(STD, D2Common,10277,10277,10277,10402,10535,11151,10460, Unit*, D2InventoryGetFirstItem, (Inventory* ptInventory));
F7(STD, D2Common,10304,10304,10304,10934,11140,10770,10464, Unit*, D2UnitGetNextItem, (Unit* ptItem));
F7(STD, D2Common,10305,10305,10305,11095,10748,10852,11147, Unit*, D2GetRealItem, (Unit* ptUnit));
//F7(STD, D2Common,10321,10321,10321,00000,00000,00000,00000, SkillData*, D2GetLeftSkill, (Unit* ptChar));
//F7(STD, D2Common,10322,10322,10322,00000,00000,00000,00000, SkillData*, D2GetRightSkill, (Unit* ptChar));
F7(STD, D2Common,10326,10326,00000,00000,00000,00000,00000, DWORD, D2GetPosX, (Unit* ptUnit));//NOT IN 1.10
//F7(STD, D2Common,10328,10328,10328,00000,00000,00000,00000, void, D2SetPosX, (Unit* ptUnit, DWORD pos));
F7(STD, D2Common,10329,10329,00000,00000,00000,00000,00000, DWORD, D2GetPosY, (Unit* ptUnit));//NOT IN 1.10
//F7(STD, D2Common,10331,10331,10331,00000,00000,00000,00000, void, D2SetPosY, (Unit* ptUnit, DWORD pos));
F7(STD, D2Common,10332,10332,10332,11080,10056,10543,10141, void, D2GetPosition, (Unit* ptUnit, Position* pos));
F7(STD, D2Common,10339,10339,10339,10455,10864,10941,11060, DWORD, D2GetMaxGoldBank, (Unit* ptUnit));
F7(STD, D2Common,10342,10342,10342,10172,10933,10366,10331, Room*, D2GetRoom, (Unit* ptUnit));
//F7(STD, D2Common,10348,10348,10348,00000,00000,00000,00000, void, D2SetUnitMode, (Unit* ptUnit, DWORD mode));
//F7(STD, D2Common,10394,10394,10394,00000,00000,00000,00000, ObjectsBIN*,D2GetObjectsBIN, (Unit* ptObject));
F7(STD, D2Common,10420,10420,10420,10218,10079,11097,10356, PlayerData*,D2InitPlayerData, (Unit* ptChar));
//F7(STD, D2Common,10421,10421,10421,10914,10329,00000,00000, DWORD, D2FreePlayerData, (DWORD game1C, Unit* ptChar));
F7(STD, D2Common,10424,10424,10424,10562,10800,10860,10920, PlayerData*,D2GetPlayerData, (Unit* ptChar));
F7(STD, D2Common,10431,10431,10431,00000,00000,00000,00000, DWORD, D2GetDefence, (Unit* ptChar));
F7(STD, D2Common,10433,10433,10433,00000,00000,00000,00000, DWORD, D2GetChanceToBlock, (Unit* ptChar, DWORD isLODGame));
F7(STD, D2Common,10439,10439,10439,10343,11131,10729,10049, DWORD, D2GetMaxGold, (Unit* ptUnit));
F7(STD, D2Common,00000,00000,00000,10440,10572,10481,11090, DWORD, D2Common10572, (Unit* ptObject, DWORD value));
//F7(STD, D2Common,10463,10463,10463,00000,00000,00000,00000, DWORD, D2SetStatWithNoTest, ( Stats* ptStats, DWORD statID, DWORD statValue, DWORD statIndex));
//F7(STD, D2Common,10464,10464,10464,00000,00000,00000,00000, void, D2AddStat, (Stats* ptStats, DWORD statID, DWORD statValue, DWORD statIndex));
//F7(STD, D2Common,10465,10465,10465,00000,00000,00000,00000, DWORD, D2SetStat, (Stats* ptStats, DWORD statID, DWORD statValue, DWORD statIndex));
//F7(STD, D2Common,10466,10466,10466,00000,00000,00000,00000, int, D2GetStat, (Stats* ptStats, DWORD statID, DWORD statIndex));
//F7(STD, D2Common,10470,10470,10470,00000,00000,00000,00000, Stats*, D2AllocNewStats, (DWORD nUnitId, DWORD flags, DWORD uk18, DWORD nUnitType, DWORD nItemNum));
F7(STD, D2Common,00000,00000,00000,10471,11160,10866,10258, BYTE, D2GetObjectFlags, (Unit* ptObject));
F7(STD, D2Common,00000,00000,00000,10572,11048,10150,10111, void, D2SetObjectFlags, (Unit* ptObject, BYTE flags));
//F7(STD, D2Common,10471,10471,10471,00000,00000,00000,00000, DWORD, D2Common10471, (void*));
//F7(STD, D2Common,10472,10472,10472,00000,00000,00000,00000, DWORD, D2Common10472, (void*));
//F7(STD, D2Common,10475,10475,10475,00000,00000,00000,00000, void, D2UpdateDisabledStat, (Stats* ptCharStats, Stats* ptStats, DWORD one));
//F7(STD, D2Common,10481,10481,10481,00000,00000,00000,00000, void*, D2Common10481, (Unit* ptUnit, DWORD flags));
//F7(STD, D2Common,10484,10484,10484,00000,00000,00000,00000, Stats*, D2GetAffixStats, (Unit* ptItem, DWORD, DWORD));
//F7(STD, D2Common,10485,10485,10485,00000,00000,00000,00000, void, D2FreeStats, (Stats* ptStats));
F7(STD, D2Common,10487,10487,10487,00000,00000,00000,00000, DWORD, D2isInState, (Unit* ptChar, DWORD isLODGame));
//F7(STD, D2Common,10517,10517,10517,00000,00000,00000,00000, void, D2SetPlayerStat, (Unit* ptChar, DWORD statID, int amount, DWORD index));
F7(STD, D2Common,10518,10518,10518,10109,10627,10762,10551, void, D2AddPlayerStat, (Unit* ptChar, DWORD statID, int amount, DWORD index));//ONLY 1.11b
F7(STD, D2Common,10519,10519,10519,11092,10061,10658,10973, int, D2GetPlayerStat, (Unit* ptChar, DWORD statID, DWORD index));//ONLY 1.11b
//F7(STD, D2Common,10520,10520,10520,00000,00000,00000,00000, int, D2GetPlayerStat20, (Unit* ptChar, DWORD statID, DWORD index));
F7(STD, D2Common,10521,10521,10521,10733,10550,10494,10587, int, D2GetPlayerBaseStat, (Unit* ptChar, DWORD statID, DWORD index));//ONLY 1.11b
//F7(STD, D2Common,10527,10527,10527,00000,00000,00000,00000, DWORD, D2Common10527, (Unit* ptUnit));
F7(STD, D2Common,10539,10539,10539,00000,00000,00000,00000, DWORD, D2haveDefenceBonus, (Unit* ptChar));
F7(STD, D2Common,10540,10540,10540,00000,00000,00000,00000, DWORD, D2haveFireResBonus, (Unit* ptChar));
F7(STD, D2Common,10541,10541,10541,00000,00000,00000,00000, DWORD, D2haveColdResBonus, (Unit* ptChar));
F7(STD, D2Common,10542,10542,10542,00000,00000,00000,00000, DWORD, D2haveLightResBonus, (Unit* ptChar));
F7(STD, D2Common,10543,10543,10543,00000,00000,00000,00000, DWORD, D2havePoisonResBonus, (Unit* ptChar));
F7(STD, D2Common,10546,10546,10546,00000,00000,00000,00000, DWORD, D2haveDefenceMalus, (Unit* ptChar));
F7(STD, D2Common,10547,10547,10547,00000,00000,00000,00000, DWORD, D2haveFireResMalus, (Unit* ptChar));
F7(STD, D2Common,10548,10548,10548,00000,00000,00000,00000, DWORD, D2haveColdResMalus, (Unit* ptChar));
F7(STD, D2Common,10549,10549,10549,00000,00000,00000,00000, DWORD, D2haveLightResMalus, (Unit* ptChar));
F7(STD, D2Common,10550,10550,10550,00000,00000,00000,00000, DWORD, D2havePoisonResMalus, (Unit* ptChar));
//F7(STD, D2Common,10552,10552,10552,00000,00000,00000,00000, DWORD, D2Common10552, (Unit* ptUnit));
//F7(STD, D2Common,10567,10567,10567,00000,00000,00000,00000, DWORD, D2CanBeBroken, (Unit* ptItem));
//F7(STD, D2Common,10573,10573,10573,00000,00000,00000,00000, void, D2CopyStats, (Stats* ptDestStats, Stats* ptSrcStats));
//F7(STD, D2Common,10574,10574,10574,00000,00000,00000,00000, void*, D2SetEnabledStat, (Unit* ptItem, DWORD statId, DWORD disabled));
//F7(STD, D2Common,10575,10575,10575,00000,00000,00000,00000, void, D2FreeBinFiles, ());
//F7(STD, D2Common,10576,10576,10576,00000,00000,00000,00000, void, D2LoadBinFiles, (DWORD zero1, DWORD zero2, bool));
//F7(STD, D2Common,00000,00000,00000,10651,10651,00000,00000, DWORD, D2CheckQuestState, (void* ptQuest, DWORD index, DWORD value));
F7(STD, D2Common,10578,10578,10578,10653,10496,10244,10849, void*, D2CompileTxtFile, (DWORD unused, const char* filename, BINField* ptFields, DWORD* ptRecordCount, DWORD recordLength));
F7(STD, D2Common,10600,10600,10600,10573,10262,10887,10695, ItemsBIN*, D2GetItemsBIN, (DWORD itemID));
//F7(STD, D2Common,10601,10601,10601,00000,00000,00000,00000, ItemsBIN*, D2GetByCodeItemStatsBIN, (DWORD code, DWORD* itemID));
//F7(STD, D2Common,10604,10604,10604,00000,00000,00000,00000, AffixBIN*, D2GetAffixBIN, (int affixID));
F7(STD, D2Common,10616,10616,10616,10500,10523,10774,10806, GemsBIN*, D2GetGemsBIN, (DWORD gemID));
F7(STD, D2Common,11232,11232,11232,10746,10258,10913,10783, CubeMainBIN*,D2GetCubeMainBIN, (DWORD cubemainID));
F7(STD, D2Common,11233,11233,11233,10639,11135,10390,10675, int, D2GetNbCubeMainBIN, ());
//F7(STD, D2Common,10737,10737,10737,00000,00000,00000,00000, LevelsBIN*, D2GetLevelsBIN, (DWORD levelID));
F7(STD, D2Common,10628,10628,10628,00000,00000,00000,00000, DWORD, D2GetNextLevelXP, (DWORD classID, DWORD level));
F7(STD, D2Common,10629,10629,10629,00000,00000,00000,00000, DWORD, D2GetMaxLevel, (DWORD classID));
F7(STD, D2Common,10655,10655,10655,10655,10309,10297,10218, DifficultyLevelsBIN*, D2GetDifficultyLevelsBIN, (DWORD difficultyLevel));
//F7(STD, D2Common,10659,10659,10659,00000,00000,00000,00000, TreasureClassBIN*, D2GetTreasureClassBIN, (WORD id, DWORD uk));
//F7(STD, D2Common,10668,10668,10668,10450,10953,00000,00000, SuperUniqueBIN*, D2GetSuperUniqueBIN, (WORD id));
F7(STD, D2Common,10695,10695,10695,10927,10899,10276,10106, DWORD, D2GetItemQuality, (Unit* ptItem));
F7(STD, D2Common,10707,10707,10707,10911,10303,10989,10202, DWORD, D2TestFlags, (Unit* ptUnit, DWORD flags, DWORD line, const char* file));
//F7(STD, D2Common,10708,10708,10708,00000,00000,00000,00000, void, D2SetFlags, (Unit* ptUnit, DWORD flags, DWORD bitNewValue));
//F7(STD, D2Common,10709,10709,10709,00000,00000,00000,00000, DWORD, D2GetFlags, (Unit* ptUnit));
//F7(STD, D2Common,10711,10711,10711,00000,00000,00000,00000, void, D2ItemSetFlags, (Unit* ptItem, DWORD flags, DWORD toSet));// toSet = 0 for set to 0 the selected flags else set to 1
F7(STD, D2Common,10717,10717,10717,10898,10100,10410,10086, DWORD, D2GetItemLevel, (Unit* ptItem));
F7(STD, D2Common,10719,10719,10719,10820,10505,10370,10020, BYTE, D2ItemGetPage, (Unit* ptUnit));
F7(STD, D2Common,10720,10720,10720,10485,10608,10223,10012, void, D2ItemSetPage, (Unit* ptItem, BYTE page));
F7(STD, D2Common,10731,10731,10731,11017,10890,10231,10744, DWORD, D2CheckItemType, (Unit* ptItem, DWORD itype));
F7(STD, D2Common,10732,10732,10732,10692,10685,10280,10620, int, D2GetUniqueID, (Unit* ptItem));
F7(STD, D2Common,10734,10734,10734,00000,00000,00000,00000, void, D2SetAnim, (Unit* ptUnit, int anim));
//F7(STD, D2Common,10749,10749,10749,00000,00000,00000,00000, void, D2GetWidthHeight, (Unit* ptItem, BYTE* Width, BYTE* Height);
//F7(STD, D2Common,10751,10751,10751,00000,00000,00000,00000, DWORD, D2GetItemType, (Unit* ptUnit));
//F7(STD, D2Common,10757,10757,10757,00000,00000,00000,00000, DWORD, D2GetItemLevelReq, (Unit* ptChar, Unit* ptItem));
F7(STD, D2Common,10619,10619,10619,10687,10877,10321,11032, int*, D2GetNbRunesBIN, ());//return the point on th number
F7(STD, D2Common,10620,10620,10620,10775,10296,10622,10006, RunesBIN*, D2GetRunesBIN, (int runesID));
//F7(STD, D2Common,10792,10792,10792,00000,00000,00000,00000, DWORD, D2CanBeRare, (Unit* ptItem));
//F7(STD, D2Common,10810,10810,10810,00000,00000,00000,00000, BYTE, D2CheckHasInv, (Unit* ptItem));
//F7(STD, D2Common,10813,10813,10813,00000,00000,00000,00000, DWORD, D2GetStaffMods, (Unit* ptItem));
//F7(STD, D2Common,10816,10816,10816,10816,11085,00000,00000, DWORD, D2GetNbSocket, (Unit* ptItem));
//F7(STD, D2Common,10840,10840,10840,00000,00000,00000,00000, DWORD, D2Common10840, (Unit* ptItem, Unit* ptChar));
//F7(STD, D2Common,10855,10855,10855,00000,00000,00000,00000, void, D2AddAffix, (DWORD, DWORD, Unit* ptItem, AffixBIN* ptAffix, DWORD, DWORD));
//F7(STD, D2Common,10872,10872,10872,00000,00000,00000,00000, DWORD, D2WarpPlayer, (Path* ptPath, Unit* ptChar, Room* ptRoom, DWORD x, DWORD y));
//F7(STD, D2Common,10875,10875,10875,00000,00000,00000,00000, WORD, D2GetItemVersion, (Unit* ptItem));
F7(STD, D2Common,11163,11163,11163,10880,11068,10436,11107, DWORD, D2isEtheral, (Unit* ptItem));//ONLY UNTIL 1.10
F7(STD, D2Common,10881,10881,10881,10956,11156,10218,10987, DWORD, D2SaveItem, (Unit* ptItem, saveBitField* data, DWORD startSize, DWORD p4, DWORD p5, DWORD p6));
//F7(STD, D2Common,10916,10916,10916,00000,00000,00000,00000, void, DoNothing916, ());
//F7(STD, D2Common,10940,10940,10940,10027,10105,10953,00000, void, D2Common10027, (Unit* ptChar, DWORD skillID));
//F7(STD, D2Common,10950,10950,10950,00000,00000,00000,00000, SkillData*, D2GetSkillPointer, (Unit* ptChar, WORD SkillID));
//F7(STD, D2Common,10952,10952,10952,10950,10256,10858,00000, SkillData*, D2IncSkillBaseLevel, (Unit* ptChar, DWORD skillID));
F7(STD, D2Common,10953,10953,10953,10099,10255,10210,10302, void, D2SetSkillBaseLevel,(Unit* ptChar, DWORD skillID, DWORD slvl, DWORD bRemove, char*, DWORD));
//F7(STD, D2Common,10963,10963,10963,00000,00000,00000,00000, DWORD, D2GetSkillID, (SkillData* ptSkill, const char* file, DWORD line));
//F7(FAST, D2Common,10966,10966,10966,00000,00000,00000,00000, SkillsBIN*, D2GetSkillsBIN, (SkillData* ptSkill));
F7(STD, D2Common,10968,10968,10968,10700,10109,10904,10306, DWORD, D2GetSkillLevel, (Unit* ptChar, SkillData* ptSkill, DWORD includingBonus));
//F7(STD, D2Common,11023,11023,11023,00000,00000,00000,00000, DWORD, D2GetCriticalStrikeFromMasteries, (Unit* ptChar, Unit* ptItem, DWORD zero, DWORD two));
//F7(STD, D2Common,11007,11007,11007,00000,00000,00000,00000, bool, D2TestQuestState, (void* ptQuest, DWORD QuestID, DWORD QuestState));
//F7(STD, D2Common,11041,11041,11041,00000,00000,00000,00000, int, D2GetPlayerSkillID, (DWORD playerID, DWORD skillNumber));
//F7(STD, D2Common,11042,11042,11042,00000,00000,00000,00000, int, D2GetNbSkillsPerPlayer, (DWORD playerID));
//F7(STD, D2Common,11269,11269,11269,00000,00000,00000,00000, DWORD, D2GetAllIndexFromStat, (Stats* ptStats, DWORD statID, D2Stat* allIndex, DWORD maxIndex));
//F7(STD, D2Common,11270,11270,11270,00000,00000,00000,00000, DWORD, D2GetAllIndexFromStatID, (Unit* ptItem, DWORD statID, D2Stat* allIndex, DWORD));
F7(STD, D2Common,11276,11276,11276,10254,10074,10111,10435, DWORD, D2GetSkillCost, (Unit* ptChar, int skpoints, DWORD skillID, DWORD curSkillLevel));//not 10447
A7(FAST, D2Common,00000,00000,82C80, 15D0, 1800, 1220, 12D0, CharStatsBIN*, D2GetCharStatsBIN, (DWORD charID));
A7(FAST, D2Common,00000,00000,12410,5D7D0,1A100,116C0,1C020, DWORD, D2CompileCubeInput, (CubeInput* cubeinput, char* s, DWORD p1, DWORD p2));
A7(FAST, D2Common,00000,00000,12910,5D210,19B40,11100,1BA60, DWORD, D2CompileCubeOutput, (CubeOutput* cubeoutput, char* s, DWORD p1, DWORD p2));
A7(FAST, D2Common,00000,00000,2B1A0, 11F0, 1380, 1140, 1300, ItemTypesBIN*, D2GetItemTypesBIN, (DWORD itemTypesId));
//A7(FAST, D2Common,00000,00000,62FD0,00000,00000,00000,00000, void, D2EncodeValueCheckMax, (saveBitField* data, DWORD value, DWORD bitSize));
A7(FAST, D2Common,00000,00000,642B0, 13F0, 12F0, 1540, 17A0, ItemStatCostBIN*,D2GetItemStatCostBIN, (DWORD id));
//A7(FAST, D2Common,00000,00000,764A0,00000,00000,00000,00000, void*, D2Common764A0, (Stats* ptStats, DWORD stat, ItemStatCostBIN* itemStatCost ,DWORD));
//A7(STD, D2Common,00000,00000,76E30,00000,00000,00000,00000, void, D2PreUpdateDisabledStat, (Stats* ptStats));
//A7(FAST, D2Common,00000,00000,76C10,00000,00000,00000,00000, void, D2ApplyStat,(Stats* ptCharStats, DWORD statId, DWORD value, Unit* ptItem));
A7(FAST, D2Common,738A4,739B4,84268, 96E0, 98D0, 9900, 9900, void*, D2ReadFile,(DWORD unused, char* filename, DWORD* size, const char*, DWORD));
//A7(FAST, D2Common,00000,00000, 94D0,00000,00000,00000,00000, void*, D2GetStringIDForTxtFile,(const char * string));
A7(STD, D2Common,1F500,1F510,29FA0,71EB0,32AA0,7D2A0,59870, void, D2LoadSuperuniques,(DWORD mempool));//FASCALL UNTIL 1.10
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//D2Client : 6FAA0000
//E2F(D2Client,A9070, void*, D2LoadImage, (const char* filename, DWORD filetype));//1.11
//E2F(D2Client,0000, void, D2FreeImage, (void* image));//6FAA1140 // NOT IN 1.11
//E2F(D2Client,5E4E0, void, D2SendMsgToAll,(BYTE* data));//1.11 and 1.11b by ESI !!
////E2S(D2Client,15A80, int, D2GetAvgChanceMonsterWillHitYou, ());//6FAB5A80
//E2S(D2Client,15A80, DWORD, D2GetLastMonsterIDFight, ());//6FAB5A80
//E2S(D2Client,89320, void, D2PrintStatsPage, ());//ONLY 1.11b
////E2F(D2Client,45990, Unit*, D245990, (Inventory*,DWORD idItem);//6FAE5990
//E2F(D2Client,21250, DWORD, D2PrintStat,(Unit* ptItem, Stats* ptStats, DWORD statID, DWORD statIndex, DWORD statValue, LPWSTR lpText));//statID=EAX, lpText=ESI 1.11b
//E2F(D2Client,62070, LPWSTR, D2SetColorPopup, (LPWSTR popupText, DWORD color));//1.11 and 1.11b BY EDI
////E2F(D2Client,869F0, Unit*, D2ClientGetObject, (DWORD itemNum, DWORD type));//6FB269F0
//E2F(D2Client,54210, DWORD, D2PlaySound, (DWORD id, DWORD, DWORD, DWORD, DWORD));//1.11b
////E2F(D2Client,BB0F0, void, D2FillRect,(DWORD x, DWORD y, DWORD Width, DWORD Height, DWORD color, DWORD transTbl));//UNITL 1.10
//E2F(D2Client,571C0, Unit*, D2GetCurrentNPC, ());//1.11b
//E2F(D2Client,5DE40, void, D2SendToServerXX,(DWORD size, BYTE * data));//ONLY 1.11b by EBX
//E2F(D2Client,65690, void, D2TogglePage, (DWORD a, DWORD b, DWORD c));//1.11b
//E2F(D2Client,710C0, void, D2ClickOnStashButton, (DWORD x, DWORD y));//STRICT 1.11/1.11b BY x=ESI y=EDI
//E2S(D2Client,621C0, void*, D2LoadBuySelBtn, ());//1.11b
//E2F(D2Client,5BA90, void, D2ReloadGambleScreen, ());//1.11b
//E2F(D2Client,1FEB0, void, D2OpenNPCMenu, (Unit* ptNPC));//1.11b by ESI
A7(FAST, D2Client, 1000, 1000, 1000,75D00,A9070,BEF70,2B420, void*, D2LoadImage, (const char* filename, DWORD filetype));
A7(FAST, D2Client, 1150, 1150, 1140,00000,00000,00000,00000, void, D2FreeImage, (void* image));//6FAA1140
A7(FAST, D2Client, D640, D630, DB50,73620,5E4E0,79670,147A0, void, D2SendMsgToAll,(BYTE* data));//1.11 and 1.11b by ESI !!
//A7(STD, D2Client,00000,00000,15A80,00000,00000,00000,00000, int, D2GetAvgChanceMonsterWillHitYou, ());//6FAB5A80
A7(STD, D2Client,00000,00000,15A80,00000,00000,00000,00000, DWORD, D2GetLastMonsterIDFight, ());//6FAB5A80
A7(STD, D2Client,29800,297F0,2FD60,828A0,89320,6B280,BCEA0, void, D2PrintStatsPage, ());
//A7(FAST, D2Client,00000,00000,45990,00000,00000,00000,00000, Unit*, D245990, (Inventory*,DWORD idItem);//6FAE5990
A7(FAST, D2Client,4BB20,4BB20,521C0,B8CB0,21250,88EA0,54E10, DWORD, D2PrintStat,(Unit* ptItem, Stats* ptStats, DWORD statID, DWORD statIndex, DWORD statValue, LPWSTR lpText));//statID=EAX, lpText=ESI 1.11b
A7(FAST, D2Client,85A60,84DE0,80430,9EEB0,62070,8B7A0,BF5F0, LPWSTR, D2SetColorPopup, (LPWSTR popupText, DWORD color));//1.11 and 1.11b BY EDI
//A7(FAST, D2Client,00000,00000,869F0,00000,00000,00000,00000, Unit*, D2ClientGetObject, (DWORD itemNum, DWORD type));//6FB269F0
A7(FAST, D2Client,B4360,B36E0,B5820,3ACC0,54210,31FA0,88A70, DWORD, D2PlaySound, (DWORD id, DWORD, DWORD, DWORD, DWORD));
//A7(FAST, D2Client,B9970,B8CF0,BB0F0,00000,00000,00000,00000, void, D2FillRect,(DWORD x, DWORD y, DWORD Width, DWORD Height, DWORD color, DWORD transTbl));
A7(FAST, D2Client,00000,00000,00000,00000,571C0,18450,46150, Unit*, D2GetCurrentNPC, ());
A7(FAST, D2Client,00000,00000,00000,73260,5DE40,791A0,143E0, void, D2SendToServerXX,(DWORD size, BYTE * data));//by EBX
A7(FAST, D2Client,88940,87CC0,83260,A1F30,65690,8EF00,C2790, void, D2TogglePage, (DWORD a, DWORD b, DWORD c));
A7(FAST, D2Client,00000,00000,00000,A6520,710C0,A6640,8CD00, void, D2ClickOnStashButton, (DWORD x, DWORD y));//BY x=ESI y=EDI
A7(STD, D2Client,897B0,88B30,84110,9E3B0,621C0,8B8F0,BEAF0, void*, D2LoadBuySelBtn, ());
A7(FAST, D2Client,00000,00000,00000,8E480,5BA90,1CC00,4ABE0, void, D2ReloadGambleScreen, ());
//A7(FAST, D2Client,00000,00000,00000,00000,1FEB0,5CDD0,00000, void, D2OpenNPCMenu, (Unit* ptNPC));//by ESI
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//D2Game : 6FC30000
//D2F(D2Game,10007, void, D2SetNbPlayers, (DWORD nbPlayers));//1.11b
////E2F(D2Game,01DE0, void*, D2GetClientByClientID, (Game* ptGame, DWORD clientID));//6FC31DE0
//E2F(D2Game,E8210, void, D2AddClient, (DWORD clientID));//BY EAX //1.11b
//E2S(D2Game,E49A0, Game*, D2GetGameByClientID, (DWORD clientID));//6FC394E0 //1.11b
//E2F(D2Game,E36D0, void, D2BroadcastFunction, (Game* ptGame, void* fct, void* param));//00DAB0E0//1.11b
//E2F(D2Game,A0D50, DWORD, D2SendPacket, (void* ptNetClient, LPVOID pData, DWORD size));//EAX=ptNetClient [ESP]=pData //1.11b
//E2F(D2Game,A3F20, void, D2SetSkillBaseLevelOnClient, (void* ptClient, Unit* ptChar, DWORD skillID, DWORD sLvl, DWORD bRemove));//ONLY 1.11 by EAX,ESI,EBX
////E2F(D2Game,0E6F0, void, D2UpdateClientItem, (NetClient* ptNetClient, Unit* ptChar, Unit* ptItem,DWORD,DWORD,DWORD));//6FC3E6F0
////E2F(D2Game,10FB0, DWORD, D2UpdateInventory, (Game* ptGame, Unit* ptChar, void* ptNetClient, Inventory* pInventory));//6FC40FB0
////E2F(D2Game,110E0, DWORD, D2UpdateItem, (Unit* ptChar, Unit* ptItem, Unit* ptSocketedItem, void* ptNetClient));//6FC410E0
//E2S(D2Game,109F0, DWORD, D2LinkPortal, (Game* ptGame, Unit* ptObject, DWORD levelEndID, DWORD levelStartID));//ONLY 1.11b
//E2F(D2Game,43E60, DWORD, D2VerifIfNotCarry1, (Unit* ptItem, ItemsBIN* itemsData, Unit* ptFirstItem));// BY EBX=itemsData EAX=ptFirstItem [ESP]=ptItem//1.11b
////E2F(D2Game,1ED80, Unit*, D2CreateItem, (Game* ptGame, ItemGenerationData* itemGenerationData, DWORD));//6FC4ED80
//E2F(D2Game,01DF0, Room*, D2TestPositionInRoom, (Room* ptRoom, DWORD x, DWORD y));//1.11b
////E2F(D2Game,22410, void, D2AddStaffModAffixes, (Unit* ptItem, ItemGenerationData* itemParam));//6FC52410
////E2F(D2Game,22C00, WORD, D2GetNewAffix, (Unit* ptItem, DWORD testIfSpawnable, DWORD mustSelectOne, DWORD addToItem, DWORD isPrefix, int affixID, WORD autoAffixGroupID));//6FC52C00
////E2F(D2Game,23610, WORD, D2GetRareAffixName, (Unit* ptItem, DWORD wantPrefix));//6FC53610
////E2F(D2Game,3AD10, DWORD, D2GetSuperUniqueMonsterID, (Game* ptGame, Unit* ptMonster));//6FC6AD10
//E2F(D2Game,EC7E0, DWORD, D2SpawnMonster, (Game* ptGame, Room* ptRoom, DWORD zero1, DWORD x, DWORD y, DWORD minusOne, DWORD superuniqueID, DWORD zero2));//1.11b (wrong param)
//E2S(D2Game,235C0, void, D2Game235C0, (Game* ptGame, Room* ptRoom));//1.11/1.11b
//E2F(D2Game,4C7B0, Unit*, D2GetSkillItem, (Unit* ptChar));//6FC7C7B0
////E2F(D2Game,5A500, DWORD, D2SavePlayer, (Game* ptGame, Unit* ptChar, char* playername, DWORD zero));//6FC8A500
//E2F(D2Game,25D50, DWORD, D2LoadInventory, (Game* ptGame, Unit* pChar, saveBitField* pdata, DWORD p2, DWORD maxSize, DWORD p4, DWORD *ptNbBytesRead));//6FC8B8A0//1.11b
//E2F(D2Game,BEF80, Unit*, D2GameGetObject, (Game* ptGame, DWORD type, DWORD itemNum));//6FCBBB00//1.11b
//E2F(D2Game,F1C50, Unit*, D2GetOwnerMonster, (Unit* ptMonster));//ONLY 1.11b
////E2F(D2Game,E08D0, void, D2UpdateSkillDataAfterUnassignment, (Game* ptGame, Unit* ptChar, DWORD skillID));//6FD108D0
//E2F(D2Game,C09E0, Unit*, D2CreateUnit, (DWORD type, DWORD id, DWORD x, DWORD y, Game* ptGame, Room* ptRoom, DWORD uk1, DWORD uk2, DWORD uk3));//1.11b
//E2F(D2Game,34920, void, D2OpenPandPortal, (Game* ptGame, Unit* ptChar));//1.11b
//E2F(D2Game,34910, void, D2OpenPandFinalPortal, (Game* ptGame, Unit* ptChar));//1.11b
//E2F(D2Game,85AA0, void, D2MephIA, (Game* ptGame, Unit* ptMonster, DWORD*));//1.11b
//E2F(D2Game,D7BD0, void, D2DiabloIA, (Game* ptGame, Unit* ptMonster, DWORD*));//1.11b
//E2F(D2Game,2BC80, void, D2BaalIA, (Game* ptGame, Unit* ptMonster, DWORD*));//1.11b
//E2F(D2Game,D2D70, void, D2UberMephIA, (Game* ptGame, Unit* ptMonster, DWORD*));//1.11b
//E2F(D2Game,7FE60, void, D2UberDiabloIA, (Game* ptGame, Unit* ptMonster, DWORD*));//1.11b
//E2F(D2Game,2A300, void, D2UberBaalIA, (Game* ptGame, Unit* ptMonster, DWORD*));//1.11b
////E2F(D2Game,92420, void, D2ReloadGambleScreenGame, (Unit* ptNPC, Game* ptGame, Unit* ptChar, DWORD, DWORD one));//1.11b
//E2S(D2Game,E66D0, void, D2SaveGame, (Game* ptGame));//1.11b
F7(FAST, D2Game,10059,10059,10059,10039,10007,10037,10049, void, D2SetNbPlayers, (DWORD nbPlayers));
//A7(FAST, D2Game,00000,00000,01DE0,00000,00000,00000,00000, void*, D2GetClientByClientID, (Game* ptGame, DWORD clientID));//6FC31DE0
A7(FAST, D2Game,00000,00000, 6C60,E3DA0,E8210,EB060,49930, void, D2AddClient, (DWORD clientID));//BY EAX
A7(STD, D2Game,00000,00000, 94E0,E0520,E49A0,A6360,2AAE0, Game*, D2GetGameByClientID, (DWORD clientID));//6FC394E0
A7(FAST, D2Game,00000,00000, B0E0,DF250,E36D0,A5080,29820, void, D2BroadcastFunction, (Game* ptGame, void* fct, void* param));//00DAB0E0
A7(FAST, D2Game, C380, C650, C710,41420,A0D50,7D220,8A3E0, DWORD, D2SendPacket, (void* ptNetClient, LPVOID pData, DWORD size));//EAX=ptNetClient [ESP]=pData
A7(FAST, D2Game, D650, D920, DB50,44D00,A3F20,802E0,8D5F0, void, D2SetSkillBaseLevelOnClient, (void* ptClient, Unit* ptChar, DWORD skillID, DWORD sLvl, DWORD bRemove));//by EAX,ESI,EBX
//A7(FAST, D2Game,00000,00000,0E6F0,00000,00000,00000,00000, void, D2UpdateClientItem, (NetClient* ptNetClient, Unit* ptChar, Unit* ptItem,DWORD,DWORD,DWORD));//6FC3E6F0
//A7(FAST, D2Game,00000,00000,10FB0,00000,00000,00000,00000, DWORD, D2UpdateInventory, (Game* ptGame, Unit* ptChar, void* ptNetClient, Inventory* pInventory));//6FC40FB0
//A7(FAST, D2Game,00000,00000,110E0,00000,00000,00000,00000, DWORD, D2UpdateItem, (Unit* ptChar, Unit* ptItem, Unit* ptSocketedItem, void* ptNetClient));//6FC410E0
A7(STD, D2Game,00000,00000,00000,27230,109F0,AE930,A22E0, DWORD, D2LinkPortal, (Game* ptGame, Unit* ptObject, DWORD levelEndID, DWORD levelStartID));
A7(FAST, D2Game,00000,00000,128F0,38D90,43E60,11FF0,D2070, DWORD, D2VerifIfNotCarry1, (Unit* ptItem, ItemsBIN* itemsData, Unit* ptFirstItem));// BY EBX=itemsData EAX=ptFirstItem [ESP]=ptItem
//A7(FAST, D2Game,00000,00000,1ED80,00000,00000,00000,00000, Unit*, D2CreateItem, (Game* ptGame, ItemGenerationData* itemGenerationData, DWORD));//6FC4ED80
A7(FAST, D2Game,00000,00000,22070, 1090, 1DF0, 11F0, 1280, Room*, D2TestPositionInRoom, (Room* ptRoom, DWORD x, DWORD y));
//A7(FAST, D2Game,00000,00000,22410,00000,00000,00000,00000, void, D2AddStaffModAffixes, (Unit* ptItem, ItemGenerationData* itemParam));//6FC52410
//A7(FAST, D2Game,00000,00000,22C00,00000,00000,00000,00000, WORD, D2GetNewAffix, (Unit* ptItem, DWORD testIfSpawnable, DWORD mustSelectOne, DWORD addToItem, DWORD isPrefix, int affixID, WORD autoAffixGroupID));//6FC52C00
//A7(FAST, D2Game,00000,00000,23610,00000,00000,00000,00000, WORD, D2GetRareAffixName, (Unit* ptItem, DWORD wantPrefix));//6FC53610
//A7(FAST, D2Game,00000,00000,3AD10,00000,00000,00000,00000, DWORD, D2GetSuperUniqueMonsterID, (Game* ptGame, Unit* ptMonster));//6FC6AD10
A7(FAST, D2Game,00000,00000,3F220,4ABE0,EC7E0,40B90,24950, DWORD, D2SpawnMonster, (Game* ptGame, Room* ptRoom, DWORD zero1, DWORD x, DWORD y, DWORD minusOne, DWORD superuniqueID, DWORD zero2));//wrong param
A7(STD, D2Game,00000,00000,00000,D6D10,235C0, D410,200E0, void, D2Game235C0, (Game* ptGame, Room* ptRoom));
//A7(FAST, D2Game,00000,00000,4C7B0,00000,00000,00000,00000, Unit*, D2GetSkillItem, (Unit* ptChar));//6FC7C7B0
//A7(FAST, D2Game,00000,00000,5A500,00000,00000,00000,00000, DWORD, D2SavePlayer, (Game* ptGame, Unit* ptChar, char* playername, DWORD zero));//6FC8A500
A7(FAST, D2Game,4F100,4F500,5B8A0,B9D70,25D50,44950,54810, DWORD, D2LoadInventory, (Game* ptGame, Unit* pChar, saveBitField* pdata, DWORD p2, DWORD maxSize, DWORD p4, DWORD *ptNbBytesRead));//6FC8B8A0
A7(FAST, D2Game,7BAE0,7BFD0,8BB00,97620,BEF80,93650,E03A0, Unit*, D2GameGetObject, (Game* ptGame, DWORD type, DWORD itemNum));//6FCBBB00
//A7(FAST, D2Game,00000,00000,9F320,501C0,F1C50,F1A50,F3220, Unit*, D2GetOwnerMonster, (Unit* ptMonster));
//A7(FAST, D2Game,00000,00000,E08D0,00000,00000,00000,00000, void, D2UpdateSkillDataAfterUnassignment, (Game* ptGame, Unit* ptChar, DWORD skillID));//6FD108D0
A7(FAST, D2Game,00000,00000,00000,99760,C09E0,94E70,E1D90, Unit*, D2CreateUnit, (DWORD type, DWORD id, DWORD x, DWORD y, Game* ptGame, Room* ptRoom, DWORD uk1, DWORD uk2, DWORD uk3));
A7(FAST, D2Game,00000,00000,00000,9B480,34920,D1AA0,70180, void, D2OpenPandPortal, (Game* ptGame, Unit* ptChar));
A7(FAST, D2Game,00000,00000,00000,9B470,34910,D1A90,70170, void, D2OpenPandFinalPortal, (Game* ptGame, Unit* ptChar));
A7(FAST, D2Game,00000,00000,00000,84730,85AA0,DBE90,A9610, void, D2MephIA, (Game* ptGame, Unit* ptMonster, DWORD*));
A7(FAST, D2Game,00000,00000,00000,75980,D7BD0,CD0F0,85B60, void, D2DiabloIA, (Game* ptGame, Unit* ptMonster, DWORD*));
A7(FAST, D2Game,00000,00000,00000,EAB20,2BC80,B3B90,B8610, void, D2BaalIA, (Game* ptGame, Unit* ptMonster, DWORD*));
A7(FAST, D2Game,00000,00000,00000,70320,D2D70,C2A90,7B4E0, void, D2UberMephIA, (Game* ptGame, Unit* ptMonster, DWORD*));
A7(FAST, D2Game,00000,00000,00000,7F200,7FE60,D6250,A39D0, void, D2UberDiabloIA, (Game* ptGame, Unit* ptMonster, DWORD*));
A7(FAST, D2Game,00000,00000,00000,E92B0,2A300,B2210,B6C80, void, D2UberBaalIA, (Game* ptGame, Unit* ptMonster, DWORD*));
//A7(FAST, D2Game,00000,00000,00000,00000,92420,00000,00000, void, D2ReloadGambleScreenGame, (Unit* ptNPC, Game* ptGame, Unit* ptChar, DWORD, DWORD one));
A7(STD, D2Game,00000,00000, 89C0,E2390,E66D0,A8090,2C830, void, D2SaveGame, (Game* ptGame) );
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//D2Net : 6FC00000
//D2S(D2Net,10020, DWORD, D2SendToServer, (DWORD size, DWORD one, void* data));//ONLY 1.11b
//D2S(D2Net,10018, DWORD, D2SendToClient, (DWORD zero, DWORD clientID, void* data, DWORD size));//ONLY 1.11b
F7(STD, D2Net, 10005,10005,10005,10035,10020,10036,10024, DWORD, D2SendToServer, (DWORD size, DWORD one, void* data));//(DWORD zero, void* data, DWORD size) for 1.10 and before
F7(STD, D2Net, 10006,10006,10006,10018,10018,10015,10002, DWORD, D2SendToClient, (DWORD zero, DWORD clientID, void* data, DWORD size));
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//Fog : 6FF50000
//D2S(Fog,10023, void, D2FogAssertOld, (const char* ptMessage, DWORD eip, DWORD line));//ONLY 1.11/1.11b (STDCALL until 1.10)
//D2F(Fog,10024, void, D2FogAssert, (const char* ptMessage, DWORD eip, DWORD line));//ONLY 1.11/1.11b (STDCALL until 1.10)
//D2F(Fog,10042, void*, D2FogMemAlloc, (DWORD dwMemSize, LPCSTR lpszErrFile, DWORD ErrLine, DWORD Zero));
//D2F(Fog,10043, void*, D2FogMemDeAlloc, (void* ptMemLoc, LPCSTR lpszErrFile, DWORD ErrLine, DWORD Zero));//1.11b
//D2F(Fog,10045, void*, D2AllocMem, (DWORD,DWORD dwMemSize, LPCSTR lpszErrFile, DWORD ErrLine, DWORD Zero));//1.11b
//D2F(Fog,10046, void*, D2FreeMem, (DWORD,void* ptMemLoc, LPCSTR lpszErrFile, DWORD ErrLine, DWORD Zero));//1.11b
//D2F(Fog,10102, DWORD, D2MPQOpenFile, (char* ptPath, void** buf));//1.11
//D2F(Fog,10103, DWORD, D2MPQCloseFile, (void* mpqfile));//1.11
//D2F(Fog,10104, DWORD, D2MPQReadFile, (void* mpqfile, BYTE* buffer, DWORD nbToRead, DWORD* nbRead,DWORD,DWORD,DWORD));//1.11
//D2F(Fog,10105, DWORD, D2MPQGetSizeFile, (void* mpqfile, DWORD* toReset));//1.11
//D2F(Fog,10115, void, D2FogGetSavePath, (char* ptPath, DWORD maxsize));//1.11b
//D2F(Fog,10116, void, D2FogGetInstallPath, (char* ptPath, DWORD maxsize));//1.11b
////D2S(Fog,10126, DWORD, D2InitBitField, (saveBitField* data, BYTE* buf, DWORD bufsize));//6FF536C0
////D2S(Fog,10127, DWORD, D2GetBitFieldSize, (saveBitField* data));//6FF536C0
////D2S(Fog,10128, void, D2EncodeValue, (saveBitField* data, DWORD value, DWORD bitSize));//6FF536C0
////D2S(Fog,10130, DWORD, D2DecodeValue, (saveBitField* data,DWORD readingSize));//6FF53840
//D2S(Fog,10212, void, D2Fog10212, (DWORD unknow));//1.11b
////D2S(Fog,10217, int, D2GetIDFromLookUpTable, (void* table, char* string, bool));//6FF53840
//D2S(Fog,10265, int, D2GetInstructionPointer, ());//ONLY 1.11/1.11b NOT 1.10
F7(STD, Fog, 10023,10023,10023,00000,00000,00000,00000, void, D2FogAssertOld, (const char* ptMessage, DWORD eip, DWORD line));//(STDCALL until 1.10)
F7(FAST, Fog, 00000,00000,00000,10024,10024,10024,10024, void, D2FogAssert, (const char* ptMessage, DWORD eip, DWORD line));
F7(FAST, Fog, 10042,10042,10042,10042,10042,10042,10042, void*, D2FogMemAlloc, (DWORD dwMemSize, LPCSTR lpszErrFile, DWORD ErrLine, DWORD Zero));
F7(FAST, Fog, 10043,10043,10043,10043,10043,10043,10043, void*, D2FogMemDeAlloc, (void* ptMemLoc, LPCSTR lpszErrFile, DWORD ErrLine, DWORD Zero));
F7(FAST, Fog, 10045,10045,10045,10045,10045,10045,10045, void*, D2AllocMem, (DWORD,DWORD dwMemSize, LPCSTR lpszErrFile, DWORD ErrLine, DWORD Zero));
F7(FAST, Fog, 10046,10046,10046,10046,10046,10046,10046, void*, D2FreeMem, (DWORD,void* ptMemLoc, LPCSTR lpszErrFile, DWORD ErrLine, DWORD Zero));
F7(FAST, Fog, 10102,10102,10102,10102,10102,10102,10102, DWORD, D2MPQOpenFile, (char* ptPath, void** buf));
F7(FAST, Fog, 10103,10103,10103,10103,10103,10103,10103, DWORD, D2MPQCloseFile, (void* mpqfile));
F7(FAST, Fog, 10104,10104,10104,10104,10104,10104,10104, DWORD, D2MPQReadFile, (void* mpqfile, BYTE* buffer, DWORD nbToRead, DWORD* nbRead,DWORD,DWORD,DWORD));
F7(FAST, Fog, 10105,10105,10105,10105,10105,10105,10105, DWORD, D2MPQGetSizeFile, (void* mpqfile, DWORD* toReset));
F7(FAST, Fog, 10115,10115,10115,10115,10115,10115,10115, void, D2FogGetSavePath, (char* ptPath, DWORD maxsize));
F7(FAST, Fog, 10116,10116,10116,10116,10116,10116,10116, void, D2FogGetInstallPath, (char* ptPath, DWORD maxsize));
//F7(STD, Fog, 10126,10126,10126,10126,10126,10126,10126, DWORD, D2InitBitField, (saveBitField* data, BYTE* buf, DWORD bufsize));//6FF536C0
//F7(STD, Fog, 10127,10127,10127,10127,10127,10127,10127, DWORD, D2GetBitFieldSize, (saveBitField* data));//6FF536C0
//F7(STD, Fog, 10128,10128,10128,10128,10128,10128,10128, void, D2EncodeValue, (saveBitField* data, DWORD value, DWORD bitSize));//6FF536C0
//F7(STD, Fog, 10130,10130,10130,10130,10130,10130,10130, DWORD, D2DecodeValue, (saveBitField* data,DWORD readingSize));//6FF53840
F7(STD, Fog, 10212,10212,10212,10212,10212,10212,10212, void, D2Fog10212, (DWORD unknow));
//F7(STD, Fog, 10217,10217,10217,10217,10217,10217,10217, int, D2GetIDFromLookUpTable, (void* table, char* string, bool));//6FF53840
F7(STD, Fog, 00000,00000,00000,10265,10265,10265,10265, int, D2GetInstructionPointer, ());
//Fog10213 getIndexFromLookupTable (&table,code,bool)
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//D2Lang : 6FC10000
////D2F(D2Lang,10003, LPWSTR, D2GetStringFromString, (const char* ptString));//6FC13BC0
//D2F(D2Lang,10000, LPWSTR, D2GetStringFromIndex, (WORD dwIndexNum));//ONLY 1.11b
////D2S(D2Lang,10006, void, D2GetStringLang, (LPSTR ptLang, DWORD Zero));//6FC13FB0
//D2S(D2Lang,10013, DWORD, D2GetLang, ());//ONLY 1.11b
//D2S(D2Lang,10010, DWORD, D2PrintBigNumber, (LPWSTR ptBuf , DWORD number, DWORD size));//6FC14210
////D2S(D2Lang,10013, DWORD, D2GetStringAndIndexFromString, (const char* ptString , LPWSTR result));//6FC13960
////E2F(D2Lang,29B0, DWORD, D2UnicodeWidth, (DWORD MemLoc, WORD Size));//6FC129B0
////E2F(D2Lang,2E60, LPWSTR, D2GetStrFromIndex , (void* ptFile, void* ptMemLoc, DWORD dwIndexNum));//6FC12E60
////E2F(D2Lang,3640, TblHeader*, D2LoadTblFile, (LPCSTR lpszFileName));//6FC13640
////E2F(D2Lang,3A90, WORD, D2GetStrAndIndexFromString, (void* ptFile, void* ptMemLoc, LPSTR String, LPWSTR RetString));//6FC13A90
////E2F(D2Lang,2CD0, DWORD, D2unicodenwidth, (char* ptChar, DWORD size));//6FC12CD0_unicodenwidth
////E2S(D2Lang,1670, DWORD, D2swprintf, (DWORD bufSize, LPWSTR buf, LPWSTR string, ...));//6FC11670_sprintf
//F7(FAST, D2Lang, 10003,10003,10003,00000,00000,00000,00000, LPWSTR, D2GetStringFromString, (const char* ptString));//6FC13BC0
F7(FAST, D2Lang, 10004,10004,10004,10005,10000,10005,10003, LPWSTR, D2GetStringFromIndex, (WORD dwIndexNum));
//F7(STD, D2Lang, 10006,10006,10006,00000,00000,00000,00000, void, D2GetStringLang, (LPSTR ptLang, DWORD Zero));//6FC13FB0
F7(STD, D2Lang, 10007,10007,10007,10009,10013,10002,10009, DWORD, D2GetLang, ());
F7(STD, D2Lang, 10010,10010,10010,00000,00000,00000,00000, DWORD, D2PrintBigNumber, (LPWSTR ptBuf , DWORD number, DWORD size));//6FC14210
//F7(STD, D2Lang, 10013,10013,10013,00000,00000,00000,00000, DWORD, D2GetStringAndIndexFromString, (const char* ptString , LPWSTR result));//6FC13960
//A7(FAST, D2Lang, 00000,00000,029B0,00000,00000,00000,00000, DWORD, D2UnicodeWidth, (DWORD MemLoc, WORD Size));//6FC129B0
//A7(FAST, D2Lang, 00000,00000,02E60,00000,00000,00000,00000, LPWSTR, D2GetStrFromIndex , (void* ptFile, void* ptMemLoc, DWORD dwIndexNum));//6FC12E60
//A7(FAST, D2Lang, 00000,00000,03640,00000,00000,00000,00000, TblHeader*, D2LoadTblFile, (LPCSTR lpszFileName));//6FC13640
//A7(FAST, D2Lang, 00000,00000,03A90,00000,00000,00000,00000, WORD, D2GetStrAndIndexFromString, (void* ptFile, void* ptMemLoc, LPSTR String, LPWSTR RetString));//6FC13A90
//A7(FAST, D2Lang, 00000,00000,02CD0,00000,00000,00000,00000, DWORD, D2unicodenwidth, (char* ptChar, DWORD size));//6FC12CD0_unicodenwidth
//A7(STD, D2Lang, 00000,00000,01670,00000,00000,00000,00000, DWORD, D2swprintf, (DWORD bufSize, LPWSTR buf, LPWSTR string, ...));//6FC11670_sprintf
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//Storm : 6FFB0000
////D2S(Storm,253, void, D2StormMPQCloseFile, (void* mpqfile));
//D2S(Storm,268, DWORD, D2StormMPQOpenFile, (DWORD zero, LPCSTR fileName, DWORD dwSearchScope, void** buffer));//1.11b
//D2S(Storm,503, void, D2Storm503, (DWORD, DWORD, DWORD)); //+1.11
//D2S(Storm,511, void, D2FreeWinMessage, (sWinMessage* msg));//1.11/1.11b
//F7(STD, Storm, 253, 253, 253, 253, 253, 253, 000, void, D2StormMPQCloseFile, (void* mpqfile));
F7(STD, Storm, 268, 268, 268, 268, 268, 268, 268, DWORD, D2StormMPQOpenFile, (DWORD zero, LPCSTR fileName, DWORD dwSearchScope, void** buffer))
F7(STD, Storm, 503, 503, 503, 503, 503, 503, 503, void, D2Storm503, (DWORD, DWORD, DWORD));
F7(STD, Storm, 511, 511, 511, 511, 511, 511, 511, void, D2FreeWinMessage, (sWinMessage* msg));
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//D2gfx : 6FA70000
//D2S(D2gfx,10063, DWORD, D2GetResolution,() );//ONLY 1.11b
////D2S(D2gfx,10023, DWORD, D2CreateMainWindow,(DWORD,DWORD) );
////D2S(D2gfx,10026, DWORD, D2ShowWindow,() );
////D2S(D2gfx,10027, HWND, D2GetWindowHandle,() );//6FA749C0
//D2S(D2gfx,10000, void, D2FillArea,(DWORD x1, DWORD y1, DWORD x2, DWORD y2, DWORD color, DWORD transTbl));//ONLY 1.11b
//D2S(D2gfx,10044, void, D2PrintImage,(sDrawImageInfo* data, DWORD x, DWORD y, DWORD p4, DWORD p5, DWORD p6) );//ONLY 1.11b
F7(STD, D2gfx, 10005,10005,10005,10000,10063,10043,10031, DWORD, D2GetResolution,() );
//F7,STD, D2gfx, 10023,10023,10023,00000,00000,00000,00000, DWORD, D2CreateMainWindow,(DWORD,DWORD) );
//F7(STD, D2gfx, 10026,10026,10026,00000,00000,00000,00000, DWORD, D2ShowWindow,() );
//F7,STD, D2gfx, 10027,10027,10027,00000,00000,00000,00000, HWND, D2GetWindowHandle,() );//6FA749C0
F7(STD, D2gfx, 10055,10055,10055,10028,10000,10062,10014, void, D2FillArea,(DWORD x1, DWORD y1, DWORD x2, DWORD y2, DWORD color, DWORD transTbl));
F7(STD, D2gfx, 10072,10072,10072,10047,10044,10024,10041, void, D2PrintImage,(sDrawImageInfo* data, DWORD x, DWORD y, DWORD p4, DWORD p5, DWORD p6) );
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//D2Win : 6F8E0000 (1.10 and 1.11)
//D2F(D2Win,10075, void, D2PrintLineOnTextBox,(void* screen, char* s, DWORD color) );//ONLY 1.11b
//D2F(D2Win,10064, void, D2PrintString,(LPWSTR s, DWORD x, DWORD y, DWORD color, DWORD bfalse) );//ONLY 1.11b
//D2F(D2Win,10128, DWORD, D2GetPixelLen,(LPWSTR s) );//ONLY 1.11b
//D2F(D2Win,10170, DWORD, D2SetFont,(DWORD fontID) );//ONLY 1.11b
//D2F(D2Win,10039, void, D2PrintPopup,(LPWSTR s, DWORD x, DWORD y, DWORD color, DWORD center) );//ONLY 1.11b
//D2F(D2Win,10131, void, D2GetPixelRect,(LPWSTR s, DWORD* x, DWORD* y) );//6F8AB260
//D2F(D2Win,10132, DWORD, D2PrintTextPopup,(LPWSTR s, DWORD x, DWORD y, DWORD uk, DWORD type, DWORD color) );//6F8AB080
//D2S(D2Win,10113, void*, D2CreateTextBox,(DWORD* data) );//ONLY 1.11b
F7(FAST, D2Win, 10046,10046,10046,10061,10075,10015,10022, void, D2PrintLineOnTextBox,(void* screen, char* s, DWORD color) );
F7(FAST, D2Win, 10117,10117,10117,10020,10064,10001,10150, void, D2PrintString,(LPWSTR s, DWORD x, DWORD y, DWORD color, DWORD bfalse) );
F7(FAST, D2Win, 10121,10121,10121,10034,10128,10132,10028, DWORD, D2GetPixelLen,(LPWSTR s) );
F7(FAST, D2Win, 10127,10127,10127,10141,10170,10010,10184, DWORD, D2SetFont,(DWORD fontID) );
F7(FAST, D2Win, 10129,10129,10129,10118,10039,10031,10085, void, D2PrintPopup,(LPWSTR s, DWORD x, DWORD y, DWORD color, DWORD center) );
F7(FAST, D2Win, 10131,10131,10131,00000,00000,00000,00000, void, D2GetPixelRect,(LPWSTR s, DWORD* x, DWORD* y) );//6F8AB260
F7(FAST, D2Win, 10132,10132,10132,00000,00000,00000,00000, DWORD, D2PrintTextPopup,(LPWSTR s, DWORD x, DWORD y, DWORD uk, DWORD type, DWORD color) );//6F8AB080
F7(STD, D2Win, 10017,10017,10017,10147,10113,10098,10098, void*, D2CreateTextBox,(DWORD* data) );
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//D2CMP : ????0000
//D2S(D2CMP,10014, DWORD, D2CMP10014, (void* image) );//ONLY 1.11
F7(STD, D2CMP, 10032,10032,10032,10021,10014,10106,10065, DWORD, D2CMP10014, (void* image) );
//ONLY UNTIL 1.10 :
A7(FAST, D2Client, BA00, B9F0, C080,00000,00000,00000,00000, DWORD, D2isLODGame, ());//6FAAC080
A7(FAST, D2Client, 00000,00000, C090,00000,00000,00000,00000, BYTE, D2GetDifficultyLevel, ());//6FAAC090 1.09 should be BA10 (b) BA00 (d)
A7(STD, D2Client, B6670,B59F0,B7BC0,00000,00000,00000,00000, DWORD, D2GetMouseX, ());//6FB57BC0
A7(STD, D2Client, B6680,B5A00,B7BD0,00000,00000,00000,00000, DWORD, D2GetMouseY, ());//6FB57BD0
A7(STD, D2Client, 8DC40,8CFC0,883D0,00000,00000,00000,00000, Unit*, D2GetClientPlayer, ());//6FB283D0
A7(FAST, D2Client, B920, B910, BF60,00000,00000,00000,00000, void, D2CleanStatMouseUp, ());//6FAABF60
A7(FAST, D2Client, D210, D200, D990,00000,00000,00000,00000, void, D2SendToServer3, (BYTE type, WORD p));//6FAAD990
//A7(FAST, D2Client, 00000,00000, DA20,00000,00000,00000,00000, void, D2SendToServer5, (BYTE type, DWORD p));//6FAADA20
//A7(FAST, D2Client, 00000,00000, D9E0,00000,00000,00000,00000, void, D2SendToServer7, (BYTE type, WORD p1, WORD p2, WORD p3));//6FAAD9E0
//A7(FAST, D2Client, 00000,00000, DA40,00000,00000,00000,00000, void, D2SendToServer9, (BYTE type, DWORD p1, DWORD p2));//6FAADA40
//A7(FAST, D2Client, 00000,00000, DA70,00000,00000,00000,00000, void, D2SendToServer13,(BYTE type, DWORD p1, DWORD p2, DWORD p3));//6FAADA70
A7(FAST, D2Game, 7C2C0,7C7B0,8C2E0,00000,00000,00000,00000, NetClient*, D2GetClient, (Unit* ptUnit, char* lpszErrFile, DWORD ErrLine));//6FCBC2E0
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////// VARIABLES ////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//Data D2Client : 6FAA0000
////E2C(D2Common,96A20, DataTables*,SgptDataTables); //03836A20 - 037A0000 //01EE6A20
//E2C(D2Client,F4FC8, DWORD, ResolutionY);//0x258 = 600 //1.11b
//E2C(D2Client,F4FC4, DWORD, ResolutionX);//0x320 = 800 //1.11b
//E2C(D2Client,11BEFC,DWORD, NegWindowStartY);//0xFFFFFFC4 = -60 //1.11b
//E2C(D2Client,11BEF8,DWORD, WindowStartX);//0x50 = 80 //1.11b
////E2C(D2Launch,2CD5C, DWORD, GameTypeMode);//0x50 = 80 //6FA3CD5C-6FA10000
//E2C(D2Game, 111718,NetClient*, ClientTable);//1.11
////E2C(D2Client,104225,DWORD, CurrentNPCNum);//1.11b
//E2C(D2Client,11A2F4,DWORD, IsLodGame);//1.11
//E2C(D2Client,11BFB8,BYTE, DifficultyLevel);//1.11
//E2C(D2Client,11B414,DWORD, MouseY);//0x258 = 600 //1.11b
//E2C(D2Client,11B418,DWORD, MouseX);//0x320 = 800 //1.11b
//E2C(D2Client,11C1E0,Unit*, ptClientChar);//1.11b
//C7(D2Common,000000,000000, 96A20, 9B74C, 9EE8C, 9B500, 99E1C, DataTables*,SgptDataTables); //03836A20 - 037A0000 //01EE6A20
C7(D2Client, D50E8, D40E0, D40F0, F5C60, F4FC8, DC6E4, DBC4C, DWORD, ResolutionY);//0x258 = 600
C7(D2Client, D50EC, D40E4, D40F4, F5C5C, F4FC4, DC6E0, DBC48, DWORD, ResolutionX);//0x320 = 800
C7(D2Client,125AD8,124958,11A74C,11BD28,11BEFC,11BD2C,11B9A4, DWORD, NegWindowStartY);//0xFFFFFFC4 = -60
C7(D2Client,125AD4,124954,11A748,11BD24,11BEF8,11BD28,11B9A0, DWORD, WindowStartX);//0x50 = 80
//C7(D2Launch, 55818, 56088, 2CD5C,000000, 2CD5C,000000,000000, DWORD, GameTypeMode);//0x50 = 80 //6FA3CD5C-6FA10000
C7(D2Game, F2A80, F2918,113FB8,111718,1115E0,1105E0,1107B8, NetClient*, ClientTable);
//C7(D2Client,000000,000000,000000,000000,104225,000000,000000, DWORD, CurrentNPCNum);
C7(D2Client,000000,000000,000000, FB3F4,11A2F4,10330C,119854, DWORD, IsLodGame);
C7(D2Client,000000,000000,10795C,11BFB8,11C2A8,11BFF4,000000, BYTE, DifficultyLevel);
C7(D2Client,000000,000000,000000,10A40C,11B414,101634,11B824, DWORD, MouseY);//0x258 = 600
C7(D2Client,000000,000000,000000,10A410,11B418,101638,11B828, DWORD, MouseX);//0x320 = 800
C7(D2Client,000000,000000,000000,11C4F0,11C1E0,11C3D0,11BBFC, Unit*, ptClientChar);
C7(D2Client, DB918, DA828,000000,000000,000000,000000,000000, DWORD, NbStatDesc);
C7(D2Client, DAF98, D9EA8,000000,000000,000000,000000,000000, DWORD, StatDescTable);
/* NEXT NOT TESTED IN 1.10 (1.09b fct)
D2_STD(D2Common10066, void, D2RemoveFromRoom, (DrlgRoom1* hRoom, DWORD untitype, DWORD unitID), 0x6FD7CFD0);
D2_STD(D2Common10082, DWORD, D2IsTown, (DrlgRoom1* hRoom), 0x6FD7D8A0);
D2_STD(D2Common10180, Unit*, D2GetTargetFromPath, (Path* hPath), 0x6FD9C4C0);
D2_STD(D2Common10184, void, D2SetPathParameter, (Path* hPath, DWORD value), 0x6FD9C5D0);
D2_STD(D2Common10240, Inventory*, D2InitInventory, (DWORD zero, DWORD param1, DWORD param2, DWORD param3, DWORD one), 0x6FD7E920);
D2_STD(D2Common10253, bool, D2EquipUnit, (Unit* ptTaker, Unit* ptItem, DWORD bodyloc), 0x6FD80020);
D2_STD(D2Common10258, Unit*, D2GetWeaponUnit, (Inventory* ptInventory), 0x6FD802D0);
D2_STD(D2Common10261, void*, D2SetMouseItem, (Inventory* ptInventory, Unit* ptUnit), 0x6FD80520);
D2_STD(D2Common10310, Node*, D2GetNodeForItem, (Inventory* ptInventory, Unit* ptUnit), 0x6FD82FB0);
D2_STD(D2Common10320, SkillData*, D2GetStartingSkill, (Unit* ptUnit), 0x6FDAD8C0);
D2_STD(D2Common10321, SkillData*, D2GetLeftHandSkill, (Unit* ptUnit), 0x6FDAD900);
//D2_STD(D2Common10322, SkillData*, D2GetRightSkill, (Unit* ptUnit), 0x6FDAD940);
D2_STD(D2Common10323, SkillData*, D2GetCurrentSkill, (Unit* ptUnit), 0x6FDAD9C0);
D2_STD(D2Common10326, DWORD, D2UNITGetXpos, ( Unit* ptUnit ), 0x6FDADA00);
D2_STD(D2Common10329, DWORD, D2UNITGetYpos, ( Unit* ptUnit ), 0x6FDADB70);
//D2_STD(D2Common10348, void, D2SetUnitMode, (Unit* ptUnit, DWORD mode), 0x6FDAEBD0);
D2_STD(D2Common10395, ShrinesTXT*, D2GetShrinesTXTRowFromID, (DWORD shrineID), 0x6FDAFE20);
D2_STD(D2Common10659, void*, D2GetTCFromID, (DWORD TCIndex), 0x6FD5E1C0);
//D2_STD(D2Common10517, void, D2SetPlayerStat, (Unit* ptChar, DWORD statID, DWORD Amount), 0x6FDA7D30);
//D2_STD(D2Common10581, CharStatsBIN*,D2GetCharStatsBIN, (DWORD classID), offset_D2Common + 0x6FD47430);
D2_STD(D2Common10746, DWORD, D2GetCode, (Unit* ptUnit), 0x6FD8AD70);
D2_STD(D2Common10749, void, D2ITEMSGetItemDimensions, (Unit* ptItem, DWORD* x, DWORD* y, char* filename, DWORD line), 0x6FD8AF00);
D2_STD(D2Common10795, DWORD, D2GetMaxStack, (Unit* ptUnit), 0x6FD8EEF0);
D2_STD(D2Common10804, DWORD, D2GetSpellIcon, (Unit* ptUnit), 0x6FD8F190);
D2_STD(D2Common10821, DWORD, D2IsSocketValid, (Unit* ptItem ), 0x6FD8FD70);
//D2_STD(D2Common10854, void, D2RemoveItem, (Unit* ptUnit, BYTE page), 0x6FD89DC0);
D2_STD(D2Common10868, void, D2SetMod, (Unit* ptUnit, ItemMod* ptProperty, int one), 0x6FD88950);
D2_FST(D2Common10918, DWORD, D2GetRandomInt, (D2Seed* ptSeed, int max), 0x6FDA0B10);
D2_STD(D2Common10952, Unit*, D2AddSingleSkill, (Unit* ptChar, WORD SkillID), 0x6FDA1CB0); // WORD ?
D2_FST(D2Common10966, Unit*, D2GetSkillPointerFromClient, (Unit* ptClientChar), 0x6FDA33A0);
D2_FST(D2Common6FC82E00,DWORD, D2GetItemNum, (D2Game* ptGame, DWORD lvl, DWORD typenum), 0x6FC82E00);
D2_FST(D2Game6FC3E3F0, void, D2ClientItemRemove, (void* ptClient, Unit* ptChar, Unit* ptItem, DWORD twenty), 0x6FC3E3F0);
D2_FST(D2Game6FC3E640, void, D2FireScrollGraph, (void* ptClient, Unit* ptItem, int one, DWORD dwStatID, DWORD dwStatNum), 0x6FC3E640);
D2_FST(D2Game6FC3E6C0, void, D2SetMouseIcon, (void* ptGame, Unit* ptChar, int nSpellicon, int zero, int one, DWORD dwUnknown), 0x6FC3E6C0);
D2_FST(D2Game6FC3E740, void*, D2ResetMouse, (void* ptClient, Unit* ptChar), 0x6FC3E740);
D2_FST(D2Game6FC45BD0, DWORD, D2SwapItem, (D2Game* ptGame, Unit* ptChar, DWORD dwSrcID, DWORD dwTrgID, int x, int y, void* ptMouse), 0x6FC45BD0);
D2_FST(D2Game6FC45FE0, void, D2RemoveItemMem, (D2Game* ptGame, Unit* ptChar, Unit* ptItem, DWORD zero), 0x6FC45FE0);
D2_FST(D2Game6FC480D0, DWORD, D2PutScroll, (D2Game* ptGame, Unit* ptChar, DWORD dwSrcID, DWORD dwTrgID, void* ptMouse), 0x6FC480D0);
D2_FST(D2Game6FC497B0, void, D2UpdatePlayer, (void * ptGame, Unit* ptChar, DWORD nUnitType), 0x6FC497B0);
D2_FST(D2Game6FC4E170, void*, D2RemoveItemFromMem, (void* ptGame, Unit* ptItem), 0x6FC4E170);
D2_FST(D2Game6FC4E290, void*, D2GetPtrFromCode, (void* ptChar, DWORD itemcode), 0x6FC4E290);
D2_FST(D2Game6FC87E40, void, D2SpawnItem, (void* ptGame, Unit* ptChar, DWORD itemCode, DWORD ilvl, DWORD quality, DWORD one), 0x6FC87E40);
D2_FST(D2Game6FC4EF60, void, D2DropTC, (void* ptGame, Unit* ptChar, Unit* ptNPC, void* ptTC, DWORD z5, DWORD ilvl, DWORD z1, DWORD z2, DWORD z3, DWORD z4), 0x6FC4EF60);
D2_FST(D2Game6FCABAE0, Unit*, D2GetPtrFromID, (D2Game* ptGame, int UnitType, DWORD UniqueID), 0x6FCABAE0);
D2_FST(D2Game6FCABB70, void, D2SpawnPlague, (void* u1,Unit* ptMissile), 0x6FCABB70);
D2_FST(D2Client6FAB9AF0,void, D2FireClientMissile, (Unit* ptUnit), 0x6FAB9AF0);
D2_FST(D2Client6FAE6600,void, D2CubeLight, (DWORD code), 0x6FAE6600);
D2_FST(D2Client6FB22270,void, D2ScrollText, (Unit* ptUnit, DWORD ptText, int zero), 0x6FB22270);
D2_FST(D2Client6FB2C1E0,Unit*, D2GetClientUnit, (DWORD itemID, DWORD nUnitType), 0x6FB2C1E0);
D2_FST(D2Client6FB30470,void, D2ClientUpdatePlayer, (Unit* ptChar, DWORD nUnitType), 0x6FB30470);
Storm 1.09:
251 SFileAuthenticateArchive
252 SFileCloseArchive
253 SFileCloseFile
254 SFileDdaBegin
255 SFileDdaBeginEx
256 SFileDdaDestroy
257 SFileDdaEnd
258 SFileDdaGetPos
259 SFileDdaGetVolume
260 SFileDdaInitialize
261 SFileDdaSetVolume
262 SFileDestroy
263 SFileEnableDirectAccess
264 SFileGetFileArchive
265 SFileGetFileSize
266 SFileOpenArchive
267 SFileOpenFile
268 SFileOpenFileEx
269 SFileReadFile
270 SFileSetBasePath
271 SFileSetFilePointer
272 SFileSetLocale
273 SFileGetBasePath
274 SFileSetIoErrorMode
275 SFileGetArchiveName
276 SFileGetFileName
277 SFileGetArchiveInfo
278 SFileSetPlatform
279 SFileLoadFile
280 SFileUnloadFile
281 SFileLoadFileEx
282 SFilePrioritizeRequest
283 SFile_CancelRequest
284 SFileSetAsyncBudget
285 SFileSetDataChunkSize
286 SFileEnableSeekOptimization
287 SFileReadFileEx
288 SFile_CancelRequestEx
289 SFileReadFileEx2
290 SFileLoadFileEx2
Storm1.08
401 SMemAlloc
403 SMemFree
404 SMemGetSize
405 SMemReAlloc
481 SMemFindNextBlock
482 SMemFindNextHeap
483 SMemGetHeapByCaller
484 SMemGetHeapByPtr
485 SMemHeapAlloc
486 SMemHeapCreate
487 SMemHeapDestroy
488 SMemHeapFree
489 SMemHeapReAlloc
490 SMemHeapSize
491 SMemCopy
492 SMemFill
493 SMemMove
494 SMemZero
495 SMemCmp
496 SMemSetDebugFlags
497 SMemDumpState
*/
//Kingpin: D2Common #10027 is used to get dest unit (used for get type5 object in next room)
//D2Common10247, (ptInventory, ptItem, x,y,0xC,void*,void*,BYTE page) verif if items can be put in inventory
//D2Common10252 CheckGrid mouse over inventory/stash/etc. grid
//D2Common10284 returns current number of used sockets arg1 = ptInventory //KP
//D2Common10367 Returns number of rows in belt Kingpin: arg1 = ptItem
//D2Common10526 Kingpin know arg1 = ptUnit, arg3 = _FILE_, arg4 = ptGame
//D2Common10573 arg2 ptStatsList
//D2Common10660 is for sure returning tc entry it uses act, difficulty as params and one more, arg3 = depends of area level (0-2)
//D2Common11064 Kingpin: Check if monster and check if current animation mode is allowed arg1 = ptUnit
//D2Common11257 Get MaxID from SuperUnique.bin adress in memory arg1 = hcIdx
//D2LoadItem D2Common10883 + 0x60370);//01D40370-1ce0000
//D2TcEx (select what item to drop from the treasureclass) at:6FC51360
//D2_STD(D2Common10578, BYTE*, D2LoadBinFile, (...), offset_D2Common + 0xFD70); //01CFFD70-01CF0000
//Kingpin :I have noted that 10732 is this: get set/unique # [[+70]+24]
/*
Kingpin: d2common #11270
Kingpin: Check MonType.txt line to see if it match (returns a boolan)
Kingpin: arg1 = unknown
arg2 = damage_vs_montype (stat from intestatscost.txt)
arg3 = ptUnit
arg4 = 80 (maxline maybe, but is only guessing)
//d2game.6FD1D660 reverse player name :P
Kingpin: figured out a new t hing related to D2common #10466 :P
Yohann: ah ?
Kingpin: get stat (from itemstatscost.txt) used to calculated frames (life, missile, mana e.tc)
Kingpin: arg1 = ptUnit
Kingpin: arg2 = stat_id
Kingpin: arg3 = table index
D2Game.6FCBC900 Get Target ptUnit
Kingpin: D2Client.6FB18770 returns a boolean if you have enough mana for skill
Kingpin: D2Client.6FB18AC0 sets it to selectable or not
D2Common #10480 Return ptState arg1 = ptUnit, arg2 = state_id
D2Common #10479 Get State_ID from ptState+14
D2Common #11265 Get Skill_ID from ptState+1C Arg1 = ptState
Kingpin: D2Common #10497 Get Duration of State
Kingpin: arg1 = state_id
D2Client.6FB5B0F0
Function: Draw Filled Rectangle
void FASTCALL D2ClientFillRect(int x, int y, int Width, int Height, ULONG ulColor, ULONG transTbl);
D2_FST(D2Client6FB5B0F0,void, D2ClientFillRect,(int x, int y, int Width, int Height, DWORD col, DWORD transTbl), offset_D2Client + 0xBB0F0);//6FB5B0F0-6FAA0000
D2Gfx.#10055
Function: Draw Filled Rectangle
void STDCALL D2GfxFillRect(int left, int top, int right, int bottom, ULONG ulColor, ULONG transTbl);
NOTES:
color = Palette index.
transTbl = pl2 transform table index ...
0 = 75% transparent
1 = 50% transparent
2 = 25% transparent
3 = color blend 1 //white is transparent black is solid
4 = color blend 2 //black is transparent white is solid
5 = normal draw
6 = color blend 3 // screen + color
7 = hilight
6FAE7831 E8 9A380800 CALL <JMP.&D2Common.#10252> ; click inventory
6FAE8D44 E8 87230800 CALL <JMP.&D2Common.#10252> ; Right click inventory
6FAE8972 E8 59270800 CALL <JMP.&D2Common.#10252> ; mouse over
D2Client.6FACFCD0 then that set color for the text (it calls in this function #10121 and 10117)
Kingpin: and the position
Kingpin: arg1 = Xpos
arg2 = Ypos
arg3 = Pointer to Unicode String
arg4 = Color
Kingpin: 10470 has as first arg ptGame +1C (memory alloc thing)
Kingpin: arg2 = flags i guess since they use 0x40 again
Kingpin: arg3 = 0 (no idea what it used for)
Kingpin: arg4 = 4 (same here, no idea)
Kingpin: arg5 = uniqueID
Kingpin: 10868 SetMod
arg1 = ptItem
arg2 = ItemMod
arg3 = 1
Kingpin: 11232 Get Cube Recipe Record (Line) from Cubemain.bin Address in memory
Kingpin: i have no parameters for 11232
Kingpin: 11233 Get Number of Cube Recipes
Kingpin: edi contains target unit
Kingpin: 10342 get ptRoom from target unit
Kingpin: ecx = unique unit id
Kingpin: ebx = unit type
Kingpin: eax = ptRoom
Kingpin: 10066 remove unit from room
D2Game.6FCBC900 ; Get Target Unit
Arg1 = ptPlayer (ptUnit)
Arg2 = ptGame
#10962 Add skill to player
Kingpin: arg1 ptPlayer
arg2 SkillID
Kingpin: arg3 Skill Level
10602 Gets an item ID # from an item code
Kingpin: get Prefix/suffix
Kingpin: #10699 arg1 = ptItem, arg2 = prefix Index
Kingpin: #10701 arg1 = ptItem, arg2 = suffix index
D2EquipUnit STDCALL_FUNCTION(int, D2Common280D, (Inventory* ptInventory, Unit* ptItem, int bodylocation));
D2AddItemToInventory STDCALL_FUNCTION(int, D2Common2802, (Inventory* ptInventory, Unit* ptItem, int nodePage));
Kingpin: in my notes it should start here
Kingpin: 6FC51360 /$ 55 PUSH EBP
D2DropTC FASTCALL_FUNCTION(void, D2Game6FC51360, (D2Game* ptGame, Unit* ptChar, Unit* ptNPC, void* ptTC, DWORD z5, DWORD ilvl, DWORD z1, DWORD z2, DWORD z3, DWORD z4));
Kingpin: D2CreateItemUnit FASTCALL_FUNCTION(Unit*, D2Game6FC501A0, (Unit* ptPlayer, DWORD itemCode, D2Game* ptGame, DWORD uk1, DWORD quality, DWORD uk3, DWORD uk4, DWORD Lvl, DWORD uk5, DWORD uk6, DWORD uk7));
ptItem = D2CreateItemUnit(ptPlayer, D2GetItemIDfromCode(CharstatTXT->Item1), PCGame, 4, 2, 1, 1, D2GetUnitStat(ptPlayer,STATS_LEVEL,0), 0, 0, 0);
Kingpin: monsterData +28 holds ptGame
Kingpin: ptGame +2C UniqueID (owner ID)
Kingpin: ptGame +30 UnitType
srvDoFunc 15 adds temporarly a stat
Kingpin: we have 10041 that get ptRoom from ptAct, XOffset&Yoffset
*/
/*================================= END OF FILE =================================*/

672
Commons/D2UnitStruct.h Normal file
View File

@ -0,0 +1,672 @@
/*=================================================================
File created by Yohann NICOLAS.
@brief Diablo II Unit Structures definitions.
NOT TESTED IN 1.10 (1.09b)
=================================================================*/
#pragma once
#include <windows.h>
struct CBPlayerData;
struct CBItemData;
struct Unit;
/*=================================================================*/
/* Skill Structure. */
/*=================================================================*/
struct SkillData
{ //Offset from Code. (size = 0x3C or 0x40)
SkillsBIN* ptSkillBin; //+00
SkillData* ptNextSkill; //+04
DWORD mode; //+08
DWORD uk1[3]; //+0C
DWORD targetInfo; //+18
DWORD targetType; //+1c
DWORD targetUNID; //+20
DWORD uk2; //+24
DWORD slvl; //+28
DWORD slvlBonus; //+2c
DWORD uk3; //+30
int state; //+34 (-1 if index exist)
DWORD param1; //+38 (nb current charge)
DWORD param2; //+3C
};
struct Skills
{ //Offset from Code.
DWORD gameRelated; //+00
SkillData* ptFirstSkill; //+04
SkillData* ptLeftSkill; //+08
SkillData* ptRightSkill; //+0c
SkillData* ptCurrentSkill; //+10
};
/*=================================================================*/
/* Unit Data Structure. */
/*=================================================================*/
struct Position
{
DWORD x;
DWORD y;
};
struct Room//size=0x80
{
//ptRoom +48 0 = spawn new units (monster, objects e.tc), 1 = don't spawn any new units
DWORD seed1; //+00
DWORD seed2; //+04
BYTE uk8[0x1C]; //+08
Room* ptNearRooms; //+24
DWORD nbNearRooms; //+28
Unit* unit; //+2C
BYTE uk5[0x44]; //+30
Room* ptNextRoom; //+74
union
{
BYTE flags; //+78
struct
{
BYTE isGenerated:1;
BYTE isGenerated2:1;//???
};
};
};
struct ActMap//ptGame+BC size=0x60
{
DWORD isNotManaged;
DWORD uk4;
DWORD uk8;//size = 0x488
Room* ptFirstRoom;
};
struct NetClient;
//ptGame : 04E4007C
struct Game
{ //Offset from Code.
BYTE uk1[0x18]; //+00
DWORD _ptLock; //+18 Unknown
DWORD memoryPool; //+1C Memory Pool (??)
BYTE uk2[0x4D]; //+20
BYTE difficultyLevel; //+6D (Difficulty 0,1 or 2)
WORD unknown1; //+6E Cube puts 4 here
DWORD isLODGame; //+70 (D2=0 LOD =1) (DWORD ?)
BYTE uk3[0x04]; //+71
WORD unknown2; //+78
BYTE uk4[0x0E]; //+7A
NetClient* ptClient; //+88
BYTE uk8C[0x30]; //+8C
ActMap* mapAct[5]; //+BC
BYTE ukD0[0x1024]; //+D0
DWORD* game10F4; //+10F4
BYTE uk6[0x28]; //+10F8
Unit* units[0xA00]; //+1120
Unit* roomtitles[0x200]; //+1B20
};
//WORD ptGame+28 game ID ?
struct Path //(8 dword)
{ //Offset from Code. Size: 20
WORD uk1; //+00
WORD mapx; //+02
WORD uk2; //+04
WORD mapy; //+06
DWORD uk3; //+08
DWORD x; //+0C
DWORD y; //+10
DWORD uk6; //+14
DWORD uk7; //+18
Room* ptRoom; //+1C
};
struct Inventory
{ //Offset from Code. Size: 30 à 40
DWORD tag; //+00 = 0x01020304
BYTE uk1[0x04]; //+04 =? 0
Unit* ptChar; //+08
Unit* ptItem; //+0C
BYTE uk2[0x10]; //+10
Unit* inventory1; //+20
BYTE uk3[0x04]; //+24
DWORD currentUsedSocket; //+28 //Kingpin : a variable to know how many sockets that have added to item
DWORD Inventory2C; //+2C //one value
DWORD Inventory30; //+30
void* ptCorpse; //+34
BYTE uk5[0x04]; //+38
DWORD nextCorpseId; //+3C //max = 15
BYTE uk6[0x04]; //+40
};
struct D2Stat
{
WORD index;
WORD id;
int value;
};
struct Stats //sizeof(Stats)=0x64
{
DWORD nUnitId; //+00
Unit* ptUnit; //+04
DWORD nUnitType; //+08
DWORD nItemNum; //+0C
union
{
DWORD flags; //+10
struct
{
DWORD fuk1:13; //0x00001FFF
DWORD isDisabled:1; //0x00002000
DWORD fuk2:17; //0x7FFFC000
DWORD dontUseBaseValue:1;//0x80000000
};
};
DWORD id; //+14
DWORD uk18; //+18
BYTE uk2[0x08]; //+1C
D2Stat* ptBaseStatsTable; //+24
WORD nbBaseStats; //+28
WORD sizeOfBaseStatsTable; //+2A ??
Stats* ptStats; //+2C
BYTE uk3[0x04]; //+30
Stats* ptItemStats; //+34
BYTE uk4[0x04]; //+38
Stats* ptAffixStats; //+3C
Stats* ptNextStats2; //+40
union
{
Unit* ptChar; //+44
Unit* ptItem;
};
D2Stat* ptStatsTable; //+48
WORD nbStats; //+4C
WORD sizeOfStatsTable; //+4E ??
BYTE uk5[0x8]; //+50
BYTE* unknow0; //+58 (sizeof(*unknow0)=0x30 (calculated)
DWORD unknow1; //+5C (=0)
DWORD unknow2; //+60 (=0)
};
struct MonsterData // sizeof(MonsterData)=0x60
{ //Offset from Code.
BYTE uk[0x16]; //+00
union {
WORD flags; //+16
struct {
WORD fuk1:1;
WORD isSuperUnique:1;
WORD isChampion:1;
WORD isUnique:1;
WORD fuk2:13;
};
};
BYTE uk1[0x0E]; //+18
WORD superUniqueID; //+26
void* unknow1; //+28
BYTE uk2[0x38]; //+28
};
struct ObjectData
{
ObjectsBIN* ptObjectsBIN;
BYTE levelID;
};
/*
Kingpin: struct MonsterData
{
BYTE uk1[0x13]; // +00
DWORD Flags; // +14
DWORD uk2; // +18
DWORD MinionOwnerID; // +1C
BYTE uk3[0x5]; // +20
WORD SuperUniqueID; // +26 Superunique ID of monster
D2Game* ptGame; // +28 ptGame
};
*/
#define F2_ITEM_IS_IDENTIFIED 0x10 //or F_IS_IDENTIFIED ?
struct ItemData//size=0x74
{ //Offset from Code.
DWORD quality; //+00
DWORD seedLow; //+04
DWORD seedHi; //+08
DWORD playerID; //+0C #10734 / #10735 (PCInventory->ptPlayer->0C)
DWORD seedStarting; //+10
DWORD flags1; //+14
union {
DWORD flags2; //+18
struct {
DWORD fuk1:1; //0x00000001
DWORD isIndentified:1; //0x00000002
DWORD fuk2:2; //0x0000000C
DWORD isUnindentified:1; //0x00000010
DWORD fuk3:3; //0x000000E0
DWORD isBroken:1; //0x00000100
DWORD fuk4:2; //0x00000600
DWORD isSocketed:1; //0x00000800
DWORD fuk5:10; //0x003FF000
DWORD isEtheral:1; //0x00400000
DWORD fuk6:3; //0x03800000
DWORD isRuneword:1; //0x04000000
DWORD fuk7:1; //0x08000000
DWORD isPersonalized:1; //0x10000000
DWORD fuk8:3; //0xE0000000
};
};
/*
ITEMFLAG_NEWITEM = 0x00000001,
ITEMFLAG_TAGETING = 0x00000004,
ITEMFLAG_UNIDENTIFIED = 0x00000010,
ITEMFLAG_QUANTITY = 0x00000020,
ITEMFLAG_Durability = 0x00000100,
ITEMFLAG_UNKNOWN2 = 0x00000400,
ITEMFLAG_SOCKETED = 0x00000800,
ITEMFLAG_NON_SELLABLE = 0x00001000,
ITEMFLAG_NEWITEM2 = 0x00002000,
ITEMFLAG_UNKNOWN3 = 0x00004000,
ITEMFLAG_CHECKSECPRICE = 0x00010000,
ITEMFLAG_CHECKGAMBLEPRICE = 0x00020000,
ITEMFLAG_UNKNOWN4 = 0x00080000,
ITEMFLAG_INDESTRUCTIBLE(ETHERAL) = 0x00400000,
ITEMFLAG_UNKNOWN5 = 0x00800000,
ITEMFLAG_FROMPLAYER = 0x01000000,
ITEMFLAG_RUNEWORD = 0x04000000
*/
DWORD guid1; //+1C Global Unique ID 1
DWORD guid2; //+20 Global Unique ID 2
DWORD guid3; //+24 Global Unique ID 3
DWORD uniqueID; //+28
BYTE ilvl; //+2C
BYTE uk1[0x03]; //+2D
WORD version; //+30
WORD rarePrefix; //+32
WORD rareSuffix; //+34
WORD autoPref; //+36
WORD prefix[3]; //+38
WORD suffix[3]; //+3E
BYTE equipLoc; //+44
/* emplacement si équipé
* 00 = noequip/inBelt
* 01 = head
* 02 = neck
* 03 = tors
* 04 = rarm
* 05 = larm
* 06 = lrin
* 07 = rrin
* 08 = belt
* 09 = feet
* 0A = glov
* 0B = ralt
* 0C = lalt
*/
BYTE page; //+45
/* page dans laquel se trouve l'item
* FF = mouse/equip/onEarth
* 00 = inventory
* 01 = cube
* 04 = stash
*/
BYTE uk4[0x01]; //+46
BYTE ItemData3; //+47 //D2Common10854 D2Common10853
BYTE pEarLevel; //+48
BYTE varGfx; //+49
char IName[0x12]; //+4A //inscribed/ear name
Inventory* ptInventory; //+5C
Unit* ptPrevItem; //+60
Unit* ptNextItem; //+64
BYTE uk8[0x01]; //+68
BYTE ItemData2; //+69
BYTE uk9[0x0A]; //+6A
};
struct NetClient
{
DWORD clientID; //+00
BYTE uk1[0x06]; //+04
union { //+0A
WORD flag;
struct {
WORD f1:1;
WORD f2:1;
WORD isHardCoreGame:1;
};
};
BYTE uk2[0x170]; //+0C
BYTE* savefile; //+17C
DWORD finalSize; //+180
DWORD counter; //+184
DWORD currentSize; //+188
BYTE uk3[0x1C]; //+18C
Game* ptGame; //+1A8
//+1A8 is ptGame
//+4A8 ptNextClient
/*
Kingpin: ptPclient
+16C is either act or unit type
+170 Active UniqueID for player
+174 Active ptPlayer on Client
+1a8 ptGame
+1b4 Current or next ptRoom
*/
};
/*
struct PlayerData
{
char name[0x10]; //+00 (size min 0x08 max 0x11)
BYTE uk1[0x8C]; //+10
NetClient* ptNetClient; //+9C
};
*/
struct PlayerData
{
char name[0x10]; //+00 Player Name
void* ptQuest[3]; //+10 Quest Pointers for each difficulty
BYTE uk1[0x18]; //+1C //before : 0x14
void* ptArenaUnit; //+34 ptArena for the Unit
BYTE uk2[0x4]; //+38 //before : 0x7
WORD MPSourcePortalUniqueID; //+3C Source Portal Unique_ID
BYTE uk3[0x2]; //+3E
WORD MPDestPortalUniqueID; //+40 Destination Portal Unique_ID
BYTE uk4[0x06]; //+42
BYTE ptObjectUnID; //+48 Object UniqueID for TownPortals
BYTE uk5[0x53]; //+49
NetClient* ptNetClient; //+9C ptClient
};
#define F1_IS_SPAWNED 0x10 //or F_IS_IDENTIFIED ?
#define F2_IS_LOD 0x2000000
struct Unit
{ //Offset from Code. Size: 0xF4+4
DWORD nUnitType; //+00
union{
DWORD nPlayerClass;
DWORD nTxtFileNo;
}; //+04
DWORD nUnitId; //+08
DWORD nItemNum; //+0C
DWORD CurrentAnim; //+10
union{
MonsterData* ptMonsterData;
ObjectData* ptObjectData;
ItemData* ptItemData;
PlayerData* ptPlayerData;
}; //+14
BYTE act; //+18
BYTE uk12[3]; //+19
void* ptAct; //+1C
DWORD SeedLow; //+20
DWORD SeedHi; //+24
DWORD SeedStarting; //+28
Path* path; //+2C
BYTE uk1[0x08]; //+30
Path* ptPos; //+38
DWORD animSpeed; //+3C
BYTE uk2[0x04]; //+40
DWORD curFrame; //+44
DWORD remainingFrame; //+48
WORD animSpeedW; //+4C
BYTE actionFlag; //+4E
BYTE uk3[0x1]; //+4F
void* ptAnimData; //+50
BYTE uk4[0x08]; //+54
Stats* ptStats; //+5C
Inventory* ptInventory; //+60
BYTE uk5[0x1C]; //+64
Game* ptGame; //+80
BYTE uk6[0x24]; //+84
Skills* ptSkills; //+A8
void* ptCombatData; //+AC
BYTE uk7[0x08]; //+B0
DWORD itemCode; //+B8 for an item being dropped by this unit
BYTE uk8[0x08]; //+BC
DWORD flags1; //+C4
union{
DWORD flags2; //+C8 //flags
struct{
DWORD ukf1:25;
DWORD isLod:1;
};
};
BYTE uk9[0x04]; //+CC
DWORD clientId; //+D0
BYTE uk10[0x0C]; //+D4
Unit* ptFirstMonster; //+E0
Unit* Unit1; //+E4
Unit* Unit2; //+E8
BYTE uk11[0x08]; //+EC
union{
CBPlayerData* ptCBPlayerData;
CBItemData* ptCBItemData;
void* ptCBData;
}; //+F4
};
/*
struct D2Game
{
DWORD unknown[19];
WORD difficulty;
};
struct ItemMod
{
DWORD mID; // +00 Mod ID, get it from properties.txt
DWORD mParam; // +04 First Property
DWORD mMinimum; // +04 Second Property, Min Value
DWORD mMaximum; // +04 Third Property, Max Value
};
struct AIStruct
{
DWORD mSpawn; // +00
void* mAIFunc; // +04
DWORD mUnknown1[8]; // +08
D2Game* mGame; // +28
DWORD mMinionOwner; // +2C
DWORD mOwnerType; // +30
};
struct LocInfo
{ //Offset from Code
Unit* noneLoc; //+00
Unit* headLoc; //+04
Unit* neckLoc; //+08
Unit* torsoLoc; //+0c
Unit* rightArmLoc; //+10
Unit* leftArmLoc; //+14
Unit* rightRingLoc; //+18
Unit* leftRingLoc; //+1c
Unit* beltLoc; //+20
Unit* feetLoc; //+24
Unit* glovesLoc; //+28
};
struct ItemData
{ // Offset from Code
DWORD quality; // +00.
DWORD lowSeed; // +04.
DWORD highSeed; // +08.
DWORD unknown1; // +0c.
DWORD startLowSeed; // +10.
DWORD cmdFlags; // +14.
DWORD flags; // +18.
DWORD unknown2[2]; // +1C
DWORD originID; // +24.
DWORD iLvl; // +28.
WORD version; // +2C.
WORD prefix; // +2E.
WORD suffix; // +30.
WORD autoPrefix; // +32.
WORD prefix1; // +34.
WORD prefix2; // +36.
WORD prefix3; // +38.
WORD suffix1; // +3A.
WORD suffix2; // +3C.
WORD suffix3; // +3E.
BYTE bodyLoc; // +40. // 0=inv/stash 4=gaucheS 5=droiteS
BYTE inPage; // +41. // FF=equip 00=inv 04=stash
BYTE unknown3[3]; // +42
BYTE picture[8]; // +45
DWORD ilvl; // +4C
};
struct PresetUnit
{ //Offset from Code
DWORD unitType; //+00
DWORD txtFileNo; //+04
DWORD unknown1[1]; //Unkonwn Data at +08
DWORD xPos; //+0c
DWORD yPos; //+10
DWORD unknown2[2]; //Unknown data at +14
PresetUnit* pNext; //+1c
};
struct MissileData
{
+04 flags
+08 0 on start
+0c -1 on start
+20 nDirection
+28 range?
+2c range?
+30 level
+34 number of pierces (byte)
+35 (byte)
+36 (byte)
+37 (byte)
+38 range-activate
};
struct Combat
{
DWORD mHeader; // +00 : Always 0x32
DWORD mDisplayFlag; // +04 : Affect critical hit etc ...
DWORD mPhysicalDmg; // +08 : Values are << 8
DWORD mUnknown1; // +0C
DWORD mFireDmg; // +10 : Values are << 8
DWORD mUnknown2; // +14
DWORD mBurnLeng; // +18
DWORD mLtngDmg; // +1C : values are << 8
DWORD mMagDmg; // +20 : values are << 8
DWORD mColdDmg; // +24 : values are << 8
DWORD mPoisDmg; // +28 : ??
DWORD mPoisLeng; // +2C
DWORD mColdLeng; // +30
DWORD mFreezeLeng; // +34
DWORD mLifeSteal; // +38
DWORD mManaSteal; // +3C
DWORD mUnknwon3; // +40
DWORD mStunLeng; // +44
DWORD mUnknown4; // +48
DWORD mTotalDamage; // +4C
DWORD mUnknown5[6]; // +50
DWORD mOverlay; // +68
DWORD mUnknwon6; // +6C
};
struct Node
{ //Offset from Code.
DWORD flag; //+00 //Yoh : null->flag
Unit* ptItem; //+04 //Yoh : ItemData=>Unit
DWORD unID; //+08
DWORD page; //+0c //Yoh plutot etat : inventory/stash=1; inv-belt=2; equip=3
Node* nextNode; //+10
};
struct MonsterData // size110 : 60
{
AIStruct* AIPtr;
void* unkonwPtr1;
void* uniqueInfo;
void* spawnInfo;
void* unknownPtr2;
DWORD unkown[8];
void* lvlPtr;
MonStatTxt* monstatPtr;
};
struct Unit
{ //Offset from Code.
DWORD nUnitType; //+00
union
{
DWORD nTxtFileNo;
DWORD nPlayerClass;
}; //+04
DWORD nUnitId; //+08
DWORD eMode; //+0c
DWORD* unknow1; //+10
DWORD nAct; //+14
DWORD pActRelated; //+18
DWORD unknown2[4]; //Unknown Data at +1C
D2Seed nSeed; //+2C
DWORD startSeed; //+34
Path* pPos; //+38
DWORD unknown3[6]; //Unknown Data at +3C
DWORD animSpeed; //+54
DWORD unknown32[2]; //+58
BYTE COFString[12]; //+60
Stats* ptStats; //+6C
union
{
PlayerData* pPlayerData;
MonsterData* pMonsterData;
ItemData* pItemData;
MissileData* pMissile;
ObjectData* pObjectData;
}; //+70
DWORD unknown5[2]; //+74
BYTE unknown6[2]; //+7C
BYTE rndDmg[2]; //+7e
DWORD unknown7; //+80
Inventory* ptInventory; //+84
DWORD unknown8[4]; //+88
DWORD startNull; //+98
DWORD unknown9[2]; //+9c
D2Game* ptGame; //+a4
DWORD unknown10[4]; //+a8
DWORD nOwnerType; //+b8
DWORD nOwnerId; //+bc
DWORD unknown11[3]; //+c0
D2Info* ptInfo; //+cc
Combat* ptCombat; //+d0
DWORD unknown12[5]; //+d4
DWORD flags; //+e8
DWORD LODflag; //+ec
DWORD unknown13[7]; //+f0
Unit* pNext; //+10c
DWORD unknown14[2]; //+110 //YOH
union
{
ItemData* ptItemData;
void* ptData;
}; //+118 //YOH
};
*/
/*================================= END OF FILE =================================*/

1263
Commons/d2BinFile.h Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,43 @@
/*=================================================================
File created by Yohann NICOLAS.
@brief Diablo II Tbl Structures definitions.
=================================================================*/
#pragma once
#include <windows.h>
#pragma pack(1)
struct TblHeader
{
WORD usCRC; // +00
WORD NumElementsOffset; // +02
DWORD HashTableSizeOffset; // +04
BYTE VersionOffset; // +08
DWORD IndexStart; // +09
DWORD NumLoopsOffset; // +0D
DWORD IndexEnd; // +11 (FileLen)
};
struct TblNode
{
BYTE ActiveOffset; // +00
WORD KeyIndex; // +01
DWORD HashValueOffset; // +03
DWORD KeyOffset; // +07
DWORD StringOffset; // +0B
WORD StringLength; // +0F
};
#pragma pack()
//#define TBLHEADERSIZE 0x15
//#define TBLNODESIZE 0x11
/*================================= END OF FILE =================================*/

118
Commons/d2Struct.h Normal file
View File

@ -0,0 +1,118 @@
/*=================================================================
File created by Yohann NICOLAS.
NOT TESTED IN 1.10 (1.09b)
=================================================================*/
#pragma once
#include <windows.h>
struct Unit;
struct Game;
struct Room;
#pragma pack(1)
struct sWinMessage
{
void* msg;
DWORD type;
DWORD uk1;
WORD x;
WORD y;
DWORD uk3;
DWORD uk4;
DWORD managed;
DWORD unmanaged;
};
#pragma pack()
/*
struct sDrawImageInfo//size = 0x48 (until 1.10)
{
void* reserved;
void* image;
DWORD frame;
DWORD zero[0xF];
};*/
struct sDrawImageInfo//size = 0x48
{
DWORD uk1;
DWORD uk2;
void* image;
DWORD uk3;
DWORD uk4;
void* reserved;
DWORD uk5[0xB];
DWORD frame;
};
struct saveBitField
{
BYTE* data;
DWORD maxBits;
DWORD currentByte;
DWORD currentBit;
DWORD overflaw;
};
struct BINField
{
char* fieldName;
int type;
DWORD strLength;
DWORD offset;
void* lookup;
};
struct ItemGenerationData //size=0x84
{
Unit* ptMonster; //+00
BYTE uk1[0x04]; //+04
Game* ptGame; //+08
DWORD ilvl; //+0C
BYTE uk2[0x04]; //+10
DWORD nTxtFileNo; //+14
DWORD unknow1; //+18
DWORD x; //+1C
DWORD y; //+20
Room* ptRoom; //+24
WORD unknow2; //+28
WORD gameUnknown2; //+2A
BYTE uk3[0x04]; //+2C
DWORD quality; //+30
BYTE uk4[0x34]; //+34
int prefixID[3]; //+68 (-1: no prefix; 0:random prefix)
int suffixID[3]; //+74 (-1: no suffix; 0:random suffix)
union { //+80
DWORD flags;
struct {
DWORD fuk1:5; //0x0000001F
DWORD unknow3:1; //0x00000020
};
};
};
/*=================================================================*/
/* Data Structure to Update Client */
/*=================================================================*/
struct DataPacket
{
BYTE mType; // +00 Packet Type
BYTE mFunc; // +02 Function to Call
BYTE mSize; // +04 Size of the Packet
DWORD mReserved; // +06 Used with items
BYTE mUnitType; // +0A Always '0'
DWORD mPlayerID; // +0C The Player ID (ptUnit + 08h)
DWORD mItemID; // +10 The Item ID
DWORD mMod1_ID; // +14 The Stat/Mod ID
DWORD mParam1; // +18 3 Paramters
DWORD mParam2; // +1C
DWORD mParam3; // +20
};
/*================================= END OF FILE =================================*/

843
Commons/d2constants.h Normal file
View File

@ -0,0 +1,843 @@
/*=================================================================
File created by Yohann NICOLAS.
Constants of D2
NOT TESTED IN 1.10 (from 1.09b)
=================================================================*/
#pragma once
/*==================================================================================*/
/*
* Constants & Enumerations.
*/
/*==================================================================================*/
enum D2TypeSize { D2TS_UNITSIZE = 0x011C };
enum D2DifficultyModes { D2DM_NORMAL, D2DM_NIGHTMARE, D2DM_HELL };
enum D2PlayerClass { D2PC_AMAZON, D2PC_SORCERESS, D2PC_NECROMANCER, D2PC_PALADIN, D2PC_BARBARIAN, D2PC_DRUID, D2PC_ASSASSIN };
enum D2Color
{
WHITE=0,
RED=1,
GREEN=2,
BLUE=3,
GOLD=4,
DARK_GRAY=5,
// INVISIBLE=6,
DARK_YELLOW=7,
ORANGE=8,
YELLOW=9,
DARKEST_GREEN=0xA,
PURPLE=0xB,
DARK_GREEN=0xC,
// WHITE_BIS=0xD,
// INVISIBLE2=0xE,
LIGHT_GRAY=0xF,
GRAY=0x10,
// VERY_WIERD=0x11,
BRIGHT_WHITE=0x12,
CRYSTAL_RED=0x13,
// WIERD_YELLOW=0x14
};
enum D2Lang
{
LNG_ENG=0,// English
LNG_ESP,// Spanish
LNG_DEU,// German
LNG_FRA,// French
LNG_POR,// Portuguese
LNG_ITA,// Italian
LNG_JPN,// Japanese
LNG_KOR,// Korean
LNG_SIN,//
LNG_CHI,// Chinese
LNG_POL,// Polish
LNG_RUS,// Russian
LNG_DEF,// Default : English
};
enum D2GameTypeMode
{
// MODE_SINGLE = 0,
MODE_CLOSED = 1,
MODE_TCP,
MODE_OPEN,
};
enum D2CStat
{
STATS_STRENGTH = 0,
STATS_ENERGY,
STATS_DEXTERITY,
STATS_VITALITY,
STATS_STATPTS,
STATS_NEWSKILLS,
STATS_HP,
STATS_MAXHP,
STATS_MANA,
STATS_MAXMANA,
STATS_STAMINA,
STATS_MAXSTAMINA,
STATS_LEVEL,
STATS_EXPERIENCE,
STATS_GOLD,
STATS_GOLDBANK,
STATS_ITEM_ARMOR_PERCENT,//0x10
STATS_ITEM_MAXDAMAGE_PERCENT,
STATS_ITEM_MINDAMAGE_PERCENT,
STATS_TOHIT,
STATS_TOBLOCK,
STATS_MINDAMAGE,
STATS_MAXDAMAGE,
STATS_SECONDARY_MINDAMAGE,
STATS_SECONDARY_MAXDAMAGE,
STATS_DAMAGEPERCENT,
STATS_MANARECOVERY,
STATS_MANARECOVERYBONUS,
STATS_STAMINARECOVERYBONUS,
STATS_LASTEXP,
STATS_NEXTEXP,
STATS_ARMORCLASS,
STATS_ARMORCLASS_VS_MISSILE,//0x20
STATS_ARMORCLASS_VS_HTH,//0x21
STATS_NORMAL_DAMAGE_REDUCTION,
STATS_MAGIC_DAMAGE_REDUCTION,
STATS_DAMAGERESIST,
STATS_MAGICRESIST,
STATS_MAXMAGICRESIST,
STATS_FIRERESIST,//0x27
STATS_MAXFIRERESIST,
STATS_LIGHTRESIST,//0x29
STATS_MAXLIGHTRESIST,
STATS_COLDRESIST,//0x2B
STATS_MAXCOLDRESIST,
STATS_POISONRESIST,
STATS_MAXPOISONRESIST,
STATS_DAMAGEAURA,
STATS_FIREMINDAM,//0x30
STATS_FIREMAXDAM,
STATS_LIGHTMINDAM,
STATS_LIGHTMAXDAM,
STATS_MAGICMINDAM,
STATS_MAGICMAXDAM,
STATS_COLDMINDAM,
STATS_COLDMAXDAM,
STATS_COLDLENGTH,
STATS_POISONMINDAM,
STATS_POISONMAXDAM,
STATS_POISONLENGTH,
STATS_LIFEDRAINMINDAM,
STATS_LIFEDRAINMAXDAM,
STATS_MANADRAINMINDAM,
STATS_MANADRAINMAXDAM,
STATS_STAMDRAINMINDAM,//0x40
STATS_STAMDRAINMAXDAM,
STATS_STUNLENGTH,
STATS_VELOCITYPERCENT,
STATS_ATTACKRATE,
STATS_OTHER_ANIMRATE,
STATS_QUANTITY,
STATS_VALUE,
STATS_DURABILITY,
STATS_MAXDURABILITY,
STATS_HPREGEN,
STATS_ITEM_MAXDURABILITY_PERCENT,
STATS_ITEM_MAXHP_PERCENT,
STATS_ITEM_MAXMANA_PERCENT,
STATS_ITEM_ATTACKERTAKESDAMAGE,
STATS_ITEM_GOLDBONUS,
STATS_ITEM_MAGICBONUS,//0x50
STATS_ITEM_KNOCKBACK,
STATS_ITEM_TIMEDURATION,
STATS_ITEM_ADDCLASSSKILLS, //STATS_ITEM_ADDAMASKILLPOINTS
STATS_UNSENTPARAM1, //STATS_ITEM_ADDPALSKILLPOINTS
STATS_ADDEXPERIENCE, //STATS_ITEM_ADDNECSKILLPOINTS
STATS_HEALAFTERKILL, //STATS_ITEM_ADDSORSKILLPOINTS
STATS_REDUCESPRICES, //STATS_ITEM_ADDBARSKILLPOINTS
STATS_ITEM_DOUBLEHERBDURATION,
STATS_ITEM_LIGHTRADIUS,
STATS_ITEM_LIGHTCOLOR,
STATS_ITEM_REQ_PERCENT,
STATS_LEVELREQ, //STATS_ITEM_FASTATTACKRATE
STATS_ITEM_FASTERATTACKRATE,
STATS_ITEM_LEVELREQPCT, //STATS_ITEM_FASTESTATTACKRATE,
STATS_LASTBLOCKFRAME, //STATS_ITEM_FASTMOVEVELOCITY,
STATS_ITEM_FASTERMOVEVELOCITY,//0x60
STATS_NONCLASSKILL, //STATS_ITEM_FASTESTMOVEVELOCITY,
STATS_STATE, //STATS_ITEM_FASTGETHITRATE,
STATS_ITEM_FASTERGETHITRATE,
STATS_MONSTER_PLAYERCOUNT, //STATS_ITEM_FASTESTGETHITRATE,
STATS_SKILL_POISON_OVERRIDE_LENGTH, //STATS_ITEM_FASTBLOCKRATE,
STATS_ITEM_FASTERBLOCKRATE,
STATS_SKILL_BYPASS_UNDEAD, //STATS_ITEM_FASTESTBLOCKRATE,
STATS_SKILL_BYPASS_DEMONS, //STATS_ITEM_FASTCASTRATE,
STATS_ITEM_FASTERCASTRATE,
STATS_SKILL_BYPASS_BEASTS, //STATS_ITEM_FASTESTCASTRATE,
STATS_ITEM_SINGLESKILL, //STATS_ITEM_SINGLESKILL1,
STATS_ITEM_RESTINPEACE, //STATS_ITEM_SINGLESKILL2,
STATS_CURSE_RESISTANCE, //STATS_ITEM_SINGLESKILL3,
STATS_ITEM_POISONLENGTHRESIST,
STATS_ITEM_NORMALDAMAGE,
STATS_ITEM_HOWL,//0x70
STATS_ITEM_STUPIDITY,
STATS_ITEM_DAMAGETOMANA,
STATS_ITEM_IGNORETARGETAC,
STATS_ITEM_FRACTIONALTARGETAC,
STATS_ITEM_PREVENTHEAL,
STATS_ITEM_HALFFREEZEDURATION,
STATS_ITEM_TOHIT_PERCENT,
STATS_ITEM_DAMAGETARGETAC,
STATS_ITEM_DEMONDAMAGE_PERCENT,
STATS_ITEM_UNDEADDAMAGE_PERCENT,
STATS_ITEM_DEMON_TOHIT,
STATS_ITEM_UNDEAD_TOHIT,
STATS_ITEM_THROWABLE,
STATS_ITEM_ELEMSKILL, //STATS_ITEM_FIRESKILL,
STATS_ITEM_ALLSKILLS,
STATS_ITEM_ATTACKERTAKESLIGHTDAMAGE,//0x80
STATS_IRONMAIDEN_LEVEL,
STATS_LIFETAP_LEVEL,
STATS_THORNS_LEVEL,
STATS_BONEARMOR,
STATS_BONEARMORMAX,
STATS_ITEM_FREEZE,
STATS_ITEM_OPENWOUNDS,
STATS_ITEM_CRUSHINGBLOW,
STATS_ITEM_KICKDAMAGE,
STATS_ITEM_MANAAFTERKILL,
STATS_ITEM_HEALAFTERDEMONKILL,
STATS_ITEM_EXTRABLOOD,
STATS_ITEM_DEADLYSTRIKE,
STATS_ITEM_ABSORBFIRE_PERCENT,
STATS_ITEM_ABSORBFIRE,
STATS_ITEM_ABSORBLIGHT_PERCENT,
STATS_ITEM_ABSORBLIGHT,
STATS_ITEM_ABSORBMAGIC_PERCENT,
STATS_ITEM_ABSORBMAGIC,
STATS_ITEM_ABSORBCOLD_PERCENT,
STATS_ITEM_ABSORBCOLD,
STATS_ITEM_SLOW,
STATS_ITEM_AURA, //STATS_ITEM_BLESSEDAIM,
STATS_ITEM_INDESTRUCTIBLE, //STATS_ITEM_DEFIANCE,
STATS_ITEM_CANNOTBEFROZEN,
STATS_ITEM_STAMINADRAINPCT,
STATS_ITEM_REANIMATE,
STATS_ITEM_PIERCE,
STATS_ITEM_MAGICARROW,
STATS_ITEM_EXPLOSIVEARROW,
STATS_ITEM_THROW_MINDAMAGE,
STATS_ITEM_THROW_MAXDAMAGE,
STATS_SKILL_HANDOFATHENA,
STATS_SKILL_STAMINAPERCENT,
STATS_SKILL_PASSIVE_STAMINAPERCENT,
STATS_SKILL_CONCENTRATION,
STATS_SKILL_ENCHANT,
STATS_SKILL_PIERCE,
STATS_SKILL_CONVICTION,
STATS_SKILL_CHILLINGARMOR,
STATS_SKILL_FRENZY,
STATS_SKILL_DECREPIFY,
STATS_SKILL_ARMOR_PERCENT,
STATS_ALIGNMENT,
STATS_TARGET0,
STATS_TARGET1,
STATS_GOLDLOST,
STATS_CONVERSION_LEVEL,
STATS_CONVERSION_MAXHP,
STATS_UNIT_DOOVERLAY,
STATS_ATTACK_VS_MONTYPE, //STATS_ITEM_ADDDRUSKILLPOINTS,
STATS_DAMAGE_VS_MONTYPE, //STATS_ITEM_ADDASSSKILLPOINTS,
STATS_FADE, //STATS_ITEM_ADDSKILL_SINGLE4,
STATS_ARMOR_OVERRIDE_PERCENT, //STATS_ITEM_ADDSKILL_SINGLE5,
STATS_UNUSED183, //STATS_ITEM_ADDSKILL_SINGLE6,
STATS_UNUSED184, //STATS_ITEM_ADDSKILL_SINGLE7,
STATS_UNUSED185, //STATS_ITEM_ADDSKILL_SINGLE8,
STATS_UNUSED186, //STATS_ITEM_ADDSKILL_SINGLE9,
STATS_UNUSED187, //STATS_ITEM_ADDSKILL_SINGLE10,
STATS_ADDSKILL_TAB, //STATS_ITEM_ADDSKILL_TAB1,
STATS_UNUSED189, //STATS_ITEM_ADDSKILL_TAB2,
STATS_UNUSED190, //STATS_ITEM_ADDSKILL_TAB3,
STATS_UNUSED191, //STATS_ITEM_ADDSKILL_TAB4,
STATS_UNUSED192, //STATS_ITEM_ADDSKILL_TAB5,
STATS_UNUSED193, //STATS_ITEM_ADDSKILL_TAB6,
STATS_ITEM_NUMSOCKETS,
STATS_ITEM_SKILLONATTACK, //STATS_ITEM_SKILLONATTACK1,
STATS_ITEM_SKILLONKILL, //STATS_ITEM_SKILLONATTACK2,
STATS_ITEM_SKILLONDEATH, //STATS_ITEM_SKILLONATTACK3,
STATS_ITEM_SKILLONHIT, //STATS_ITEM_SKILLONHIT1,
STATS_ITEM_SKILLONLEVELUP, //STATS_ITEM_SKILLONHIT2,
STATS_UNUSED200, //STATS_ITEM_SKILLONHIT3,
STATS_ITEM_SKILLONGETHIT, //STATS_ITEM_SKILLONGETHIT1,
STATS_UNUSED202, //STATS_ITEM_SKILLONGETHIT2,
STATS_UNUSED203, //STATS_ITEM_SKILLONGETHIT3,
STATS_ITEM_CHARGED_SKILL, //STATS_ITEM_CHARGED_SKILL0,
STATS_UNUSED205, //STATS_ITEM_CHARGED_SKILL1,
STATS_UNUSED206, //STATS_ITEM_CHARGED_SKILL2,
STATS_UNUSED207, //STATS_ITEM_CHARGED_SKILL3,
STATS_UNUSED208, //STATS_ITEM_CHARGED_SKILL4,
STATS_UNUSED209, //STATS_ITEM_CHARGED_SKILL5,
STATS_UNUSED210, //STATS_ITEM_CHARGED_SKILL6,
STATS_UNUSED211, //STATS_ITEM_CHARGED_SKILL7,
STATS_UNUSED212, //STATS_ITEM_CHARGED_SKILL8,
STATS_UNUSED213, //STATS_ITEM_CHARGED_SKILL9,
STATS_ITEM_ARMOR_PERLEVEL,
STATS_ITEM_ARMORPERCENT_PERLEVEL,
STATS_ITEM_HP_PERLEVEL,
STATS_ITEM_MANA_PERLEVEL,
STATS_ITEM_MAXDAMAGE_PERLEVEL,
STATS_ITEM_MAXDAMAGE_PERCENT_PERLEVEL,
STATS_ITEM_STRENGTH_PERLEVEL,
STATS_ITEM_DEXTERITY_PERLEVEL,
STATS_ITEM_ENERGY_PERLEVEL,
STATS_ITEM_VITALITY_PERLEVEL,
STATS_ITEM_TOHIT_PERLEVEL,
STATS_ITEM_TOHITPERCENT_PERLEVEL,
STATS_ITEM_COLD_DAMAGEMAX_PERLEVEL,
STATS_ITEM_FIRE_DAMAGEMAX_PERLEVEL,
STATS_ITEM_LTNG_DAMAGEMAX_PERLEVEL,
STATS_ITEM_POIS_DAMAGEMAX_PERLEVEL,
STATS_ITEM_RESIST_COLD_PERLEVEL,
STATS_ITEM_RESIST_FIRE_PERLEVEL,
STATS_ITEM_RESIST_LTNG_PERLEVEL,
STATS_ITEM_RESIST_POIS_PERLEVEL,
STATS_ITEM_ABSORB_COLD_PERLEVEL,
STATS_ITEM_ABSORB_FIRE_PERLEVEL,
STATS_ITEM_ABSORB_LTNG_PERLEVEL,
STATS_ITEM_ABSORB_POIS_PERLEVEL,
STATS_ITEM_THORNS_PERLEVEL,
STATS_ITEM_FIND_GOLD_PERLEVEL,
STATS_ITEM_FIND_MAGIC_PERLEVEL,
STATS_ITEM_REGENSTAMINA_PERLEVEL,
STATS_ITEM_STAMINA_PERLEVEL,
STATS_ITEM_DAMAGE_DEMON_PERLEVEL,
STATS_ITEM_DAMAGE_UNDEAD_PERLEVEL,
STATS_ITEM_TOHIT_DEMON_PERLEVEL,
STATS_ITEM_TOHIT_UNDEAD_PERLEVEL,
STATS_ITEM_CRUSHINGBLOW_PERLEVEL,
STATS_ITEM_OPENWOUNDS_PERLEVEL,
STATS_ITEM_KICK_DAMAGE_PERLEVEL,
STATS_ITEM_DEADLYSTRIKE_PERLEVEL,
STATS_ITEM_FIND_GEMS_PERLEVEL,
STATS_ITEM_REPLENISH_DURABILITY,
STATS_ITEM_REPLENISH_QUANTITY,
STATS_ITEM_EXTRA_STACK,
STATS_ITEM_FIND_ITEM,
STATS_ITEM_SLASH_DAMAGE,
STATS_ITEM_SLASH_DAMAGE_PERCENT,
STATS_ITEM_CRUSH_DAMAGE,
STATS_ITEM_CRUSH_DAMAGE_PERCENT,
STATS_ITEM_THRUST_DAMAGE,
STATS_ITEM_THRUST_DAMAGE_PERCENT,
STATS_ITEM_ABSORB_SLASH,
STATS_ITEM_ABSORB_CRUSH,
STATS_ITEM_ABSORB_THRUST,
STATS_ITEM_ABSORB_SLASH_PERCENT,
STATS_ITEM_ABSORB_CRUSH_PERCENT,
STATS_ITEM_ABSORB_THRUST_PERCENT,
STATS_ITEM_ARMOR_BYTIME,
STATS_ITEM_ARMORPERCENT_BYTIME,
STATS_ITEM_HP_BYTIME,
STATS_ITEM_MANA_BYTIME,
STATS_ITEM_MAXDAMAGE_BYTIME,
STATS_ITEM_MAXDAMAGE_PERCENT_BYTIME,
STATS_ITEM_STRENGTH_BYTIME,
STATS_ITEM_DEXTERITY_BYTIME,
STATS_ITEM_ENERGY_BYTIME,
STATS_ITEM_VITALITY_BYTIME,
STATS_ITEM_TOHIT_BYTIME,
STATS_ITEM_TOHITPERCENT_BYTIME,
STATS_ITEM_COLD_DAMAGEMAX_BYTIME,
STATS_ITEM_FIRE_DAMAGEMAX_BYTIME,
STATS_ITEM_LTNG_DAMAGEMAX_BYTIME,
STATS_ITEM_POIS_DAMAGEMAX_BYTIME,
STATS_ITEM_RESIST_COLD_BYTIME,
STATS_ITEM_RESIST_FIRE_BYTIME,
STATS_ITEM_RESIST_LTNG_BYTIME,
STATS_ITEM_RESIST_POIS_BYTIME,
STATS_ITEM_ABSORB_COLD_BYTIME,
STATS_ITEM_ABSORB_FIRE_BYTIME,
STATS_ITEM_ABSORB_LTNG_BYTIME,
STATS_ITEM_ABSORB_POIS_BYTIME,
STATS_ITEM_FIND_GOLD_BYTIME,
STATS_ITEM_FIND_MAGIC_BYTIME,
STATS_ITEM_REGENSTAMINA_BYTIME,
STATS_ITEM_STAMINA_BYTIME,
STATS_ITEM_DAMAGE_DEMON_BYTIME,
STATS_ITEM_DAMAGE_UNDEAD_BYTIME,
STATS_ITEM_TOHIT_DEMON_BYTIME,
STATS_ITEM_TOHIT_UNDEAD_BYTIME,
STATS_ITEM_CRUSHINGBLOW_BYTIME,
STATS_ITEM_OPENWOUNDS_BYTIME,
STATS_ITEM_KICK_DAMAGE_BYTIME,
STATS_ITEM_DEADLYSTRIKE_BYTIME,
STATS_ITEM_FIND_GEMS_BYTIME,
STATS_ITEM_PIERCE_COLD,
STATS_ITEM_PIERCE_FIRE,
STATS_ITEM_PIERCE_LTNG,
STATS_ITEM_PIERCE_POIS,
STATS_ITEM_DAMAGE_VS_MONSTER,
STATS_ITEM_DAMAGE_PERCENT_VS_MONSTER,
STATS_ITEM_TOHIT_VS_MONSTER,
STATS_ITEM_TOHIT_PERCENT_VS_MONSTER,
STATS_ITEM_AC_VS_MONSTER,
STATS_ITEM_AC_PERCENT_VS_MONSTER,
STATS_FIRELENGTH,
STATS_BURNINGMIN,
STATS_BURNINGMAX,
STATS_PROGRESSIVE_DAMAGE,
STATS_PROGRESSIVE_STEAL,
STATS_PROGRESSIVE_OTHER,
STATS_PROGRESSIVE_FIRE,
STATS_PROGRESSIVE_COLD,
STATS_PROGRESSIVE_LIGHTNING,
STATS_ITEM_EXTRA_CHARGES,
STATS_PROGRESSIVE_TOHIT,
STATS_POISON_COUNT,
STATS_DAMAGE_FRAMERATE,
STATS_PIERCE_IDX,
STATS_PASSIVE_FIRE_MASTERY,///////////////////////// NEW FOR 1.10
STATS_PASSIVE_LTNG_MASTERY,
STATS_PASSIVE_COLD_MASTERY,
STATS_PASSIVE_POUS_MASTERY,
STATS_PASSIVE_FIRE_PIERCE,
STATS_PASSIVE_LTNG_PIERCE,
STATS_PASSIVE_COLD_PIERCE,
STATS_PASSIVE_POIS_PIERCE,
STATS_PASSIVE_CRITICAL_STRIKE,
STATS_PASSIVE_DODGE,
STATS_PASSIVE_AVOID,
STATS_PASSIVE_EVADE,
STATS_PASSIVE_WARMTH,
STATS_PASSIVE_MASTERY_MELEE_TH,
STATS_PASSIVE_MASTERY_MELEE_DMG,
STATS_PASSIVE_MASTERY_MELEE_CRIT,
STATS_PASSIVE_MASTERY_THROW_TH,
STATS_PASSIVE_MASTERY_THROW_DMG,
STATS_PASSIVE_MASTERY_THROW_CRIT,
STATS_PASSIVE_WEAPONBLOCK,
STATS_PASSIVE_SUMMON_RESIST,
STATS_MODIFIERLIST_SKILL,
STATS_MODIFIERLIST_LEVEL,
STATS_LAST_SENT_HP_PCT,
STATS_SOURCE_UNIT_TYPE,
STATS_SOURCE_UNIT_ID,
STATS_SHORTPARAM1,
STATS_QUESTITEMDIFFICULTY,
STATS_PASSIVE_MAG_MASTERY,
STATS_PASSIVE_MAG_PIERCE
};
enum D2Mod
{
ARMORCLASS = 0,
ARMORCLASS_VS_MISSILE,
ARMORCLASS_VS_HTH,
NORMAL_DAMAGE_REDUCTION,
NORMAL_DAMAGE_REDUCTION_PCT,
ARMOR_PERCENT,
MAGIC_DAMAGE_REDUCTION,
STRENGTH,
DEXTERITY,
VITALITY,
ENERGY,
MAXMANA,
MAXMANA_PERCENT,
MAXHP,
MAXHP_PERCENT,
TOHIT,
TOBLOCK,
COLDMINDAM,
COLDMAXDAM,
COLDLENGTH,
FIREMINDAM,
FIREMAXDAM,
LIGHTMINDAM,
LIGHTMAXDAM,
POISONMINDAM,
POISONMAXDAM,
POISONLENGTH,
MINDAMAGE,
MAXDAMAGE,
WEAPONDAMAGE_PERCENT,
DAMAGETOMANA,
FIRERESIST,
MAXFIRERESIST,
LIGHTRESIST,
MAXLIGHTRESIST,
COLDRESIST,
MAXCOLDRESIST,
MAGICRESIST,
MAXMAGICRESIST,
POISONRESIST,
MAXPOISONRESIST,
RESISTALL,
MAXRESISTALL,
ASBORBFIRE_PERCENT,
ASBORBFIRE,
ASBORBLIGHT_PERCENT,
ASBORBLIGHT,
ASBORBMAGIC_PERCENT,
ASBORBMAGIC,
ASBORBCOLD_PERCENT,
ASBORBCOLD,
MAXDURABILITY,
MAXDURABILITY_PERCENT,
HITPOINTS_DELTA,
ATTACKERTAKES_DAMAGE,
FASTATTACKRATE,
FASTERATTACKRATE,
FASTESTATTACKRATE,
GOLDBONUS,
MAGICBONUS,
KNOCKBACK,
REGENSTAMINA_PERCENT,
REGENMANA_PERCENT,
BASESTAMINA,
TIMEDURATION,
MANASTEAL,
LIFESTEAL,
ADDAMASKILLPOINTS,
ADDPALSKILLPOINTS,
ADDNECSKILLPOINTS,
ADDSORSKILLPOINTS,
ADDBARSKILLPOINTS,
DOUBLEHERBDURATION,
LIGHTRADIUS,
LIGHTCOLOR,
REQ_PERCENT,
FASTMOVEVELOCITY,
FASTERMOVEVELOCITY,
FASTESTMOVEVELOCITY,
FASTGETHITRATE,
FASTERGETHITRATE,
FASTESTGETHITRATE,
FASTBLOCKRATE,
FASTERBLOCKRATE,
FASTESTBLOCKRATE,
FASTCASTRATE,
FASTERCASTRATE,
FASTESTCASTRATE,
POISONLENGTHRESIST,
NORMALDAMAGE,
HOWL,
STUPIDITY,
IGNORETARGETAC,
FRACTIONALTARGETAC,
PREVENTHEAL,
HALFFREEZEDURATION,
TOHIT_PERCENT,
DAMAGETARGETAC,
DEMONDAMAGE_PERCENT,
UNDEADDAMAGE_PERCENT,
DEMON_TOHIT,
UNDEAD_TOHIT,
THROWABLE,
FIRESKILL,
ALLSKILLS,
ATTACKERTAKESLIGHT_DAMAGE,
FREEZE,
OPENWOUNDS,
CRUSHINGBLOW,
KICKDAMAGE,
MANAAFTERKILL,
HEALAFTERDEMONKILL,
EXTRABLOOD,
DEADLYSTRIKE,
SLOW,
CANNOTBEFROZEN,
STAMINADRAINPCT,
REANIMATE,
PIERCE,
MAGICARROW,
EXPLOSIVEARROW,
ADDDRUSKILLPOINTS,
ADDASSSKILLPOINTS,
ADDSKILL,
ADDTAB,
ADDSKILL_PASSIVES,
SKILL_ON_ATTACK,
SKILL_ON_HIT,
SKILL_ON_GETHIT,
GEMBONUS,
DURABILITY_OVER_TIME,
FIRE_EFFECTS,
LIGHTNING_EFFECTS,
SOCKETS,
FIRE_DAMAGE_MINMAX,
LIGHT_DAMAGE_MINMAX,
MAGIC_DAMAGE_MINMAX,
COLD_DAMAGE_MINMAXLEN,
POIS_DAMAGE_MINMAXLEN,
THROW_DAMAGE_MINMAX,
DAMAGE_MINMAX,
STATS_ITEM_ARMOR_PERLEVEL_MOD,
STATS_ITEM_ARMORPERCENT_PERLEVEL_MOD,
STATS_ITEM_HP_PERLEVEL_MOD,
STATS_ITEM_MANA_PERLEVEL_MOD,
STATS_ITEM_MAXDAMAGE_PERLEVEL_MOD,
STATS_ITEM_MAXDAMAGE_PERCENT_PERLEVEL_MOD,
STATS_ITEM_STRENGTH_PERLEVEL_MOD,
STATS_ITEM_DEXTERITY_PERLEVEL_MOD,
STATS_ITEM_ENERGY_PERLEVEL_MOD,
STATS_ITEM_VITALITY_PERLEVEL_MOD,
STATS_ITEM_TOHIT_PERLEVEL_MOD,
STATS_ITEM_TOHITPERCENT_PERLEVEL_MOD,
STATS_ITEM_COLD_DAMAGEMAX_PERLEVEL_MOD,
STATS_ITEM_FIRE_DAMAGEMAX_PERLEVEL_MOD,
STATS_ITEM_LTNG_DAMAGEMAX_PERLEVEL_MOD,
STATS_ITEM_POIS_DAMAGEMAX_PERLEVEL_MOD,
STATS_ITEM_RESIST_COLD_PERLEVEL_MOD,
STATS_ITEM_RESIST_FIRE_PERLEVEL_MOD,
STATS_ITEM_RESIST_LTNG_PERLEVEL_MOD,
STATS_ITEM_RESIST_POIS_PERLEVEL_MOD,
STATS_ITEM_ABSORB_COLD_PERLEVEL_MOD,
STATS_ITEM_ABSORB_FIRE_PERLEVEL_MOD,
STATS_ITEM_ABSORB_LTNG_PERLEVEL_MOD,
STATS_ITEM_ABSORB_POIS_PERLEVEL_MOD,
STATS_ITEM_THORNS_PERLEVEL_MOD,
STATS_ITEM_FIND_GOLD_PERLEVEL_MOD,
STATS_ITEM_FIND_MAGIC_PERLEVEL_MOD,
STATS_ITEM_REGENSTAMINA_PERLEVEL_MOD,
STATS_ITEM_STAMINA_PERLEVEL_MOD,
STATS_ITEM_DAMAGE_DEMON_PERLEVEL_MOD,
STATS_ITEM_DAMAGE_UNDEAD_PERLEVEL_MOD,
STATS_ITEM_TOHIT_DEMON_PERLEVEL_MOD,
STATS_ITEM_TOHIT_UNDEAD_PERLEVEL_MOD,
STATS_ITEM_CRUSHINGBLOW_PERLEVEL_MOD,
STATS_ITEM_OPENWOUNDS_PERLEVEL_MOD,
STATS_ITEM_KICK_DAMAGE_PERLEVEL_MOD,
STATS_ITEM_DEADLYSTRIKE_PERLEVEL_MOD,
STATS_ITEM_FIND_GEMS_PERLEVEL_MOD,
STATS_ITEM_REPLENISH_DURABILITY_MOD,
STATS_ITEM_REPLENISH_QUANTITY_MOD,
STATS_ITEM_EXTRA_STACK_MOD,
STATS_ITEM_FIND_ITEM_MOD,
STATS_ITEM_SLASH_DAMAGE_MOD,
STATS_ITEM_SLASH_DAMAGE_PERCENT_MOD,
STATS_ITEM_CRUSH_DAMAGE_MOD,
STATS_ITEM_CRUSH_DAMAGE_PERCENT_MOD,
STATS_ITEM_THRUST_DAMAGE_MOD,
STATS_ITEM_THRUST_DAMAGE_PERCENT_MOD,
STATS_ITEM_ABSORB_SLASH_MOD,
STATS_ITEM_ABSORB_CRUSH_MOD,
STATS_ITEM_ABSORB_THRUST_MOD,
STATS_ITEM_ABSORB_SLASH_PERCENT_MOD,
STATS_ITEM_ABSORB_CRUSH_PERCENT_MOD,
STATS_ITEM_ABSORB_THRUST_PERCENT_MOD,
STATS_ITEM_ARMOR_BYTIME_MOD,
STATS_ITEM_ARMORPERCENT_BYTIME_MOD,
STATS_ITEM_HP_BYTIME_MOD,
STATS_ITEM_MANA_BYTIME_MOD,
STATS_ITEM_MAXDAMAGE_BYTIME_MOD,
STATS_ITEM_MAXDAMAGE_PERCENT_BYTIME_MOD,
STATS_ITEM_STRENGTH_BYTIME_MOD,
STATS_ITEM_DEXTERITY_BYTIME_MOD,
STATS_ITEM_ENERGY_BYTIME_MOD,
STATS_ITEM_VITALITY_BYTIME_MOD,
STATS_ITEM_TOHIT_BYTIME_MOD,
STATS_ITEM_TOHITPERCENT_BYTIME_MOD,
STATS_ITEM_COLD_DAMAGEMAX_BYTIME_MOD,
STATS_ITEM_FIRE_DAMAGEMAX_BYTIME_MOD,
STATS_ITEM_LTNG_DAMAGEMAX_BYTIME_MOD,
STATS_ITEM_POIS_DAMAGEMAX_BYTIME_MOD,
STATS_ITEM_RESIST_COLD_BYTIME_MOD,
STATS_ITEM_RESIST_FIRE_BYTIME_MOD,
STATS_ITEM_RESIST_LTNG_BYTIME_MOD,
STATS_ITEM_RESIST_POIS_BYTIME_MOD,
STATS_ITEM_ABSORB_COLD_BYTIME_MOD,
STATS_ITEM_ABSORB_FIRE_BYTIME_MOD,
STATS_ITEM_ABSORB_LTNG_BYTIME_MOD,
STATS_ITEM_ABSORB_POIS_BYTIME_MOD,
STATS_ITEM_FIND_GOLD_BYTIME_MOD,
STATS_ITEM_FIND_MAGIC_BYTIME_MOD,
STATS_ITEM_REGENSTAMINA_BYTIME_MOD,
STATS_ITEM_STAMINA_BYTIME_MOD,
STATS_ITEM_DAMAGE_DEMON_BYTIME_MOD,
STATS_ITEM_DAMAGE_UNDEAD_BYTIME_MOD,
STATS_ITEM_TOHIT_DEMON_BYTIME_MOD,
STATS_ITEM_TOHIT_UNDEAD_BYTIME_MOD,
STATS_ITEM_CRUSHINGBLOW_BYTIME_MOD,
STATS_ITEM_OPENWOUNDS_BYTIME_MOD,
STATS_ITEM_KICK_DAMAGE_BYTIME_MOD,
STATS_ITEM_DEADLYSTRIKE_BYTIME_MOD,
STATS_ITEM_FIND_GEMS_BYTIME_MOD,
STATS_ITEM_PIERCE_COLD_MOD,
STATS_ITEM_PIERCE_FIRE_MOD,
STATS_ITEM_PIERCE_LTNG_MOD,
STATS_ITEM_PIERCE_POIS_MOD,
STATS_ITEM_DAMAGE_VS_MONSTER_MOD,
STATS_ITEM_DAMAGE_PERCENT_VS_MONSTER_MOD,
STATS_ITEM_TOHIT_VS_MONSTER_MOD,
STATS_ITEM_TOHIT_PERCENT_VS_MONSTER_MOD,
STATS_ITEM_AC_VS_MONSTER_MOD,
STATS_ITEM_AC_PERCENT_VS_MONSTER_MOD,
INDESTRUCTIBLE,
STATS_ITEM_CHARGED_SKILL_MOD
};
enum D2ItemFlags
{
ITEMFLAG_NEWITEM = 0x00000001,
ITEMFLAG_MAGICAL = 0x00000010,
ITEMFLAG_SOCKETED = 0x00000800,
ITEMFLAG_EAR = 0x00001000,
ITEMFLAG_NEWITEM2 = 0x00002000,
ITEMFLAG_CHECKSECPRICE = 0x00010000,
ITEMFLAG_CHACKGAMBLEPRICE = 0x00020000,
ITEMFLAG_ETHERAL = 0x00400000,
ITEMFLAG_FROMPLAYER = 0x01000000
};
enum D2ItemTtype
{
TYPE_NONE0 = 0,
TYPE_NONE1,
TYPE_SHIELD,
TYPR_ARMOR,
TYPE_GOLD,
TYPE_BOW_QUIVER,
TYPE_CROSSBOW_QUIVER,
TYPE_PLAYER_BODY_PART,
TYPE_HERB,
TYPE_POTION,
TYPE_RING,
TYPE_ELIXIR,
TYPE_AMULET,
TYPE_CHARM,
TYPE_NOT_USED14,
TYPE_BOOTS,
TYPE_GLOVES,
TYPE_NOT_USED17,
TYPE_BOOK,
TYPE_BELT,
TYPE_GEM,
TYPE_TORCH,
TYPE_SCROLL,
TYPE_NOT_USED23,
TYPE_SCEPTER,
TYPE_WAND,
TYPE_STAFF,
TYPE_BOW,
TYPE_AXE,
TYPE_CLUB,
TYPE_SWORD,
TYPE_HAMMER,
TYPE_KNIFE,
TYPE_SPEAR,
TYPE_POLEARM,
TYPE_CROSSBOW,
TYPE_MACE,
TYPE_HELM,
TYPE_MISSILE_POTION,
TYPE_QUEST,
TYPE_BODY_PART,
TYPE_KEY,
TYPE_THROWING_KNIFE,
TYPE_THROWING_AXE,
TYPE_JAVELIN,
TYPE_WEAPON,
TYPE_MELEE_WEAPON,
TYPE_MISSILE_WEAPON,
TYPE_THROWN_WEAPON,
TYPE_COMBO_WEAPON,
TYPE_ANY_ARMOR,
TYPE_ANY_SHIELD,
TYPE_MISCELLANEOUS,
TYPE_SOCKET_FILLER,
TYPE_SECOND_HAND,
TYPE_STAVES_AND_RODS,
TYPE_MISSILE,
TYPE_BLUNT,
//Expansion
TYPE_JEWEL,
TYPE_CLASS_SPECIFIC,
TYPE_AMAZON_ITEM,
TYPE_BARBARIAN_ITEM,
TYPE_NECROMANCER_ITEM,
TYPE_PALADIN_ITEM,
TYPE_SORCERESS_ITEM,
TYPE_ASSASSIN_ITEM,
TYPE_DRUID_ITEM,
TYPE_HAND_TO_HAND,
TYPE_ORB,
TYPE_VOODOO_HEADS,
TYPE_AURIC_SHIELDS,
TYPE_PRIMAL_HELM,
TYPE_PELT,
TYPE_CLOAK,
TYPE_RUNE,
TYPE_CIRCLET,
TYPE_HEALING_POTION,
TYPE_MANA_POTION,
TYPE_REJUV_POTION,
TYPE_STAMINA_POTION,
TYPE_ANTIDOTE_POTION,
TYPE_THAWING_POTION,
TYPE_SMALL_CHARM,
TYPE_MEDIUM_CHARM,
TYPE_LARGE_CHARM,
TYPE_AMAZON_BOW,
TYPE_AMAZON_SPEAR,
TYPE_AMAZON_JAVELIN,
TYPE_HAND_TO_HAND2,
TYPE_MAGIC_BOW_QUIVER,
TYPE_MAGIC_CROSSBOW_QUIVER,
TYPE_CHIPPED_GEM,
TYPE_FLAWED_GEM,
TYPE_STANDARD_GEM,
TYPE_FLAWLESS_GEM,
TYPE_PERFECT_GEM,
TYPE_AMETHYST,
TYPE_DIAMOND,
TYPE_EMERALD,
TYPE_RUBY,
TYPE_SAPPHIRE,
TYPE_TOPAZ,
TYPE_SKULL
};
enum D2ItemQuality
{
ITEMQUALITY_CRACKED = 1,
ITEMQUALITY_NORMAL,
ITEMQUALITY_SUPERIOR,
ITEMQUALITY_MAGIC,
ITEMQUALITY_SET,
ITEMQUALITY_RARE,
ITEMQUALITY_UNIQUE,
ITEMQUALITY_CRAFTED,
ITEMQUALITY_TEMPERED
};
enum D2UnitType
{
UNIT_PLAYER = 0,
UNIT_MONSTER,
UNIT_OBJECT,
UNIT_MISSILE,
UNIT_ITEM,
UNIT_ROOMTILE
};
enum D2BodyLoc
{
LOC_HEAD =1,
LOC_NECK,
LOC_TORS,
LOC_RARM,
LOC_LARM,
LOC_LRIN,
LOC_RRIN,
LOC_BELT,
LOC_FEET,
LOC_GLOV,
LOC_RALT,
LOC_LALT
};
/*================================= END OF FILE =================================*/

54
Commons/updatingConst.h Normal file
View File

@ -0,0 +1,54 @@
/*=================================================================
File created by Yohann NICOLAS.
Updating Client and Server constantes.
=================================================================*/
#pragma once
enum UpdateClientConst
{
UC_SELECT_STASH=0x18,
UC_SHARED_GOLD,
UC_ADD_STAT,
UC_ADD_SYNERGY,
UC_TEST1,
UC_TEST2,
UC_TEST3
};
enum UpdateServerConst
{
US_UNASSIGN_STR_POINT=0x10,//Don't change these first 8 value
US_UNASSIGN_ENE_POINT,
US_UNASSIGN_DEX_POINT,
US_UNASSIGN_VIT_POINT,
US_UNASSIGN_STR_POINTS,
US_UNASSIGN_ENE_POINTS,
US_UNASSIGN_DEX_POINTS,
US_UNASSIGN_VIT_POINTS,
US_UNASSIGN_SKILLS,
US_SELECT_PREVIOUS,
US_SELECT_NEXT,
US_SELECT_SELF,
US_SELECT_SHARED,
US_SELECT_PREVIOUS_INDEX,
US_SELECT_NEXT_INDEX,
US_SELECT_PREVIOUS2,
US_SELECT_NEXT2,
US_SELECT_PREVIOUS_INDEX2,
US_SELECT_NEXT_INDEX2,
US_WORLDEVENT,
US_STARTSAVE,
US_MAXGOLD,
US_PUTGOLD,
US_TAKEGOLD,
//For CB
US_TEST1,
US_TEST2,
US_TEST3
};
/*================================= END OF FILE =================================*/

104
PlugY/BigStash.cpp Normal file
View File

@ -0,0 +1,104 @@
/*=================================================================
File created by Yohann NICOLAS.
Use a more big stash
=================================================================*/
#include "common.h"
#include "error.h"
#include "d2functions.h"
#include "plugYFiles.h" // Install_PlugYFiles()
bool active_bigStash = false;
bool active_bigStash_tested = false;
const char* tradeStash_RefFile= "%s\\TradeStash";
const BYTE gridX_BB = 10;
const BYTE gridY_BB = 10;
const DWORD gridLeft_BB = 16;
const DWORD gridRight_BB = 302;
const DWORD gridTop_BB = 82;
const DWORD gridbottom_BB = 371;
InventoryBIN* STDCALL modifStashGrid(InventoryBIN* ptInventoryBin)
{
active_bigStash_tested = true;
if ( onRealm || !active_bigStash) return ptInventoryBin;
InventoryBIN* inventory=ptInventoryBin+12;
inventory->gridX = gridX_BB;
inventory->gridY = gridY_BB;
inventory->gridLeft = gridLeft_BB;
inventory->gridRight = gridRight_BB;
inventory->gridTop = gridTop_BB;
inventory->gridBottom = gridbottom_BB;
inventory = ptInventoryBin+28;
inventory->gridX = gridX_BB;
inventory->gridY = gridY_BB;
inventory->gridLeft = gridLeft_BB + 80;
inventory->gridRight = gridRight_BB + 80;
inventory->gridTop = gridTop_BB + 60;
inventory->gridBottom = gridbottom_BB + 60;
return ptInventoryBin;
}
FCT_ASM ( caller_modifStashGrid )
POP ESI
CALL D2CompileTxtFile
PUSH EAX
CALL modifStashGrid
JMP ESI
}}
FCT_ASM ( caller_changeTradeStash )
CMP onRealm,0
JNZ normalTradeStash
MOV EAX,modDataDirectory
MOV DWORD PTR SS:[ESP+0x8],EAX
MOV EAX,tradeStash_RefFile
MOV DWORD PTR SS:[ESP+0x4],EAX
normalTradeStash:
POP EAX
PUSH 0x104
JMP EAX
}}
void Install_BigStash()
{
static int isInstalled = false;
if (isInstalled) return;
Install_PlugYFiles();
log_msg("Patch D2Common & D2Client for make 10x10 squares in the stash. (BigStash)\n");
// modification of stash grid
mem_seek R7(D2Common, C9F3, CA03, 14ED3, 5FCB5, 2A505, 1BDB5, 82CA5);
MEMC_REF4( D2CompileTxtFile, caller_modifStashGrid);
//01B64ED2 |. E8 99AEFFFF CALL D2Common.#10578
//6FDAFCB4 |. E8 A7C3FCFF CALL D2Common.#10653
//6FD7A504 |. E8 5743FEFF CALL D2Common.#10496 ; \#10496
//6FD6BDB4 |. E8 97600200 CALL D2Common.#10244 ; \#10244
//6FDD2CA4 |. E8 97C2FDFF CALL D2Common.#10849 ; \#10849
// modification of stash background
mem_seek R7(D2Client, 45B1C, 45B1C, 4C61C, A643C, 749BC, A9D7C, 8CC1C);
memt_byte( 0x68, 0xE8 ); // CALL caller_changeTradeStash
MEMT_REF4( 0x00000104, caller_changeTradeStash);
//6FAEC61C |. 68 04010000 PUSH 104
//6FB5643C |. 68 04010000 PUSH 104
//6FB249BC |. 68 04010000 PUSH 104
//6FB59D7C |. 68 04010000 PUSH 104
//6FB3CC1C |. 68 04010000 PUSH 104
log_msg("\n");
isInstalled = true;
}
/*================================= END OF FILE =================================*/

115
PlugY/ClientSaveFile.cpp Normal file
View File

@ -0,0 +1,115 @@
/*=================================================================
File created by Yohann NICOLAS.
Add an extra save file for each characters.
=================================================================*/
/*
#include "common.h"
#include "error.h"
#include "d2functions.h"
#include <stdio.h>
#define BUFFER_SIZE 0x4000
#define FILE_VERSION 0x3130 //"01"
#define FILE_SAVETYPE 0x544E4C43 //"CLNT"
BYTE * openClientSaveFile(char* name, DWORD* size)
{
char filename[512];
BYTE* data;
d2_assert(!name, "Bad file name (NULL)", __FILE__, __LINE__);
D2FogGetSavePath( filename, 512-5);
strncat(filename, name, 512 - strlen(filename) - 5);
strcat(filename, ".clt");
log_msg("Client file to read : %s\n",filename);
FILE* file = fopen(filename, "rb");
if (file)
{
fseek(file, 0, SEEK_END);
*size = ftell(file);
fseek(file, 0, SEEK_SET);
data = (BYTE*)D2FogMemAlloc(*size,__FILE__,__LINE__,0);
DWORD nbRead = fread(data, 1, *size, file);
fclose(file);
d2_assert(nbRead != *size , "nbRead from client save file != size", __FILE__, __LINE__);
} else {
log_msg("Can't open client save file in mode \"rb\" (is not an error if it's a new player)\n");
*size = 6;
data = (BYTE*)D2FogMemAlloc(*size,__FILE__,__LINE__,0);
*((DWORD*)&data[0]) = FILE_SAVETYPE; //"CSTM"
*((WORD *)&data[4]) = FILE_VERSION;
}
return data;
}
DWORD loadClientSaveFile()
{
Unit* ptChar = D2GetClientPlayer();
DWORD size=0;
log_msg("Load client file\n");
if (!ptChar || !PCPlayerData) return 0;
BYTE* data = openClientSaveFile(PCPlayerData->name,&size);
if (!data) return 0;
DWORD curSize = 0;
log_msg("Load client file.\n");
if (*(DWORD*)&data[curSize] != FILE_SAVETYPE)
{
log_msg("loadClientSaveFile -> bad header\n");
D2FogMemDeAlloc(data,__FILE__,__LINE__,0);
return 9;
}
curSize += 4;
if (*(WORD *)&data[curSize] != FILE_VERSION)
{
log_msg("loadClientSaveFile -> bad file version\n");
D2FogMemDeAlloc(data,__FILE__,__LINE__,0);
return 9;
}
curSize += 2;
D2FogMemDeAlloc(data,__FILE__,__LINE__,0);
return 0;
}
DWORD saveClientSaveFile()
{
DWORD curSize = 0;
BYTE data[BUFFER_SIZE];
char szTempName[MAX_PATH];
char szSaveName[MAX_PATH];
FILE* customSaveFile;
Unit* ptChar = D2GetClientPlayer();
D2FogGetSavePath( (char*)data, BUFFER_SIZE);
sprintf( szTempName, "%s%s.cl~", data, PCPlayerData->name );
log_msg("Client tmp file for saving : %s\n",szTempName);
customSaveFile = fopen(szTempName, "wb+");
*(DWORD *)&data[curSize] = FILE_SAVETYPE;
curSize += 4;
*(WORD *)&data[curSize] = FILE_VERSION;
curSize += 2;
fwrite(data, curSize, 1, customSaveFile);
fclose(customSaveFile);
D2FogGetSavePath( (char*)data, BUFFER_SIZE);
sprintf( szSaveName, "%s%s.clt", data, PCPlayerData->name );
log_msg("Client save file for saving : %s\n",szSaveName);
// if (!MoveFileEx(szTempName, szSaveName, MOVEFILE_WRITE_THROUGH|MOVEFILE_REPLACE_EXISTING))
DeleteFile(szSaveName);
if (!MoveFile(szTempName, szSaveName))
log_box("Could not create the client save file.");
return 1;
}
/*================================= END OF FILE =================================*/

283
PlugY/Commands.cpp Normal file
View File

@ -0,0 +1,283 @@
/*=================================================================
File created by Yohann NICOLAS.
Updating server.
=================================================================*/
#include "common.h"
#include "error.h"
#include "d2functions.h"
#include "updateServer.h"
#include "updateClient.h"
#include "infinityStash.h"
#include "newInterfaces.h"
#include "newInterface_CubeListing.h"
#include "extraOptions.h"
bool active_Commands=true;
bool active_listAllCubeFormula=true;
bool active_savegame=false;
#define MAX_CMD_SIZE 200
const char * CMD_RENAME="/rename";
const char * CMD_LISTCUBEFORMULA="/listcube";
const char * CMD_SELECTPAGE="/page";
const char * CMD_RELOAD="/reload";
const char * CMD_STARTSAVE="/save";
const char * CMD_MAXGOLD="/maxgold";
const char * CMD_DISPLAY_MANA_LIFE = "/dml";
const char * CMD_DISPLAY_LIFE_MANA = "/dlm";
const char * CMD_DISPLAY_LIFE = "/dl";
const char * CMD_DISPLAY_MANA = "/dm";
/*
$+21C8 02020648 |. 6A 01 PUSH 1
$+21CA 0202064A |. 52 PUSH EDX
$+21CB 0202064B |. 57 PUSH EDI
$+21CC 0202064C |. 55 PUSH EBP
$+21CD 0202064D |. 8BC3 MOV EAX,EBX
$+21CF 0202064F |. E8 2CDEFFFF CALL D2Game.0201E480
*/
void gambleReload(Unit* ptChar)
{
Unit* ptNPC = D2GetCurrentNPC();
if (ptNPC)
{
D2TogglePage(0xC,1,0);
__asm {
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
}
// D2OpenNPCMenu(ptNPC);
D2ReloadGambleScreen();
}
}
//6FACFFD4 |. E8 77F90000 CALL D2Client.6FADF950
void savePlayers(Unit* ptChar)
{
if (active_savegame)
D2SaveGame(PCGame);
}
void maxGold(Unit* ptChar)
{
log_msg("maxGold\n");
DWORD maxGold = D2GetMaxGold(ptChar);
DWORD maxGoldBank = D2GetMaxGoldBank(ptChar);
DWORD playerGold = D2GetPlayerStat(ptChar, STATS_GOLD, 0);
DWORD playerGoldBank = D2GetPlayerStat(ptChar, STATS_GOLDBANK, 0);
if ( (playerGold < maxGold) || (playerGoldBank < maxGoldBank) ) {
D2AddPlayerStat( ptChar, STATS_GOLD, maxGold-playerGold, 0 );
D2AddPlayerStat( ptChar, STATS_GOLDBANK, maxGoldBank-playerGoldBank, 0 );
} else {
D2AddPlayerStat( ptChar, STATS_GOLD, 100000, 0 );
}
if (active_sharedGold)
{
PCPY->sharedGold = 0xFFFFFFFF;
updateClient(ptChar, UC_SHARED_GOLD, PCPY->sharedGold, 0, 0);
}
}
void putGold(Unit* ptChar, DWORD amount)
{
if (!active_sharedGold) return;
log_msg("putGold : %d\n", amount);
DWORD playerGold = D2GetPlayerStat(ptChar, STATS_GOLD, 0);
DWORD toAdd = 0xFFFFFFFF - PCPY->sharedGold;
if (playerGold < toAdd)
toAdd = playerGold;
if (amount && (toAdd > amount))
toAdd = amount;
D2AddPlayerStat(ptChar, STATS_GOLD, 0-toAdd, 0);
PCPY->sharedGold += toAdd;
updateClient(ptChar, UC_SHARED_GOLD, PCPY->sharedGold, 0, 0);
}
void takeGold(Unit* ptChar, DWORD amount)
{
if (!active_sharedGold) return;
log_msg("takeGold : %d\n", amount);
DWORD maxGold = D2GetMaxGold(ptChar) - D2GetPlayerStat(ptChar, STATS_GOLD, 0);
// DWORD maxGoldBank = D2GetMaxGoldBank(ptChar) - D2GetPlayerStat(ptChar, STATS_GOLDBANK, 0);
DWORD toAdd = maxGold < PCPY->sharedGold ? maxGold : PCPY->sharedGold;
if (amount && (toAdd > amount))
toAdd = amount;
D2AddPlayerStat( ptChar, STATS_GOLD, toAdd, 0 );
PCPY->sharedGold -= toAdd;
updateClient(ptChar, UC_SHARED_GOLD, PCPY->sharedGold, 0, 0);
}
void updateSharedGold(DWORD goldAmount)
{
Unit* ptChar = D2GetClientPlayer();
log_msg("SharedGold = %d\n",goldAmount);
PCPY->sharedGold = goldAmount;
}
/****************************************************************************************************/
int STDCALL commands (char* ptText)
{
Unit* ptChar = D2GetClientPlayer();
char command[MAX_CMD_SIZE];
ZeroMemory(command,MAX_CMD_SIZE);
strncpy(command,ptText,MAX_CMD_SIZE-1);
strlwr(command);
if (!strncmp(command,CMD_RENAME,strlen(CMD_RENAME)))
{
if (!active_multiPageStash) return 1;
char* param = &command[strlen(CMD_RENAME)];
DWORD len = strlen(param);
if (len && (param[0] != ' ')) return 1;
Stash* ptStash = PCPY->currentStash;
if (!ptStash) return 0;
if (len>1)
{
D2FogMemDeAlloc(ptStash->name,__FILE__,__LINE__,0);
ptStash->name = (char *)malloc(len);//D2FogMemAlloc(len,__FILE__,__LINE__,0);
strcpy(ptStash->name,&param[1]);
} else {
D2FogMemDeAlloc(ptStash->name,__FILE__,__LINE__,0);
ptStash->name = NULL;
}
return 0;
}
if (!strcmp(command,CMD_LISTCUBEFORMULA))
{
if (!active_listAllCubeFormula) return 1;
listAllCubeFormula();
return 0;
}
if (!strncmp(command,CMD_SELECTPAGE,strlen(CMD_SELECTPAGE)))
{
if (!active_newInterfaces) return 1;
GoStatPage(atoi(&command[strlen(CMD_SELECTPAGE)])-1);
return 0;
}
if (!strcmp(command,CMD_RELOAD))
{
if (onRealm) return 1;
gambleReload(ptChar);
return 0;
}
if (!strcmp(command,CMD_STARTSAVE))
{
if (onRealm) return 1;
updateServer(US_STARTSAVE);
return 0;
}
if (!strcmp(command,CMD_MAXGOLD))
{
if (onRealm) return 1;
updateServer(US_MAXGOLD);
return 0;
}
if (!strcmp(command,CMD_DISPLAY_LIFE))
{
active_AlwaysDisplayLifeMana = !active_AlwaysDisplayLifeMana;
return 0;
}
if (!strcmp(command,CMD_DISPLAY_MANA))
{
active_AlwaysDisplayLifeMana = !active_AlwaysDisplayLifeMana;
return 0;
}
if (!strcmp(command,CMD_DISPLAY_LIFE_MANA) || !strcmp(command,CMD_DISPLAY_MANA_LIFE))
{
active_AlwaysDisplayLifeMana = !active_AlwaysDisplayLifeMana;
return 0;
}
return 1;
}
FCT_ASM ( caller_Commands )
TEST EAX,EAX
JE MANAGESOUNDCHAOSDEBUG
PUSH DWORD PTR SS:[ESP+0x1C]
CALL commands
TEST EAX,EAX
JNZ MANAGESOUNDCHAOSDEBUG
ADD DWORD PTR SS:[ESP],7
MANAGESOUNDCHAOSDEBUG:
RETN 8
}}
FCT_ASM ( caller_Commands_111 )
TEST EAX,EAX
JE MANAGESOUNDCHAOSDEBUG
PUSH ESI
CALL commands
TEST EAX,EAX
JNZ MANAGESOUNDCHAOSDEBUG
ADD DWORD PTR SS:[ESP],7
MANAGESOUNDCHAOSDEBUG:
RETN 8
}}
void Install_Commands()
{
static int isInstalled = false;
if (isInstalled) return;
Install_UpdateServer();
log_msg("Patch D2Client for install commands. (Commands)\n");
active_listAllCubeFormula = version_D2Common >= V110;
active_savegame = version_D2Common >= V111;
// Run custom commmand
mem_seek R7(D2Client, 2C120, 2C110, 32BDD, C1EE6, 91C16, 86926, 70AE6);
memt_byte( 0x83, 0xE8 ); // CALL
MEMT_REF4( 0xC08508C4 , version_D2Client >= V111 ? caller_Commands_111 : caller_Commands);
//6FB71EE6 . 83C4 08 ADD ESP,8
//6FB71EE7 . 85C0 TEST EAX,EAX
//6FB41C16 |. 83C4 08 ADD ESP,8
//6FB41C19 |. 85C0 TEST EAX,EAX
//6FB36926 |. 83C4 08 ADD ESP,8
//6FB36929 |. 85C0 TEST EAX,EAX
//6FB20AE6 |. 83C4 08 ADD ESP,8
//6FB20AE9 |. 85C0 TEST EAX,EAX
//6FB20AE6 |. 83C4 08 ADD ESP,8
//6FB20AE9 |. 85C0 TEST EAX,EAX
log_msg("\n");
isInstalled = true;
}
/*================================= END OF FILE =================================*/

489
PlugY/Common.cpp Normal file
View File

@ -0,0 +1,489 @@
/*=================================================================
File created by Yohann NICOLAS.
Common functions.
=================================================================*/
#include "common.h"
#include "error.h"
#include "d2functions.h"
s_shifting shifting;
bool isOnRect(DWORD x, DWORD y, DWORD x0, DWORD y0, DWORD l, DWORD h)
{return (x>=x0) && (x<x0+l) && (y>y0-h) && (y<=y0);}
void freeMessage(sWinMessage* msg)
{
msg->managed=1;
msg->unmanaged=0;
D2FreeWinMessage(msg);
}
LPWSTR getString(LPWSTR eng, LPWSTR esp, LPWSTR deu, LPWSTR fra, LPWSTR por, LPWSTR ita, LPWSTR jpn, LPWSTR kor, LPWSTR sin, LPWSTR chi, LPWSTR pol, LPWSTR rus)
{
switch(D2GetLang())
{
case LNG_ENG: return eng;
case LNG_ESP: return esp;
case LNG_DEU: return deu;
case LNG_FRA: return fra;
case LNG_POR: return por;
case LNG_ITA: return ita;
case LNG_JPN: return jpn;
case LNG_KOR: return kor;
case LNG_SIN: return sin;
case LNG_CHI: return chi;
case LNG_POL: return pol;
case LNG_RUS: return rus;
case LNG_DEF:
default: return eng;
}
}
#define LANGUAGE(I,ENG,FRA,DEU,ITA,ESP,POL/*,CHI*/) case I : return getString(L##ENG,L##ESP,L##DEU,L##FRA,L##ENG,L##ITA,L##ENG,L##ENG,L##ENG,L##ENG,L##POL,L##ENG)
LPWSTR getTranslatedString(int stringID)
{
switch(stringID)
{
/* LANGUAGE2( STR_STATS_UNASSIGN_WITH_LIMIT,
"+Alt: ;,+Shift: %d \x70B9\x6570",//"+Alt: Unassign, +Shift: by %d points",
// "+Alt: \x91CD\x5206\x914D;,+Shift: %d \x70B9\x6570",//"+Alt: Unassign, +Shift: by %d points",
"+Alt: Désallocation, +Shift: par %d points,",
"+Alt: Zurücksetzen, +Shift: um %d Punkte",
"+Alt: Rimuovi, +Shift: Assegna %d punti",
"+Alt: Quita, +Shift: por %d puntos",
"+Alt: \37325\20998\37197;,+Shift:%d \28857\25968");
*/
LANGUAGE( STR_STATS_UNASSIGN_WITH_LIMIT,
"+Alt: Unassign, +Shift: by %d points",
"+Alt: Désallocation, +Shift: par %d points",
"+Alt: Zurücksetzen, +Shift: um %d Punkte",
"+Alt: Rimuovi, +Shift: Assegna %d punti",
"+Alt: Quita, +Shift: por %d puntos",
"+Alt: Odejmij, +Shift: %d punktów");
// "+Alt: ????, +Shift: %d ??");
LANGUAGE( STR_STATS_UNASSIGN_WITHOUT_LIMIT,
"+Alt: Unassign, +Shift: all remaining points",
"+Alt: Désallocation, +Shift: Tous les points restants",
"+Alt: Zurücksetzen, +Shift: Alle verbleibenden Punkte",
"+Alt: Rimuovi, +Shift: Assegna tutti i punti rimanenti",
"+Alt: Quita, +Shift: Todos los puntos restantes",
"+Alt: Odejmij, +Shift: wszystkie pozostale punkty");
// "+Alt: ????, +Shift: ???");
LANGUAGE( STR_STATS_BASE_MIN,
"Base: %d (Min: %d)",
"Base: %d (Min: %d)",
"Basiswert: %d (Min: %d)",
"Base: %d (Min: %d)",
"Base: %d (Min: %d)",
"Bazowo: %d (Minimum: %d)");
// "??: %d(??: %d)");
LANGUAGE( STR_SKILLS_UNASSIGN,
"Un-allocate all skills points",
"Désalloue tous les points d'aptitudes",
"Alle Fertigkeitspunkte zurücksetzen",
"Rimuovi tutte le abilità",
"Quita todos los puntos de habilidades",
"Rozdaj od nowa wszystkie punkty umiejetnosci");
// "????????");
LANGUAGE( STR_STASH_PREVIOUS_PAGE,
"Previous Page (+shift: First Page)",
"Page précédente (+shift: Première page)",
"Vorherige Seite (+shift: Erste Seite)",
"Pagina Precedente (+shift: Prima Pagina)",
"Pagina anterior (+shift: Primera Pagina)",
"Poprzednia Strona (+shift: Pierwsza Strona)");
// "??? (+shift: ??)");
LANGUAGE( STR_STASH_NEXT_PAGE,
"Next Page (+shift: Last not empty Page)",
"Page suivante (+shift: Dernière page non vide)",
"Nächste Seite (+shift: Letzte nicht leere Seite )",
"Pagina Successiva (+shift: Ultima Pagina non vuota)",
"Pagina Siguiente (+shift: Ultima pagina non vacia)",
"Nastepna Strona (+shift: Ostatnia nie pusta Strona)");
// "??? (+shift: ?????");
LANGUAGE( STR_TOGGLE_TO_PERSONAL,
"Toggle to Personal Stash",
"Voir coffre personnel",
"Wechselt zum persönlichen Goldschatz",
"Vai all'Inventario Personale",
"Ver el cofre personal",
"Przejdz do Skrzyni Osobistej");
// "????????");
LANGUAGE( STR_TOGGLE_TO_SHARED,
"Toggle to Shared Stash",
"Voir coffre partagé",
"Wechselt zum gemeinsamen Goldschatz",
"Vai all'Inventario Condiviso",
"Ver el cofre compartido",
"Przejdz do Skrzyni Wspólnej");
// "????????");
LANGUAGE( STR_STASH_PREVIOUS_INDEX,
"Previous Index : by %d Pages (+Shift: %d)",
"Index précédent : par %d pages (+shift: %d)",
"Vorheriger Index: in %d Seiten (+shift: %d)",
"Schermata Precedente : Indietro di %d Pagine (+Shift: %d)",
"Indice anterior : por %d paginas (+shift: %d)",
"Poprzednia Strona : po %d Stron (+Shift: %d)");
// "???? : %d ? (+Shift:%d)");
LANGUAGE( STR_STASH_NEXT_INDEX,
"Next Index : by %d Pages (+shift: %d)",
"Index suivant : par %d pages (+shift: %d)",
"Nächster Index: in %d Seiten (+shift: %d)",
"Schermata Successiva : Avanti di %d Pagine (+shift: %d)",
"Indice siguiente : por %d paginas (+shift: %d)",
"Nastepna Strona : po %d Stron (+shift: %d)");
// "???? : %d ? (+shift:%d)");
LANGUAGE( STR_PUT_GOLD,
"Put Gold",
"Poser de l'Or",
"Gib Gold",
"Immetti Oro",
"Poner oro",
"Zdeponuj Zloto");
// "????");
LANGUAGE( STR_TAKE_GOLD,
"Take Gold",
"Prendre de l'Or",
"Nehme Gold",
"Ritira Oro",
"Tomar oro",
"Wyplac zloto");
// "????");
LANGUAGE( STR_PERSONAL_PAGE_NUMBER,
"Personal Page n°%u",
"Page perso n°%u",
"Persönliche Seite n°%u",
"Pagina Personale n°%u",
"Pagina personal n°%u",
"Strona Osobista n°%u");
// "????? n°%u");
LANGUAGE( STR_SHARED_PAGE_NUMBER,
"Shared Page n°%u",
"Page partagée n°%u",
"Gemeinsame Seite n°%u",
"Pagina Condivisa n°%u",
"Pagina personal n°%u",
"Strona Wspólna n°%u");
// "????? n°%u");
LANGUAGE( STR_NO_SELECTED_PAGE,
"No selected page",
"Aucune page sélectionnée",
"Keine ausgewählte Seite",
"Nessuna pagina selezionata",
"Ninguna pagina seleccionada",
"Nie zaznaczono strony");
// "????");
LANGUAGE( STR_SHARED_GOLD_QUANTITY,
"Shared Gold : %u",
"Or partagé : %u",
"Gemeinsamen Gold : %u",
"Oro Condiviso : %u",
"Oro compartido : %u",
"Wspólne Zloto : %u");
// "????: %u");
LANGUAGE( STR_PREVIOUS_PAGE,
"Previous Page",
"Page précédente",
"Vorherige Seite",
"Pagina Precedente",
"Pagina anterior",
"Poprzednia Strona");
// "???");
LANGUAGE( STR_NEXT_PAGE,
"Next Page",
"Page suivante",
"Nächste Seite",
"Pagina Successiva",
"Pagina siguiente",
"Nastepna Strona");
// "???");
default : return L"";
}
}
/*=================================================================*/
const char* SNONE="";
const char* c_shie[3]={"Shield (Not Class Specific)",SNONE,SNONE};
const char* c_tors[3]={"Body Armor",SNONE,SNONE};
const char* c_gold[3]={"Gold",SNONE,SNONE};
const char* c_bowq[3]={"Arrow",SNONE,SNONE};
const char* c_xboq[3]={"Bolt",SNONE,SNONE};
const char* c_play[3]={"Ear",SNONE,SNONE};
const char* c_herb[3]={"Herb",SNONE,SNONE};
const char* c_poti[3]={"Potion",SNONE,SNONE};
const char* c_ring[3]={"Ring",SNONE,SNONE};
const char* c_elix[3]={"Elixir",SNONE,SNONE};
const char* c_amul[3]={"Amulet",SNONE,SNONE};
const char* c_char[3]={"Charm",SNONE,SNONE};
const char* c_boot[3]={"Boot",SNONE,SNONE};
const char* c_glov[3]={"Glove",SNONE,SNONE};
const char* c_book[3]={"Book",SNONE,SNONE};
const char* c_belt[3]={"Belt",SNONE,SNONE};
const char* c_gem[3]={"Gem",SNONE,SNONE};
const char* c_torc[3]={"Torch",SNONE,SNONE};
const char* c_scro[3]={"Scroll",SNONE,SNONE};
const char* c_scep[3]={"Scepter",SNONE,SNONE};
const char* c_wand[3]={"Wand",SNONE,SNONE};
const char* c_staf[3]={"Staff",SNONE,SNONE};
const char* c_bow[3]={"Bow",SNONE,SNONE};
const char* c_axe[3]={"Axe",SNONE,SNONE};
const char* c_club[3]={"Club",SNONE,SNONE};
const char* c_swor[3]={"Sword",SNONE,SNONE};
const char* c_hamm[3]={"Hammer",SNONE,SNONE};
const char* c_knif[3]={"Knife",SNONE,SNONE};
const char* c_spea[3]={"Spear",SNONE,SNONE};
const char* c_pole[3]={"Polearm",SNONE,SNONE};
const char* c_xbow[3]={"Crossbow",SNONE,SNONE};
const char* c_mace[3]={"Mace",SNONE,SNONE};
const char* c_helm[3]={"Helm",SNONE,SNONE};
const char* c_tpot[3]={"Missile Potion",SNONE,SNONE};
const char* c_ques[3]={"Quest Item",SNONE,SNONE};
const char* c_body[3]={"Body Part",SNONE,SNONE};
const char* c_key[3]={"Key",SNONE,SNONE};
const char* c_tkni[3]={"Throwing Knife",SNONE,SNONE};
const char* c_taxe[3]={"Throwing Axe",SNONE,SNONE};
const char* c_jave[3]={"Javelin",SNONE,SNONE};
const char* c_weap[3]={"Weapon",SNONE,SNONE};
const char* c_mele[3]={"Melee Weapon",SNONE,SNONE};
const char* c_miss[3]={"Missile Weapon",SNONE,SNONE};
const char* c_thro[3]={"Throwing Weapon",SNONE,SNONE};
const char* c_comb[3]={"Combo Weapon",SNONE,SNONE};
const char* c_armo[3]={"Armor",SNONE,SNONE};
const char* c_shld[3]={"Any Shield",SNONE,SNONE};
const char* c_misc[3]={"Miscellaneous",SNONE,SNONE};
const char* c_sock[3]={"Socket Filler",SNONE,SNONE};
const char* c_seco[3]={"Second Hand Item",SNONE,SNONE};
const char* c_rod[3]={"Staves And Rods",SNONE,SNONE};
const char* c_misl[3]={"Missile",SNONE,SNONE};
const char* c_blun[3]={"Blunt",SNONE,SNONE};
const char* c_jewl[3]={"Jewel",SNONE,SNONE};
const char* c_clas[3]={"Class Specific",SNONE,SNONE};
const char* c_amaz[3]={"Amazon Item",SNONE,SNONE};
const char* c_barb[3]={"Barbarian Item",SNONE,SNONE};
const char* c_necr[3]={"Necromancer Item",SNONE,SNONE};
const char* c_pala[3]={"Paladin Item",SNONE,SNONE};
const char* c_sorc[3]={"Sorceress Item",SNONE,SNONE};
const char* c_assn[3]={"Assassin Item",SNONE,SNONE};
const char* c_drui[3]={"Druid Item",SNONE,SNONE};
const char* c_h2h[3]={"Claw",SNONE,SNONE};
const char* c_orb[3]={"Orb",SNONE,SNONE};
const char* c_head[3]={"Voodoo Heads",SNONE,SNONE};
const char* c_ashd[3]={"Paladin Shield",SNONE,SNONE};
const char* c_phlm[3]={"Barbarian Helm",SNONE,SNONE};
const char* c_pelt[3]={"Druid Helm",SNONE,SNONE};
const char* c_cloa[3]={"Cloak",SNONE,SNONE};
const char* c_rune[3]={"Rune",SNONE,SNONE};
const char* c_circ[3]={"Circlet",SNONE,SNONE};
const char* c_hpot[3]={"Healing Potion",SNONE,SNONE};
const char* c_mpot[3]={"Mana Potion",SNONE,SNONE};
const char* c_rpot[3]={"Rejuvenation potion",SNONE,SNONE};
const char* c_spot[3]={"Stamina Potion",SNONE,SNONE};
const char* c_apot[3]={"Antidote Potion",SNONE,SNONE};
const char* c_wpot[3]={"Thawing Potion",SNONE,SNONE};
const char* c_scha[3]={"Small Charm",SNONE,SNONE};
const char* c_mcha[3]={"Large Charm",SNONE,SNONE};
const char* c_lcha[3]={"Grand Charm",SNONE,SNONE};
const char* c_abow[3]={"Amazon Bow",SNONE,SNONE};
const char* c_aspe[3]={"Amazon Spear",SNONE,SNONE};
const char* c_ajav[3]={"Amazon Javelin",SNONE,SNONE};
const char* c_h2h2[3]={"Assassin Claw",SNONE,SNONE};
const char* c_mboq[3]={"Magic Arrow",SNONE,SNONE};
const char* c_mxbq[3]={"Magic Bolt",SNONE,SNONE};
const char* c_gem0[3]={"Chipped Gem",SNONE,SNONE};
const char* c_gem1[3]={"Flawed Gem",SNONE,SNONE};
const char* c_gem2[3]={"Normal Gem",SNONE,SNONE};
const char* c_gem3[3]={"Flawless Gem",SNONE,SNONE};
const char* c_gem4[3]={"Perfect Gem",SNONE,SNONE};
const char* c_gema[3]={"Amethyst",SNONE,SNONE};
const char* c_gemd[3]={"Diamond",SNONE,SNONE};
const char* c_geme[3]={"Emerald",SNONE,SNONE};
const char* c_gemr[3]={"Ruby",SNONE,SNONE};
const char* c_gems[3]={"Sapphire",SNONE,SNONE};
const char* c_gemt[3]={"Topaz",SNONE,SNONE};
const char* c_gemz[3]={"Skull",SNONE,SNONE};
const char* getTypeString (DWORD code)
{
DWORD lang = 0;//D2GetLang();
if ((lang == LNG_FRA) || (lang == LNG_DEU)) lang--;
else lang = 0;
switch (code)
{
case BIN('s','h','i','e') : return c_shie[0];
case BIN('t','o','r','s') : return c_tors[0];
case BIN('g','o','l','d') : return c_gold[0];
case BIN('b','o','w','q') : return c_bowq[0];
case BIN('x','b','o','q') : return c_xboq[0];
case BIN('p','l','a','y') : return c_play[0];
case BIN('h','e','r','b') : return c_herb[0];
case BIN('p','o','t','i') : return c_poti[0];
case BIN('r','i','n','g') : return c_ring[0];
case BIN('e','l','i','x') : return c_elix[0];
case BIN('a','m','u','l') : return c_amul[0];
case BIN('c','h','a','r') : return c_char[0];
case BIN('b','o','o','t') : return c_boot[0];
case BIN('g','l','o','v') : return c_glov[0];
case BIN('b','o','o','k') : return c_book[0];
case BIN('b','e','l','t') : return c_belt[0];
case BIN('g','e','m',' ') : return c_gem[0];
case BIN('t','o','r','c') : return c_torc[0];
case BIN('s','c','r','o') : return c_scro[0];
case BIN('s','c','e','p') : return c_scep[0];
case BIN('w','a','n','d') : return c_wand[0];
case BIN('s','t','a','f') : return c_staf[0];
case BIN('b','o','w',' ') : return c_bow[0];
case BIN('a','x','e',' ') : return c_axe[0];
case BIN('c','l','u','b') : return c_club[0];
case BIN('s','w','o','r') : return c_swor[0];
case BIN('h','a','m','m') : return c_hamm[0];
case BIN('k','n','i','f') : return c_knif[0];
case BIN('s','p','e','a') : return c_spea[0];
case BIN('p','o','l','e') : return c_pole[0];
case BIN('x','b','o','w') : return c_xbow[0];
case BIN('m','a','c','e') : return c_mace[0];
case BIN('h','e','l','m') : return c_helm[0];
case BIN('t','p','o','t') : return c_tpot[0];
case BIN('q','u','e','s') : return c_ques[0];
case BIN('b','o','d','y') : return c_body[0];
case BIN('k','e','y',' ') : return c_key[0];
case BIN('t','k','n','i') : return c_tkni[0];
case BIN('t','a','x','e') : return c_taxe[0];
case BIN('j','a','v','e') : return c_jave[0];
case BIN('w','e','a','p') : return c_weap[0];
case BIN('m','e','l','e') : return c_mele[0];
case BIN('m','i','s','s') : return c_miss[0];
case BIN('t','h','r','o') : return c_thro[0];
case BIN('c','o','m','b') : return c_comb[0];
case BIN('a','r','m','o') : return c_armo[0];
case BIN('s','h','l','d') : return c_shld[0];
case BIN('m','i','s','c') : return c_misc[0];
case BIN('s','o','c','k') : return c_sock[0];
case BIN('s','e','c','o') : return c_seco[0];
case BIN('r','o','d',' ') : return c_rod[0];
case BIN('m','i','s','l') : return c_misl[0];
case BIN('b','l','u','n') : return c_blun[0];
case BIN('j','e','w','l') : return c_jewl[0];
case BIN('c','l','a','s') : return c_clas[0];
case BIN('a','m','a','z') : return c_amaz[0];
case BIN('b','a','r','b') : return c_barb[0];
case BIN('n','e','c','r') : return c_necr[0];
case BIN('p','a','l','a') : return c_pala[0];
case BIN('s','o','r','c') : return c_sorc[0];
case BIN('a','s','s','n') : return c_assn[0];
case BIN('d','r','u','i') : return c_drui[0];
case BIN('h','2','h',' ') : return c_h2h[0];
case BIN('h','2','h','2') : return c_h2h2[0];
case BIN('o','r','b',' ') : return c_orb[0];
case BIN('h','e','a','d') : return c_head[0];
case BIN('a','s','h','d') : return c_ashd[0];
case BIN('p','h','l','m') : return c_phlm[0];
case BIN('p','e','l','t') : return c_pelt[0];
case BIN('c','l','o','a') : return c_cloa[0];
case BIN('r','u','n','e') : return c_rune[0];
case BIN('c','i','r','c') : return c_circ[0];
case BIN('h','p','o','t') : return c_hpot[0];
case BIN('m','p','o','t') : return c_mpot[0];
case BIN('r','p','o','t') : return c_rpot[0];
case BIN('s','p','o','t') : return c_spot[0];
case BIN('a','p','o','t') : return c_apot[0];
case BIN('w','p','o','t') : return c_wpot[0];
case BIN('s','c','h','a') : return c_scha[0];
case BIN('m','c','h','a') : return c_mcha[0];
case BIN('l','c','h','a') : return c_lcha[0];
case BIN('a','b','o','w') : return c_abow[0];
case BIN('a','s','p','e') : return c_aspe[0];
case BIN('a','j','a','v') : return c_ajav[0];
case BIN('m','b','o','q') : return c_mboq[0];
case BIN('m','x','b','q') : return c_mxbq[0];
case BIN('g','e','m','0') : return c_gem0[0];
case BIN('g','e','m','1') : return c_gem1[0];
case BIN('g','e','m','2') : return c_gem2[0];
case BIN('g','e','m','3') : return c_gem3[0];
case BIN('g','e','m','4') : return c_gem4[0];
case BIN('g','e','m','a') : return c_gema[0];
case BIN('g','e','m','d') : return c_gemd[0];
case BIN('g','e','m','e') : return c_geme[0];
case BIN('g','e','m','r') : return c_gemr[0];
case BIN('g','e','m','s') : return c_gems[0];
case BIN('g','e','m','t') : return c_gemt[0];
case BIN('g','e','m','z') : return c_gemz[0];
default: return NULL;
}
}
char* getTypeAString (WORD id, char* lpText, DWORD size)
{
ItemTypesBIN* itemTypeData = D2GetItemTypesBIN(id);
if (!itemTypeData)
{
strncpy(lpText, "Bad Type", size);
return lpText;
}
const char* string = getTypeString(itemTypeData->code);
if (!string)
{
struct {
DWORD code;
BYTE zero;
} code;
code.code = itemTypeData->code;
code.zero = 0;
strncpy(lpText, (char*)&code, size);
} else
strncpy(lpText, string, size);
return lpText;
}
LPWSTR getTypeUString (WORD id, LPWSTR lpText, DWORD size)
{
ItemTypesBIN* itemTypeData = D2GetItemTypesBIN(id);
if (!itemTypeData)
{
mbstowcs(lpText, "Bad Type", size);
return lpText;
}
const char* string = getTypeString(itemTypeData->code);
if (!string)
{
struct {
DWORD code;
BYTE zero;
} code;
code.code = itemTypeData->code;
code.zero = 0;
mbstowcs(lpText, (char*)&code, size);
} else
mbstowcs(lpText, string, size);
return lpText;
}
/*================================= END OF FILE =================================*/

489
PlugY/CommonUTF8.cpp Normal file
View File

@ -0,0 +1,489 @@
/*=================================================================
File created by Yohann NICOLAS.
Common functions.
=================================================================*/
#include "common.h"
#include "error.h"
#include "d2functions.h"
s_shifting shifting;
bool isOnRect(DWORD x, DWORD y, DWORD x0, DWORD y0, DWORD l, DWORD h)
{return (x>=x0) && (x<x0+l) && (y>y0-h) && (y<=y0);}
void freeMessage(sWinMessage* msg)
{
msg->managed=1;
msg->unmanaged=0;
D2FreeWinMessage(msg);
}
LPWSTR getString(LPWSTR eng, LPWSTR esp, LPWSTR deu, LPWSTR fra, LPWSTR por, LPWSTR ita, LPWSTR jpn, LPWSTR kor, LPWSTR sin, LPWSTR chi, LPWSTR pol, LPWSTR rus)
{
switch(D2GetLang())
{
case LNG_ENG: return eng;
case LNG_ESP: return esp;
case LNG_DEU: return deu;
case LNG_FRA: return fra;
case LNG_POR: return por;
case LNG_ITA: return ita;
case LNG_JPN: return jpn;
case LNG_KOR: return kor;
case LNG_SIN: return sin;
case LNG_CHI: return chi;
case LNG_POL: return pol;
case LNG_RUS: return rus;
case LNG_DEF:
default: return eng;
}
}
#define LANGUAGE(I,ENG,FRA,DEU,ITA,ESP,POL,CHI) case I : return getString(L##ENG,L##ESP,L##DEU,L##FRA,L##ENG,L##ITA,L##ENG,L##ENG,L##ENG,L##ENG,L##POL,L##ENG)
LPWSTR getTranslatedString(int stringID)
{
switch(stringID)
{
/* LANGUAGE2( STR_STATS_UNASSIGN_WITH_LIMIT,
"+Alt: ;,+Shift: %d \x70B9\x6570",//"+Alt: Unassign, +Shift: by %d points",
// "+Alt: \x91CD\x5206\x914D;,+Shift: %d \x70B9\x6570",//"+Alt: Unassign, +Shift: by %d points",
"+Alt: Désallocation, +Shift: par %d points,",
"+Alt: Zurücksetzen, +Shift: um %d Punkte",
"+Alt: Rimuovi, +Shift: Assegna %d punti",
"+Alt: Quita, +Shift: por %d puntos",
"+Alt: \37325\20998\37197;,+Shift:%d \28857\25968");
*/
LANGUAGE( STR_STATS_UNASSIGN_WITH_LIMIT,
"+Alt: Unassign, +Shift: by %d points",
"+Alt: Désallocation, +Shift: par %d points",
"+Alt: Zurücksetzen, +Shift: um %d Punkte",
"+Alt: Rimuovi, +Shift: Assegna %d punti",
"+Alt: Quita, +Shift: por %d puntos",
"+Alt: Odejmij, +Shift: %d punktów");
// "+Alt: 取消加点, +Shift: %d 点数");
LANGUAGE( STR_STATS_UNASSIGN_WITHOUT_LIMIT,
"+Alt: Unassign, +Shift: all remaining points",
"+Alt: Désallocation, +Shift: Tous les points restants",
"+Alt: Zurücksetzen, +Shift: Alle verbleibenden Punkte",
"+Alt: Rimuovi, +Shift: Assegna tutti i punti rimanenti",
"+Alt: Quita, +Shift: Todos los puntos restantes",
"+Alt: Odejmij, +Shift: wszystkie pozostale punkty");
// "+Alt: 取消加点, +Shift: 所有剩");
LANGUAGE( STR_STATS_BASE_MIN,
"Base: %d (Min: %d)",
"Base: %d (Min: %d)",
"Basiswert: %d (Min: %d)",
"Base: %d (Min: %d)",
"Base: %d (Min: %d)",
"Bazowo: %d (Minimum: %d)");
// "基础: %d(最小: %d)");
LANGUAGE( STR_SKILLS_UNASSIGN,
"Un-allocate all skills points",
"Désalloue tous les points d'aptitudes",
"Alle Fertigkeitspunkte zurücksetzen",
"Rimuovi tutte le abilità",
"Quita todos los puntos de habilidades",
"Rozdaj od nowa wszystkie punkty umiejetnosci");
// "取消所有技能加点");
LANGUAGE( STR_STASH_PREVIOUS_PAGE,
"Previous Page (+shift: First Page)",
"Page précédente (+shift: Première page)",
"Vorherige Seite (+shift: Erste Seite)",
"Pagina Precedente (+shift: Prima Pagina)",
"Pagina anterior (+shift: Primera Pagina)",
"Poprzednia Strona (+shift: Pierwsza Strona)");
// "上一页 (+shift: 首页)");
LANGUAGE( STR_STASH_NEXT_PAGE,
"Next Page (+shift: Last not empty Page)",
"Page suivante (+shift: Dernière page non vide)",
"Nächste Seite (+shift: Letzte nicht leere Seite )",
"Pagina Successiva (+shift: Ultima Pagina non vuota)",
"Pagina Siguiente (+shift: Ultima pagina non vacia)",
"Nastepna Strona (+shift: Ostatnia nie pusta Strona)");
// "下一页 (+shift: 最后非空页");
LANGUAGE( STR_TOGGLE_TO_PERSONAL,
"Toggle to Personal Stash",
"Voir coffre personnel",
"Wechselt zum persönlichen Goldschatz",
"Vai all'Inventario Personale",
"Ver el cofre personal",
"Przejdz do Skrzyni Osobistej");
// "切换到个人储物箱");
LANGUAGE( STR_TOGGLE_TO_SHARED,
"Toggle to Shared Stash",
"Voir coffre partagé",
"Wechselt zum gemeinsamen Goldschatz",
"Vai all'Inventario Condiviso",
"Ver el cofre compartido",
"Przejdz do Skrzyni Wspólnej");
// "切换到共享储物箱");
LANGUAGE( STR_STASH_PREVIOUS_INDEX,
"Previous Index : by %d Pages (+Shift: %d)",
"Index précédent : par %d pages (+shift: %d)",
"Vorheriger Index: in %d Seiten (+shift: %d)",
"Schermata Precedente : Indietro di %d Pagine (+Shift: %d)",
"Indice anterior : por %d paginas (+shift: %d)",
"Poprzednia Strona : po %d Stron (+Shift: %d)");
// "向前索引 : %d 页 (+Shift:%d)");
LANGUAGE( STR_STASH_NEXT_INDEX,
"Next Index : by %d Pages (+shift: %d)",
"Index suivant : par %d pages (+shift: %d)",
"Nächster Index: in %d Seiten (+shift: %d)",
"Schermata Successiva : Avanti di %d Pagine (+shift: %d)",
"Indice siguiente : por %d paginas (+shift: %d)",
"Nastepna Strona : po %d Stron (+shift: %d)");
// "向后索引 : %d 页 (+shift:%d)");
LANGUAGE( STR_PUT_GOLD,
"Put Gold",
"Poser de l'Or",
"Gib Gold",
"Immetti Oro",
"Poner oro",
"Zdeponuj Zloto");
// "放入金币");
LANGUAGE( STR_TAKE_GOLD,
"Take Gold",
"Prendre de l'Or",
"Nehme Gold",
"Ritira Oro",
"Tomar oro",
"Wyplac zloto");
// "取出金币");
LANGUAGE( STR_PERSONAL_PAGE_NUMBER,
"Personal Page n°%u",
"Page perso n°%u",
"Persönliche Seite n°%u",
"Pagina Personale n°%u",
"Pagina personal n°%u",
"Strona Osobista n°%u");
// "个人储物箱 n°%u");
LANGUAGE( STR_SHARED_PAGE_NUMBER,
"Shared Page n°%u",
"Page partagée n°%u",
"Gemeinsame Seite n°%u",
"Pagina Condivisa n°%u",
"Pagina personal n°%u",
"Strona Wspólna n°%u");
// "共享储物箱 n°%u");
LANGUAGE( STR_NO_SELECTED_PAGE,
"No selected page",
"Aucune page sélectionnée",
"Keine ausgewählte Seite",
"Nessuna pagina selezionata",
"Ninguna pagina seleccionada",
"Nie zaznaczono strony");
// "未使用页");
LANGUAGE( STR_SHARED_GOLD_QUANTITY,
"Shared Gold : %u",
"Or partagé : %u",
"Gemeinsamen Gold : %u",
"Oro Condiviso : %u",
"Oro compartido : %u",
"Wspólne Zloto : %u");
// "共享金币: %u");
LANGUAGE( STR_PREVIOUS_PAGE,
"Previous Page",
"Page précédente",
"Vorherige Seite",
"Pagina Precedente",
"Pagina anterior",
"Poprzednia Strona");
// "上一页");
LANGUAGE( STR_NEXT_PAGE,
"Next Page",
"Page suivante",
"Nächste Seite",
"Pagina Successiva",
"Pagina siguiente",
"Nastepna Strona");
// "下一页");
default : return L"";
}
}
/*=================================================================*/
const char* SNONE="";
const char* c_shie[3]={"Shield (Not Class Specific)",SNONE,SNONE};
const char* c_tors[3]={"Body Armor",SNONE,SNONE};
const char* c_gold[3]={"Gold",SNONE,SNONE};
const char* c_bowq[3]={"Arrow",SNONE,SNONE};
const char* c_xboq[3]={"Bolt",SNONE,SNONE};
const char* c_play[3]={"Ear",SNONE,SNONE};
const char* c_herb[3]={"Herb",SNONE,SNONE};
const char* c_poti[3]={"Potion",SNONE,SNONE};
const char* c_ring[3]={"Ring",SNONE,SNONE};
const char* c_elix[3]={"Elixir",SNONE,SNONE};
const char* c_amul[3]={"Amulet",SNONE,SNONE};
const char* c_char[3]={"Charm",SNONE,SNONE};
const char* c_boot[3]={"Boot",SNONE,SNONE};
const char* c_glov[3]={"Glove",SNONE,SNONE};
const char* c_book[3]={"Book",SNONE,SNONE};
const char* c_belt[3]={"Belt",SNONE,SNONE};
const char* c_gem[3]={"Gem",SNONE,SNONE};
const char* c_torc[3]={"Torch",SNONE,SNONE};
const char* c_scro[3]={"Scroll",SNONE,SNONE};
const char* c_scep[3]={"Scepter",SNONE,SNONE};
const char* c_wand[3]={"Wand",SNONE,SNONE};
const char* c_staf[3]={"Staff",SNONE,SNONE};
const char* c_bow[3]={"Bow",SNONE,SNONE};
const char* c_axe[3]={"Axe",SNONE,SNONE};
const char* c_club[3]={"Club",SNONE,SNONE};
const char* c_swor[3]={"Sword",SNONE,SNONE};
const char* c_hamm[3]={"Hammer",SNONE,SNONE};
const char* c_knif[3]={"Knife",SNONE,SNONE};
const char* c_spea[3]={"Spear",SNONE,SNONE};
const char* c_pole[3]={"Polearm",SNONE,SNONE};
const char* c_xbow[3]={"Crossbow",SNONE,SNONE};
const char* c_mace[3]={"Mace",SNONE,SNONE};
const char* c_helm[3]={"Helm",SNONE,SNONE};
const char* c_tpot[3]={"Missile Potion",SNONE,SNONE};
const char* c_ques[3]={"Quest Item",SNONE,SNONE};
const char* c_body[3]={"Body Part",SNONE,SNONE};
const char* c_key[3]={"Key",SNONE,SNONE};
const char* c_tkni[3]={"Throwing Knife",SNONE,SNONE};
const char* c_taxe[3]={"Throwing Axe",SNONE,SNONE};
const char* c_jave[3]={"Javelin",SNONE,SNONE};
const char* c_weap[3]={"Weapon",SNONE,SNONE};
const char* c_mele[3]={"Melee Weapon",SNONE,SNONE};
const char* c_miss[3]={"Missile Weapon",SNONE,SNONE};
const char* c_thro[3]={"Throwing Weapon",SNONE,SNONE};
const char* c_comb[3]={"Combo Weapon",SNONE,SNONE};
const char* c_armo[3]={"Armor",SNONE,SNONE};
const char* c_shld[3]={"Any Shield",SNONE,SNONE};
const char* c_misc[3]={"Miscellaneous",SNONE,SNONE};
const char* c_sock[3]={"Socket Filler",SNONE,SNONE};
const char* c_seco[3]={"Second Hand Item",SNONE,SNONE};
const char* c_rod[3]={"Staves And Rods",SNONE,SNONE};
const char* c_misl[3]={"Missile",SNONE,SNONE};
const char* c_blun[3]={"Blunt",SNONE,SNONE};
const char* c_jewl[3]={"Jewel",SNONE,SNONE};
const char* c_clas[3]={"Class Specific",SNONE,SNONE};
const char* c_amaz[3]={"Amazon Item",SNONE,SNONE};
const char* c_barb[3]={"Barbarian Item",SNONE,SNONE};
const char* c_necr[3]={"Necromancer Item",SNONE,SNONE};
const char* c_pala[3]={"Paladin Item",SNONE,SNONE};
const char* c_sorc[3]={"Sorceress Item",SNONE,SNONE};
const char* c_assn[3]={"Assassin Item",SNONE,SNONE};
const char* c_drui[3]={"Druid Item",SNONE,SNONE};
const char* c_h2h[3]={"Claw",SNONE,SNONE};
const char* c_orb[3]={"Orb",SNONE,SNONE};
const char* c_head[3]={"Voodoo Heads",SNONE,SNONE};
const char* c_ashd[3]={"Paladin Shield",SNONE,SNONE};
const char* c_phlm[3]={"Barbarian Helm",SNONE,SNONE};
const char* c_pelt[3]={"Druid Helm",SNONE,SNONE};
const char* c_cloa[3]={"Cloak",SNONE,SNONE};
const char* c_rune[3]={"Rune",SNONE,SNONE};
const char* c_circ[3]={"Circlet",SNONE,SNONE};
const char* c_hpot[3]={"Healing Potion",SNONE,SNONE};
const char* c_mpot[3]={"Mana Potion",SNONE,SNONE};
const char* c_rpot[3]={"Rejuvenation potion",SNONE,SNONE};
const char* c_spot[3]={"Stamina Potion",SNONE,SNONE};
const char* c_apot[3]={"Antidote Potion",SNONE,SNONE};
const char* c_wpot[3]={"Thawing Potion",SNONE,SNONE};
const char* c_scha[3]={"Small Charm",SNONE,SNONE};
const char* c_mcha[3]={"Large Charm",SNONE,SNONE};
const char* c_lcha[3]={"Grand Charm",SNONE,SNONE};
const char* c_abow[3]={"Amazon Bow",SNONE,SNONE};
const char* c_aspe[3]={"Amazon Spear",SNONE,SNONE};
const char* c_ajav[3]={"Amazon Javelin",SNONE,SNONE};
const char* c_h2h2[3]={"Assassin Claw",SNONE,SNONE};
const char* c_mboq[3]={"Magic Arrow",SNONE,SNONE};
const char* c_mxbq[3]={"Magic Bolt",SNONE,SNONE};
const char* c_gem0[3]={"Chipped Gem",SNONE,SNONE};
const char* c_gem1[3]={"Flawed Gem",SNONE,SNONE};
const char* c_gem2[3]={"Normal Gem",SNONE,SNONE};
const char* c_gem3[3]={"Flawless Gem",SNONE,SNONE};
const char* c_gem4[3]={"Perfect Gem",SNONE,SNONE};
const char* c_gema[3]={"Amethyst",SNONE,SNONE};
const char* c_gemd[3]={"Diamond",SNONE,SNONE};
const char* c_geme[3]={"Emerald",SNONE,SNONE};
const char* c_gemr[3]={"Ruby",SNONE,SNONE};
const char* c_gems[3]={"Sapphire",SNONE,SNONE};
const char* c_gemt[3]={"Topaz",SNONE,SNONE};
const char* c_gemz[3]={"Skull",SNONE,SNONE};
const char* getTypeString (DWORD code)
{
DWORD lang = 0;//D2GetLang();
if ((lang == LNG_FRA) || (lang == LNG_DEU)) lang--;
else lang = 0;
switch (code)
{
case BIN('s','h','i','e') : return c_shie[0];
case BIN('t','o','r','s') : return c_tors[0];
case BIN('g','o','l','d') : return c_gold[0];
case BIN('b','o','w','q') : return c_bowq[0];
case BIN('x','b','o','q') : return c_xboq[0];
case BIN('p','l','a','y') : return c_play[0];
case BIN('h','e','r','b') : return c_herb[0];
case BIN('p','o','t','i') : return c_poti[0];
case BIN('r','i','n','g') : return c_ring[0];
case BIN('e','l','i','x') : return c_elix[0];
case BIN('a','m','u','l') : return c_amul[0];
case BIN('c','h','a','r') : return c_char[0];
case BIN('b','o','o','t') : return c_boot[0];
case BIN('g','l','o','v') : return c_glov[0];
case BIN('b','o','o','k') : return c_book[0];
case BIN('b','e','l','t') : return c_belt[0];
case BIN('g','e','m',' ') : return c_gem[0];
case BIN('t','o','r','c') : return c_torc[0];
case BIN('s','c','r','o') : return c_scro[0];
case BIN('s','c','e','p') : return c_scep[0];
case BIN('w','a','n','d') : return c_wand[0];
case BIN('s','t','a','f') : return c_staf[0];
case BIN('b','o','w',' ') : return c_bow[0];
case BIN('a','x','e',' ') : return c_axe[0];
case BIN('c','l','u','b') : return c_club[0];
case BIN('s','w','o','r') : return c_swor[0];
case BIN('h','a','m','m') : return c_hamm[0];
case BIN('k','n','i','f') : return c_knif[0];
case BIN('s','p','e','a') : return c_spea[0];
case BIN('p','o','l','e') : return c_pole[0];
case BIN('x','b','o','w') : return c_xbow[0];
case BIN('m','a','c','e') : return c_mace[0];
case BIN('h','e','l','m') : return c_helm[0];
case BIN('t','p','o','t') : return c_tpot[0];
case BIN('q','u','e','s') : return c_ques[0];
case BIN('b','o','d','y') : return c_body[0];
case BIN('k','e','y',' ') : return c_key[0];
case BIN('t','k','n','i') : return c_tkni[0];
case BIN('t','a','x','e') : return c_taxe[0];
case BIN('j','a','v','e') : return c_jave[0];
case BIN('w','e','a','p') : return c_weap[0];
case BIN('m','e','l','e') : return c_mele[0];
case BIN('m','i','s','s') : return c_miss[0];
case BIN('t','h','r','o') : return c_thro[0];
case BIN('c','o','m','b') : return c_comb[0];
case BIN('a','r','m','o') : return c_armo[0];
case BIN('s','h','l','d') : return c_shld[0];
case BIN('m','i','s','c') : return c_misc[0];
case BIN('s','o','c','k') : return c_sock[0];
case BIN('s','e','c','o') : return c_seco[0];
case BIN('r','o','d',' ') : return c_rod[0];
case BIN('m','i','s','l') : return c_misl[0];
case BIN('b','l','u','n') : return c_blun[0];
case BIN('j','e','w','l') : return c_jewl[0];
case BIN('c','l','a','s') : return c_clas[0];
case BIN('a','m','a','z') : return c_amaz[0];
case BIN('b','a','r','b') : return c_barb[0];
case BIN('n','e','c','r') : return c_necr[0];
case BIN('p','a','l','a') : return c_pala[0];
case BIN('s','o','r','c') : return c_sorc[0];
case BIN('a','s','s','n') : return c_assn[0];
case BIN('d','r','u','i') : return c_drui[0];
case BIN('h','2','h',' ') : return c_h2h[0];
case BIN('h','2','h','2') : return c_h2h2[0];
case BIN('o','r','b',' ') : return c_orb[0];
case BIN('h','e','a','d') : return c_head[0];
case BIN('a','s','h','d') : return c_ashd[0];
case BIN('p','h','l','m') : return c_phlm[0];
case BIN('p','e','l','t') : return c_pelt[0];
case BIN('c','l','o','a') : return c_cloa[0];
case BIN('r','u','n','e') : return c_rune[0];
case BIN('c','i','r','c') : return c_circ[0];
case BIN('h','p','o','t') : return c_hpot[0];
case BIN('m','p','o','t') : return c_mpot[0];
case BIN('r','p','o','t') : return c_rpot[0];
case BIN('s','p','o','t') : return c_spot[0];
case BIN('a','p','o','t') : return c_apot[0];
case BIN('w','p','o','t') : return c_wpot[0];
case BIN('s','c','h','a') : return c_scha[0];
case BIN('m','c','h','a') : return c_mcha[0];
case BIN('l','c','h','a') : return c_lcha[0];
case BIN('a','b','o','w') : return c_abow[0];
case BIN('a','s','p','e') : return c_aspe[0];
case BIN('a','j','a','v') : return c_ajav[0];
case BIN('m','b','o','q') : return c_mboq[0];
case BIN('m','x','b','q') : return c_mxbq[0];
case BIN('g','e','m','0') : return c_gem0[0];
case BIN('g','e','m','1') : return c_gem1[0];
case BIN('g','e','m','2') : return c_gem2[0];
case BIN('g','e','m','3') : return c_gem3[0];
case BIN('g','e','m','4') : return c_gem4[0];
case BIN('g','e','m','a') : return c_gema[0];
case BIN('g','e','m','d') : return c_gemd[0];
case BIN('g','e','m','e') : return c_geme[0];
case BIN('g','e','m','r') : return c_gemr[0];
case BIN('g','e','m','s') : return c_gems[0];
case BIN('g','e','m','t') : return c_gemt[0];
case BIN('g','e','m','z') : return c_gemz[0];
default: return NULL;
}
}
char* getTypeAString (WORD id, char* lpText, DWORD size)
{
ItemTypesBIN* itemTypeData = D2GetItemTypesBIN(id);
if (!itemTypeData)
{
strncpy(lpText, "Bad Type", size);
return lpText;
}
const char* string = getTypeString(itemTypeData->code);
if (!string)
{
struct {
DWORD code;
BYTE zero;
} code;
code.code = itemTypeData->code;
code.zero = 0;
strncpy(lpText, (char*)&code, size);
} else
strncpy(lpText, string, size);
return lpText;
}
LPWSTR getTypeUString (WORD id, LPWSTR lpText, DWORD size)
{
ItemTypesBIN* itemTypeData = D2GetItemTypesBIN(id);
if (!itemTypeData)
{
mbstowcs(lpText, "Bad Type", size);
return lpText;
}
const char* string = getTypeString(itemTypeData->code);
if (!string)
{
struct {
DWORD code;
BYTE zero;
} code;
code.code = itemTypeData->code;
code.zero = 0;
mbstowcs(lpText, (char*)&code, size);
} else
mbstowcs(lpText, string, size);
return lpText;
}
/*================================= END OF FILE =================================*/

89
PlugY/CustomLibraries.cpp Normal file
View File

@ -0,0 +1,89 @@
/*=================================================================
File created by Yohann NICOLAS.
Language management.
=================================================================*/
#include "common.h"
#include "error.h"
#include "customLibraries.h"
TCustomDll* customDlls=NULL;
void TCustomDll::init()
{
if (initFct)
initFct();
};
void TCustomDll::release()
{
if (releaseFct)
releaseFct();
};
void TCustomDll::saveExtendedSaveFile(Unit* ptChar, BYTE** data, DWORD* maxSize, DWORD* curSize)
{
if (saveExtendedSaveFileFct)
saveExtendedSaveFileFct(ptChar, data, maxSize, curSize);
};
int TCustomDll::loadExtendedSaveFile(Unit* ptChar, BYTE* data, DWORD maxSize, DWORD* curSize)
{
if (loadExtendedSaveFileFct)
return loadExtendedSaveFileFct(ptChar, data, maxSize, curSize);
return 0;
};
int TCustomDll::initExtendedSaveFile(BYTE** data, DWORD* maxSize, DWORD* curSize)
{
if (initExtendedSaveFileFct)
return initExtendedSaveFileFct(data, maxSize, curSize);
return 0;
};
void TCustomDll::saveSharedSaveFile(Unit* ptChar, BYTE** data, DWORD* maxSize, DWORD* curSize)
{
if (saveSharedSaveFileFct)
saveSharedSaveFileFct(ptChar, data, maxSize, curSize);
};
int TCustomDll::loadSharedSaveFile(Unit* ptChar, BYTE data[], DWORD maxSize, DWORD* curSize)
{
if (loadSharedSaveFileFct)
return loadSharedSaveFileFct(ptChar, data, maxSize, curSize);
return 0;
};
int TCustomDll::initSharedSaveFile(BYTE** data, DWORD* maxSize, DWORD* curSize)
{
if (initSharedSaveFileFct)
return initSharedSaveFileFct(data, maxSize, curSize);
return 0;
};
void TCustomDll::initialize(DWORD offsetDll)
{
offset = offsetDll;
initFct = GetProcAddress(module,(LPCSTR)"_Init@0");
if (!initFct)
initFct = GetProcAddress(module,(LPCSTR)10000);
releaseFct = GetProcAddress(module,(LPCSTR)"_Release@0");
if (!releaseFct)
releaseFct = GetProcAddress(module,(LPCSTR)10001);
saveExtendedSaveFileFct = (TsaveSaveFile) GetProcAddress(module,"_saveExtendedSaveFile@16");
loadExtendedSaveFileFct = (TloadSaveFile) GetProcAddress(module,"_loadExtendedSaveFile@16");
initExtendedSaveFileFct = (TinitSaveFile) GetProcAddress(module,"_initExtendedSaveFile@12");
saveSharedSaveFileFct = (TsaveSaveFile) GetProcAddress(module,"_saveSharedSaveFile@16");
loadSharedSaveFileFct = (TloadSaveFile) GetProcAddress(module,"_loadSharedSaveFile@16");
initSharedSaveFileFct = (TinitSaveFile) GetProcAddress(module,"_initSharedSaveFile@12");
}
/*================================= END OF FILE =================================*/

962
PlugY/D2functions.cpp Normal file
View File

@ -0,0 +1,962 @@
/*================================================
File created by Yohann NICOLAS.
This file implements some common and useful
function related to some Diablo II mechanisms.
================================================*/
#include "common.h"
#include "d2functions.h"
#include "error.h"
#define D2S(F, I, R, N, P) T##N N;
#define D2F(F, I, R, N, P) T##N N;
#define E2S(F, A, R, N, P) T##N N;
#define E2F(F, A, R, N, P) T##N N;
#define E2C(F, A, T, N) T* pt##N;
#define F7(X, Z, A,B,C,D,E,F,G, R, N, P) T##N N;
#define A7(X, Z, A,B,C,D,E,F,G, R, N, P) T##N N;
#define C7(Z, A,B,C,D,E,F,G, T, N) T* pt##N;
#include "../Commons/D2Funcs.h"
DataTables* SgptDataTables;
//E2F(D2Client,0, DWORD, D2isLODGame, ());//6FAAC080
//E2F(D2Client,0, BYTE, D2GetDifficultyLevel, ());//6FAAC090
//E2S(D2Client,0, DWORD, D2GetMouseX, ());//6FB57BC0
//E2S(D2Client,0, DWORD, D2GetMouseY, ());//6FB57BD0
//E2S(D2Client,0, Unit*, D2GetClientPlayer, ());//6FB283D0
//E2F(D2Client,0, void, D2SendToServer3, (BYTE type, WORD p));//6FAAD990
////E2F(D2Client,0, void, D2SendToServer7, (BYTE type, WORD p1, WORD p2, WORD p3));//6FAAD9E0
////E2F(D2Client,0, void, D2SendToServer5, (BYTE type, DWORD p));//6FAADA20
////E2F(D2Client,0, void, D2SendToServer9, (BYTE type, DWORD p1, DWORD p2));//6FAADA40
////E2F(D2Client,0, void, D2SendToServer13,(BYTE type, DWORD p1, DWORD p2, DWORD p3));//6FAADA70
//E2F(D2Game,0, NetClient*, D2GetClient, (Unit* ptUnit, char* lpszErrFile, DWORD ErrLine));//6FCBC2E0
//E2F(D2Client,0, void, D2CleanStatMouseUp, ());//6FAABF60
#undef F7
#undef A7
#undef C7
#undef D2S
#undef D2F
#undef E2S
#undef E2F
#undef E2C
#define D2S(F, I, R, N, P) typedef R (STDCALL *T##N) P; T##N N;
D2S(D2Common,10581, CharStatsBIN*, D2Common10581, (DWORD charID));//ONLY in 1.09
D2S(D2Common,10598, ItemStatCostBIN*, D2Common10598, (DWORD itemStatCostID));//ONLY in 1.09
D2S(D2Common,10673, ItemTypesBIN*, D2Common10673, (DWORD itemTypesID));//ONLY in 1.09
#undef D2S
//TD2SetPlayerStat V2SetPlayerStat;
TD2AddPlayerStat V2AddPlayerStat;
TD2GetPlayerStat V2GetPlayerStat;
//TD2GetPlayerStat20 V2GetPlayerStat20;
TD2GetPlayerBaseStat V2GetPlayerBaseStat;
TD2SetSkillBaseLevel V2SetSkillBaseLevel;
TD2SetSkillBaseLevelOnClient V2SetSkillBaseLevelOnClient;
TD2PrintStat V2PrintStat;
TD2CompileCubeInput V2CompileCubeInput;
TD2CompileCubeOutput V2CompileCubeOutput;
TD2BroadcastFunction V2BroadcastFunction;
TD2GetGameByClientID V2GetGameByClientID;
TD2SpawnMonster V2SpawnMonster;
TD2VerifIfNotCarry1 V2VerifIfNotCarry1;
TD2GameGetObject V2GameGetObject;
TD2TestPositionInRoom V2TestPositionInRoom;
TD2GetItemTypesBIN V2GetItemTypesBIN;
TD2CompileTxtFile compileTxtFile;
WORD (*getDescStrPos) (DWORD statID);
//void (*setImage) (sDrawImageInfo* data, void* image);
//void (*setFrame) (sDrawImageInfo* data, DWORD frame);
TD2SendMsgToAll V2SendMsgToAll;
TD2SetColorPopup V2SetColorPopup;
TD2LoadImage V2LoadImage;
TD2PlaySound V2PlaySound;
TD2SendToServer V2SendToServer;
TD2GetCharStatsBIN V2GetCharStatsBIN;
TD2GetItemStatCostBIN V2GetItemStatCostBIN;
TD2SendPacket V2SendPacket;
TD2LoadInventory V2LoadInventory;
TD2SaveGame V2SaveGame;
//DWORD* ptNbStatDesc
//DWORD* ptStatDescTable;
//TD2OpenNPCMenu V2OpenNPCMenu;
DWORD getStatDescIDFrom (DWORD statID)//FOR 1.09
{
DWORD* desc = ptStatDescTable;
DWORD curDesc = 0;
while (curDesc < *ptNbStatDesc)
{
if (*desc == statID)
return curDesc;
desc+=4;
curDesc++;
}
return curDesc;
}
//FCT_ASM ( D2SetPlayerStat_9 )//(Unit* ptChar, DWORD statID, DWORD amount, DWORD index)
// PUSH DWORD PTR SS:[ESP+0xC]
// PUSH DWORD PTR SS:[ESP+0xC]
// PUSH DWORD PTR SS:[ESP+0xC]
// CALL V2SetPlayerStat
// RETN 0x10
//}}
FCT_ASM ( D2AddPlayerStat_9 )//(Unit* ptChar, DWORD statID, DWORD amount, DWORD index)
PUSH DWORD PTR SS:[ESP+0xC]
PUSH DWORD PTR SS:[ESP+0xC]
PUSH DWORD PTR SS:[ESP+0xC]
CALL V2AddPlayerStat
RETN 0x10
}}
FCT_ASM ( D2GetPlayerStat_9 )//(Unit* ptChar, DWORD statID, DWORD index)
PUSH DWORD PTR SS:[ESP+0x8]
PUSH DWORD PTR SS:[ESP+0x8]
CALL V2GetPlayerStat
RETN 0x0C
}}
//FCT_ASM ( D2GetPlayerStat20_9 )//(Unit* ptChar, DWORD statID, DWORD index)
// PUSH DWORD PTR SS:[ESP+0x8]
// PUSH DWORD PTR SS:[ESP+0x8]
// CALL V2GetPlayerStat20
// RETN 0x0C
//}}
FCT_ASM ( D2GetPlayerBaseStat_9 )//(Unit* ptChar, DWORD statID, DWORD index)
PUSH DWORD PTR SS:[ESP+0x8]
PUSH DWORD PTR SS:[ESP+0x8]
CALL V2GetPlayerBaseStat
RETN 0x0C
}}
FCT_ASM ( D2SetSkillBaseLevel_9 )//(Unit* ptChar, DWORD skillID, DWORD slvl, DWORD bRemove, char*, DWORD));
PUSH DWORD PTR SS:[ESP+0x10]
PUSH DWORD PTR SS:[ESP+0x10]
PUSH DWORD PTR SS:[ESP+0x10]
PUSH DWORD PTR SS:[ESP+0x10]
CALL V2SetSkillBaseLevel
RETN 0x18
}}
FCT_ASM ( D2SetSkillBaseLevelOnClient_9 )//(void* ptClient, Unit* ptChar, DWORD skillID, DWORD newValue, DWORD zero)
POP EAX
MOV ECX,EDX
POP EDX
PUSH EAX
JMP V2SetSkillBaseLevelOnClient
}}
FCT_ASM ( D2GetCharStatsBIN_9 )
PUSH ECX
CALL D2Common10581
RETN
}}
FCT_ASM ( D2GetItemStatCostBIN_9 )
PUSH ECX
CALL D2Common10598
RETN
}}
FCT_ASM ( D2GetItemTypesBIN_9 )
PUSH ECX
CALL D2Common10673
RETN
}}
DWORD FASTCALL D2PrintStat_9 (Unit* ptItem, Stats* ptStats, DWORD statID, DWORD statIndex, DWORD statValue, LPWSTR lpText)
{
DWORD curDesc = getStatDescIDFrom(statID);
if (curDesc < *ptNbStatDesc)
return V2PrintStat(ptItem, (Stats*)curDesc, statValue, 0, 0, lpText);
return 0;
}
void setImage(sDrawImageInfo* data, void* image){((void**)data)[shifting.ptImage/4]=image;}//0x4 0x8 0x3C
void setFrame(sDrawImageInfo* data, DWORD frame){((DWORD*)data)[shifting.ptFrame/4]=frame;}//0x8 0x44 0x40
//void setImage_111(sDrawImageInfo* data, void* image){data->image=image;}//0x8 0x44
//void setImage_1XX(sDrawImageInfo* data, void* image){((void**)data)[1]=image;}//0x4 0x8
//void setFrame_111(sDrawImageInfo* data, DWORD frame){data->frame=frame;}
//void setFrame_1XX(sDrawImageInfo* data, DWORD frame){((DWORD*)data)[2]=frame;}
WORD getDescStrPos_9 (DWORD statID)
{
DWORD* desc = &ptStatDescTable[getStatDescIDFrom(statID)*4];
return (WORD)*(desc+2);
}
WORD getDescStrPos_10 (DWORD statID)
{
ItemStatCostBIN* itemStatCost = D2GetItemStatCostBIN(statID);
return itemStatCost->descstrpos;
}
const char* S_compileTxtFile = "compileTxtFile";
const char* S_errorReadTxtFile = "pbData";
__declspec(naked) void* STDCALL compileTxtFile_9(DWORD unused, const char* filename, BINField* ptFields, DWORD* ptRecordCount, DWORD recordLength)
{_asm{
SUB ESP,0x210
// MOV EAX,DWORD PTR DS:[1BEA28C]
PUSH EBX
PUSH EBP
PUSH ESI
PUSH EDI
MOV ESI,DWORD PTR SS:[ESP+0x228]
MOV DWORD PTR SS:[ESP+0x10],0
MOV EDI,wsprintf
PUSH ESI
LEA EAX,DWORD PTR SS:[ESP+0x20]
PUSH EAX
CALL EDI
ADD ESP,8
LEA EDX,DWORD PTR SS:[ESP+0x10]
PUSH 0
PUSH S_compileTxtFile
PUSH EDX
MOV ECX,DWORD PTR SS:[ESP+0x230]
LEA EDX,DWORD PTR SS:[ESP+0x28]
CALL D2ReadFile
TEST EAX,EAX
JNZ continue_compileTxtFile
PUSH 0
PUSH S_compileTxtFile
PUSH S_errorReadTxtFile
CALL D2FogAssertOld
PUSH -1
CALL exit
continue_compileTxtFile:
MOV ECX,D2CompileTxtFile
ADD ECX,0x305
JMP ECX
}}
__declspec(naked) void* STDCALL compileTxtFile_10(DWORD unused, const char* filename, BINField* ptFields, DWORD* ptRecordCount, DWORD recordLength)
{_asm{
SUB ESP,0x210
// MOV EAX,DWORD PTR DS:[1BEA28C]
PUSH EBX
PUSH EBP
MOV EBP,DWORD PTR SS:[ESP+0x220]
PUSH ESI
PUSH EDI
MOV DWORD PTR SS:[ESP+0x10],0
MOV EBX,wsprintf
PUSH EBP
LEA EAX,DWORD PTR SS:[ESP+0x20]
PUSH EAX
CALL EBX
ADD ESP,8
LEA EDX,DWORD PTR SS:[ESP+0x10]
PUSH 0
PUSH S_compileTxtFile
PUSH EDX
MOV ECX,DWORD PTR SS:[ESP+0x230]
LEA EDX,DWORD PTR SS:[ESP+0x28]
CALL D2ReadFile
TEST EAX,EAX
JNZ continue_compileTxtFile
PUSH 0
PUSH S_compileTxtFile
PUSH S_errorReadTxtFile
CALL D2FogAssertOld
PUSH -1
CALL exit
continue_compileTxtFile:
MOV ECX,D2CompileTxtFile
ADD ECX,0x2ED
JMP ECX
}}
__declspec(naked) void* STDCALL compileTxtFile_111(DWORD unused, const char* filename, BINField* ptFields, DWORD* ptRecordCount, DWORD recordLength)
{_asm{
SUB ESP,0x20C
// MOV EAX,DWORD PTR DS:[6FDF1464]
PUSH EBX
PUSH EBP
PUSH ESI
PUSH EDI
MOV DWORD PTR SS:[ESP+0x10],0
MOV EBX,DWORD PTR SS:[ESP+0x224]
PUSH EBX
LEA EAX,DWORD PTR SS:[ESP+0x1C]
PUSH EAX
CALL DWORD PTR SS:[wsprintf]
MOV EDX,DWORD PTR SS:[ESP+0x228]
ADD ESP,8
LEA EDX,DWORD PTR SS:[ESP+0x10]
PUSH EDX
PUSH EAX
LEA EAX,DWORD PTR SS:[ESP+0x20]
CALL D2ReadFile
TEST EAX,EAX
JNZ continue_compileTxtFile
PUSH __LINE__
CALL D2GetInstructionPointer
PUSH EAX
PUSH S_errorReadTxtFile
CALL D2FogAssert
ADD ESP,0xC
PUSH -1
CALL exit
continue_compileTxtFile:
MOV ECX,D2CompileTxtFile
ADD ECX,0x1EC
JMP ECX
}}
DWORD FASTCALL D2isLODGame_111(){return IsLodGame;}
BYTE FASTCALL D2GetDifficultyLevel_111(){return DifficultyLevel;}
DWORD STDCALL D2GetMouseX_111(){return MouseX;}
DWORD STDCALL D2GetMouseY_111(){return MouseY;}
Unit* STDCALL D2GetClientPlayer_111(){return ptClientChar;}
DWORD *StatMouse1, *StatMouse2, *StatMouse3, *StatMouse4;
void FASTCALL D2CleanStatMouseUp_111(){*StatMouse1=*StatMouse2=*StatMouse3=*StatMouse4=0;}
Unit* STDCALL D2GetRealItem_111(Unit* ptItem){return ptItem;}
/* 1.11 : sizememory : 0x104 (LoadBuySell)
6FADA7F0 |. A1 48BDBC6F MOV EAX,DWORD PTR DS:[6FBCBD48]
6FADA7F5 |. 3BC3 CMP EAX,EBX
6FADA7F7 |. 75 27 JNZ SHORT D2Client.6FADA820
6FADA7F9 |. 68 C407B86F PUSH D2Client.6FB807C4 ; /<%s> = "DATA\GLOBAL"
6FADA7FE |. 8D4424 6C LEA EAX,DWORD PTR SS:[ESP+6C] ; |
6FADA802 |. 68 483BB86F PUSH D2Client.6FB83B48 ; |Format = "%s\ui\panel\buysellbtn"
6FADA807 |. 50 PUSH EAX ; |s
6FADA808 |. FF15 FCF0B76F CALL DWORD PTR DS:[<&USER32.wsprintfA>] ; \wsprintfA
6FADA80E |. 83C4 0C ADD ESP,0C
6FADA811 |. 53 PUSH EBX ; /Arg1
6FADA812 |. 8D4424 6C LEA EAX,DWORD PTR SS:[ESP+6C] ; |
6FADA816 |. E8 E5B40400 CALL D2Client.6FB25D00 ; \D2Client.6FB25D00
6FADA81B |. A3 48BDBC6F MOV DWORD PTR DS:[6FBCBD48],EAX
*/
FCT_ASM ( D2SendMsgToAll_111 )
PUSH ESI
MOV ESI,ECX
CALL V2SendMsgToAll
POP ESI
RETN
}}
FCT_ASM ( D2SetColorPopup_111 )
PUSH EDI
PUSH EDX
MOV EDI,ECX
CALL V2SetColorPopup
POP EDI
RETN
}}
FCT_ASM ( D2LoadImage_111 )
PUSH EDX
MOV EAX,ECX
CALL V2LoadImage
RETN
}}
const char* D2FreeImage_FILE = __FILE__;
FCT_ASM ( D2FreeImage_111 )
PUSH ESI
MOV ESI,ECX
PUSH ESI
CALL D2CMP10014
TEST ESI,ESI
JE END_D2Free
PUSH 0
PUSH __LINE__
MOV EDX,D2FreeImage_FILE ; ASCII "C:\projects\D2\head\Diablo2\Source\D2Client\CORE\ARCHIVE.CPP"
MOV ECX,ESI
CALL D2FogMemDeAlloc
END_D2Free:
POP ESI
RETN
}}
FCT_ASM ( D2PlaySound_111 )
PUSH EBX
PUSH DWORD PTR SS:[ESP+0x10]
PUSH DWORD PTR SS:[ESP+0x10]
PUSH DWORD PTR SS:[ESP+0x10]
PUSH EDX
MOV EBX,ECX
CALL V2PlaySound
POP EBX
RETN 0xC
}}
FCT_ASM ( D2GetClient_111 )
PUSH ECX
CALL D2GetPlayerData
MOV EAX,DWORD PTR DS:[EAX+0x9C]
RETN 4
}}
FCT_ASM ( D2SetSkillBaseLevelOnClient_111 )
PUSH EBX
PUSH ESI
PUSH DWORD PTR SS:[ESP+0x14]
PUSH DWORD PTR SS:[ESP+0x14]
MOV EBX, DWORD PTR SS:[ESP+0x14]
MOV EAX,ECX
MOV ESI,EDX
CALL V2SetSkillBaseLevelOnClient
POP ESI
POP EBX
RETN 0xC
}}
FCT_ASM ( D2GetCharStatsBIN_111 )
MOV EAX,ECX
JMP V2GetCharStatsBIN
}}
FCT_ASM ( D2GetItemStatCostBIN_111 )
MOV EAX,ECX
JMP V2GetItemStatCostBIN
}}
FCT_ASM ( D2SendToServer3_111 )
PUSH EBX
PUSH ECX
MOV BYTE PTR SS:[ESP],CL
MOV WORD PTR SS:[ESP+1],DX
MOV EBX,3
LEA EDX,DWORD PTR SS:[ESP]
PUSH EDX
CALL D2SendToServerXX
POP ECX
POP EBX
RETN
}}
FCT_ASM ( D2PrintStat_111 )
PUSH ESI
MOV ESI,DWORD PTR SS:[ESP+0x14]
MOV EAX,DWORD PTR SS:[ESP+0x08]
PUSH DWORD PTR SS:[ESP+0x10]
PUSH DWORD PTR SS:[ESP+0x10]
PUSH EDX
PUSH ECX
CALL V2PrintStat
POP ESI
RETN 0x10
}}
FCT_ASM ( D2SendPacket_111 )
POP EAX
PUSH EDX
PUSH EAX
MOV EAX,ECX
JMP V2SendPacket
}}
FCT_ASM ( D2LoadInventory_111 )
MOV EAX,DWORD PTR SS:[ESP+4]
MOV DWORD PTR SS:[ESP+4],EDX
JMP V2LoadInventory
}}
FCT_ASM ( D2CompileCubeInput_111 )
PUSH EBX
MOV EBX,ECX
MOV EAX,EDX
CALL V2CompileCubeInput
POP EBX
RETN 8
}}
FCT_ASM ( D2CompileCubeOutput_111 )
PUSH EBX
MOV EBX,ECX
PUSH EDX
CALL V2CompileCubeOutput
POP EBX
RETN 8
}}
FCT_ASM ( D2BroadcastFunction_111 )
PUSH EDI
PUSH EBX
MOV EAX,ECX
MOV EDI,EDX
MOV EBX,DWORD PTR SS:[ESP+0xC]
CALL V2BroadcastFunction
POP EBX
POP EDI
RETN 4
}}
FCT_ASM ( D2SpawnMonster_111 )
PUSH DWORD PTR SS:[ESP+0x18]
PUSH DWORD PTR SS:[ESP+0x14]
PUSH DWORD PTR SS:[ESP+0x14]
PUSH DWORD PTR SS:[ESP+0x14]
PUSH ECX
MOV ECX,DWORD PTR SS:[ESP+0x18]
MOV EAX,DWORD PTR SS:[ESP+0x28]
CALL V2SpawnMonster
RETN 0x18
}}
FCT_ASM ( D2SpawnMonster_111b )
PUSH DWORD PTR SS:[ESP+0x10]
PUSH DWORD PTR SS:[ESP+0x10]
PUSH DWORD PTR SS:[ESP+0x10]
PUSH EDX
PUSH ECX
MOV EAX,DWORD PTR SS:[ESP+0x18]
MOV EDX,DWORD PTR SS:[ESP+0x2C]
MOV ECX,DWORD PTR SS:[ESP+0x28]//superuniqueID
CALL V2SpawnMonster
RETN 0x18
}}
FCT_ASM ( D2VerifIfNotCarry1_111 )
PUSH EBX
PUSH ECX
MOV EBX,EDX
MOV EAX,DWORD PTR SS:[ESP+0xC]
CALL V2VerifIfNotCarry1
POP EBX
RETN 4
}}
FCT_ASM ( D2GameGetObject_111 )
MOV EAX,EDX
MOV EDX,DWORD PTR SS:[ESP+4]
CALL V2GameGetObject
RETN 4
}}
FCT_ASM ( D2TestPositionInRoom_111 )
PUSH EDI
PUSH EBX
MOV EDI,DWORD PTR SS:[ESP+0xC]
MOV EAX,ECX
MOV EBX,EDX
CALL V2TestPositionInRoom
POP EBX
POP EDI
RETN 4
}}
FCT_ASM ( D2GetItemTypesBIN_111)
MOV EAX,ECX
JMP V2GetItemTypesBIN
}}
//FCT_ASM ( D2OpenNPCMenu_111)
// MOV ESI,ECX
// JMP V2OpenNPCMenu
//}}
FCT_ASM ( D2SendToServer_1XX )
PUSH DWORD PTR SS:[ESP+0x4]
PUSH DWORD PTR SS:[ESP+0x10]
PUSH 0
CALL V2SendToServer
RETN 0xC
}}
FCT_ASM ( D2GetGameByClientID_1XX )
POP EAX
POP ECX
PUSH EAX
JMP V2GetGameByClientID
}}
FCT_ASM ( D2SaveGame_1XX )
POP EAX
POP ECX
PUSH EAX
JMP V2SaveGame
}}
#define SETFCTADDR(F, I, N) setFctAddr((DWORD*)&N, (HMODULE)offset_##F, (LPCSTR)I)
void setFctAddr(DWORD* addr, HMODULE module, LPCSTR index)
{
if (index)
{
*addr = (DWORD)GetProcAddress(module,index);
if (!*addr)
{
log_msg("Bad index fct %d for %08X\n",index,module);
}
} else
*addr = NULL;
}
bool initD2functions()
{
// #define D2S(F, I, R, N, P) N = (F##I)GetProcAddress((HMODULE)offset_##F, (LPCSTR)I);
// #define D2F(F, I, R, N, P) N = (F##I)GetProcAddress((HMODULE)offset_##F, (LPCSTR)I);
#define D2S(F, I, R, N, P) SETFCTADDR(F, I, N);
#define D2F(F, I, R, N, P) SETFCTADDR(F, I, N);
#define E2S(F, A, R, N, P) N = (T##N)(offset_##F + 0x##A);
#define E2F(F, A, R, N, P) N = (T##N)(offset_##F + 0x##A);
#define E2C(F, A, T, N) pt##N = (T*)(offset_##F + 0x##A);
#define F7(X, Z, A,B,C,D,E,F,G, R, N, P) setFctAddr((DWORD*)&N, (HMODULE)offset_##Z, (LPCSTR)((version_##Z == V113? G : (version_##Z == V112? F : version_##Z == V111b? E : (version_##Z == V111? D : (version_##Z == V110? C : (version_##Z == V109d? B : A)))))));
#define A7(X, Z, A,B,C,D,E,F,G, R, N, P) N = (T##N)R7(Z,A,B,C,D,E,F,G);
#define C7(Z, A,B,C,D,E,F,G, T, N) pt##N = (T*)R7(Z,A,B,C,D,E,F,G);
#include "../Commons/D2Funcs.h"
SgptDataTables = *(DataTables**) R7(D2Common, 0000, 0000, 96A20, 9B74C, 9EE8C, 9B500, 99E1C);
if (version_D2Common < V110)
{
D2S(D2Common,10581, CharStatsBIN*, D2Common10581, (DWORD charID));//ONLY in 1.09
D2S(D2Common,10598, ItemStatCostBIN*, D2Common10598, (DWORD itemStatCostID));//ONLY in 1.09
D2S(D2Common,10673, ItemTypesBIN*, D2Common10673, (DWORD itemTypesID));//ONLY in 1.09
}
#undef F7
#undef A7
#undef C7
#undef D2S
#undef D2F
#undef E2S
#undef E2F
#undef E2C
//////////////// MISC FCT ////////////////
//setImage = version_D2Common >= V111 ? setImage_111 : setImage_1XX;
//setFrame = version_D2Common >= V111 ? setFrame_111 : setFrame_1XX;
getDescStrPos = version_D2Common >= V110 ? getDescStrPos_10 : getDescStrPos_9;
compileTxtFile = version_D2Common >= V111 ? compileTxtFile_111 : version_D2Common == V110 ? compileTxtFile_10 : compileTxtFile_9;
//////////////// SELECT RIGHT ADDR FUNCTION ////////////////
//#define V3(V,T,F,A,B,C,D)\
// if (version_##F == V109b) V = (T) (offset_##F + 0x##A);\
// else if (version_##F == V109d) V = (T) (offset_##F + 0x##B);\
// else if (version_##F == V110) V = (T) (offset_##F + 0x##C);\
// else if (version_##F == V111) V = (T) (offset_##F + 0x##D)
//if (version_D2Common != V111b)
//{
//SETFCTADDR( D2Common, 10332, D2GetLevelID);
//SETFCTADDR( D2Common, 10623, D2GetDropRoom);
//SETFCTADDR( D2Common, 10461, D2InvRemoveItem);
//SETFCTADDR( D2Common, 10855, D2CanPutItemInInv);
//SETFCTADDR( D2Common, 10880, D2InvAddItem);
//SETFCTADDR( D2Common, 10402, D2InventoryGetFirstItem);
//SETFCTADDR( D2Common, 10934, D2UnitGetNextItem);
//SETFCTADDR( D2Common, 11095, D2GetRealItem);
//SETFCTADDR( D2Common, 11080, D2GetPosition);
//SETFCTADDR( D2Common, 10455, D2GetMaxGoldBank);
//SETFCTADDR( D2Common, 10172, D2GetRoom);
//SETFCTADDR( D2Common, 10218, D2InitPlayerData);
//SETFCTADDR( D2Common, 10914, D2FreePlayerData);
//SETFCTADDR( D2Common, 10562, D2GetPlayerData);
//SETFCTADDR( D2Common, 10343, D2GetMaxGold);
//SETFCTADDR( D2Common, 10500, D2GetGemsBIN);
//SETFCTADDR( D2Common, 10109, D2AddPlayerStat);
//SETFCTADDR( D2Common, 11092, D2GetPlayerStat);
//SETFCTADDR( D2Common, 10733, D2GetPlayerBaseStat);
//SETFCTADDR( D2Common, 10653, D2CompileTxtFile);
//SETFCTADDR( D2Common, 10573, D2GetItemsBIN);
//SETFCTADDR( D2Common, 10687, D2GetNbRunesBIN);
//SETFCTADDR( D2Common, 10775, D2GetRunesBIN);
//SETFCTADDR( D2Common, 10450, D2GetSuperUniqueBIN);
//SETFCTADDR( D2Common, 10927, D2GetItemQuality);
//SETFCTADDR( D2Common, 10911, D2TestFlags);
//SETFCTADDR( D2Common, 10898, D2GetItemLevel);
//SETFCTADDR( D2Common, 10820, D2ItemGetPage);
//SETFCTADDR( D2Common, 10485, D2ItemSetPage);
//SETFCTADDR( D2Common, 11017, D2CheckItemType);
//SETFCTADDR( D2Common, 10692, D2GetUniqueID);
//SETFCTADDR( D2Common, 10816, D2GetNbSocket);
//SETFCTADDR( D2Common, 10880, D2isEtheral);
//SETFCTADDR( D2Common, 10956, D2SaveItem);
//SETFCTADDR( D2Common, 10950, D2IncSkillBaseLevel);
//SETFCTADDR( D2Common, 10700, D2GetSkillLevel);
//SETFCTADDR( D2Common, 10027, D2Common10027);
//SETFCTADDR( D2Common, 10099, D2SetSkillBaseLevel);
//SETFCTADDR( D2Common, 10746, D2GetCubeMainBIN);
//SETFCTADDR( D2Common, 10639, D2GetNbCubeMainBIN);
//SETFCTADDR( D2Common, 10254, D2GetSkillCost);
//SETFCTADDR( D2Common, 10471, D2GetObjectFlags);
//SETFCTADDR( D2Common, 10572, D2SetObjectFlags);
//SETFCTADDR( D2Common, 10188, D2Common11084);
//SETFCTADDR( D2Common, 10440, D2Common10572);
//SETFCTADDR( D2Common, 10655, D2GetDifficultyLevelsBIN);
//SETFCTADDR( D2Game, 10039, D2SetNbPlayers);
//SETFCTADDR( D2Win, 10061, D2PrintLineOnTextBox);
//SETFCTADDR( D2Win, 10020, D2PrintString);
//SETFCTADDR( D2Win, 10034, D2GetPixelLen);
//SETFCTADDR( D2Win, 10141, D2SetFont);
//SETFCTADDR( D2Win, 10118, D2PrintPopup);
//SETFCTADDR( D2Win, 10147, D2CreateTextBox);
//SETFCTADDR( D2Lang, 10009, D2GetLang);
//SETFCTADDR( D2Lang, 10005, D2GetStringFromIndex);
//SETFCTADDR( D2gfx, 10000, D2GetResolution);
//SETFCTADDR( D2gfx, 10047, D2PrintImage);
//SETFCTADDR( D2gfx, 10028, D2FillArea);
//SETFCTADDR( D2Net, 10035, D2SendToServer);
////SETFCTADDR( D2Net, 10018, D2SendToClient);//SAME IN BOTH VERSION
//SETFCTADDR( D2CMP, 10021, D2CMP10014);
//if (version_D2Common != V111)
//{
//setImage = setImage_1XX;
//setFrame = setFrame_1XX;
//SETFCTADDR( D2Common, 10057, D2GetLevelID);
//SETFCTADDR( D2Common, 10138, D2GetDropRoom);
//SETFCTADDR( D2Common, 10243, D2InvRemoveItem);
//SETFCTADDR( D2Common, 10246, D2CanPutItemInInv);
//SETFCTADDR( D2Common, 10249, D2InvAddItem);
//SETFCTADDR( D2Common, 10277, D2InventoryGetFirstItem);
//SETFCTADDR( D2Common, 10304, D2UnitGetNextItem);
//SETFCTADDR( D2Common, 10305, D2GetRealItem);
//SETFCTADDR( D2Common, 10332, D2GetPosition);
//SETFCTADDR( D2Common, 10339, D2GetMaxGoldBank);
//SETFCTADDR( D2Common, 10342, D2GetRoom);
//SETFCTADDR( D2Common, 10420, D2InitPlayerData);
//SETFCTADDR( D2Common, 10421, D2FreePlayerData);
//SETFCTADDR( D2Common, 10424, D2GetPlayerData);
//SETFCTADDR( D2Common, 10439, D2GetMaxGold);
//SETFCTADDR( D2Common, 10616, D2GetGemsBIN);
//SETFCTADDR( D2Common, 10518, D2AddPlayerStat);
//SETFCTADDR( D2Common, 10519, D2GetPlayerStat);
//SETFCTADDR( D2Common, 10521, D2GetPlayerBaseStat);
//SETFCTADDR( D2Common, 10578, D2CompileTxtFile);
//SETFCTADDR( D2Common, 10600, D2GetItemsBIN);
//SETFCTADDR( D2Common, 10619, D2GetNbRunesBIN);
//SETFCTADDR( D2Common, 10620, D2GetRunesBIN);
//SETFCTADDR( D2Common, 10668, D2GetSuperUniqueBIN);
//SETFCTADDR( D2Common, 10695, D2GetItemQuality);
//SETFCTADDR( D2Common, 10707, D2TestFlags);
//SETFCTADDR( D2Common, 10717, D2GetItemLevel);
//SETFCTADDR( D2Common, 10719, D2ItemGetPage);
//SETFCTADDR( D2Common, 10720, D2ItemSetPage);
//SETFCTADDR( D2Common, 10731, D2CheckItemType);
//SETFCTADDR( D2Common, 10732, D2GetUniqueID);
//SETFCTADDR( D2Common, 10816, D2GetNbSocket);
//SETFCTADDR( D2Common, 11163, D2isEtheral);
//SETFCTADDR( D2Common, 10881, D2SaveItem);
//SETFCTADDR( D2Common, 10952, D2IncSkillBaseLevel);
//SETFCTADDR( D2Common, 10968, D2GetSkillLevel);
//SETFCTADDR( D2Common, 10940, D2Common10027);
//SETFCTADDR( D2Common, 10953, D2SetSkillBaseLevel);
//SETFCTADDR( D2Common, 11232, D2GetCubeMainBIN);
//SETFCTADDR( D2Common, 11233, D2GetNbCubeMainBIN);
//SETFCTADDR( D2Common, 11276, D2GetSkillCost);
//SETFCTADDR( D2Common, 10655, D2GetDifficultyLevelsBIN);
//SETFCTADDR( D2Game, 10059, D2SetNbPlayers);
//SETFCTADDR( D2Win, 10046, D2PrintLineOnTextBox);
//SETFCTADDR( D2Win, 10117, D2PrintString);
//SETFCTADDR( D2Win, 10121, D2GetPixelLen);
//SETFCTADDR( D2Win, 10127, D2SetFont);
//SETFCTADDR( D2Win, 10129, D2PrintPopup);
//SETFCTADDR( D2Win, 10017, D2CreateTextBox);
//SETFCTADDR( D2Lang, 10007, D2GetLang);
//SETFCTADDR( D2Lang, 10004, D2GetStringFromIndex);
//SETFCTADDR( D2gfx, 10005, D2GetResolution);
//SETFCTADDR( D2gfx, 10072, D2PrintImage);
//SETFCTADDR( D2gfx, 10055, D2FillArea);
//SETFCTADDR( D2Net, 10005, D2SendToServer); //(DWORD zero, void* data, DWORD size)
//SETFCTADDR( D2Net, 10006, D2SendToClient);
//SETFCTADDR( Fog, 10023, D2FogAssertOld);
//SETFCTADDR( D2CMP, 10032, D2CMP10014);
//}
//}
//V3(ptResolutionY, DWORD*, D2Client, D50E8, D40E0, D40F0, F5C60);
//V3(ptResolutionX, DWORD*, D2Client, D50EC, D40E4, D40F4, F5C5C);
//V3(ptNegWindowStartY, DWORD*, D2Client, 125AD8, 124958, 11A74C, 11BD28);
//V3(ptWindowStartX, DWORD*, D2Client, 125AD4, 124954, 11A748, 11BD24);
//V3(ptGameTypeMode, DWORD*, D2Launch, 55818, 56088, 2CD5C, 0000);
//V3(ptClientTable, NetClient**, D2Game, F2A80, F2918, 113FB8, 111718);
//V3(ptIsLodGame, DWORD*, D2Client, 0000, 0000, 0000, FB3F4);
//V3(ptDifficultyLevel, BYTE*, D2Client, 0000, 0000, 10795C, 11BFB8);
//V3(ptMouseY, DWORD*, D2Client, 0000, 0000, 0000, 10A40C);
//V3(ptMouseX, DWORD*, D2Client, 0000, 0000, 0000, 10A410);
//V3(ptptClientChar, Unit**, D2Client, 0000, 0000, 0000, 11C4F0);
//V3(ptNbStatDesc, DWORD*, D2Client, DB918, DA828, 0000, 0000);
//V3(ptStatDescTable, DWORD*, D2Client, DAF98, D9EA8, 0000, 0000);
//V3(D2LoadImage, TD2LoadImage, D2Client, 1000, 1000, 1000, 75D00);
//V3(D2FreeImage, TD2FreeImage, D2Client, 1150, 1150, 1140, 0000);
//V3(D2CleanStatMouseUp, TD2CleanStatMouseUp, D2Client, B920, B910, BF60, 0000);
//V3(D2isLODGame, TD2isLODGame, D2Client, BA00, B9F0, C080, 0000);
//V3(D2GetDifficultyLevel,TD2GetDifficultyLevel, D2Client, 000, 000, C090, 0000);//1.09 should be BA10 (b) BA00 (d)
//V3(D2SendToServer3, TD2SendToServer3, D2Client, D210, D200, D990, 0000);
//V3(D2SendToServer7, TD2SendToServer7, D2Client, 000, 000, D9E0, 0000);
//V3(D2SendToServer5, TD2SendToServer5, D2Client, 000, 000, DA20, 0000);
//V3(D2SendToServer9, TD2SendToServer9, D2Client, 000, 000, DA40, 0000);
//V3(D2SendToServer13, TD2SendToServer13, D2Client, 000, 000, DA70, 0000);
//V3(D2SendMsgToAll, TD2SendMsgToAll, D2Client, D640, D630, DB50, 73620);
//V3(D2PrintStatsPage, TD2PrintStatsPage, D2Client, 29800, 297F0, 2FD60, 828A0);
//V3(D2SetColorPopup, TD2SetColorPopup, D2Client, 85A60, 84DE0, 80430, 9EEB0);
//V3(D2SendToServerXX, TD2SendToServerXX, D2Client, 000, 000, 000, 73260);
//V3(D2TogglePage, TD2TogglePage, D2Client, 88940, 87CC0, 83260, A1F30);
//V3(D2LoadBuySelBtn, TD2LoadBuySelBtn, D2Client, 897B0, 88B30, 84110, 9E3B0);
//V3(D2GetClientPlayer, TD2GetClientPlayer, D2Client, 8DC40, 8CFC0, 883D0, 0000);
//V3(D2PlaySound, TD2PlaySound, D2Client, B4360, B36E0, B5820, 3ACC0);
//V3(D2GetMouseX, TD2GetMouseX, D2Client, B6670, B59F0, B7BC0, 0000);
//V3(D2GetMouseY, TD2GetMouseY, D2Client, B6680, B5A00, B7BD0, 0000);
// //V3(D2FillRect, TD2FillRect, D2Client, B9970, B8CF0, BB0F0, 0000);
//V3(D2PrintStat, TD2PrintStat, D2Client, 4BB20, 4BB20, 521C0, B8CB0);
//V3(D2AddClient, TD2AddClient, D2Game, 000, 000, 6C60, E3DA0);
//V3(D2SendPacket, TD2SendPacket, D2Game, C380, C650, C710, 41420);
//V3(D2GetGameByClientID, TD2GetGameByClientID, D2Game, 000, 000, 94E0, E0520);
//V3(D2BroadcastFunction, TD2BroadcastFunction, D2Game, 000, 000, B0E0, DF250);
//V3(D2SetSkillBaseLevelOnClient, TD2SetSkillBaseLevelOnClient,D2Game, D650, D920, DB50, 44D00);
//V3(D2VerifIfNotCarry1, TD2VerifIfNotCarry1, D2Game, 000, 000, 128F0, 38D90);
//V3(D2TestPositionInRoom,TD2TestPositionInRoom, D2Game, 000, 000, 22070, 01090);
//V3(D2LoadInventory, TD2LoadInventory, D2Game, 4F100, 4F500, 5B8A0, B9D70);
//V3(D2GameGetObject, TD2GameGetObject, D2Game, 7BAE0, 7BFD0, 8BB00, 97620);
//V3(D2GetClient, TD2GetClient, D2Game, 7C2C0, 7C7B0, 8C2E0, 000);
//V3(D2GetOwnerMonster, TD2GetOwnerMonster, D2Game, 000, 000, 9F320, 501C0);
//V3(D2ReadFile, TD2ReadFile, D2Common, 738A4, 739B4, 84268, 96E0);//1.11
//V3(D2CompileCubeInput, TD2CompileCubeInput, D2Common, 000, 000, 12410, 5D7D0);
//V3(D2CompileCubeOutput, TD2CompileCubeOutput, D2Common, 000, 000, 12910, 5D210);
//V3(D2GetCharStatsBIN, TD2GetCharStatsBIN, D2Common, 000, 000, 82C80, 015D0);
//V3(D2LoadSuperuniques, TD2LoadSuperuniques, D2Common, 1F500, 1F510, 29FA0, 71EB0);
//V3(D2GetItemStatCostBIN,TD2GetItemStatCostBIN, D2Common, 000, 000, 642B0, 13F0);
//V3(D2GetItemTypesBIN, TD2GetItemTypesBIN, D2Common, 000, 000, 2B1A0, 11F0);
//V3(D2SpawnMonster, TD2SpawnMonster, D2Game, 000, 000, 3F220, 4ABE0);
//V3(D2ReloadGambleScreen,TD2ReloadGambleScreen, D2Game, 000, 000, 000, 8E480);
//V3(D2SaveGame, TD2SaveGame, D2Game, 000, 000, 89C0, E2390);
//V3(D2ClickOnStashButton,TD2ClickOnStashButton, D2Client, 000, 000, 000, A6520);
//V3(D2CreateUnit, TD2CreateUnit, D2Game, 000, 000, 000, 99760);
//V3(D2LinkPortal, TD2LinkPortal, D2Game, 000, 000, 000, 27230);
//V3(D2Game235C0, TD2Game235C0, D2Game, 000, 000, 000, D6D10);
//V3(D2OpenPandPortal, TD2OpenPandPortal, D2Game, 000, 000, 000, 9B480);
//V3(D2OpenPandFinalPortal,TD2OpenPandFinalPortal,D2Game, 000, 000, 000, 9B470);
//V3(D2MephIA, TD2MephIA, D2Game, 000, 000, 000, 84730);
//V3(D2DiabloIA, TD2DiabloIA, D2Game, 000, 000, 000, 75980);
//V3(D2BaalIA, TD2BaalIA, D2Game, 000, 000, 000, EAB20);
//V3(D2UberMephIA, TD2UberMephIA, D2Game, 000, 000, 000, 70320);
//V3(D2UberDiabloIA, TD2UberDiabloIA, D2Game, 000, 000, 000, 7F200);
//V3(D2UberBaalIA, TD2UberBaalIA, D2Game, 000, 000, 000, E92B0);
//#undef V3
//V2SetPlayerStat = D2SetPlayerStat;
V2AddPlayerStat = D2AddPlayerStat;
V2GetPlayerStat = D2GetPlayerStat;
//V2GetPlayerStat20 = D2GetPlayerStat20;
V2GetPlayerBaseStat = D2GetPlayerBaseStat;
V2SetSkillBaseLevel = D2SetSkillBaseLevel;
V2SetSkillBaseLevelOnClient = D2SetSkillBaseLevelOnClient;
V2PrintStat = D2PrintStat;
V2SendMsgToAll = D2SendMsgToAll;
V2SetColorPopup = D2SetColorPopup;
V2LoadImage = D2LoadImage;
V2PlaySound = D2PlaySound;
V2GetCharStatsBIN = D2GetCharStatsBIN;
V2GetItemStatCostBIN = D2GetItemStatCostBIN;
V2SendToServer = D2SendToServer;
V2SendPacket = D2SendPacket;
V2LoadInventory = D2LoadInventory;
V2CompileCubeInput = D2CompileCubeInput;
V2CompileCubeOutput = D2CompileCubeOutput;
V2BroadcastFunction = D2BroadcastFunction;
V2GetGameByClientID = D2GetGameByClientID;
V2SpawnMonster = D2SpawnMonster;
V2VerifIfNotCarry1 = D2VerifIfNotCarry1;
V2GameGetObject = D2GameGetObject;
V2TestPositionInRoom = D2TestPositionInRoom;
V2GetItemTypesBIN = D2GetItemTypesBIN;
V2SaveGame = D2SaveGame;
//V2OpenNPCMenu = D2OpenNPCMenu;
//////////////// REDIRECT ON CUSTOM FUNCTIONS ////////////////
if ( version_D2Client >= V111 )
{
D2SendMsgToAll = (TD2SendMsgToAll) D2SendMsgToAll_111;
D2SetColorPopup = (TD2SetColorPopup) D2SetColorPopup_111;
D2LoadImage = (TD2LoadImage) D2LoadImage_111;
D2FreeImage = (TD2FreeImage) D2FreeImage_111;
D2PlaySound = (TD2PlaySound) D2PlaySound_111;
D2GetClient = (TD2GetClient) D2GetClient_111;
D2SendToServer3 = (TD2SendToServer3) D2SendToServer3_111;
D2SetSkillBaseLevelOnClient = (TD2SetSkillBaseLevelOnClient) D2SetSkillBaseLevelOnClient_111;
D2GetCharStatsBIN = (TD2GetCharStatsBIN) D2GetCharStatsBIN_111;
D2GetItemStatCostBIN = (TD2GetItemStatCostBIN) D2GetItemStatCostBIN_111;
D2PrintStat = (TD2PrintStat) D2PrintStat_111;
D2SendPacket = (TD2SendPacket) D2SendPacket_111;
D2LoadInventory = (TD2LoadInventory) D2LoadInventory_111;
D2CompileCubeInput = (TD2CompileCubeInput) D2CompileCubeInput_111;
D2CompileCubeOutput = (TD2CompileCubeOutput) D2CompileCubeOutput_111;
D2BroadcastFunction = (TD2BroadcastFunction) D2BroadcastFunction_111;
D2SpawnMonster = version_D2Game >= V111b ? (TD2SpawnMonster)D2SpawnMonster_111b : (TD2SpawnMonster)D2SpawnMonster_111;
D2VerifIfNotCarry1 = (TD2VerifIfNotCarry1) D2VerifIfNotCarry1_111;
D2GameGetObject = (TD2GameGetObject) D2GameGetObject_111;
D2GetItemTypesBIN = (TD2GetItemTypesBIN) D2GetItemTypesBIN_111;
D2TestPositionInRoom = (TD2TestPositionInRoom) D2TestPositionInRoom_111;
//D2OpenNPCMenu = (TD2OpenNPCMenu) D2OpenNPCMenu_111;
D2isLODGame = D2isLODGame_111;
D2GetDifficultyLevel = D2GetDifficultyLevel_111;
D2GetMouseX = D2GetMouseX_111;
D2GetMouseY = D2GetMouseY_111;
D2GetClientPlayer = D2GetClientPlayer_111;
D2GetRealItem = D2GetRealItem_111;
D2CleanStatMouseUp = D2CleanStatMouseUp_111;
StatMouse1 = (DWORD*)R7(D2Client, 0000, 0000, 0000, 11C004, 11C2F4, 11C040, 11C3DC);
StatMouse2 = (DWORD*)R7(D2Client, 0000, 0000, 0000, 11C008, 11C2F8, 11C044, 11C3E0);
StatMouse3 = (DWORD*)R7(D2Client, 0000, 0000, 0000, 11C020, 11C310, 11C05C, 11C3F8);
StatMouse4 = (DWORD*)R7(D2Client, 0000, 0000, 0000, 11C024, 11C314, 11C060, 11C3FC);
} else {
D2SendToServer = (TD2SendToServer) D2SendToServer_1XX;
D2GetGameByClientID = (TD2GetGameByClientID) D2GetGameByClientID_1XX;
D2SaveGame = (TD2SaveGame) D2SaveGame_1XX;
}
if ( version_D2Common <= V109d )
{
//D2SetPlayerStat = (TD2SetPlayerStat) D2SetPlayerStat_9;
D2AddPlayerStat = (TD2AddPlayerStat) D2AddPlayerStat_9;
D2GetPlayerStat = (TD2GetPlayerStat) D2GetPlayerStat_9;
//D2GetPlayerStat20 = (TD2GetPlayerStat20) D2GetPlayerStat20_9;
D2GetPlayerBaseStat = (TD2GetPlayerBaseStat) D2GetPlayerBaseStat_9;
D2SetSkillBaseLevel = (TD2SetSkillBaseLevel) D2SetSkillBaseLevel_9;
D2GetCharStatsBIN = (TD2GetCharStatsBIN) D2GetCharStatsBIN_9;
D2GetItemStatCostBIN = (TD2GetItemStatCostBIN) D2GetItemStatCostBIN_9;
D2GetItemTypesBIN = (TD2GetItemTypesBIN) D2GetItemTypesBIN_9;
}
if ( version_D2Client <= V109d )
D2PrintStat = (TD2PrintStat) D2PrintStat_9;
if ( version_D2Game <= V109d )
D2SetSkillBaseLevelOnClient = (TD2SetSkillBaseLevelOnClient) D2SetSkillBaseLevelOnClient_9;
//////////////// STRUCTURE MANAGEMENT ////////////////
// shifting.ptPYPlayerData = V7(D2Common,118,118,F4,F4,F4,F4,F4);
shifting.ptPYPlayerData = *(DWORD*)((DWORD)D2InitPlayerData + V7(D2Common,5D,5D,5D,49,49,49,49));
shifting.ptSpecificData = V7(D2Common,70,70,14,14,14,14,14);
shifting.ptGame = V7(D2Common,A4,A4,80,80,80,80,80);
shifting.ptClientGame = V7(D2Common,170,194,1A8,1A8,1A8,1A8,1A8);
shifting.ptInventory = V7(D2Common,84,84,60,60,60,60,60);
shifting.ptSkills = V7(D2Common,CC,CC,A8,A8,A8,A8,A8);
shifting.ptImage = V7(D2Common,04,04,04,08,08,3C,34);
shifting.ptFrame = V7(D2Common,08,08,08,44,44,40,00);
return true;
}
/*================================= END OF FILE =================================*/

562
PlugY/D2wrapper.cpp Normal file
View File

@ -0,0 +1,562 @@
/*=================================================================
File created by Yohann NICOLAS.
@file D2wrapper.cpp
@brief Main Diablo II extra DLL handler.
This is the sources of the D2DLL class.
=================================================================*/
// Core Class Headers
#include "common.h"
#include "error.h"
#include "d2functions.h"
#include "customLibraries.h"
/* Beginning of Custom Header */
#include "globalVariable.h" // Install_VariableOnRealm()
#include "commands.h" // Install_Commands()
#include "othersFeatures.h" // Install_ChangeResolution()
#include "mainScreen.h" // Install_PrintPlugYVersion() Install_VersionChange()
#include "savePath.h" // Install_ChangingSavePath()
#include "bigStash.h" // Install_BigStash()
#include "skillPerLevelUp.h" // Install_SkillPerLevelUp()
#include "statPerLevelUp.h" // Install_StatPerLevelUp()
#include "statsPoints.h" // Install_StatsPoints() Install_StatsLimitShiftClick()
#include "skillsPoints.h" // Install_SkillsPoints()
#include "infinityStash.h" // Install_MultiPageStash()
#include "newInterfaces.h" // Install_NewInterfaces()
#include "worldEvent.h" // Install_WorldEvent()
#include "uberQuest.h" // Install_UberQuest()
#include "extraOptions.h" // Install_AlwaysRegenMapInSP()
#include "language.h" // Install_LanguageManagement()
int version_SmackW32=V113;
int version_D2Common=V113;
int version_ijl11=V113;
int version_D2Gdi=V113;
int version_D2Win=V113;
int version_D2sound=V113;
int version_D2MCPCLI=V113;
int version_D2Launch=V113;
int version_D2gfx=V113;
int version_D2Client=V113;
int version_D2Net=V113;
int version_D2Lang=V113;
int version_D2Game=V113;
int version_D2CMP=V113;
int version_Bnclient=V113;
int version_Fog=V113;
int version_Storm=V113;
DWORD offset_SmackW32=NULL;
DWORD offset_D2Common=NULL;
DWORD offset_ijl11=NULL;
DWORD offset_D2Gdi=NULL;
DWORD offset_D2Win=NULL;
DWORD offset_D2sound=NULL;
DWORD offset_D2Multi=NULL;
DWORD offset_D2MCPCLI=NULL;
DWORD offset_D2Launch=NULL;
DWORD offset_D2gfx=NULL;
DWORD offset_D2Game=NULL;
DWORD offset_D2Client=NULL;
DWORD offset_D2Net=NULL;
DWORD offset_D2Lang=NULL;
DWORD offset_D2CMP=NULL;
DWORD offset_Bnclient=NULL;
DWORD offset_Fog=NULL;
DWORD offset_Storm=NULL;
// manque : Game.exe D2DDraw.dll D2Direct3D.dll D2Glide.dll
const char* S_SmackW32 = "SmackW32.dll";
const char* S_D2Common = "D2Common.dll";
const char* S_ijl11 = "ijl11.dll";
const char* S_D2Gdi = "D2Gdi.dll";
const char* S_D2Win = "D2Win.dll";
const char* S_D2sound = "D2sound.dll";
const char* S_D2Multi = "D2Multi.dll";
const char* S_D2MCPCLI = "D2MCPClient.dll";
const char* S_D2Launch = "D2Launch.dll";
const char* S_D2gfx = "D2gfx.dll";
const char* S_D2Game = "D2Game.dll";
const char* S_D2Client = "D2Client.dll";
const char* S_D2Net = "D2Net.dll";
const char* S_D2Lang = "D2Lang.dll";
const char* S_D2CMP = "D2CMP.dll";
const char* S_Bnclient = "Bnclient.dll";
const char* S_Fog = "Fog.dll";
const char* S_Storm = "Storm.dll";
const char* S_CloneBattles ="CloneBattles.dll";
const char* S_DarkAlliance ="DarkAlliance.dll";
DWORD loadLibrary( const char* libraryName)
{
DWORD offset;
/* char currentpath[MAX_PATH];
if (!strcmp(libraryName,"D2Common.dll") || !strcmp(libraryName,"D2Game.dll") || !strcmp(libraryName,"D2Client.dll"))
{
GetCurrentDirectory(MAX_PATH,currentpath);
strncat(currentpath,"\\",MAX_PATH);
strncat(currentpath,libraryName,MAX_PATH);
log_msg("Load = %s : ",currentpath);
offset = (DWORD)LoadLibrary(currentpath);
log_msg("offset = %08X\n",offset);
if (offset)
{
log_msg("%s loaded successfully at: %08X\n", libraryName, offset);
return offset;
}
}*/
offset = (DWORD)LoadLibrary(libraryName);
if (!offset)
{
log_msg("Failed to load library : %s\n", libraryName);
exit(-1);
}
log_msg("%s loaded successfully at: %08X\n", libraryName, offset);
return offset;
}
void freeLibrary( DWORD library )
{
if (library)
FreeLibrary((HINSTANCE__ *)library);
}
// Change the protection scheme of a loaded
// DLL called libraryName in memory space at address addr+size to allow us to customize it.
void hookLibrary(const char* libraryName, DWORD addr)
{
DWORD dw=0;
BYTE* offsetPESignature = addr + *(BYTE**)((BYTE*)addr + 0x3C);
DWORD sizeOfCode = *(DWORD*)(offsetPESignature + 0x1C);
BYTE* baseOfCode = addr + *(BYTE**)(offsetPESignature + 0x2C);
if( !VirtualProtect(baseOfCode, sizeOfCode, PAGE_EXECUTE_READWRITE, &dw) )
{
log_msg("Failed to hook library : %s. (%08X,%08X)\n", libraryName ,baseOfCode, sizeOfCode);
exit(-1);
}
log_msg("%s successfully hooked. (%08X,%08X)\n", libraryName ,baseOfCode, sizeOfCode);
}
void unhookLibrary(const char* libraryName, DWORD addr)
{
DWORD dw=0;
BYTE* offsetPESignature = addr + *(BYTE**)((BYTE*)addr + 0x3C);
DWORD sizeOfCode = *(DWORD*)(offsetPESignature + 0x1C);
BYTE* baseOfCode = addr + *(BYTE**)(offsetPESignature + 0x2C);
if( !VirtualProtect(baseOfCode, sizeOfCode, PAGE_EXECUTE_READ, &dw) )
log_msg("Failed to unhook library : %s. (%08X,%08X)\n", libraryName ,baseOfCode, sizeOfCode);
else
log_msg("%s successfully unhooked. (%08X,%08X)\n", libraryName ,baseOfCode, sizeOfCode);
}
void loadD2Libraries ()
{
log_msg("***** Load D2 Libraries *****\n");
offset_SmackW32 = loadLibrary( S_SmackW32); //0xD000 0x03B90000 Already Loaded -
offset_D2Common = loadLibrary( S_D2Common); //0x8D000 0x037A0000 0x7C000
offset_ijl11 = loadLibrary( S_ijl11); //0x24000 0x60000000 Already Loaded -
offset_D2Gdi = loadLibrary( S_D2Gdi); //0x7000 0x6F830000 Already Loaded -
offset_D2Win = loadLibrary( S_D2Win); //0x19000 0x6F8A0000 Already Loaded 0x1C000
offset_D2sound = loadLibrary( S_D2sound); //0xC000 0x6F980000 Already Loaded 0xD000
// offset_D2Multi = loadLibrary( S_D2Multi); //0x1000 0x6F9A0000 ?
// offset_D2MCPCLI = loadLibrary( S_D2MCPCLI); //0x6000 0x6F9F0000 Already Loaded -
offset_D2Launch = loadLibrary( S_D2Launch); //0x20000 0x6FA10000 Already Loaded 0x1E000
offset_D2gfx = loadLibrary( S_D2gfx); //0xB000 0x6FA70000 Already Loaded -
offset_D2Game = loadLibrary( S_D2Game); //0xF6000 0x6FC30000 0xCF000
offset_D2Client = loadLibrary( S_D2Client); //0xCC000 0x6FAA0000 0xCA000
offset_D2Net = loadLibrary( S_D2Net); //0x6000 0x6FC00000 Already Loaded -
offset_D2Lang = loadLibrary( S_D2Lang); //0x0A000 0x6FC10000 Already Loaded -
offset_D2CMP = loadLibrary( S_D2CMP); //0x18000 0x6FDF0000 Already Loaded 0x19000
offset_Bnclient = loadLibrary( S_Bnclient); //0x15000 0x6FF00000 Already Loaded -
offset_Fog = loadLibrary( S_Fog); //0x20000 0x6FF50000 Already Loaded 0x1F000
offset_Storm = loadLibrary( S_Storm); //0x30000 0x6FFB0000 Already Loaded -
log_msg("\n\n");
}
void freeD2Libraries()
{
log_msg("***** Free Libraries *****\n");
freeLibrary( offset_SmackW32 );
freeLibrary( offset_D2Common );
freeLibrary( offset_ijl11 );
freeLibrary( offset_D2Gdi );
freeLibrary( offset_D2Win );
freeLibrary( offset_D2sound );
// freeLibrary( offset_D2Multi );
// freeLibrary( offset_D2MCPCLI );
freeLibrary( offset_D2Launch );
freeLibrary( offset_D2gfx );
freeLibrary( offset_D2Game );
freeLibrary( offset_D2Client );
freeLibrary( offset_D2Net );
freeLibrary( offset_D2Lang );
freeLibrary( offset_D2CMP );
freeLibrary( offset_Bnclient );
freeLibrary( offset_Fog );
freeLibrary( offset_Storm );
log_msg("\n\n");
}
void hookLibraries()
{
log_msg("***** Unprotect Libraries *****\n");
hookLibrary(S_D2Common, offset_D2Common);
hookLibrary(S_D2Client, offset_D2Client);
hookLibrary(S_D2Lang, offset_D2Lang);
hookLibrary(S_D2Game, offset_D2Game);
hookLibrary(S_Fog, offset_Fog);
hookLibrary(S_Storm, offset_Storm);
// hookLibrary(S_D2Win, offset_D2Win);
hookLibrary(S_D2Launch, offset_D2Launch);
hookLibrary(S_D2gfx, offset_D2gfx);
// hookLibrary(S_D2Gdi, offset_D2Gdi);
log_msg("\n\n");
}
void unhookLibraries()
{
log_msg("***** Reprotect Libraries *****\n");
unhookLibrary(S_D2Common, offset_D2Common);
unhookLibrary(S_D2Client, offset_D2Client);
unhookLibrary(S_D2Lang, offset_D2Lang);
unhookLibrary(S_D2Game, offset_D2Game);
unhookLibrary(S_Fog, offset_Fog);
unhookLibrary(S_Storm, offset_Storm);
// unhookLibrary(S_D2Win, offset_D2Win);
unhookLibrary(S_D2Launch, offset_D2Launch);
unhookLibrary(S_D2gfx, offset_D2gfx);
// unhookLibrary(S_D2Gdi, offset_D2Gdi);
log_msg("\n\n");
}
void freeCustomLibraries()
{
log_msg("***** Free custom libraries *****\n");
TCustomDll* dll=customDlls;
TCustomDll* nextDll;
while (dll)
{
dll->release();
freeLibrary(dll->offset);
nextDll = dll->nextDll;
D2FogMemDeAlloc(dll,__FILE__,__LINE__,0);
dll = nextDll;
}
}
void initCustomLibraries()
{
log_msg("***** Init custom libraries *****\n");
TCustomDll* dll=customDlls;
while (dll)
{
dll->init();
dll = dll->nextDll;
}
}
void loadCustomLibraries()
{
char* curString = NULL;
TCustomDll* nextDll;
DWORD offset_currentDll;
log_msg("***** Custom libraries *****\n");
if (dllFilenames)
curString = strtok(dllFilenames,"|");
if (!curString)
log_msg("No custom libraries to load.\n");
else
{
log_msg("Load custom libraries :\n");
while (curString)
{
if (curString[0])
{
offset_currentDll = loadLibrary(curString);
if (offset_currentDll)
{
nextDll = customDlls;
customDlls = new(TCustomDll);
customDlls->nextDll = nextDll;
customDlls->initialize(offset_currentDll);
}
}
curString=strtok(NULL,"|");
}
}
if(dllFilenames)
D2FogMemDeAlloc(dllFilenames,__FILE__,__LINE__,0);
log_msg("\n\n");
}
/*
void getVersion(DWORD addr, DWORD addr111, int* ver, DWORD v109b, DWORD v109d, DWORD v110, DWORD v111, DWORD v111a, DWORD v111b, DWORD v112, DWORD v113, const char * filename)
{
log_msg("version of %s\t",filename);
if (addr==v109b) {
*ver = V109b;
log_msg("1.09b\n");
} else if (addr==v109d) {
*ver = V109d;
log_msg("1.09d\n");
} else if (addr==v110) {
*ver = V110;
log_msg("1.10\n");
} else if ((addr==v111) && (addr111==v111a)) {
*ver = V111;
log_msg("1.11\n");
} else if ((addr==v111) && (addr111==v111b)) {
*ver = V111b;
log_msg("1.11b\n");
} else if (addr==v112) {
*ver = V112;
log_msg("1.12\n");
} else if (addr==v113) {
*ver = V113;
log_msg("1.13\n");
} else {
*ver = V113;
log_msg("unknow, try with 1.13\n");
}
}
#define GET_VERSION(F,X,Y,A,B,C,D,E,G,H,I) getVersion(*(DWORD*)(offset_##F + 0x##X), *(DWORD*)(offset_##F + 0x##Y), &version_##F, 0x##A, 0x##B, 0x##C, 0x##D, 0x##E, 0x##G, 0x##H, 0x##I, S_##F)
bool initD2version()
{
log_msg("***** Get dll versions *****\n");
//GET_VERSION(SmackW32
GET_VERSION(D2Common, 80, 108, B03A26A0, 9E3DE7CC, 0355C185, 8402CA7A, 42E6C2E5, 43028BA5, E58C71DA, 00000000);
//GET_VERSION(ijl11
GET_VERSION(D2Gdi, 80, 108, 90CFD95A, 86CE337B, A8CCC67B, 06059D7D, 42E6C248, 43028B2F, 5D6490A2, 00000000);
GET_VERSION(D2Win, 80, 108, B595A0CD, 1995DAD2, A8F5E2FD, B6DAB75A, 42E6C266, 43028B44, 6AA01FF5, 00000000);
//GET_VERSION(D2sound
//GET_VERSION(D2MCPCLI
GET_VERSION(D2Launch, 80, 100, A66532FF, 66678CC5, 686223E5, 80B0E2C6, 42E6C275, 43028B50, 205A4C0F, 00000000);
GET_VERSION(D2gfx, 80, 110, 00949FA8, 018866A8, 401526B2, 575C8A5E, 42E6C22A, 43028B19, ACBE1B9E, 00000000);
GET_VERSION(D2Client, 80, 108, 03522F39, 6730B639, C9817825, 37EC6E13, 42E6C43F, 43028CA5, 61A3B3D5, 00000000);
GET_VERSION(D2Net, 80, 0F0, E60F4DEA, 940E178B, 890FCC0B, C293A9D5, 42E6C20D, 43028B05, 19FA9F76, 00000000);
GET_VERSION(D2Lang, 80, 0F8, 111DCCB7, 13978953, DF917353, B91BAEA2, 42E6C213, 43028B09, B7B3978E, 00000000);
GET_VERSION(D2Game, 80, 108, B0805792, 8BB2C392, 92FA18E6, 00B6F7B7, 42E6C375, 43028C0D, BD8DD8E5, 00000000);
GET_VERSION(D2CMP, 80, 0F8, BA755486, 9A77DFEE, 38F44382, 4059B13F, 42E6C203, 43028AFE, 33A9427B, 00000000);
//GET_VERSION(Bnclient
GET_VERSION(Fog, 80, 100, 6F16123B, 75990846, 7E7ED3C7, D333B997, 42E6C1F0, 43028AF2, D3BD4F1B, 00000000);
GET_VERSION(Storm, E0, 110, 3B4B41D8, 3B8AB1CE, 00004550, 9C2BECC4, 42E6C1CA, 43028AD9, E4FA2944, 00000000);
log_msg("\n\n");
return true;
}
*/
void getVersion(DWORD addr, int* ver, DWORD v109b, DWORD v109d, DWORD v110, DWORD v111, DWORD v111b, DWORD v112, DWORD v113, const char * filename)
{
log_msg("version of %s\t",filename);
if (addr==v109b) {
*ver = V109b;
log_msg("1.09b\n");
} else if (addr==v109d) {
*ver = V109d;
log_msg("1.09d\n");
} else if (addr==v110) {
*ver = V110;
log_msg("1.10\n");
} else if (addr==v111) {
*ver = V111;
log_msg("1.11\n");
} else if (addr==v111b) {
*ver = V111b;
log_msg("1.11b\n");
} else if (addr==v112) {
*ver = V112;
log_msg("1.12\n");
} else if (addr==v113) {
*ver = V113;
log_msg("1.13\n");
} else {
*ver = V113;
log_msg("unknow, try with 1.13\n");
}
}
#define GET_VERSION(F,X,A,B,C,D,E,G,H) getVersion(*(DWORD*)(offset_##F + 0x##X), &version_##F, 0x##A, 0x##B, 0x##C, 0x##D, 0x##E, 0x##G, 0x##H, S_##F)
bool initD2version()
{
log_msg("***** Get dll versions *****\n");
//GET_VERSION(SmackW32
GET_VERSION(D2Common, 10CA, A1E86FDC, B1E86FDC, 72D03B42, F883057E, 16746AC6, 00FE81C3, 74FE85DB);
//GET_VERSION(ijl11
GET_VERSION(D2Gdi, 105, B4000000, 0B210E00, E4000000, 48000401, 2F000401, 00000000, B7000401);
GET_VERSION(D2Win, 1699, 88686F8C, 84686F8C, D094686F, F0030000, 001435E8, 8B088F44, 0013F5E8);
//GET_VERSION(D2sound
//GET_VERSION(D2MCPCLI
GET_VERSION(D2Launch, 109A, 81E8526F, 01E8526F, 85E8526F, 247C8B00, 00FC6583, 15FF0424, E850E045);
GET_VERSION(D2gfx, 10D, EB000000, 006FA700, 00000010, 2A000401, 19000401, 0B210E00, 00000000);
GET_VERSION(D2Client, 17F, 00000000, 14500000, 12500000, 0D814800, 0D812800, 0DA01000, 0DA03000);
GET_VERSION(D2Net, 16E1, 78B8A73C, 68B8A73C, 10244C8B, 5349E808, 5EA9E808, 105D8B72, 53B9E808);
GET_VERSION(D2Lang, 126D, FC45048B, F445048B, 02C18313, C4830000, 00C6E045, 8B48408B, 0C75FF0C);
// GET_VERSION(D2Game, 1010, D22A78A1, D22910A1, D43FB0A1, 03E8506F, 53E8506F, 89E8506F, 63E8506F);
GET_VERSION(D2Game, 1092, 18968BF1, 38968BF1, 28968BF1, F6335608, C690C5B9, 895FD713, 56535700);
GET_VERSION(D2CMP, 1359, 3C686FE0, 38686FE0, 8BF78B56, 4C880424, 07C71824, CCCCCCCC, C7000005);
//GET_VERSION(Bnclient
GET_VERSION(Fog, 102, D0000006, 10000001, 00000006, 000042E6, 00004302, 0000483C, 00004B95);
GET_VERSION(Storm, 1190, 19E85082, 59E85082, 13C103F6, 0474F685, 8B000321, 3B1074C9, 0D896404);
log_msg("\n\n");
return true;
}
//////////////////////////////////// EXPORTS FUNCTIONS ////////////////////////////////////
extern "C" __declspec(dllexport) void* __stdcall Init(LPSTR IniName)
{
if (IniName) log_msg("* PlugY is called from D2mod.dll\n\n");
else log_msg("* PlugY is called from D2gfx.dll\n\n");
static int isInstalled = false;
if (isInstalled) return NULL;
isInstalled=true;
loadD2Libraries();
if (!initD2version()) return NULL;
if (!initD2functions()) return NULL;
loadParameters();
if (!active_plugin) return NULL;
loadCustomLibraries();
hookLibraries();
log_msg("***** INSTALL FUNCTIONS *****\n");
Install_VariableOnRealm();
if (active_Commands)
Install_Commands();
if (active_ChangeLanguage || active_LanguageManagement)
Install_LanguageManagement();
if (active_VersionTextChange)
Install_VersionChange();
if (active_PrintPlugYVersion)
Install_PrintPlugYVersion();
if (active_StatsPoints)
Install_StatsPoints();
else if (active_DisplayBaseStatsValue)
Install_DisplayBaseStatsValue();
if (active_SkillsPoints)
Install_SkillsPoints();
if (active_changingSavePath)
Install_ChangingSavePath();
if (active_StatsShiftClickLimit)
Install_StatsLimitShiftClick();
if (active_RunLODs)
Install_RunLODs();
if (active_bigStash)
Install_BigStash();
if (active_SkillPerLevelUpChange)
Install_SkillPerLevelUp();
if (active_StatPerLevelUpChange)
Install_StatPerLevelUp();
if (active_multiPageStash)
Install_MultiPageStash();
if (active_othersFeatures)
Install_OthersFeatures();
if (active_newInterfaces)
Install_NewInterfaces();
if (active_WorldEvent)
Install_WorldEvent();
if (active_UberQuest)
Install_UberQuest();
if (active_alwaysRegenMapInSP)
Install_AlwaysRegenMapInSP();
if (nbPlayersCommandByDefault)
Install_SendPlayersCommand();
if (active_DisplayItemLevel)
Install_DisplayItemLevel();
if (active_AlwaysDisplayLifeMana)
Install_AlwaysDisplayLifeMana();
if (active_EnabledTXTFilesWithMSExcel)
Install_EnabledTXTFilesWithMSExcel();
if (active_LadderRunewords)
Install_LadderRunewords();
if (active_EnabledCowPortalWhenCowKingWasKill)
Install_EnabledCowPortalWhenCowKingWasKill();
log_msg("\nDLL patched sucessfully.\n\n\n");
unhookLibraries();
initCustomLibraries();
log_msg("***** ENTERING DIABLO II *****\n\n" );
active_logFile = active_logFile - 1;
return NULL;
}
extern "C" __declspec(dllexport) bool __stdcall Release()
{
log_msg("\n***** ENDING DIABLO II *****\n\n" );
freeCustomLibraries();
freeD2Libraries();
return true;
}
/*================================= END OF FILE =================================*/

103
PlugY/Error.cpp Normal file
View File

@ -0,0 +1,103 @@
/*=================================================================
File created by Yohann NICOLAS.
Error Logger implementation.
=================================================================*/
#include <stdio.h> // fopen() fclose() fprintf() vfprintf()
#include <stdarg.h> // ...
#include <string.h> // strlen() strcat()
#include <direct.h> // _getcwd()
#include "error.h"
#include "d2functions.h" // Fog_assert()
DWORD active_logFile = 1;
static char log_file[MAX_PATH] = "";
static bool log_init = false;
void log_initfile()
{
if (log_init) return;
_getcwd( log_file, MAX_PATH );
if( log_file[strlen(log_file)] != '\\')
strcat(log_file, "\\");
strcat(log_file, LOG_FILE);
FILE* lLog = fopen( log_file, "w" );
if( lLog != NULL )
{
fclose(lLog);
log_init = true;
}
log_msg("<----------------------------------------------->\n"
"\n"
"\t\tA Plugin by Yohann\n"
"\t\tversion %s\n"
"\n"
"\n"
"<---------- Starting Diablo II Plugin ---------->\n\n\n"
,PLUGY_VERSION);
}
void log_box( const char* pFormat, ... )
{
char buffer[300];
va_list lArgs;
va_start( lArgs, pFormat );
vsprintf( buffer, pFormat, lArgs );
va_end(lArgs);
log_msg(buffer);
MessageBox(NULL, buffer, "PlugY, The Survival Kit", MB_OK|MB_ICONEXCLAMATION);
}
void log_msg( const char* pFormat, ... )
{
if (!active_logFile) return;
if( !log_init )
log_initfile();
if( log_init )
{
va_list lArgs;
va_start( lArgs, pFormat );
FILE *lDebug = fopen( log_file, "a" );
if( lDebug != NULL )
{
vfprintf( lDebug, pFormat, lArgs );
fclose( lDebug );
}
else
log_init = false;
va_end(lArgs);
}
}
void d2_assert( bool pCondition, char* pMessage, char* pLocation, int pLineNbr )
{
if( pCondition )
{
log_msg("\n"
"*-----------------------*\n"
"Assertion fail at line %d of %s :\n"
"%s\n"
"*-----------------------*\n",
pLineNbr, pLocation, pMessage);
MessageBox(NULL, pMessage, "Diablo 2 Error", MB_OK|MB_ICONEXCLAMATION);
exit(1);
}
}
/*================================= END OF FILE =================================*/

166
PlugY/ExtendedSaveFile.cpp Normal file
View File

@ -0,0 +1,166 @@
/*=================================================================
File created by Yohann NICOLAS.
Add an extra save file for each characters.
=================================================================*/
#include "common.h"
#include "extendedSaveFile.h"
#include "error.h"
#include "d2functions.h"
#include "infinityStash.h"
#include "customLibraries.h"
#define BUFFER_SIZE 0x4000
#define FILE_VERSION 0x3130 //"01"
#define FILE_EXTENDED 0x4D545343 //"CSTM"
BYTE * readExtendedSaveFile(char* name, DWORD* size)//WORKS
{
char filename[512];
BYTE* data;
d2_assert(!name, "Bad file name (NULL)", __FILE__, __LINE__);
D2FogGetSavePath( filename, 512-5);
strncat(filename, name, 512 - strlen(filename) - 5);
strcat(filename, ".d2x");
log_msg("Extended file to read : %s\n",filename);
FILE* file = fopen(filename, "rb");
if (file)
{
fseek(file, 0, SEEK_END);
*size = ftell(file);
fseek(file, 0, SEEK_SET);
data = (BYTE*)D2FogMemAlloc(*size,__FILE__,__LINE__,0);
DWORD nbRead = fread(data, 1, *size, file);
fclose(file);
d2_assert(nbRead != *size , "nbRead from extented save file != size", __FILE__, __LINE__);
} else {
log_msg("Can't open extented save file in mode \"rb\" (is not an error if it's a new player)\n");
DWORD maxSize = 100;
data = (BYTE*)D2FogMemAlloc(maxSize,__FILE__,__LINE__,0);
*size = 14;
*((DWORD*)&data[0]) = FILE_EXTENDED; //"CSTM"
*((WORD *)&data[4]) = FILE_VERSION;
*((DWORD*)&data[6]) = 0;// not used
*((DWORD*)&data[10]) = 0;// number of stash
TCustomDll* currentDll = customDlls;
while (currentDll)
{
currentDll->initExtendedSaveFile(&data, &maxSize, size);
currentDll=currentDll->nextDll;
}
}
return data;
}
int loadExtendedSaveFile(Unit* ptChar, BYTE data[], DWORD maxSize)//WORKS
{
if (!ptChar || !PCPY || !data) return 0;
log_msg("Load extended file\n");
DWORD curSize = 0;
if (*(DWORD*)&data[curSize] != FILE_EXTENDED)
{
log_msg("loadExtendedSaveFile -> bad header\n");
return 9;
}
curSize += 4;
if (*(WORD *)&data[curSize] != FILE_VERSION)
{
log_msg("loadExtendedSaveFile -> bad file version\n");
return 9;
}
curSize += 2;
curSize += 4;
int ret = loadStashList(ptChar, data, maxSize, &curSize, false);
TCustomDll* currentDll = customDlls;
while (!ret && currentDll)
{
ret = currentDll->loadExtendedSaveFile(ptChar, data, maxSize, &curSize);
currentDll=currentDll->nextDll;
}
PCPY->selfStashIsOpened = true;
return ret;
}
void writeExtendedSaveFile(char* name, BYTE* data, DWORD size)
{
char szTempName[MAX_PATH];
char szSaveName[MAX_PATH];
//Get temporary savefile name.
D2FogGetSavePath(szTempName, MAX_PATH);
strcat(szTempName, name);
strcat(szTempName, ".d2~");
log_msg("Extended temporary file for saving : %s\n",szTempName);
//Write data in savefile.
FILE* customSaveFile = fopen(szTempName, "wb+");
fwrite(data, size, 1, customSaveFile);
fclose(customSaveFile);
//Get real savefile name.
D2FogGetSavePath(szSaveName, MAX_PATH);
strcat(szSaveName, name);
strcat(szSaveName, ".d2x");
log_msg("Extended file for saving : %s\n",szSaveName);
// if (!MoveFileEx(szTempName, szSaveName, MOVEFILE_WRITE_THROUGH|MOVEFILE_REPLACE_EXISTING))
DeleteFile(szSaveName);
if (!MoveFile(szTempName, szSaveName))
log_box("Could not create the extended save file.");
}
void backupExtendedSaveFile(char* name)
{
char szBackupName[MAX_PATH];
char szSaveName[MAX_PATH];
D2FogGetSavePath(szSaveName, MAX_PATH);
strcat(szSaveName, name);
strcat(szSaveName, ".d2x");
D2FogGetSavePath(szBackupName, MAX_PATH);
strcat(szBackupName, name);
strcat(szBackupName, ".d2x.backup");
CopyFile(szSaveName, szBackupName, true);
}
void saveExtendedSaveFile(Unit* ptChar, BYTE** data, DWORD* maxSize, DWORD* curSize)
{
*(DWORD *)(*data + *curSize) = FILE_EXTENDED; //"CSTM"
*curSize += 4;
*(WORD *)(*data + *curSize) = FILE_VERSION;
*curSize += 2;
*(DWORD *)(*data + *curSize) = 0;
*curSize += 4;
saveStashList(ptChar, PCPY->selfStash, data, maxSize, curSize);
TCustomDll* currentDll = customDlls;
while (currentDll)
{
currentDll->saveExtendedSaveFile(ptChar, data, maxSize, curSize);
currentDll=currentDll->nextDll;
}
}
/*================================= END OF FILE =================================*/

625
PlugY/ExtraOptions.cpp Normal file
View File

@ -0,0 +1,625 @@
/*=================================================================
File created by Yohann NICOLAS.
More little options.
=================================================================*/
#include "common.h"
#include "error.h"
#include "d2functions.h"
#include <stdio.h>
int active_RunLODs = false;
int active_alwaysRegenMapInSP = false;
DWORD nbPlayersCommandByDefault = 1;
int active_DisplayItemLevel = false;
int active_AlwaysDisplayLifeMana = false;
int active_EnabledTXTFilesWithMSExcel = false;
int active_DisplayBaseStatsValue = false;
int active_LadderRunewords = false;
int active_EnabledCowPortalWhenCowKingWasKill = false;
/****************************************************************************************************/
void STDCALL displayItemlevel(LPWSTR popup, Unit* ptItem)
{
if (onRealm && (selectModParam==MOD_NO)) return;
WCHAR text[0x50];
swprintf(text, L"Item Level: %u\n", D2GetItemLevel(ptItem));
D2SetColorPopup(text,WHITE);
wcscat(popup,text);
}
FCT_ASM ( caller_displayItemlevel_113 )
PUSH ECX
PUSH EAX
PUSH EAX
LEA EAX,DWORD PTR SS:[ESP+0x1E70]
PUSH EAX
CALL displayItemlevel
POP EAX
POP ECX
POP EDX
PUSH 0x100
JMP EDX
}}
FCT_ASM ( caller_displayItemlevel_111 )
PUSH ECX
PUSH EDX
PUSH ECX
LEA EAX,DWORD PTR SS:[ESP+0x1E74]
PUSH EAX
CALL displayItemlevel
POP EDX
POP ECX
POP EAX
PUSH 0x100
JMP EAX
}}
FCT_ASM ( caller_displayItemlevelSet_111 )
PUSH ECX
PUSH EDX
PUSH ECX
LEA EAX,DWORD PTR SS:[ESP+0x1958]
PUSH EAX
CALL displayItemlevel
POP EDX
POP ECX
POP EAX
PUSH 0x100
JMP EAX
}}
FCT_ASM ( caller_displayItemlevel )
PUSH ECX
PUSH EDX
PUSH ECX
LEA EAX,DWORD PTR SS:[ESP+0x5018]
PUSH EAX
CALL displayItemlevel
POP EDX
POP ECX
POP EAX
PUSH 0x100
JMP EAX
}}
FCT_ASM ( caller_displayItemlevelSet )
PUSH ECX
PUSH EDX
PUSH ECX
LEA EAX,DWORD PTR SS:[ESP+0x1220]
PUSH EAX
CALL displayItemlevel
POP EDX
POP ECX
POP EAX
PUSH 0x100
JMP EAX
}}
FCT_ASM ( caller_displayItemlevel_9 )
PUSH ECX
PUSH EDX
PUSH ECX
LEA EAX,DWORD PTR SS:[ESP+0x501C]
PUSH EAX
CALL displayItemlevel
POP EDX
POP ECX
POP EAX
PUSH 0x100
JMP EAX
}}
FCT_ASM ( caller_displayItemlevelSet_9 )
PUSH ECX
PUSH EDX
PUSH ECX
LEA EAX,DWORD PTR SS:[ESP+0x1224]
PUSH EAX
CALL displayItemlevel
POP EDX
POP ECX
POP EAX
PUSH 0x100
JMP EAX
}}
void Install_DisplayItemLevel()
{
static int isInstalled = false;
if (isInstalled) return;
log_msg("Patch D2Client for display item popup. (DisplayPopup)\n");
// print the text in the final buffer
mem_seek R7(D2Client, 3D47C, 3D47C, 438A1, ADD0A, 789DA, AE0AA, 941C0);
memt_byte( 0x68 , 0xE8);
MEMT_REF4( 0x100, version_D2Client >= V113 ? caller_displayItemlevel_113 : version_D2Client >= V111 ? caller_displayItemlevel_111 : version_D2Client == V110 ? caller_displayItemlevel : caller_displayItemlevel_9);
//6FAE38A1 . 68 00010000 PUSH 100
//6FB5DD0A |. 68 00010000 PUSH 100
//6FB289DA |. 68 00010000 PUSH 100
//6FB5E0AA |. 68 00010000 PUSH 100
//6FB441C0 |. 68 00010000 PUSH 100
// print the text in the final buffer (for set items)
mem_seek R7(D2Client, 3C452, 3C452, 427BE, AC773, 77773, ACEB3, 92FE3);
memt_byte( 0x68 , 0xE8);
MEMT_REF4( 0x100, version_D2Client >= V111 ? caller_displayItemlevelSet_111 : version_D2Client == V110 ? caller_displayItemlevelSet : caller_displayItemlevelSet_9);
//6FAE27BE . 68 00010000 PUSH 100
//6FB5C773 |. 68 00010000 PUSH 100
//6FB27773 |. 68 00010000 PUSH 100
//6FB5CEB3 |. 68 00010000 PUSH 100
//6FB42FE3 |. 68 00010000 PUSH 100
log_msg("\n");
isInstalled = true;
}
/****************************************************************************************************/
char* msgNBPlayersString = "players %u";
DWORD* infoEnabledSendPlayersCommand;
void SendPlayersCommand()
{
#pragma pack(1)
struct {
BYTE displayType;//0x15 main msg; 0x14: char popup
BYTE un;
BYTE zero;
char string[0xFF];
char null;
} data;
#pragma pack()
if (!needToInit || onRealm) return;
needToInit=0;
DWORD info = *infoEnabledSendPlayersCommand;
if ((info != 0) && (info != 1) && (info != 6) && (info != 8)) return;
D2SetNbPlayers(nbPlayersCommandByDefault);
memset(&data,0,sizeof(data));
data.displayType=0x15;
data.un=1;
data.zero=0;//*(BYTE*)(offset_D2Client+0x112CFC); in 1.10
data.null=NULL;
sprintf(data.string, msgNBPlayersString, nbPlayersCommandByDefault);
D2SendMsgToAll((BYTE*)&data);
}
FCT_ASM ( caller_SendPlayersCommand )
CALL SendPlayersCommand
JMP D2GetResolution
}}
void Install_SendPlayersCommand()
{
static int isInstalled = false;
if (isInstalled) return;
log_msg("Patch D2Client for init default nb /players. (SendPlayersCommand)\n");
infoEnabledSendPlayersCommand = (DWORD*)R7(D2Client, 111D60, 110BC0, 107960, 11BFBC, 11C2AC, 11BFF8, 11C394);
if ( version_D2Client >= V110 )
msgNBPlayersString = (char*)R7(D2Client, 0000, 0000, D8448, D06A8, D4748, D4680, D4E00);
// Set nb Player to default
mem_seek R7(D2Client, 8723B, 865BB, 81B8B, A3602, 66A02, 90162, C39F2);//6FB1C7B7-6FAA0000
MEMJ_REF4( D2GetResolution , caller_SendPlayersCommand);
//6FB2723A |. E8 7D8E0300 CALL <JMP.&D2gfx.#10005>
//6FB265BA |. E8 7D8E0300 CALL <JMP.&D2gfx.#10005>
//6FB21B8A . E8 4F9C0400 CALL <JMP.&D2gfx.#10005>
//6FB53601 |. E8 E099F6FF CALL <JMP.&D2gfx.#10000>
//6FB16A01 |. E8 AA65FAFF CALL <JMP.&D2gfx.#10063>
//6FB40161 |. E8 1ECFF7FF CALL <JMP.&D2gfx.#10043>
//6FB739F1 |. E8 B896F4FF CALL <JMP.&D2gfx.#10031>
log_msg("\n");
isInstalled = true;
}
/****************************************************************************************************/
void Install_AlwaysRegenMapInSP()
{
static int isInstalled = false;
if (isInstalled) return;
log_msg("Patch D2Game for always regenerate maps in Single player. (AlwaysRegenMapInSP)\n");
// Always regenerate maps in Single player
mem_seek R7(D2Game, 517ED, 51BFA, 5DE88, 6235D, 2966D, 1E1FE, ED3BE);
memt_byte( 0x74 , 0xEB); // JMP SHORT D2Game.01FE2368
//6FC8DE88 |. 74 09 JE SHORT D2Game.6FC8DE93
//01FE235D |. 74 09 JE SHORT D2Game.01FE2368
//01F9966D |. 74 09 JE SHORT D2Game.01F99678
//6FC3E1FE |. 74 09 JE SHORT D2Game.6FC3E209
//6FD0D3BE |. 74 09 JE SHORT D2Game.6FD0D3C9
log_msg("\n");
isInstalled = true;
}
/****************************************************************************************************/
void Install_RunLODs()
{
static int isInstalled = false;
if (isInstalled) return;
log_msg("Patch D2gfx for launch any number of Diablo II game in the same computer. (RunLODs)\n");
// execute if it's our packet else continue
mem_seek R7(D2gfx, 447C, 447C, 446A, 84CF, 84AF, 894F, 85BF);
memt_byte( 0x74, 0xEB ); // JMP SHORT D2gfx.6FA884F6
//6FA884AF |. 74 45 JE SHORT D2gfx.6FA884F6
//6FA8894F |. 74 45 JE SHORT D2gfx.6FA88996
//6FA885BF |. 74 45 JE SHORT D2gfx.6FA88606
log_msg("\n");
isInstalled = true;
}
/****************************************************************************************************/
FCT_ASM (caller_AlwaysDisplayLife_113)
POP EAX
CMP onRealm,0
JNZ normalDisplayLife
CMP active_AlwaysDisplayLifeMana,0
JE normalDisplayLife
ADD EAX,0x28
JMP EAX
normalDisplayLife:
CMP EDX,0x1E
JGE cont
ADD EAX,0xBC
cont:
JMP EAX
}}
FCT_ASM (caller_AlwaysDisplayLife_111)
CMP onRealm,0
JNZ normalDisplayLife
CMP active_AlwaysDisplayLifeMana,0
JE normalDisplayLife
POP EAX
ADD EAX,0x25
JMP EAX
normalDisplayLife:
MOV EAX,ptResolutionY
MOV EAX,DWORD PTR DS:[EAX]
RETN
}}
FCT_ASM (caller_AlwaysDisplayLife)
CMP onRealm,0
JNZ normalDisplayLife
CMP active_AlwaysDisplayLifeMana,0
JE normalDisplayLife
POP EAX
ADD EAX,0x28
JMP EAX
normalDisplayLife:
MOV EAX,ptResolutionY
MOV EAX,DWORD PTR DS:[EAX]
RETN
}}
FCT_ASM (caller_AlwaysDisplayMana_113)
MOV EAX,DWORD PTR DS:[ptResolutionY]
MOV EAX,DWORD PTR DS:[EAX]
CMP onRealm,0
JNZ normalDisplayMana
CMP active_AlwaysDisplayLifeMana,0
JE normalDisplayMana
POP EAX
ADD EAX,0x3C
JMP EAX
normalDisplayMana:
RETN
}}
FCT_ASM (caller_AlwaysDisplayMana)
CMP onRealm,0
JNZ normalDisplayMana
CMP active_AlwaysDisplayLifeMana,0
JE normalDisplayMana
POP EAX
MOV WORD PTR SS:[ESP+0x14],0
ADD EAX,0x38
JMP EAX
normalDisplayMana:
POP EAX
POP EDI
POP ESI
POP EBP
POP EBX
ADD ESP,0x25C
RETN
}}
FCT_ASM (caller_AlwaysDisplayMana_9)
CMP onRealm,0
JNZ normalDisplayMana
CMP active_AlwaysDisplayLifeMana,0
JE normalDisplayMana
ADD DWORD PTR SS:[ESP],0x32
LEA ECX,DWORD PTR SS:[ESP+0x24]
PUSH DWORD PTR SS:[ESP+0xC]
PUSH DWORD PTR SS:[ESP+0xC]
PUSH DWORD PTR SS:[ESP+0xC]
CALL D2PrintString
MOV WORD PTR SS:[ESP+0x24],0
RETN 0xC
normalDisplayMana:
POP EAX
ADD EAX,0xC2
JMP EAX
}}
void Install_AlwaysDisplayLifeMana()
{
static int isInstalled = false;
if (isInstalled) return;
log_msg("Patch D2Client for always display life and mana. (ALwaysPrintLifeMana)\n");
if ( version_D2Client >= V113 )
{
mem_seek R7(D2Client, 0000, 0000, 0000, 0000, 0000, 0000, 2764A);
memt_byte( 0x0F , 0x90);
memt_byte( 0x8C , 0xE8);
MEMT_REF4( 0x000000BC, caller_AlwaysDisplayLife_113);
//6FAD764A |. 0F8C BC000000 JL D2Client.6FAD770C
//6FAD7650 |. 83FA 6E CMP EDX,6E
//6FAD7653 |. 0F8F B3000000 JG D2Client.6FAD770C
//6FAD7659 |. A1 4CBCB86F MOV EAX,DWORD PTR DS:[6FB8BC4C]
//6FAD7667 |. 0F8C A4000000 JL D2Client.6FAD7711
} else {
// Always display life.
mem_seek R7(D2Client, 58B32, 58B32, 5F102, 2D713, B5DF3, 81733, 0000);
memt_byte( 0xA1 , 0xE8);
MEMT_REF4( ptResolutionY , version_D2Client >= V111 ? caller_AlwaysDisplayLife_111 : caller_AlwaysDisplayLife);
//6FADD713 |. A1 605CBA6F MOV EAX,DWORD PTR DS:[6FBA5C60]
//6FB65DF3 |. A1 C84FBA6F MOV EAX,DWORD PTR DS:[6FBA4FC8]
//6FB31733 |. A1 E4C6B86F MOV EAX,DWORD PTR DS:[6FB8C6E4]
}
// Always display mana.
if ( version_D2Client >= V113 )
{
//mem_seek R7(D2Client, 0000, 0000, 0000, 0000, 0000, 0000, 27711);
//memt_byte( 0x8B , 0x90);
//memt_byte( 0x0D , 0xE8);
//MEMT_REF4( offset_D2Client + 0x11C4B4 , caller_AlwaysDisplayMana_113);
mem_seek R7(D2Client, 0000, 0000, 0000, 0000, 0000, 0000, 2770C);
memt_byte( 0xA1 , 0xE8);
MEMT_REF4( ptResolutionY , caller_AlwaysDisplayMana_113);
//6FAD770C |> A1 4CBCB86F MOV EAX,DWORD PTR DS:[6FB8BC4C]
//6FAD7711 |> 8B0D B4C4BC6F MOV ECX,DWORD PTR DS:[6FBCC4B4]
//6FAD7708 |. 8B5424 10 MOV EDX,DWORD PTR SS:[ESP+10]
//6FAD77C7 |> 5F POP EDI
//6FAD77C8 |. 5E POP ESI
//6FAD77C9 |. 5D POP EBP
//6FAD77CA |. 5B POP EBX
//6FAD77CB |. 81C4 28030000 ADD ESP,328
//6FAD77D1 \. C3 RETN
}
else if ( version_D2Client >= V110 )
{
mem_seek R7(D2Client, 0000, 0000, 5F1E6, 2D7FB, B5EDB, 8181B, 0000);
memt_byte( 0x5F , 0xE8);
MEMT_REF4( 0x815B5D5E , caller_AlwaysDisplayMana);
memt_byte( 0xC4 , 0x90); // NOP
memt_byte( 0x5C , 0x90); // NOP
memt_byte( 0x02 , 0x90); // NOP
memt_byte( 0x00 , 0x90); // NOP
memt_byte( 0x00 , 0x90); // NOP
//6FADD7FB |. 5F POP EDI
//6FADD7FC |. 5E POP ESI
//6FADD7FD |. 5D POP EBP
//6FADD7FE |. 5B POP EBX
//6FADD7FF |. 81C4 5C020000 ADD ESP,25C
//6FB65EDB |. 5F POP EDI
//6FB65EDC |. 5E POP ESI
//6FB65EDD |. 5D POP EBP
//6FB65EDE |. 5B POP EBX
//6FB65EDF |. 81C4 5C020000 ADD ESP,25C
//6FB3181B |. 5F POP EDI
//6FB3181C |. 5E POP ESI
//6FB3181D |. 5D POP EBP
//6FB3181E |. 5B POP EBX
//6FB3181F |. 81C4 5C020000 ADD ESP,25C
//6FB31825 |. C3 RETN
} else {
mem_seek R7(D2Client, 58C09, 58C09, 0000, 0000, 0000, 0000, 0000);
memt_byte( 0xE9 , 0xE8);
MEMT_REF4( 0x000000C2 , caller_AlwaysDisplayMana_9);
//6FAF8C09 . E9 C2000000 JMP D2Client.6FAF8CD0
}
if (active_AlwaysDisplayLifeMana==2)
active_AlwaysDisplayLifeMana=0;
log_msg("\n");
isInstalled = true;
}
/****************************************************************************************************/
void Install_EnabledTXTFilesWithMSExcel()
{
static int isInstalled = false;
if (isInstalled) return;
log_msg("Patch D2Client for enabled the opening of files already opened by MS Excel. (EnabledTXTFilesWithMSExcel)\n");
mem_seek( (DWORD)D2StormMPQOpenFile + (version_Storm >= V111 ? 0x12A : 0xFF) );
memt_byte( 0x01 , 0x03); //; |ShareMode = FILE_SHARE_READ|FILE_SHARE_WRITE
//6FC1C969 |. 6A 01 PUSH 1 ; |ShareMode = FILE_SHARE_READ
log_msg("\n");
isInstalled = true;
}
/****************************************************************************************************/
void STDCALL printDisplayBaseStatsValue(WORD statID, sDrawImageInfo* data, DWORD x, DWORD y, DWORD p4, DWORD p5, DWORD p6)
{
if ( onRealm || !D2isLODGame())
{
D2PrintImage(data,x,y,p4,p5,p6);
return;
}
Unit* ptChar = D2GetClientPlayer();
CharStatsBIN* charStats = D2GetCharStatsBIN(ptChar->nPlayerClass);
int minValue=1;
switch (statID)
{
case STATS_STRENGTH: minValue = charStats->baseSTR; break;
case STATS_DEXTERITY: minValue = charStats->baseDEX; break;
case STATS_VITALITY: minValue = charStats->baseVIT; break;
case STATS_ENERGY: minValue = charStats->baseENE; break;
}
int statValue = D2GetPlayerBaseStat(ptChar, statID, 0);
if (isOnRect(D2GetMouseX(),D2GetMouseY(),x+5,y+5,32,32))
{
WCHAR text[100];
swprintf(text, getTranslatedString(STR_STATS_BASE_MIN), statValue, minValue);
D2SetFont(1);
D2PrintPopup(text, x+18, y-32, WHITE, 1);
}
if ( D2GetPlayerBaseStat(ptChar, 4, 0) <= 0)
setFrame(data, 2);
D2PrintImage(data,x,y,p4,p5,p6);
}
FCT_ASM ( caller_displayBaseStatsValue )
POP EAX
XOR ECX,ECX
MOV CX,WORD PTR DS:[ESI+8]
PUSH ECX
PUSH EAX
JMP printDisplayBaseStatsValue
}}
void Install_DisplayBaseStatsValue()
{
static int isInstalled = false;
if (isInstalled) return;
log_msg("Patch D2Client for display base stats value. (DisplayBaseStatsValue)\n");
// Always print stat button images.
mem_seek R7(D2Client, 29B12, 29B02, 30073, 82BBA, 8963A, 6B59A, BD1B5);
memt_byte( 0x8B, 0xEB ); // JMP SHORT D2Client.6FAD0088
memt_byte( 0x4C, V7(D2Client, 12, 12, 13, 13, 13, 13, 13) );
memt_byte( 0x24, 0x90 ); // NOP
memt_byte( V7(D2Client, 20, 20, 14, 1C, 1C, 1C, 1C), 0x90 ); // NOP (V109d:0x20 , V110:0x14
//6FAD0073 8B4C24 14 MOV ECX,DWORD PTR SS:[ESP+14]
//6FB32BBA > 8B4C24 1C MOV ECX,DWORD PTR SS:[ESP+1C]
//6FB3963A > 8B4C24 1C MOV ECX,DWORD PTR SS:[ESP+1C]
//6FB1B59A > 8B4C24 1C MOV ECX,DWORD PTR SS:[ESP+1C]
//6FB6D1B5 |> 8B4C24 1C MOV ECX,DWORD PTR SS:[ESP+1C]
mem_seek R7(D2Client, 29B9D, 29B8D, 300FD, 82C54, 896D4, 6B637, BD23E);
MEMJ_REF4( D2PrintImage, caller_displayBaseStatsValue);
//6FB32C53 . E8 82A3F8FF CALL <JMP.&D2gfx.#10047>
//6FB396D3 . E8 D238F8FF CALL <JMP.&D2gfx.#10044>
//6FB1B636 . E8 431AFAFF CALL <JMP.&D2gfx.#10024>
//6FB6D23D |. E8 54FEF4FF |CALL <JMP.&D2gfx.#10041>
log_msg("\n");
isInstalled = true;
}
/****************************************************************************************************/
RunesBIN* STDCALL compileRunesTxt(DWORD unused, const char* filename, BINField* ptFields, DWORD* ptRecordCount, DWORD recordLength)
{
RunesBIN* ptRunesBin = (RunesBIN*)D2CompileTxtFile(unused, filename, ptFields, ptRecordCount, recordLength);
for (DWORD i=0; i < *ptRecordCount; i++)
ptRunesBin[i].Server=0;
return ptRunesBin;
}
void Install_LadderRunewords()
{
static int isInstalled = false;
if (isInstalled) return;
if ( version_D2Common < V110 )
return;
log_msg("Patch D2Common for enabled the ladder only runewords. (LadderRunewords)\n");
mem_seek R7(D2Common, 0000, 0000, 1E965, 61762, 43A72, 5D492, 724B2);
MEMC_REF4( D2CompileTxtFile, compileRunesTxt);
//01B6E964 |. E8 0714FFFF CALL D2Common.#10578 ; \#10578
//6FDB1761 |. E8 FAA8FCFF CALL D2Common.#10653 ; \#10653
//6FD93A71 |. E8 EAADFCFF CALL D2Common.#10496 ; \#10496
//6FDAD491 |. E8 BA49FEFF CALL D2Common.#10244 ; \#10244
//6FDC24B1 |. E8 8ACAFEFF CALL D2Common.#10849 ; \#10849
log_msg("\n");
isInstalled = true;
}
/****************************************************************************************************/
void Install_EnabledCowPortalWhenCowKingWasKill()
{
static int isInstalled = false;
if (isInstalled) return;
log_msg("Patch D2Game for enabled the opening of Cow Portal when player have already kill the cow king in that difficulty. (EnabledCowPortalWhenCowKingWasKill)\n");
mem_seek R7(D2Game, 5DFF7, 5E457, 6C5E7 , B1278, 5DB68, 75C68, 67508);
memt_byte( 0x85 , 0x33); // XOR EAX,EAX
//6FC8DFF7 . 85C0 TEST EAX,EAX
//6FC8E457 . 85C0 TEST EAX,EAX
//6FC9C5E7 . 85C0 TEST EAX,EAX
//02061278 |. 85C0 TEST EAX,EAX
//01FEDB68 |. 85C0 TEST EAX,EAX
//6FC95C68 |. 85C0 TEST EAX,EAX
//6FC87508 |. 85C0 TEST EAX,EAX
log_msg("\n");
isInstalled = true;
}
/*================================= END OF FILE =================================*/

152
PlugY/GlobalVariable.cpp Normal file
View File

@ -0,0 +1,152 @@
/*=================================================================
File created by Yohann NICOLAS.
Updating server.
=================================================================*/
#include "common.h"
#include "error.h"
#include "d2functions.h"
#include "bigStash.h"
#include <stdio.h>
#include "uberQuest.h"
#include "worldEvent.h"
bool onRealm=false;
bool needToInit=false;
int previouslyOnRealm = -1;
void STDCALL BtnPress()
{
needToInit = 1;
// if (active_WorldEvent)
// initWorldEventVariables();
if (active_UberQuest)
resetQuestState();
d2_assert(active_bigStash_tested && onRealm && (previouslyOnRealm==0), "Need to restart after play an open game with the Big Stash",__FILE__,__LINE__);
d2_assert(active_bigStash_tested && !onRealm && (previouslyOnRealm>0), "Need to restart after play an closed game with the Big Stash",__FILE__,__LINE__);
previouslyOnRealm = onRealm;
}
FCT_ASM ( caller_BnetBtnPress )
CMP active_DisableBattleNet,1
JE disableBattleNet
MOV onRealm,1
PUSH EAX
CALL BtnPress
POP EAX
SUB ESP,0x3FC//400
JMP DWORD PTR SS:[ESP+0x3FC]
disableBattleNet:
POP EAX
RETN
}}
/*
FCT_ASM ( caller_MultiPlayerBtnPress )
CALL BtnPress
MOV EAX,1
RETN
}}
*/
FCT_ASM ( caller_TCPIPBtnPress111 )
MOV onRealm,0
CALL BtnPress
MOV ESI,0x40
RETN
}}
FCT_ASM ( caller_TCPIPBtnPress )
MOV onRealm,0
CALL BtnPress
MOV EBP,1
RETN
}}
FCT_ASM ( caller_SinglePlayerBtnPress )
MOV onRealm,0
CALL BtnPress
MOV EDX,0x400
RETN
}}
FCT_ASM ( caller_fixClientRemovingBug )
TEST ECX,ECX
JE notFound
CMP DWORD PTR DS:[ECX],EBP
JE found
next:
MOV EAX,ECX
MOV ECX,DWORD PTR DS:[EAX+0x4A8]
TEST ECX,ECX
JE notFound
CMP DWORD PTR DS:[ECX],EBP
JNZ next
found:
ADD DWORD PTR SS:[ESP],0xB
RETN
notFound:
ADD DWORD PTR SS:[ESP],0x1D
RETN
}}
void Install_VariableOnRealm()
{
static int isInstalled = false;
if (isInstalled) return;
log_msg("Patch D2Launch for set not on realm variable. (VariableonRealm)\n");
// click on Battle.net button
mem_seek R7(D2Launch, 8195, 81A5, 9915, 129E5, 18AA5, 17D15, 19295);
memt_byte( 0x81, 0xE8 ); // CALL
MEMT_REF4( 0x000400EC, caller_BnetBtnPress);
memt_byte( 0x00, 0x90 ); // NOP
//6FA529E5 . 81EC 00040000 SUB ESP,400
// click on Multiplayer button
// mem_seek R7(D2Launch, D5EC, D5CC, EFFC, 0000, 0000, 0000, 0000);
// memt_byte( 0xB8, 0xE8 ); // CALL
// MEMT_REF4( 0x00000001, caller_MultiPlayerBtnPress);
//6FA1EFFC . B8 01000000 MOV EAX,1
// click on TCP/IP button
mem_seek R7(D2Launch, 87B9, 87C9, 9F99, 11329, 17409, 16659, 17B8E);
if (version_D2Launch == V109b || version_D2Launch == V109d || version_D2Launch == V110)
{
memt_byte( 0xBD, 0xE8 ); // CALL
MEMT_REF4( 0x00000001, caller_TCPIPBtnPress);
} else {
memt_byte( 0xBE, 0xE8 ); // CALL
MEMT_REF4( 0x00000040, caller_TCPIPBtnPress111);
//6FA51329 . BE 40000000 MOV ESI,40
}
// click on SinglePlayer button
mem_seek R7(D2Launch, D1F6, D1E6, EC16, B726, 117E6, 10A56, 11F36);
memt_byte( 0xBA, 0xE8 ); // CALL
MEMT_REF4( 0x00000400, caller_SinglePlayerBtnPress);
//6FA4B726 . BA 00040000 MOV EDX,400
if (version_D2Game == V110)
{
log_msg("\nPatch D2Game for fixing ptClient removing bug. (VariableonRealm)\n");
//Bug crash ptClient search fix (for Megalixir Mod).
mem_seek R7(D2Game, 0000, 0000, 2B97, 0000, 0000, 0000, 0000);
memt_byte( 0x39 ,0xE8);
MEMT_REF4( 0x8B0C7429 , caller_fixClientRemovingBug);
memt_byte( 0xC1 ,0x90);
//6FC32B97 |> 3929 CMP DWORD PTR DS:[ECX],EBP
//6FC32B99 |. 74 0C JE SHORT D2Game.6FC32BA7
//6FC32B9B |> 8BC1 MOV EAX,ECX
}
log_msg("\n");
isInstalled = true;
}
/*================================= END OF FILE =================================*/

359
PlugY/INIfile.cpp Normal file
View File

@ -0,0 +1,359 @@
/******************************************************************************
File modified by Yohann NICOLAS.
NAME
INIfile.cpp
DESCRIPTION
Memory cached INI file read/write class to replace legacy MS code
COPYRIGHT
©1999-2004 Ultrafunk (www.ultrafunk.com) - info@ultrafunk.com
******************************************************************************/
#include <stdio.h>
#include "INIfile.h"
#include "d2functions.h"
#include "error.h"
/*
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/sysinfo/base/getprivateprofilestring.asp
*/
/*****************************************************************************/
// First a few support routines
static char *strstri(char *text, char *string)
{
char *found = NULL;
if(text && string)
{
int len = strlen(string);
if(len)
{
while(*text)
{
if(strnicmp(string, text, len) == 0)
{
found = text;
break;
}
text++;
}
}
}
return found;
}
static BOOL chrcmp(char c, char *string)
{
for(unsigned int i=0; i<strlen(string); i++)
{
if(c == string[i])
return TRUE;
}
return FALSE;
}
static BOOL FileExists(char *name)
{
DWORD attr = GetFileAttributes(name);
return ( (attr != (DWORD)-1) && !(attr & FILE_ATTRIBUTE_DIRECTORY) );
}
/*****************************************************************************/
INIFile::INIFile()
{
m_readWrite = 0;
m_file = NULL;
m_cache = NULL;
m_cacheWritePos = 0;
m_sectionStart = NULL;
m_sectionEnd = NULL;
ZeroMemory((void *)m_path, sizeof(m_path));
ZeroMemory((void *)m_currentSection, sizeof(m_currentSection));
}
INIFile::~INIFile()
{
if(m_file)
CloseHandle(m_file);
if(m_cache)
delete [] m_cache;
}
/*****************************************************************************/
BOOL INIFile::InitReadWrite(char *path, int readWrite, DWORD writeCacheSize)
{
if(path)
{
m_readWrite = readWrite;
m_cacheWritePos = 0;
m_sectionStart = NULL;
m_sectionEnd = NULL;
ZeroMemory((void *)m_path, sizeof(m_path));
ZeroMemory((void *)m_currentSection, sizeof(m_currentSection));
strncpy(m_path, path, sizeof(m_path));
if(m_file)
{
CloseHandle(m_file);
m_file = NULL;
}
if(m_cache)
{
delete [] m_cache;
m_cache = NULL;
}
// If read, the open file and cache content in memory
if(m_readWrite == INIFILE_MPQREAD)
{
void* refFile;
if ( D2MPQOpenFile(m_path,&refFile) )
{
DWORD fileSize = D2MPQGetSizeFile(refFile, NULL);
m_cache = new char[fileSize + 1];
if(m_cache)
{
DWORD read;
if(D2MPQReadFile(refFile, (BYTE*)m_cache, fileSize, &read, NULL, NULL, NULL) == 0)
{
delete [] m_cache;
m_cache = NULL;
}
else
m_cache[fileSize] = 0;
}
D2MPQCloseFile(refFile);
if(m_cache)
return TRUE;
}
}
// if((m_readWrite == INIFILE_MPQREAD) || (m_readWrite == INIFILE_READ))
if(m_readWrite == INIFILE_READ)
{
if(FileExists(m_path))
{
m_file = CreateFile(m_path,
GENERIC_READ,
0,
NULL,
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL,
NULL);
if(m_file != INVALID_HANDLE_VALUE)
{
DWORD fileSize = GetFileSize(m_file, NULL);
m_cache = new char[fileSize + 1];
if(m_cache)
{
DWORD read;
if(ReadFile(m_file, m_cache, fileSize, &read, NULL) == 0)
{
delete [] m_cache;
m_cache = NULL;
}
else
m_cache[fileSize] = 0;
}
CloseHandle(m_file);
m_file = NULL;
if(m_cache)
return TRUE;
}
}
}
// If write, then create write cache memory buffer
if(m_readWrite == INIFILE_WRITE)
{
m_cache = new char[writeCacheSize];
if(m_cache)
return TRUE;
}
}
return FALSE;
}
BOOL INIFile::close()
{
BOOL success = FALSE;
// If read, then kill the memory cached settings
if(m_readWrite == INIFILE_READ)
{
// Just to be sure, close the settings file again if it's still open for some reason
if(m_file)
{
CloseHandle(m_file);
m_file = NULL;
}
if(m_cache)
{
delete [] m_cache;
m_cache = NULL;
success = TRUE;
}
// Just to be sure, reset section position markers
m_sectionStart = NULL;
m_sectionEnd = NULL;
}
// If write, then commit (write) cached settings file to disk
if(m_readWrite == INIFILE_WRITE)
{
if(m_path && m_cache)
{
m_file = CreateFile(m_path,
GENERIC_WRITE,
0,
NULL,
CREATE_ALWAYS,
FILE_ATTRIBUTE_NORMAL,
NULL);
if(m_file != INVALID_HANDLE_VALUE)
{
DWORD written;
WriteFile(m_file, m_cache, m_cacheWritePos, &written, NULL);
CloseHandle(m_file);
m_file = NULL;
if(written == m_cacheWritePos)
success = TRUE;
}
delete [] m_cache;
m_cache = NULL;
}
}
return success;
}
/*****************************************************************************/
static char delimiterEnd[] = "\r\n\0";
int INIFile::GetPrivateProfileString(const char *section, const char *key, const char *def, char *dest, DWORD size)
{
DWORD copied = 0;
if((m_cache) && (section && key && dest && size))
{
if(stricmp(section, m_currentSection) != 0)
{
strncpy(m_currentSection, section, MAX_SECTIONNAME_LENGTH);
char headerString[MAX_SECTIONNAME_LENGTH];
ZeroMemory((void *)headerString, sizeof(headerString));
// _snprintf(headerString, MAX_SECTIONNAME_LENGTH, "[%s]\r\n", section);
_snprintf(headerString, MAX_SECTIONNAME_LENGTH, "[%s]", section);
// Locate section start in buffer
m_sectionStart = strstri(m_cache, headerString);
// We found the start section
if(m_sectionStart)
{
// Keys start after the "[" + section + "]" header
m_sectionStart += strlen(section) + 2;
// Locate section end in buffer
m_sectionEnd = strstr(m_sectionStart, "\r\n[");
// If no next section is found, then use end of buffer
if(m_sectionEnd == NULL)
m_sectionEnd = m_cache + strlen(m_cache);
}
}
if(m_sectionStart && m_sectionEnd)
{
char keyString[MAX_KEYNAME_LENGTH];
ZeroMemory((void *)keyString, sizeof(keyString));
_snprintf(keyString, MAX_KEYNAME_LENGTH, "\r\n%s=", key);
if(char *s = strstri(m_sectionStart, keyString))
{
if(s < m_sectionEnd)
{
s += strlen(keyString);
while(*s && (copied < size) && (chrcmp(*s, delimiterEnd) == FALSE))
{
*dest++ = *s++;
copied++;
}
*dest = 0;
copied++;
}
}
}
}
if(!copied && def)
strncpy(dest, def, size);
return copied; // Do not include the terminating null character
}
BOOL INIFile::WritePrivateProfileString(char *section, char *key, char *string)
{
if(!section || !key || !string) return false;
if(stricmp(section, m_currentSection) != 0)
{
if(m_cacheWritePos == 0)
m_cacheWritePos += sprintf((m_cache + m_cacheWritePos), "[%s]\r\n", section);
else
m_cacheWritePos += sprintf((m_cache + m_cacheWritePos), "\r\n[%s]\r\n", section);
strncpy(m_currentSection, section, MAX_SECTIONNAME_LENGTH);
}
m_cacheWritePos += sprintf((m_cache + m_cacheWritePos), "%s=%s\r\n", key, string);
return true;
}
/*================================= END OF FILE =================================*/

54
PlugY/INIfile.h Normal file
View File

@ -0,0 +1,54 @@
/******************************************************************************
File modified by Yohann NICOLAS.
NAME
inifile.h
DESCRIPTION
Memory cached INI file read/write class to replace legacy MS code
COPYRIGHT
©1999-2004 Ultrafunk (www.ultrafunk.com) - info@ultrafunk.com
******************************************************************************/
#ifndef _INIFILE_H
#define _INIFILE_H
#include <windows.h>
#define INIFILE_READ 10
#define INIFILE_WRITE 20
#define INIFILE_MPQREAD 30
#define MAX_SECTIONNAME_LENGTH 128
#define MAX_KEYNAME_LENGTH 128
/*****************************************************************************/
class INIFile
{
public:
INIFile();
~INIFile();
BOOL InitReadWrite(char *path, int readWrite, DWORD writeCacheSize);
BOOL close();
int GetPrivateProfileString(const char *section, const char *key, const char *def, char *dest, DWORD size);
BOOL WritePrivateProfileString(char *section, char *key, char *string);
private:
int m_readWrite;
char m_path[_MAX_PATH];
HANDLE m_file;
char *m_cache;
DWORD m_cacheWritePos;
char *m_sectionStart;
char *m_sectionEnd;
char m_currentSection[MAX_SECTIONNAME_LENGTH];
};
#endif // _INIFILE_H
/*================================= END OF FILE =================================*/

864
PlugY/InfinityStash.cpp Normal file
View File

@ -0,0 +1,864 @@
/*=================================================================
File created by Yohann NICOLAS.
Gestion of the infinity and shared Stash.
=================================================================*/
#include "common.h"
#include "infinityStash.h"
#include "error.h"
#include "d2functions.h"
#include "updateClient.h"
#include "interface_Stash.h"
#define STASH_TAG 0x5453 //"ST"
#define JM_TAG 0x4D4A //"JM"
DWORD maxSelfPages = -1;
DWORD maxSharedPages = -1;
DWORD nbPagesPerIndex = 10;
DWORD nbPagesPerIndex2 = 100;
bool active_multiPageStash = false;
bool active_sharedStash = false;
bool separateHardSoftStash = false;
bool active_sharedGold=false;
char* sharedStashFilename = NULL;
typedef int (*TchangeToSelectedStash)(Unit* ptChar, Stash* newStash, DWORD bIsClient);
Unit* firstClassicStashItem(Unit* ptChar)
{
Unit* ptItem = D2InventoryGetFirstItem(PCInventory);
while (ptItem)
{
if (D2ItemGetPage(D2GetRealItem(ptItem)) == 4)
return ptItem;
ptItem = D2UnitGetNextItem(ptItem);
}
return NULL;
}
DWORD endStashList(Unit* ptChar, Stash* ptStash)//WORKS
{
Stash* stash = ptStash;
while (stash)
{
if (stash->ptListItem || ((stash == PCPY->currentStash) && firstClassicStashItem(ptChar))) return 0;
stash = stash->nextStash;
}
return 1;
}
//bool isInList(Stash* list, Stash* pStash)
//{
// Stash* ptStash = list;
// while(ptStash)
// {
// if (ptStash->id == pStash->id) return true;
// ptStash = ptStash->nextStash;
// }
// return false;
//}
Stash* getLastStash(Stash* ptStash)//WORKS
{
Stash* stash = ptStash;
if (!stash) return NULL;
while (stash->nextStash)
stash = stash->nextStash;
return stash;
}
Stash* newStash(DWORD id)
{
d2_assert( id == 0xFFFFFFFF , "trop de stash", __FILE__, __LINE__);
Stash* stash = (Stash*)malloc(sizeof(Stash));//D2AllocMem(memPool, sizeof(Stash),__FILE__,__LINE__,0);
d2_assert(!stash , "pb de génération de stash", __FILE__, __LINE__);
ZeroMemory(stash, sizeof(Stash));
stash->id = id;
return stash;
}
Stash* addStash(Unit* ptChar, bool isShared)
{
Stash* previous;
Stash* stash;
// DWORD memPool = PCGame ? PCGame->memoryPool :0;
if (isShared)
{
previous = getLastStash(PCPY->sharedStash);
stash = newStash(PCPY->nbSharedPages++);
} else {
previous = getLastStash(PCPY->selfStash);
stash = newStash(PCPY->nbSelfPages++);
}
stash->isShared = isShared;
stash->previousStash = previous;
if (previous)
previous->nextStash = stash;
else if (isShared)
PCPY->sharedStash = stash;
else
PCPY->selfStash = stash;
log_msg("AddStash: stash->id=%d\tstash->isShared=%d\tstash->previous=%08X\tnbSelf=%d\tnbShared=%d\n",
stash->id,stash->isShared,stash->previousStash,PCPY->nbSelfPages,PCPY->nbSharedPages);
return stash;
}
Stash* getStash(Unit* ptChar, DWORD isShared, DWORD id)//WORKS
{
Stash* ptStash = isShared ? PCPY->sharedStash : PCPY->selfStash;
while(ptStash)
{
if (ptStash->id == id) return ptStash;
ptStash = ptStash->nextStash;
}
return NULL;
}
int changeToSelectedStash_9(Unit* ptChar, Stash* newStash, DWORD bIsClient)
{
if (!newStash) return 0;
log_msg("changeToSelectedStash ID:%d\tshared:%d\tclient:%d\n",newStash->id,newStash->id,bIsClient);
Stash* currentStash = PCPY->currentStash;
if (currentStash == newStash) return 0;
d2_assert( currentStash && currentStash->ptListItem, "ERROR : currentStash isn't empty (ptListItem != NULL)",__FILE__,__LINE__);
// collect items to remove
Inventory* ptInventory = PCInventory;
Unit* ptNextItem;
Unit* ptPrevItem = NULL;
Unit* ptItem = D2InventoryGetFirstItem(ptInventory);
while (ptItem)
{
ptNextItem = D2UnitGetNextItem(ptItem);
if (D2ItemGetPage(D2GetRealItem(ptItem)) == 4)
{
D2SetAnim(D2GetRealItem(ptItem),-1);
if (ptPrevItem) {
ptPrevItem->CurrentAnim = (DWORD)ptNextItem;//is ptPrevItem->nextNode = ptNextItem;
} else {
ptInventory->currentUsedSocket = (DWORD)ptNextItem;//is ptInventory->ptListItem = ptNextItem;
}
if (!ptNextItem)
ptInventory->Inventory2C = (DWORD)ptPrevItem;
ptInventory->Inventory30 = ptInventory->Inventory30 - 1;
D2Common10250(__FILE__,__LINE__,ptInventory, D2GetPosX(D2GetRealItem(ptItem)), D2GetPosY(D2GetRealItem(ptItem)), 0xC, bIsClient, 4);
// ptItem = D2InvRemoveItem(PCInventory, D2GetRealItem(ptItem));
// D2Common10250(__FILE__,__LINE__,PCInventory, D2GetPosX(ptItem), D2GetPosY(ptItem), 0xC, bIsClient, 4);
if (currentStash)
{
// ptItem = setNextItem(ptItem, PCPY->currentStash->ptListItem);
ptItem->CurrentAnim = (DWORD)currentStash->ptListItem;//is ptItem->nextNode = ptListItem
currentStash->ptListItem = ptItem;
};
} else ptPrevItem = ptItem;
ptItem = ptNextItem;
}
// add items of new stash
PCPY->currentStash = newStash;
ptItem = newStash->ptListItem;
while (ptItem)
{
D2InvAddItem(PCInventory, D2GetRealItem(ptItem), D2GetPosX(D2GetRealItem(ptItem)), D2GetPosY(D2GetRealItem(ptItem)), 0xC, bIsClient, 4);
D2Common10242(PCInventory, D2GetRealItem(ptItem), 1);
ptItem = D2UnitGetNextItem(ptItem);
}
newStash->ptListItem = NULL;
return 1;
}
int changeToSelectedStash_10(Unit* ptChar, Stash* newStash, DWORD bIsClient)
{
if (!newStash) return 0;
log_msg("changeToSelectedStash ID:%d\tshared:%d\tclient:%d\n",newStash->id,newStash->id,bIsClient);
Stash* currentStash = PCPY->currentStash;
if (currentStash == newStash) return 0;
d2_assert( currentStash && currentStash->ptListItem, "ERROR : currentStash isn't empty (ptListItem != NULL)",__FILE__,__LINE__);
// Remove items from current page
Unit* ptNextItem;
Unit* ptItem = D2InventoryGetFirstItem(PCInventory);
while (ptItem)
{
ptNextItem = D2UnitGetNextItem(ptItem);
if (D2ItemGetPage(ptItem) == 4)
{
BYTE tmp = ptItem->ptItemData->ItemData2;
ptItem = D2InvRemoveItem(PCInventory, ptItem);
ptItem->ptItemData->ItemData2 = tmp;
if (currentStash)
{
ptItem->ptItemData->ptNextItem = currentStash->ptListItem;
currentStash->ptListItem = ptItem;
}
}
ptItem = ptNextItem;
}
// add items of new stash
PCPY->currentStash = newStash;
ptItem = newStash->ptListItem;
while (ptItem)
{
D2InvAddItem(PCInventory, ptItem, ptItem->path->x, ptItem->path->y, 0xC, bIsClient, 4);
ptItem = D2UnitGetNextItem(ptItem);
}
newStash->ptListItem = NULL;
return 1;
}
TchangeToSelectedStash changeToSelectedStash;
DWORD loadStash(Unit* ptChar, Stash* ptStash, BYTE data[], DWORD startSize, DWORD maxSize, DWORD* retSize)
{
DWORD curSize = startSize;
DWORD nbBytesRead;
log_msg("loadStash\n");
*retSize = curSize;
if( *(WORD *)&data[curSize] != STASH_TAG )//"ST"
{
log_msg("loadStash -> Bad tag of stash of character %s : %04X\n",PCPlayerData->name,*(WORD *)&data[curSize]);
return 0x7;//Unable to enter game. Bad inventory data
}
curSize += 2;
// if (strlen((char *)&data[curSize]) > 0xF)
// *(char *)&data[curSize+0xF] = NULL;
if (strlen((char *)&data[curSize]))
ptStash->name = (char*)malloc(strlen((char *)&data[curSize]));//D2AllocMem(PCGame->memoryPool, strlen((char *)&data[curSize]),__FILE__,__LINE__,0);
if (ptStash->name)
strcpy(ptStash->name, (char *)&data[curSize]);
curSize += strlen((char *)&data[curSize]) + 1;
DWORD ret = D2LoadInventory(PCGame, ptChar, (saveBitField*)&data[curSize], 0x60, maxSize-curSize, 0, &nbBytesRead);
if (ret) log_msg("loadStash -> D2LoadInventory failed\n");
log_msg("Stash loaded (%d : %s)\n", ptStash->id ,ptStash->name);
*retSize=curSize + nbBytesRead;
return ret;
}
DWORD loadStashList(Unit* ptChar, BYTE data[], DWORD maxSize, DWORD* curSize, bool isShared)//WORKS
{
DWORD curStash = 0;
Stash* newStash;
DWORD nbStash = *(DWORD*)&data[*curSize];
*curSize += 4;
while (curStash < nbStash)
{
newStash = addStash(ptChar, isShared);
changeToSelectedStash(ptChar, newStash, false);
DWORD ret = loadStash(ptChar, newStash, data, *curSize, 10000000, curSize);
if (ret) return ret;
curStash++;
}
if (!isShared && !PCPY->selfStash)
{
newStash = addStash(ptChar, isShared);
PCPY->currentStash = newStash;
}
if (isShared && !PCPY->sharedStash)
{
newStash = addStash(ptChar, isShared);
if (!PCPY->currentStash)
PCPY->currentStash = newStash;
}
return 0;
}
//ADDDATA(DWORD, curSize, 0);
#define DATA (*data + *curSize)
#define ADDDATA(T) (T*)DATA; *curSize += sizeof(T)
#define SETDATA(T,V) *(T*)DATA = V; *curSize += sizeof(T)
void saveStash(Unit* ptChar, Stash* ptStash, BYTE** data, DWORD* maxSize, DWORD* curSize)
{
//write "ST"
SETDATA(WORD, STASH_TAG);
//save name
if (ptStash->name)
{
int size = strlen(ptStash->name);
if (size > 15) size = 15;
strncpy((char*)DATA, ptStash->name, size);
*curSize += size;
}
SETDATA(char, NULL);
//Write "JM" of inventory
SETDATA(WORD, JM_TAG);
//Get position of counter of items in inventory
WORD* ptNBItem = ADDDATA(WORD);
*ptNBItem = 0;
//Get first item
Unit* ptItem;
if ((ptStash->id == PCPY->currentStash->id) && (ptStash->isShared == PCPY->currentStash->isShared))
ptItem = D2InventoryGetFirstItem(PCInventory);
else
ptItem = ptStash->ptListItem;
//Write all items
while (ptItem)
{
if (D2ItemGetPage(D2GetRealItem(ptItem)) == 4)
{
int nbBytes = D2SaveItem(D2GetRealItem(ptItem), (saveBitField*)DATA, *maxSize - *curSize, 1, 1, 0);
d2_assert(!nbBytes, "!\"Character has too many items\"", __FILE__, __LINE__ );
*curSize += nbBytes;
(*ptNBItem)++;
}
ptItem = D2UnitGetNextItem(ptItem);
}
}
void saveStashList(Unit* ptChar, Stash* ptStash, BYTE** data, DWORD* maxSize, DWORD* curSize)
{
DWORD curSizeNbStash = *curSize;
*curSize += sizeof(DWORD);
DWORD nbStash=0;
while(ptStash)
{
if (*curSize + 0x2000 > *maxSize)
{
BYTE* oldData = *data;
*maxSize *= 2;
*data = (BYTE *)D2AllocMem(PCGame->memoryPool, *maxSize,__FILE__,__LINE__,0);
d2_assert(!*data, "Error : Memory allocation", __FILE__, __LINE__);
CopyMemory(*data, oldData, *curSize);
D2FreeMem(PCGame->memoryPool, oldData,__FILE__,__LINE__,0);
}
saveStash(ptChar, ptStash, data, maxSize, curSize);
nbStash++;
ptStash = endStashList(ptChar, ptStash->nextStash) ? NULL : ptStash->nextStash;
}
*(DWORD*)(*data + curSizeNbStash) = nbStash;
}
/////// client
void updateSelectedStashClient(Unit* ptChar)//WORKS
{
Stash* newStash = PCPY->currentStash;
updateClient(ptChar, UC_SELECT_STASH, newStash->id, newStash->flags, PCPY->flags);
}
void setSelectedStashClient(DWORD stashId, DWORD stashFlags, DWORD flags)//WORKS
{
log_msg("setSelectedStashClient ID:%d, isShared:%d, flags:%08X\n", stashId, stashFlags&1, flags);
Unit* ptChar = D2GetClientPlayer();
Stash* newStash = getStash(ptChar, stashFlags&1, stashId);
if (!newStash) do
newStash = addStash(ptChar, stashFlags&1);
while (newStash->id < stashId);
changeToSelectedStash(ptChar, newStash, 1);
PCPY->flags = flags;
}
void selectStash(Unit* ptChar, Stash* newStash)//WORKS
{
changeToSelectedStash(ptChar, newStash, 0);
updateSelectedStashClient(ptChar);
}
///// public functions
void toggleToSelfStash(Unit* ptChar)
{
Stash* selStash = PCPY->selfStash;
if (selStash && (selStash != PCPY->currentStash))
{
PCPY->showSharedStash = false;
selectStash(ptChar, selStash);
}
}
void toggleToSharedStash(Unit* ptChar)
{
Stash* selStash = PCPY->sharedStash;
if (selStash && (selStash != PCPY->currentStash))
{
PCPY->showSharedStash = true;
selectStash(ptChar, selStash);
}
}
void selectPreviousStash(Unit* ptChar)
{
Stash* selStash = PCPY->currentStash->previousStash;
if (selStash && (selStash != PCPY->currentStash))
selectStash(ptChar, selStash);
}
void selectPrevious2Stash(Unit* ptChar)// Select first stash
{
Stash* selStash = PCPY->showSharedStash ? PCPY->sharedStash : PCPY->selfStash;
if (selStash && (selStash != PCPY->currentStash))
selectStash(ptChar, selStash);
}
void selectNextStash(Unit* ptChar)
{
Stash* selStash = PCPY->currentStash;
if (!selStash->isShared && (selStash->id >= maxSelfPages)) return;
if (selStash->isShared && (selStash->id >= maxSharedPages)) return;
selStash = selStash->nextStash ? selStash->nextStash : addStash(ptChar, PCPY->showSharedStash);
if (selStash && (selStash != PCPY->currentStash))
selectStash(ptChar, selStash);
}
void selectNext2Stash(Unit* ptChar)//select last stash
{
Stash* selStash = PCPY->showSharedStash ? PCPY->sharedStash : PCPY->selfStash;//PCPY->currentStash;
Stash* lastStash = NULL;
Unit* currentStashItem = firstClassicStashItem(ptChar);
while (selStash)
{
if (selStash->ptListItem || (selStash == PCPY->currentStash) && currentStashItem) lastStash=selStash;
selStash = selStash->nextStash;
}
if (!lastStash)
lastStash = PCPY->showSharedStash ? PCPY->sharedStash : PCPY->selfStash;
if (lastStash != PCPY->currentStash)
selectStash(ptChar, lastStash);
}
void selectPreviousIndexStash(Unit* ptChar)
{
selectPreviousStash(ptChar);
Stash* selStash = PCPY->currentStash;
while (selStash->previousStash && ((selStash->id+1) % nbPagesPerIndex != 0))
selStash = selStash->previousStash;
if (selStash && (selStash != PCPY->currentStash))
selectStash(ptChar, selStash);
}
void selectPreviousIndex2Stash(Unit* ptChar)
{
selectPreviousStash(ptChar);
Stash* selStash = PCPY->currentStash;
while (selStash->previousStash && ((selStash->id+1) % nbPagesPerIndex2 != 0))
selStash = selStash->previousStash;
if (selStash && (selStash != PCPY->currentStash))
selectStash(ptChar, selStash);
}
void selectNextIndexStash(Unit* ptChar)
{
selectNextStash(ptChar);
Stash* selStash = PCPY->currentStash;
while ((selStash->id+1) % nbPagesPerIndex != 0)
{
if (!selStash->isShared && (selStash->id >= maxSelfPages)) break;
if (selStash->isShared && (selStash->id >= maxSharedPages)) break;
selStash = selStash->nextStash ? selStash->nextStash : addStash(ptChar, PCPY->showSharedStash);;
}
if (selStash && (selStash != PCPY->currentStash))
selectStash(ptChar, selStash);
}
void selectNextIndex2Stash(Unit* ptChar)
{
selectNextStash(ptChar);
Stash* selStash = PCPY->currentStash;
while ((selStash->id+1) % nbPagesPerIndex2 != 0)
{
if (!selStash->isShared && (selStash->id >= maxSelfPages)) break;
if (selStash->isShared && (selStash->id >= maxSharedPages)) break;
selStash = selStash->nextStash ? selStash->nextStash : addStash(ptChar, PCPY->showSharedStash);;
}
if (selStash && (selStash != PCPY->currentStash))
selectStash(ptChar, selStash);
}
//////////////////////////////////////////////////////////////////////
Stash* curStash2;
DWORD currentSawStash2;
Unit* STDCALL getNextItem(Unit* ptChar, Unit* ptItem)
{
Unit* item = D2UnitGetNextItem(ptItem);
if (item) return item;
if (!curStash2)
{
switch (currentSawStash2)
{
case 0: curStash2 = PCPY->selfStash;
currentSawStash2 = 1;
break;
case 1: curStash2 = PCPY->sharedStash;
currentSawStash2 = 2;
break;
default: return NULL;//case 2:
}
} else {
curStash2 = curStash2->nextStash;
}
if (curStash2)
{
item = curStash2->ptListItem;
if (item) return item;
}
return getNextItem(ptChar,item);
}
Unit* STDCALL initGetNextItem(Unit* ptChar, Unit* ptItem)
{
if (ptChar->nUnitType != UNIT_PLAYER) return NULL;
if (!PCPY) return NULL;
curStash2 = NULL;
currentSawStash2 = 0;
if (ptItem) return ptItem;
return getNextItem(ptChar,ptItem);
}
FCT_ASM ( caller_initGetNextItem )
PUSH DWORD PTR SS:[ESP+0x20]
PUSH DWORD PTR SS:[ESP+0xC]
CALL initGetNextItem
MOV EDI,EAX
TEST EDI,EDI
RETN
}}
FCT_ASM ( caller_getNextItem )
PUSH DWORD PTR SS:[ESP+4]
PUSH DWORD PTR SS:[ESP+0x10]
CALL getNextItem
RETN 4
}}
DWORD STDCALL carry1Limit(Unit* ptChar, Unit* ptItemParam, DWORD itemNum, BYTE page)
{
if (!ptChar) return 0;
Unit* ptItem = ptItemParam ? ptItemParam : D2GameGetObject(PCGame, UNIT_ITEM, itemNum);
if ((page != 4) && (D2GetItemQuality(ptItem) == 7) && ptChar)
{
int uniqueID = D2GetUniqueID(ptItem);
if ((uniqueID>=0) && (uniqueID < (int)SgptDataTables->nbUniqueItems))
{
UniqueItemsBIN* uniqueItems = SgptDataTables->uniqueItems + uniqueID;
if (uniqueItems && (uniqueItems->carry1==1))
{
ItemsBIN* ptItemsBin = D2GetItemsBIN(ptItem->nTxtFileNo);
Unit* ptFirstItem = D2InventoryGetFirstItem(PCInventory);
if (ptItemsBin && ptFirstItem)
return D2VerifIfNotCarry1(ptItem, ptItemsBin, ptFirstItem);
}
}
}
return 0;
}
FCT_ASM ( caller_carry1Limit_111 )
PUSH DWORD PTR SS:[ESP+0x08]//page
PUSH 0//EDI
PUSH DWORD PTR SS:[ESP+0x0C]
PUSH ESI//ptChar
CALL carry1Limit
TEST EAX,EAX
JNZ end_carry1Limit
JMP D2ItemSetPage
end_carry1Limit:
ADD ESP,0xC
XOR EAX,EAX
POP EDI
POP EBX
POP ESI
POP EBP
RETN 8
}}
FCT_ASM ( caller_carry1Limit )
PUSH DWORD PTR SS:[ESP+0x08]//page
PUSH 0//EBP
PUSH DWORD PTR SS:[ESP+0x0C]
PUSH DWORD PTR SS:[ESP+0x28]//ptChar
CALL carry1Limit
TEST EAX,EAX
JNZ end_carry1Limit
JMP D2ItemSetPage
end_carry1Limit:
ADD ESP,0xC
POP EDI
POP ESI
POP EBP
XOR EAX,EAX
POP EBX
ADD ESP,0x24
RETN 8
}}
FCT_ASM ( caller_carry1LimitSwap_112 )
PUSH EAX
PUSH DWORD PTR SS:[ESP+0x1C]
PUSH 0
PUSH ESI//ptChar
CALL carry1Limit
TEST EAX,EAX
JNZ end_carry1Limit
JMP D2ItemGetPage
end_carry1Limit:
ADD ESP,8
XOR EAX,EAX
POP EDI
POP EBP
POP ESI
POP EBX
POP ECX
RETN 8
}}
FCT_ASM ( caller_carry1LimitSwap_111 )
PUSH EAX
PUSH EBP
PUSH 0
PUSH DWORD PTR SS:[ESP+0x24]//ptChar
CALL carry1Limit
TEST EAX,EAX
JNZ end_carry1Limit
JMP D2ItemGetPage
end_carry1Limit:
ADD ESP,8
XOR EAX,EAX
POP EDI
POP EBP
POP ESI
POP EBX
POP ECX
RETN 8
}}
FCT_ASM ( caller_carry1LimitSwap )
PUSH EAX
PUSH DWORD PTR SS:[ESP+0x20]
PUSH 0
PUSH EBP//ptChar
CALL carry1Limit
TEST EAX,EAX
JNZ end_carry1Limit
JMP D2ItemGetPage
end_carry1Limit:
ADD ESP,8
POP EDI
POP ESI
POP EBP
XOR EAX,EAX
POP EBX
ADD ESP,0x4C
RETN 8
}}
/*
FCT_ASM ( caller_carry1LimitWhenDrop )
PUSH EAX
PUSH 0
PUSH ESI//ptItem
PUSH EDI//ptChar
CALL carry1Limit
TEST EAX,EAX
POP EAX
JE END_carry1LimitWhenDrop
MOV EDX,0x806
RETN
END_carry1LimitWhenDrop:
ADD DWORD PTR SS:[ESP],0x1F
RETN
}}*/
FCT_ASM ( caller_carry1LimitWhenDrop_111 )
PUSH 0
PUSH 0
PUSH DWORD PTR SS:[ESP+0x10] //ptItem
PUSH ESI //ptChar
CALL carry1Limit
TEST EAX,EAX
JNZ end_carry1Limit
JMP D2CanPutItemInInv
end_carry1Limit:
XOR EAX,EAX
RETN 0x1C
}}
/*
FCT_ASM ( caller_carry1LimitWhenDrop )
PUSH 0
PUSH 0
PUSH DWORD PTR SS:[ESP+0x10] //ptItem
PUSH EDI //ptChar
CALL carry1Limit
JNZ end_carry1Limit
JMP D2CanPutItemInInv
end_carry1Limit:
XOR EAX,EAX
RETN 0x1C
}}*/
FCT_ASM ( caller_carry1LimitWhenDrop )
PUSH EAX
PUSH 0
PUSH 0
PUSH ESI//ptItem
PUSH EDI//ptChar
CALL carry1Limit
TEST EAX,EAX
POP EAX
JNZ END_carry1LimitWhenDrop
MOV EDX,0x806
RETN
END_carry1LimitWhenDrop:
ADD DWORD PTR SS:[ESP],0x1F
RETN
}}
FCT_ASM ( caller_carry1OutOfStash_111 )
PUSH EDI
CALL D2ItemGetPage
CMP AL,4
JNZ continue_carry1OutOfStash
ADD DWORD PTR SS:[ESP],0x17C
RETN
continue_carry1OutOfStash:
MOV ESI,DWORD PTR SS:[ESP+0x10]
TEST ESI,ESI
RETN
}}
FCT_ASM ( caller_carry1OutOfStash )
PUSH ESI
CALL D2ItemGetPage
CMP AL,4
JNZ continue_carry1OutOfStash
ADD DWORD PTR SS:[ESP],0x1AF
RETN
continue_carry1OutOfStash:
MOV EAX,DWORD PTR SS:[ESP+0x14]
TEST EAX,EAX
RETN
}}
void Install_MultiPageStash()
{
static int isInstalled = false;
if (isInstalled) return;
Install_PlayerCustomData();
Install_InterfaceStash();
changeToSelectedStash = version_D2Common >= V110 ? changeToSelectedStash_10 : changeToSelectedStash_9;
if ( version_D2Game >= V110 )
{
log_msg("Patch D2Game for carry1 unique item. (MultiPageStash)\n");
// Cannot put 2 items carry1 in inventory
mem_seek R7(D2Game, 0000, 0000, 55050, 57CA3, 2FE63, 99B03, CF1E3);
MEMJ_REF4( D2ItemSetPage , version_D2Game >= V111 ? caller_carry1Limit_111 : caller_carry1Limit);
//6FC8504F . E8 94670900 CALL <JMP.&D2Common.#10720>
//01FD7CA2 . E8 6329FBFF CALL <JMP.&D2Common.#10485>
//01F9FE62 . E8 47A8FDFF CALL <JMP.&D2Common.#10608>
//6FCB9B02 . E8 9709F7FF CALL <JMP.&D2Common.#10223>
//6FCEF1E2 . E8 47B7F3FF CALL <JMP.&D2Common.#10012>
// Cannot put 2 items carry1 in inventory by swapping
mem_seek R7(D2Game, 0000, 0000, 558D9, 58968, 310E8, 9B6E8, D10C8);
MEMJ_REF4( D2ItemGetPage , version_D2Game >= V112 ? caller_carry1LimitSwap_112 : version_D2Game >= V111 ? caller_carry1LimitSwap_111 : caller_carry1LimitSwap);
//6FC858D8 . E8 175F0900 CALL <JMP.&D2Common.#10719>
//01FD8967 . E8 8E1DFBFF CALL <JMP.&D2Common.#10820>
//01FA10E7 . E8 9A96FDFF CALL <JMP.&D2Common.#10505>
//6FCBB6E7 . E8 CAEDF6FF CALL <JMP.&D2Common.#10370>
//6FCF10C7 . E8 F895F3FF CALL <JMP.&D2Common.#10020>
if ( version_D2Game >= V111 )
{
// Cannot put 2 items carry1 in inventory when drop cube
mem_seek R7(D2Game, 0000, 0000, 0000, 3D935, 49FD5, 17AD5, D7B75);
MEMJ_REF4( D2CanPutItemInInv , caller_carry1LimitWhenDrop_111);
//01FBD934 |. E8 5BD3FCFF |CALL <JMP.&D2Common.#10855>
//01FB9FD4 |. E8 3912FCFF |CALL <JMP.&D2Common.#10813>
//6FC37AD4 |. E8 0535FFFF |CALL <JMP.&D2Common.#10289>
//6FCF7B74 |. E8 232FF3FF |CALL <JMP.&D2Common.#10133>
} else {
// Cannot put 2 items carry1 in inventory when drop cube
mem_seek R7(D2Game, 0000, 0000, 14341, 0000, 0000, 0000, 0000);
memt_byte( 0xBA ,0xE8);
MEMT_REF4( 0x00000806 , caller_carry1LimitWhenDrop);
//6FC44341 |. BA 06080000 |MOV EDX,806
}
// Verif only carry1 out of stash page when pick up an item
mem_seek R7(D2Game, 0000, 0000, 1299E, 38E3B, 43F0B, 1209B, D211B);
memt_byte( 0x8B ,0xE8);
MEMT_REF4( version_D2Game >= V111 ? 0x850C2474 : 0x85102444 , version_D2Game >= V111 ? caller_carry1OutOfStash_111 : caller_carry1OutOfStash);
memt_byte( version_D2Game >= V111 ? 0xF6 : 0xC0 ,0x90);
//6FC4299E |. 8B4424 10 |MOV EAX,DWORD PTR SS:[ESP+10]
//6FC429A2 |. 85C0 |TEST EAX,EAX
//01FB8E3B |. 8B7424 0C |MOV ESI,DWORD PTR SS:[ESP+C]
//01FB8E3F |. 85F6 |TEST ESI,ESI
//01FB3F0B |. 8B7424 0C |MOV ESI,DWORD PTR SS:[ESP+C]
//01FB3F0F |. 85F6 |TEST ESI,ESI
//6FC3209B |. 8B7424 0C |MOV ESI,DWORD PTR SS:[ESP+C]
//6FC3209F |. 85F6 |TEST ESI,ESI
//6FCF211B |. 8B7424 0C |MOV ESI,DWORD PTR SS:[ESP+C]
//6FCF211F |. 85F6 |TEST ESI,ESI
log_msg("\n");
}
isInstalled = true;
}
/*================================= END OF FILE =================================*/

219
PlugY/Interface_Skills.cpp Normal file
View File

@ -0,0 +1,219 @@
/*=================================================================
File created by Yohann NICOLAS.
Interface functions
=================================================================*/
#include "common.h"
#include "error.h"
#include "d2functions.h"
#include "updateServer.h" // Install_UpdateServer()
#include "plugYFiles.h" // Install_PlugYImagesFiles()
#include "skillsPoints.h"
#include <stdio.h>
int posXUnassignSkillBtn=-1;
int posYUnassignSkillBtn=-1;
DWORD btnSkillIsDown;
DWORD getXSkillBtn() {return RX(posXUnassignSkillBtn<0? 0x243 : posXUnassignSkillBtn);}
#define getLSkillBtn() 32
DWORD getYSkillBtn() {return RY(posYUnassignSkillBtn<0 ? 0x1B1 : posYUnassignSkillBtn);}
#define getHSkillBtn() 32
#define isOnButtonUnassignSkill(x,y) isOnRect(x, y, getXSkillBtn(), getYSkillBtn(), getLSkillBtn(), getHSkillBtn())
void STDCALL printSkillsPageBtns()
{
if (active_SkillsPoints && !onRealm && D2isLODGame())
{
sDrawImageInfo data;
ZeroMemory(&data,sizeof(data));
setImage(&data, unassignSkillsBtnImages);
setFrame(&data, btnSkillIsDown);
D2PrintImage(&data, getXSkillBtn(), getYSkillBtn(), -1, 5, 0);
if ( isOnButtonUnassignSkill(D2GetMouseX(),D2GetMouseY()))
{
LPWSTR popupText = getTranslatedString(STR_SKILLS_UNASSIGN);
D2PrintPopup(popupText, getXSkillBtn()+getLSkillBtn()/2, getYSkillBtn()-getHSkillBtn(), 0, 1);
}
}
}
Unit* STDCALL skillsPageMouseDown(sWinMessage* msg)
{
Unit* ptChar = D2GetClientPlayer();
if ( active_SkillsPoints && !onRealm && D2isLODGame() && isOnButtonUnassignSkill(D2GetMouseX(),D2GetMouseY()))
{
log_msg("push down left button unassign skill\n");
btnSkillIsDown = 1;
D2PlaySound(4,0,0,0,0);
freeMessage(msg);
return NULL;
}
return ptChar;
}
void STDCALL skillsPageMouseUp()
{
if ( active_SkillsPoints && !onRealm && D2isLODGame() && isOnButtonUnassignSkill(D2GetMouseX(),D2GetMouseY()))
{
log_msg("push up left button unassign skill\n");
if (btnSkillIsDown)
updateServer(US_UNASSIGN_SKILLS);
}
btnSkillIsDown = 0;
}
FCT_ASM ( caller_printSkillsPageBtns_111 )
CALL printSkillsPageBtns
POP EDI
POP ESI
POP EBX
RETN
}}
FCT_ASM ( caller_printSkillsPageBtns )
CALL printSkillsPageBtns
POP EDI
POP ESI
POP EBP
POP EBX
ADD ESP,0x48
RETN
}}
FCT_ASM ( caller_DontPrintSkillPointsRemaining_111 )
MOV AL,BYTE PTR DS:[onRealm]
TEST AL,AL
JNZ dontPrint
ADD DWORD PTR SS:[ESP],0xF2
RETN
dontPrint:
MOV ECX,0x1083
RETN
}}
FCT_ASM ( caller_DontPrintSkillPointsRemaining )
MOV AL,BYTE PTR DS:[onRealm]
TEST AL,AL
JNZ dontPrint
ADD DWORD PTR SS:[ESP],0x9D
RETN
dontPrint:
MOV ECX,0x1083
RETN
}}
FCT_ASM ( caller_skillsPageMouseDown_111 )
PUSH EBP
CALL skillsPageMouseDown
RETN
}}
FCT_ASM ( caller_skillsPageMouseDown )
PUSH EBX
CALL skillsPageMouseDown
RETN
}}
FCT_ASM ( caller_skillsPageMouseUp )
CALL skillsPageMouseUp
JMP D2FreeWinMessage
}}
void Install_InterfaceSkills()
{
static int isInstalled = false;
if (isInstalled) return;
Install_UpdateServer();
Install_PlugYImagesFiles();
log_msg("Patch D2Client for skills interface. (InterfaceSkills)\n");
// Print new buttons images
mem_seek R7(D2Client, 7AC20, 7AC20, 77073, 16190, 8A9C0, 7F320, 77F20);
memt_byte( 0x5F, 0xE9 ); // JMP caller_printBtns
if ( version_D2Client >= V111 ) {
MEMT_REF4( 0xCCC35B5E, caller_printSkillsPageBtns_111);
//6FAC6190 5F POP EDI
//6FAC6191 5E POP ESI
//6FAC6192 5B POP EBX
//6FAC6193 C3 RETN
//6FAC6194 CC INT3
//6FB3A9C0 |> 5F POP EDI
//6FB3A9C1 |. 5E POP ESI
//6FB3A9C2 |. 5B POP EBX
//6FB3A9C3 \. C3 RETN
//6FB3A9C4 CC INT3
//6FB2F320 |> 5F POP EDI
//6FB2F321 |. 5E POP ESI
//6FB2F322 |. 5B POP EBX
//6FB2F323 \. C3 RETN
//6FB2F324 CC INT3
//6FB27F20 |> 5F POP EDI
//6FB27F21 |. 5E POP ESI
//6FB27F22 |. 5B POP EBX
//6FB27F23 \. C3 RETN
//6FB27F24 CC INT3
} else {
MEMT_REF4( 0x835B5D5E, caller_printSkillsPageBtns);
memt_byte( 0xC4, 0x90 ); // NOP
memt_byte( 0x48, 0x90 ); // NOP
memt_byte( 0xC3, 0x90 ); // NOP
//6FB17073 |. 5F POP EDI
//6FB17074 |. 5E POP ESI
//6FB17075 |. 5D POP EBP
//6FB17076 |. 5B POP EBX
//6FB17077 |. 83C4 48 ADD ESP,48
//6FB1707A \. C3 RETN
}
if (posXUnassignSkillBtn==-1 && posYUnassignSkillBtn==-1)
{
// Don't print "Skill Points Remaining"
mem_seek R7(D2Client, 7AC30, 7AC30, 77080, 16294, 8AC74, 7ECF4, 78334);
memt_byte( 0xB9, 0xE8 );
MEMT_REF4( 0x00001083, version_D2Client >= V111 ? caller_DontPrintSkillPointsRemaining_111 : caller_DontPrintSkillPointsRemaining);
//6FB17080 /$ B9 83100000 MOV ECX,1083
//6FAC6294 |. B9 83100000 MOV ECX,1083
//6FB3AC74 |. B9 83100000 MOV ECX,1083
//6FB2ECF4 |. B9 83100000 MOV ECX,1083
//6FB28334 |. B9 83100000 MOV ECX,1083
}
// Manage mouse down (Play sound)
mem_seek R7(D2Client, 7BBD1, 7BBD1, 780E4, 17BC2, 8C6E2, 808B2, 79C62);
memt_byte( 0xC7, 0xE8 ); // CALL caller_skillsPageMouseDown
MEMT_REF4( version_D2Client >= V111 ? 0x00001845 : 0x00001843, version_D2Client >= V111 ? caller_skillsPageMouseDown_111 : caller_skillsPageMouseDown);
memt_byte( 0x00, 0x90 ); // NOP
memt_byte( 0x00, 0x90 ); // NOP
//6FB180E4 > C743 18 00000000 MOV DWORD PTR DS:[EBX+18],0
//6FAC7BC2 > C745 18 00000000 MOV DWORD PTR SS:[EBP+18],0
//6FB3C6E2 > C745 18 00000000 MOV DWORD PTR SS:[EBP+18],0
//6FB308B2 > C745 18 000000>MOV DWORD PTR SS:[EBP+18],0
//6FB29C62 > C745 18 000000>MOV DWORD PTR SS:[EBP+18],0
// Manage mouse up
mem_seek R7(D2Client, 7BC40, 7BC40, 78466, 17558, 8C078, 80248, 795F8);
MEMJ_REF4( D2FreeWinMessage, caller_skillsPageMouseUp);//0xFFF93B0A
//6FB18465 . E8 C07D0400 CALL <JMP.&Storm.#511>
//6FAC7557 .^E9 4248FFFF JMP <JMP.&Storm.#511>
//6FB3C077 .^E9 16FDF7FF JMP <JMP.&Storm.#511>
//6FB30247 .^E9 2CBCF8FF JMP <JMP.&Storm.#511>
//6FB295F7 .^E9 8828F9FF JMP <JMP.&Storm.#511>
log_msg("\n");
isInstalled = true;
}
/*================================= END OF FILE =================================*/

524
PlugY/Interface_Stash.cpp Normal file
View File

@ -0,0 +1,524 @@
/*=================================================================
File created by Yohann NICOLAS.
Interface stats page functions
=================================================================*/
#include "common.h"
#include "error.h"
#include "interface_Stash.h"
#include "d2functions.h"
#include "updateServer.h"
#include "infinityStash.h"
#include "plugYFiles.h" // Install_PlugYImagesFiles()
#include <stdio.h>
static struct
{
union{
DWORD all;
struct{
DWORD previous:1;
DWORD next:1;
DWORD toggleToSharedStash:1;
DWORD previousIndex:1;
DWORD nextIndex:1;
DWORD putGold:1;
DWORD takeGold:1;
};
};
} isDownBtn;
bool displaySharedSetItemNameInGreen = true;
int posXPreviousBtn=-1;
int posYPreviousBtn=-1;
int posXNextBtn=-1;
int posYNextBtn=-1;
int posXSharedBtn=-1;
int posYSharedBtn=-1;
int posXPreviousIndexBtn=-1;
int posYPreviousIndexBtn=-1;
int posXNextIndexBtn=-1;
int posYNextIndexBtn=-1;
int posXPutGoldBtn=-1;
int posYPutGoldBtn=-1;
int posXTakeGoldBtn=-1;
int posYTakeGoldBtn=-1;
DWORD getXPreviousBtn() {return RX(posXPreviousBtn<0? D2GetResolution()?0x80:0xAF : posXPreviousBtn);}
#define getLPreviousBtn() 32
DWORD getYPreviousBtn() {return RY(posYPreviousBtn<0 ? 0x40 : posYPreviousBtn);}
#define getHPreviousBtn() 32
DWORD getXNextBtn() {return RX(posXNextBtn<0 ? D2GetResolution()?0xA0:0xCF :posXNextBtn);}//?169:SEL_X(0x63, 0x63, 0xCF, 0xA0));}
#define getLNextBtn() 32
DWORD getYNextBtn() {return RY(posYNextBtn<0 ? 0x40 : posYNextBtn);}
#define getHNextBtn() 32
DWORD getXSharedBtn() {return RX(posXSharedBtn<0 ? D2GetResolution()?0x10:0x6F :posXSharedBtn);}//17:SEL_X(0xE3, 0xE3, 0x6F, 0x10));}//0xD8
#define getLSharedBtn() 32
DWORD getYSharedBtn() {return RY(posYSharedBtn<0 ? 0x40 : posYSharedBtn);}
#define getHSharedBtn() 32
DWORD getXPreviousIndexBtn() {return RX(posXPreviousIndexBtn<0 ? D2GetResolution()?0x60:0x8F :posXPreviousIndexBtn);}//73:SEL_X(0x18, 0x60, 0x8F, 0x60));}
#define getLPreviousIndexBtn() 32
DWORD getYPreviousIndexBtn() {return RY(posYPreviousIndexBtn<0 ? 0x40 : posYPreviousIndexBtn);}
#define getHPreviousIndexBtn() 32
DWORD getXNextIndexBtn() {return RX(posXNextIndexBtn<0? D2GetResolution()?0xC0:0xEF : posXNextIndexBtn);}//217:SEL_X(0x128, 0xC0, 0xEF, 0xC0));}
#define getLNextIndexBtn() 32
DWORD getYNextIndexBtn() {return RY(posYNextIndexBtn<0 ? 0x40 : posYNextIndexBtn);}
#define getHNextIndexBtn() 32
DWORD getXPutGoldBtn() {return RX(posXPutGoldBtn<0? 0x1C : posXPutGoldBtn);}
#define getLPutGoldBtn() 32
DWORD getYPutGoldBtn() {return RY(posYPutGoldBtn<0 ? 0x1A8 : posYPutGoldBtn);}
#define getHPutGoldBtn() 32
DWORD getXTakeGoldBtn() {return RX(posXTakeGoldBtn<0? 0x105 : posXTakeGoldBtn);}
#define getLTakeGoldBtn() 32
DWORD getYTakeGoldBtn() {return RY(posYTakeGoldBtn<0 ? 0x1A8 : posYTakeGoldBtn);}
#define getHTakeGoldBtn() 32
//closeBtn x: D2C=0x113 LOD=0x110(0->0x28) y: D2C=0x41 LOD=0x40 (-0x23 -> 5)
#define isOnButtonNextStash(x,y) isOnRect(x, y, getXNextBtn(), getYNextBtn(), getLNextBtn(), getHNextBtn())
#define isOnButtonPreviousStash(x,y) isOnRect(x, y, getXPreviousBtn(), getYPreviousBtn(), getLPreviousBtn(), getHPreviousBtn())
#define isOnButtonToggleSharedStash(x,y) isOnRect(x, y, getXSharedBtn(), getYSharedBtn(), getLSharedBtn(), getHSharedBtn())
#define isOnButtonNextIndexStash(x,y) isOnRect(x, y, getXNextIndexBtn(), getYNextIndexBtn(), getLNextIndexBtn(), getHNextIndexBtn())
#define isOnButtonPreviousIndexStash(x,y) isOnRect(x, y, getXPreviousIndexBtn(), getYPreviousIndexBtn(), getLPreviousIndexBtn(), getHPreviousIndexBtn())
#define isOnButtonPutGold(x,y) isOnRect(x, y, getXPutGoldBtn(), getYPutGoldBtn(), getLPutGoldBtn(), getHPutGoldBtn())
#define isOnButtonTakeGold(x,y) isOnRect(x, y, getXTakeGoldBtn(), getYTakeGoldBtn(), getLTakeGoldBtn(), getHTakeGoldBtn())
void* STDCALL printBtns()
{
if (onRealm || !D2isLODGame()) return D2LoadBuySelBtn();
Unit* ptChar = D2GetClientPlayer();
sDrawImageInfo data;
ZeroMemory(&data,sizeof(data));
setImage(&data, stashBtnsImages);
setFrame(&data, 0 + isDownBtn.previous);
D2PrintImage(&data, getXPreviousBtn(), getYPreviousBtn(), -1, 5, 0);
setFrame(&data, 2 + isDownBtn.next);
D2PrintImage(&data, getXNextBtn(), getYNextBtn(), -1, 5, 0);
if (active_sharedStash)
{
setFrame(&data, 4 + isDownBtn.toggleToSharedStash + (PCPY->showSharedStash?2:0) );
D2PrintImage(&data, getXSharedBtn(), getYSharedBtn(), -1, 5, 0);
}
setFrame(&data, 8 + isDownBtn.previousIndex);
D2PrintImage(&data, getXPreviousIndexBtn(), getYPreviousIndexBtn(), -1, 5, 0);
setFrame(&data, 10 + isDownBtn.nextIndex);
D2PrintImage(&data, getXNextIndexBtn(), getYNextIndexBtn(), -1, 5, 0);
if (active_sharedGold)
{
setImage(&data, sharedGoldBtnsImages);
setFrame(&data, 0 + isDownBtn.putGold);
D2PrintImage(&data, getXPutGoldBtn(), getYPutGoldBtn(), -1, 5, 0);
setFrame(&data, 2 + isDownBtn.takeGold);
D2PrintImage(&data, getXTakeGoldBtn(), getYTakeGoldBtn(), -1, 5, 0);
}
LPWSTR lpText;
WCHAR text[100];
DWORD mx = D2GetMouseX();
DWORD my = D2GetMouseY();
D2SetFont(1);
if (isOnButtonPreviousStash(mx,my)) {
lpText = getTranslatedString(STR_STASH_PREVIOUS_PAGE);
D2PrintPopup(lpText, getXPreviousBtn()+getLPreviousBtn()/2, getYPreviousBtn()-getHPreviousBtn(), WHITE, 1);
} else if (isOnButtonNextStash(mx,my)) {
lpText = getTranslatedString(STR_STASH_NEXT_PAGE);
D2PrintPopup(lpText, getXNextBtn()+getLNextBtn()/2, getYNextBtn()-getHNextBtn(), WHITE, 1);
} else if (active_sharedStash && isOnButtonToggleSharedStash(mx,my)) {
lpText = getTranslatedString(PCPY->showSharedStash ? STR_TOGGLE_TO_PERSONAL : STR_TOGGLE_TO_SHARED);
D2PrintPopup(lpText, getXSharedBtn()+getLSharedBtn()/2, getYSharedBtn()-getHSharedBtn(), WHITE, 1);
} else if (isOnButtonPreviousIndexStash(mx,my)) {
swprintf(text, getTranslatedString(STR_STASH_PREVIOUS_INDEX) ,nbPagesPerIndex,nbPagesPerIndex2);
D2PrintPopup(text, getXPreviousIndexBtn()+getLPreviousIndexBtn()/2, getYPreviousIndexBtn()-getHPreviousIndexBtn(), 0, 0);
} else if (isOnButtonNextIndexStash(mx,my)) {
swprintf(text, getTranslatedString(STR_STASH_NEXT_INDEX) ,nbPagesPerIndex,nbPagesPerIndex2);
D2PrintPopup(text, getXNextIndexBtn()+getLNextIndexBtn()/2, getYNextIndexBtn()-getHNextIndexBtn(), WHITE, 1);
} else if (active_sharedGold && isOnButtonPutGold(mx,my)) {
lpText = getTranslatedString(STR_PUT_GOLD);
D2PrintPopup(lpText, getXPutGoldBtn()+getLPutGoldBtn()/2, getYPutGoldBtn()-getHPutGoldBtn(), WHITE, 1);
} else if (active_sharedGold && isOnButtonTakeGold(mx,my)) {
lpText = getTranslatedString(STR_TAKE_GOLD);
D2PrintPopup(lpText, getXTakeGoldBtn()+getLTakeGoldBtn()/2, getYTakeGoldBtn()-getHTakeGoldBtn(), WHITE, 1);
}
return D2LoadBuySelBtn();
}
DWORD STDCALL manageBtnDown(sWinMessage* msg)
{
if (onRealm || !D2isLODGame()) return 0;
if (isOnButtonPreviousStash(msg->x,msg->y))
isDownBtn.previous = 1;
else if (isOnButtonNextStash(msg->x,msg->y))
isDownBtn.next = 1;
else if (active_sharedStash && isOnButtonToggleSharedStash(msg->x,msg->y))
isDownBtn.toggleToSharedStash = 1;
else if (isOnButtonPreviousIndexStash(msg->x,msg->y))
isDownBtn.previousIndex = 1;
else if (isOnButtonNextIndexStash(msg->x,msg->y))
isDownBtn.nextIndex = 1;
else if (active_sharedGold && isOnButtonPutGold(msg->x,msg->y))
isDownBtn.putGold = 1;
else if (active_sharedGold && isOnButtonTakeGold(msg->x,msg->y))
isDownBtn.takeGold = 1;
else return 0;
D2PlaySound(4,0,0,0,0);
freeMessage(msg);
return 1;
}
DWORD STDCALL manageBtnUp(sWinMessage* msg)
{
if (onRealm || !D2isLODGame()) return 0;
Unit* ptChar = D2GetClientPlayer();
if (isOnButtonPreviousStash(msg->x,msg->y)) {
log_msg("push up left button previous\n");
if (isDownBtn.previous)
if (GetKeyState(VK_SHIFT)<0)
updateServer(US_SELECT_PREVIOUS2);
else
updateServer(US_SELECT_PREVIOUS);
} else if (isOnButtonNextStash(msg->x,msg->y)) {
log_msg("push up left button next\n");
if (isDownBtn.next)
if (GetKeyState(VK_SHIFT)<0)
updateServer(US_SELECT_NEXT2);
else
updateServer(US_SELECT_NEXT);
} else if (active_sharedStash && isOnButtonToggleSharedStash(msg->x,msg->y)) {
log_msg("push up left button shared\n");
if (isDownBtn.toggleToSharedStash)
if (PCPY->showSharedStash)
updateServer(US_SELECT_SELF);
else
updateServer(US_SELECT_SHARED);
} else if (isOnButtonPreviousIndexStash(msg->x,msg->y)) {
log_msg("select left button previous index\n");
if (isDownBtn.previousIndex)
if (GetKeyState(VK_SHIFT)<0)
updateServer(US_SELECT_PREVIOUS_INDEX2);
else
updateServer(US_SELECT_PREVIOUS_INDEX);
} else if (isOnButtonNextIndexStash(msg->x,msg->y)) {
log_msg("push up left button next index\n");
if (isDownBtn.nextIndex)
if (GetKeyState(VK_SHIFT)<0)
updateServer(US_SELECT_NEXT_INDEX2);
else
updateServer(US_SELECT_NEXT_INDEX);
} else if (active_sharedGold && isOnButtonPutGold(msg->x,msg->y)) {
log_msg("push up left put gold\n");
if (isDownBtn.putGold)
updateServer(US_PUTGOLD);
} else if (active_sharedGold && isOnButtonTakeGold(msg->x,msg->y)) {
log_msg("push up left take gold\n");
if (isDownBtn.takeGold)
updateServer(US_TAKEGOLD);
} else return 0;
return 1;
}
void FASTCALL printPageNumber(LPWSTR maxGoldText, DWORD x, DWORD y, DWORD color, DWORD bfalse)
{
if (onRealm || !D2isLODGame() )
{
D2PrintString(maxGoldText,x,y,color,bfalse);
return;
}
Unit* ptChar = D2GetClientPlayer();
WCHAR popupText[100];
if (PCPY->currentStash)
{
bool isShared = PCPY->currentStash->isShared;
DWORD currentId = PCPY->currentStash->id;
if (PCPY->currentStash->name && PCPY->currentStash->name[0])
mbstowcs(popupText,PCPY->currentStash->name,50);//strlen(PCPY->currentStash->name)+1
else swprintf(popupText, getTranslatedString( isShared ? STR_SHARED_PAGE_NUMBER : STR_PERSONAL_PAGE_NUMBER), currentId+1);
D2PrintString(popupText,x,y, isShared?RED:WHITE ,bfalse);
} else {
swprintf(popupText, getTranslatedString(STR_NO_SELECTED_PAGE));
D2PrintString(popupText,x,y, WHITE ,bfalse);
}
//printGoldMaxPopup
DWORD mx = D2GetMouseX();
DWORD my = D2GetMouseY();
if ((RX(0x5E) < mx) && (mx < RX(0xF8)) && (RY(0x1C8) < my) && (my < RY(0x1B6)) )
{
if (active_sharedGold)
{
swprintf(popupText, L"%s\n", maxGoldText);
swprintf(popupText+wcslen(popupText), getTranslatedString(STR_SHARED_GOLD_QUANTITY), PCPY->sharedGold);
DWORD x = D2GetPixelLen(maxGoldText);
DWORD x2 = D2GetPixelLen(popupText) - x;
D2PrintPopup(popupText, RX(0xA8-max(x,x2)/2), RY(0x1CA), WHITE, 0);
} else
D2PrintPopup(maxGoldText, RX(0xA8), RY(0x1CA), WHITE, 1);
}
}
static Stash* curStash=NULL;
static DWORD currentSawStash=0;
Unit* STDCALL getNextItemForSet(Unit* ptItem)
{
Unit* item = ptItem?D2UnitGetNextItem(ptItem):NULL;
if (item) return item;
if (!curStash)
{
Unit* ptChar = D2GetClientPlayer();
switch (currentSawStash)
{
case 0: curStash = PCPY->selfStash;
currentSawStash = displaySharedSetItemNameInGreen ? 1 : 2;
break;
case 1: curStash = PCPY->sharedStash;
currentSawStash = 2;
break;
default:return NULL;
}
} else {
curStash = curStash->nextStash;
}
if (curStash)
{
item = curStash->ptListItem;
if (item) return item;
}
return getNextItemForSet(item);
}
Unit* STDCALL initGetNextItemForSet(Inventory* ptInventory)
{
Unit* ptChar = D2GetClientPlayer();
if (ptChar->nUnitType != UNIT_PLAYER) return NULL;
if (!PCPY) return NULL;
curStash = NULL;
currentSawStash = 0;
Unit* item = D2InventoryGetFirstItem(ptInventory);
if (item) return item;
return getNextItemForSet(item);
}
FCT_ASM( caller_manageBtnDown_111 )
PUSH EBP
CALL manageBtnDown
TEST EAX,EAX
JE IS_NOT_ON_BUTTON
POP EDX
MOV EDX, DWORD PTR DS:[EDX+0x10]
MOV DWORD PTR DS:[EDX],1
POP EDI
POP ESI
POP EBP
POP EBX
RETN 4
IS_NOT_ON_BUTTON:
JMP D2ClickOnStashButton
}}
FCT_ASM( caller_manageBtnDown )
PUSH EDI
CALL manageBtnDown
TEST EAX,EAX
JE IS_NOT_ON_BUTTON
POP EDX
MOV EDX, DWORD PTR DS:[EDX+0xF3]
MOV DWORD PTR DS:[EDX],1
POP EDI
POP ESI
POP EBP
POP EBX
RETN 4
IS_NOT_ON_BUTTON:
JMP D2isLODGame
}}
FCT_ASM( caller_manageBtnUp_111 )
PUSH EBX
CALL manageBtnUp
MOV isDownBtn.all,0
TEST EAX,EAX
JE IS_NOT_ON_BUTTON
POP EDX
MOV EDX, DWORD PTR DS:[EDX+0x1A]
MOV DWORD PTR DS:[EDX],0
SUB EDX,8
MOV DWORD PTR DS:[EDX],0
ADD EDX,4
MOV DWORD PTR DS:[EDX],0
ADD EDX,0x68
MOV DWORD PTR DS:[EDX],0
POP EDI
POP ESI
POP EBP
POP EBX
POP ECX
RETN 4
IS_NOT_ON_BUTTON:
JMP D2ClickOnStashButton
}}
FCT_ASM( caller_manageBtnUp )
PUSH EBP
CALL manageBtnUp
MOV isDownBtn.all,0
TEST EAX,EAX
JE IS_NOT_ON_BUTTON
POP EDX
MOV EDX, DWORD PTR DS:[EDX+0xEA]
MOV DWORD PTR DS:[EDX],0
SUB EDX,8
MOV DWORD PTR DS:[EDX],0
ADD EDX,4
MOV DWORD PTR DS:[EDX],0
ADD EDX,0x68
MOV DWORD PTR DS:[EDX],0
POP EDI
POP ESI
POP EBP
POP EBX
RETN 4
IS_NOT_ON_BUTTON:
JMP D2isLODGame
}}
FCT_ASM ( initBtnsStates )
MOV isDownBtn.all,0
ADD ESP,0x104
RETN
}}
void Install_InterfaceStash()
{
static int isInstalled = false;
if (isInstalled) return;
Install_UpdateServer();
Install_PlugYImagesFiles();
log_msg("Patch D2Client for stash interface. (InterfaceStash)\n");
// Print button images
mem_seek R7(D2Client, 39060, 39060, 3F399, B1006, 7DF86, B3656, 99A56);
MEMC_REF4( D2LoadBuySelBtn, printBtns);
//6FADF398 |. E8 734D0400 CALL D2Client.6FB24110
//6FB61005 |. E8 A6D3FEFF CALL D2Client.6FB4E3B0
//6FB2DF85 |. E8 3642FEFF CALL D2Client.6FB121C0
//6FB63655 |. E8 9682FDFF CALL D2Client.6FB3B8F0
//6FB49A55 |. E8 96500200 CALL D2Client.6FB6EAF0
// print page number
mem_seek R7(D2Client, 3903C, 3903C, 3F375, B0FE3, 7DF63, B3633, 99A33);
MEMJ_REF4( D2PrintString, printPageNumber);
//6FADF374 |. E8 3FCC0800 CALL <JMP.&D2Win.#10117>
//6FB60FE2 |. E8 99C2F5FF CALL <JMP.&D2Win.#10020>
//6FB2DF62 |. E8 19F3F8FF CALL <JMP.&D2Win.#10064>
//6FB63632 |. E8 299DF5FF CALL <JMP.&D2Win.#10001>
//6FB49A32 |. E8 4739F7FF CALL <JMP.&D2Win.#10150>
// Manage mouse down (Play sound)
mem_seek R7(D2Client, 45091, 45091, 4BBA1, B4666, 7FDD6, B54A6, 9B8A6);
MEMC_REF4( version_D2Client >= V111 ? (DWORD)D2ClickOnStashButton : (DWORD)D2isLODGame, version_D2Client >= V111 ? caller_manageBtnDown_111 : caller_manageBtnDown);
//6FAEBBA0 > E8 DB04FCFF CALL D2Client.6FAAC080
//6FB64665 . E8 B61EFFFF CALL D2Client.6FB56520
//6FB2FDD5 . E8 E612FFFF CALL D2Client.6FB210C0
//6FB654A5 . E8 9611FFFF CALL D2Client.6FB56640
//6FB4B8A5 . E8 5614FFFF CALL D2Client.6FB3CD00
// Manage mouse up
mem_seek R7(D2Client, 455F9, 455F9, 4C0F9, B57B9, 7FC09, B52D9, 9B6D9);
MEMC_REF4( version_D2Client >= V111 ? (DWORD)D2ClickOnStashButton : (DWORD)D2isLODGame, version_D2Client >= V111 ? caller_manageBtnUp_111 : caller_manageBtnUp);
//6FAEC0F8 > E8 83FFFBFF CALL D2Client.6FAAC080
//6FB657B8 > E8 630DFFFF CALL D2Client.6FB56520
//6FB2FC08 > E8 B314FFFF CALL D2Client.6FB210C0
//6FB652D8 > E8 6313FFFF CALL D2Client.6FB56640
//6FB4B6D8 > E8 2316FFFF CALL D2Client.6FB3CD00
// init state of button on open stash page
mem_seek R7(D2Client, 45B3A, 45B3A, 4C63A, A645A, 749DA, A9D9A, 8CC3A);
memt_byte( 0x81, 0xE9 ); // CALL initBtnsStates
MEMT_REF4( 0x000104C4, initBtnsStates);
memt_byte( 0x00, 0x90 );
//6FAE5B3A |> 81C4 04010000 ADD ESP,104
//6FAE5B3A |> 81C4 04010000 ADD ESP,104
//6FAEC63A |> 81C4 04010000 ADD ESP,104
//6FB5645A |> 81C4 04010000 ADD ESP,104
//6FB249DA |> 81C4 04010000 ADD ESP,104
//6FB59D9A |> 81C4 04010000 ADD ESP,104
//6FB3CC3A |> 81C4 04010000 ADD ESP,104
// init the search of print in green the item set name we have in stash
mem_seek R7(D2Client, 3F098, 3F098, 45997, A71F4, 71F64, A7314, 8D434);
MEMJ_REF4( D2InventoryGetFirstItem, initGetNextItemForSet);
//6FAE5996 |. E8 D5500800 CALL <JMP.&D2Common.#10277>
//6FB571F3 |. E8 D64EF6FF CALL <JMP.&D2Common.#10402>
//6FB21F63 |. E8 96A1F9FF CALL <JMP.&D2Common.#10535>
//6FB57313 |. E8 8250F6FF CALL <JMP.&D2Common.#11151>
//6FB3D433 |. E8 B8F0F7FF CALL <JMP.&D2Common.#10460>
// Get next item for print in green the item set name we have in stash
mem_seek R7(D2Client, 3F0FA, 3F0FA, 45A1C, A728B, 71FFB, A73AB, 8D4CB);
MEMJ_REF4( D2UnitGetNextItem, getNextItemForSet);
//6FAE5A1B E8 4A500800 CALL <JMP.&D2Common.#10304>
//6FB5728A |. E8 0B4FF6FF |CALL <JMP.&D2Common.#10934>
//6FB21FFA |. E8 A1A1F9FF |CALL <JMP.&D2Common.#11140>
//6FB573AA |. E8 7550F6FF |CALL <JMP.&D2Common.#10770>
//6FB3D4CA |. E8 99F0F7FF |CALL <JMP.&D2Common.#10464>
log_msg("\n");
isInstalled = true;
}
/*================================= END OF FILE =================================*/

318
PlugY/Interface_Stats.cpp Normal file
View File

@ -0,0 +1,318 @@
/*=================================================================
File created by Yohann NICOLAS.
Interface functions
=================================================================*/
#include "common.h"
#include "error.h"
#include "d2functions.h"
#include "plugYFiles.h" // Install_PlugYImagesFiles()
#include "statsPoints.h"
#include "newInterfaces.h"
#include <stdio.h>
static struct
{
union{
DWORD all;
struct{
DWORD previousPage:1;
DWORD nextPage:1;
};
};
} isDownBtn;
#define getXPreviousPageBtn() RX(0x19)//0x70
#define getLPreviousPageBtn() 32
#define getYPreviousPageBtn() RY(0x40)
#define getHPreviousPageBtn() 32
#define isOnPreviousPageBtn(x,y) isOnRect(x, y, getXPreviousPageBtn(), getYPreviousPageBtn(), getLPreviousPageBtn(), getHPreviousPageBtn())
#define getXNextPageBtn() RX(D2GetResolution()?0x43:0x8A)
#define getLNextPageBtn() 32
#define getYNextPageBtn() RY(D2GetResolution()?0x40:0x70)
#define getHNextPageBtn() 32
#define isOnNextPageBtn(x,y) isOnRect(x, y, getXNextPageBtn(), getYNextPageBtn(), getLNextPageBtn(), getHNextPageBtn())
void STDCALL printStatsPageBtns()
{
if (!active_newInterfaces || !D2isLODGame() ) return;
LPWSTR lpText;
DWORD mx = D2GetMouseX();
DWORD my = D2GetMouseY();
sDrawImageInfo data;
ZeroMemory(&data,sizeof(data));
if (printBackgroundOnMainPage && D2GetResolution())
{
setImage(&data, statsBackgroundImages);
setFrame(&data, 1);
D2PrintImage(&data, getXPreviousPageBtn()-7, getYPreviousPageBtn()+8, -1, 5, 0);
}
setImage(&data, D2LoadBuySelBtn());
if (D2GetResolution())
{
setFrame(&data, 12 + isDownBtn.previousPage);
D2PrintImage(&data, getXPreviousPageBtn(), getYPreviousPageBtn(), -1, 5, 0);
}
setFrame(&data, 14 + isDownBtn.nextPage);
D2PrintImage(&data, getXNextPageBtn(), getYNextPageBtn(), -1, 5, 0);
D2SetFont(1);
if (D2GetResolution() && isOnPreviousPageBtn(mx,my)) //print popup "previous page"
{
lpText = getTranslatedString(STR_PREVIOUS_PAGE);
D2PrintPopup(lpText, getXPreviousPageBtn()+getLPreviousPageBtn()/2, getYPreviousPageBtn()-getHPreviousPageBtn(), WHITE, 1);
}
else if ( isOnNextPageBtn(mx,my))
{
lpText = getTranslatedString(STR_NEXT_PAGE);
D2PrintPopup(lpText, getXNextPageBtn()+getLNextPageBtn()/2, getYNextPageBtn()-getHNextPageBtn(), WHITE, 1);
}
}
Unit* STDCALL statsPageMouseDown(sWinMessage* msg)
{
Unit* ptChar = D2GetClientPlayer();
if (!active_newInterfaces || !D2isLODGame() ) return ptChar;
if (D2GetResolution() && isOnPreviousPageBtn(msg->x,msg->y))
{
log_msg("push down left button previous page\n");
isDownBtn.previousPage = 1;
D2PlaySound(4,0,0,0,0);
freeMessage(msg);
return NULL;
}
else if (isOnNextPageBtn(msg->x,msg->y))
{
log_msg("push down left button next page\n");
isDownBtn.nextPage = 1;
D2PlaySound(4,0,0,0,0);
freeMessage(msg);
return NULL;
}
return ptChar;
}
Unit* STDCALL statsPageMouseUp(sWinMessage* msg)
{
Unit* ptChar = D2GetClientPlayer();
if (!active_newInterfaces || !D2isLODGame() ) return ptChar;
if (D2GetResolution() && isOnPreviousPageBtn(msg->x,msg->y))
{
log_msg("push up left button previous page\n");
if (isDownBtn.previousPage)
{
GoPreviousStatPage();
log_msg("previous page press\n");
isDownBtn.all=0;
freeMessage(msg);
return NULL;
}
}
else if (isOnNextPageBtn(msg->x,msg->y))
{
log_msg("push up left button next page\n");
if (isDownBtn.nextPage)
{
GoNextStatPage();
log_msg("next page press\n");
isDownBtn.all=0;
freeMessage(msg);
return NULL;
}
}
isDownBtn.all=0;
return ptChar;
}
FCT_ASM ( caller_printStatsPageBtns_111 )
CALL printStatsPageBtns
POP EDI
POP ESI
POP EBP
POP EBX
ADD ESP,0x370
RETN
}}
FCT_ASM ( caller_printStatsPageBtns )
CALL printStatsPageBtns
POP EDI
POP ESI
POP EBP
POP EBX
ADD ESP,0x3B0
RETN
}}
FCT_ASM ( caller_printStatsPageBtns_9 )
CALL printStatsPageBtns
POP EDI
POP ESI
POP EBP
POP EBX
ADD ESP,0x374
RETN
}}
FCT_ASM ( caller_statsPageMouseDown_111 )
PUSH DWORD PTR SS:[ESP+0x20]
CALL statsPageMouseDown
TEST EAX,EAX
JE fin_statsPageMouseDown
RETN
fin_statsPageMouseDown:
ADD ESP,4
POP EDI
POP ESI
POP EBP
POP EBX
RETN 4
}}
FCT_ASM ( caller_statsPageMouseDown )
PUSH DWORD PTR SS:[ESP+0x18]
CALL statsPageMouseDown
TEST EAX,EAX
JE fin_statsPageMouseDown
RETN
fin_statsPageMouseDown:
ADD ESP,4
POP EDI
POP ESI
POP EBP
POP EBX
RETN 4
}}
FCT_ASM ( caller_statsPageMouseUp )
PUSH EBP
CALL statsPageMouseUp
TEST EAX,EAX
JE fin_statsPageMouseUp
RETN
fin_statsPageMouseUp:
ADD ESP,4
POP EDI
POP ESI
POP EBP
POP EBX
ADD ESP,8
RETN 4
}}
FCT_ASM ( caller_statsPageMouseUp_9 )
PUSH EBP
CALL statsPageMouseUp
TEST EAX,EAX
JE fin_statsPageMouseUp
RETN
fin_statsPageMouseUp:
ADD ESP,4
POP EDI
POP ESI
POP EBP
POP EBX
POP ECX
RETN 4
}}
void Install_InterfaceStats()
{
static int isInstalled = false;
if (isInstalled) return;
Install_PlugYImagesFiles();
log_msg("Patch D2Client for stats interface. (InterfaceStats)\n");
// Print new buttons images
mem_seek R7(D2Client, 2A7BE, 2A7AE, 30F86, 83636, 8A0B6, 6C016, BDC16);
memt_byte( 0x5F, 0xE9 ); // JMP
MEMT_REF4( 0x815B5D5E, version_D2Client >= V111 ? caller_printStatsPageBtns_111: version_D2Client == V110 ? caller_printStatsPageBtns : caller_printStatsPageBtns_9);
//6FAD0F86 . 5F POP EDI
//6FAD0F87 . 5E POP ESI
//6FAD0F88 . 5D POP EBP
//6FAD0F89 . 5B POP EBX
//6FAD0F8A . 81C4 B0030000 ADD ESP,3B0
//6FAD0F90 . C3 RETN
//6FB33636 . 5F POP EDI
//6FB33637 . 5E POP ESI
//6FB33638 . 5D POP EBP
//6FB33639 . 5B POP EBX
//6FB3363A . 81C4 70030000 ADD ESP,370
//6FB33640 . C3 RETN
//6FB3A0B6 . 5F POP EDI
//6FB3A0B7 . 5E POP ESI
//6FB3A0B8 . 5D POP EBP
//6FB3A0B9 . 5B POP EBX
//6FB3A0BA . 81C4 70030000 ADD ESP,370
//6FB3A0C0 . C3 RETN
//6FB1C016 . 5F POP EDI
//6FB1C017 . 5E POP ESI
//6FB1C018 . 5D POP EBP
//6FB1C019 . 5B POP EBX
//6FB1C01A . 81C4 70030000 ADD ESP,370
//6FB1C020 . C3 RETN
//6FB6DC16 |. 5F POP EDI
//6FB6DC17 |. 5E POP ESI
//6FB6DC18 |. 5D POP EBP
//6FB6DC19 |. 5B POP EBX
//6FB6DC1A |. 81C4 70030000 ADD ESP,370
//6FB6DC20 \. C3 RETN
if ( version_D2Client >= V111 )
{
// Manage mouse down (Play sound)
mem_seek R7(D2Client, 2AA6D, 2AA5D, 3133D, 827C8, 89248, 6B1A8, BCDC8);
memt_byte( 0xA1, 0xE8 );
MEMT_REF4( ptptClientChar, caller_statsPageMouseDown);
//6FB327C8 . A1 F0C4BC6F MOV EAX,DWORD PTR DS:[6FBCC4F0]
//6FB39248 . A1 E0C1BC6F MOV EAX,DWORD PTR DS:[6FBCC1E0]
//6FB1B1A8 . A1 D0C3BC6F MOV EAX,DWORD PTR DS:[6FBCC3D0]
//6FB6CDC8 . A1 FCBBBC6F MOV EAX,DWORD PTR DS:[6FBCBBFC]
// Manage mouse up
mem_seek R7(D2Client, 2AC43, 2AC33, 3151A, 83853, 8A2D3, 6C233, BDE33);
memt_byte( 0xA1, 0xE8 );
MEMT_REF4( ptptClientChar, caller_statsPageMouseUp);
//6FB33853 . A1 F0C4BC6F MOV EAX,DWORD PTR DS:[6FBCC4F0]
//6FB3A2D3 . A1 E0C1BC6F MOV EAX,DWORD PTR DS:[6FBCC1E0]
//6FB1C233 . A1 D0C3BC6F MOV EAX,DWORD PTR DS:[6FBCC3D0]
//6FB6DE33 . A1 FCBBBC6F MOV EAX,DWORD PTR DS:[6FBCBBFC]
} else {
// Manage mouse down (Play sound)
mem_seek R7(D2Client, 2AA6D, 2AA5D, 3133D, 827C8, 89248, 6B1A8, 0000);
MEMC_REF4( D2GetClientPlayer, caller_statsPageMouseDown);
//6FAD133C . E8 8F700500 CALL D2Client.6FB283D0
// Manage mouse up
mem_seek R7(D2Client, 2AC43, 2AC33, 3151A, 83853, 8A2D3, 6C233, 0000);
MEMC_REF4( D2GetClientPlayer, version_D2Client == V110 ? caller_statsPageMouseUp : caller_statsPageMouseUp_9);//0x00056EB2
//6FAD1519 . E8 B26E0500 CALL D2Client.6FB283D0
}
log_msg("\n");
isInstalled = true;
}
/*================================= END OF FILE =================================*/

57
PlugY/Language.cpp Normal file
View File

@ -0,0 +1,57 @@
/*=================================================================
File created by Yohann NICOLAS.
Language management.
=================================================================*/
#include "common.h"
#include "error.h"
#include "d2functions.h"
#include "language.h"
#include <stdio.h>
bool active_ChangeLanguage = true;
DWORD selectedLanguage = LNG_ENG;
bool active_LanguageManagement = false;
DWORD defaultLanguage = LNG_ENG;
t_availableLanguages availableLanguages;
DWORD* ptCurrentLanguage;
DWORD STDCALL languageManagement ()
{
if (active_ChangeLanguage) *ptCurrentLanguage = selectedLanguage;
if (active_LanguageManagement)
if ((*ptCurrentLanguage > LNG_RUS) || !((1 << *ptCurrentLanguage) & availableLanguages.all))
*ptCurrentLanguage = defaultLanguage;
return *ptCurrentLanguage;
}
void Install_LanguageManagement()
{
static int isInstalled = false;
if (isInstalled) return;
log_msg("Patch D2Lang for language management. (LanguageManagement)\n");
ptCurrentLanguage = *(DWORD**)((DWORD)D2GetLang + (version_D2Lang >= V111 ? 0x51: 0x5C));
// Language management
mem_seek( (DWORD)D2GetLang + (version_D2Lang >= V111 ? 0x3E : 0x49));//6FC13E39-6FC10000
memt_byte( 0xA1 , 0xE8);
MEMT_REF4( ptCurrentLanguage, languageManagement);
//6FC13E39 |. A1 EC0CC26F MOV EAX,DWORD PTR DS:[6FC20CEC]
//003D91FE |. A1 1C0A3E00 MOV EAX,DWORD PTR DS:[3E0A1C]
//003DA0AE |. A1 1C0A3E00 MOV EAX,DWORD PTR DS:[3E0A1C]
log_msg("\n");
isInstalled = true;
}
/*================================= END OF FILE =================================*/

566
PlugY/LoadPlayerData.cpp Normal file
View File

@ -0,0 +1,566 @@
/*=================================================================
File created by Yohann NICOLAS.
Load Player Custom Data.
=================================================================*/
#include "common.h"
#include "error.h"
#include "d2functions.h"
#include "infinityStash.h"
#include "extendedSaveFile.h"
#include "sharedSaveFile.h"
/************************************ LOADING ***********************************/
DWORD STDCALL LoadSPCustomData(Unit* ptChar)
{
DWORD size = 0;
BYTE* data;
log_msg("--- Start LoadSPCustomData ---\n");
if (!ptChar)
{log_msg("LoadSPCustomData : ptChar == NULL\n");return 0x1B;}//Unknow failure
if (ptChar->nUnitType != UNIT_PLAYER)
{log_msg("LoadSPCustomData : ptChar->nUnitType != UNIT_PLAYER\n");return 0x1B;}//Unknow failure
if (!PCPlayerData)
{log_msg("LoadSPCustomData : PCPlayerData == NULL\n");return 0x1B;}//Unknow failure
if (!PCGame)
{log_msg("LoadSPCustomData : PCGame == NULL\n");return 0x1B;}//Unknow failure
DWORD ret=0;
if (PCGame->isLODGame)
{
log_msg("is LOD Game\n");
data = readExtendedSaveFile(PCPlayerData->name, &size);
ret = loadExtendedSaveFile(ptChar, data, size);
D2FogMemDeAlloc(data,__FILE__,__LINE__,0);
if (!ret)
{
data = readSharedSaveFile(PCPlayerData->name, &size);
ret = loadSharedSaveFile(ptChar, data, size);
D2FogMemDeAlloc(data,__FILE__,__LINE__,0);
}
} else {
log_msg("is not LOD Game\n");
}
log_msg("End LoadSPCustomData.\n\n");
return ret;
}
FCT_ASM (caller_LoadSPPlayerCustomData )
MOV ESI,EAX
TEST ESI,ESI
JNZ JMP_LoadSPPlayerCustomData
PUSH DWORD PTR SS:[ESP+0x14]
CALL LoadSPCustomData
MOV ESI,EAX
TEST ESI,ESI
JNZ JMP_LoadSPPlayerCustomData
RETN
JMP_LoadSPPlayerCustomData:
ADD DWORD PTR SS:[ESP],0x17
RETN
}}
/*
return value :
0:ok
1:Unable to enter game. Bad character version
2:Unable to enter game. Bad character quest data
3:Unable to enter game. Bad character waypoint data
4:Unable to enter game. Bad character stats data
5:Unable to enter game. Bad character skills data
6:Unable to enter game
7:Unable to enter game. Bad inventory data
8:Unable to enter game. Bad dead bodies
9:Unable to enter game. Bad header
0A:Unable to enter game. bad hireables
0B:Unable to enter game, bad intro data
0C:Unable to enter game. bad item
0D:Unable to enter game, bad dead body item
0E:Unable to enter game, generic bad file
0F:Game is full
10:Version do not match....
11:Unable to enter game,Your character must kill Baal to play nightmare game
12:Unable to enter game,Your character must kill Baal in nightmare difficulty to play hell game
13:Unable to enter game, a normal character cannot join a game create an harcore character.
14:Unable to enter game, an harcore character cannot join a game create by a normal character.
15:A dead character cannot join or create any game
16:unknow failure
17:Unable to enter game. A D2 Character cannot join an expansion character
18:Expansion cannot join D2
19:Failures to join game
1A:Unable to enter game
1B:unknow failure
*/
enum {
TS_SAVE_PERSONAL=0,
TS_SAVE_SHARED,
TS_PUTGOLD,
TS_TAKEGOLD
};
#pragma pack(1)
typedef struct {
BYTE packID;
BYTE packSize;
DWORD finalSize:31;
DWORD isCustom:1;
BYTE type;
BYTE data[0xFF];
} t_rcvMsg;
#pragma pack()
struct s_MPSaveFile
{
DWORD clientID;
int sizeExtended;
int curExtended;
BYTE* dataExtended;
int sizeShared;
int curShared;
BYTE* dataShared;
s_MPSaveFile* prev;
s_MPSaveFile* next;
bool completed;
};
static BYTE customPackID = 0x6C;
static s_MPSaveFile * receivedSaveFiles = NULL;
void freeCurrentCF(DWORD memoryPool, s_MPSaveFile** curSF)
{
if (*curSF == NULL) return;
D2FreeMem(memoryPool, (*curSF)->dataExtended,__FILE__,__LINE__,0);
D2FreeMem(memoryPool, (*curSF)->dataShared,__FILE__,__LINE__,0);
if ((*curSF)->next)
(*curSF)->next->prev = (*curSF)->prev;
if ((*curSF)->prev)
(*curSF)->prev->next = (*curSF)->next;
else
receivedSaveFiles = (*curSF)->next;
D2FreeMem(memoryPool, *curSF,__FILE__,__LINE__,0);
*curSF = NULL;
}
void sendData(BYTE* data, DWORD size, bool isShared)
{
t_rcvMsg pack;
// d2_assert(size >= 0x40000000, "size of file > 0x40000000", __FILE__, __LINE__);
pack.packID = customPackID;
pack.finalSize = size;
pack.isCustom = true;
pack.type = isShared ? TS_SAVE_SHARED : TS_SAVE_PERSONAL;
DWORD sended = 0;
while (sended < size)
{
pack.packSize = (BYTE) (size - sended > 0xFE ? 0xFF : size - sended + 1);
CopyMemory(pack.data, &data[sended], pack.packSize);
log_msg("Loading Send Packet: \ttype=%X\t finalSize=%X\t packSize=%02X\t data=%08X\n", pack.type, pack.finalSize, pack.packSize, pack.data);
D2SendToServer(pack.packSize+7, 0, &pack);
sended += pack.packSize -1;
}
log_msg("\n");
}
static DWORD sizeExtended;
static BYTE* dataExtended;
static DWORD sizeShared;
static BYTE* dataShared;
void FASTCALL SendSaveFiles (char* ptPath, DWORD maxsize, char* name)
{
// DWORD size;
// BYTE* data;
D2FogGetSavePath(ptPath,maxsize);
log_msg("\n--- Start SendSaveFiles ---\n");
// Send Extended Save File
log_msg("Send Extended Save File\n");
dataExtended = readExtendedSaveFile(name, &sizeExtended);
sendData(dataExtended, sizeExtended, false);
D2FogMemDeAlloc(dataExtended,__FILE__,__LINE__,0);
// Send Shared Save File
log_msg("Send Shared Save File\n");
dataShared = readSharedSaveFile(name, &sizeShared);
sendData(dataShared, sizeShared, true);
D2FogMemDeAlloc(dataShared,__FILE__,__LINE__,0);
// Ending load
log_msg("End SendSaveFiles.\n\n");
}
DWORD STDCALL ReceiveSaveFiles (DWORD clientID, t_rcvMsg* msg)
{
if( (msg->packID != customPackID) || !msg->isCustom) return msg->packID;
log_msg("Loading Receive Packet: clientID=%d\t type=%X\t finalSize=%X\t packSize=%02X\t data=%08X\n", clientID, msg->type, msg->finalSize, msg->packSize, msg->data);
bool isShared;
switch (msg->type)
{
case TS_SAVE_PERSONAL : isShared = false;break;
case TS_SAVE_SHARED : isShared = true;break;
// case TS_PUTGOLD : putGold(ptChar, (DWORD)msg->data); return 0;
// case TS_TAKEGOLD : takeGold(ptChar, (DWORD)msg->data); return 0;
default: return 0;//return msg->packID;
}
NetClient* ptClient = ptClientTable[clientID & 0xFF];
s_MPSaveFile* curSF = receivedSaveFiles;
while (curSF && (clientID != curSF->clientID) )
curSF = curSF->next;
if (curSF && curSF->completed)
freeCurrentCF(0 * PClientGame->memoryPool, &curSF);
if (!curSF)
{
curSF = (s_MPSaveFile *)D2AllocMem(0 * PClientGame->memoryPool, sizeof(s_MPSaveFile),__FILE__,__LINE__,0);
ZeroMemory(curSF, sizeof(s_MPSaveFile));
curSF->clientID = clientID;
curSF->next = receivedSaveFiles;
if (receivedSaveFiles) receivedSaveFiles->prev = curSF;
receivedSaveFiles = curSF;
}
log_msg("curSF = %08X\tcurSF->completed = %d\n", curSF, curSF->completed);
DWORD size = msg->packSize - 1;
if (isShared)
{
if (curSF->sizeShared == 0)
curSF->sizeShared = msg->finalSize;
d2_assert(curSF->sizeShared != msg->finalSize, "Size of shared file has change", __FILE__, __LINE__);
if (!curSF->dataShared)
curSF->dataShared = (BYTE *)D2AllocMem(0 * PClientGame->memoryPool, curSF->sizeShared,__FILE__,__LINE__,0);// d2_assert(!curSF->dataShared, "Can't malloc data", __FILE__, __LINE__);
CopyMemory(&curSF->dataShared[curSF->curShared], msg->data, size);
curSF->curShared += size;
} else {
if (curSF->sizeExtended == 0)
curSF->sizeExtended = msg->finalSize;
d2_assert(curSF->sizeExtended != msg->finalSize, "Size of extented file has change", __FILE__, __LINE__);
if (!curSF->dataExtended)
curSF->dataExtended = (BYTE *)D2AllocMem( 0 * PClientGame->memoryPool, curSF->sizeExtended,__FILE__,__LINE__,0);// d2_assert(!curSF->dataExtended, "Can't malloc data", __FILE__, __LINE__);
CopyMemory(&curSF->dataExtended[curSF->curExtended], msg->data, size);
curSF->curExtended += size;
}
if( curSF->sizeExtended && (curSF->sizeExtended == curSF->curExtended) && curSF->sizeShared && (curSF->sizeShared == curSF->curShared) )
{
curSF->completed = true;
log_msg("ReceiveSaveFiles completed.\n");
}
log_msg("End Load Receive Packet\n");
return msg->packID+10;
}
/*
typedef int (STDCALL * t_fct_recv)(SOCKET s, char *buf, int len, int flags);
t_fct_recv fct_recv;
int STDCALL ReceiveSaveFiles_9(DWORD clientID, SOCKET s, char *buf, int len, int flags)
{
t_rcvMsg* msg = (t_rcvMsg*) buf;
int nb = fct_recv(s,buf,len,flags);
if ((nb<6) || (msg->packID != customPackID) || !msg->isCustom || (msg->packSize+7 != nb))
return nb;
ReceiveSaveFiles(clientID,msg);
msg->packSize = 1;
return 7;
}*/
DWORD STDCALL LoadMPCustomData(Unit* ptChar)
{
log_msg("Start LoadMPCustomData\n");
if (!ptChar) return NULL;
if (!ptChar)
{log_msg("LoadMPCustomData : ptChar == NULL\n");return 0x1B;}//Unknow failure
if (ptChar->nUnitType != UNIT_PLAYER)
{log_msg("LoadMPCustomData : ptChar->nUnitType != UNIT_PLAYER\n");return 0x1B;}//Unknow failure
if (!PCPlayerData)
{log_msg("LoadMPCustomData : PCPlayerData == NULL\n");return 0x1B;}//Unknow failure
NetClient* ptClient = D2GetClient(ptChar,__FILE__,__LINE__);
s_MPSaveFile* curSF = receivedSaveFiles;
while (curSF && (ptClient->clientID != curSF->clientID) )
curSF = curSF->next;
DWORD ret=0;
if (!curSF)
{
log_msg("Server has received no data from extra save files of character %s\n", PCPlayerData->name);
ret = 0xE;//Unable to enter game, generic bad file
}
if (!ret && !curSF->completed)
{
log_msg("Server hasn't receive all data from extra save files of character %s\n",PCPlayerData->name);
ret = 0xE;//Unable to enter game, generic bad file
}
if (!ret && !PCGame)
{
log_msg("LoadMPCustomData : PCGame == NULL\n");
ret = 0x1B;//Unknow failure
}
if (PCGame->isLODGame)
{
log_msg("is LOD Game\n");
if (!ret)
ret = loadExtendedSaveFile(ptChar, curSF->dataExtended, curSF->sizeExtended);
if (!ret)
ret = loadSharedSaveFile(ptChar, curSF->dataShared, curSF->sizeShared);
} else {
log_msg("is not LOD Game\n");
}
freeCurrentCF(PCGame->memoryPool, &curSF);
log_msg("--- End LoadMPCustomData. ---\n\n");
return ret;
}
FCT_ASM ( caller_LoadMPPlayerCustomData_111 )
PUSH DWORD PTR SS:[EBX]
CALL LoadMPCustomData
TEST EAX,EAX
JNZ JMP_LoadMPlayerCustomData
CMP DWORD PTR DS:[EBX],0
JNZ Continue_LoadMP
ADD DWORD PTR SS:[ESP],0x21
Continue_LoadMP:
RETN
JMP_LoadMPlayerCustomData:
SUB DWORD PTR SS:[ESP],0x12
RETN
}}
FCT_ASM ( caller_LoadMPPlayerCustomData )
PUSH DWORD PTR SS:[EDI]
CALL LoadMPCustomData
TEST EAX,EAX
JNZ JMP_LoadMPlayerCustomData
CMP DWORD PTR DS:[EDI],0
JNZ Continue_LoadMP
ADD DWORD PTR SS:[ESP],0x46
Continue_LoadMP:
RETN
JMP_LoadMPlayerCustomData:
SUB DWORD PTR SS:[ESP],0xD
RETN
}}
FCT_ASM ( caller_LoadMPPlayerCustomData_9 )
PUSH DWORD PTR SS:[EDI]
CALL LoadMPCustomData
TEST EAX,EAX
JNZ JMP_LoadMPlayerCustomData
CMP DWORD PTR DS:[EDI],0
JNZ Continue_LoadMP
ADD DWORD PTR SS:[ESP],0x1D
Continue_LoadMP:
RETN
JMP_LoadMPlayerCustomData:
SUB DWORD PTR SS:[ESP],0x13
RETN
}}
FCT_ASM ( caller_SendSaveFiles_111 )
POP EAX
PUSH DWORD PTR CS:[EAX+0x01] //"name"
PUSH EAX
JMP SendSaveFiles
}}
FCT_ASM ( caller_SendSaveFiles )
POP EAX
PUSH DWORD PTR CS:[EAX+0x0F] //"name"
PUSH EAX
JMP SendSaveFiles
}}
FCT_ASM ( caller_ReceiveSaveFiles_111 )
PUSH ECX
PUSH EDX
LEA EBX,DWORD PTR DS:[EBP+4]
PUSH EBX //Message
MOV EBX,DWORD PTR SS:[EBP]
PUSH EBX //ID client
CALL ReceiveSaveFiles
POP EDX
POP ECX
RETN
}}
FCT_ASM ( caller_ReceiveSaveFiles )
PUSH ECX
PUSH EDX
LEA EDI,DWORD PTR DS:[ESI+4]
PUSH EDI //Message
MOV EDI,DWORD PTR DS:[ESI]
PUSH EDI //ID client
CALL ReceiveSaveFiles
POP EDX
POP ECX
RETN
}}
FCT_ASM ( caller_BugFix109b )
MOV EAX,DWORD PTR DS:[EDI+0xBD0]
TEST EAX,EAX
JE go_to_default
MOV EAX,DWORD PTR SS:[ESP+0x20]
MOV DWORD PTR SS:[ESP+0x24],EAX
RETN
go_to_default:
SUB DWORD PTR SS:[ESP],0x4B
RETN
}}
FCT_ASM ( caller_BugFix109d )
MOV EAX,DWORD PTR DS:[ESI+0xAB0]
TEST EAX,EAX
JE go_to_default
MOV EAX,DWORD PTR SS:[ESP+0x20]
MOV DWORD PTR SS:[ESP+0x24],EAX
RETN
go_to_default:
SUB DWORD PTR SS:[ESP],0x4B
RETN
}}
void Install_LoadPlayerData()
{
static int isInstalled = false;
if (isInstalled || !active_PlayerCustomData) return;
log_msg("Patch D2Game & D2Client for load Player's custom data. (LoadPlayerData)\n");
// Load SP player custom data.
mem_seek R7(D2Game, 5046F, 5086F, 5CB0F, BB8ED, 278CD, 465BD, 5638D);
memt_byte( 0x8B, 0xE8); // CALL caller_LoadSPPlayerCustomData
MEMT_REF4( 0x75F685F0 , caller_LoadSPPlayerCustomData);
memt_byte( 0x16, 0x90); // NOP
//6FC8CB0F 8BF0 MOV ESI,EAX
//6FC8CB11 85F6 TEST ESI,ESI
//6FC8CB13 75 16 JNZ SHORT D2Game.6FC8CB2B
//0203B8ED |> 8BF0 MOV ESI,EAX
//0203B8EF |. 85F6 TEST ESI,ESI
//0203B8F1 |. 75 16 JNZ SHORT D2Game.0203B909
//01F978CD |> 8BF0 MOV ESI,EAX
//01F978CF |. 85F6 TEST ESI,ESI
//01F978D1 |. 75 16 JNZ SHORT D2Game.01F978E9
//6FC665BD |> 8BF0 MOV ESI,EAX
//6FC665BF |. 85F6 TEST ESI,ESI
//6FC665C1 |. 75 16 JNZ SHORT D2Game.6FC665D9
//6FC7638D |> 8BF0 MOV ESI,EAX
//6FC7638F |. 85F6 TEST ESI,ESI
//6FC76391 |. 75 16 JNZ SHORT D2Game.6FC763A9
// Load MP player custom data.
mem_seek R7(D2Game, 50790, 50B90, 5CC66, BB777, 27757, 46447, 56217);
memt_byte( 0x83, 0xE8);
MEMT_REF4( version_D2Game >= V111 ? 0x2174003B : version_D2Game == V110 ? 0x4674003F : 0x1D74003F, version_D2Game >= V111 ? caller_LoadMPPlayerCustomData_111 : version_D2Game == V110 ? caller_LoadMPPlayerCustomData: caller_LoadMPPlayerCustomData_9);
//6FC8CC66 . 833F 00 CMP DWORD PTR DS:[EDI],0
//6FC8CC69 . 74 46 JE SHORT D2Game.6FC8CCB1
//0203B777 |> 833B 00 CMP DWORD PTR DS:[EBX],0
//0203B77A |. 74 21 JE SHORT D2Game.0203B79D
//01F97757 |> 833B 00 CMP DWORD PTR DS:[EBX],0
//01F9775A |. 74 21 JE SHORT D2Game.01F9777D
//6FC66447 |> 833B 00 CMP DWORD PTR DS:[EBX],0
//6FC6644A |. 74 21 JE SHORT D2Game.6FC6646D
//6FC76217 |> 833B 00 CMP DWORD PTR DS:[EBX],0
//6FC7621A |. 74 21 JE SHORT D2Game.6FC7623D
// Send save files to Server.
mem_seek R7(D2Client, CF42, CF32, D5A2, 733FC, 5DFDC, 7933C, 1457C);
MEMJ_REF4( D2FogGetSavePath, version_D2Game >= V111 ? caller_SendSaveFiles_111 : caller_SendSaveFiles);
//6FAAD5A1 |. E8 88D10B00 CALL <JMP.&Fog.#10115>
//6FB233FB |. E8 CA8AF9FF CALL <JMP.&Fog.#10115>
//6FB0DFDB |. E8 C6DEFAFF CALL <JMP.&Fog.#10115>
//6FB2933B |. E8 6A2CF9FF CALL <JMP.&Fog.#10115>
//6FAC457B |. E8 187AFFFF CALL <JMP.&Fog.#10115>
// Receive save files from client.
mem_seek R7(D2Game, 183A, 183A, 191A, 376E9, 703D9, 624D9, CAF39);
memt_byte( 0x8B ,0xE8);
if ( version_D2Game >= V111 ) {
MEMT_REF4( 0xB60F005D, caller_ReceiveSaveFiles_111);
memt_byte( 0x45 ,0x90);
memt_byte( 0x04 ,0x90);
//01FB76E9 |. 8B5D 00 MOV EBX,DWORD PTR SS:[EBP]
//01FB76EC |. 0FB645 04 MOVZX EAX,BYTE PTR SS:[EBP+4]
//01FE03D9 |. 8B5D 00 MOV EBX,DWORD PTR SS:[EBP]
//01FE03DC |. 0FB645 04 MOVZX EAX,BYTE PTR SS:[EBP+4]
//6FC824D9 |. 8B5D 00 MOV EBX,DWORD PTR SS:[EBP]
//6FC824DC |. 0FB645 04 MOVZX EAX,BYTE PTR SS:[EBP+4]
//6FCEAF39 |. 8B5D 00 MOV EBX,DWORD PTR SS:[EBP]
//6FCEAF3C |. 0FB645 04 MOVZX EAX,BYTE PTR SS:[EBP+4]
} else {
MEMT_REF4( 0x04468A3E, caller_ReceiveSaveFiles);
//6FC3191A |. 8B3E MOV EDI,DWORD PTR DS:[ESI]
//6FC3191C |. 8A46 04 MOV AL,BYTE PTR DS:[ESI+4]
}
if ( version_Fog <= V109d )
{
mem_seek R7(Fog, 47DE, 45AE, 0000, 0000, 0000, 0000, 0000);
memt_byte( 0x8B ,0xE8);
MEMT_REF4( 0x891C2444, version_Fog == V109b? caller_BugFix109b : caller_BugFix109d);
memt_byte( 0x44 ,0x90);
memt_byte( 0x24 ,0x90);
memt_byte( 0x20 ,0x90);
//6FF545AE |> 8B4424 1C |MOV EAX,DWORD PTR SS:[ESP+1C] ; Case 2 of switch 6FF5454C
//6FF545B2 |. 894424 20 |MOV DWORD PTR SS:[ESP+20],EAX
}
if ( version_D2Game == V109b || version_D2Game == V109d )
customPackID -= 3;
else if ( version_D2Game == V110 )
customPackID --;
log_msg("\n");
isInstalled = true;
}
/*================================= END OF FILE =================================*/

123
PlugY/MainScreen.cpp Normal file
View File

@ -0,0 +1,123 @@
/*=================================================================
File created by Yohann NICOLAS.
Add "plugY v1.00" on screen.
=================================================================*/
#include "common.h"
#include "error.h"
#include "d2functions.h"
#include <stdio.h>
char* versionText = "";
bool active_VersionTextChange = 0;
BYTE modVersionColor = 0;
bool active_PrintPlugYVersion = 1;
BYTE colorOfPlugYVersion = 4;
DWORD newTextBoxData[]={4,0x237,0x243,0xC8,0x14,0,0,0,0,0,0,2};//type,x,y,l,h,?,?,?,?,?,?,?(0,257,C8,28)
void STDCALL printPlugYVersion(void** childrens, DWORD* sgnNumChildren)
{
char buf[20];
void* textbox = D2CreateTextBox(newTextBoxData);
childrens[*sgnNumChildren]=textbox;
d2_assert((*sgnNumChildren)++ >= 40,"sgnNumChildren < MAX_CHILDREN", __FILE__, __LINE__);
sprintf(buf, "PlugY %s", PLUGY_VERSION);
D2PrintLineOnTextBox(textbox, buf, colorOfPlugYVersion);
}
FCT_ASM ( caller_printPlugYVersion )
POP ESI
PUSH DWORD PTR [ESI+2]
PUSH DWORD PTR [ESI+9]
CALL printPlugYVersion
CALL D2CreateTextBox
JMP ESI
}}
void Install_PrintPlugYVersion()
{
static int isInstalled = false;
if (isInstalled) return;
log_msg("Patch D2Launch to print PlugY version. (PrintPlugYVersion)\n");
// Print PlugY version.
mem_seek R7(D2Launch, 7F5D, 7F7D, 9639, 117C7, 178A7, 16AF7, 18061);
MEMJ_REF4( D2CreateTextBox, caller_printPlugYVersion);
//6FA19638 |. E8 1BED0000 CALL <JMP.&D2Win.#10017>
//6FA517C6 |. E8 6F81FFFF CALL <JMP.&D2Win.#10147>
//6FA578A6 |. E8 D71FFFFF CALL <JMP.&D2Win.#10113>
//6FA56B1F |. E8 1A2EFFFF CALL <JMP.&D2Win.#10098>
//6FA56AF6 |. E8 432EFFFF CALL <JMP.&D2Win.#10098>
//6FA58060 |. E8 ED18FFFF CALL <JMP.&D2Win.#10098>
log_msg("\n");
isInstalled = true;
}
/*************************************************************************************/
void FASTCALL versionChange(void* screen, char* text, DWORD color)
{
D2PrintLineOnTextBox(screen,versionText,modVersionColor);
}
FCT_ASM ( caller_VersionChange_10 )
MOV CL, BYTE PTR DS:[modVersionColor]
MOV BYTE PTR SS:[ESP+4], CL
MOV EDX,versionText
MOV ECX,EDI
RETN
}}
void Install_VersionChange()// BUG WITH 2MOD if D2Mod started before PlugY ????
{
static int isInstalled = false;
if (isInstalled) return;
log_msg("Patch D2Launch to print Mod version. (VersionChange)\n");
//6FA18012 |. 8D5424 0C LEA EDX,DWORD PTR SS:[ESP+C]
//6FA18016 |. 8BCE MOV ECX,ESI
//6FA18018 |. 6A 00 PUSH 0
// Print LoD/Mod version.
if (version_D2Launch >= V110)
{
mem_seek R7(D2Launch, 00000, 00000, 9723, 1189B, 1797B, 16BCB, 18134);//6FA19721-6FA10000
memt_byte( 0x8D, 0xE8 ); // CALL
MEMT_REF4( 0x8B102454 , caller_VersionChange_10);
memt_byte( 0xCF, 0x90 ); // NOP
//6FA19723 |. 8D5424 10 LEA EDX,DWORD PTR SS:[ESP+10]
//6FA19727 |. 8BCF MOV ECX,EDI
//6FA5189B |. 8D5424 10 LEA EDX,DWORD PTR SS:[ESP+10]
//6FA5189F |. 8BCF MOV ECX,EDI
//6FA5797B |. 8D5424 10 LEA EDX,DWORD PTR SS:[ESP+10]
//6FA5797F |. 8BCF MOV ECX,EDI
//6FA56BCB |. 8D5424 10 LEA EDX,DWORD PTR SS:[ESP+10]
//6FA56BCF |. 8BCF MOV ECX,EDI
//6FA58134 |. 8D5424 10 LEA EDX,DWORD PTR SS:[ESP+10]
//6FA58138 |. 8BCF MOV ECX,EDI
} else {
mem_seek R7(D2Launch, 801B, 803B, 972A, 118A2, 17982, 16BD2, 1813B);
MEMJ_REF4( D2PrintLineOnTextBox, versionChange);
//6FA19729 |. E8 88EB0000 CALL <JMP.&D2Win.#10046>
//6FA518A1 |. E8 267FFFFF CALL <JMP.&D2Win.#10061>
//6FA57981 |. E8 781EFFFF CALL <JMP.&D2Win.#10075>
//6FA56BD1 |. E8 EA2CFFFF CALL <JMP.&D2Win.#10015>
//6FA5813A |. E8 8F17FFFF CALL <JMP.&D2Win.#10022>
}
log_msg("\n");
isInstalled = true;
}
/*================================= END OF FILE =================================*/

234
PlugY/ModifMemory.cpp Normal file
View File

@ -0,0 +1,234 @@
/*=================================================================
File created by Yohann NICOLAS.
Modification of code in memory functions.
=================================================================*/
#include "common.h"
#include "error.h"
#include "modifMemory.h"
#include "d2functions.h"
const char* MSG_ERROR_READ_MEMORY = "Error : Read access missing to patch memory at %08X.\nPlease install a clean version of Lord of Destruction\n\n"
"You can avoid this error message by setting ActiveCkeckMemory=0 in PlugY.ini\n(WARNING: Be careful when you use it, it shouldn't be used by common user)";
const char* MSG_CRITICAL_WRITE_MEMORY = "Error.\nWrite access missing to patch memory at %08X.\n\nPlease install a clean version of Lord of Destruction\n";
const char* ERROR_TESTING1 = "Error : BYTE %02X wanted but %02X found to change memory at %08X\n\n";
const char* ERROR_TESTING4 = "Error : DWORD %08X wanted but %08X found to change memory at %08X\n\n";
void* currentMemoryPos = 0;
DWORD mem_seek(DWORD newPos)
{
currentMemoryPos = (void*)newPos;
return (DWORD)currentMemoryPos;
}
void patchMemory1(BYTE value)
{
if (IsBadWritePtr(currentMemoryPos,1))
{
log_box(MSG_CRITICAL_WRITE_MEMORY, currentMemoryPos);
exit(1);
}
*(BYTE*)currentMemoryPos = value;
currentMemoryPos = (LPVOID)((DWORD)currentMemoryPos + 1);
}
void patchMemory4(DWORD value)
{
if (IsBadWritePtr(currentMemoryPos,4))
{
log_box(MSG_CRITICAL_WRITE_MEMORY, currentMemoryPos);
exit(1);
}
*(DWORD*)currentMemoryPos = value;
currentMemoryPos = (LPVOID)((DWORD)currentMemoryPos + 4);
}
BYTE getMemory1(LPVOID mempos)
{
if (IsBadReadPtr(mempos,1))
{
log_box(MSG_ERROR_READ_MEMORY, currentMemoryPos);
exit(1);
}
return *(BYTE*)mempos;
}
DWORD getMemory4(LPVOID mempos)
{
if (IsBadReadPtr(mempos,4))
{
log_box(MSG_ERROR_READ_MEMORY, currentMemoryPos);
exit(1);
}
return *(DWORD*)mempos;
}
void memt_byte(BYTE old, BYTE val)
{
BYTE current = getMemory1(currentMemoryPos);
if ( current == val)
{
log_msg("Warning : BYTE %02X is already set at memory %08X\n", val, currentMemoryPos);
currentMemoryPos = (LPVOID)((DWORD)currentMemoryPos + 1);
return;
}
if ( old != current)
{
if (active_CheckMemory)
{
log_box(ERROR_TESTING1, old, current, currentMemoryPos);
exit(1);
} else log_msg(ERROR_TESTING1, old, current, currentMemoryPos);
}
log_msg("BYTE\t%08X : %02X->%02X\n", currentMemoryPos, old, val);
patchMemory1(val);
}
bool testIfAlreadySet(DWORD current, DWORD wanted)
{
if (current == wanted)
{
log_msg("Warning : DWORD %08X is already set at memory %08X\n", wanted, currentMemoryPos);
currentMemoryPos = (LPVOID)((DWORD)currentMemoryPos + 4);
return true;
}
return false;
}
void testMemory4(DWORD old, DWORD found)
{
if (old != found)
if (active_CheckMemory)
{
log_box(ERROR_TESTING4, old, found, currentMemoryPos);
exit(1);
} else log_msg(ERROR_TESTING4, old, found, currentMemoryPos);
}
void memt_dword(DWORD old, DWORD val)
{
DWORD current = getMemory4(currentMemoryPos);
DWORD wanted = val;
if (testIfAlreadySet(current, wanted)) return;
testMemory4(old, current);
log_msg("DWORD\t%08X : %08X->%08X\n", currentMemoryPos, old, wanted);
patchMemory4(wanted);
}
void memt_ref4(DWORD old, DWORD ref)
{
DWORD current = getMemory4(currentMemoryPos);
DWORD wanted = ref-(DWORD)currentMemoryPos-4;
if (testIfAlreadySet(current, wanted)) return;
testMemory4(old, current);
log_msg("DWORD\t%08X : %08X->%08X\n", currentMemoryPos, old, wanted);
patchMemory4(wanted);
}
void memc_ref4(DWORD old, DWORD ref)
{
DWORD current = getMemory4(currentMemoryPos);
DWORD wanted = ref-(DWORD)currentMemoryPos-4;
if (testIfAlreadySet(current, wanted)) return;
testMemory4(old, current + (DWORD)currentMemoryPos + 4);
log_msg("DWORD\t%08X : %08X->%08X\n", currentMemoryPos, old, wanted);
patchMemory4(wanted);
}
void memj_ref4(DWORD old, DWORD ref)
{
DWORD current = getMemory4(currentMemoryPos);
DWORD wanted = ref-(DWORD)currentMemoryPos-4;
if (testIfAlreadySet(current, wanted)) return;
testMemory4(old, getMemory4((LPVOID)getMemory4((LPVOID)(current + (DWORD)currentMemoryPos + 6))));
log_msg("DWORD\t%08X : %08X->%08X\n", currentMemoryPos, old, wanted);
patchMemory4(wanted);
}
void memd_ref4(DWORD old, DWORD ref)
{
DWORD current = getMemory4(currentMemoryPos);
DWORD wanted = ref-(DWORD)currentMemoryPos-4;
if (testIfAlreadySet(current, wanted)) return;
testMemory4(old, getMemory4((LPVOID)current));
log_msg("DWORD\t%08X : %08X->%08X\n", currentMemoryPos, old, wanted);
patchMemory4(wanted);
}
/*
void mem_byte(BYTE val)
{
if ( *(BYTE*)currentMemoryPos == val)
{
log_msg("Warning : BYTE at %08X is already set to %02X\n", currentMemoryPos, val);
currentMemoryPos += 1;
return;
}
log_msg("BYTE\t%08X : %02X\n", currentMemoryPos, val);
*(BYTE*)currentMemoryPos = val;
currentMemoryPos += 1;
}
void mem_word(WORD val)
{
if ( *(WORD*)currentMemoryPos == val)
{
log_msg("Warning : WORD at %08X is already set to %04X\n", currentMemoryPos, val);
currentMemoryPos += 2;
return;
}
log_msg("WORD\t%08X : %04X\n", currentMemoryPos, val);
*(WORD*)currentMemoryPos = val;
currentMemoryPos += 2;
}
void memt_word(WORD old, WORD val)
{
if ( *(WORD*)currentMemoryPos == val)
{
log_msg("Warning : WORD at %08X is already set to %04X (normal:%04X)\n", currentMemoryPos, val, old);
currentMemoryPos += 2;
return;
}
if ( *(WORD*)currentMemoryPos != old)
{
log_msg("WORD %04X found, want %04X at %08X\n", *(WORD*)currentMemoryPos, old, currentMemoryPos);
if (active_CheckMemory)
{
log_box(MSG_ERROR_MEMORY);
exit(1);
}
}
log_msg("WORD\t%08X : %04X->%04X\n", currentMemoryPos, old, val);
*(WORD*)currentMemoryPos = val;
currentMemoryPos += 2;
}
void mem_dword(DWORD val)
{
if ( *(DWORD*)currentMemoryPos == val)
{
log_msg("Warning : DWORD at %08X is already set to %08X\n", currentMemoryPos, val);
currentMemoryPos += 4;
return;
}
log_msg("DWORD\t%08X : %08X\n", currentMemoryPos, val);
*(DWORD*)currentMemoryPos = val;
currentMemoryPos += 4;
}
void mem_ref4(DWORD ref)
{
log_msg("DWORD\t%08X : %08X\n", currentMemoryPos, ref-(DWORD)currentMemoryPos-4);
*(DWORD*)currentMemoryPos = ref-(DWORD)currentMemoryPos-4;
currentMemoryPos += 4;
}
*/
/*================================= END OF FILE =================================*/

View File

@ -0,0 +1,306 @@
/*=================================================================
File created by Yohann NICOLAS.
Cube Listing functions
=================================================================*/
#include "common.h"
#include "error.h"
#include "d2functions.h"
#include "updateClient.h"
#include <stdio.h>
#include <direct.h> // _getcwd()
const char* CUBEFORMULA_FILE = "cube.txt";
const char * STRING_ERROR="***Error***";
#define BUF (&buf[strlen(buf)])
/*
6FC9275F |. E8 ECCCFFFF |CALL D2Game.6FC8F450 ; \D2Game.6FC8F450
*/
void printOutput(CubeOutput* output, char* buf, BYTE* nbOutputs)
{
if (!output->outputType)
return;
if (*nbOutputs)
sprintf(BUF," + ");
*nbOutputs += 1;
if (output->outputType == 1) {
sprintf(BUF,"Cow Portal");
return;
} else if (output->outputType == 2) {
sprintf(BUF,"Pandemonium Portal");
return;
} else if (output->outputType == 3) {
sprintf(BUF,"Pandemonium Final Portal");
return;
}
if ((output->quantityOrNbSockets>1) && !output->haveSockets)
sprintf(BUF,"%u ", output->quantityOrNbSockets);
if (output->repair)
sprintf(BUF,"repair ");
if (output->recharge)
sprintf(BUF,"recharge ");
if (output->isEthereal)
sprintf(BUF,"ethereal ");
if (output->destroysFillers)
sprintf(BUF,"destroys Fillers ");
if (output->removeFillers)
sprintf(BUF,"remove Fillers ");
if (output->regeneratesUnique)
sprintf(BUF,"regenerate ");
if (output->upgradeToExceptional)
sprintf(BUF,"exceptional ");
if (output->upgradeToElite)
sprintf(BUF,"elite ");
if (output->isSpecificItem) {
if (output->quality == ITEMQUALITY_UNIQUE)
{
UniqueItemsBIN* uniqueItems = SgptDataTables->uniqueItems + output->specificID-1;
LPWSTR string = D2GetStringFromIndex(uniqueItems->uniqueNameId);
wcstombs(BUF, string, wcslen(string)+1);
} else if (output->quality == ITEMQUALITY_SET) {
SetItemsBIN* setItems = SgptDataTables->setItems + output->specificID-1;
LPWSTR string = D2GetStringFromIndex(setItems->setNameId);
wcstombs(BUF, string, wcslen(string)+1);
} else {
sprintf(BUF,STRING_ERROR);return;
}
} else {
switch (output->quality)
{
case 1:sprintf(BUF,"Cracked ");break;
case 2:sprintf(BUF,"Normal ");break;
case 3:sprintf(BUF,"Superior ");break;
case 4:sprintf(BUF,"Magic ");break;
case 5:sprintf(BUF,"Set ");break;
case 6:sprintf(BUF,"Rare ");break;
case 7:sprintf(BUF,"Unique ");break;
case 8:sprintf(BUF,"Crafted ");break;
case 9:sprintf(BUF,"Tempered ");break;
}
ItemsBIN* items;LPWSTR string;
switch (output->outputType)
{
case 0xFC:
items = D2GetItemsBIN(output->ID);
string = D2GetStringFromIndex(items->NameStr);
wcstombs(BUF, string, wcslen(string)+1);
break;
case 0xFD:
getTypeAString(output->ID,BUF,50);
// WCHAR string[50];
// getTypeString(input->ID,string,50);
// wcstombs(BUF, string, wcslen(string)+1);
break;
case 0xFE: sprintf(BUF,"Item");break;
case 0xFF: sprintf(BUF,"Item of the same type");break;
default: sprintf(BUF,STRING_ERROR);return;
}
}
if ((output->quantityOrNbSockets>1) && (output->haveSockets==1))
sprintf(BUF," with %u sockets", output->quantityOrNbSockets);
}
void printInput(CubeInput* input, char* buf, BYTE* nbInputs)//maxsize)
{
if (!input->byItemID && !input->byItemTypeID)
return;
if (*nbInputs)
sprintf(BUF," + ");
BYTE nb = input->quantity > 0 ? input->quantity : 1;
*nbInputs += nb;
if (nb>1)
sprintf(BUF,"%u ", nb);
if (input->isEthereal)
sprintf(BUF,"ethereal ");
if (input->isNotEthereal)
sprintf(BUF,"not ethereal ");
if (input->isNotRuneword)
sprintf(BUF,"not runeword ");
if (input->isBasic)
sprintf(BUF,"basic ");
if (input->isExceptional)
sprintf(BUF,"exceptional ");
if (input->isElite)
sprintf(BUF,"elite ");
if (input->isSpecificItem) {
if (input->quality == ITEMQUALITY_UNIQUE)
{
UniqueItemsBIN* uniqueItems = SgptDataTables->uniqueItems + input->specificID-1;
LPWSTR string = D2GetStringFromIndex(uniqueItems->uniqueNameId);
wcstombs(BUF, string, wcslen(string)+1);
} else if (input->quality == ITEMQUALITY_SET) {
SetItemsBIN* setItems = SgptDataTables->setItems + input->specificID-1;
LPWSTR string = D2GetStringFromIndex(setItems->setNameId);
wcstombs(BUF, string, wcslen(string)+1);
} else {
sprintf(BUF,STRING_ERROR);return;
}
} else {
switch (input->quality)
{
case 1:sprintf(BUF,"Cracked ");break;
case 2:sprintf(BUF,"Normal ");break;
case 3:sprintf(BUF,"Superior ");break;
case 4:sprintf(BUF,"Magic ");break;
case 5:sprintf(BUF,"Set ");break;
case 6:sprintf(BUF,"Rare ");break;
case 7:sprintf(BUF,"Unique ");break;
case 8:sprintf(BUF,"Crafted ");break;
case 9:sprintf(BUF,"Tempered ");break;
}
if (input->byItemTypeID) {
getTypeAString(input->ID,BUF,50);
} else if (input->ID == 0xFFFF) {
sprintf(BUF,"Item");
} else {
ItemsBIN* items = D2GetItemsBIN(input->ID);
LPWSTR string = D2GetStringFromIndex(items->NameStr);
wcstombs(BUF, string, wcslen(string)+1);
}
}
if (input->includeUpgradedVersions && !input->isElite)
sprintf(BUF,"(or upgraded) ");
if (input->haveNoSocket)
sprintf(BUF," with no socket");
if (input->haveSockets)
sprintf(BUF," with sockets");
}
DWORD print(CubeMainBIN* curForm, char* buf, DWORD)//maxsize)
{
if (!buf || !curForm || !curForm->enabled) return 0;
BYTE realNbInputs=0;
printInput(&curForm->input1, buf, &realNbInputs);
printInput(&curForm->input2, buf, &realNbInputs);
printInput(&curForm->input3, buf, &realNbInputs);
printInput(&curForm->input4, buf, &realNbInputs);
printInput(&curForm->input5, buf, &realNbInputs);
printInput(&curForm->input6, buf, &realNbInputs);
printInput(&curForm->input7, buf, &realNbInputs);
if (realNbInputs != curForm->numinputs)
{
sprintf(BUF," *** ERROR : numInputs(%d) != realNbInputs(%d) ***", curForm->numinputs, realNbInputs);
return 1;
}
sprintf(BUF," => ");
BYTE realNbOutputs=0;
printOutput(&curForm->output1, buf, &realNbOutputs);
printOutput(&curForm->output2, buf, &realNbOutputs);
printOutput(&curForm->output3, buf, &realNbOutputs);
// if (curForm->ladder)
// sprintf(BUF," [ladder only]");
if (curForm->minDiff == 1)
sprintf(BUF," [Nightmare and Hell only]");
else if (curForm->minDiff == 2)
sprintf(BUF," [Hell only]");
if (curForm->playerClass != 0xFF)
{
CharStatsBIN* charStats = D2GetCharStatsBIN(curForm->playerClass);
sprintf(BUF, " [%s only]", charStats->name);
}
if ((curForm->op>0) && (curForm->op!=28))
sprintf(BUF, " [op%d(%d,%d)]", curForm->op, curForm->param, curForm->value);
// if (curForm->version == 100)
// sprintf(BUF, " [expansion only]");
return 1;
}
#undef BUF
void listAllCubeFormula()
{
char filename[MAX_PATH];
_getcwd( filename, MAX_PATH );
if( filename[strlen(filename)] != '\\')
strcat(filename, "\\");
strcat(filename, CUBEFORMULA_FILE);
FILE* file = fopen(filename, "w");
if (!file) return;
log_msg("\n\n********** Print all cube formula **********\n");//SgptDataTables->nbCubemain\n"
int nbLines = D2GetNbCubeMainBIN();//SgptDataTables->nbCubemain
log_msg("nbLines : %d\n",nbLines);
char buf[300];
for (int i=0; i<nbLines; i++)
{
buf[0]=NULL;
DWORD res = print(D2GetCubeMainBIN(i), buf, 300);//SgptDataTables->cubemain + i;
if (res) fprintf(file,"%4u: %s\n",i,buf);
if (res) fflush(file);
}
fclose(file);
log_msg("\n********** Printing over **********\n\n");
/* _getcwd( filename, MAX_PATH );
if( filename[strlen(filename)] != '\\')
strcat(filename, "\\");
strcat(filename, "tmp.txt");
file = fopen(filename, "w");
ItemStatCostBIN* itemStatCost;
LPWSTR lpText;
for (i=0;i<=STATS_ITEM_CHARGED_SKILL_MOD;i++)
{
buf[0]='\0';
itemStatCost = D2GetItemStatCostBIN(i);
lpText = D2GetStringFromIndex(itemStatCost->descstrpos);
wcstombs(&buf[0],lpText,100);
strcat(buf,"\t - \t");
lpText = D2GetStringFromIndex(itemStatCost->descstrneg);
wcstombs(&buf[strlen(buf)],lpText,100);
fprintf(file,"%03d %03X \t- %s\n",i,i,buf);
}
fclose(file);*/
}
/*================================= END OF FILE =================================*/

View File

@ -0,0 +1,291 @@
/*=================================================================
File created by Yohann NICOLAS.
Interface functions
=================================================================*/
#include "common.h"
#include "error.h"
#include "d2functions.h"
#include "updateServer.h" // Install_UpdateServer()
#include "plugYFiles.h" // Install_PlugYImagesFiles()
#include "statsPoints.h"
#include "newInterfaces.h"
#include <stdio.h>
#define NB_RUNES_PER_PAGE 25
#define getXCloseBtn() 360
#define getLCloseBtn() 32
#define getYCloseBtn() (ResolutionY - 60)
#define getHCloseBtn() 32
#define isOnCloseBtn(x,y) isOnRect(x, y, getXCloseBtn(), getYCloseBtn(), getLCloseBtn(), getHCloseBtn())
#define getXNextPageBtn() 120
#define getLNextPageBtn() 32
#define getYNextPageBtn() (ResolutionY - 60)
#define getHNextPageBtn() 32
#define isOnNextPageBtn(x,y) isOnRect(x, y, getXNextPageBtn(), getYNextPageBtn(), getLNextPageBtn(), getHNextPageBtn())
#define getXPrevRunesBtn() 168
#define getLPrevRunesBtn() 32
#define getYPrevRunesBtn() (ResolutionY - 60)
#define getHPrevRunesBtn() 32
#define isOnPrevRunesBtn(x,y) isOnRect(x, y, getXPrevRunesBtn(), getYPrevRunesBtn(), getLPrevRunesBtn(), getHPrevRunesBtn())
#define getXNextRunesBtn() 200
#define getLNextRunesBtn() 32
#define getYNextRunesBtn() (ResolutionY - 60)
#define getHNextRunesBtn() 32
#define isOnNextRunesBtn(x,y) isOnRect(x, y, getXNextRunesBtn(), getYNextRunesBtn(), getLNextRunesBtn(), getHNextRunesBtn())
int curRunesPage=0;
int maxRunesPage=0xFFFF;
static struct
{
union{
DWORD all;
struct{
DWORD close:1;
DWORD nextPage:1;
DWORD prevRunes:1;
DWORD nextRunes:1;
};
};
} isDownBtn;
void printRuneword(RunesBIN* runesData, DWORD pos)
{
WCHAR temp[50];
WCHAR runesList[50];
WCHAR typesList[50];
LPWSTR lpText = D2GetStringFromIndex(runesData->RuneNameID);
D2SetFont(6);
DWORD nbPixel = D2GetPixelLen(lpText);
DWORD x1 = (nbPixel >= 195) ? 0 : 195-nbPixel;
D2PrintString(lpText, x1, 10 + pos*20, GOLD, 0);//MILIEU(0x00,0x70,nbPixel)
typesList[0]=L'\0';
DWORD numItype=0;
while (numItype<6)
{
WORD type = runesData->Itypes[numItype];
if (!type) break;
getTypeUString(type,temp,50);
if (numItype) wcscat(typesList,L"/");
wcscat(typesList,temp);
numItype++;
}
nbPixel = D2GetPixelLen(typesList);
x1 = (nbPixel >= 195) ? 0 : 195-nbPixel;
D2PrintString(typesList, x1, 20 + pos*20, WHITE, 0);//MILIEU(0x70,0xA0,nbPixel)
runesList[0]=L'\0';
DWORD numRune=0;
int curRuneID = runesData->Runes[0];
while ((curRuneID>0) && (numRune<6))
{
ItemsBIN* itemsData = D2GetItemsBIN(curRuneID);
d2_assert( !itemsData , "itemsData", __FILE__, __LINE__);
GemsBIN* gemData = D2GetGemsBIN(itemsData->GemOffset);
if (gemData) {
d2_assert( !gemData , "gemData", __FILE__, __LINE__);
mbstowcs(temp, gemData->letter, 50);
if (numRune) wcscat(runesList,L" ");
// else wcscat(runesList,L"");
wcscat(runesList,temp);}
numRune++;
curRuneID = runesData->Runes[numRune];
}
// wcscat(runesList,L"");
D2SetFont(1);
DWORD y1;
nbPixel = D2GetPixelLen(runesList);
if (nbPixel>195)
{
D2SetFont(6);
nbPixel = D2GetPixelLen(runesList);
y1=16;
x1 = nbPixel>195 ? 395-nbPixel : 204;
} else {
x1=205;
y1=18;
}
// x1 = (nbPixel < 145) ? 155 : 300-nbPixel;
D2PrintString(runesList, x1, y1 + pos*20, WHITE, 0);//MILIEU(0xD0,0xA0,nbPixel)
}
#define BUFSIZE 0x80
//6FB21FAA
void STDCALL printRunewordsPage()
{
if (!D2isLODGame() || !D2GetResolution()) return D2PrintStatsPage();
LPWSTR lpText;
bDontPrintBorder = true;
//Init data for print image
sDrawImageInfo data;
ZeroMemory(&data,sizeof(data));
//print background
/* setImage(&data, newStatsInterfaceImages);
setFrame(&data, 0);
D2PrintImage(&data, 0, 256, -1, 5, 0);
setFrame(&data, 1);
D2PrintImage(&data, 256,256, -1, 5, 0);
setFrame(&data, 2);
D2PrintImage(&data, 0, 512, -1, 5, 0);
setFrame(&data, 3);
D2PrintImage(&data, 256,512, -1, 5, 0);
setFrame(&data, 4);
D2PrintImage(&data, 0, 552, -1, 5, 0);
setFrame(&data, 5);
D2PrintImage(&data, 256,552, -1, 5, 0);
*/
fillRect(0,0,400,552,0,5);
//print button close
setImage(&data, D2LoadBuySelBtn());
setFrame(&data, 10 + isDownBtn.close);
D2PrintImage(&data, getXCloseBtn(), getYCloseBtn(), -1, 5, 0);
//print next page button
setFrame(&data, isDownBtn.nextPage);
D2PrintImage(&data, getXNextPageBtn(), getYNextPageBtn(), -1, 5, 0);
//print previous runes button
setImage(&data, stashBtnsImages);
setFrame(&data, isDownBtn.prevRunes);
D2PrintImage(&data, getXPrevRunesBtn(), getYPrevRunesBtn(), -1, 5, 0);
//print previous runes button
setFrame(&data, 2 + isDownBtn.nextRunes);
D2PrintImage(&data, getXNextRunesBtn(), getYNextRunesBtn(), -1, 5, 0);
D2SetFont(6);
//146;//B400
int nbRunes = *D2GetNbRunesBIN();
RunesBIN* runesFirst = nbRunes>1 ? D2GetRunesBIN(1)-1 : NULL;
RunesBIN* runesLast = runesFirst? runesFirst + nbRunes : NULL;
// log_msg("nbRunes(%d,%d) runesFirst(%08X, %08X) runesLast(%08X, %08X)",nbRunes,SgptDataTables->nbRunes,runesFirst, SgptDataTables->runes,runesLast,SgptDataTables->runes + SgptDataTables->nbRunes);
int nbRunesCompleted=0;
DWORD curNbRunes=0;
for ( RunesBIN* runesData = runesFirst; runesData < runesLast; runesData++)
{
if (!runesData->Complete || runesData->Server) continue;
nbRunesCompleted++;
if ( (curRunesPage * NB_RUNES_PER_PAGE < nbRunesCompleted) &&
(nbRunesCompleted <= (curRunesPage+1) * NB_RUNES_PER_PAGE) )
printRuneword(runesData, curNbRunes++);
}
maxRunesPage = nbRunesCompleted ? (nbRunesCompleted-1) / NB_RUNES_PER_PAGE : 0;
//////////////////// POPUP PRINTING ////////////////////
//set MouseX & MouseY
DWORD x = D2GetMouseX();
DWORD y = D2GetMouseY();
if (isOnCloseBtn(x,y)) // print popup "close"
{
D2PrintPopup(D2GetStringFromIndex(0x1030), getXCloseBtn()+getLCloseBtn()/2, getYCloseBtn()-getHCloseBtn(), WHITE, 1);
}
else if (isOnNextPageBtn(x,y)) // print popup "next page"
{
lpText = getTranslatedString(STR_NEXT_PAGE);
D2PrintPopup(lpText, getXNextPageBtn()+getLNextPageBtn()/2, getYNextPageBtn()-getHNextPageBtn(), WHITE, 1);
}
}
//////////////////////////////////////////////////////////////////////////////////////////////
DWORD STDCALL mouseRunewordsPageLeftDown(sWinMessage* msg)
{
if (!D2isLODGame() || !D2GetResolution()) return -1;
if (!isOnStatsPage(msg->x,msg->y)) return 1;
if (isOnCloseBtn(msg->x,msg->y))
{
log_msg("push down left button close\n");
isDownBtn.close = 1;
D2PlaySound(4,0,0,0,0);
}
else if (isOnNextPageBtn(msg->x,msg->y))
{
log_msg("push down left button next page\n");
isDownBtn.nextPage = 1;
D2PlaySound(4,0,0,0,0);
}
else if (isOnPrevRunesBtn(msg->x,msg->y))
{
log_msg("push down left button prev page\n");
isDownBtn.prevRunes = 1;
D2PlaySound(4,0,0,0,0);
}
else if (isOnNextRunesBtn(msg->x,msg->y))
{
log_msg("push down left button next runes\n");
isDownBtn.nextRunes = 1;
D2PlaySound(4,0,0,0,0);
}
freeMessage(msg);
return 0;
}
DWORD STDCALL mouseRunewordsPageLeftUp(sWinMessage* msg)
{
if (!D2isLODGame() || !D2GetResolution()) return -1;
if (!isOnStatsPage(msg->x,msg->y)) return 1;
if (isOnCloseBtn(msg->x,msg->y))
{
log_msg("push up left button close\n");
if (isDownBtn.close)
D2TogglePage(2,1,0);
}
else if (isOnNextPageBtn(msg->x,msg->y))
{
log_msg("push up left button next page\n");
if (isDownBtn.nextPage)
{
GoStatPage(GetCurrentPage()+1);
log_msg("next page press\n");
}
}
else if (isOnPrevRunesBtn(msg->x,msg->y))
{
log_msg("push up left button prev runes\n");
if (isDownBtn.prevRunes)
{
if (curRunesPage) curRunesPage--;
}
}
else if (isOnNextRunesBtn(msg->x,msg->y))
{
log_msg("push up left button next runes\n");
if (isDownBtn.nextRunes)
{
if (curRunesPage < maxRunesPage) curRunesPage++;
}
}
D2CleanStatMouseUp();
freeMessage(msg);
isDownBtn.all=0;
return 0;
}
/*================================= END OF FILE =================================*/

View File

@ -0,0 +1,823 @@
/*=================================================================
File created by Yohann NICOLAS.
Interface functions
=================================================================*/
#include "common.h"
#include "error.h"
#include "d2functions.h"
#include "updateServer.h" // Install_UpdateServer()
#include "plugYFiles.h" // Install_PlugYImagesFiles()
#include "statsPoints.h"
#include "newInterfaces.h"
#include <stdio.h>
#define getXCloseBtn() 360
#define getLCloseBtn() 32
#define getYCloseBtn() (ResolutionY - 60)
#define getHCloseBtn() 32
#define isOnCloseBtn(x,y) isOnRect(x, y, getXCloseBtn(), getYCloseBtn(), getLCloseBtn(), getHCloseBtn())
#define getXPreviousPageBtn() RX(0x19)//0x70
#define getLPreviousPageBtn() 32
#define getYPreviousPageBtn() RY(0x40)
#define getHPreviousPageBtn() 32
#define isOnPreviousPageBtn(x,y) isOnRect(x, y, getXPreviousPageBtn(), getYPreviousPageBtn(), getLPreviousPageBtn(), getHPreviousPageBtn())
#define getXNextPageBtn() RX(D2GetResolution()?0x43:0x8A)
#define getLNextPageBtn() 32
#define getYNextPageBtn() RY(D2GetResolution()?0x40:0x70)
#define getHNextPageBtn() 32
#define isOnNextPageBtn(x,y) isOnRect(x, y, getXNextPageBtn(), getYNextPageBtn(), getLNextPageBtn(), getHNextPageBtn())
/*
#define getXNextPageBtn() 120
#define getLNextPageBtn() 32
#define getYNextPageBtn() (ResolutionY - 60)
#define getHNextPageBtn() 32
#define isOnNextPageBtn(x,y) isOnRect(x, y, getXNextPageBtn(), getYNextPageBtn(), getLNextPageBtn(), getHNextPageBtn())
*/
#define getLAssignBtn() 32
#define getHAssignBtn() 32
#define getXAssSTRBtn() 0x7D+35
#define getYAssSTRBtn() 0x6A
#define isOnAssSTRBtn(x,y) isOnRect(x, y, getXAssSTRBtn(), getYAssSTRBtn(), getLAssignBtn(), getHAssignBtn())
#define getXAssDEXBtn() 0x7D+35
#define getYAssDEXBtn() 0xA8
#define isOnAssDEXBtn(x,y) isOnRect(x, y, getXAssDEXBtn(), getYAssDEXBtn(), getLAssignBtn(), getHAssignBtn())
#define getXAssVITBtn() 0x7D+35
#define getYAssVITBtn() 0xFE
#define isOnAssVITBtn(x,y) isOnRect(x, y, getXAssVITBtn(), getYAssVITBtn(), getLAssignBtn(), getHAssignBtn())
#define getXAssENEBtn() 0x7D+35
#define getYAssENEBtn() 0x13C
#define isOnAssENEBtn(x,y) isOnRect(x, y, getXAssENEBtn(), getYAssENEBtn(), getLAssignBtn(), getHAssignBtn())
#define getLUnassignBtn() 32
#define getHUnassignBtn() 32
#define getXUnaSTRBtn() 0x7D
#define getYUnaSTRBtn() getYAssSTRBtn()
#define isOnUnaSTRBtn(x,y) isOnRect(x, y, getXUnaSTRBtn(), getYUnaSTRBtn(), getLUnassignBtn(), getHUnassignBtn())
#define getXUnaDEXBtn() 0x7D
#define getYUnaDEXBtn() getYAssDEXBtn()
#define isOnUnaDEXBtn(x,y) isOnRect(x, y, getXUnaDEXBtn(), getYUnaDEXBtn(), getLUnassignBtn(), getHUnassignBtn())
#define getXUnaVITBtn() 0x7D
#define getYUnaVITBtn() getYAssVITBtn()
#define isOnUnaVITBtn(x,y) isOnRect(x, y, getXUnaVITBtn(), getYUnaVITBtn(), getLUnassignBtn(), getHUnassignBtn())
#define getXUnaENEBtn() 0x7D
#define getYUnaENEBtn() getYAssENEBtn()
#define isOnUnaENEBtn(x,y) isOnRect(x, y, getXUnaENEBtn(), getYUnaENEBtn(), getLUnassignBtn(), getHUnassignBtn())
void** ptD2RemainingStatsPointsBoxImages = (void**)0x6FBB5E50;
#define D2RemainingStatsPointsBoxImages (*ptD2RemainingStatsPointsBoxImages)
void** ptD2AssignStatsPointsBoxImages = (void**)0x6FBB5BB8;
#define D2AssignStatsPointsBoxImages (*ptD2AssignStatsPointsBoxImages)
void** ptD2AssignStatsPointsBtnImages = (void**)0x6FBB5BB4;
#define D2AssignStatsPointsBtnImages (*ptD2AssignStatsPointsBtnImages)
static struct
{
union{
DWORD all;
struct{
DWORD close:1;
DWORD AssSTR:1;
DWORD AssDEX:1;
DWORD AssVIT:1;
DWORD AssENE:1;
DWORD UnaSTR:1;
DWORD UnaDEX:1;
DWORD UnaVIT:1;
DWORD UnaENE:1;
DWORD previousPage:1;
DWORD nextPage:1;
};
};
} isDownBtn;
void print2Lines(WORD id, LPWSTR lpText, DWORD x, DWORD l, DWORD y)
{
wcsncpy(lpText, D2GetStringFromIndex(id), 0x63);
lpText[0x64]= L'\0';
LPWSTR lptmp = lpText;
while (*lptmp)
{
if (*lptmp==L'\n')
{
*lptmp = L'\0';
if (*(++lptmp))
{
DWORD nbPixel = D2GetPixelLen(lpText);
D2PrintString(lpText, MILIEU(x,l,nbPixel), y-4, WHITE, 0);
nbPixel = D2GetPixelLen(lptmp);
D2PrintString(lptmp, MILIEU(x,l,nbPixel), y+4, WHITE, 0);
return;
}
break;
}
lptmp++;
}
DWORD nbPixel = D2GetPixelLen(lpText);
D2PrintString(lpText, MILIEU(x,l,nbPixel), y, WHITE, 0);
}
#define BUFSIZE 0x80
void STDCALL printNewStatsPage()
{
if (!D2isLODGame() || !D2GetResolution()) return D2PrintStatsPage();
WCHAR text[BUFSIZE];
LPWSTR lpText;
DWORD nbPixel;
DWORD curValue,baseValue,color;
DWORD x1,y1,reset=0;
bDontPrintBorder = true;
int curRes,maxRes;
Unit* ptChar = D2GetClientPlayer();
d2_assert(!ptChar, "Printing stats page : no character selected",__FILE__,__LINE__);
d2_assert(ptChar->nUnitType != UNIT_PLAYER, "Printing stats page : bad unit type",__FILE__,__LINE__);
//Init data for print image
sDrawImageInfo data;
ZeroMemory(&data,sizeof(data));
//print background
/* setImage(&data, newStatsInterfaceImages);
setFrame(&data, 0);
D2PrintImage(&data, 0, 256, -1, 5, 0);
setFrame(&data, 1);
D2PrintImage(&data, 256,256, -1, 5, 0);
setFrame(&data, 2);
D2PrintImage(&data, 0, 512, -1, 5, 0);
setFrame(&data, 3);
D2PrintImage(&data, 256,512, -1, 5, 0);
setFrame(&data, 4);
D2PrintImage(&data, 0, 552, -1, 5, 0);
setFrame(&data, 5);
D2PrintImage(&data, 256,552, -1, 5, 0);
*/
fillRect(0,0,400,552,0,5);
//print button close
setImage(&data, D2LoadBuySelBtn());
setFrame(&data, 10 + isDownBtn.close);
D2PrintImage(&data, getXCloseBtn(), getYCloseBtn(), -1, 5, 0);
//print previous page button
setFrame(&data, 12 + isDownBtn.previousPage);
D2PrintImage(&data, getXPreviousPageBtn(), getYPreviousPageBtn(), -1, 5, 0);
//print next page button
setFrame(&data, 14 + isDownBtn.nextPage);
D2PrintImage(&data, getXNextPageBtn(), getYNextPageBtn(), -1, 5, 0);
CharStatsBIN* charStats = D2GetCharStatsBIN(ptChar->nPlayerClass);
DifficultyLevelsBIN* difficultyLevels = D2GetDifficultyLevelsBIN (D2GetDifficultyLevel());
//print fixed text
D2SetFont(6);
print2Lines(0xFD9, text, 0x0B, 0x29, 0x2C); //level //0x34-0xB
print2Lines(0xFDA, text, 0x41, 0x73, 0x2C); //Experience //0xB4-0x41
print2Lines(0xFDB, text, 0xC1, 0x73, 0x2C); //Next Level //0x134-0xC1
print2Lines(0xFDC, text, 0x0A, 0x3F, 0x61); //Strengh //0x49-0xA
print2Lines(0xFDE, text, 0x0A, 0x3F, 0xA0); //Dexterity //0x49-0xA
print2Lines(0xFE0, text, 0xAE, 0x5E, 0xCF); //Defence //0x10C-0xAE
print2Lines(0xFE2, text, 0x0A, 0x3F, 0xF5); //Vitality //0x49-0xA
print2Lines(0xFE3, text, 0xAE, 0x36, 0xF5); //Stamina //0xE4-0xAE
print2Lines(0xFE4, text, 0xAE, 0x36, 0x10D);//Life //0xE4-0xAE
print2Lines(0xFE5, text, 0x0A, 0x3F, 0x133);//Energy //0x49-0xA
print2Lines(0xFE6, text, 0xAE, 0x36, 0x133);//Mana //0xE4-0xAE
print2Lines(0xFE7, text, 0xBE, 0x4E, 0x15A);//Fire.Resistance //0x10C-0xBE
print2Lines(0xFE8, text, 0xBE, 0x4E, 0x172);//Cold.Resistance //0x10C-0xBE
print2Lines(0xFE9, text, 0xBE, 0x4E, 0x18B);//Lightning.Resistance //0x10C-0xBE
print2Lines(0xFEA, text, 0xBE, 0x4E, 0x1A3);//Poison.Resistance //0x10C-0xBE
// print class
D2SetFont(1);
lpText = charStats->nameU;
nbPixel = D2GetPixelLen(lpText);
D2PrintString(lpText, MILIEU(0xC1,0x76,nbPixel), 0x19, WHITE, 0);
// print name
char* string = PCPlayerData->name;
int usize = strlen(string);
if (usize>9)
D2SetFont(usize < 12?0:6);
mbstowcs(text,string,BUFSIZE);
nbPixel = D2GetPixelLen(text);
D2PrintString(text, MILIEU(0xD,0x94,nbPixel), 0x19, WHITE, 0);
D2SetFont(1);
// print level value
curValue = D2GetPlayerStat(ptChar, STATS_LEVEL, 0);
baseValue = D2GetPlayerBaseStat(ptChar, STATS_LEVEL, 0);
if (curValue != baseValue) color = curValue < baseValue ? RED : BLUE;
else color = WHITE;
swprintf(text,L"%ld",curValue);
nbPixel = D2GetPixelLen(text);
D2PrintString(text, MILIEU(0xD,0x29,nbPixel), 0x3B, color, 0);//ESI,EBX,EDI
if (version_D2Client <= V110)
{
//print Experience
curValue = D2GetPlayerStat(ptChar, STATS_EXPERIENCE, 0);
D2PrintBigNumber(text, curValue, BUFSIZE);
nbPixel = D2GetPixelLen(text);
D2PrintString(text, MILIEU(0x43,0x72,nbPixel), 0x3B, WHITE, 0);
//print next level
DWORD plvl = D2GetPlayerBaseStat(ptChar, STATS_LEVEL, 0);
if (plvl < D2GetMaxLevel(ptChar->nPlayerClass))
curValue = D2GetNextLevelXP(ptChar->nPlayerClass, plvl);
else
curValue = D2GetPlayerStat(ptChar, STATS_NEXTEXP, 0);
D2PrintBigNumber(text,curValue,BUFSIZE);
nbPixel = D2GetPixelLen(text);
D2PrintString(text, MILIEU(0xC3,0x72,nbPixel), 0x3B, WHITE, 0);
//print strength
curValue = D2GetPlayerStat(ptChar, STATS_STRENGTH, 0);
baseValue = D2GetPlayerBaseStat(ptChar, STATS_STRENGTH, 0);
if (curValue != baseValue) color = curValue < baseValue ? RED : BLUE;
else color = WHITE;
swprintf(text,L"%ld",curValue);
nbPixel = D2GetPixelLen(text);
D2PrintString(text, MILIEU(0x4D,0x24,nbPixel), 0x63, color, 0);//ESI,EBX,EDI
//print dexterity
curValue = D2GetPlayerStat(ptChar, STATS_DEXTERITY, 0);
baseValue = D2GetPlayerBaseStat(ptChar, STATS_DEXTERITY, 0);
if (curValue != baseValue) color = curValue < baseValue ? RED : BLUE;
else color = WHITE;
swprintf(text,L"%ld",curValue);
nbPixel = D2GetPixelLen(text);
D2PrintString(text, MILIEU(0x4D,0x24,nbPixel), 0xA1, color, 0);//ESI,EBX,EDI
//print vitality
curValue = D2GetPlayerStat(ptChar, STATS_VITALITY, 0);
baseValue = D2GetPlayerBaseStat(ptChar, STATS_VITALITY, 0);
if (curValue != baseValue) color = curValue < baseValue ? RED : BLUE;
else color = WHITE;
swprintf(text,L"%ld",curValue);
nbPixel = D2GetPixelLen(text);
D2PrintString(text, MILIEU(0x4D,0x24,nbPixel), 0xF7, color, 0);//ESI,EBX,EDI
//print energy
curValue = D2GetPlayerStat(ptChar, STATS_ENERGY, 0);
baseValue = D2GetPlayerBaseStat(ptChar, STATS_ENERGY, 0);
if (curValue != baseValue) color = curValue < baseValue ? RED : BLUE;
else color=0;
swprintf(text,L"%ld",curValue);
nbPixel = D2GetPixelLen(text);
D2PrintString(text, MILIEU(0x4D,0x24,nbPixel), 0x134, color, 0);//ESI,EBX,EDI
//print max stamina
curValue = D2GetPlayerStat(ptChar, STATS_MAXSTAMINA, 0) / 256;
baseValue = D2GetPlayerBaseStat(ptChar, STATS_MAXSTAMINA, 0) / 256;
if (curValue != baseValue) color = curValue < baseValue ? RED : BLUE;
else color = WHITE;
swprintf(text,L"%ld",curValue);
if (curValue > 999) reset=1;
D2GetPixelRect(text,&x1,&y1);
if (0x24<x1) reset = 1;
if (reset) D2SetFont(0);
nbPixel = D2GetPixelLen(text);
D2PrintString(text, MILIEU(0xE8,0x24,nbPixel), 0xF6, color, 0);//ESI,EBX,EDI
if (reset) {D2SetFont(1); reset=0;}
//print stamina
curValue = D2GetPlayerStat(ptChar, STATS_STAMINA, 0) / 256;
swprintf(text,L"%ld",curValue);
if (curValue > 999) reset=1;
D2GetPixelRect(text,&x1,&y1);
if (0x24<x1) reset = 1;
if (reset) D2SetFont(0);
nbPixel = D2GetPixelLen(text);
D2PrintString(text, MILIEU(0x111,0x24,nbPixel), 0xF6, WHITE, 0);//ESI,EBX,EDI
if (reset) {D2SetFont(1); reset=0;}
//print max Hit Point
curValue = D2GetPlayerStat(ptChar, STATS_MAXHP, 0) / 256;
baseValue = D2GetPlayerBaseStat(ptChar, STATS_MAXHP, 0) / 256;
if (curValue != baseValue) color = curValue < baseValue ? RED : BLUE;
else color = WHITE;
swprintf(text,L"%ld",curValue);
if (curValue > 999) reset=1;
D2GetPixelRect(text,&x1,&y1);
if (0x24<x1) reset = 1;
if (reset) D2SetFont(0);
nbPixel = D2GetPixelLen(text);
D2PrintString(text, MILIEU(0xE8,0x24,nbPixel), 0x10E, color, 0);//ESI,EBX,EDI
if (reset) {D2SetFont(1); reset=0;}
//print Hit Point
curValue = D2GetPlayerStat(ptChar, STATS_HP, 0) / 256;
if ((ptChar->CurrentAnim != 0x11) && !curValue) curValue=1;
swprintf(text,L"%ld",curValue);
if (curValue > 999) reset=1;
D2GetPixelRect(text,&x1,&y1);
if (0x24<x1) reset = 1;
if (reset) D2SetFont(0);
nbPixel = D2GetPixelLen(text);
D2PrintString(text, MILIEU(0x111,0x24,nbPixel), 0x10E, WHITE, 0);//ESI,EBX,EDI
if (reset) {D2SetFont(1); reset=0;}
//print max mana
curValue = D2GetPlayerStat(ptChar, STATS_MAXMANA, 0) / 256;
baseValue = D2GetPlayerBaseStat(ptChar, STATS_MAXMANA, 0) / 256;
if (curValue != baseValue) color = curValue < baseValue ? RED : BLUE;
else color = WHITE;
swprintf(text,L"%ld",curValue);
if (curValue > 999) reset=1;
D2GetPixelRect(text,&x1,&y1);
if (0x24<x1) reset = 1;
if (reset) D2SetFont(0);
nbPixel = D2GetPixelLen(text);
D2PrintString(text, MILIEU(0xE8,0x24,nbPixel), 0x134, color, 0);//ESI,EBX,EDI
if (reset) {D2SetFont(1); reset=0;}
//print mana
curValue = D2GetPlayerStat(ptChar, STATS_MANA, 0) / 256;
swprintf(text,L"%ld",curValue);
if (curValue > 999) reset=1;
D2GetPixelRect(text,&x1,&y1);
if (0x24<x1) reset = 1;
if (reset) D2SetFont(0);
nbPixel = D2GetPixelLen(text);
D2PrintString(text, MILIEU(0x111,0x24,nbPixel), 0x134, WHITE, 0);//ESI,EBX,EDI
if (reset) {D2SetFont(1); reset=0;}
// print defence
curValue = D2GetDefence(ptChar);
color = D2haveDefenceBonus(ptChar) ? BLUE : WHITE;
if (PCInventory && D2Common10273(PCInventory,0) && D2isInState(ptChar,0x65))
color = BLUE;
if (D2haveDefenceMalus(ptChar)) color = RED;
if ( D2GetLang() == LNG_JPN)
{
D2GetPixelRect(text,&x1,&y1);
if ((0x24<x1) || (curValue > 999))
{reset = 1; D2SetFont(0);}
}
swprintf(text,L"%ld",curValue);
nbPixel = D2GetPixelLen(text);
D2PrintString(text, MILIEU(0x111,0x23,nbPixel), 0xD1, color, 0);//ESI,EBX,EDI
if (reset) {D2SetFont(1); reset=0;}
//print fire resistance
curRes = D2GetPlayerStat(ptChar, STATS_FIRERESIST, 0) + difficultyLevels->resistPenalty;
color = D2haveFireResBonus(ptChar) ? BLUE : WHITE;
if (D2haveFireResMalus(ptChar)) color = RED;
maxRes = 75 + D2GetPlayerStat(ptChar, STATS_MAXFIRERESIST, 0);
if (maxRes>95) maxRes = 95;
if (curRes < -100) curRes=-100;
if (curRes > maxRes) curRes = maxRes;
if ((curRes == maxRes) && (color != BLUE)) color = GOLD;
else if (curRes < 0) color = RED;
swprintf(text,L"%ld",curRes);
nbPixel = D2GetPixelLen(text);
D2PrintString(text, MILIEU(0x111,0x23,nbPixel), 0x15C, color, 0);//ESI,EBX,EDI
//print lightning resistance
curRes = D2GetPlayerStat(ptChar, STATS_LIGHTRESIST, 0) + difficultyLevels->resistPenalty;
color = D2haveLightResBonus(ptChar) ? BLUE : WHITE;
if (D2haveLightResMalus(ptChar)) color = RED;
maxRes = 75 + D2GetPlayerStat(ptChar, STATS_MAXLIGHTRESIST, 0);
if (maxRes>95) maxRes = 95;
if (curRes < -100) curRes=-100;
if (curRes > maxRes) curRes = maxRes;
if ((curRes == maxRes) && (color != BLUE)) color = GOLD;
else if (curRes < 0) color = RED;
swprintf(text,L"%ld",curRes);
nbPixel = D2GetPixelLen(text);
D2PrintString(text, MILIEU(0x111,0x23,nbPixel), 0x174, color, 0);//ESI,EBX,EDI
//print cold resistance
curRes = D2GetPlayerStat(ptChar, STATS_COLDRESIST, 0) + difficultyLevels->resistPenalty;
color = D2haveColdResBonus(ptChar) ? BLUE : WHITE;
if (D2haveColdResMalus(ptChar)) color = RED;
maxRes = 75 + D2GetPlayerStat(ptChar, STATS_MAXCOLDRESIST, 0);
if (maxRes>95) maxRes = 95;
if (curRes < -100) curRes=-100;
if (curRes > maxRes) curRes = maxRes;
if ((curRes == maxRes) && (color != BLUE)) color = GOLD;
else if (curRes < 0) color = RED;
swprintf(text,L"%ld",curRes);
nbPixel = D2GetPixelLen(text);
D2PrintString(text, MILIEU(0x111,0x23,nbPixel), 0x18C, color, 0);//ESI,EBX,EDI
//print poison resistance
curRes = D2GetPlayerStat(ptChar, STATS_POISONRESIST, 0) + difficultyLevels->resistPenalty;
color = D2havePoisonResBonus(ptChar) ? BLUE : WHITE;
if (D2havePoisonResMalus(ptChar)) color = RED;
maxRes = 75 + D2GetPlayerStat(ptChar, STATS_MAXPOISONRESIST, 0);
if (maxRes>95) maxRes = 95;
if (curRes < -100) curRes=-100;
if (curRes > maxRes) curRes = maxRes;
if ((curRes == maxRes) && (color != BLUE)) color = GOLD;
else if (curRes < 0) color = RED;
swprintf(text,L"%ld",curRes);
nbPixel = D2GetPixelLen(text);
D2PrintString(text, MILIEU(0x111,0x23,nbPixel), 0x1A4, color, 0);//ESI,EBX,EDI
//////////////////// STAT POINTS REMAINING MANAGEMENT ////////////////////
//print Assign box of btns : Str,Dex,Ene,Vit
setImage(&data, D2AssignStatsPointsBoxImages);
setFrame(&data, 0);
D2PrintImage(&data, getXAssSTRBtn()-3, getYAssSTRBtn()+4, -1, 5, 0);
D2PrintImage(&data, getXAssDEXBtn()-3, getYAssDEXBtn()+4, -1, 5, 0);
D2PrintImage(&data, getXAssENEBtn()-3, getYAssENEBtn()+4, -1, 5, 0);
D2PrintImage(&data, getXAssVITBtn()-3, getYAssVITBtn()+4, -1, 5, 0);
DWORD nbStatPointsRemaining = D2GetPlayerBaseStat(ptChar, 4, 0);
if (nbStatPointsRemaining)
{
//print stat point remaining box image
setImage(&data, D2RemainingStatsPointsBoxImages);
setFrame(&data, 0);
D2PrintImage(&data, 3, 0x16C, -1, 5, 0);
//print "Stat Points Remaining"
D2SetFont(6);
lpText = D2GetStringFromIndex(0xFEB);
nbPixel = D2GetPixelLen(lpText);
D2PrintString(lpText, MILIEU(11,78,nbPixel), 0x163, RED, 0);//163
lpText = D2GetStringFromIndex(0xFEC);
nbPixel = D2GetPixelLen(lpText);
D2PrintString(lpText, MILIEU(11,78,nbPixel), 0x16B, RED, 0);
//print Stat Points Remaining number
D2SetFont(1);
swprintf(text, L"%i", nbStatPointsRemaining);
nbPixel = D2GetPixelLen(text);
D2PrintString(text, MILIEU(92,36,nbPixel), 0x168, WHITE, 0);
setImage(&data, D2AssignStatsPointsBtnImages);
setFrame(&data, isDownBtn.AssSTR);
D2PrintImage(&data, getXAssSTRBtn(), getYAssSTRBtn(), -1, 5, 0);
setFrame(&data, isDownBtn.AssDEX);
D2PrintImage(&data, getXAssDEXBtn(), getYAssDEXBtn(), -1, 5, 0);
setFrame(&data, isDownBtn.AssVIT);
D2PrintImage(&data, getXAssVITBtn(), getYAssVITBtn(), -1, 5, 0);
setFrame(&data, isDownBtn.AssENE);
D2PrintImage(&data, getXAssENEBtn(), getYAssENEBtn(), -1, 5, 0);
} else {
setImage(&data, D2AssignStatsPointsBtnImages);
setFrame(&data, 2);
D2PrintImage(&data, getXAssSTRBtn(), getYAssSTRBtn(), -1, 5, 0);
D2PrintImage(&data, getXAssDEXBtn(), getYAssDEXBtn(), -1, 5, 0);
D2PrintImage(&data, getXAssVITBtn(), getYAssVITBtn(), -1, 5, 0);
D2PrintImage(&data, getXAssENEBtn(), getYAssENEBtn(), -1, 5, 0);
}
if (active_StatsPoints && !onRealm)
{
setImage(&data, D2AssignStatsPointsBoxImages);
setFrame(&data, 0);
D2PrintImage(&data, getXUnaSTRBtn()-3, getYUnaSTRBtn()+4, -1, 5, 0);
D2PrintImage(&data, getXUnaDEXBtn()-3, getYUnaDEXBtn()+4, -1, 5, 0);
D2PrintImage(&data, getXUnaENEBtn()-3, getYUnaENEBtn()+4, -1, 5, 0);
D2PrintImage(&data, getXUnaVITBtn()-3, getYUnaVITBtn()+4, -1, 5, 0);
setImage(&data, unassignStatsBtnImages);
if ((int)charStats->baseSTR < D2GetPlayerBaseStat(ptChar, STATS_STRENGTH, 0))
setFrame(&data, isDownBtn.UnaSTR);
else data.frame = 2;
D2PrintImage(&data, getXUnaSTRBtn(), getYUnaSTRBtn(), -1, 5, 0);
if ((int)charStats->baseDEX < D2GetPlayerBaseStat(ptChar, STATS_DEXTERITY, 0))
setFrame(&data, isDownBtn.UnaDEX);
else setFrame(&data, 2);
D2PrintImage(&data, getXUnaDEXBtn(), getYUnaDEXBtn(), -1, 5, 0);
if ((int)charStats->baseVIT < D2GetPlayerBaseStat(ptChar, STATS_VITALITY, 0))
setFrame(&data, isDownBtn.UnaVIT);
else setFrame(&data, 2);
D2PrintImage(&data, getXUnaVITBtn(), getYUnaVITBtn(), -1, 5, 0);
if ((int)charStats->baseENE < D2GetPlayerBaseStat(ptChar, STATS_ENERGY, 0))
setFrame(&data, isDownBtn.UnaENE);
else setFrame(&data, 2);
D2PrintImage(&data, getXUnaENEBtn(), getYUnaENEBtn(), -1, 5, 0);
}
}
//////////////////// POPUP PRINTING ////////////////////
//set MouseX & MouseY
DWORD x = D2GetMouseX();
DWORD y = D2GetMouseY();
if (isOnCloseBtn(x,y)) // print popup "close"
{
//lpText = D2GetStringFromIndex(0x1030);
//nbPixel = D2GetPixelLen(lpText);
//D2PrintPopup(lpText, getXCloseBtn()+getLCloseBtn()/2-nbPixel/2, getYCloseBtn()-getHCloseBtn(), WHITE, 0);
D2PrintPopup(D2GetStringFromIndex(0x1030), getXCloseBtn()+getLCloseBtn()/2, getYCloseBtn()-getHCloseBtn(), WHITE, 1);
}
else if (isOnPreviousPageBtn(x,y)) //print popup "previous page"
{
lpText = getTranslatedString(STR_PREVIOUS_PAGE);
D2PrintPopup(lpText, getXPreviousPageBtn()+getLPreviousPageBtn()/2, getYPreviousPageBtn()-getHPreviousPageBtn(), WHITE, 1);
}
else if (isOnNextPageBtn(x,y)) //print popup "next page"
{
lpText = getTranslatedString(STR_NEXT_PAGE);
D2PrintPopup(lpText, getXNextPageBtn()+getLNextPageBtn()/2, getYNextPageBtn()-getHNextPageBtn(), WHITE, 1);
}
else if (isOnRect(x, y, 0xAD, 0x137, 0x15, 0x13))
{
if ( version_D2Client <= V110 )
{
DWORD avgChanceMonsterWillHitYou=53;//TODO
if (avgChanceMonsterWillHitYou<5) avgChanceMonsterWillHitYou = 5;
else if (avgChanceMonsterWillHitYou>95) avgChanceMonsterWillHitYou = 95;
int chanceToBlock = D2GetChanceToBlock(ptChar, D2isLODGame());
if (chanceToBlock <= 0)
{
//......TODO
chanceToBlock=0;
}
int monsterID = D2GetLastMonsterIDFight();
MonStatsBIN* monStats = SgptDataTables->monStats + monsterID;
d2_assert((monsterID<0) || (monsterID >= (int)SgptDataTables->nbMonStats) || !monStats, "ptStats", __FILE__, __LINE__);
LPWSTR monsterStr = D2GetStringFromIndex(monStats->monsterNameID);
if (chanceToBlock)
swprintf(text,D2GetStringFromIndex(0x2779),chanceToBlock,avgChanceMonsterWillHitYou,monsterStr,avgChanceMonsterWillHitYou);
else
swprintf(text,D2GetStringFromIndex(0x2778),monsterStr,avgChanceMonsterWillHitYou);
//D2swprintf(0x80
D2PrintTextPopup(text,0x8B,0xA5,*(BYTE*)0x6FBB1A50,2,WHITE);
}
}
}
//////////////////////////////////////////////////////////////////////////////////////////////
DWORD STDCALL mouseNewStatsPageLeftDown(sWinMessage* msg)
{
if (!D2isLODGame() || !D2GetResolution()) return -1;
if (!isOnStatsPage(msg->x,msg->y)) return 1;
Unit* ptChar = D2GetClientPlayer();
if (isOnCloseBtn(msg->x,msg->y))
{
log_msg("push down left button close\n");
isDownBtn.close = 1;
D2PlaySound(4,0,0,0,0);
}
else if (isOnPreviousPageBtn(msg->x,msg->y))
{
log_msg("push down left button previous page\n");
isDownBtn.previousPage = 1;
D2PlaySound(4,0,0,0,0);
}
else if (isOnNextPageBtn(msg->x,msg->y))
{
log_msg("push down left button next page\n");
isDownBtn.nextPage = 1;
D2PlaySound(4,0,0,0,0);
}
else if (D2GetPlayerBaseStat(ptChar, 4, 0))
{
if (isOnAssSTRBtn(msg->x,msg->y))
{
log_msg("push down left button assign strengh\n");
isDownBtn.AssSTR = 1;
D2PlaySound(5,0,0,0,0);
}
else if (isOnAssDEXBtn(msg->x,msg->y))
{
log_msg("push down left button assign dexterity\n");
isDownBtn.AssDEX = 1;
D2PlaySound(5,0,0,0,0);
}
else if (isOnAssVITBtn(msg->x,msg->y))
{
log_msg("push down left button assign vitality\n");
isDownBtn.AssVIT = 1;
D2PlaySound(5,0,0,0,0);
}
else if (isOnAssENEBtn(msg->x,msg->y))
{
log_msg("push down left button assign energy\n");
isDownBtn.AssENE = 1;
D2PlaySound(5,0,0,0,0);
}
}
if (active_StatsPoints && !onRealm)
{
CharStatsBIN* charStats = D2GetCharStatsBIN(ptChar->nPlayerClass);
if (isOnUnaSTRBtn(msg->x,msg->y) && ((int)charStats->baseSTR < D2GetPlayerBaseStat(ptChar, STATS_STRENGTH, 0)))
{
log_msg("push down left button unassign strengh\n");
isDownBtn.UnaSTR = 1;
D2PlaySound(5,0,0,0,0);
}
else if (isOnUnaDEXBtn(msg->x,msg->y) && ((int)charStats->baseDEX < D2GetPlayerBaseStat(ptChar, STATS_DEXTERITY, 0)))
{
log_msg("push down left button unassign dexterity\n");
isDownBtn.UnaDEX = 1;
D2PlaySound(5,0,0,0,0);
}
else if (isOnUnaVITBtn(msg->x,msg->y) && ((int)charStats->baseVIT < D2GetPlayerBaseStat(ptChar, STATS_VITALITY, 0)))
{
log_msg("push down left button unassign vitality\n");
isDownBtn.UnaVIT = 1;
D2PlaySound(5,0,0,0,0);
}
else if (isOnUnaENEBtn(msg->x,msg->y) && ((int)charStats->baseENE < D2GetPlayerBaseStat(ptChar, STATS_ENERGY, 0)))
{
log_msg("push down left button unassign energy\n");
isDownBtn.UnaENE = 1;
D2PlaySound(5,0,0,0,0);
}
}
freeMessage(msg);
return 0;
}
void sendAssignStats(DWORD code, DWORD nbStatPointsRemaining)
{
DWORD nbPoints = GetKeyState(VK_SHIFT)<0? nbStatPointsRemaining : 1;
if (active_StatsShiftClickLimit && (nbPoints>limitValueToShiftClick))
nbPoints = limitValueToShiftClick;
while ( nbPoints>0 )
{
DWORD nbTemp = nbPoints > 0x20 ? 0x20 : nbPoints;
D2SendToServer3(0x3A, (WORD)(code + (nbTemp-1)*256));
nbPoints -= nbTemp;
}
}
DWORD STDCALL mouseNewStatsPageLeftUp(sWinMessage* msg)
{
if (!D2isLODGame() || !D2GetResolution()) return -1;
if (!isOnStatsPage(msg->x,msg->y)) return 1;
Unit* ptChar = D2GetClientPlayer();
DWORD nbStatPointsRemaining = D2GetPlayerBaseStat(ptChar, 4, 0);
if (isOnCloseBtn(msg->x,msg->y))
{
log_msg("push up left button close\n");
if (isDownBtn.close)
D2TogglePage(2,1,0);
}
else if (isOnPreviousPageBtn(msg->x,msg->y))
{
log_msg("push up left button previous page\n");
if (isDownBtn.previousPage)
{
GoStatPage(GetCurrentPage()-1);
log_msg("previous page press\n");
}
}
else if (isOnNextPageBtn(msg->x,msg->y))
{
log_msg("push up left button next page\n");
if (isDownBtn.nextPage)
{
GoNextStatPage();
log_msg("next page press\n");
}
}
else if (nbStatPointsRemaining)
{
if (isOnAssSTRBtn(msg->x,msg->y))
{
log_msg("push up left button assign strengh\n");
if (isDownBtn.AssSTR)
sendAssignStats(0,nbStatPointsRemaining);
}
else if (isOnAssDEXBtn(msg->x,msg->y))
{
log_msg("push up left button assign dexterity\n");
if (isDownBtn.AssDEX)
sendAssignStats(2,nbStatPointsRemaining);
}
else if (isOnAssVITBtn(msg->x,msg->y))
{
log_msg("push up left button assign vitality\n");
if (isDownBtn.AssVIT)
sendAssignStats(3,nbStatPointsRemaining);
}
else if (isOnAssENEBtn(msg->x,msg->y))
{
log_msg("push up left button assign energy\n");
if (isDownBtn.AssENE)
sendAssignStats(1,nbStatPointsRemaining);
}
}
if (active_StatsPoints && !onRealm)
{
CharStatsBIN* charStats = D2GetCharStatsBIN(ptChar->nPlayerClass);
if (isOnUnaSTRBtn(msg->x,msg->y) && ((int)charStats->baseSTR < D2GetPlayerBaseStat(ptChar, STATS_STRENGTH, 0)))
{
log_msg("push up left button unassign strengh\n");
if (isDownBtn.UnaSTR)
if (GetKeyState(VK_SHIFT)<0)
updateServer(US_UNASSIGN_STR_POINTS);
else
updateServer(US_UNASSIGN_STR_POINT);
}
else if (isOnUnaDEXBtn(msg->x,msg->y) && ((int)charStats->baseDEX < D2GetPlayerBaseStat(ptChar, STATS_DEXTERITY, 0)))
{
log_msg("push up left button unassign dexterity\n");
if (isDownBtn.UnaDEX)
if (GetKeyState(VK_SHIFT)<0)
updateServer(US_UNASSIGN_DEX_POINTS);
else
updateServer(US_UNASSIGN_DEX_POINT);
}
else if (isOnUnaVITBtn(msg->x,msg->y) && ((int)charStats->baseVIT < D2GetPlayerBaseStat(ptChar, STATS_VITALITY, 0)))
{
log_msg("push up left button unassign vitality\n");
if (isDownBtn.UnaVIT)
if (GetKeyState(VK_SHIFT)<0)
updateServer(US_UNASSIGN_VIT_POINTS);
else
updateServer(US_UNASSIGN_VIT_POINT);
}
else if (isOnUnaENEBtn(msg->x,msg->y) && ((int)charStats->baseENE < D2GetPlayerBaseStat(ptChar, STATS_ENERGY, 0)))
{
log_msg("push up left button unassign energy\n");
if (isDownBtn.UnaENE)
if (GetKeyState(VK_SHIFT)<0)
updateServer(US_UNASSIGN_ENE_POINTS);
else
updateServer(US_UNASSIGN_ENE_POINT);
}
}
D2CleanStatMouseUp();
freeMessage(msg);
isDownBtn.all=0;
return 0;
}
/*================================= END OF FILE =================================*/

View File

@ -0,0 +1,307 @@
/*=================================================================
File created by Yohann NICOLAS.
Interface stats page 2 functions
=================================================================*/
#include "common.h"
#include "error.h"
#include "d2functions.h"
#include "updateServer.h"
#include "plugYFiles.h"
#include "statsPoints.h"
#include "newInterfaces.h"
#include <stdio.h>
#define getXCloseBtn() RX(0x110)
#define getLCloseBtn() 32
#define getYCloseBtn() RY(0x40)
#define getHCloseBtn() 32
#define isOnCloseBtn(x,y) isOnRect(x, y, getXCloseBtn(), getYCloseBtn(), getLCloseBtn(), getHCloseBtn())
#define getXPreviousPageBtn() RX(D2GetResolution()?0x19:0x77)//0x70
#define getLPreviousPageBtn() 32
#define getYPreviousPageBtn() RY(0x40)
#define getHPreviousPageBtn() 32
#define isOnPreviousPageBtn(x,y) isOnRect(x, y, getXPreviousPageBtn(), getYPreviousPageBtn(), getLPreviousPageBtn(), getHPreviousPageBtn())
#define getXNextPageBtn() RX(D2GetResolution()?0x43:0xA1)//0x70
#define getLNextPageBtn() 32
#define getYNextPageBtn() RY(0x40)
#define getHNextPageBtn() 32
#define isOnNextPageBtn(x,y) isOnRect(x, y, getXNextPageBtn(), getYNextPageBtn(), getLNextPageBtn(), getHNextPageBtn())
#define BUFSIZE 0x80
static struct
{
union{
DWORD all;
struct{
DWORD close:1;
DWORD previousPage:1;
DWORD nextPage:1;
};
};
} isDownBtn;
struct statsInterfaceBIN
{
WORD enabled;
WORD page;
WORD x;
WORD y;
WORD color;
WORD font;
WORD statsID;
};
extern int lastPage;
int nbStatsInterface;
statsInterfaceBIN* statsInterface;
void loadStatsInterfaceDesc(DWORD mempool)
{
log_msg("loadStatsInterfaceDesc(%d)\n",mempool);
CREATE_TABLE_DESCRIPTION(8);
ADD_WORD_FIELD(0, "enabled");
ADD_WORD_FIELD(2, "page");
ADD_WORD_FIELD(4, "x");
ADD_WORD_FIELD(6, "y");
ADD_WORD_FIELD(8, "color");
ADD_WORD_FIELD(10, "font");
// ADD_LOOKUP_WORD(10, "stat", lookupItemStatCost);
ADD_WORD_FIELD(12, "statID");
ADD_TERM_FIELD();
BUILD_BIN(statsInterfaceBIN, statsInterface, nbStatsInterface, "PlugY\\statsinterface.txt");
lastPage = 0;
for (i=0; i<nbStatsInterface; i++)
if (statsInterface[i].page > lastPage)
lastPage = statsInterface[i].page;
}
void freeStatsInterfaceDesc()
{
log_msg("freeStatsInterfaceDesc()\n");
if (statsInterface)
{
D2FogMemDeAlloc(statsInterface,__FILE__,__LINE__,0);
statsInterface = NULL;
nbStatsInterface = 0;
}
}
void printStat(Unit* ptChar, DWORD statID, DWORD x, DWORD y, DWORD color, LPWSTR lpText)
{
LPWSTR text;
log_msg("printStat : %d\n", statID);
switch (statID)
{
case STATS_FIRERESIST:
case STATS_COLDRESIST:
case STATS_LIGHTRESIST:
case STATS_POISONRESIST:
text = D2GetStringFromIndex(getDescStrPos(statID));
if (wcslen(text) > 50) return;
swprintf(lpText, L"%s +%i%%", text, D2GetPlayerStat(ptChar,statID,0));
break;
default:
D2PrintStat(ptChar, NULL, statID, 0, D2GetPlayerStat(ptChar,statID,0), lpText);//param2=ptChar->ptStats->ptItemStats
}
// D2SetFont(1);
// if (D2GetPixelLen(lpText)>0x110)
// D2SetFont(6);
D2PrintString(lpText, x, y, color, 0);
}
void manageStatLine(Unit* ptChar, statsInterfaceBIN* statLine, int currentPage, LPWSTR lpText)
{
if (!statLine->enabled)
return;
if (statLine->page != currentPage)
return;
if (statLine->font)
D2SetFont(statLine->font);
printStat(ptChar, statLine->statsID, RX(statLine->x), RY(statLine->y), statLine->color, lpText);
}
void STDCALL printNewStatsPageTwo(int currentPage)
{
if (!D2isLODGame()) return D2PrintStatsPage();
WCHAR text[BUFSIZE];
LPWSTR lpText;
bDontPrintBorder = false;
Unit* ptChar = D2GetClientPlayer();
d2_assert(!ptChar, "Printing stats page : no character selected",__FILE__,__LINE__);
d2_assert(ptChar->nUnitType != UNIT_PLAYER, "Printing stats page : bad unit type",__FILE__,__LINE__);
//Init data for print image
sDrawImageInfo data;
ZeroMemory(&data,sizeof(data));
//print background
fillRect(RX(0),RY(480),320,432,0,5);//552
setImage(&data, newStatsInterfaceImages);
setFrame(&data, 0);
D2PrintImage(&data, RX(0), RY(224), -1, 5, 0);
setFrame(&data, 1);
D2PrintImage(&data, RX(256),RY(224), -1, 5, 0);//256
setFrame(&data, 2);
D2PrintImage(&data, RX(0), RY(48), -1, 5, 0);//432
setFrame(&data, 3);
D2PrintImage(&data, RX(256),RY(48), -1, 5, 0);
D2SetFont(1);
for (int i=0; i<nbStatsInterface; i++)
manageStatLine(ptChar, &statsInterface[i], currentPage, text);
/*
// DWORD x,y;
// DWORD curValue;
// CharStatsBIN* charStats = D2GetCharStatsBIN(ptChar->nPlayerClass);
// DifficultyLevelsBIN* difficultyLevels = D2GetDifficultyLevelsBIN (D2GetDifficultyLevel());
//print deadly Strike / Critical Strike
x=RX(25);
y=RY(445);
Unit* ptItem = D2GetSkillItem(ptChar);
DWORD cs = ptItem ? D2GetCriticalStrikeFromMasteries(ptChar,ptItem,0,2) : 0;
cs = cs>100?100:cs;
cs += D2GetPlayerStat(ptChar, STATS_PASSIVE_CRITICAL_STRIKE, 0)*(100-cs)/100;
cs = cs>100?100:cs;
//SkillDescBIN* skilldesc = SgptDataTables->skilldesc + 9;
LPWSTR lpCS = D2GetStringFromIndex(skilldesc->strNameID);
lpText = D2GetStringFromIndex(getDescStrPos(STATS_ITEM_DEADLYSTRIKE));
curValue = D2GetPlayerStat(ptChar, STATS_ITEM_DEADLYSTRIKE, 0);
cs += curValue*(100-cs)/100;
curValue = cs>100?100:cs;
swprintf(text,L"%i%% %s/%s",curValue,lpCS,lpText);
D2SetFont(1);
D2SetFont( D2GetPixelLen(text)>0x110 ? 6 : 1);
D2PrintString(text, x, y, WHITE, 0);
*/
//print background previous/next page buttons
setImage(&data, statsBackgroundImages);
setFrame(&data, D2GetResolution()?1:0);
D2PrintImage(&data, getXPreviousPageBtn()-7, getYPreviousPageBtn()+8, -1, 5, 0);
//print button close
setImage(&data, D2LoadBuySelBtn());
setFrame(&data, 10 + isDownBtn.close);
D2PrintImage(&data, getXCloseBtn(), getYCloseBtn(), -1, 5, 0);
//print previous page button
setFrame(&data, 12 + isDownBtn.previousPage);
D2PrintImage(&data, getXPreviousPageBtn(), getYPreviousPageBtn(), -1, 5, 0);
//print next page button
setFrame(&data, 14 + isDownBtn.nextPage);
D2PrintImage(&data, getXNextPageBtn(), getYNextPageBtn(), -1, 5, 0);
//////////////////// POPUP PRINTING ////////////////////
//set MouseX & MouseY
DWORD mx = D2GetMouseX();
DWORD my = D2GetMouseY();
D2SetFont(1);
if (isOnCloseBtn(mx,my)) // print popup "close"
{
D2PrintPopup(D2GetStringFromIndex(0x1030), getXCloseBtn()+getLCloseBtn()/2, getYCloseBtn()-getHCloseBtn(), WHITE, 1);
}
else if (isOnPreviousPageBtn(mx,my)) //print popup "previous page"
{
lpText = getTranslatedString(STR_PREVIOUS_PAGE);
D2PrintPopup(lpText, getXPreviousPageBtn()+getLPreviousPageBtn()/2, getYPreviousPageBtn()-getHPreviousPageBtn(), WHITE, 1);
}
else if (isOnNextPageBtn(mx,my)) //print popup "next page"
{
lpText = getTranslatedString(STR_NEXT_PAGE);
D2PrintPopup(lpText, getXNextPageBtn()+getLNextPageBtn()/2, getYNextPageBtn()-getHNextPageBtn(), WHITE, 1);
}
}
//////////////////////////////////////////////////////////////////////////////////////////////
DWORD STDCALL mouseNewStatsPageTwoLeftDown(sWinMessage* msg)
{
if (!D2isLODGame()) return -1;
DWORD x = D2GetMouseX();
DWORD y = D2GetMouseY();
if (!isOnStatsPage(x,y)) return 1;
if (isOnCloseBtn(x,y))
{
log_msg("push down left button close\n");
isDownBtn.close = 1;
D2PlaySound(4,0,0,0,0);
}
else if (isOnPreviousPageBtn(x,y))
{
log_msg("push down left button previous page\n");
isDownBtn.previousPage = 1;
D2PlaySound(4,0,0,0,0);
}
else if (isOnNextPageBtn(x,y))
{
log_msg("push down left button next page\n");
isDownBtn.nextPage = 1;
D2PlaySound(4,0,0,0,0);
}
freeMessage(msg);
return 0;
}
DWORD STDCALL mouseNewStatsPageTwoLeftUp(sWinMessage* msg)
{
if (!D2isLODGame()) return -1;
DWORD x = D2GetMouseX();
DWORD y = D2GetMouseY();
if (!isOnStatsPage(x,y)) return 1;
if (isOnCloseBtn(x,y))
{
log_msg("push up left button close\n");
if (isDownBtn.close)
D2TogglePage(2,1,0);
}
else if (isOnPreviousPageBtn(x,y))
{
log_msg("push up left button previous page\n");
if (isDownBtn.previousPage)
GoPreviousStatPage();
}
else if (isOnNextPageBtn(x,y))
{
log_msg("push up left button next page\n");
if (isDownBtn.nextPage)
GoNextStatPage();
}
D2CleanStatMouseUp();
freeMessage(msg);
isDownBtn.all=0;
return 0;
}
/*================================= END OF FILE =================================*/

416
PlugY/NewInterfaces.cpp Normal file
View File

@ -0,0 +1,416 @@
/*=================================================================
File created by Yohann NICOLAS.
Interface functions
=================================================================*/
#include "common.h"
#include "error.h"
#include "d2functions.h"
#include "globalVariable.h"
#include "updateServer.h" // Install_UpdateServer()
#include "plugYFiles.h" // Install_PlugYImagesFiles()
#include "interface_Stats.h"// Install_InterfaceStats()
#include "newInterfaces.h"
#include "newInterface_Stats.h"
#include "newInterface_StatsPageTwo.h"
#include "newInterface_Runewords.h"
#include <stdio.h>
bool active_newInterfaces=false;
bool selectMainPageOnOpenning=true;
bool printBackgroundOnMainPage=true;
DWORD bDontPrintBorder=false;
int selectedPage=0;
int lastPage=0;
int extraHiddenPage=0;
void GoNextStatPage()
{
selectedPage++;
if ( selectedPage > lastPage)
selectedPage = 0;
}
void GoPreviousStatPage()
{
selectedPage--;
if ( selectedPage < 0 )
selectedPage = lastPage;
}
void GoStatPage(int page)
{
if ( (page >= 0) && (page <= lastPage + (D2GetResolution()? extraHiddenPage : 0)) )
selectedPage = page;
}
int GetCurrentPage()
{
return selectedPage;
}
void STDCALL printCustomPage()
{
if(onRealm) {D2PrintStatsPage();return;}
if ( (selectedPage > 0) && (selectedPage<=lastPage) )
printNewStatsPageTwo(selectedPage);
else if (selectedPage == lastPage+1)
printRunewordsPage();
else if (selectedPage == lastPage+2)
printNewStatsPage();
else
D2PrintStatsPage();
}
DWORD STDCALL mouseCustomPageLeftDown(sWinMessage* msg)
{
if(onRealm) return -1;
if ( (selectedPage > 0) && (selectedPage<=lastPage) )
return mouseNewStatsPageTwoLeftDown(msg);
else if (selectedPage == lastPage+1)
return mouseRunewordsPageLeftDown(msg);
else if (selectedPage == lastPage+2)
return mouseNewStatsPageLeftDown(msg);
else
return -1;
}
DWORD STDCALL mouseCustomPageLeftUp(sWinMessage* msg)
{
if(onRealm) return -1;
if ( (selectedPage > 0) && (selectedPage <= lastPage) )
return mouseNewStatsPageTwoLeftUp(msg);
else if (selectedPage == lastPage+1)
return mouseRunewordsPageLeftUp(msg);
else if (selectedPage == lastPage+2)
return mouseNewStatsPageLeftUp(msg);
else
return -1;
}
FCT_ASM ( caller_DontPrintBorder_111 )
MOV ECX,bDontPrintBorder
TEST ECX,ECX
JE printBorder
MOV bDontPrintBorder,0
ADD DWORD PTR SS:[ESP],0xBC
RETN
printBorder:
MOV ECX,0x12
RETN
}}
FCT_ASM ( caller_DontPrintBorder )
MOV ECX,bDontPrintBorder
TEST ECX,ECX
JE printBorder
MOV bDontPrintBorder,0
ADD DWORD PTR SS:[ESP],0xB6
RETN
printBorder:
MOV ECX,0x12
RETN
}}
FCT_ASM ( caller_mouseCustomPageLeftDown_111 )
PUSH EAX
PUSH ESI
CALL mouseCustomPageLeftDown
TEST EAX,EAX
POP EAX
JE end_mouseNewPageLDown
JG continue_mouseNewPageLDown
LEA ECX,DWORD PTR DS:[EAX+0x80]
RETN
continue_mouseNewPageLDown:
POP EAX
ADD EAX,0x143
PUSH EDI
JMP EAX
RETN
end_mouseNewPageLDown:
ADD ESP,4
POP ESI
POP EBP
POP EBX
RETN 4
}}
FCT_ASM ( caller_mouseCustomPageLeftDown )
PUSH EAX
PUSH EDI
CALL mouseCustomPageLeftDown
TEST EAX,EAX
POP EAX
JE end_mouseNewPageLDown
JG continue_mouseNewPageLDown
LEA ECX,DWORD PTR DS:[EAX+0x80]
RETN
continue_mouseNewPageLDown:
ADD DWORD PTR SS:[ESP],0x152
RETN
end_mouseNewPageLDown:
ADD ESP,4
POP EDI
POP ESI
POP EBP
POP EBX
RETN 4
}}
FCT_ASM ( caller_mouseCustomPageLeftDown_9 )
PUSH EAX
PUSH EDI
CALL mouseCustomPageLeftDown
TEST EAX,EAX
POP EAX
JE end_mouseNewPageLDown
JG continue_mouseNewPageLDown
LEA ECX,DWORD PTR DS:[EAX+0x80]
RETN
continue_mouseNewPageLDown:
ADD DWORD PTR SS:[ESP],0x149
RETN
end_mouseNewPageLDown:
ADD ESP,4
POP EDI
POP ESI
POP EBP
POP EBX
RETN 4
}}
FCT_ASM ( caller_mouseCustomPageLeftUp_111 )
PUSH EBP
CALL mouseCustomPageLeftUp
TEST EAX,EAX
JE end_mouseNewPageLUp
JG continue_mouseNewPageLUp
MOV EAX,DWORD PTR DS:[ptWindowStartX]
MOV EAX,DWORD PTR DS:[EAX]
RETN
continue_mouseNewPageLUp:
ADD DWORD PTR SS:[ESP],0x2C4
RETN
end_mouseNewPageLUp:
ADD ESP,4
POP EDI
POP ESI
POP EBP
POP EBX
ADD ESP,8
RETN 4
}}
FCT_ASM ( caller_mouseCustomPageLeftUp )
PUSH EBP
CALL mouseCustomPageLeftUp
TEST EAX,EAX
JE end_mouseNewPageLUp
JG continue_mouseNewPageLUp
MOV EAX,DWORD PTR DS:[ptWindowStartX]
MOV EAX,DWORD PTR DS:[EAX]
RETN
continue_mouseNewPageLUp:
ADD DWORD PTR SS:[ESP],0x1AE
RETN
end_mouseNewPageLUp:
ADD ESP,4
POP EDI
POP ESI
POP EBP
POP EBX
ADD ESP,8
RETN 4
}}
FCT_ASM ( caller_mouseCustomPageLeftUp_9 )
PUSH EBP
CALL mouseCustomPageLeftUp
TEST EAX,EAX
JE end_mouseNewPageLUp
JG continue_mouseNewPageLUp
MOV EAX,DWORD PTR DS:[ptWindowStartX]
MOV EAX,DWORD PTR DS:[EAX]
RETN
continue_mouseNewPageLUp:
ADD DWORD PTR SS:[ESP],0x16A
RETN
end_mouseNewPageLUp:
ADD ESP,4
POP EDI
POP ESI
POP EBP
POP EBX
POP ECX
RETN 4
}}
FCT_ASM ( caller_resetSelectedPageByToolBar )
MOV selectedPage,0
CMP EAX,0x26
JNZ noJump
ADD DWORD PTR SS:[ESP],0x1F
noJump:
RETN
}}
FCT_ASM ( caller_resetSelectedPageByKey )
MOV selectedPage,0
POP EAX
PUSH EBP
XOR EBP,EBP
CMP EDX,EBP
JMP EAX
}}
FCT_ASM ( caller_resetSelectedPage )
TEST EAX,EAX
SETE DL
JNZ END_resetSelectedPage
CMP ESI,2
JNZ END_resetSelectedPage
MOV selectedPage,0
END_resetSelectedPage:
RETN
}}
void Install_NewInterfaces()
{
static int isInstalled = false;
if (isInstalled) return;
Install_UpdateServer();
Install_PlugYImagesFiles();
Install_PlugYTxtFiles();
Install_InterfaceStats();
log_msg("Patch D2Client for new custom page interface. (NewInterfaces)\n");
if ( version_D2Client >= V110 )
extraHiddenPage=1;
if (selectMainPageOnOpenning)
{
if ( version_D2Client >= V111 )
{
//Reset selectedPage variable on opening stats page
mem_seek R7(D2Client, 0000, 0000, 0000, 4B79E, 8F73E, 55E0E, 65F5E);
memt_byte( 0x83, 0xE8 ); // CALL caller_resetSelectedPage
MEMT_REF4( 0x1F7426F8, caller_resetSelectedPageByToolBar);
//6FAFB79E > 83F8 26 CMP EAX,26
//6FAFB7A1 . 74 1F JE SHORT D2Client.6FAFB7C2
//6FB3F73E > 83F8 26 CMP EAX,26
//6FB3F741 . 74 1F JE SHORT D2Client.6FB3F762
//6FB05E0E > 83F8 26 CMP EAX,26
//6FB05E11 . 74 1F JE SHORT D2Client.6FB05E32
//6FB15F5E > 83F8 26 CMP EAX,26
//6FB15F61 . 74 1F JE SHORT D2Client.6FB15F82
mem_seek R7(D2Client, 0000, 0000, 0000, 1E55A, 6A8FA, A31DA, 3C5EA);
memt_byte( 0x55, 0xE8 ); // CALL caller_resetSelectedPage
MEMT_REF4( 0xD53BED33, caller_resetSelectedPageByKey);
//6FACE55A . 55 PUSH EBP
//6FACE55B . 33ED XOR EBP,EBP
//6FACE55D . 3BD5 CMP EDX,EBP
//6FB1A8FA . 55 PUSH EBP
//6FB1A8FB . 33ED XOR EBP,EBP
//6FB1A8FD . 3BD5 CMP EDX,EBP
//6FB531DA . 55 PUSH EBP
//6FB531DB . 33ED XOR EBP,EBP
//6FB531DD . 3BD5 CMP EDX,EBP
//6FAEC5EA . 55 PUSH EBP
//6FAEC5EB . 33ED XOR EBP,EBP
//6FAEC5ED . 3BD5 CMP EDX,EBP
//For Toggle fct : (not used for open the stat page)
// mem_seek R7(D2Client, 88B58, 87ED8, 83478, A1FBE, 6571E, 8EF8E, 0000);//((DWORD)D2TogglePage+0x218);
// memt_byte( 0x3B, 0xE8 );
// MEMT_REF4( 0x393974C5, caller_resetSelectedPage_111);
// memt_byte( 0x28, 0x90 ); // NOP
//6FB51FBE |. 3BC5 CMP EAX,EBP ; Case 2 of switch 6FB51FB8
//6FB51FC0 |. 74 39 JE SHORT D2Client.6FB51FFB
//6FB51FC2 |. 3928 CMP DWORD PTR DS:[EAX],EBP
//6FB1571E |. 3BC5 CMP EAX,EBP ; Case 2 of switch 6FB15718
//6FB15720 |. 74 39 JE SHORT D2Client.6FB1575B
//6FB15722 |. 3928 CMP DWORD PTR DS:[EAX],EBP
//6FB3EF8E |. 3BC5 CMP EAX,EBP ; Case 2 of switch 6FB3EF88
//6FB3EF90 |. 74 39 JE SHORT D2Client.6FB3EFCB
//6FB3EF92 |. 3928 CMP DWORD PTR DS:[EAX],EBP
} else {
//Reset selectedPage variable on opening stats page
mem_seek R7(D2Client, 88B58, 87ED8, 83478, A1FBE, 6571E, 8EF8E, 0000);//((DWORD)D2TogglePage+0x218);
memt_byte( 0x85, 0xE8 ); // CALL caller_resetSelectedPage
MEMT_REF4( 0xC2940FC0, caller_resetSelectedPage);
//6FB23478 |. 85C0 TEST EAX,EAX
//6FB2347A |. 0F94C2 SETE DL
//FOR 1.11
}
}
// Print custom page
mem_seek R7(D2Client, 87697, 86A17, 81FAB, A3759, 66B59, 902B9, C3B49);
MEMC_REF4( D2PrintStatsPage, printCustomPage);
//6FB21FAA . E8 B1DDFAFF CALL D2Client.6FACFD60
//6FB53758 . E8 43F1FDFF CALL D2Client.6FB328A0
//6FB16B58 |. E8 C3270200 CALL D2Client.6FB39320
//6FB402B8 |. E8 C3AFFDFF CALL D2Client.6FB1B280
//6FB73B48 |. E8 5393FFFF CALL D2Client.6FB6CEA0
// Don't print Border
mem_seek R7(D2Client, 58EF6, 58EF6, 5F4C6, 2D366, B5A46, 82166, 271C6);
memt_byte( 0xB9, 0xE8 ); // CALL caller_DontPrintBorder
MEMT_REF4( 0x00000012, version_D2Client >= V111 ? caller_DontPrintBorder_111 : caller_DontPrintBorder);
//6FAFF4C6 > B9 12000000 MOV ECX,12
//6FADD366 |. B9 12000000 MOV ECX,12
//6FB65A46 |. B9 12000000 MOV ECX,12
//6FB32166 |. B9 12000000 MOV ECX,12
//6FAD71C6 |. B9 12000000 MOV ECX,12
// Manage mouse down (Play sound)
mem_seek R7(D2Client, 2A9DC, 2A9CC, 312A5, 82736, 891B6, 6B116, BCD36);
memt_byte( 0x8D, 0xE8 ); // CALL
MEMT_REF4( 0x00008088, version_D2Client >= V111 ? caller_mouseCustomPageLeftDown_111 : version_D2Client == V110 ? caller_mouseCustomPageLeftDown : caller_mouseCustomPageLeftDown_9);
memt_byte( 0x00, 0x90 ); // NOP
//6FAD12A5 . 8D88 80000000 LEA ECX,DWORD PTR DS:[EAX+80]
//6FB32736 . 8D88 80000000 LEA ECX,DWORD PTR DS:[EAX+80]
//6FB391B6 . 8D88 80000000 LEA ECX,DWORD PTR DS:[EAX+80]
//6FB1B116 . 8D88 80000000 LEA ECX,DWORD PTR DS:[EAX+80]
//6FB6CD36 . 8D88 80000000 LEA ECX,DWORD PTR DS:[EAX+80]
// Manage mouse up
mem_seek R7(D2Client, 2ABBB, 2ABAB, 3148D, 836D9, 8A159, 6C0B9, BDCB9);
memt_byte( 0xA1, 0xE8 ); // CALL caller_mouseCustomPageLeftUp
MEMT_REF4( ptWindowStartX, version_D2Client >= V111 ? caller_mouseCustomPageLeftUp_111 : version_D2Client == V110 ? caller_mouseCustomPageLeftUp : caller_mouseCustomPageLeftUp_9);
//6FAD148D . A1 48A7BB6F MOV EAX,DWORD PTR DS:[6FBBA748]
//6FB336D9 . A1 24BDBC6F MOV EAX,DWORD PTR DS:[6FBCBD24]
//6FB3A159 . A1 F8BEBC6F MOV EAX,DWORD PTR DS:[6FBCBEF8]
//6FB1C0B9 . A1 28BDBC6F MOV EAX,DWORD PTR DS:[6FBCBD28]
//6FB6DCB9 . A1 A0B9BC6F MOV EAX,DWORD PTR DS:[6FBCB9A0]
// open page : 6FB23515 |> 892CB5 A8A6BB6>MOV DWORD PTR DS:[ESI*4+6FBBA6A8],EBP
//6FB2347D |. 8914B5 A8A6BB6F MOV DWORD PTR DS:[ESI*4+6FBBA6A8],EDX
log_msg("\n");
isInstalled = true;
}
/*================================= END OF FILE =================================*/

131
PlugY/OthersFeatures.cpp Normal file
View File

@ -0,0 +1,131 @@
/*=================================================================
File created by Yohann NICOLAS.
Others features.
=================================================================*/
#include "common.h"
#include "error.h"
#include "d2functions.h"
bool active_othersFeatures = false;
/*
// Remove protect on the save file .d2s
mem_seek( offset_D2Game + 0x77080);//6FC8DD5E-6FAA0000
memt_byte( 0x74, 0xEB ); // JMP SHORT D2Game.6FC8DD6D
//6FC8DD5E 74 0D JE SHORT D2Game.6FC8DD6D
*/
/*
void Install_ChangeResolution()
{
static int isInstalled = false;
if (isInstalled) return;
log_msg("Patch D2gfx for . (ChangeResolution)\n");
// execute if it's our packet else continue
mem_seek( offset_D2Client + 0x23ED);//6FAA23EC-6FAA0000
memt_dword( 0x280, 0x400 );
//6FAA23EC B8 80020000 MOV EAX,280 ; Case 0 of switch 6FAA23C2
mem_seek( offset_D2Client + 0x23F7);//6FAA23F1-6FAA0000
memt_dword( 0x1E0, 0x300 );
//6FAA23F1 C705 F040B76F E0>MOV DWORD PTR DS:[6FB740F0],1E0
// change resolution
mem_seek R7(D2gfx, 4B91, 4B91, 4B61, 0000, 0000, 0000, 0000);
memt_dword( 0x280, 0x400 );
//6FA74B5D > C74424 14 8002>MOV DWORD PTR SS:[ESP+14],280 ; Case 0 of switch 6FA74B45
mem_seek R7(D2gfx, 4B96, 4B96, 4B66, 0000, 0000, 0000, 0000);
memt_dword( 0x1E0, 0x300 );
//6FA74B65 . B8 E0010000 MOV EAX,1E0
// refresh size
mem_seek( offset_D2Gdi + 0x118F);//6F831189-6F830000
memt_dword( 0x280, 0x400 );
//6F831189 |> C705 7CC0836F >MOV DWORD PTR DS:[6F83C07C],280
mem_seek( offset_D2Gdi + 0x1199);//6F831193-6F830000
memt_dword( 0x1E0, 0x300 );
//6F831193 |. C705 8CC4836F >MOV DWORD PTR DS:[6F83C48C],1E0
log_msg("\n");
isInstalled = true;
}
///////////////////////////////////////////////////////////////////////////////////////////
DWORD SetDisabledStat(Unit* ptItem, Stats* ptStats, DWORD disabled)
{
if (!ptItem || !ptStats)
return 0;
if (disabled)
{
if (!ptStats->isDisabled)
{
D2PreUpdateDisabledStat(ptStats);
ptStats->isDisabled = 1;
D2UpdateDisabledStat(ptItem->ptStats,ptStats,1);
return 1;
}
} else if (ptStats->isDisabled)
{
D2PreUpdateDisabledStat(ptStats);
ptStats->isDisabled = 0;
D2UpdateDisabledStat(ptItem->ptStats,ptStats,1);
}
return 0;
}
void STDCALL Test2Fct (Unit* ptChar, Unit* ptItem)
{
SetDisabledStat(ptItem, ptItem->ptStats->ptStatsList, 0);//(DWORD)(rand()/(RAND_MAX+1.0)*2));
}
FCT_ASM ( caller_Test2 )
PUSH EDI //ptItem
PUSH ESI //ptChar
CALL Test2Fct
POP ECX
PUSH EBX
MOV EAX,DWORD PTR DS:[ESI]
XOR EBX,EBX
JMP ECX
}}
void Install_Test2()
{
static int isInstalled = false;
if (isInstalled) return;
log_msg("Patch D2Game. (Test)\n");
// Test
mem_seek( offset_D2Game + 0x1253C);//6FC4253C-6FC30000
memt_byte( 0x8B, 0xE8 ); // CALL caller_BnetBtnPress
MEMT_REF4( 0xDB335306, caller_Test2);
//6FC4253C |> 8B06 MOV EAX,DWORD PTR DS:[ESI]
//6FC4253E |. 53 PUSH EBX
//6FC4253F |. 33DB XOR EBX,EBX
isInstalled = true;
}*/
///////////////////////////////////////////////////////////////////////////////////////////////
void Install_OthersFeatures()
{
static int isInstalled = false;
if (isInstalled) return;
log_msg("Patch. (OthersFeatures)\n");
// Install_ChangeResolution();
// Install_Test();
isInstalled = true;
}
/*================================= END OF FILE =================================*/

818
PlugY/Parameters.cpp Normal file
View File

@ -0,0 +1,818 @@
/*=================================================================
File created by Yohann NICOLAS.
Loading parameters from ini file.
=================================================================*/
// Core Class Headers
#include <stdio.h>
#include <string.h>
#include <time.h>
#include "common.h"
#include "error.h"
#include "parameters.h" // loadParameters()
#include "D2functions.h"
#include "INIfile.h"
#define PARAMETERS_FILENAME "PlugY.ini"
#define PARAM_FIXED_FILENAME "PlugY\\PlugYFixed.ini"
#define PARAM_DEFAULT_FILENAME "PlugY\\PlugYDefault.ini"
#define BUFSIZE 0x400
#include "statsPoints.h"
#include "mainScreen.h"
#include "skillPerLevelUp.h"
#include "statPerLevelUp.h"
#include "savePath.h"
#include "bigStash.h"
#include "skillsPoints.h"
#include "infinityStash.h"
#include "othersFeatures.h"
#include "newInterfaces.h"
#include "worldEvent.h"
#include "uberQuest.h"
#include "extraOptions.h"
#include "commands.h"
#include "language.h"
extern bool displayGreenSetItemIncludeSharedStash;
char* modDataDirectory = "PlugY";
bool active_plugin = true;
bool active_DisableBattleNet = true;
bool active_CheckMemory = true;
bool active_D2Mod = false;
char* dllFilenames;
TargetMod selectModParam = MOD_NO;
const char* S_GENERAL = "GENERAL";
const char* S_dllFilenames = "DllToLoad";
const char* S_dllFilenames2 = "DllToLoad2";
const char* S_active_plugin = "ActivePlugin";
const char* S_active_DisableBattleNet = "DisableBattleNet";
const char* S_active_logFile = "ActiveLogFile";
const char* S_active_CheckMemory = "ActiveCheckMemory";
const char* S_active_Commands = "ActiveCommands";
const char* S_active_othersFeatures = "ActiveAllOthersFeatures";
const char* S_LANGUAGE = "LANGUAGE";
const char* S_active_ChangeLanguage = "ActiveChangeLanguage";
const char* S_selectedLanguage = "SelectedLanguage";
const char* S_active_LanguageManagement = "ActiveLanguageManagement";
const char* S_defaultLanguage = "DefaultLanguage";
const char* S_availableLanguages = "AvailableLanguages";
const char* S_SAVEPATH = "SAVEPATH";
const char* S_active_changingSavePath = "ActiveSavePathChange";
const char* S_savePath = "SavePath";
const char* S_MAIN_SCREEN = "MAIN SCREEN";
const char* S_active_VersionTextChange = "ActiveVersionTextChange";
const char* S_active_VersionTextChanges = "ActiveVersionTextChanges";
const char* S_versionText = "VersionText";
const char* S_modVersionColor = "ColorOfVersionText";
const char* S_active_PrintPlugYVersion = "ActivePrintPlugYVersion";
const char* S_colorOfPlugYVersion = "ColorOfPlugYVersion";
const char* S_STASH = "STASH";
const char* S_active_multiPageStash = "ActiveMultiPageStash";
const char* S_maxSelfPages = "MaxPersonnalPages";
const char* S_nbPagesPerIndex = "NbPagesPerIndex";
const char* S_nbPagesPerIndex2 = "NbPagesPerIndex2";
const char* S_active_sharedStash = "ActiveSharedStash";
const char* S_maxSharedPages = "MaxSharedPages";
const char* S_sharedStashFilename = "SharedStashFilename";
const char* S_separateHardSoftStash = "SeparateHardcoreStash";
const char* S_active_bigStash = "ActiveBigStash";
const char* S_displaySharedSetItemNameInGreen = "DisplaySharedSetItemNameInGreen";
const char* S_active_sharedGold = "ActiveSharedGold";
const char* S_posXPreviousBtn = "PosXPreviousBtn";
const char* S_posYPreviousBtn = "PosYPreviousBtn";
const char* S_posXNextBtn = "PosXNextBtn";
const char* S_posYNextBtn = "PosYNextBtn";
const char* S_posXSharedBtn = "PosXSharedBtn";
const char* S_posYSharedBtn = "PosYSharedBtn";
const char* S_posXPreviousIndexBtn = "PosXPreviousIndexBtn";
const char* S_posYPreviousIndexBtn = "PosYPreviousIndexBtn";
const char* S_posXNextIndexBtn = "PosXNextIndexBtn";
const char* S_posYNextIndexBtn = "PosYNextIndexBtn";
const char* S_posXPutGoldBtn = "PosXPutGoldBtn";
const char* S_posYPutGoldBtn = "PosYPutGoldBtn";
const char* S_posXTakeGoldBtn = "PosXTakeGoldBtn";
const char* S_posYTakeGoldBtn = "PosYTakeGoldBtn";
const char* S_STATS_POINTS = "STATS POINTS";
const char* S_active_StatsPoints = "ActiveStatsUnassignment";
const char* S_keyUsedForUnassignStatPoint = "KeyUsed";
const char* S_active_StatsShiftClickLimit = "ActiveShiftClickLimit";
const char* S_limitValueToShiftClick = "LimitValueToShiftClick";
const char* S_SKILL_ON_LEVEL_UP = "SKILL ON LEVEL UP";
const char* S_active_SkillPerLevelUpChange = "ActiveSkillPerLevelUp";
const char* S_skillPerLevelUp = "SkillPerLevelUp";
const char* S_STAT_ON_LEVEL_UP = "STAT ON LEVEL UP";
const char* S_active_StatPerLevelUpChange = "ActiveStatPerLevelUp";
const char* S_statPerLevelUp = "StatPerLevelUp";
const char* S_WORLD_EVENT = "WORLD EVENT";
const char* S_active_WorldEvent = "ActiveWorldEvent";
const char* S_showSOJSoldCounterInAllDiff = "ShowCounterInAllDifficulty";
const char* S_itemsToSell = "ItemsToSell";
const char* S_worldEventmonsterID = "MonsterID";
const char* S_valueOfOwnSOJSold = "OwnSOJSoldChargeFor";
const char* S_valueInitSOJSoldMin = "InititalSOJSoldMin";
const char* S_valueInitSOJSoldDelta = "InititalSOJSoldMax";
const char* S_triggerAtSolJSoldMin = "TriggerAtEachSOJSoldMin";
const char* S_triggerAtSolJSoldDelta = "TriggerAtEachSOJSoldMax";
const char* S_active_AutomaticSell = "ActiveAutoSell";
const char* S_timeBeforeAutoSellMin = "TimeBeforeAutoSellMin";
const char* S_timeBeforeAutoSellDelta = "TimeBeforeAutoSellMax";
const char* S_UBER_QUEST = "UBER QUEST";
const char* S_active_UberQuest = "ActiveUberQuest";
const char* S_SKILLS_POINTS = "SKILLS POINTS";
const char* S_active_SkillsPoints = "ActiveSkillsUnassignment";
const char* S_unassignSkillsPointsOneByOne = "ActiveSkillsUnassignmentOneByOne";
const char* S_posXUnassignSkillBtn = "PosXUnassignSkillBtn";
const char* S_posYUnassignSkillBtn = "PosYUnassignSkillBtn";
const char* S_INTERFACE = "INTERFACE";
const char* S_active_newInterfaces = "ActiveNewStatsInterface";
const char* S_selectMainPageOnOpenning = "SelectMainPageOnOpenning";
const char* S_printBackgroundOnMainPage = "PrintButtonsBackgroundOnMainStatsPage";
const char* S_EXTRA = "EXTRA";
const char* S_active_alwaysRegenMapInSP = "AlwaysRegenMapInSP";
const char* S_nbPlayersCommandByDefault = "NBPlayersByDefault";
const char* S_active_DisplayItemLevel = "ActiveDisplayItemLevel";
const char* S_active_RunLODs = "ActiveLaunchAnyNumberOfLOD";
const char* S_active_AlwaysDisplayLifeMana = "AlwaysDisplayLifeAndManaValues";
const char* S_active_EnabledTXTFilesWithMSExcel= "EnabledTXTFilesWhenMSExcelOpenIt";
const char* S_active_DisplayBaseStatsValue = "ActiveDisplayBaseStatsValue";
const char* S_active_LadderRunewords = "ActiveLadderRunewords";
const char* S_active_EnabledCowPortalWhenCowKingWasKill = "ActiveCowPortalWhenCowKingWasKilled";
const char* S_DLL = "DLL:\t";
const char* S_DEFAULT = "DEFAULT:";
const char* S_USER = "USER:\t";
const char* S_FIXED = "FIXED:\t";
#define GET_PRIVATE_PROFILE_STRING(S,F,D)\
if (!iniFixedFile->GetPrivateProfileString(S, F, NULL, buffer, maxSize)) \
if (!iniFile->GetPrivateProfileString(S, F, NULL, buffer, maxSize)) \
if (!iniDefaultFile->GetPrivateProfileString(S, F, D, buffer, maxSize)) \
log_msg(S_DLL); \
else log_msg(S_DEFAULT); \
else log_msg(S_USER); \
else log_msg(S_FIXED)
#define GET_PRIVATE_PROFILE_STRING2(S,F,D)\
if (!iniFile->GetPrivateProfileString(S, F, NULL, buffer, maxSize)) \
if (!iniDefaultFile->GetPrivateProfileString(S, F, D, buffer, maxSize)) \
log_msg(S_DLL); \
else log_msg(S_DEFAULT); \
else log_msg(S_USER)
#define GET_PRIVATE_PROFILE_STRING3(S,F,D)\
if (!iniFile->GetPrivateProfileString(S, F, NULL, buffer, maxSize)) \
if (!iniFixedFile->GetPrivateProfileString(S, F, NULL, buffer, maxSize)) \
if (!iniDefaultFile->GetPrivateProfileString(S, F, D, buffer, maxSize)) \
log_msg(S_DLL); \
else log_msg(S_DEFAULT); \
else log_msg(S_FIXED); \
else log_msg(S_USER)
void init_ActivePlugin(INIFile* iniFile, INIFile* iniFixedFile, INIFile* iniDefaultFile, char* buffer, DWORD maxSize)
{
iniFixedFile->GetPrivateProfileString(S_GENERAL, S_active_plugin, "0", buffer, maxSize);
active_plugin = atoi(buffer) != 0;
if (!active_plugin)
{
GET_PRIVATE_PROFILE_STRING2(S_GENERAL, S_active_plugin, "1");
active_plugin = atoi(buffer) != 0;
} else log_msg(S_FIXED);
log_msg("active_plugin\t\t\t\t= %u\n", active_plugin);
}
void init_General(INIFile* iniFile, INIFile* iniFixedFile, INIFile* iniDefaultFile, char* buffer, DWORD maxSize)
{
GET_PRIVATE_PROFILE_STRING(S_GENERAL, S_active_DisableBattleNet, "0");
active_DisableBattleNet = atoi(buffer) != 0;
log_msg("active_DisableBattleNet\t\t\t\t= %d\n", active_DisableBattleNet);
GET_PRIVATE_PROFILE_STRING(S_GENERAL, S_active_logFile, "0");
active_logFile = atoi(buffer)+1;
log_msg("active_logFile\t\t\t\t= %d\n", active_logFile-1);
GET_PRIVATE_PROFILE_STRING(S_GENERAL, S_active_Commands, "0");
active_Commands = atoi(buffer) != 0;
log_msg("active_Commands\t\t\t\t= %d\n", active_Commands);
GET_PRIVATE_PROFILE_STRING(S_GENERAL, S_active_CheckMemory, "1");
active_CheckMemory = atoi(buffer) != 0;
log_msg("active_CheckMemory\t\t\t= %d\n", active_CheckMemory);
GET_PRIVATE_PROFILE_STRING(S_GENERAL, S_active_othersFeatures, "0");
active_othersFeatures = atoi(buffer) != 0;
log_msg("active_othersFeatures\t\t= %u\n", active_othersFeatures);
GET_PRIVATE_PROFILE_STRING(S_GENERAL,S_dllFilenames,"");
strcat(buffer,"|");
char* buf = &buffer[strlen(buffer)];
if (!iniFixedFile->GetPrivateProfileString(S_GENERAL, S_dllFilenames2, NULL, buf, maxSize))
if (!iniFile->GetPrivateProfileString(S_GENERAL, S_dllFilenames2, NULL, buf, maxSize))
iniDefaultFile->GetPrivateProfileString(S_GENERAL, S_dllFilenames2, NULL, buf, maxSize);
dllFilenames = (char*)D2FogMemAlloc(strlen(buffer)+1,__FILE__,__LINE__,0);
strcpy(dllFilenames,buffer);
log_msg("dllFilenames\t\t\t\t= %s\n",dllFilenames);
log_msg("\n");
}
void init_ActiveLanguage(INIFile* iniFile, INIFile* iniFixedFile, INIFile* iniDefaultFile, char* buffer, DWORD maxSize)
{
GET_PRIVATE_PROFILE_STRING(S_LANGUAGE, S_active_ChangeLanguage, "0");
active_ChangeLanguage = atoi(buffer) != 0;
log_msg("active_ChangeLanguage\t\t= %d\n", active_ChangeLanguage);
if (active_ChangeLanguage)
{
GET_PRIVATE_PROFILE_STRING(S_LANGUAGE, S_selectedLanguage, "ENG");
strupr(buffer);
switch (*(DWORD*)buffer)
{
case BIN('E','N','G',0) : selectedLanguage=LNG_ENG;break;
case BIN('E','S','P',0) : selectedLanguage=LNG_ESP;break;
case BIN('D','E','U',0) : selectedLanguage=LNG_DEU;break;
case BIN('F','R','A',0) : selectedLanguage=LNG_FRA;break;
case BIN('P','O','R',0) : selectedLanguage=LNG_POR;break;
case BIN('I','T','A',0) : selectedLanguage=LNG_ITA;break;
case BIN('J','P','N',0) : selectedLanguage=LNG_JPN;break;
case BIN('K','O','R',0) : selectedLanguage=LNG_KOR;break;
case BIN('S','I','N',0) : selectedLanguage=LNG_SIN;break;
case BIN('C','H','I',0) : selectedLanguage=LNG_CHI;break;
case BIN('P','O','L',0) : selectedLanguage=LNG_POL;break;
case BIN('R','U','S',0) : selectedLanguage=LNG_RUS;break;
default: active_ChangeLanguage = false;
log_msg("active_ChangeLanguage\t\t= %d (because bad language string : %s)\n", active_ChangeLanguage, buffer);
}
}
if (active_ChangeLanguage)
log_msg("selectedLanguage\t\t\t= %u\n", selectedLanguage);
GET_PRIVATE_PROFILE_STRING(S_LANGUAGE, S_active_LanguageManagement, "0");
active_LanguageManagement = atoi(buffer) != 0;
log_msg("active_LanguageManagement\t= %d\n", active_LanguageManagement);
if (active_LanguageManagement)
{
GET_PRIVATE_PROFILE_STRING(S_LANGUAGE, S_defaultLanguage, "ENG");
strupr(buffer);
switch (*(DWORD*)buffer)
{
case BIN('E','N','G',0) : defaultLanguage=LNG_ENG;break;
case BIN('E','S','P',0) : defaultLanguage=LNG_ESP;break;
case BIN('D','E','U',0) : defaultLanguage=LNG_DEU;break;
case BIN('F','R','A',0) : defaultLanguage=LNG_FRA;break;
case BIN('P','O','R',0) : defaultLanguage=LNG_POR;break;
case BIN('I','T','A',0) : defaultLanguage=LNG_ITA;break;
case BIN('J','P','N',0) : defaultLanguage=LNG_JPN;break;
case BIN('K','O','R',0) : defaultLanguage=LNG_KOR;break;
case BIN('S','I','N',0) : defaultLanguage=LNG_SIN;break;
case BIN('C','H','I',0) : defaultLanguage=LNG_CHI;break;
case BIN('P','O','L',0) : defaultLanguage=LNG_POL;break;
case BIN('R','U','S',0) : defaultLanguage=LNG_RUS;break;
default: defaultLanguage=LNG_ENG;
}
log_msg("defaultLanguage\t\t\t= %d\n", defaultLanguage);
GET_PRIVATE_PROFILE_STRING(S_LANGUAGE, S_availableLanguages, "ENG|ESP|DEU|FRA|POR|ITA|JPN|KOR|SIN|CHI|POL|RUS");
availableLanguages.all = 0;
strupr(buffer);
char* curString = strtok(buffer,"|");
while (curString)
{
switch (*(DWORD*)curString)
{
case BIN('E','N','G',0) : availableLanguages.eng=1;break;
case BIN('E','S','P',0) : availableLanguages.esp=1;break;
case BIN('D','E','U',0) : availableLanguages.deu=1;break;
case BIN('F','R','A',0) : availableLanguages.fra=1;break;
case BIN('P','O','R',0) : availableLanguages.por=1;break;
case BIN('I','T','A',0) : availableLanguages.ita=1;break;
case BIN('J','P','N',0) : availableLanguages.jpn=1;break;
case BIN('K','O','R',0) : availableLanguages.kor=1;break;
case BIN('S','I','N',0) : availableLanguages.sin=1;break;
case BIN('C','H','I',0) : availableLanguages.chi=1;break;
case BIN('P','O','L',0) : availableLanguages.pol=1;break;
case BIN('R','U','S',0) : availableLanguages.rus=1;break;
default:;
}
curString=strtok(NULL,"|");
}
log_msg("availableLanguage.all\t\t= 0x%04X\n\n",availableLanguages.all);
}
log_msg("\n");
}
void init_SavePath(INIFile* iniFile, INIFile* iniFixedFile, INIFile* iniDefaultFile, char* buffer, DWORD maxSize)
{
GET_PRIVATE_PROFILE_STRING3(S_SAVEPATH, S_active_changingSavePath, "0");
active_changingSavePath = atoi(buffer) != 0;
log_msg("active_changingSavePath\t\t= %u\n", active_changingSavePath);
if (active_changingSavePath)
{
int curSize = 0;
int start = 0;
GET_PRIVATE_PROFILE_STRING3(S_SAVEPATH, S_savePath, "Save\\");
while (buffer[curSize])
curSize++;
if ( (curSize>0) && buffer[curSize-1] != (BYTE)'\\')
{
buffer[curSize++] = (BYTE)'\\';
buffer[curSize]='\0';
}
while (buffer[start] == '\\')
start++;
if (!buffer[start])
{
active_changingSavePath = false;
log_msg("active_changingSavePath\t\t= %u (no valid savePath)\n\n", active_changingSavePath);
// log_msg("\tsavePath\t\t\t= %s\n", savePath);
return;
}
if (buffer[start+1]!=':')
{
char buf[MAX_PATH];
buf[0]=NULL;
D2FogGetInstallPath(buf,MAX_PATH);
savePath = (char*)D2FogMemAlloc(strlen(buf) + curSize - start + 1,__FILE__,__LINE__,0);
strcpy(savePath,buf);
strcat(savePath,&buffer[start]);
} else {
savePath = (char*)D2FogMemAlloc(curSize-start+1,__FILE__,__LINE__,0);
strcpy(savePath,&buffer[start]);
}
log_msg("savePath\t\t\t\t\t= %s\n", savePath);
}
log_msg("\n");
}
void init_VersionText(INIFile* iniFile, INIFile* iniFixedFile, INIFile* iniDefaultFile, char* buffer, DWORD maxSize)
{
GET_PRIVATE_PROFILE_STRING(S_MAIN_SCREEN, S_active_VersionTextChange, "0");
active_VersionTextChange = atoi(buffer) != 0;
log_msg("active_VersionTextChange\t= %u\n", active_VersionTextChange);
if (active_VersionTextChange)
{
GET_PRIVATE_PROFILE_STRING(S_MAIN_SCREEN, S_versionText, versionText);
if (!buffer[0])
{
switch(version_D2Game)
{
case V109b: strcpy(buffer, "v 1.09b");break;
case V109d: strcpy(buffer, "v 1.09d");break;
//case V110: strcpy(buffer, "v 1.10");break;
//case V111: strcpy(buffer, "v 1.11");break;
case V111b: strcpy(buffer, "v 1.11b");break;
default:
active_VersionTextChange=0;
}
}
versionText = (char*)D2FogMemAlloc(strlen(buffer)+1,__FILE__,__LINE__,0);
strcpy(versionText,buffer);
log_msg("versionText\t\t\t\t\t= %s\n", versionText);
GET_PRIVATE_PROFILE_STRING(S_MAIN_SCREEN, S_modVersionColor, "0");
modVersionColor = atoi(buffer);
log_msg("modVersionColor\t\t\t\t= %u\n", modVersionColor);
}
GET_PRIVATE_PROFILE_STRING(S_MAIN_SCREEN, S_active_PrintPlugYVersion, "1");
active_PrintPlugYVersion = atoi(buffer) != 0;
log_msg("active_PrintPlugYVersion\t= %u\n", active_PrintPlugYVersion);
if (active_PrintPlugYVersion)
{
GET_PRIVATE_PROFILE_STRING(S_MAIN_SCREEN, S_colorOfPlugYVersion, "4");
colorOfPlugYVersion = atoi(buffer);
log_msg("colorOfPlugYVersion\t\t\t= %u\n", colorOfPlugYVersion);
}
log_msg("\n");
}
void init_Stash(INIFile* iniFile, INIFile* iniFixedFile, INIFile* iniDefaultFile, char* buffer, DWORD maxSize)
{
GET_PRIVATE_PROFILE_STRING(S_STASH, S_active_bigStash, "0");
active_bigStash = atoi(buffer) != 0;
log_msg("active_bigStash\t\t\t\t= %u\n", active_bigStash);
GET_PRIVATE_PROFILE_STRING(S_STASH, S_active_multiPageStash, "0");
active_multiPageStash = atoi(buffer) != 0;
log_msg("active_multiPageStash\t\t= %u\n", active_multiPageStash);
if (active_multiPageStash)
{
active_PlayerCustomData = true;
// log_msg("active_PlayerCustomData\t\t= %d\n", active_PlayerCustomData);
GET_PRIVATE_PROFILE_STRING(S_STASH, S_maxSelfPages, "0");
maxSelfPages = atoi(buffer) - 1;
log_msg("maxSelfPages\t\t\t\t= %u\n", maxSelfPages);
GET_PRIVATE_PROFILE_STRING(S_STASH, S_nbPagesPerIndex, "10");
nbPagesPerIndex = atoi(buffer);
if (!nbPagesPerIndex) nbPagesPerIndex=10;
log_msg("nbPagesPerIndex\t\t\t\t= %u\n", nbPagesPerIndex);
GET_PRIVATE_PROFILE_STRING(S_STASH, S_nbPagesPerIndex2, "100");
nbPagesPerIndex2 = atoi(buffer);
if (!nbPagesPerIndex2) nbPagesPerIndex2=100;
log_msg("nbPagesPerIndex2\t\t\t= %u\n", nbPagesPerIndex2);
GET_PRIVATE_PROFILE_STRING(S_STASH, S_active_sharedStash, "0");
active_sharedStash = atoi(buffer) != 0;
log_msg("active_sharedStash\t\t\t= %u\n", active_sharedStash);
GET_PRIVATE_PROFILE_STRING(S_STASH, S_posXPreviousBtn,"-1");
posXPreviousBtn = atoi(buffer);
GET_PRIVATE_PROFILE_STRING(S_STASH, S_posYPreviousBtn,"-1");
posYPreviousBtn = atoi(buffer);
GET_PRIVATE_PROFILE_STRING(S_STASH, S_posXNextBtn,"-1");
posXNextBtn = atoi(buffer);
GET_PRIVATE_PROFILE_STRING(S_STASH, S_posYNextBtn,"-1");
posYNextBtn = atoi(buffer);
GET_PRIVATE_PROFILE_STRING(S_STASH, S_posXSharedBtn,"-1");
posXSharedBtn = atoi(buffer);
GET_PRIVATE_PROFILE_STRING(S_STASH, S_posYSharedBtn,"-1");
posYSharedBtn = atoi(buffer);
GET_PRIVATE_PROFILE_STRING(S_STASH, S_posXPreviousIndexBtn,"-1");
posXPreviousIndexBtn = atoi(buffer);
GET_PRIVATE_PROFILE_STRING(S_STASH, S_posYPreviousIndexBtn,"-1");
posYPreviousIndexBtn = atoi(buffer);
GET_PRIVATE_PROFILE_STRING(S_STASH, S_posXNextIndexBtn,"-1");
posXNextIndexBtn = atoi(buffer);
GET_PRIVATE_PROFILE_STRING(S_STASH, S_posYNextIndexBtn,"-1");
posYNextIndexBtn = atoi(buffer);
GET_PRIVATE_PROFILE_STRING(S_STASH, S_posXPutGoldBtn,"-1");
posXPutGoldBtn = atoi(buffer);
GET_PRIVATE_PROFILE_STRING(S_STASH, S_posYPutGoldBtn,"-1");
posYPutGoldBtn = atoi(buffer);
GET_PRIVATE_PROFILE_STRING(S_STASH, S_posXTakeGoldBtn,"-1");
posXTakeGoldBtn = atoi(buffer);
GET_PRIVATE_PROFILE_STRING(S_STASH, S_posYTakeGoldBtn,"-1");
posYTakeGoldBtn = atoi(buffer);
log_msg("\t Buttons Positions: %d %d %d %d %d %d %d %d %d %d\n",posXPreviousBtn,posYPreviousBtn,posXNextBtn,posYNextBtn,posXSharedBtn,posYSharedBtn,posXPreviousIndexBtn,posYPreviousIndexBtn,posXNextIndexBtn,posYNextIndexBtn);
}
if (active_sharedStash)
{
GET_PRIVATE_PROFILE_STRING(S_STASH, S_maxSharedPages, "0");
maxSharedPages = atoi(buffer) - 1;
log_msg("maxSharedPages\t\t\t\t= %u\n", maxSharedPages);
GET_PRIVATE_PROFILE_STRING(S_STASH, S_sharedStashFilename, "SharedStashSave");
sharedStashFilename = (char*)D2FogMemAlloc(strlen(buffer)+1,__FILE__,__LINE__,0);
strcpy(sharedStashFilename, buffer);
log_msg("sharedStashFilename\t\t\t= %s\n", sharedStashFilename);
GET_PRIVATE_PROFILE_STRING(S_STASH, S_separateHardSoftStash, "1");
separateHardSoftStash = atoi(buffer) != 0;
log_msg("separateHardSoftStash\t\t= %u\n", separateHardSoftStash);
GET_PRIVATE_PROFILE_STRING(S_STASH, S_displaySharedSetItemNameInGreen, "1");
displaySharedSetItemNameInGreen = atoi(buffer) != 0;
log_msg("displaySharedSetItemNameInGreen = %u\n", displaySharedSetItemNameInGreen);
GET_PRIVATE_PROFILE_STRING(S_STASH, S_active_sharedGold, "1");
active_sharedGold = atoi(buffer) != 0;
log_msg("active_sharedGold\t\t\t= %u\n", active_sharedGold);
}
log_msg("\n");
}
void init_StatsPoints(INIFile* iniFile, INIFile* iniFixedFile, INIFile* iniDefaultFile, char* buffer, DWORD maxSize)
{
GET_PRIVATE_PROFILE_STRING(S_STATS_POINTS, S_active_StatsPoints, "0");
active_StatsPoints = atoi(buffer) != 0;
log_msg("active_StatsPoints\t\t\t= %u\n", active_StatsPoints);
if (active_StatsPoints)
{
GET_PRIVATE_PROFILE_STRING(S_STATS_POINTS, S_keyUsedForUnassignStatPoint, "18");
keyUsedForUnassignStatPoint = atoi(buffer);
log_msg("keyUsedForUnassignStatPoint\t= %u (0x%x)\n", keyUsedForUnassignStatPoint);
}
GET_PRIVATE_PROFILE_STRING(S_STATS_POINTS, S_active_StatsShiftClickLimit, "0");
active_StatsShiftClickLimit = atoi(buffer) != 0;
log_msg("active_StatsShiftClickLimit\t= %u\n", active_StatsShiftClickLimit);
if (active_StatsShiftClickLimit)
{
GET_PRIVATE_PROFILE_STRING(S_STATS_POINTS, S_limitValueToShiftClick, "5");
limitValueToShiftClick = atoi(buffer);
log_msg("limitValueToShiftClick\t\t= %u\n", limitValueToShiftClick);
}
log_msg("\n");
}
void init_StatPerLevelUp(INIFile* iniFile, INIFile* iniFixedFile, INIFile* iniDefaultFile, char* buffer, DWORD maxSize)
{
GET_PRIVATE_PROFILE_STRING(S_STAT_ON_LEVEL_UP, S_active_StatPerLevelUpChange, "0");
active_StatPerLevelUpChange = atoi(buffer) != 0;
log_msg("active_StatPerLevelUpChange\t= %u\n", active_StatPerLevelUpChange);
if (active_StatPerLevelUpChange)
{
GET_PRIVATE_PROFILE_STRING(S_STAT_ON_LEVEL_UP, S_statPerLevelUp, "5");
statPerLevelUp = atoi(buffer);
log_msg("statPerLevelUp\t\t\t\t= %u\n", statPerLevelUp);
}
log_msg("\n");
}
void init_SkillsPoints(INIFile* iniFile, INIFile* iniFixedFile, INIFile* iniDefaultFile, char* buffer, DWORD maxSize)
{
GET_PRIVATE_PROFILE_STRING(S_SKILLS_POINTS, S_active_SkillsPoints, "0");
active_SkillsPoints = atoi(buffer) != 0;
log_msg("active_SkillsPoints\t\t\t= %d\n", active_SkillsPoints);
GET_PRIVATE_PROFILE_STRING(S_SKILLS_POINTS, S_unassignSkillsPointsOneByOne, "0");
unassignSkillsPointsOneByOne = atoi(buffer) != 0;
log_msg("unassignSkillsPointsOneByOne\t\t\t= %d\n", unassignSkillsPointsOneByOne);
if (unassignSkillsPointsOneByOne)
{
active_SkillsPoints = true;
log_msg("active_SkillsPoints\t\t\t= %d\n", active_SkillsPoints);
}
GET_PRIVATE_PROFILE_STRING(S_SKILLS_POINTS, S_posXUnassignSkillBtn,"-1");
posXUnassignSkillBtn = atoi(buffer);
log_msg("posXUnassignSkillBtn\t\t\t= %d\n", posXUnassignSkillBtn);
GET_PRIVATE_PROFILE_STRING(S_SKILLS_POINTS, S_posYUnassignSkillBtn,"-1");
posYUnassignSkillBtn = atoi(buffer);
log_msg("posXUnassignSkillBtn\t\t\t= %d\n", posYUnassignSkillBtn);
log_msg("\n");
}
void init_SkillPerLevelUp(INIFile* iniFile, INIFile* iniFixedFile, INIFile* iniDefaultFile, char* buffer, DWORD maxSize)
{
GET_PRIVATE_PROFILE_STRING(S_SKILL_ON_LEVEL_UP, S_active_SkillPerLevelUpChange, "0");
active_SkillPerLevelUpChange = atoi(buffer) != 0;
log_msg("active_SkillPerLevelUpChange= %u\n", active_SkillPerLevelUpChange);
if (active_SkillPerLevelUpChange)
{
GET_PRIVATE_PROFILE_STRING(S_SKILL_ON_LEVEL_UP, S_skillPerLevelUp, "1");
skillPerLevelUp = atoi(buffer);
log_msg("skillPerLevelUp\t\t\t\t= %u\n", skillPerLevelUp);
}
log_msg("\n");
}
void init_WorldEvent(INIFile* iniFile, INIFile* iniFixedFile, INIFile* iniDefaultFile, char* buffer, DWORD maxSize)
{
GET_PRIVATE_PROFILE_STRING(S_WORLD_EVENT, S_active_WorldEvent, "0");
active_WorldEvent = atoi(buffer) != 0;
if (active_WorldEvent && ((version_D2Game == V109b) || (version_D2Game == V109d)) ) {
active_WorldEvent = 0;
log_msg("active_WorldEvent\t\t\t= %d (Warning : this feature is only for LoD version 1.10 or higher, so it's automatically disabled)\n", active_WorldEvent);
} else
log_msg("active_WorldEvent\t\t\t= %d\n", active_WorldEvent);
if (active_WorldEvent)
{
GET_PRIVATE_PROFILE_STRING(S_WORLD_EVENT, S_showSOJSoldCounterInAllDiff, "0");
showSOJSoldCounterInAllDiff = atoi(buffer);
log_msg("showSOJSoldCounterInAllDiff\t= %d\n", showSOJSoldCounterInAllDiff);
GET_PRIVATE_PROFILE_STRING(S_WORLD_EVENT, S_itemsToSell, itemsToSell);
if (strlen(buffer)>50) buffer[50]='\0';
itemsToSell = (char*)D2FogMemAlloc(strlen(buffer)+1,__FILE__,__LINE__,0);
strcpy(itemsToSell,buffer);
log_msg("itemsToSell\t\t\t\t\t= %s\n", itemsToSell);
GET_PRIVATE_PROFILE_STRING(S_WORLD_EVENT, S_worldEventmonsterID, "333");
worldEventmonsterID = atoi(buffer);
log_msg("worldEventmonsterID\t\t\t= %d\n", worldEventmonsterID);
GET_PRIVATE_PROFILE_STRING(S_WORLD_EVENT, S_valueOfOwnSOJSold, "100");
valueOfOwnSOJSold = atoi(buffer);
log_msg("valueOfOwnSOJSold\t\t\t= %d\n", valueOfOwnSOJSold);
GET_PRIVATE_PROFILE_STRING(S_WORLD_EVENT, S_valueInitSOJSoldMin, "200");
valueInitSOJSoldMin = atoi(buffer);
log_msg("valueInitSOJSoldMin\t\t\t= %d\n", valueInitSOJSoldMin);
GET_PRIVATE_PROFILE_STRING(S_WORLD_EVENT, S_valueInitSOJSoldDelta, "3000");
valueInitSOJSoldDelta = atoi(buffer)-valueInitSOJSoldMin+1;
log_msg("valueInitSOJSoldDelta\t\t= %d\n", valueInitSOJSoldDelta);
GET_PRIVATE_PROFILE_STRING(S_WORLD_EVENT, S_triggerAtSolJSoldMin, "75");
triggerAtSolJSoldMin = atoi(buffer);
log_msg("triggerAtSolJSoldMin\t\t= %d\n", triggerAtSolJSoldMin);
GET_PRIVATE_PROFILE_STRING(S_WORLD_EVENT, S_triggerAtSolJSoldDelta, "125");
triggerAtSolJSoldDelta = atoi(buffer)-triggerAtSolJSoldMin+1;
log_msg("triggerAtSolJSoldDelta\t\t= %d\n", triggerAtSolJSoldDelta);
GET_PRIVATE_PROFILE_STRING(S_WORLD_EVENT, S_active_AutomaticSell, "1");
active_AutomaticSell = atoi(buffer) != 0;
log_msg("active_AutomaticSell\t\t= %d\n", active_AutomaticSell);
if (active_AutomaticSell)
{
GET_PRIVATE_PROFILE_STRING(S_WORLD_EVENT, S_timeBeforeAutoSellMin, "0");
timeBeforeAutoSellMin = atoi(buffer)*1000;
log_msg("timeBeforeAutoSellMin\t\t= %d\n", timeBeforeAutoSellMin);
GET_PRIVATE_PROFILE_STRING(S_WORLD_EVENT, S_timeBeforeAutoSellDelta, "1200");
timeBeforeAutoSellDelta = atoi(buffer)*1000-timeBeforeAutoSellMin+1;
log_msg("timeBeforeAutoSellDelta\t\t= %d\n", timeBeforeAutoSellDelta);
}
}
log_msg("\n");
}
void init_UberQuest(INIFile* iniFile, INIFile* iniFixedFile, INIFile* iniDefaultFile, char* buffer, DWORD maxSize)
{
GET_PRIVATE_PROFILE_STRING(S_UBER_QUEST, S_active_UberQuest, "0");
active_UberQuest = atoi(buffer) != 0;
if (active_UberQuest && ((version_D2Game == V109b) || (version_D2Game == V109d) || (version_D2Game == V110)) ) {
active_UberQuest = 0;
log_msg("active_UberQuest\t\t= %d (Warning : this feature is only for LoD version 1.11 or higher, so it's automatically disabled)\n", active_UberQuest);
} else
log_msg("active_UberQuest\t\t\t= %d\n", active_UberQuest);
log_msg("\n");
}
void init_NewInterfaces(INIFile* iniFile, INIFile* iniFixedFile, INIFile* iniDefaultFile, char* buffer, DWORD maxSize)
{
GET_PRIVATE_PROFILE_STRING(S_INTERFACE, S_active_newInterfaces, "0");
active_newInterfaces = atoi(buffer) != 0;
log_msg("active_newInterfaces\t\t= %d\n", active_newInterfaces);
if (active_newInterfaces)
{
GET_PRIVATE_PROFILE_STRING(S_INTERFACE, S_selectMainPageOnOpenning, "1");
selectMainPageOnOpenning = atoi(buffer) != 0;
log_msg("selectMainPageOnOpenning\t= %u\n", selectMainPageOnOpenning);
GET_PRIVATE_PROFILE_STRING(S_INTERFACE, S_printBackgroundOnMainPage, "1");
printBackgroundOnMainPage = atoi(buffer) != 0;
log_msg("printBackgroundOnMainPage\t= %u\n", printBackgroundOnMainPage);
}
log_msg("\n");
}
void init_ExtraOptions(INIFile* iniFile, INIFile* iniFixedFile, INIFile* iniDefaultFile, char* buffer, DWORD maxSize)
{
GET_PRIVATE_PROFILE_STRING(S_EXTRA, S_active_alwaysRegenMapInSP, "0");
active_alwaysRegenMapInSP = atoi(buffer);
log_msg("active_alwaysRegenMapInSP\t= %d\n", active_alwaysRegenMapInSP);
GET_PRIVATE_PROFILE_STRING(S_EXTRA, S_nbPlayersCommandByDefault, "0");
nbPlayersCommandByDefault = atoi(buffer);
if (version_D2Common == V110)
{if (nbPlayersCommandByDefault > 8) nbPlayersCommandByDefault=8;}
else if (nbPlayersCommandByDefault > 64) nbPlayersCommandByDefault=64;
log_msg("nbPlayersCommandByDefault\t= %d\n", nbPlayersCommandByDefault);
GET_PRIVATE_PROFILE_STRING(S_EXTRA, S_active_DisplayItemLevel, "0");
active_DisplayItemLevel = atoi(buffer);
log_msg("active_DisplayItemLevel\t\t= %d\n", active_DisplayItemLevel);
GET_PRIVATE_PROFILE_STRING(S_EXTRA, S_active_AlwaysDisplayLifeMana, "0");
active_AlwaysDisplayLifeMana = atoi(buffer);
log_msg("active_AlwaysDisplayLifeMana= %d\n", active_AlwaysDisplayLifeMana);
GET_PRIVATE_PROFILE_STRING(S_EXTRA, S_active_RunLODs, "0");
active_RunLODs = atoi(buffer);
log_msg("active_RunLODs\t\t\t\t= %u\n", active_RunLODs);
GET_PRIVATE_PROFILE_STRING(S_EXTRA, S_active_EnabledTXTFilesWithMSExcel, "0");
active_EnabledTXTFilesWithMSExcel = atoi(buffer);
log_msg("active_EnabledTXTFilesWithMSExcel= %u\n\n", active_EnabledTXTFilesWithMSExcel);
GET_PRIVATE_PROFILE_STRING(S_EXTRA, S_active_DisplayBaseStatsValue, "0");
active_DisplayBaseStatsValue = atoi(buffer);
log_msg("active_DisplayBaseStatsValue= %u\n\n", active_DisplayBaseStatsValue);
GET_PRIVATE_PROFILE_STRING(S_EXTRA, S_active_LadderRunewords, "0");
active_LadderRunewords = atoi(buffer);
if (active_LadderRunewords && (version_D2Common == V109b || version_D2Common == V109d) ) {
active_LadderRunewords = 0;
log_msg("active_LadderRunewords\t= %d (Warning : Warning : this feature is only for LoD version 1.10 or higher, so it's automatically disabled)\n", active_WorldEvent);
} else
log_msg("active_LadderRunewords\t= %u\n\n", active_LadderRunewords);
GET_PRIVATE_PROFILE_STRING(S_EXTRA, S_active_EnabledCowPortalWhenCowKingWasKill, "0");
active_EnabledCowPortalWhenCowKingWasKill = atoi(buffer);
log_msg("active_EnabledCowPortalWhenCowKingWasKill= %u\n\n", active_EnabledCowPortalWhenCowKingWasKill);
}
void loadParameters()
{
char buffer[BUFSIZE];
int loading=0;
INIFile *iniFile = new INIFile;
INIFile *iniFixedFile = new INIFile;
INIFile *iniDefaultFile = new INIFile;
srand(time(NULL));
log_msg("***** PARAMETERS *****\n");
if (iniFile->InitReadWrite(PARAMETERS_FILENAME, INIFILE_READ, 0))
{
log_msg("Parameters file is opened.\n\n");
loading = 1;
}
if (iniFixedFile->InitReadWrite(PARAM_FIXED_FILENAME, INIFILE_MPQREAD, 0))
{
log_msg("Fixed Parameters file is opened.\n\n");
loading = 1;
}
if (iniDefaultFile->InitReadWrite(PARAM_DEFAULT_FILENAME, INIFILE_MPQREAD, 0))
{
log_msg("Default Parameters file is opened.\n\n");
loading = 1;
}
if(loading)
{
log_msg("Reading parameters.\n\n");
init_ActivePlugin(iniFile, iniFixedFile, iniDefaultFile, buffer, BUFSIZE);
if (active_plugin)
{
init_General(iniFile, iniFixedFile, iniDefaultFile, buffer, BUFSIZE);
init_ActiveLanguage(iniFile, iniFixedFile, iniDefaultFile, buffer,BUFSIZE);
init_SavePath(iniFile, iniFixedFile, iniDefaultFile, buffer, BUFSIZE);
init_VersionText(iniFile, iniFixedFile, iniDefaultFile, buffer, BUFSIZE);
init_Stash(iniFile, iniFixedFile, iniDefaultFile, buffer, BUFSIZE);
init_StatsPoints(iniFile, iniFixedFile, iniDefaultFile, buffer, BUFSIZE);
init_StatPerLevelUp(iniFile, iniFixedFile, iniDefaultFile, buffer, BUFSIZE);
init_SkillsPoints(iniFile, iniFixedFile, iniDefaultFile, buffer, BUFSIZE);
init_SkillPerLevelUp(iniFile, iniFixedFile, iniDefaultFile, buffer, BUFSIZE);
init_WorldEvent(iniFile, iniFixedFile, iniDefaultFile, buffer, BUFSIZE);
init_UberQuest(iniFile, iniFixedFile, iniDefaultFile, buffer, BUFSIZE);
init_NewInterfaces(iniFile, iniFixedFile, iniDefaultFile, buffer, BUFSIZE);
init_ExtraOptions(iniFile, iniFixedFile, iniDefaultFile, buffer, BUFSIZE);
}
log_msg("Reading parameters end.\n\n\n");
} else {
log_msg("\nCan't open parameters files: Default values used.\n\n\n");
active_plugin = false;
}
if (iniFile)
iniFile->close();
if (iniFixedFile)
iniFixedFile->close();
if (iniDefaultFile)
iniDefaultFile->close();
delete iniFile;
delete iniDefaultFile;
delete iniFixedFile;
}
/*================================= END OF FILE =================================*/

403
PlugY/PlayerCustomData.cpp Normal file
View File

@ -0,0 +1,403 @@
/*=================================================================
File created by Yohann NICOLAS.
Adding custom data.
Save and load infinity & shared Stash
=================================================================*/
#include "common.h"
#include "error.h"
#include "updateClient.h"
#include "d2functions.h"
#include "infinityStash.h"
#include "savePlayerData.h" //Install_SavePlayerData()
#include "loadPlayerData.h" //Install_LoadPlayerData()
bool active_PlayerCustomData = true;
/*********************************** UPDATING ***********************************/
Stash* getStashFromItem(Unit* ptChar, Unit* ptItem)
{
Stash* curStash = PCPY->selfStash;
Unit* curItem;
while (curStash)
{
if (curStash == PCPY->currentStash)
curItem = D2InventoryGetFirstItem(PCInventory);
else curItem = curStash->ptListItem;
while (curItem)
{
if (D2GetRealItem(curItem) == ptItem) return curStash;
curItem = D2UnitGetNextItem(curItem);
}
curStash = curStash->nextStash;
}
curStash = PCPY->sharedStash;
while (curStash)
{
if (curStash == PCPY->currentStash)
curItem = D2InventoryGetFirstItem(PCInventory);
else curItem = curStash->ptListItem;
while (curItem)
{
if (D2GetRealItem(curItem) == ptItem) return curStash;
curItem = D2UnitGetNextItem(curItem);
}
curStash = curStash->nextStash;
}
return NULL;
}
Unit* FASTCALL updateItem(Game* ptGame, DWORD type, DWORD itemNum, Unit* ptChar)
{
Unit* ptItem = D2GameGetObject(ptGame, type, itemNum);
if (ptGame->isLODGame && (D2ItemGetPage(ptItem) == 4))
{
Stash* ptStash = getStashFromItem(ptChar, ptItem);
if (!ptStash) return NULL;
selectStash(ptChar, ptStash);
}
return ptItem;
}
void STDCALL updateClientPlayerOnLoading(Unit* ptChar)
{
log_msg("--- Start updateClientPlayerOnLoading ---\n");
if (PCGame->isLODGame)
{
selectStash(ptChar, PCPY->selfStash);
log_msg("End update client on loading.\n\n");
}
updateClient(ptChar, UC_SHARED_GOLD, PCPY->sharedGold, 0, 0);
}
/**************************** INIT CUSTOM DATA ****************************/
PlayerData* FASTCALL init_PlayerCustomData(DWORD p1, DWORD size, LPCSTR file, DWORD line, DWORD p5)
{
log_msg("init_PlayerCustomData\n");
PlayerData* playerData = (PlayerData*)D2AllocMem(p1,size+sizeof(PYPlayerData),file,line,p5);
ZeroMemory((BYTE*)playerData + shifting.ptPYPlayerData, sizeof(PYPlayerData));
return playerData;
}
/**************************** FREE CUSTOM DATA ****************************/
void freeStash(Stash* ptStash)
{
if (!ptStash) return;
freeStash(ptStash->nextStash);
free(ptStash->nextStash);// D2FogMemDeAlloc(ptStash->nextStash,__FILE__,__LINE__,0);
if(ptStash->name)
{
free(ptStash->name);//D2FogMemDeAlloc(ptStash->name,__FILE__,__LINE__,0);
ptStash->name = NULL;
}
ptStash->nextStash = NULL;
}
void FASTCALL free_PlayerCustomData(DWORD p1, PlayerData* playerData, LPCSTR file, DWORD line, DWORD p5)
{
log_msg("free_PlayerCustomData\n");
PYPlayerData* ptPYPlayerData = (PYPlayerData*)((DWORD)playerData + shifting.ptPYPlayerData);
freeStash(ptPYPlayerData->selfStash);
free(ptPYPlayerData->selfStash);//D2FogMemDeAlloc(ptPYPlayerData->selfStash,__FILE__,__LINE__,0);
ptPYPlayerData->selfStash = NULL;
freeStash(ptPYPlayerData->sharedStash);
free(ptPYPlayerData->sharedStash);//D2FogMemDeAlloc(ptPYPlayerData->sharedStash,__FILE__,__LINE__,0);
ptPYPlayerData->sharedStash = NULL;
D2FreeMem(p1,playerData,file,line,p5);
}
Unit* STDCALL getNextItemToFree(Unit* ptChar, Unit* ptItem)
{
Unit* item = D2UnitGetNextItem(ptItem);
if (item) return item;
if (ptChar->nUnitType != UNIT_PLAYER) return NULL;
if (!PCPlayerData) return NULL;
if (!PCPY) return NULL;
Stash* curStash = PCPY->selfStash;
while ( curStash )
{
if (curStash->ptListItem)
{
item = curStash->ptListItem;
curStash->ptListItem = NULL;
return item;//->nUnitType == 4 ? item : NULL;
}
curStash = curStash->nextStash;
}
curStash = PCPY->sharedStash;
while ( curStash )
{
if (curStash->ptListItem)
{
item = curStash->ptListItem;
curStash->ptListItem = NULL;
return item->nUnitType == 4 ? item : NULL;
}
curStash = curStash->nextStash;
}
return NULL;
}
/************************ INSTALL PLAYER CUSTOM DATA ****************************/
void FASTCALL updateItem_111(Unit* ptItem, Unit* ptChar)
{
if (PCGame->isLODGame && (D2ItemGetPage(ptItem) == 4))
{
Stash* ptStash = getStashFromItem(ptChar, ptItem);
if (ptStash)
selectStash(ptChar, ptStash);
}
}
FCT_ASM ( caller_updateItem_111 )
MOV ECX,ESI
MOV EDX,EBP
CALL updateItem_111
POP EAX
MOV EDX,DWORD PTR SS:[ESP+0x18]
PUSH EDX
JMP EAX
}}
FCT_ASM ( caller_updateItemB_111 )
MOV EDX,EBP
CALL updateItem_111
POP EAX
MOV EDX,DWORD PTR SS:[ESP+0x18]
PUSH EDX
JMP EAX
}}
FCT_ASM ( caller_updateItem )
PUSH EBP
PUSH DWORD PTR SS:[ESP+0x8]
CALL updateItem
RETN 4
}}
FCT_ASM ( caller_updateItem_9 )
PUSH EBX
PUSH DWORD PTR SS:[ESP+0x8]
CALL updateItem
RETN 4
}}
FCT_ASM ( caller_updateClientPlayerOnLoading )
PUSH DWORD PTR SS:[ESP+0x14]
CALL updateClientPlayerOnLoading
POP ECX
POP EDI
POP ESI
POP EBP
XOR EAX,EAX
JMP ECX
}}
FCT_ASM ( callerServer_getNextItemToFree_111 )
PUSH DWORD PTR SS:[ESP+4]
PUSH DWORD PTR SS:[ESP+0x30]
CALL getNextItemToFree
RETN 4
}}
FCT_ASM ( callerServer_getNextItemToFree )
PUSH DWORD PTR SS:[ESP+4]
PUSH DWORD PTR SS:[ESP+0x28]
CALL getNextItemToFree
RETN 4
}}
FCT_ASM ( callerServer_getNextItemToFree_9 )
PUSH DWORD PTR SS:[ESP+4]
PUSH DWORD PTR SS:[ESP+0x1C]
CALL getNextItemToFree
RETN 4
}}
FCT_ASM ( callerClient_getNextItemToFree_111 )
PUSH DWORD PTR SS:[ESP+4]
PUSH EBX
CALL getNextItemToFree
RETN 4
}}
FCT_ASM ( callerClient_getNextItemToFree )
PUSH DWORD PTR SS:[ESP+4]
PUSH DWORD PTR SS:[ESP+0x24]
CALL getNextItemToFree
RETN 4
}}
FCT_ASM ( callerClient_getNextItemToFree_9 )
PUSH DWORD PTR SS:[ESP+4]
PUSH DWORD PTR SS:[ESP+0x28]
CALL getNextItemToFree
RETN 4
}}
void Install_PlayerCustomData()
{
static int isInstalled = false;
if (isInstalled || !active_PlayerCustomData) return;
Install_SavePlayerData();
Install_LoadPlayerData();
Install_UpdateClient();
log_msg("Patch D2Game & D2Client & D2Common for Player's custom data. (PlayerCustomData)\n");
// Initialize custom data.
mem_seek( version_D2Client == V113 ? offset_D2Common + 0x309BE : version_D2Client == V112 ? offset_D2Common + 0x585EE : version_D2Client == V111b ? offset_D2Common + 0x5BFCE : version_D2Common == V111 ? offset_D2Common + 0x4ED5E :(DWORD)D2InitPlayerData + 0x62 );
MEMJ_REF4( D2AllocMem, init_PlayerCustomData);
//01BD0381 |. E8 C03F0000 CALL <JMP.&Fog.#10045>
//6FD9ED5D |. E8 94A4FBFF CALL <JMP.&Fog.#10045>
//6FDABFCD |. E8 34D2FAFF CALL <JMP.&Fog.#10045>
//6FDA85ED |. E8 240CFBFF CALL <JMP.&Fog.#10045>
//6FD809BD |. E8 6088FDFF CALL <JMP.&Fog.#10045>
if ( version_D2Game >= V111 )
{
// update item
mem_seek R7(D2Game, 10933, 10C03, 1100D, 8BC71, C3C51, 5F2A1, 9BB91);
memt_byte( 0x8B ,0xE8); // CALL
MEMT_REF4( 0x52182454, caller_updateItem_111);
//0200BC71 |> 8B5424 18 |MOV EDX,DWORD PTR SS:[ESP+18]
//0200BC75 |. 52 |PUSH EDX ; /Arg1
//02023C51 |> 8B5424 18 |MOV EDX,DWORD PTR SS:[ESP+18]
//02023C55 |. 52 |PUSH EDX ; /Arg1
//6FC7F2A1 |> 8B5424 18 |MOV EDX,DWORD PTR SS:[ESP+18]
//6FC7F2A5 |. 52 |PUSH EDX ; /Arg1
//6FCBBB91 |> 8B5424 18 |MOV EDX,DWORD PTR SS:[ESP+18]
//6FCBBB95 |. 52 |PUSH EDX
mem_seek R7(D2Game, 1097B, 10C4B, 11058, 8BCD1, C3CB1, 5F301, 9BBF1);
memt_byte( 0x8B ,0xE8); // CALL
MEMT_REF4( 0x52182454, caller_updateItemB_111);
//0200BCD1 |> 8B5424 18 ||MOV EDX,DWORD PTR SS:[ESP+18]
//0200BCD5 |. 52 ||PUSH EDX ; /Arg1
//02023CB1 |> 8B5424 18 ||MOV EDX,DWORD PTR SS:[ESP+18]
//02023CB5 |. 52 ||PUSH EDX ; /Arg1
//6FC7F301 |> 8B5424 18 ||MOV EDX,DWORD PTR SS:[ESP+18]
//6FC7F305 |. 52 ||PUSH EDX ; /Arg1
//6FCBBBF1 |> 8B5424 18 ||MOV EDX,DWORD PTR SS:[ESP+18]
//6FCBBBF5 |. 52 ||PUSH EDX
} else {
// update item
mem_seek R7(D2Game, 10933, 10C03, 1100D, 8BC71, C3C51, 5F2A1, 0000);
MEMC_REF4( D2GameGetObject, version_D2Game == V110?caller_updateItem: caller_updateItem_9);
//6FC4100C |. E8 EFAA0700 |CALL D2Game.6FCBBB00
mem_seek R7(D2Game, 1097B, 10C4B, 11058, 8BCD1, C3CB1, 5F301, 0000);
MEMC_REF4( D2GameGetObject, version_D2Game == V110?caller_updateItem: caller_updateItem_9);
//6FC41057 |. E8 A4AA0700 ||CALL D2Game.6FCBBB00
}
// Update client on loading
mem_seek R7(D2Game, 23EB, 2426, 25D4, 53482, C6A32, ED502, 4BF12);//6FC325D4-6FC30000
memt_byte( 0x5F ,0xE8); // CALL
MEMT_REF4( 0xC0335D5E , caller_updateClientPlayerOnLoading);
//6FC325D4 |> 5F POP EDI
//6FC325D5 |. 5E POP ESI
//6FC325D6 |. 5D POP EBP
//6FC325D7 |. 33C0 XOR EAX,EAX
//01FD3482 |> 5F POP EDI
//01FD3483 |. 5E POP ESI
//01FD3484 |. 5D POP EBP
//01FD3485 |. 33C0 XOR EAX,EAX
//02026A32 |> 5F POP EDI
//02026A33 |. 5E POP ESI
//02026A34 |. 5D POP EBP
//02026A35 |. 33C0 XOR EAX,EAX
//6FD0D502 |> 5F POP EDI
//6FD0D503 |. 5E POP ESI
//6FD0D504 |. 5D POP EBP
//6FD0D505 |. 33C0 XOR EAX,EAX
//6FC6BF12 |> 5F POP EDI
//6FC6BF13 |. 5E POP ESI
//6FC6BF14 |. 5D POP EBP
//6FC6BF15 |. 33C0 XOR EAX,EAX
// Free custom data.
mem_seek R7(D2Common, 7055C, 7065C, 80483, 4F82D, 5C9CD, 5856D, 3093D);
MEMJ_REF4( D2FreeMem, free_PlayerCustomData);
//01BD0482 |. E8 C53E0000 CALL <JMP.&Fog.#10046>
//6FD9F82C |. E8 E399FBFF CALL <JMP.&Fog.#10046>
//6FDAC9CC |. E8 3BC8FAFF CALL <JMP.&Fog.#10046>
//6FDA856C |. E8 E70CFBFF CALL <JMP.&Fog.#10046>
//6FD8093C |. E8 E788FDFF CALL <JMP.&Fog.#10046>
// Free item in Stash (Server-side)
mem_seek R7(D2Game, 7D12B, 7D62B, 8D5A4, 99112, BFDB2, 94242, E1162);
MEMJ_REF4( D2UnitGetNextItem, version_D2Game >= V111 ? callerServer_getNextItemToFree_111 : version_D2Game == V110 ? callerServer_getNextItemToFree : callerServer_getNextItemToFree_9);//0x0005E204
//6FCBD5A3 . E8 04E20500 CALL <JMP.&D2Common.#10304>
//02019111 |. E8 5016F7FF |CALL <JMP.&D2Common.#10934>
//0202FDB1 |. E8 30AAF4FF |CALL <JMP.&D2Common.#11140>
//6FCB4241 |. E8 8862F7FF |CALL <JMP.&D2Common.#10770>
//6FD01161 |. E8 6693F2FF |CALL <JMP.&D2Common.#10464>
// Free item in Stash (Client-side)
mem_seek R7(D2Client, 8EF8F, 8E30F, 89B32, 26404, 4C264, 1F2D4, A5C94);//6FB29B31-6FAA0000
MEMJ_REF4( D2UnitGetNextItem, version_D2Game >= V111 ? callerClient_getNextItemToFree_111 : version_D2Game == V110 ? callerClient_getNextItemToFree : callerClient_getNextItemToFree_9);//0x00040F34
//6FB29B31 E8 340F0400 CALL <JMP.&D2Common.#10304>
//6FAD6403 |. E8 925DFEFF |CALL <JMP.&D2Common.#10934>
//6FAFC263 |. E8 38FFFBFF |CALL <JMP.&D2Common.#11140>
//6FACF2D3 |. E8 4CD1FEFF |CALL <JMP.&D2Common.#10770>
//6FB55C93 |. E8 D068F6FF |CALL <JMP.&D2Common.#10464>
if ( version_D2Common >= V110 )
{
// Test if it's already removed from inventory
mem_seek R7(D2Common, 0000, 0000, 4E689, 26E33, 42133, 6AE93, 21B23);
memt_byte( 0x0D , 0x07);
//01D2E688 75 0D JNZ SHORT D2Common.01D2E697
//6FD76E32 |. 74 0D JE SHORT D2Common.6FD76E41
//6FD92132 |. 74 0D JE SHORT D2Common.6FD92141
//6FDBAE92 |. 74 0D JE SHORT D2Common.6FDBAEA1
//6FD71B22 |. 74 0D JE SHORT D2Common.6FD71B31
} else {
mem_seek R7(D2Game, 7D176, 7D676, 0000, 0000, 0000, 0000, 0000);
memt_byte( 0x74 , 0x90);//MOV EAX,EDI
memt_byte( 0x35 , 0x90);//NOP
//6FCAD176 |. 74 35 |JE SHORT D2Game.6FCAD1AD
mem_seek R7(D2Client, 8F0CA, 8E44A, 0000, 0000, 0000, 0000, 0000);
memt_byte( 0x0F , 0x90);//MOV EAX,EDI
memt_byte( 0x84 , 0x90);//NOP
memt_dword( 0x000000BF , 0x90909090);//NOP
//6FB2F0CA |. 0F84 BF000000 |JE D2Client.6FB2F18F
mem_seek R7(D2Client, 8F13C, 8E4BC, 0000, 0000, 0000, 0000, 0000);
memt_byte( 0x74 , 0x90);//MOV EAX,EDI
memt_byte( 0x6F , 0x90);//NOP
//6FB2F13C |. 74 6F |JE SHORT D2Client.6FB2F1AD
}
log_msg("\n");
isInstalled = true;
}
/*================================= END OF FILE =================================*/

BIN
PlugY/PlugY.aps Normal file

Binary file not shown.

22
PlugY/PlugY.cpp Normal file
View File

@ -0,0 +1,22 @@
/*=================================================================
File created by Yohann NICOLAS.
Main file of this DLL
=================================================================*/
#include <windows.h>
BOOL WINAPI DllMain(HANDLE /*hModule*/, DWORD dwReason, LPVOID /*lpReserved*/)
{
switch(dwReason)
{
case DLL_PROCESS_ATTACH:
break;
case DLL_PROCESS_DETACH:
break;
}
return true;
}
/*================================= END OF FILE =================================*/

111
PlugY/PlugY.rc Normal file
View File

@ -0,0 +1,111 @@
// Microsoft Visual C++ generated resource script.
//
#include "resource.h"
#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#include "afxres.h"
/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
// English (U.S.) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
#ifdef _WIN32
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
#pragma code_page(1252)
#endif //_WIN32
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//
1 TEXTINCLUDE
BEGIN
"resource.h\0"
END
2 TEXTINCLUDE
BEGIN
"#include ""afxres.h""\r\n"
"\0"
END
3 TEXTINCLUDE
BEGIN
"\r\n"
"\0"
END
#endif // APSTUDIO_INVOKED
#endif // English (U.S.) resources
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
// French (France) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_FRA)
#ifdef _WIN32
LANGUAGE LANG_FRENCH, SUBLANG_FRENCH
#pragma code_page(1252)
#endif //_WIN32
/////////////////////////////////////////////////////////////////////////////
//
// Version
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 10,0,0,0
PRODUCTVERSION 10,0,0,0
FILEFLAGSMASK 0x17L
#ifdef _DEBUG
FILEFLAGS 0x1L
#else
FILEFLAGS 0x0L
#endif
FILEOS 0x4L
FILETYPE 0x2L
FILESUBTYPE 0x0L
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040004b0"
BEGIN
VALUE "CompanyName", "Yohann Nicolas"
VALUE "FileVersion", "10.00"
VALUE "OriginalFilename", "PlugY.dll"
VALUE "ProductName", "PlugY, The Survival Kit"
VALUE "ProductVersion", "10.00"
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x400, 1200
END
END
#endif // French (France) resources
/////////////////////////////////////////////////////////////////////////////
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED

19
PlugY/PlugY.sln Normal file
View File

@ -0,0 +1,19 @@
Microsoft Visual Studio Solution File, Format Version 9.00
# Visual Studio 2005
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PlugY", "PlugY.vcproj", "{F5E47DA0-4D85-41E4-954D-29237DF8AFCB}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Release|Win32 = Release|Win32
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{F5E47DA0-4D85-41E4-954D-29237DF8AFCB}.Debug|Win32.ActiveCfg = Debug|Win32
{F5E47DA0-4D85-41E4-954D-29237DF8AFCB}.Debug|Win32.Build.0 = Debug|Win32
{F5E47DA0-4D85-41E4-954D-29237DF8AFCB}.Release|Win32.ActiveCfg = Release|Win32
{F5E47DA0-4D85-41E4-954D-29237DF8AFCB}.Release|Win32.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

BIN
PlugY/PlugY.suo Normal file

Binary file not shown.

574
PlugY/PlugY.vcproj Normal file
View File

@ -0,0 +1,574 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="8,00"
Name="PlugY"
ProjectGUID="{F5E47DA0-4D85-41E4-954D-29237DF8AFCB}"
RootNamespace="PlugY"
Keyword="ExtStoredProcProj"
>
<Platforms>
<Platform
Name="Win32"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="Debug"
IntermediateDirectory="Debug"
ConfigurationType="2"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC70.vsprops"
CharacterSet="2"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
PreprocessorDefinitions="_DEBUG"
MkTypLibCompatible="false"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
PreprocessorDefinitions="WIN32;_WINDOWS;_DEBUG;_USRDLL"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="false"
DebugInformationFormat="4"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="_DEBUG"
Culture="1033"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="opends60.lib"
LinkIncremental="2"
GenerateDebugInformation="true"
SubSystem="2"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="Release"
IntermediateDirectory="Release"
ConfigurationType="2"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC70.vsprops"
UseOfMFC="0"
CharacterSet="2"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
PreprocessorDefinitions="NDEBUG"
MkTypLibCompatible="false"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="2"
InlineFunctionExpansion="1"
OmitFramePointers="true"
PreprocessorDefinitions="WIN32;_WINDOWS;NDEBUG;_USRDLL;_CRT_NON_CONFORMING_SWPRINTFS;_CRT_SECURE_NO_DEPRECATE;_CRT_ NONSTDC_NO_DEPRECATE;_USE_32BIT_TIME_T"
StringPooling="false"
ExceptionHandling="0"
RuntimeLibrary="0"
BufferSecurityCheck="false"
EnableFunctionLevelLinking="true"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="false"
DebugInformationFormat="0"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="NDEBUG"
Culture="1033"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="opends60.lib"
LinkIncremental="1"
GenerateDebugInformation="false"
SubSystem="2"
OptimizeReferences="2"
EnableCOMDATFolding="2"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
CommandLine="copy $(TargetPath) &quot;..\PlugYInstaller\PlugY.dll&quot;&#x0D;&#x0A;copy $(TargetPath) &quot;D:\Jeux\Blizzard\Diablo II\PlugY.dll&quot;&#x0D;&#x0A;copy $(TargetPath) &quot;D:\www\PlugY.dll&quot;&#x0D;&#x0A;"
/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="Source Files"
Filter="cpp;c;cxx;rc;def;odl;idl;hpj;bat;asm"
>
<File
RelativePath="BigStash.cpp"
>
</File>
<File
RelativePath="ClientSaveFile.cpp"
>
</File>
<File
RelativePath="Commands.cpp"
>
</File>
<File
RelativePath="Common.cpp"
>
</File>
<File
RelativePath="CustomLibraries.cpp"
>
</File>
<File
RelativePath="D2functions.cpp"
>
</File>
<File
RelativePath="D2wrapper.cpp"
>
</File>
<File
RelativePath="Error.cpp"
>
</File>
<File
RelativePath="ExtendedSaveFile.cpp"
>
</File>
<File
RelativePath="ExtraOptions.cpp"
>
</File>
<File
RelativePath="GlobalVariable.cpp"
>
</File>
<File
RelativePath="InfinityStash.cpp"
>
</File>
<File
RelativePath="INIfile.cpp"
>
</File>
<File
RelativePath="Interface_Skills.cpp"
>
</File>
<File
RelativePath="Interface_Stash.cpp"
>
</File>
<File
RelativePath="Interface_Stats.cpp"
>
</File>
<File
RelativePath="Language.cpp"
>
</File>
<File
RelativePath="LoadPlayerData.cpp"
>
</File>
<File
RelativePath="MainScreen.cpp"
>
</File>
<File
RelativePath="ModifMemory.cpp"
>
</File>
<File
RelativePath="NewInterface_CubeListing.cpp"
>
</File>
<File
RelativePath="NewInterface_Runewords.cpp"
>
</File>
<File
RelativePath="NewInterface_Stats.cpp"
>
</File>
<File
RelativePath="NewInterface_StatsPageTwo.cpp"
>
</File>
<File
RelativePath="NewInterfaces.cpp"
>
</File>
<File
RelativePath="OthersFeatures.cpp"
>
</File>
<File
RelativePath="Parameters.cpp"
>
</File>
<File
RelativePath="PlayerCustomData.cpp"
>
</File>
<File
RelativePath="PlugY.cpp"
>
</File>
<File
RelativePath="PlugY.rc"
>
</File>
<File
RelativePath="PlugYFiles.cpp"
>
</File>
<File
RelativePath="SavePath.cpp"
>
</File>
<File
RelativePath="SavePlayerData.cpp"
>
</File>
<File
RelativePath="SharedSaveFile.cpp"
>
</File>
<File
RelativePath="SkillPerLevelUp.cpp"
>
</File>
<File
RelativePath="SkillsPoints.cpp"
>
</File>
<File
RelativePath="StatPerLevelUp.cpp"
>
</File>
<File
RelativePath="StatsPoints.cpp"
>
</File>
<File
RelativePath="UberQuest.cpp"
>
</File>
<File
RelativePath="UpdateClient.cpp"
>
</File>
<File
RelativePath="UpdateServer.cpp"
>
</File>
<File
RelativePath="WorldEvent.cpp"
>
</File>
</Filter>
<Filter
Name="Header Files"
Filter="h;hpp;hxx;hm;inl;inc"
>
<File
RelativePath="bigStash.h"
>
</File>
<File
RelativePath="clientSaveFile.h"
>
</File>
<File
RelativePath="commands.h"
>
</File>
<File
RelativePath="common.h"
>
</File>
<File
RelativePath="customData.h"
>
</File>
<File
RelativePath="customLibraries.h"
>
</File>
<File
RelativePath="d2functions.h"
>
</File>
<File
RelativePath="error.h"
>
</File>
<File
RelativePath="extendedSaveFile.h"
>
</File>
<File
RelativePath="extraOptions.h"
>
</File>
<File
RelativePath="globalVariable.h"
>
</File>
<File
RelativePath="infinityStash.h"
>
</File>
<File
RelativePath="INIfile.h"
>
</File>
<File
RelativePath="interface_Skills.h"
>
</File>
<File
RelativePath="interface_Stash.h"
>
</File>
<File
RelativePath="interface_Stats.h"
>
</File>
<File
RelativePath="language.h"
>
</File>
<File
RelativePath="loadPlayerData.h"
>
</File>
<File
RelativePath="mainScreen.h"
>
</File>
<File
RelativePath="modifMemory.h"
>
</File>
<File
RelativePath="newInterface_CubeListing.h"
>
</File>
<File
RelativePath="newInterface_Runewords.h"
>
</File>
<File
RelativePath="newInterface_Stats.h"
>
</File>
<File
RelativePath="newInterface_StatsPageTwo.h"
>
</File>
<File
RelativePath="newInterfaces.h"
>
</File>
<File
RelativePath="othersFeatures.h"
>
</File>
<File
RelativePath="parameters.h"
>
</File>
<File
RelativePath="playerCustomData.h"
>
</File>
<File
RelativePath="plugYFiles.h"
>
</File>
<File
RelativePath="resource.h"
>
</File>
<File
RelativePath="savePath.h"
>
</File>
<File
RelativePath="savePlayerData.h"
>
</File>
<File
RelativePath="sharedSaveFile.h"
>
</File>
<File
RelativePath="skillPerLevelUp.h"
>
</File>
<File
RelativePath="skillsPoints.h"
>
</File>
<File
RelativePath="statPerLevelUp.h"
>
</File>
<File
RelativePath="statsPoints.h"
>
</File>
<File
RelativePath="uberQuest.h"
>
</File>
<File
RelativePath="updateClient.h"
>
</File>
<File
RelativePath="updateServer.h"
>
</File>
<File
RelativePath="worldEvent.h"
>
</File>
<Filter
Name="Commons"
>
<File
RelativePath="..\Commons\d2BinFile.h"
>
</File>
<File
RelativePath="..\Commons\d2constants.h"
>
</File>
<File
RelativePath="..\Commons\D2Funcs.h"
>
</File>
<File
RelativePath="..\Commons\d2StringTblStruct.h"
>
</File>
<File
RelativePath="..\Commons\d2Struct.h"
>
</File>
<File
RelativePath="..\Commons\D2UnitStruct.h"
>
</File>
<File
RelativePath="..\Commons\updatingConst.h"
>
</File>
</Filter>
</Filter>
<Filter
Name="Resource Files"
Filter="ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
>
</Filter>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

View File

@ -0,0 +1,65 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioUserFile
ProjectType="Visual C++"
Version="8,00"
ShowAllFiles="false"
>
<Configurations>
<Configuration
Name="Debug|Win32"
>
<DebugSettings
Command=""
WorkingDirectory=""
CommandArguments=""
Attach="false"
DebuggerType="3"
Remote="1"
RemoteMachine="ATHLON64"
RemoteCommand=""
HttpUrl=""
PDBPath=""
SQLDebugging=""
Environment=""
EnvironmentMerge="true"
DebuggerFlavor=""
MPIRunCommand=""
MPIRunArguments=""
MPIRunWorkingDirectory=""
ApplicationCommand=""
ApplicationArguments=""
ShimCommand=""
MPIAcceptMode=""
MPIAcceptFilter=""
/>
</Configuration>
<Configuration
Name="Release|Win32"
>
<DebugSettings
Command=""
WorkingDirectory=""
CommandArguments=""
Attach="false"
DebuggerType="3"
Remote="1"
RemoteMachine="ATHLON64"
RemoteCommand=""
HttpUrl=""
PDBPath=""
SQLDebugging=""
Environment=""
EnvironmentMerge="true"
DebuggerFlavor=""
MPIRunCommand=""
MPIRunArguments=""
MPIRunWorkingDirectory=""
ApplicationCommand=""
ApplicationArguments=""
ShimCommand=""
MPIAcceptMode=""
MPIAcceptFilter=""
/>
</Configuration>
</Configurations>
</VisualStudioUserFile>

273
PlugY/PlugYFiles.cpp Normal file
View File

@ -0,0 +1,273 @@
/*=================================================================
File created by Yohann NICOLAS.
Adding custom data.
Save and load infinity & shared Stash
=================================================================*/
#include "common.h"
#include "error.h"
#include "d2functions.h"
#include "plugYFiles.h"
#include <stdio.h>
//#include "newInterfaces.h"
extern bool active_SkillsPoints, active_StatsPoints, active_newInterfaces, active_multiPageStash, active_sharedGold;
void* unassignSkillsBtnImages = NULL;
void* unassignStatsBtnImages = NULL;
void* stashBtnsImages = NULL;
void* newStatsInterfaceImages = NULL;
void* statsBackgroundImages = NULL;
void* sharedGoldBtnsImages = NULL;
//void* lookupItemStatCost = NULL;
DWORD STDCALL isModFile (char* filename)
{
if (strstr(filename, modDataDirectory) )
{
char fileTemp[0x104];
log_msg("Load custom file : %s", filename);
strcpy(fileTemp,filename);
D2FogGetInstallPath(filename,0x104-strlen(filename));
strcat(filename,fileTemp);
log_msg("-> %s\n", filename);
if ((GetFileAttributesA(filename) & 0x10) == 0)
return true;
}
return false;
}
FCT_ASM ( caller_isModFile )
TEST ESI,ESI
JNZ ISNOTMODDATA
MOV EBP, DWORD PTR SS:[ESP+0x140]
PUSH EBP
CALL isModFile
TEST EAX,EAX
JE ISNOTMODDATA
MOV BL, BYTE PTR SS:[ESP+0x144]
POP EAX
POP EAX
MOV EAX,D2StormMPQOpenFile
ADD EAX,0x9A
JMP EAX
ISNOTMODDATA:
JMP DWORD PTR CS:[LeaveCriticalSection]
}}
FCT_ASM ( caller_isModFile_111 )
TEST EDI,EDI
JNZ ISNOTMODDATA
MOV ESI, DWORD PTR SS:[ESP+0x130]
PUSH ESI
CALL isModFile
TEST EAX,EAX
JE ISNOTMODDATA
MOV BL, BYTE PTR SS:[ESP+0x134]
POP EAX
POP EAX
MOV EAX,D2StormMPQOpenFile
ADD EAX,0xBD
MOV EBP,GetFileAttributesA
JMP EAX
ISNOTMODDATA:
JMP DWORD PTR CS:[LeaveCriticalSection]
}}
void Install_PlugYFiles()
{
static int isInstalled = false;
if (isInstalled) return;
log_msg("Patch Storm to found custom file. (PlugYFiles)\n");
// Try in Diablo II\PlugY\ if file not found
mem_seek R7(Storm, 192C6, 19296, 18677, 2CC69, 14259, 121E9, 28D89);//( (DWORD)D2Storm268 + V7(Storm, 01A8, 01A8, 01AB, 0429, 0429, 0429, 0000) );
memt_byte( 0xFF ,0x90); // NOP
memt_byte( 0x15 ,0xE8); // CALL
MEMD_REF4( LeaveCriticalSection, version_Storm >= V111 ? caller_isModFile_111 : caller_isModFile);
//6FFC8677 |. FF15 F411FE6F CALL DWORD PTR DS:[<&KERNEL32.LeaveCriti>; \LeaveCriticalSection
//6FC1CC69 |. FF15 3832C36F CALL DWORD PTR DS:[<&KERNEL32.LeaveCriti>; \LeaveCriticalSection
//6FC04259 |. FF15 3832C36F CALL DWORD PTR DS:[<&KERNEL32.LeaveCriti>; \LeaveCriticalSection
//6FC021E9 |. FF15 4432C36F CALL DWORD PTR DS:[<&KERNEL32.LeaveCriti>; \LeaveCriticalSection
//6FC18D89 |. FF15 5832C36F CALL DWORD PTR DS:[<&KERNEL32.LeaveCriti>; \LeaveCriticalSection
log_msg("\n" );
isInstalled = true;
}
//6FFC7EF0 >/$ 8B4C24 10 MOV ECX,DWORD PTR SS:[ESP+10]
/****************************************************************************************************/
void loadImagesFile(void** images, const char* name)
{
if(!images || !name) return;
if(!*images)
{
char buffer[MAX_PATH];
sprintf(buffer, "%s\\%s", modDataDirectory, name);
log_msg("Images file to load : %s\n",buffer);
*images = D2LoadImage(buffer,0);
if (!*images)
{
sprintf(buffer, "Don't find Buttons Images File : %s.dc6", name);
d2_assert(!*images, buffer, __FILE__, __LINE__);
}
}
}
void STDCALL loadCustomImages()
{
if ( active_SkillsPoints ) loadImagesFile(&unassignSkillsBtnImages, "UnassignSkillsBtns");
if ( active_StatsPoints ) loadImagesFile(&unassignStatsBtnImages, "UnassignStatsBtns");
if ( active_multiPageStash || active_newInterfaces) loadImagesFile(&stashBtnsImages, "StashBtns");
if ( active_sharedGold) loadImagesFile(&sharedGoldBtnsImages, "SharedGoldBtns");
if ( active_newInterfaces ) loadImagesFile(&newStatsInterfaceImages, "EmptyPage");
if ( active_newInterfaces ) loadImagesFile(&statsBackgroundImages, "StatsBackground");
}
#define freeImagesFile(I) if(I) {D2FreeImage(I);I=NULL;}
void STDCALL freeCustomImages()
{
freeImagesFile(unassignSkillsBtnImages);
freeImagesFile(unassignStatsBtnImages);
freeImagesFile(stashBtnsImages);
freeImagesFile(sharedGoldBtnsImages);
freeImagesFile(newStatsInterfaceImages);
freeImagesFile(statsBackgroundImages);
}
FCT_ASM ( caller_loadCustomImages )
CALL loadCustomImages
MOV ECX,0x0C
RETN
}}
FCT_ASM ( caller_freeCustomImages )
CALL freeCustomImages
MOV ECX,0x0C
RETN
}}
void Install_PlugYImagesFiles()
{
static int isInstalled = false;
if (isInstalled) return;
Install_PlugYFiles();
log_msg("Patch D2Client to load/free custom images. (PlugYImagesFiles)\n");
// Load custom images
mem_seek R7(D2Client, 57E21, 57E21, 5E4B1, 2E101, B67E1, 82761, 27EAE);
memt_byte( 0xB9 ,0xE8);
MEMT_REF4( 0x0000000C , caller_loadCustomImages);
//6FAFE4B1 |. B9 0C000000 MOV ECX,0C
//6FADE101 |. B9 0C000000 MOV ECX,0C
//6FB667E1 |. B9 0C000000 MOV ECX,0C
//6FB32761 |. B9 0C000000 MOV ECX,0C
//6FAD7EAE |. B9 0C000000 MOV ECX,0C
// Free custom images
mem_seek R7(D2Client, 57FA9, 57FA9, 5E639, 2D12D, B580D, 8158D, 26F8D);
memt_byte( 0xB9 ,0xE8);
MEMT_REF4( 0x0000000C , caller_freeCustomImages);
//6FAFE639 |> B9 0C000000 MOV ECX,0C
//6FADD12D |> B9 0C000000 MOV ECX,0C
//6FB6580D |> B9 0C000000 MOV ECX,0C
//6FB3158D |> B9 0C000000 MOV ECX,0C
//6FAD6F8D |> B9 0C000000 MOV ECX,0C
log_msg("\n" );
isInstalled = true;
}
/****************************************************************************************************/
void loadStatsInterfaceDesc(DWORD mempool);
void freeStatsInterfaceDesc();
void FASTCALL loadTxtFiles(DWORD mempool)
{
loadStatsInterfaceDesc(mempool);
}
void FASTCALL freeTxtFiles()
{
freeStatsInterfaceDesc();
}
FCT_ASM ( caller_loadTxtFiles_111 )
MOV ECX,DWORD PTR SS:[ESP+4]
CALL loadTxtFiles
JMP D2LoadSuperuniques
}}
FCT_ASM ( caller_loadTxtFiles )
PUSH ECX
CALL loadTxtFiles
POP ECX
JMP D2LoadSuperuniques
}}
FCT_ASM ( caller_freeTxtFiles )
CALL freeTxtFiles
JMP D2Fog10212
}}
void Install_PlugYTxtFiles()
{
static int isInstalled = false;
if (isInstalled) return;
Install_PlugYFiles();
log_msg("Patch D2Common to load/free custom txt files. (PlugYTxtFiles)\n");
// lookupItemStatCost = (void*)R7(D2Common, A1D70, A1D70, AA1D8, 0000, 0000, 0000, 0000);
// Load custom txt files
mem_seek R7(D2Common, 7F4B, 7F4B, 2F7D7, 76854, 37444, 81C44, 5D6E4);
MEMC_REF4( D2LoadSuperuniques, version_D2Common >= V111 ? caller_loadTxtFiles_111 : caller_loadTxtFiles );
//6FD47F4A |. E8 B1750100 CALL D2Common.6FD5F500
//6FD47F4A |. E8 C1750100 CALL D2Common.6FD5F510
//01B6F7D6 |. E8 C5A7FFFF CALL D2Common.01B69FA0
//6FDC6853 |. E8 58B6FFFF CALL D2Common.6FDC1EB0 ; \D2Common.6FDC1EB0
//6FD87443 |. E8 58B6FFFF CALL D2Common.6FD82AA0 ; \D2Common.6FD82AA0
//6FDD1C43 |. E8 58B6FFFF CALL D2Common.6FDCD2A0 ; \D2Common.6FDCD2A0
//6FDAD6E3 |. E8 88C1FFFF CALL D2Common.6FDA9870 ; \D2Common.6FDA9870
// Free custom txt files
mem_seek R7(D2Common, 79EC, 79EC, 10186, 332B3, 15AB3, 44E13, 5E8B3);
MEMJ_REF4( D2Fog10212, caller_freeTxtFiles );
//6FD479EB . E8 C8C00600 CALL <JMP.&Fog.#10212>
//6FD479EB . E8 C8C00600 CALL <JMP.&Fog.#10212>
//01B50185 |. E8 F8410700 CALL <JMP.&Fog.#10212>
//6FD832B2 |. E8 755FFDFF CALL <JMP.&Fog.#10212>
//6FD65AB2 |. E8 B537FFFF CALL <JMP.&Fog.#10212>
//6FD94E12 |. E8 1744FCFF CALL <JMP.&Fog.#10212>
//6FDAE8B2 |. E8 8FA9FAFF CALL <JMP.&Fog.#10212>
log_msg("\n" );
isInstalled = true;
}
/*================================= END OF FILE =================================*/

52
PlugY/Progress.txt Normal file
View File

@ -0,0 +1,52 @@
Parameters.h et PlugY.rc => version changing
A faire :
A tester :
UPDATED :
DONE D2funcs.h
DONE BigStash.cpp
DONE ClientSaveFile.cpp
DONE Commands.cpp
DONE Common.cpp
DONE CustomLibraries.cpp
DONE D2functions.cpp
DONE D2wrapper.cpp
DONE Error.cpp
DONE ExtendedSaveFile.cpp
DONE ExtraOptions.cpp
DONE GlobalVariable.cpp
DONE InfinityStash.cpp
DONE INIfile.cpp
DONE Interface_Skills.cpp
DONE Interface_Stash.cpp
DONE Interface_Stats.cpp
DONE Language.cpp
DONE LoadPlayerData.cpp
DONE MainScreen.cpp
DONE ModifMemory.cpp
DONE NewInterface_CubeListing.cpp
DONE NewInterface_Runewords.cpp
DONE NewInterface_Stats.cpp
DONE NewInterface_StatsPageTwo.cpp
DONE NewInterfaces.cpp
DONE OthersFeatures.cpp
DONE Parameters.cpp
DONE PlayerCustomData.cpp
DONE PlugY.cpp
DONE PlugY.rc
DONE PlugYFiles.cpp
DONE SavePath.cpp
DONE SavePlayerData.cpp
DONE SharedSaveFile.cpp
DONE SkillPerLevelUp.cpp
DONE SkillsPoints.cpp
DONE StatPerLevelUp.cpp
DONE StatsPoints.cpp
DONE UberQuest.cpp
DONE UpdateClient.cpp
DONE UpdateServer.cpp
DONE WorldEvent.cpp

202
PlugY/SavePath.cpp Normal file
View File

@ -0,0 +1,202 @@
/*=================================================================
File created by Yohann NICOLAS.
Changing the current save path.
=================================================================*/
#include "savePath.h"
#include "common.h"
#include "error.h"
#include "d2functions.h"
char* savePath = NULL;
bool active_changingSavePath = false;
FCT_ASM( changeSavePath )
PUSH EDI
PUSH EDX
PUSH ESI
MOV EDI,DWORD PTR DS:[savePath]
XOR AL,AL
CLD
OR ECX,0xFFFFFFFF
REPNE SCAS BYTE PTR ES:[EDI]
NOT ECX
SUB EDI,ECX
XCHG EDI,ESI
CMP BYTE PTR [ESI+1],':'
JE END_CHANGESP
//RELATIVE_PATH:
MOV EDX,ECX
OR ECX,0xFFFFFFFF
REPNE SCAS BYTE PTR ES:[EDI]
DEC EDI
CMP BYTE PTR [EDI-1],'\\'
JE NEXT
MOV BYTE PTR [EDI],'\\'
INC EDI
NEXT:
MOV ECX,EDX
END_CHANGESP:
REP MOVS BYTE PTR ES:[EDI],BYTE PTR DS:[ESI]
POP ESI
POP EDX
POP EDI
PUSH ESI
CALL EBP
CMP EAX,-1
RETN
}}
FCT_ASM( changeSavePath_111 )
PUSH EAX
PUSH EDI
PUSH EDX
PUSH ESI
MOV EDI,DWORD PTR DS:[savePath]
XOR AL,AL
CLD
OR ECX,0xFFFFFFFF
REPNE SCAS BYTE PTR ES:[EDI]
NOT ECX
SUB EDI,ECX
XCHG EDI,ESI
CMP BYTE PTR [ESI+1],':'
JE END_CHANGESP
//RELATIVE_PATH:
MOV EDX,ECX
OR ECX,0xFFFFFFFF
REPNE SCAS BYTE PTR ES:[EDI]
DEC EDI
CMP BYTE PTR [EDI-1],'\\'
JE NEXT
MOV BYTE PTR [EDI],'\\'
INC EDI
NEXT:
MOV ECX,EDX
END_CHANGESP:
REP MOVS BYTE PTR ES:[EDI],BYTE PTR DS:[ESI]
POP ESI
POP EDX
POP EDI
POP EAX
CMP EAX,-1
JE DONOT_JMP
ADD DWORD PTR SS:[ESP],5
DONOT_JMP:
RETN
}}
FCT_ASM ( forCreateSavePath )
PUSH EDI
MOV EDI,DWORD PTR DS:[savePath]
MOV ECX,EDI
CMP BYTE PTR DS:[EDI+1],':'
JNZ END_CREATESP
PUSH ESI
XOR AL,AL
CLD
OR ECX,0xFFFFFFFF
REPNE SCAS BYTE PTR ES:[EDI]
NOT ECX
SUB EDI,ECX
XCHG EDI,ESI
REP MOVS BYTE PTR ES:[EDI],BYTE PTR DS:[ESI]
POP ESI
END_CREATESP:
POP EDI
MOV DWORD PTR SS:[ESP+8],ECX
JMP D2Storm503
}}
void Install_ChangingSavePath()
{
static int isInstalled = false;
if (isInstalled) return;
log_msg("Patch Fog for change the save path. (changingSavePath)\n");
if (version_Fog >= V111)
{
// Appel de notre fct d'ajout d'un sous-répertoire
mem_seek R7(Fog, 000, 000, 000, 185F6, 1C106, 1F086, 17F86);
memt_byte( 0x83 ,0xE8); // CALL changeSavePath
MEMT_REF4( 0x0575FFF8, changeSavePath_111);
//6FF685F6 . 83F8 FF CMP EAX,-1
//6FF685F9 . 75 05 JNZ SHORT fog.6FF68600
//6FF6C106 . 83F8 FF CMP EAX,-1
//6FF6C109 . 75 05 JNZ SHORT fog.6FF6C110
//6FF6F086 . 83F8 FF CMP EAX,-1
//6FF6F089 . 75 05 JNZ SHORT Fog.6FF6F090
//6FF67F86 . 83F8 FF CMP EAX,-1
//6FF67F89 . 75 05 JNZ SHORT Fog.6FF67F90
// Pour créer le bon chemin de sauvegarde
mem_seek R7(Fog, 000, 000, 000, 18616, 1C126, 1F0A6, 17FA6);
MEMJ_REF4( D2Storm503, forCreateSavePath);
//6FF68615 . E8 A246FFFF CALL <JMP.&Storm.#503>
//6FF6C125 . E8 C20BFFFF CALL <JMP.&Storm.#503>
//6FF6F0A5 . E8 34DDFEFF CALL <JMP.&Storm.#503>
//6FF67FA5 . E8 504EFFFF CALL <JMP.&Storm.#503>
// Remove registry update
mem_seek R7(Fog, 000, 000, 000, 1861A, 1C12A, 1F0AA, 17FAA);
memt_byte( 0x56 ,0xEB); // JMP SHORT fog.6FF6862C
memt_byte( 0x6A ,0x10); //
memt_byte( 0x00 ,0x90); // NOP
//6FF6861A . 56 PUSH ESI
//6FF6861B . 6A 00 PUSH 0
//6FF6861D . 68 7C7BF76F PUSH fog.6FF77B7C ; ASCII "Save Path"
//6FF68622 . 68 2876F76F PUSH fog.6FF77628 ; ASCII "Diablo II"
//6FF68627 . E8 1A47FFFF CALL <JMP.&Storm.#425>
//6FF6C12A . 56 PUSH ESI
//6FF6C12B . 6A 00 PUSH 0
//6FF6C12D . 68 BC73F76F PUSH fog.6FF773BC ; ASCII "Save Path"
//6FF6C132 . 68 C873F76F PUSH fog.6FF773C8 ; ASCII "Diablo II"
//6FF6C137 . E8 E60BFFFF CALL <JMP.&Storm.#425>
//6FF6F0AA . 56 PUSH ESI
//6FF6F0AB . 6A 00 PUSH 0
//6FF6F0AD . 68 D466F76F PUSH Fog.6FF766D4 ; ASCII "Save Path"
//6FF6F0B2 . 68 E066F76F PUSH Fog.6FF766E0 ; ASCII "Diablo II"
//6FF6F0B7 . E8 58DDFEFF CALL <JMP.&Storm.#425>
//6FF67FAA . 56 PUSH ESI
//6FF67FAB . 6A 00 PUSH 0
} else {
// Appel de notre fct d'ajout d'un sous-répertoire
mem_seek( (DWORD)D2FogGetSavePath + 0x28);//6FF61928-6FF50000
memt_byte( 0x56 ,0x90); // NOP
memt_byte( 0xFF ,0xE8); // CALL changeSavePath
MEMT_REF4( 0xFFF883D5, changeSavePath);
//6FF61928 56 PUSH ESI
//6FF61929 FFD5 CALL EBP
//6FF6192B 83F8 FF CMP EAX,-1
// Pour créer le bon chemin de sauvegarde
mem_seek( (DWORD)D2FogGetSavePath + 0xBD);//6FF619BC
MEMJ_REF4( D2Storm503, forCreateSavePath);
//6FF619BC . E8 5D2A0000 CALL <JMP.&Storm.#503>
// Remove registry update
mem_seek( (DWORD)D2FogGetSavePath + 0xC1);//6FF619C1-6FF50000
memt_byte( 0x56 ,0xEB); // JMP SHORT FOG.6FF619D2
memt_byte( 0x53 ,0x0F); //6FF619C3-6FF619D2
//6FF619C1 56 PUSH ESI
//6FF619C2 53 PUSH EBX
//6FF619C3 68 A877F76F PUSH Fog.6FF777A8 ; ASCII "Save Path"
//6FF619C8 68 9068F76F PUSH Fog.6FF76890 ; ASCII "Diablo II"
//6FF619CD E8 AC2A0000 CALL <JMP.&Storm.#425>
}
log_msg("\n");
isInstalled = true;
}
/*================================= END OF FILE =================================*/

611
PlugY/SavePlayerData.cpp Normal file
View File

@ -0,0 +1,611 @@
/*=================================================================
File created by Yohann NICOLAS.
Save Player Custom Data.
=================================================================*/
#include "common.h"
#include "error.h"
#include "d2functions.h"
#include "infinityStash.h"
#include "extendedSaveFile.h"
#include "sharedSaveFile.h"
void STDCALL SaveSPPlayerCustomData(Unit* ptChar)
{
if (!D2isLODGame()) return;//D2Game but in SP so np
log_msg("\n--- Start SaveSPPlayerCustomData ---\n");
if (PCPY->selfStashIsOpened)
{
DWORD curSizeExt = 0;
DWORD maxSizeExt = 0x4000;
BYTE* dataExt = (BYTE *)D2AllocMem(PCGame->memoryPool, maxSizeExt,__FILE__,__LINE__,0);
d2_assert(!dataExt, "Error : Memory allocation Extended SaveFile", __FILE__, __LINE__);
saveExtendedSaveFile(ptChar, &dataExt, &maxSizeExt, &curSizeExt);
writeExtendedSaveFile(PCPlayerData->name, dataExt, curSizeExt);
D2FreeMem(PCGame->memoryPool, dataExt,__FILE__,__LINE__,0);
}
if (active_sharedStash && PCPY->sharedStashIsOpened)
{
DWORD curSizeShr = 0;
DWORD maxSizeShr = 0x4000;
BYTE* dataShr = (BYTE *)D2AllocMem(PCGame->memoryPool, maxSizeShr,__FILE__,__LINE__,0);
d2_assert(!dataShr, "Error : Memory allocation Shared SaveFile", __FILE__, __LINE__);
saveSharedSaveFile(ptChar, &dataShr, &maxSizeShr, &curSizeShr);
NetClient* ptClient = D2GetClient(ptChar,__FILE__,__LINE__);
writeSharedSaveFile(PCPlayerData->name, dataShr, curSizeShr, ptClient->isHardCoreGame );
D2FreeMem(PCGame->memoryPool, dataShr,__FILE__,__LINE__,0);
}
log_msg("End saving.\n\n");
}
FCT_ASM ( caller_SaveSPPlayerCustomData_111 )
CALL D2FogGetSavePath
PUSH DWORD PTR SS:[ESP+0x2608]
CALL SaveSPPlayerCustomData
RETN
}}
FCT_ASM ( caller_SaveSPPlayerCustomData )
CALL D2FogGetSavePath
PUSH EDI
CALL SaveSPPlayerCustomData
RETN
}}
FCT_ASM ( caller_SaveSPPlayerCustomData_9 )
CALL D2FogGetSavePath
PUSH ESI
CALL SaveSPPlayerCustomData
RETN
}}
//////////////////////////////////////////////////////////////////////////////////////////////////
#define TC_SAVE_PERSONAL 0
#define TC_SAVE_SHARED 1
#pragma pack(1)
typedef struct {
BYTE packID;
BYTE packSize;
BYTE init;
DWORD finalSize:31;
DWORD isCustom:1;
BYTE type;
BYTE data[0xFF];
} t_rcvMsg;
#pragma pack()
struct s_MPSaveFile
{
int sizeExtended;
int curExtended;
BYTE* dataExtended;
int sizeShared;
int curShared;
BYTE* dataShared;
};
static s_MPSaveFile receivedSaveFiles;
static BYTE customPackID = 0xB2;
//static s_MPSaveFile* receivedSaveFiles = NULL;
struct s_dataToSend
{
s_dataToSend* next;
int clientID;
int sizeExtended;
int curExtended;
BYTE* dataExtended;
int sizeShared;
int curShared;
BYTE* dataShared;
bool init;
};
s_dataToSend* ptDataToSend=NULL;
/*
void sendDataToSave(DWORD clientID, BYTE* data, DWORD size, bool isShared)
{
t_rcvMsg pack;
d2_assert(size >= 0x40000000, "size of file > 0x40000000", __FILE__, __LINE__);
pack.packID = customPackID;
pack.init = !isShared;
pack.finalSize = size;
pack.type = isShared ? TC_SAVE_SHARED : TC_SAVE_PERSONAL;
pack.isCustom = true;
DWORD sended = 0;
while (sended < size)
{
pack.packSize = (BYTE) (size - sended > 0xFE ? 0xFE : size - sended);
CopyMemory(pack.data, &data[sended], pack.packSize);
log_msg("send: ID=%02X\tsize=%02X\tinit=%02X\ttotalsize=%08X\ttype=%d\n", pack.packID, pack.init, pack.packSize, pack.finalSize, pack.type);
pack.packSize++;
D2SendToClient(0, clientID, (BYTE*)&pack, pack.packSize+7);
pack.init = false;
sended += pack.packSize -1;
}
log_msg("\n");
}*/
void STDCALL SendSaveFilesToSave( Unit* ptChar )
{
// if (!D2isLODGame()) return;
log_msg("\n--- Start SendSaveFilesToSave ---\n");
DWORD curSizeExt = 0;
BYTE* dataExt = NULL;
DWORD curSizeShr = 0;
BYTE* dataShr = NULL;
if (PCPY->selfStashIsOpened)
{
DWORD maxSizeExt = 0x4000;
dataExt = (BYTE *)D2AllocMem(PCGame->memoryPool, maxSizeExt,__FILE__,__LINE__,0);
d2_assert(!dataExt, "Error : Memory allocation Extended SaveFile", __FILE__, __LINE__);
saveExtendedSaveFile(ptChar, &dataExt, &maxSizeExt, &curSizeExt);
}
if (active_sharedStash && PCPY->sharedStashIsOpened)
{
DWORD maxSizeShr = 0x4000;
dataShr = (BYTE *)D2AllocMem(PCGame->memoryPool, maxSizeShr,__FILE__,__LINE__,0);
d2_assert(!dataShr, "Error : Memory allocation Shared SaveFile", __FILE__, __LINE__);
saveSharedSaveFile(ptChar, &dataShr, &maxSizeShr, &curSizeShr);
}
NetClient* ptClient = D2GetClient(ptChar,__FILE__,__LINE__);
s_dataToSend* dataToSend = ptDataToSend;
while (dataToSend && (dataToSend->clientID != ptClient->clientID))
dataToSend = dataToSend->next;
if (!dataToSend)
{
dataToSend = (s_dataToSend*) D2AllocMem(PCGame->memoryPool, sizeof(s_dataToSend), __FILE__, __LINE__, 0);
ZeroMemory(dataToSend, sizeof(s_dataToSend));
dataToSend->next = ptDataToSend;
ptDataToSend = dataToSend;
}
//Sending savefiles
dataToSend->clientID = ptClient->clientID;
dataToSend->init = 1;
dataToSend->sizeExtended = curSizeExt;
dataToSend->curExtended = 0;
dataToSend->dataExtended = dataExt;
dataToSend->sizeShared = curSizeShr;
dataToSend->curShared = 0;
dataToSend->dataShared = dataShr;
log_msg("clientID=%d\t init=%d\t sizeExtended=%X\t curExtended=%X\t dataExtended=%X\t sizeShared=%X\t curShared=%X\t dataShared=%08X\n",
dataToSend->clientID, dataToSend->init, dataToSend->sizeExtended, dataToSend->curExtended, dataToSend->dataExtended, dataToSend->sizeShared, dataToSend->curShared, dataToSend->dataShared);
/* NetClient* ptClient = D2GetClient(ptChar,__FILE__,__LINE__);
if (dataExt)
{
sendDataToSave(ptClient->clientID, dataExt, curSizeExt, false);
D2FreeMem(PCGame->memoryPool, dataExt,__FILE__,__LINE__,0);
}
if (dataShr)
{
sendDataToSave(ptClient->clientID, dataShr, curSizeShr, true);
D2FreeMem(PCGame->memoryPool, dataShr,__FILE__,__LINE__,0);
}
*/
log_msg("End SendSaveFilesToSave.\n\n");
}
DWORD STDCALL ManageNextPacketToSend(NetClient* ptClient)
{
log_msg("ManageNextPacketToSend: ");
s_dataToSend* dataToSend = ptDataToSend;
while (dataToSend && (dataToSend->clientID != ptClient->clientID))
dataToSend = dataToSend->next;
if (!dataToSend) return 1;
log_msg("clientID=%d\t init=%d\t sizeExtended=%X\t curExtended=%X\t dataExtended=%X\t sizeShared=%X\t curShared=%X\t dataShared=%08X\n",
dataToSend->clientID, dataToSend->init, dataToSend->sizeExtended, dataToSend->curExtended, dataToSend->dataExtended, dataToSend->sizeShared, dataToSend->curShared, dataToSend->dataShared);
if (dataToSend->sizeExtended && dataToSend->dataExtended && (dataToSend->curExtended < dataToSend->sizeExtended))
{
DWORD remainingData = dataToSend->sizeExtended - dataToSend->curExtended;
t_rcvMsg* msg = (t_rcvMsg*)D2AllocMem(PClientGame->memoryPool, sizeof(t_rcvMsg),__FILE__,__LINE__,0);
msg->packID = customPackID;
msg->init = dataToSend->init;
msg->finalSize = dataToSend->sizeExtended;
msg->type = TC_SAVE_PERSONAL;
msg->isCustom = true;
msg->packSize = remainingData > 0xFE ? 0xFF : (BYTE)remainingData + 1;
CopyMemory(msg->data, &dataToSend->dataExtended[dataToSend->curExtended], msg->packSize);
log_msg("Saving Send Packet: type=%X\t init=%d\t finalSize=%X\t packSize=%02X\t data=%08X\n", msg->type, msg->init, msg->finalSize, msg->packSize, msg->data);
D2SendToClient(0, dataToSend->clientID, msg, msg->packSize+7);
dataToSend->init = false;
dataToSend->curExtended += msg->packSize - 1;
D2FreeMem(PClientGame->memoryPool, msg,__FILE__,__LINE__,0);
if (dataToSend->curExtended == dataToSend->sizeExtended)
{
dataToSend->sizeExtended = 0;
dataToSend->curExtended = 0;
D2FreeMem(PClientGame->memoryPool, dataToSend->dataExtended,__FILE__,__LINE__,0);
dataToSend->dataExtended = NULL;
}
log_msg("End Send Packet\n");
return 0;//ManageNextPacketToSend(ptClient);//return 0;
}
if (dataToSend->sizeShared && dataToSend->dataShared && (dataToSend->curShared < dataToSend->sizeShared))
{
DWORD remainingData = dataToSend->sizeShared - dataToSend->curShared;
t_rcvMsg* msg = (t_rcvMsg*)D2AllocMem(PClientGame->memoryPool, sizeof(t_rcvMsg),__FILE__,__LINE__,0);
msg->packID = customPackID;
msg->init = dataToSend->init;
msg->finalSize = dataToSend->sizeShared;
msg->type = TC_SAVE_SHARED;
msg->isCustom = true;
msg->packSize = remainingData > 0xFE ? 0xFF : (BYTE)remainingData + 1;
CopyMemory(msg->data, &dataToSend->dataShared[dataToSend->curShared], msg->packSize);
log_msg("Saving Send Packet: type=%X\t init=%d\t finalSize=%X\t packSize=%02X\t data=%08X\n", msg->type, msg->init, msg->finalSize, msg->packSize, msg->data);
D2SendToClient(0, dataToSend->clientID, msg, msg->packSize+7);
dataToSend->init = false;
dataToSend->curShared += msg->packSize - 1;
D2FreeMem(PClientGame->memoryPool, msg,__FILE__,__LINE__,0);
if (dataToSend->curShared == dataToSend->sizeShared)
{
dataToSend->sizeShared = 0;
dataToSend->curShared = 0;
D2FreeMem(PClientGame->memoryPool, dataToSend->dataShared,__FILE__,__LINE__,0);
dataToSend->dataShared = NULL;
}
log_msg("End Send Packet\n");
return 0;//ManageNextPacketToSend(ptClient);//return 0;
}
log_msg("End Send Packet\n");
return 1;
}
DWORD STDCALL ReceiveSaveFilesToSave(t_rcvMsg* msg)
{
if( (msg->packID != customPackID) || !msg->isCustom) return 0;
log_msg("Saving Receive Packet: type=%X\t init=%d\t finalSize=%X\t packSize=%02X\t data=%08X\n", msg->type, msg->init, msg->finalSize, msg->packSize, msg->data);
bool isShared;
if ( msg->type == TC_SAVE_PERSONAL)
isShared = false;
else if (msg->type == TC_SAVE_SHARED)
isShared = true;
else return 0;
if (msg->init)
{
D2FogMemDeAlloc(receivedSaveFiles.dataExtended,__FILE__,__LINE__,0);
D2FogMemDeAlloc(receivedSaveFiles.dataShared,__FILE__,__LINE__,0);
ZeroMemory(&receivedSaveFiles, sizeof(receivedSaveFiles));//TODO
}
log_msg("receivedSaveFiles: sizeExtended=%d\t curExtended=%d\t dataExtended=%08X\t sizeShared=%d\t curShared=%d\t dataShared=%08X\n", receivedSaveFiles.sizeExtended, receivedSaveFiles.curExtended, receivedSaveFiles.dataExtended, receivedSaveFiles.sizeShared, receivedSaveFiles.curShared, receivedSaveFiles.dataShared);
DWORD size = msg->packSize - 1;
if (isShared)
{
if (receivedSaveFiles.sizeShared == 0)
receivedSaveFiles.sizeShared = msg->finalSize;
// d2_assert(receivedSaveFiles.sizeShared != msg->finalSize, "Size of shared file has change", __FILE__, __LINE__);
if (!receivedSaveFiles.dataShared)
receivedSaveFiles.dataShared = (BYTE *)D2FogMemAlloc(receivedSaveFiles.sizeShared,__FILE__,__LINE__,0);
CopyMemory(&receivedSaveFiles.dataShared[receivedSaveFiles.curShared], msg->data, size);
receivedSaveFiles.curShared += size;
} else {
if (receivedSaveFiles.sizeExtended == 0)
receivedSaveFiles.sizeExtended = msg->finalSize;
// d2_assert(receivedSaveFiles.sizeExtended != msg->finalSize, "Size of extented file has change", __FILE__, __LINE__);
if (!receivedSaveFiles.dataExtended)
receivedSaveFiles.dataExtended = (BYTE *)D2FogMemAlloc(receivedSaveFiles.sizeExtended,__FILE__,__LINE__,0);
CopyMemory(&receivedSaveFiles.dataExtended[receivedSaveFiles.curExtended], msg->data, size);
receivedSaveFiles.curExtended += size;
}
log_msg("End Save Receive Packet\n");
return 1;
}
void STDCALL SaveMPPlayerCustomData(BYTE* dataD2Savefile )
{
log_msg("Start SaveMPPlayerCustomData.\n");
Unit* ptChar = D2GetClientPlayer();
if( receivedSaveFiles.sizeExtended && (receivedSaveFiles.sizeExtended == receivedSaveFiles.curExtended) && receivedSaveFiles.sizeShared && (receivedSaveFiles.sizeShared == receivedSaveFiles.curShared) )
{
log_msg("Saving can start\n");
if (ptChar)
{
writeExtendedSaveFile(PCPlayerData->name, receivedSaveFiles.dataExtended, receivedSaveFiles.sizeExtended);
D2FogMemDeAlloc(receivedSaveFiles.dataExtended,__FILE__,__LINE__,0);
if (active_sharedStash)
writeSharedSaveFile(PCPlayerData->name, receivedSaveFiles.dataShared, receivedSaveFiles.sizeShared, (dataD2Savefile[0x24] & 4) == 4);//6FBAB9A4-6FAA0000
D2FogMemDeAlloc(receivedSaveFiles.dataShared,__FILE__,__LINE__,0);
ZeroMemory(&receivedSaveFiles,sizeof(receivedSaveFiles));
}
log_msg("Receive Savefiles completed\n\n");
} else {
if (ptChar)
{
log_box("Connection error : back up current save file then save with client data.");
backupSharedSaveFile();
backupExtendedSaveFile(PCPlayerData->name);
SaveSPPlayerCustomData(ptChar);
}
}
log_msg("--- End SaveMPPlayerCustomData. ---\n\n");
}
/*
FCT_ASM ( caller_SendSaveFilesToSave_9 )
POP ECX
PUSH EAX
PUSH ECX
PUSH EBX
CALL SendSaveFilesToSave
MOV EDX,EBX
MOV ECX,EDI
RETN
}}
FCT_ASM ( caller_SendSaveFilesToSave )
POP ECX
PUSH EAX
PUSH ECX
PUSH EBX
CALL SendSaveFilesToSave
MOV EDX,EBX
MOV ECX,EBP
RETN
}}
*/
FCT_ASM( caller_ManageNextPacketToSend )
PUSH ESI
CALL ManageNextPacketToSend
TEST EAX,EAX
JNZ end_caller_ManageNextPacketToSend
XOR ECX,ECX
RETN
end_caller_ManageNextPacketToSend:
MOV ECX,DWORD PTR DS:[ESI+0x17C]
RETN
}}
FCT_ASM( caller_ManageNextPacketToSend_9 )
PUSH ESI
CALL ManageNextPacketToSend
TEST EAX,EAX
JNZ end_caller_ManageNextPacketToSend_9
MOV DWORD PTR DS:[ESI+0x14C],5
POP ESI
POP ESI
RETN
end_caller_ManageNextPacketToSend_9:
MOV EAX,DWORD PTR DS:[ESI+0x150]
RETN
}}
FCT_ASM( caller_ManageNextPacketToSend_9d )
PUSH ESI
CALL ManageNextPacketToSend
TEST EAX,EAX
JNZ end_caller_ManageNextPacketToSend_9d
MOV DWORD PTR DS:[ESI+0x170],5
POP ESI
POP ESI
RETN
end_caller_ManageNextPacketToSend_9d:
MOV EAX,DWORD PTR DS:[ESI+0x174]
RETN
}}
FCT_ASM( caller_SendSaveFilesToSave_111 )
PUSH DWORD PTR SS:[ESP+0x2014]
CALL SendSaveFilesToSave
MOV EAX,DWORD PTR SS:[ESP+0x8]
TEST EAX,EAX
RETN
}}
FCT_ASM( caller_SendSaveFilesToSave )
PUSH EDI
CALL SendSaveFilesToSave
MOV EDI,DWORD PTR SS:[ESP+0x14]
TEST EDI,EDI
RETN
}}
FCT_ASM( caller_SendSaveFilesToSave_9 )
PUSH ESI
CALL SendSaveFilesToSave
MOV ESI,DWORD PTR SS:[ESP+0x14]
TEST ESI,ESI
RETN
}}
FCT_ASM ( caller_ReceivedSaveFilesToSave_111 )
LEA EAX,DWORD PTR SS:[ESP+0x10]
PUSH EAX
CALL ReceiveSaveFilesToSave
TEST EAX,EAX
JE continue_rcvFct
ADD DWORD PTR SS:[ESP],0x3D
RETN
continue_rcvFct:
MOVZX EAX,BYTE PTR SS:[ESP+0x10]
RETN
}}
FCT_ASM ( caller_ReceivedSaveFilesToSave )
CMP EDX,-1
JE continue_rcvFct
PUSH ECX
PUSH EDX
PUSH ECX
CALL ReceiveSaveFilesToSave
POP EDX
POP ECX
TEST EAX,EAX
JE continue_rcvFct
XOR EAX,EAX
ADD ESP,4
RETN
continue_rcvFct:
POP EAX
SUB ESP,0x5F4//5F4
JMP EAX
// JMP DWORD PTR SS:[ESP+0x5F0]
}}
FCT_ASM ( caller_SaveMPPlayerCustomData_111 )
PUSH EAX
PUSH ECX
PUSH EAX
CALL SaveMPPlayerCustomData
POP ECX
POP EAX
CMP ECX,0xAA55AA55
RETN
}}
FCT_ASM ( caller_SaveMPPlayerCustomData )
PUSH ECX
PUSH ECX
CALL SaveMPPlayerCustomData
POP ECX
MOV EAX,DWORD PTR DS:[ECX]
MOV EDX,DWORD PTR DS:[ECX+4]
RETN
}}
void Install_SavePlayerData()
{
static int isInstalled = false;
if (isInstalled || !active_PlayerCustomData) return;
log_msg("Patch D2Game & D2Client for save Player's custom data. (SavePlayerData)\n");
//Save single player custom data.
mem_seek R7(D2Game, 4DF04, 4E304, 5A624, B9365, 25475, 44165, 53F35);
MEMJ_REF4( D2FogGetSavePath, version_D2Game >= V111 ? caller_SaveSPPlayerCustomData_111 : version_D2Game != V109b ? caller_SaveSPPlayerCustomData : caller_SaveSPPlayerCustomData_9);
//6FC8A623 E8 3E210900 CALL <JMP.&Fog.#10115>
//02039364 |. E8 3B0FF5FF CALL <JMP.&Fog.#10115>
//01F95474 |. E8 C34EFEFF CALL <JMP.&Fog.#10115>
//6FC64164 |. E8 EB61FCFF CALL <JMP.&Fog.#10115>
//6FC73F34 |. E8 DD63FBFF CALL <JMP.&Fog.#10115>
//Send SaveFiles
mem_seek R7(D2Game, 4DFFA, 4E3FA, 5A720, B92DB, 253EB, 440DB, 53EAB);
memt_byte( 0x8B ,0x90); // NOP
memt_byte( version_D2Game >= V111 ? 0x44 : version_D2Game != V109b ? 0x7C : 0x74 ,0xE8); // CALL
MEMT_REF4( version_D2Game >= V111 ? 0xC0850424 : version_D2Game != V109b ? 0xFF851024 : 0xF6851024, version_D2Game >= V111 ? caller_SendSaveFilesToSave_111 : version_D2Game != V109b ? caller_SendSaveFilesToSave : caller_SendSaveFilesToSave_9);
//6FC8A720 |. 8B7C24 10 MOV EDI,DWORD PTR SS:[ESP+10]
//6FC8A724 |. 85FF TEST EDI,EDI
//020392DB |. 8B4424 04 MOV EAX,DWORD PTR SS:[ESP+4]
//020392DF |. 85C0 TEST EAX,EAX
//01F953EB |. 8B4424 04 MOV EAX,DWORD PTR SS:[ESP+4]
//01F953EF |. 85C0 TEST EAX,EAX
//6FC640DB |. 8B4424 04 MOV EAX,DWORD PTR SS:[ESP+4]
//6FC640DF |. 85C0 TEST EAX,EAX
//6FC73EAB |. 8B4424 04 MOV EAX,DWORD PTR SS:[ESP+4]
//6FC73EAF |. 85C0 TEST EAX,EAX
mem_seek R7(D2Game, 7993, 7A13, 7BBB, E2943, E6D83, A89D3, 2D173);
memt_byte( 0x8B ,0x90); // NOP
memt_byte( version_D2Game >= V110 ? 0x8E : 0x86 ,0xE8); // CALL
MEMT_REF4( version_D2Game >= V110 ? 0x0000017C : version_D2Game == V109d ? 0x0000174 : 0x00000150, version_D2Game >= V110 ? caller_ManageNextPacketToSend : version_D2Game == V109d ? caller_ManageNextPacketToSend_9d : caller_ManageNextPacketToSend_9);
//6FC37BBB |> 8B8E 7C010000 MOV ECX,DWORD PTR DS:[ESI+17C]
//02062943 |. 8B8E 7C010000 MOV ECX,DWORD PTR DS:[ESI+17C]
//02056D83 |. 8B8E 7C010000 MOV ECX,DWORD PTR DS:[ESI+17C]
//6FCC89D3 |. 8B8E 7C010000 MOV ECX,DWORD PTR DS:[ESI+17C]
//6FC4D173 |. 8B8E 7C010000 MOV ECX,DWORD PTR DS:[ESI+17C]
// mem_seek R7(D2Game, 7B82, 7C05, 7DCF, 0000, 0000, 0000, 0000);//117FC, 117EC, 11DBC
// memt_byte( 0x8B ,0xE8); // CALL
// MEMT_REF4( (version_D2Game == V110) ? 0x50CD8BD3 : 0x50CF8BD3, (version_D2Game == V110) ? caller_SendSaveFilesToSave : caller_SendSaveFilesToSave_9);
//6FC37DCF |. 8BD3 |MOV EDX,EBX
//6FC37DD1 |. 8BCD |MOV ECX,EBP
//6FC37DD3 |. 50 |PUSH EAX
if ( version_D2Game >= V111 )
{
//Received SaveFiles
mem_seek R7(D2Client, 116F0, 116E0, 11CB0, 89246, 32076, 7BCD6, 43946);
memt_byte( 0x0F ,0xE8);
MEMT_REF4( 0x0C2444B6, caller_ReceivedSaveFilesToSave_111);
//6FB39246 |. 0FB64424 0C |MOVZX EAX,BYTE PTR SS:[ESP+C]
//6FAE2076 |. 0FB64424 0C |MOVZX EAX,BYTE PTR SS:[ESP+C]
//6FB2BCD6 |. 0FB64424 0C |MOVZX EAX,BYTE PTR SS:[ESP+C]
//6FAF3946 |. 0FB64424 0C |MOVZX EAX,BYTE PTR SS:[ESP+C]
// Save multiplayer player custom data.
mem_seek R7(D2Client, 117FC, 117EC, 11DBC, 99AE2, BD7F2, 64A22, AC572);
memt_byte( 0x81 ,0xE8); // CALL
MEMT_REF4( 0x55AA55F9, caller_SaveMPPlayerCustomData_111);
memt_byte( 0xAA ,0x90); // CALL
//6FB49AE2 |. 81F9 55AA55AA CMP ECX,AA55AA55
//6FB6D7F2 |. 81F9 55AA55AA CMP ECX,AA55AA55
//6FB14A22 |. 81F9 55AA55AA CMP ECX,AA55AA55
//6FB5C572 |. 81F9 55AA55AA CMP ECX,AA55AA55
} else {
//Received SaveFiles
mem_seek R7(D2Client, 116F0, 116E0, 11CB0, 89246, 32076, 7BCD6, 0000);
memt_byte( 0x81 ,0x90); // NOP
memt_byte( 0xEC ,0xE8); // CALL
MEMT_REF4( 0x000005F4, caller_ReceivedSaveFilesToSave);
//6FAB1CB0 |$ 81EC F4050000 SUB ESP,5F4
// Save multiplayer player custom data.
mem_seek R7(D2Client, 117FC, 117EC, 11DBC, 99AE2, BD7F2, 64A22, 0000);
memt_byte( 0x8B ,0xE8); // CALL
MEMT_REF4( 0x04518B01, caller_SaveMPPlayerCustomData);
//6FAB1DBC |. 8B01 MOV EAX,DWORD PTR DS:[ECX]
//6FAB1DBE |. 8B51 04 MOV EDX,DWORD PTR DS:[ECX+4]
}
if ( version_D2Game == V109b || version_D2Game == V109d )
customPackID = 0xAB;
else if ( version_D2Game >= V111 )
customPackID++;
log_msg("\n");
isInstalled = true;
}
/*================================= END OF FILE =================================*/

221
PlugY/SharedSaveFile.cpp Normal file
View File

@ -0,0 +1,221 @@
/*=================================================================
File created by Yohann NICOLAS.
Add an extra save file shared by all own characters.
=================================================================*/
#include "common.h"
#include "sharedSaveFile.h"
#include "error.h"
#include "d2functions.h"
#include "infinityStash.h"
#include "customLibraries.h"
#define FILE_SHAREDSTASH 0x00535353 //"SSS "
#define BUFFER_SIZE 0x4000
#define FILE_VERSION 0x3230 //"02"
//6FC8CE8A |. E8 A16BFAFF CALL D2Game.6FC33A30
//$+C0 > 1F 00 00 00 03 00 00 06 .....
// 28 0010 1000
BYTE* readSharedSaveFile(char* name, DWORD* size)
{
char filename[512];
BYTE* data=NULL;
BYTE isHardCore=0;
FILE* file=NULL;
if (separateHardSoftStash)//Get hardcore flag
{
D2FogGetSavePath( filename, 512-strlen(name)-5);
strcat(filename,name);
strcat(filename,".d2s");
log_msg("Normal file to read if it's hardcore character : %s\n",filename);
file = fopen(filename, "rb");
if (file)
{
fseek(file, 0x24, SEEK_SET);
DWORD nbRead = fread(&isHardCore, 1, 1, file);
isHardCore = (nbRead==1)? ((isHardCore & 4) == 4) : 0;
fclose(file);
file=NULL;
}
log_msg("%s is a HardCore character = %d\n",name,isHardCore);
}
if (active_sharedStash)
{
D2FogGetSavePath( filename, 512-strlen("_LOD_HC_SharedStashSave")-5);
strcat(filename,isHardCore? "_LOD_HC_" : "_LOD_");
strcat(filename, sharedStashFilename);
strcat(filename,".sss");
log_msg("Shared file to read : %s\n",filename);
file = fopen(filename, "rb");
}
if (file)
{
fseek(file, 0, SEEK_END);
*size = ftell(file);
fseek(file, 0, SEEK_SET);
data = (BYTE*)D2FogMemAlloc(*size,__FILE__,__LINE__,0);
DWORD nbRead = fread(data, 1, *size, file);
fclose(file);
d2_assert(nbRead != *size , "nbRead from shared save file != size", __FILE__, __LINE__);
} else {
log_msg("Can't open shared save file in mode \"rb\" (is not an error if it's the first start of the mod)\n");
*size = 14;
DWORD maxSize = 100;
data = (BYTE*)D2FogMemAlloc(maxSize,__FILE__,__LINE__,0);
*((DWORD *)&data[0]) = FILE_SHAREDSTASH;
*((WORD *)&data[4]) = FILE_VERSION;
*((DWORD *)&data[6]) = 0;
*((DWORD *)&data[10]) = 0;// number of stash
TCustomDll* currentDll = customDlls;
while (currentDll)
{
currentDll->initSharedSaveFile(&data, &maxSize, size);
currentDll=currentDll->nextDll;
}
}
return data;
}
int loadSharedSaveFile(Unit* ptChar, BYTE data[], DWORD maxSize)
{
if ( !ptChar || !data) return false;
log_msg("Load shared file\n");
DWORD curSize = 0;
if (*(DWORD*)&data[curSize] != FILE_SHAREDSTASH)
{
log_msg("loadSharedSaveFile -> bad header\n");
return 9;
}
curSize += 4;
if (*(WORD *)&data[curSize] == 0x3130) {//"01"
curSize += 2;
PCPY->sharedGold = 0;
} else if (*(WORD *)&data[curSize] == FILE_VERSION) {
curSize += 2;
PCPY->sharedGold = *(DWORD*)&data[curSize];
curSize += 4;
} else {
log_msg("loadSharedSaveFile -> bad file version : %04X\n", *(WORD *)&data[curSize]);
return 9;
}
int ret = loadStashList(ptChar, data, maxSize, &curSize, true);
TCustomDll* currentDll = customDlls;
while (!ret && currentDll)
{
ret = currentDll->loadSharedSaveFile(ptChar, data, maxSize, &curSize);
currentDll=currentDll->nextDll;
}
PCPY->sharedStashIsOpened = true;
return ret;
}
void writeSharedSaveFile(char* name, BYTE* data, DWORD size, bool isHardcore)
{
char szTempName[MAX_PATH];
char szSaveName[MAX_PATH];
//Get temporary savefile name.
D2FogGetSavePath( szTempName, MAX_PATH-30);
strcat(szTempName, separateHardSoftStash && isHardcore? "_LOD_HC_" : "_LOD_");
strcat(szTempName, sharedStashFilename);
strcat(szTempName,".ss~");
log_msg("Shared temporary file for saving : %s\n", szTempName);
//Write data in savefile.
FILE* customSaveFile = fopen(szTempName, "wb+");
fwrite(data, size, 1, customSaveFile);
fclose(customSaveFile);
//Get real savefile name.
D2FogGetSavePath( szSaveName, MAX_PATH-30);
strcat(szSaveName, separateHardSoftStash && isHardcore? "_LOD_HC_" : "_LOD_");
strcat(szSaveName, sharedStashFilename);
strcat(szSaveName,".sss");
log_msg("Shared file for saving : %s\n", szSaveName);
// if (!MoveFileEx(szTempName, szSaveName, MOVEFILE_WRITE_THROUGH|MOVEFILE_REPLACE_EXISTING))
DeleteFile(szSaveName);
if (!MoveFile(szTempName, szSaveName))
log_box("Could not create the shared save file.");
}
void backupSharedSaveFile()
{
char szBackupName[MAX_PATH];
char szSaveName[MAX_PATH];
D2FogGetSavePath( szSaveName, MAX_PATH-30);
strcat(szSaveName, "_LOD_");
strcat(szSaveName, sharedStashFilename);
strcat(szSaveName,".sss");
D2FogGetSavePath( szBackupName, MAX_PATH-30);
strcat(szBackupName, "_LOD_");
strcat(szBackupName, sharedStashFilename);
strcat(szBackupName,".sss.backup");
CopyFile(szSaveName, szBackupName, true);
if (separateHardSoftStash)
{
D2FogGetSavePath( szSaveName, MAX_PATH-30);
strcat(szSaveName, "_LOD_HC_");
strcat(szSaveName, sharedStashFilename);
strcat(szSaveName,".sss");
D2FogGetSavePath( szBackupName, MAX_PATH-30);
strcat(szBackupName, "_LOD_HC_");
strcat(szBackupName, sharedStashFilename);
strcat(szBackupName,".sss.backup");
CopyFile(szSaveName, szBackupName, true);
}
}
void saveSharedSaveFile(Unit* ptChar, BYTE** data, DWORD* maxSize, DWORD* curSize)
{
*(DWORD *)(*data + *curSize) = FILE_SHAREDSTASH;
*curSize += 4;
if (PCPY->sharedGold)
{
*(WORD *)(*data + *curSize) = FILE_VERSION;
*curSize += 2;
*(DWORD *)(*data + *curSize) = PCPY->sharedGold;
*curSize += 4;
} else {
*(WORD *)(*data + *curSize) = 0x3130;
*curSize += 2;
}
saveStashList(ptChar, PCPY->sharedStash, data, maxSize, curSize);
TCustomDll* currentDll = customDlls;
while (currentDll)
{
currentDll->saveSharedSaveFile(ptChar, data, maxSize, curSize);
currentDll=currentDll->nextDll;
}
}
/*================================= END OF FILE =================================*/

53
PlugY/SkillPerLevelUp.cpp Normal file
View File

@ -0,0 +1,53 @@
/*=================================================================
File created by Yohann NICOLAS.
Change Skill win per level up.
=================================================================*/
#include "skillPerLevelUp.h"
#include "common.h"
#include "error.h"
#include "d2functions.h"
bool active_SkillPerLevelUpChange=0;
DWORD skillPerLevelUp=1;
FCT_ASM ( caller_changeSkillPerLevelUp_111 )
MOV EAX,skillPerLevelUp
IMUL EAX,EBX
MOV DWORD PTR SS:[ESP+0xC], EAX
JMP V2AddPlayerStat
}}
FCT_ASM ( caller_changeSkillPerLevelUp )
MOV EAX,skillPerLevelUp
IMUL EAX,EDI
MOV DWORD PTR SS:[ESP+0xC], EAX
JMP V2AddPlayerStat
}}
void Install_SkillPerLevelUp()
{
static int isInstalled = false;
if (isInstalled) return;
log_msg("Patch D2Game for change Skill points win per level up. (SkillPerLevelUp)\n");
mem_seek R7(D2Game, 42261, 42651, 4ED60, D7AE5, 79695, AA455, EB1E5);
MEMJ_REF4( V2AddPlayerStat, version_D2Game >= V111 ? caller_changeSkillPerLevelUp_111 : caller_changeSkillPerLevelUp);
//6FC7ED5F |. E8 56CB0900 CALL <JMP.&D2Common.#10518>
//02057AE4 |. E8 9F28F3FF CALL <JMP.&D2Common.#10109>
//01FE9694 |. E8 1B0DF9FF CALL <JMP.&D2Common.#10627>
//6FCCA454 |. E8 5F01F6FF CALL <JMP.&D2Common.#10762>
//6FD0B1E4 |. E8 E9F2F1FF CALL <JMP.&D2Common.#10551>
log_msg("\n");
isInstalled = true;
}
/*================================= END OF FILE =================================*/

97
PlugY/SkillsPoints.cpp Normal file
View File

@ -0,0 +1,97 @@
/*=================================================================
File created by Yohann NICOLAS.
Unassign Skill Point for futher re-assignment.
=================================================================*/
#include "common.h"
#include "error.h"
#include "d2functions.h"
#include "updateServer.h"
#include "interface_Skills.h" // Install_InterfaceSkills()
bool active_SkillsPoints=0;
bool unassignSkillsPointsOneByOne=0;
int (*getskPoint)(SkillData* ptSkill);
int (*getCharClass)(SkillData* ptSkill);
TD2GetPlayerStat getSingleSkillValue;
int getskPoint_109(SkillData* ptSkill) {return -1;}
int getskPoint_11X(SkillData* ptSkill) {return ptSkill->ptSkillBin->skpoints;}
int getCharClass_109(SkillData* ptSkill) {return *(&ptSkill->ptSkillBin->charclass+8);}
int getCharClass_11X(SkillData* ptSkill) {return ptSkill->ptSkillBin->charclass;}
int STDCALL getSingleSkillValue_109(Unit* ptChar, DWORD , DWORD skillID)
{
DWORD stat;
DWORD ret=0;
stat = D2GetPlayerStat(ptChar, STATS_ITEM_SINGLESKILL+0, skillID);
if ((stat & 255) == skillID) ret += (stat >> 8) & 255;
stat = D2GetPlayerStat(ptChar, STATS_ITEM_SINGLESKILL+1, skillID);
if ((stat & 255) == skillID) ret += (stat >> 8) & 255;
stat = D2GetPlayerStat(ptChar, STATS_ITEM_SINGLESKILL+2, skillID);
if ((stat & 255) == skillID) ret += (stat >> 8) & 255;
return ret;
}
void UnassignAllSkillsPoints(Unit* ptChar)
{
DWORD skillID, keepBonus, maxSkillLevel;
int skpoints;
DWORD nbPoints = 0;
void* ptClient = D2GetClient(ptChar,__FILE__,__LINE__);
SkillData* ptSkill = PCSkills->ptFirstSkill;
while (ptSkill)
{
if (getCharClass(ptSkill) == ptChar->nPlayerClass)//ptSkill->ptSkillBin->charclass
if (ptSkill->state == -1)
{
skillID = ptSkill->ptSkillBin->skillID;
keepBonus = !getSingleSkillValue(ptChar, STATS_ITEM_SINGLESKILL, skillID);
maxSkillLevel = D2GetSkillLevel(ptChar, ptSkill, 0);
skpoints = getskPoint(ptSkill);
if (skpoints == -1 || unassignSkillsPointsOneByOne)
{
D2SetSkillBaseLevel(ptChar, skillID, 0, keepBonus, __FILE__, __LINE__);
nbPoints += maxSkillLevel;
} else {
while (maxSkillLevel--)
{
D2SetSkillBaseLevel(ptChar, skillID, maxSkillLevel, keepBonus, __FILE__, __LINE__);
nbPoints += D2GetSkillCost(ptChar, skpoints, skillID, maxSkillLevel);
}
}
D2SetSkillBaseLevelOnClient(ptClient, ptChar, skillID, 0, keepBonus);
}
ptSkill = ptSkill->ptNextSkill;
}
// Add new free skill points
D2AddPlayerStat( ptChar, STATS_NEWSKILLS, nbPoints, 0 );
}
void Install_SkillsPoints()
{
static int isInstalled = false;
if (isInstalled) return;
Install_InterfaceSkills();
Install_UpdateServer();
if ( version_D2Common >= V110 )
{
getskPoint = getskPoint_11X;
getCharClass = getCharClass_11X;
getSingleSkillValue = D2GetPlayerStat;
} else {
getskPoint = getskPoint_109;
getCharClass = getCharClass_109;
getSingleSkillValue = getSingleSkillValue_109;
}
isInstalled = true;
}
/*================================= END OF FILE =================================*/

50
PlugY/StatPerLevelUp.cpp Normal file
View File

@ -0,0 +1,50 @@
/*=================================================================
File created by Yohann NICOLAS.
Change Stat win per level up.
=================================================================*/
#include "statPerLevelUp.h"
#include "common.h"
#include "error.h"
#include "d2functions.h"
bool active_StatPerLevelUpChange=0;
DWORD statPerLevelUp=5;
FCT_ASM ( caller_changeStatPerLevelUp_111 )
MOV EAX,statPerLevelUp
IMUL EAX,EBX
MOV DWORD PTR SS:[ESP+0xC], EAX
JMP V2AddPlayerStat
}}
FCT_ASM ( caller_changeStatPerLevelUp )
MOV EAX,statPerLevelUp
IMUL EAX,EDI
MOV DWORD PTR SS:[ESP+0xC], EAX
JMP V2AddPlayerStat
}}
void Install_StatPerLevelUp()
{
static int isInstalled = false;
if (isInstalled) return;
log_msg("Patch D2Game for change Stat points win per level up. (StatPerLevelUp)\n");
mem_seek R7(D2Game, 42258, 42648, 4ED55, D7ADA, 7968A, AA44A, EB1DA);
MEMJ_REF4( V2AddPlayerStat, version_D2Game >= V111 ? caller_changeStatPerLevelUp_111 : caller_changeStatPerLevelUp);
//6FC7ED54 |. E8 61CB0900 CALL <JMP.&D2Common.#10518>
//02057AD9 |. E8 AA28F3FF CALL <JMP.&D2Common.#10109>
//01FE9689 |. E8 260DF9FF CALL <JMP.&D2Common.#10627>
//6FCCA449 |. E8 6A01F6FF CALL <JMP.&D2Common.#10762>
//6FD0B1D9 |. E8 F4F2F1FF CALL <JMP.&D2Common.#10551>
log_msg("\n");
isInstalled = true;
}
/*================================= END OF FILE =================================*/

494
PlugY/StatsPoints.cpp Normal file
View File

@ -0,0 +1,494 @@
/*=================================================================
File created by Yohann NICOLAS.
Unassign Stats Point for futher re-assignment.
=================================================================*/
#include "common.h"
#include "error.h"
#include "d2functions.h"
#include "plugYFiles.h" // Install_PlugYImagesFiles()
#include "interface_Stats.h" // Install_InterfaceStats()
#include "updateServer.h"
#include <stdio.h>
bool active_StatsPoints=0;
DWORD keyUsedForUnassignStatPoint=VK_CONTROL;
bool active_StatsShiftClickLimit=1;
DWORD limitValueToShiftClick=5;
void UnassignStr(Unit* ptChar, int nb)
{
log_msg("Start Unassign Strengh\n");
int currentStr, removePtsNb;
CharStatsBIN* charStats = D2GetCharStatsBIN(ptChar->nPlayerClass);
currentStr = D2GetPlayerBaseStat( ptChar, STATS_STRENGTH, 0 );
if (currentStr <= charStats->baseSTR) return;
removePtsNb = currentStr - charStats->baseSTR >= nb ? nb : currentStr - charStats->baseSTR;
if (currentStr - removePtsNb < 1) removePtsNb = currentStr - 1;
log_msg("Start Unassign Strengh (cur %d, base %d, rem %d)\n",currentStr,charStats->baseSTR,removePtsNb);
D2AddPlayerStat( ptChar, STATS_STRENGTH, -removePtsNb ,0 );
D2AddPlayerStat( ptChar, STATS_STATPTS, removePtsNb ,0 );
}
void UnassignDex(Unit* ptChar, int nb)
{
log_msg("Start Unassign Dexterity\n");
int currentDex, removePtsNb;
CharStatsBIN* charStats = D2GetCharStatsBIN(ptChar->nPlayerClass);
currentDex = D2GetPlayerBaseStat( ptChar, STATS_DEXTERITY, 0 );
if (currentDex <= charStats->baseDEX) return;
removePtsNb = currentDex - charStats->baseDEX >= nb ? nb : currentDex - charStats->baseDEX;
if (currentDex - removePtsNb < 1) removePtsNb = currentDex - 1;
log_msg("Start Unassign Dexterity (cur %d, base %d, rem %d)\n",currentDex,charStats->baseDEX,removePtsNb);
D2AddPlayerStat( ptChar, STATS_DEXTERITY, -removePtsNb ,0 );
D2AddPlayerStat( ptChar, STATS_STATPTS, removePtsNb ,0 );
}
void UnassignVit(Unit* ptChar, int nb)
{
log_msg("Start Unassign Vitality\n");
int currentVit, removePtsNb, removeVitNb, removeStaNb;
CharStatsBIN* charStats = D2GetCharStatsBIN(ptChar->nPlayerClass);
currentVit = D2GetPlayerBaseStat( ptChar, STATS_VITALITY, 0 );
if (currentVit <= charStats->baseVIT) return;
removePtsNb = currentVit - charStats->baseVIT >= nb ? nb : currentVit - charStats->baseVIT;
if (currentVit - removePtsNb < 1) removePtsNb = currentVit - 1;
removeVitNb = removePtsNb * (charStats->lifePerVitality << 6);
removeStaNb = removePtsNb * (charStats->staminaPerVitality << 6);
log_msg("Start Unassign Vitality (cur %d, base %d, rem %d)\n",currentVit,charStats->baseVIT,removePtsNb);
D2AddPlayerStat( ptChar, STATS_VITALITY, -removePtsNb ,0 );
D2AddPlayerStat( ptChar, STATS_MAXHP, -removeVitNb ,0 );
D2AddPlayerStat( ptChar, STATS_MAXSTAMINA, -removeStaNb ,0 );
D2AddPlayerStat( ptChar, STATS_STATPTS, removePtsNb ,0 );
}
void UnassignEne(Unit* ptChar, int nb)
{
log_msg("Start Unassign Energy\n");
int currentEne, removePtsNb, removeManNb;
CharStatsBIN* charStats = D2GetCharStatsBIN(ptChar->nPlayerClass);
currentEne = D2GetPlayerBaseStat( ptChar, STATS_ENERGY, 0);
if (currentEne <= charStats->baseENE) return;
removePtsNb = currentEne - charStats->baseENE >= nb ? nb : currentEne - charStats->baseENE;
if (currentEne - removePtsNb < 1) removePtsNb = currentEne - 1;
removeManNb = removePtsNb * (charStats->manaPerMagic << 6);
log_msg("Start Unassign Energy (cur %d, base %d, rem %d)\n",currentEne,charStats->baseENE,removePtsNb);
D2AddPlayerStat( ptChar, STATS_ENERGY, -removePtsNb ,0 );
D2AddPlayerStat( ptChar, STATS_MAXMANA, -removeManNb ,0 );
D2AddPlayerStat( ptChar, STATS_STATPTS, removePtsNb ,0 );
}
void UnassignStrPoint(Unit* ptChar)
{
UnassignStr(ptChar, 1);
}
void UnassignStrPoints(Unit* ptChar)
{
UnassignStr(ptChar, active_StatsShiftClickLimit ? limitValueToShiftClick: 0x7FFFFFFF);
}
void UnassignDexPoint(Unit* ptChar)
{
UnassignDex(ptChar, 1);
}
void UnassignDexPoints(Unit* ptChar)
{
UnassignDex(ptChar, active_StatsShiftClickLimit ? limitValueToShiftClick: 0x7FFFFFFF);
}
void UnassignVitPoint(Unit* ptChar)
{
UnassignVit(ptChar, 1);
}
void UnassignVitPoints(Unit* ptChar)
{
UnassignVit(ptChar, active_StatsShiftClickLimit ? limitValueToShiftClick: 0x7FFFFFFF);
}
void UnassignEnePoint(Unit* ptChar)
{
UnassignEne(ptChar, 1);
}
void UnassignEnePoints(Unit* ptChar)
{
UnassignEne(ptChar, active_StatsShiftClickLimit ? limitValueToShiftClick: 0x7FFFFFFF);
}
//////////////////////////////////
void STDCALL printDisabledStatsBtn(WORD statID, sDrawImageInfo* data, DWORD x, DWORD y, DWORD p4, DWORD p5, DWORD p6)
{
if ( onRealm || !D2isLODGame())
{
D2PrintImage(data,x,y,p4,p5,p6);
return;
}
Unit* ptChar = D2GetClientPlayer();
CharStatsBIN* charStats = D2GetCharStatsBIN(ptChar->nPlayerClass);
int minValue=1;
switch (statID)
{
case STATS_STRENGTH: minValue = charStats->baseSTR; break;
case STATS_DEXTERITY: minValue = charStats->baseDEX; break;
case STATS_VITALITY: minValue = charStats->baseVIT; break;
case STATS_ENERGY: minValue = charStats->baseENE; break;
}
int statValue = D2GetPlayerBaseStat(ptChar, statID, 0);
if (isOnRect(D2GetMouseX(),D2GetMouseY(),x+5,y+5,32,32))
{
WCHAR text[100];
if (active_StatsShiftClickLimit)
swprintf(text, getTranslatedString(STR_STATS_UNASSIGN_WITH_LIMIT),limitValueToShiftClick);
else
swprintf(text, getTranslatedString(STR_STATS_UNASSIGN_WITHOUT_LIMIT));
wcscat(text,L"\n");
swprintf(text+wcslen(text), getTranslatedString(STR_STATS_BASE_MIN), statValue, minValue);
D2SetFont(1);
D2PrintPopup(text, x+18, y-32, WHITE, 1);
}
if ( GetKeyState(keyUsedForUnassignStatPoint) >= 0) {
if ( D2GetPlayerBaseStat(ptChar, 4, 0) <= 0)
setFrame(data, 2);
} else {
setImage(data, unassignStatsBtnImages);
if (minValue >= statValue)
setFrame(data, 2);
}
D2PrintImage(data,x,y,p4,p5,p6);
}
FCT_ASM ( caller_printUnassignStatsBtn )
POP EAX
XOR ECX,ECX
MOV CX,WORD PTR DS:[ESI+8]
PUSH ECX
PUSH EAX
JMP printDisabledStatsBtn
}}
BYTE currentMsgID=0;
WORD UnassignStats()
{
if (onRealm || !D2isLODGame()) return 0;
return GetKeyState(keyUsedForUnassignStatPoint);
}
FCT_ASM ( caller_UnassignStats_9 )
PUSH EAX
CALL UnassignStats
TEST AX,AX
POP EAX
JNL NOT_CTRL
MOV currentMsgID,0x10
TEST AX,AX
JNL NOT_SHIFT
ADD currentMsgID,4
NOT_SHIFT:
MOV EAX,1
MOV ESI,EAX
RETN
NOT_CTRL:
MOV currentMsgID,0
TEST AX,AX
MOV EAX,1
RETN
}}
FCT_ASM ( caller_UnassignStats )
PUSH EAX
CALL UnassignStats
TEST AX,AX
POP EAX
JNL NOT_CTRL
MOV currentMsgID,0x10
TEST AX,AX
JNL NOT_SHIFT
ADD currentMsgID,4
NOT_SHIFT:
MOV ESI,1
ADD DWORD PTR SS:[ESP],0xB
RETN
NOT_CTRL:
MOV currentMsgID,0
TEST AX,AX
JNL END_UNASSGNSTATS
ADD DWORD PTR SS:[ESP],0x7
END_UNASSGNSTATS:
RETN
}}
FCT_ASM ( caller_setValue_111 )
ADD CL,currentMsgID
MOV WORD PTR SS:[ESP+0x19],CX
RETN
}}
FCT_ASM ( caller_setValue )
ADD DL,currentMsgID
JMP D2SendToServer3
}}
DWORD STDCALL pushDown (DWORD num)
{
Unit* ptChar = D2GetClientPlayer();
if ( !D2isLODGame() || GetKeyState(keyUsedForUnassignStatPoint) >= 0)//GetAsyncKeyState
{
if ( D2GetPlayerBaseStat(ptChar, 4, 0) > 0)
return 1;
} else {
CharStatsBIN* charStats = D2GetCharStatsBIN(ptChar->nPlayerClass);
switch (num)
{
case 0: if ((DWORD)charStats->baseSTR < (DWORD)D2GetPlayerBaseStat(ptChar, STATS_STRENGTH, 0))
return 1; break;
case 1: if ((DWORD)charStats->baseDEX < (DWORD)D2GetPlayerBaseStat(ptChar, STATS_DEXTERITY, 0))
return 1; break;
case 2: if ((DWORD)charStats->baseVIT < (DWORD)D2GetPlayerBaseStat(ptChar, STATS_VITALITY, 0))
return 1; break;
case 3: if ((DWORD)charStats->baseENE < (DWORD)D2GetPlayerBaseStat(ptChar, STATS_ENERGY, 0))
return 1; break;
}
}
return 0;
}
FCT_ASM ( caller_pushDown_111 )
PUSH EDX
PUSH EDX
CALL pushDown
POP EDX
TEST EAX,EAX
JNZ end_pushDown
SUB DWORD PTR SS:[ESP],0x22
RETN
end_pushDown:
MOV EDI,1
RETN
}}
FCT_ASM ( caller_pushDown )
PUSH EDX
PUSH EDX
CALL pushDown
POP EDX
TEST EAX,EAX
JNZ end_pushDown
SUB DWORD PTR SS:[ESP],0x22
RETN
end_pushDown:
LEA EAX,DWORD PTR DS:[EDX*8]
RETN
}}
void Install_StatsPoints()
{
static int isInstalled = false;
if (isInstalled) return;
Install_PlugYImagesFiles();
// Install_InterfaceStats();
Install_UpdateServer();
log_msg("Patch D2Client for unassign stat points when specified key is press. (StatsPoints)\n");
//if ( version_D2Client < V113 )
{
// Always print stat button images.
mem_seek R7(D2Client, 29B12, 29B02, 30073, 82BBA, 8963A, 6B59A, BD1B5);
memt_byte( 0x8B, 0xEB ); // JMP SHORT D2Client.6FAD0088
memt_byte( 0x4C, V7(D2Client, 12, 12, 13, 13, 13, 13, 13) );
memt_byte( 0x24, 0x90 ); // NOP
memt_byte( V7(D2Client, 20, 20, 14, 1C, 1C, 1C, 1C), 0x90 ); // NOP (V109d:0x20 , V110:0x14
//6FAD0073 8B4C24 14 MOV ECX,DWORD PTR SS:[ESP+14]
//6FB32BBA > 8B4C24 1C MOV ECX,DWORD PTR SS:[ESP+1C]
//6FB3963A > 8B4C24 1C MOV ECX,DWORD PTR SS:[ESP+1C]
//6FB1B59A > 8B4C24 1C MOV ECX,DWORD PTR SS:[ESP+1C]
//6FB6D1B5 |> 8B4C24 1C MOV ECX,DWORD PTR SS:[ESP+1C]
//print our buttons
mem_seek R7(D2Client, 29B9D, 29B8D, 300FD, 82C54, 896D4, 6B637, BD23E);
MEMJ_REF4( D2PrintImage, caller_printUnassignStatsBtn);
//6FB32C53 . E8 82A3F8FF CALL <JMP.&D2gfx.#10047>
//6FB396D3 . E8 D238F8FF CALL <JMP.&D2gfx.#10044>
//6FB1B636 . E8 431AFAFF CALL <JMP.&D2gfx.#10024>
//6FB6D23D . E8 54FEF4FF CALL <JMP.&D2gfx.#10041>
// Always manage push down.
mem_seek R7(D2Client, 2AA7B, 2AA6B, 3134D, 827D9, 89259, 6B1B9, BCDD9);
memt_byte( 0x74, 0x90 ); // NOP
memt_byte( 0x4E, 0x90 ); // NOP
//6FAD134D 74 4E JE SHORT D2Client.6FAD139D
//6FB327D9 . 74 4E JE SHORT D2Client.6FB32829
//6FB39259 . 74 4E JE SHORT D2Client.6FB392A9
//6FB1B1B9 74 4E JE SHORT D2Client.6FB1B209
//6FB6CDD9 . 74 4E JE SHORT D2Client.6FB6CE29
if ( version_D2Client >= V111 )
{
// On Push down.
mem_seek R7(D2Client, 2AAE6, 2AAD6, 313B8, 82844, 892C4, 6B224, BCE44);
memt_byte( 0x6B, 0xE8 );
MEMT_REF4( 0x01BF0ED2, caller_pushDown_111);
memt_byte( 0x00, 0x6B ); // IMUL EDX,EDX,0E
memt_byte( 0x00, 0xD2 );
memt_byte( 0x00, 0x0E );
//6FB32844 > 6BD2 0E IMUL EDX,EDX,0E
//6FB32847 . BF 01000000 MOV EDI,1
//6FB392C4 > 6BD2 0E IMUL EDX,EDX,0E
//6FB392C7 . BF 01000000 MOV EDI,1
//6FB1B224 6BD2 0E IMUL EDX,EDX,0E
//6FB1B227 BF 01000000 MOV EDI,1
//6FB6CE44 > 6BD2 0E IMUL EDX,EDX,0E
//6FB6CE47 . BF 01000000 MOV EDI,1
} else {
// On Push down.
mem_seek R7(D2Client, 2AAE6, 2AAD6, 313B8, 82844, 892C4, 0000, 0000);
memt_byte( 0x8D, 0xE8 ); // CALL
MEMT_REF4( 0x0000D504, caller_pushDown);
memt_byte( 0x00, 0x90 ); // NOP
memt_byte( 0x00, 0x90 ); // NOP
//6FAD13B8 8D04D5 00000000 LEA EAX,DWORD PTR DS:[EDX*8]
}
if ( version_D2Client >= V110 )
{
// Always manage push up.
mem_seek R7(D2Client, 0000, 0000, 3152E, 83869, 8A2E9, 6C249, BDE49);
memt_byte( 0x74, 0x90 ); // NOP
memt_byte( version_D2Client >= V111 ? 0x65 : 0x68, 0x90 ); // NOP
//6FAD152E 74 68 JE SHORT D2Client.6FAD1598
//6FB33869 . 74 65 JE SHORT D2Client.6FB338D0
//6FB3A2E9 . 74 65 JE SHORT D2Client.6FB3A350
//6FB1C249 74 65 JE SHORT D2Client.6FB1C2B0
//6FB6DE49 . 74 65 JE SHORT D2Client.6FB6DEB0
// Unassign stats point when ctrl is push.
mem_seek R7(D2Client, 0000, 0000, 315D3, 8391B, 8A39B, 6C2FB, BDEFB);
memt_byte( 0x66, 0xE8 ); // CALL
MEMT_REF4( 0x077CC085, caller_UnassignStats);
//6FAD15D3 . 66:85C0 TEST AX,AX
//6FAD15D6 . 7C 07 JL SHORT D2Client.6FAD15DF
//6FB3391B . 66:85C0 TEST AX,AX
//6FB3391E . 7C 07 JL SHORT D2Client.6FB33927
//6FB3A39B . 66:85C0 TEST AX,AX
//6FB3A39E . 7C 07 JL SHORT D2Client.6FB3A3A7
//6FB1C2FB . 66:85C0 TEST AX,AX
//6FB1C2FE . 7C 07 JL SHORT D2Client.6FB1C307
//6FB6DEFB . 66:85C0 TEST AX,AX
//6FB6DEFE . 7C 07 JL SHORT D2Client.6FB6DF07
} else {
// Always manage push up.
mem_seek R7(D2Client, 2AC55, 2AC45, 0000, 0000, 0000, 0000, 0000);
memt_byte( 0x0F, 0x90 ); // NOP
memt_byte( 0x84, 0x90 ); // NOP
memt_dword( 0x000000AE, 0x90909090 ); // NOP NOP NOP NOP
//6FACAC45 . 0F84 AE000000 JE D2Client.6FACACF9
// Unassign stats point when ctrl is push.
mem_seek R7(D2Client, 2ACD9, 2ACC9, 0000, 0000, 0000, 0000, 0000);
memt_byte( 0xB8, 0xE8 ); // CALL
MEMT_REF4( 0x00000001, caller_UnassignStats_9);
//6FACACC9 . B8 01000000 MOV EAX,1
}
// Set the id for the calling function.
mem_seek R7(D2Client, 2AD02, 2ACF2, 31611, 8395E, 8A3DE, 6C33E, BDF3E);
if ( version_D2Client >= V111 ) {
memt_byte( 0x66, 0xE8 ); // CALL
MEMT_REF4( 0x15244C89, caller_setValue_111);
//6FB3395E . 66:894C24 15 MOV WORD PTR SS:[ESP+15],CX
//6FB3A3DE . 66:894C24 15 MOV WORD PTR SS:[ESP+15],CX
//6FB1C33E . 66:894C24 15 MOV WORD PTR SS:[ESP+15],CX ; |
//6FB6DF3E . 66:894C24 15 MOV WORD PTR SS:[ESP+15],CX ; |
} else {
MEMC_REF4( D2SendToServer3, caller_setValue);
//6FAD1610 . E8 7BC3FDFF CALL D2Client.6FAAD990
}
} log_msg("\n");
isInstalled = true;
}
/*********************************************************************************/
FCT_ASM ( caller_LimitShift_111 )
CMP EDI,limitValueToShiftClick
JL DontTruncTheValue
MOV EDI,limitValueToShiftClick
DontTruncTheValue:
JMP DWORD PTR DS:[GetKeyState]
}}
FCT_ASM ( caller_LimitShift )
CMP ESI,limitValueToShiftClick
JL DontTruncTheValue
MOV ESI,limitValueToShiftClick
DontTruncTheValue:
JMP DWORD PTR DS:[GetKeyState]
}}
void Install_StatsLimitShiftClick()
{
static int isInstalled = false;
if (isInstalled) return;
log_msg("Patch D2Client for limit the assigment of stat points when shift is used. (LimitShift)\n");
// Limit the assigment of stat points.
mem_seek R7(D2Client, 2ACD0, 2ACC0, 315CD, 83915, 8A395, 6C2F5, BDEF5);
memt_byte( 0xFF, 0x90 ); // NOP
memt_byte( 0x15, 0xE8 ); // CALL
MEMD_REF4( GetKeyState, version_D2Client >= V111 ? caller_LimitShift_111 : caller_LimitShift);
//6FAD15CD . FF15 68E0B66F CALL DWORD PTR DS:[<&USER32.GetKeyState>]
//6FB33915 . FF15 CCF0B76F CALL DWORD PTR DS:[<&USER32.GetKeyState>]
//6FB3A395 . FF15 08F1B76F CALL DWORD PTR DS:[<&USER32.GetKeyState>]
//6FB1C2F5 . FF15 10F1B76F CALL DWORD PTR DS:[<&USER32.GetKeyState>>; \GetKeyState
//6FB6DEF5 . FF15 04F1B76F CALL DWORD PTR DS:[<&USER32.GetKeyState>>; \GetKeyState
log_msg("\n");
isInstalled = true;
}
/*================================= END OF FILE =================================*/

401
PlugY/UberQuest.cpp Normal file
View File

@ -0,0 +1,401 @@
/*=================================================================
File created by Yohann NICOLAS.
Uber Quest Management.
=================================================================*/
#include "common.h"
#include "error.h"
#include "d2functions.h"
bool active_UberQuest=0;
/*
void* ptQuest = D2GetPlayerData(ptChar)->ptQuest[ptGame->difficultyLevel];
if (D2CheckQuestState(ptGame->game10F4[0xC],4,0xB) ||
D2CheckQuestState(ptQuest,4,0xA) ||
ptGame->ptIsLodGame && !D2CheckQuestState(ptQuest,0x28,0)
// !ptGame->ptIsLodGame && D2CheckQuestState(ptQuest,0x1A,0)TODO for !ptGame->ptIsLodGame...
{
// d2_assert(!ptChar,"openPandPortal : ptChar==NULL",__FILE__,__LINE__);
// ptChar->v6E = 0x14;
// ptChar->v70 = ptChar;
// D2Common10148(ptChar);
// ptChar->flag400 = 1;
// return 0;
}
Room* = ptRoom = D2GetRoom(ptChar);
if (D2GetLevelID(ptRoom) != 1) return 0;
Position pos1;
D2GetPosition(ptChar, &pos1);
void* ptPortal = NULL;
D2Game02059FE0(ptRoom,&pos1,3,0x400,&ptPortal,0x64);
if (!ptPortal) return 0;
Position pos2;
pos2.x = pos1.x;
pos2.y = pos1.y;
testing crash useless...
D2GetDropRoom(ptRoom, &pos2, &pos2,3,0x3E01,0xC01,0);
*/
/*
void* FASTCALL D2Game01F81090(Room* ptRoom, DWORD x, DWORD y);//0x1090
*/
#define OBJECT_PERMANENT_PORTAL 0x3C
#define LEVEL_ACT5TOWN 109
#define LEVEL_ACT5_PANDEMONIUM1 133
#define LEVEL_ACT5_PANDEMONIUM2 134
#define LEVEL_ACT5_PANDEMONIUM3 135
#define LEVEL_ACT5_PANDEMONIUM_FINAL 136
static struct
{
union{
DWORD all;
struct{
DWORD portal1Opened:1;
DWORD portal2Opened:1;
DWORD portal3Opened:1;
DWORD portal4Opened:1;
DWORD uber1Spawned:1;
DWORD uber2Spawned:1;
DWORD uber3Spawned:1;
DWORD uber4Spawned:1;
DWORD uber5Spawned:1;
DWORD uber6Spawned:1;
};
};
int count1;
int count2;
int count3;
int count4;
int count5;
int count6;
Room* room1;
Room* room2;
Room* room3;
Room* room4;
Room* room5;
Room* room6;
} questState;
void resetQuestState()
{
ZeroMemory(&questState,sizeof(questState));
questState.count1 = 10 + RANDOM(10);
questState.count2 = 20 + RANDOM(40);
questState.count3 = 10 + RANDOM(20);
int value = 5 + RANDOM(10);
questState.count4 = value + RANDOM(4);
questState.count5 = value + RANDOM(4);
questState.count6 = value + RANDOM(4);
log_msg("Uber Quest State : %d %d %d %d %d %d\n",questState.count1, questState.count2, questState.count3, questState.count4, questState.count5, questState.count6);
}
DWORD openPortalOnLevel(Game* ptGame, Unit* ptChar, DWORD levelID)
{
log_msg("openning portal to level %d\n",levelID);
Room* ptRoom = D2GetRoom(ptChar);
if ( D2GetLevelID(ptRoom) != LEVEL_ACT5TOWN ) return 0;
//Get position in the room
Position pos;
D2GetPosition(ptChar, &pos);
if (!D2GetDropRoom(ptRoom, &pos, &pos, 3, 0x3E01, 0xC01, 0)) return 0;
ptRoom = D2TestPositionInRoom(ptRoom, pos.x, pos.y);
if (!ptRoom) return 0;
// Create Portal
Unit* ptPortal = D2CreateUnit(UNIT_OBJECT, OBJECT_PERMANENT_PORTAL, pos.x, pos.y, ptGame, ptRoom, 1, 1, 0);
ptPortal->ptObjectData->levelID = (BYTE)levelID;
D2Common10572(ptPortal, 1);
D2LinkPortal(ptGame, ptPortal, levelID, LEVEL_ACT5TOWN);
D2SetObjectFlags(ptPortal, D2GetObjectFlags(ptPortal) | 3);
D2Common11084(ptRoom, 0);
D2Common11084(D2GetRoom(ptPortal), 0);
return 1;
}
DWORD FASTCALL openPandPortal(Game* ptGame, Unit* ptChar)
{
log_msg("openPandPortal\n");
Position pos;
D2GetPosition(ptChar, &pos);
log_msg("ptChar pos : %d %d\n",pos.x,pos.y);
if (ptGame->difficultyLevel != D2DM_HELL) return 0;
int available[3];
int nbAvailable=0;
if (!questState.portal1Opened) available[nbAvailable++]=LEVEL_ACT5_PANDEMONIUM1;
if (!questState.portal2Opened) available[nbAvailable++]=LEVEL_ACT5_PANDEMONIUM2;
if (!questState.portal3Opened) available[nbAvailable++]=LEVEL_ACT5_PANDEMONIUM3;
int selectedTargetLevel;
if (nbAvailable)
selectedTargetLevel = available[RANDOM(nbAvailable)];
else selectedTargetLevel = LEVEL_ACT5_PANDEMONIUM1 + RANDOM(3);
int ret = openPortalOnLevel(ptGame, ptChar, selectedTargetLevel);
if (ret)
{
if (selectedTargetLevel == LEVEL_ACT5_PANDEMONIUM1) questState.portal1Opened = 1;
else if (selectedTargetLevel == LEVEL_ACT5_PANDEMONIUM2) questState.portal2Opened = 1;
else if (selectedTargetLevel == LEVEL_ACT5_PANDEMONIUM3) questState.portal3Opened = 1;
}
log_msg("openPandPortal ending\n\n");
return ret;//normally return ret;
}
DWORD FASTCALL openPandFinalPortal(Game* ptGame, Unit* ptChar)
{
log_msg("openPandFinalPortal\n");
Position pos;
D2GetPosition(ptChar, &pos);
log_msg("ptChar pos : %d %d",pos.x,pos.y);
int ret = openPortalOnLevel(ptGame, ptChar, LEVEL_ACT5_PANDEMONIUM_FINAL);
log_msg("openPandFinalPortal ending\n");
return ret;//normally return ret;
}
Room* selectRoom(Game* ptGame, Room* ptCurrentRoom, DWORD level)
{
/* Room* tab[200];
nbRoom=0;
Room* ptRoom = ptGame->mapAct[5]->ptFirstRoom;
while (ptRoom);
if(!ptCurrentRoom->nbNearRooms) return ptCurrentRoom;
int targetRoomNum = RANDOM(ptCurrentRoom->nbNearRooms);
Room* ptRoom = ptCurrentRoom->ptNearRooms;
while (targetRoomNum--)
ptRoom = ptRoom->ptNextRoom;*/
return ptCurrentRoom;
}
void STDCALL spawnUber(Game* ptGame, Room* ptRoom)
{
log_msg("Uber Quest State : %d %d %d %d %d %d\n",questState.count1, questState.count2, questState.count3, questState.count4, questState.count5, questState.count6);
switch(D2GetLevelID(ptRoom))
{
case LEVEL_ACT5_PANDEMONIUM1:
if (!questState.uber1Spawned)
{
if (questState.count1) questState.count1--;
else {
Room* ptTargetRoom = selectRoom(ptGame, ptRoom, LEVEL_ACT5_PANDEMONIUM1);
if (D2SpawnMonster(ptGame, ptTargetRoom, 0, 0, 0, -1, 707, 0))
questState.uber1Spawned = 1;
}
}
break;
case LEVEL_ACT5_PANDEMONIUM2:
if (!questState.uber2Spawned)
{
if (questState.count2) questState.count2--;
else {
Room* ptTargetRoom = selectRoom(ptGame, ptRoom, LEVEL_ACT5_PANDEMONIUM1);
if (D2SpawnMonster(ptGame, ptTargetRoom, 0, 0, 0, -1, 708, 0))
questState.uber2Spawned = 1;
}
}
break;
case LEVEL_ACT5_PANDEMONIUM3:
if (!questState.uber3Spawned)
{
if (questState.count3) questState.count3--;
else {
Room* ptTargetRoom = selectRoom(ptGame, ptRoom, LEVEL_ACT5_PANDEMONIUM1);
if (D2SpawnMonster(ptGame, ptTargetRoom, 0, 0, 0, -1, 706, 0))
questState.uber3Spawned = 1;
}
}
break;
case LEVEL_ACT5_PANDEMONIUM_FINAL:
if (!questState.uber4Spawned)
{
if (questState.count4) questState.count4--;
else {
Room* ptTargetRoom = selectRoom(ptGame, ptRoom, LEVEL_ACT5_PANDEMONIUM1);
if (D2SpawnMonster(ptGame, ptTargetRoom, 0, 0, 0, -1, 704, 0))
questState.uber4Spawned = 1;
}
}
if (!questState.uber5Spawned)
{
if (questState.count5) questState.count5--;
else {
Room* ptTargetRoom = selectRoom(ptGame, ptRoom, LEVEL_ACT5_PANDEMONIUM1);
if (D2SpawnMonster(ptGame, ptTargetRoom, 0, 0, 0, -1, 705, 0))
questState.uber5Spawned = 1;
}
}
if (!questState.uber6Spawned)
{
if (questState.count6) questState.count6--;
else {
Room* ptTargetRoom = selectRoom(ptGame, ptRoom, LEVEL_ACT5_PANDEMONIUM1);
if (D2SpawnMonster(ptGame, ptTargetRoom, 0, 0, 0, -1, 709, 0))
questState.uber6Spawned = 1;
}
}
// D2SpawnMonster(PCGame, ptRoom, 0, 25113, 5138, -1, 704, 0);
// D2SpawnMonster(PCGame, ptRoom, 0, 25125, 5150, -1, 705, 0);
// D2SpawnMonster(PCGame, ptRoom, 0, 25135, 5140, -1, 709, 0);
}
D2Game235C0(ptGame, ptRoom);
}
/*DWORD STDCALL spawnUber(Path* ptPath, Unit* ptChar, Room* ptRoom, DWORD x, DWORD y)
{
if (!D2WarpPlayer(ptPath, ptChar, ptRoom, x, y)) return 0;
switch(D2GetLevelID(ptRoom))
{
case LEVEL_ACT5_PANDEMONIUM1:
if (!questState.uber1Spawned)
{
Room* ptTargetRoom = selectRoom(PCGame, ptRoom, LEVEL_ACT5_PANDEMONIUM1);
D2SpawnMonster(PCGame, ptTargetRoom, 0, 0, 0, -1, 707, 0);
questState.uber1Spawned = 1;
}
break;
case LEVEL_ACT5_PANDEMONIUM2:
if (!questState.uber2Spawned)
{
Room* ptTargetRoom = selectRoom(PCGame, ptRoom, LEVEL_ACT5_PANDEMONIUM1);
D2SpawnMonster(PCGame, ptTargetRoom, 0, 0, 0, -1, 708, 0);
questState.uber2Spawned = 1;
}
break;
case LEVEL_ACT5_PANDEMONIUM3:
if (!questState.uber3Spawned)
{
Room* ptTargetRoom = selectRoom(PCGame, ptRoom, LEVEL_ACT5_PANDEMONIUM1);
D2SpawnMonster(PCGame, ptTargetRoom, 0, 0, 0, -1, 706, 0);
questState.uber3Spawned = 1;
}
break;
case LEVEL_ACT5_PANDEMONIUM_FINAL:
if (!questState.uber4Spawned)
{
Room* ptTargetRoom = selectRoom(PCGame, ptRoom, LEVEL_ACT5_PANDEMONIUM1);
D2SpawnMonster(PCGame, ptTargetRoom, 0, 0, 0, -1, 704, 0);
ptTargetRoom = selectRoom(PCGame, ptRoom, LEVEL_ACT5_PANDEMONIUM1);
D2SpawnMonster(PCGame, ptTargetRoom, 0, 0, 0, -1, 705, 0);
ptTargetRoom = selectRoom(PCGame, ptRoom, LEVEL_ACT5_PANDEMONIUM1);
D2SpawnMonster(PCGame, ptTargetRoom, 0, 0, 0, -1, 709, 0);
// D2SpawnMonster(PCGame, ptRoom, 0, 25113, 5138, -1, 704, 0);
// D2SpawnMonster(PCGame, ptRoom, 0, 25125, 5150, -1, 705, 0);
// D2SpawnMonster(PCGame, ptRoom, 0, 25135, 5140, -1, 709, 0);
questState.uber4Spawned = 1;
}
}
return 1;
}
*/
void FASTCALL uberMephIA(Game* ptGame, Unit* ptMonster, DWORD* ptData)
{
D2MephIA(ptGame, ptMonster, ptData);
}
void FASTCALL uberDiabloIA(Game* ptGame, Unit* ptMonster, DWORD* ptData)
{
D2DiabloIA(ptGame, ptMonster, ptData);
}
void FASTCALL uberBaalIA(Game* ptGame, Unit* ptMonster, DWORD* ptData)
{
D2BaalIA(ptGame, ptMonster, ptData);
}
void Install_UberQuest()
{
static int isInstalled = false;
if (isInstalled) return;
if ( version_D2Game <= V110 )
return;
log_msg("Patch D2Game for active Uber Quest. (UberQuest)\n");
DWORD oldProtection;
// open Red Portal
VirtualProtect((LPVOID)R7(D2Game,0,0,0,FA480,FA7B8, FA228, FA5F0), 8, PAGE_EXECUTE_READWRITE, &oldProtection);
mem_seek R7(D2Game, 0000, 0000, 0000, FA480, FA7B8, FA228, FA5F0);
MEMT_DWORD( D2OpenPandPortal , openPandPortal);
MEMT_DWORD( D2OpenPandFinalPortal , openPandFinalPortal);
//0201E357 |. FFD0 |CALL EAX
//01FA77E7 |. FFD0 |CALL EAX
//6FCF3CC7 |. FFD0 |CALL EAX
//6FC92437 |. FFD0 |CALL EAX
VirtualProtect((LPVOID)R7(D2Game,0,0,0,FA480,FA7B8, FA228, FA5F0), 8, oldProtection, &oldProtection);
// manage uberIA (fct table at 0209E7E8)
VirtualProtect((LPVOID)(R7(D2Game,0,0,0,10E7E8,10ECD0,10EF58,10E788) + 145*0x10), 0x30, PAGE_EXECUTE_READWRITE, &oldProtection);
mem_seek R7(D2Game, 0000, 0000, 0000, 10F100, 10F5E8, 10F870, 10F0A0);
MEMT_DWORD( D2UberBaalIA , uberBaalIA);
mem_seek R7(D2Game, 0000, 0000, 0000, 10F110, 10F5F8, 10F880, 10F0B0);
MEMT_DWORD( D2UberMephIA , uberMephIA);
mem_seek R7(D2Game, 0000, 0000, 0000, 10F120, 10F608, 10F890, 10F0C0);
MEMT_DWORD( D2UberDiabloIA , uberDiabloIA);
VirtualProtect((LPVOID)(R7(D2Game,0,0,0,10E7E8,10ECD0,10EF58,10E788) + 145*0x10), 0x30, oldProtection, &oldProtection);
//0202ADA7 |> B8 E8E70902 MOV EAX,D2Game.0209E7E8
//01FD2BE7 |> B8 D0EC0702 MOV EAX,D2Game.0207ECD0
//6FC3B597 |> B8 58EFD26F MOV EAX,D2Game.6FD2EF58
//6FCBD157 |> B8 88E7D26F MOV EAX,D2Game.6FD2E788
// spawn Uber
// mem_seek R7(D2Game, 0000, 0000, 0000, 98DAD, 0000, 0000, 0000);
// MEMJ_REF4( D2WarpPlayer , spawnUber);
//02028DAC |. E8 491CF7FF CALL <JMP.&D2Common.#10872>
mem_seek R7(D2Game, 0000, 0000, 0000, E26E2, E6B52, A850B, 2CCAB);
MEMC_REF4( D2Game235C0 , spawnUber);
//020726E1 |. E8 2A46FFFF ||CALL D2Game.02066D10
//02056B51 |. E8 6ACAF3FF ||CALL D2Game.01F935C0
//6FCC850A |. E8 014FF6FF ||CALL D2Game.6FC2D410
//6FC4CCAA |. E8 3134FFFF ||CALL D2Game.6FC400E0
log_msg("\n");
isInstalled = true;
}
/*
call fct to manage TP :
0201E33E |. 8B048D 78A4070>|MOV EAX,DWORD PTR DS:[ECX*4+207A478] ; D2Game.0201B480
0201E345 |. 85C0 |TEST EAX,EAX
0201E347 |. 74 14 |JE SHORT D2Game.0201E35D
0201E349 |. 8B9424 2C01000>|MOV EDX,DWORD PTR SS:[ESP+12C]
0201E350 |. 8B8C24 2801000>|MOV ECX,DWORD PTR SS:[ESP+128]
0201E357 |. FFD0 |CALL EAX
0201E359 |. 894424 38 |MOV DWORD PTR SS:[ESP+38],EAX
DWORD FASTCALL openPortal (Unit* ptGame, Unit* ptChar)
0201C6D0 : CowPortal
0201B480 : Pand. Portal return 0 !!
0201B470 : Pand. FInal Portal
manage IA
0202AD8B |> 66:8B46 1E MOV AX,WORD PTR DS:[ESI+1E]
0202AD8F |. 66:85C0 TEST AX,AX
0202AD92 |. 7C 13 JL SHORT D2Game.0202ADA7
0202AD94 |. 66:3D 9400 CMP AX,94
0202AD98 |. 73 0D JNB SHORT D2Game.0202ADA7
0202AD9A |. 0FBFC0 MOVSX EAX,AX
0202AD9D |. C1E0 04 SHL EAX,4
0202ADA0 |. 05 E8E70902 ADD EAX,D2Game.0209E7E8
0202ADA5 |. 5E POP ESI
0202ADA6 |. C3 RETN
0202ADA7 |> B8 E8E70902 MOV EAX,D2Game.0209E7E8
0202ADAC |. 5E POP ESI
0202ADAD \. C3 RETN
*/
/*================================= END OF FILE =================================*/

90
PlugY/UpdateClient.cpp Normal file
View File

@ -0,0 +1,90 @@
/*=================================================================
File created by Yohann NICOLAS.
Updating client.
=================================================================*/
#include "common.h"
#include "updateClient.h"
#include "error.h"
#include "d2functions.h"
#include "infinityStash.h"
#include "commands.h"
void updateClient(Unit* ptChar, DWORD mFunc, DWORD p1, DWORD p2, DWORD p3)
{
void* ptNetClient;
DataPacket packet;
// Intialize the packet to send to client
ZeroMemory(&packet, sizeof(DataPacket));
packet.mType = 0x9D;
packet.mFunc = (BYTE)mFunc;
packet.mSize = sizeof(DataPacket);
packet.mPlayerID = ptChar->nUnitId;
packet.mParam1 = p1;
packet.mParam2 = p2;
packet.mParam3 = p3;
ptNetClient = D2GetClient( ptChar, __FILE__ , __LINE__);
// Send packet to client for remove placed skills
D2SendPacket(ptNetClient, &packet, sizeof(DataPacket));
}
DWORD FASTCALL handleClientUpdate(DataPacket* packet)
{
log_msg("[CLIENT] Received custom message: %d with param: %08X , %08X , %08X\n",packet->mFunc,packet->mParam1,packet->mParam2,packet->mParam3);
switch (packet->mFunc)
{
case UC_SELECT_STASH : setSelectedStashClient(packet->mParam1,packet->mParam2,packet->mParam3); return 1;
case UC_SHARED_GOLD : updateSharedGold(packet->mParam1); return 1;
default : return 0;
}
}
FCT_ASM ( caller_handleClientUpdate_111 )
LEA ECX,DWORD PTR SS:[ESP+8]
CALL handleClientUpdate
POP EDI
POP ESI
MOV ESP,EBP
POP EBP
RETN
}}
FCT_ASM ( caller_handleClientUpdate )
LEA ECX,DWORD PTR SS:[ESP]
CALL handleClientUpdate
ADD ESP,0x104
RETN
}}
void Install_UpdateClient()
{
static int isInstalled = false;
if (isInstalled) return;
log_msg("Patch D2Client for received Item packet. (UpdateClient)\n");
// execute if it's our packet else continue
mem_seek R7(D2Client, 14236, 14226, 145B6, 9C6B6, BFE86, 66E06, AE896);
MEMT_REF4( version_D2Client >= V111 ? 0x000000CF : 0x000000D6, version_D2Client >= V111 ? caller_handleClientUpdate_111 : caller_handleClientUpdate);
//6FAB45B4 |. 0F87 D6000000 JA D2Client.6FAB4690
//6FB4C6B4 |. 0F87 CF000000 JA D2Client.6FB4C789
//6FB6FE84 |. 0F87 CF000000 JA D2Client.6FB6FF59
//6FB16E04 |. 0F87 CF000000 JA D2Client.6FB16ED9
//6FB5E894 |. 0F87 CF000000 JA D2Client.6FB5E969
log_msg("\n");
isInstalled = true;
}
/*================================= END OF FILE =================================*/

138
PlugY/UpdateServer.cpp Normal file
View File

@ -0,0 +1,138 @@
/*=================================================================
File created by Yohann NICOLAS.
Updating server.
=================================================================*/
#include "common.h"
#include "updateServer.h"
#include "error.h"
#include "d2functions.h"
#include "statsPoints.h"
#include "skillsPoints.h"
#include "infinityStash.h"
#include "commands.h"
int STDCALL handleServerUpdate(Unit* ptChar, WORD param)
{
log_msg("Received custom message: %X\n", param);
switch(param & 0xFF)
{
case US_UNASSIGN_STR_POINT : UnassignStrPoint( ptChar ); return 1;
case US_UNASSIGN_ENE_POINT : UnassignEnePoint( ptChar ); return 1;
case US_UNASSIGN_DEX_POINT : UnassignDexPoint( ptChar ); return 1;
case US_UNASSIGN_VIT_POINT : UnassignVitPoint( ptChar ); return 1;
case US_UNASSIGN_STR_POINTS : UnassignStrPoints( ptChar ); return 1;
case US_UNASSIGN_ENE_POINTS : UnassignEnePoints( ptChar ); return 1;
case US_UNASSIGN_DEX_POINTS : UnassignDexPoints( ptChar ); return 1;
case US_UNASSIGN_VIT_POINTS : UnassignVitPoints( ptChar ); return 1;
case US_UNASSIGN_SKILLS : UnassignAllSkillsPoints( ptChar ); return 1;
case US_SELECT_PREVIOUS : selectPreviousStash( ptChar ); return 1;
case US_SELECT_NEXT : selectNextStash( ptChar ); return 1;
case US_SELECT_SELF : if (active_sharedStash) toggleToSelfStash( ptChar ); return 1;
case US_SELECT_SHARED : if (active_sharedStash) toggleToSharedStash( ptChar ); return 1;
case US_SELECT_PREVIOUS_INDEX : selectPreviousIndexStash( ptChar ); return 1;
case US_SELECT_NEXT_INDEX : selectNextIndexStash( ptChar ); return 1;
case US_SELECT_PREVIOUS2 : selectPrevious2Stash( ptChar ); return 1;
case US_SELECT_NEXT2 : selectNext2Stash( ptChar ); return 1;
case US_SELECT_PREVIOUS_INDEX2: selectPreviousIndex2Stash( ptChar ); return 1;
case US_SELECT_NEXT_INDEX2 : selectNextIndex2Stash( ptChar ); return 1;
case US_STARTSAVE : savePlayers( ptChar ); return 1;
case US_MAXGOLD : maxGold(ptChar); return 1;
case US_PUTGOLD : putGold(ptChar, 0); return 1;
case US_TAKEGOLD : takeGold(ptChar, 0); return 1;
default : return 0;
}
}
FCT_ASM( caller_handleServerUpdate)
PUSH EAX
PUSH EBX
CALL handleServerUpdate
TEST EAX,EAX
JNZ END_RCM
MOV EAX,ESI
AND EAX,0xFF
SHR ESI,8
MOV EDI,EAX
RETN
END_RCM:
ADD ESP,4
POP EDI
POP ESI
XOR EAX,EAX
POP EBX
RETN 8
}}
FCT_ASM( caller_handleServerUpdate_9)
XOR EDX,EDX
MOV DX,WORD PTR DS:[EAX+1]
PUSH ECX
PUSH EDX
PUSH EDX
PUSH ECX
CALL handleServerUpdate
POP EDX
POP ECX
TEST EAX,EAX
JNZ END_RCM
RETN
END_RCM:
POP EAX
XOR EAX,EAX
RETN 8
}}
void Install_UpdateServer()
{
static int isInstalled = false;
if (isInstalled) return;
log_msg("Patch D2Game for received button click message. (UpdateServer)\n");
// manage button click message from Client.
mem_seek R7(D2Game, 4A702, 4AAC2, 56EA2, 54AE3, 2C773, 975C3, CC983);
if (version_D2Game >= V111) {
memt_byte( 0xC1, 0x57 ); // PUSH EDI
memt_byte( 0xEE, 0xE8 ); // CALL caller_handleServerUpdate
MEMT_REF4( 0xF88B5708, caller_handleServerUpdate);
//01FD4AE3 . C1EE 08 SHR ESI,8
//01FD4AE6 . 57 PUSH EDI
//01FD4AE7 . 8BF8 MOV EDI,EAX
//01F9C773 . C1EE 08 SHR ESI,8
//01F9C776 . 57 PUSH EDI
//01F9C777 . 8BF8 MOV EDI,EAX
//6FCB75C3 . C1EE 08 SHR ESI,8
//6FCB75C6 . 57 PUSH EDI
//6FCB75C7 . 8BF8 MOV EDI,EAX
//6FCEC983 . C1EE 08 SHR ESI,8
//6FCEC986 . 57 PUSH EDI
//6FCEC987 . 8BF8 MOV EDI,EAX
} else if (version_D2Game == V110) {
memt_byte( 0xC1, 0xE8 ); // CALL caller_handleServerUpdate
MEMT_REF4( 0xF88B08EE, caller_handleServerUpdate);
//6FC86EA2 . C1EE 08 SHR ESI,8
//6FC86EA5 . 8BF8 MOV EDI,EAX
} else {
memt_byte( 0x33, 0xE8 ); // CALL caller_handleServerUpdate
MEMT_REF4( 0x508B66D2, caller_handleServerUpdate_9);
memt_byte( 0x01, 0x90 ); // NOP
//6FC7A702 . 33D2 XOR EDX,EDX
//6FC7A704 . 66:8B50 01 MOV DX,WORD PTR DS:[EAX+1]
}
log_msg("\n");
isInstalled = true;
}
/*================================= END OF FILE =================================*/

274
PlugY/WorldEvent.cpp Normal file
View File

@ -0,0 +1,274 @@
/*=================================================================
File created by Yohann NICOLAS.
World Event Management.
=================================================================*/
#include "common.h"
#include "error.h"
#include "d2functions.h"
#pragma pack(1)
struct s_WEdata
{
BYTE type;
BYTE fct;
BYTE id;
DWORD param;
WORD z;
BYTE uk[31];
};
#pragma pack()
bool active_WorldEvent=0;
DWORD WEactive = 0;
DWORD DCloneSpawned = 0;
DWORD nbSOJSold = 0;
DWORD nbNeedSOJSold = 100;
DWORD nbManagedSOJSold = 0;
DWORD nbTicksForNextSOJSold = 0;
DWORD prevTicks = 0;
DWORD showSOJSoldCounterInAllDiff=0;
char* itemsToSell="The Stone of Jordan";
DWORD worldEventmonsterID = 333;
DWORD valueOfOwnSOJSold=100;
DWORD valueInitSOJSoldMin=200;
DWORD valueInitSOJSoldDelta=2000;
DWORD triggerAtSolJSoldMin=75;
DWORD triggerAtSolJSoldDelta=51;
bool active_AutomaticSell=1;
DWORD timeBeforeAutoSellMin=00000;
DWORD timeBeforeAutoSellDelta=120000;
CubeInput itemNeeded;
DWORD getTicksForNextSOJSold()
{
return ((DWORD)(rand()/(RAND_MAX+1.0)*timeBeforeAutoSellDelta)+timeBeforeAutoSellMin);//average of +100 in 25hours max 41h40
}
void FASTCALL sendDataToClient(void* ptclient, DWORD* param)
{
D2SendPacket(ptclient, (void*)param[0], (DWORD)param[1]);
}
void STDCALL worldEventBroadcast(Game* ptGame, DWORD activeWE, DWORD nbSOJSold)
{
void* param[2];
s_WEdata data;
data.type = 0x5A;
data.fct = activeWE ? 0x12 : 0x11;
data.id = 4;
data.param = nbSOJSold;
data.z = 0;
param[0]=&data;
param[1]=(void*)sizeof(data);
D2BroadcastFunction(ptGame,&sendDataToClient,param);
}
Game* STDCALL WEManagement(DWORD clientID)
{
Game* ptGame = D2GetGameByClientID(clientID);
if (!ptGame) return ptGame;
if (active_AutomaticSell)
while (GetTickCount() - prevTicks >= nbTicksForNextSOJSold)
{
nbSOJSold++;
prevTicks = prevTicks + nbTicksForNextSOJSold;
nbTicksForNextSOJSold = getTicksForNextSOJSold();
}
if (nbSOJSold == nbManagedSOJSold) return ptGame;
DWORD newWE;
if (!WEactive && (ptGame->difficultyLevel == D2DM_HELL) && (nbSOJSold >= nbNeedSOJSold))
{
newWE = 1;
WEactive = 1;
} else newWE = 0;
if ( showSOJSoldCounterInAllDiff || (ptGame->difficultyLevel == D2DM_HELL))
worldEventBroadcast(ptGame, newWE, nbSOJSold);
nbManagedSOJSold = nbSOJSold;
return ptGame;
}
DWORD FASTCALL spawnDClone(Game* ptGame, Room* ptRoom, DWORD p3, DWORD p4, DWORD p5, DWORD p6, DWORD monsterID, DWORD p8)
{
if (WEactive && (ptGame->difficultyLevel == D2DM_HELL) && !DCloneSpawned)
{
DCloneSpawned=1;
D2SpawnMonster(ptGame,ptRoom,p3,p4,p5,p6,worldEventmonsterID,p8);
return 0;//no minions
}
else return D2SpawnMonster(ptGame,ptRoom,p3,p4,p5,p6,monsterID,p8);
}
DWORD STDCALL verifIfWEItem (Unit* ptItem, DWORD flags, DWORD line, const char* filename)
{
ItemsBIN* ptItemStats = D2GetItemsBIN(ptItem->nTxtFileNo);
ItemsBIN* ptWantedItemStats = D2GetItemsBIN(itemNeeded.ID);
if((itemNeeded.byItemTypeID && D2CheckItemType(ptItem,itemNeeded.ID))
|| (itemNeeded.byItemID && (itemNeeded.ID == 0xFFFF))
|| (itemNeeded.byItemID && !itemNeeded.includeUpgradedVersions && ((DWORD)itemNeeded.ID == ptItem->nTxtFileNo))
|| (itemNeeded.byItemID && itemNeeded.includeUpgradedVersions) && (
(ptItemStats->ItemCode == ptItemStats->NormCode) && (ptItemStats->ItemCode == ptWantedItemStats->NormCode)
|| (ptItemStats->ItemCode == ptItemStats->UberCode) && (ptItemStats->ItemCode == ptWantedItemStats->NormCode)
|| (ptItemStats->ItemCode == ptItemStats->UberCode) && (ptItemStats->ItemCode == ptWantedItemStats->UberCode)
|| (ptItemStats->ItemCode == ptItemStats->HellCode) && (ptItemStats->ItemCode == ptWantedItemStats->NormCode)
|| (ptItemStats->ItemCode == ptItemStats->HellCode) && (ptItemStats->ItemCode == ptWantedItemStats->UberCode)
|| (ptItemStats->ItemCode == ptItemStats->HellCode) && (ptItemStats->ItemCode == ptWantedItemStats->HellCode)
))
if(!(itemNeeded.isSpecificItem && (D2GetUniqueID(ptItem) != itemNeeded.specificID-1))
&& !(itemNeeded.haveNoSocket && (D2GetPlayerStat(ptItem, STATS_ITEM_NUMSOCKETS, 0) > 0))
&& !(itemNeeded.haveSockets && (D2GetPlayerStat(ptItem, STATS_ITEM_NUMSOCKETS, 0) == 0))
&& !(itemNeeded.isNotEthereal && D2isEtheral(ptItem))
&& !(itemNeeded.isEthereal && !D2isEtheral(ptItem))
&& !(itemNeeded.isBasic && (ptItemStats->ItemCode != ptWantedItemStats->NormCode))
&& !(itemNeeded.isExceptional && (ptItemStats->ItemCode != ptWantedItemStats->UberCode))
&& !(itemNeeded.isElite && (ptItemStats->ItemCode != ptWantedItemStats->HellCode))
&& !(itemNeeded.isNotRuneword && ptItem->ptItemData->isRuneword) )
{
nbSOJSold += valueOfOwnSOJSold;
return 1;// Can't re-buy the item.
}
return D2TestFlags(ptItem, flags, line, filename);
}
void initWorldEventVariables()
{
char buf[50];
memset(&itemNeeded,0,sizeof(itemNeeded));
strncpy(buf,itemsToSell,50);
D2CompileCubeInput(&itemNeeded,buf,0,0);
nbManagedSOJSold = 0;
DCloneSpawned = 0;
WEactive = 0;
while (nbSOJSold >= nbNeedSOJSold)
nbNeedSOJSold += (DWORD)(rand()/(RAND_MAX+1.0)*triggerAtSolJSoldDelta+triggerAtSolJSoldMin);
}
FCT_ASM ( caller_WEManagement_1XX )
POP EAX
PUSH ECX
PUSH EAX
JMP WEManagement
}}
FCT_ASM ( caller_spawnDClone_111 )
PUSH DWORD PTR SS:[ESP+0x14]
PUSH EAX
PUSH DWORD PTR SS:[ESP+0x18]
PUSH DWORD PTR SS:[ESP+0x18]
PUSH DWORD PTR SS:[ESP+0x18]
PUSH ECX
MOV ECX,DWORD PTR SS:[ESP+0x1C]
CALL spawnDClone
RETN 0x14
}}
FCT_ASM ( caller_spawnDClone_111b )
PUSH EDX
PUSH ECX
PUSH DWORD PTR SS:[ESP+0x1C]
PUSH DWORD PTR SS:[ESP+0x1C]
PUSH DWORD PTR SS:[ESP+0x1C]
PUSH EAX
MOV EDX,DWORD PTR SS:[ESP+0x20]
MOV ECX,DWORD PTR SS:[ESP+0x1C]
CALL spawnDClone
RETN 0x14
}}
FCT_ASM( caller_addClientForWE_111 )
PUSH EAX
CALL initWorldEventVariables
POP EAX
JMP D2AddClient
}}
FCT_ASM( caller_addClientForWE )
PUSH ECX
CALL initWorldEventVariables
POP ECX
JMP D2AddClient
}}
void Install_WorldEvent()
{
static int isInstalled = false;
if (isInstalled) return;
if ( version_D2Game < V110 )
return;
nbSOJSold = (DWORD)(rand()/(RAND_MAX+1.0)*valueInitSOJSoldDelta+valueInitSOJSoldMin);
if (active_AutomaticSell)
{
prevTicks = GetTickCount();
nbTicksForNextSOJSold = (DWORD)(rand()/(RAND_MAX+1.0)*(timeBeforeAutoSellDelta+timeBeforeAutoSellMin));
}
log_msg("Patch D2Game for active World Event. (WorldEvent)\n");
// spawn DClone
mem_seek R7(D2Game, 0000, 0000, 3F720, 4BCB1, ECF10, 41570, 25280);
MEMC_REF4( V2SpawnMonster , version_D2Game >= V111b ? (DWORD)caller_spawnDClone_111b : version_D2Game == V111 ? (DWORD)caller_spawnDClone_111 : (DWORD)spawnDClone);
//6FC6F71F |. E8 FCFAFFFF CALL D2Game.6FC6F220
//01FCBCB0 |. E8 2BEFFFFF CALL D2Game.01FCABE0 ; \D2Game.01FCABE0
//0205CF0F |. E8 CCF8FFFF CALL D2Game.0205C7E0 ; \D2Game.0205C7E0
//6FC6156F |. E8 1CF6FFFF CALL D2Game.6FC60B90 ; \D2Game.6FC60B90
//6FC4527F |. E8 CCF6FFFF CALL D2Game.6FC44950 ; \D2Game.6FC44950
// verify if the item sold is a trigger of WE
mem_seek R7(D2Game, 0000, 0000, 977D0, 8E799, 92859, 84499, BFB29);
MEMJ_REF4( D2TestFlags , verifIfWEItem);
//6FCC77CF |. E8 32400500 CALL <JMP.&D2Common.#10707>
//0200E798 |. E8 E9BDF7FF CALL <JMP.&D2Common.#10911>
//02002858 |. E8 E57DF7FF CALL <JMP.&D2Common.#10303>
//6FCA4498 |. E8 3B62F8FF CALL <JMP.&D2Common.#10989>
//6FCDFB28 |. E8 77ADF4FF CALL <JMP.&D2Common.#10202>
// management of the WorldEvent
mem_seek R7(D2Game, 0000, 0000, 3CE0, 51F01, C5681, EBF41, 4A791);
MEMC_REF4( V2GetGameByClientID , version_D2Game >= V111 ? (DWORD)WEManagement : (DWORD)caller_WEManagement_1XX);
//6FC33CDF . E8 FC570000 CALL D2Game.6FC394E0
//01FD1F00 |. E8 1BE60800 CALL D2Game.02060520
//02035680 |. E8 1BF30100 CALL D2Game.020549A0
//6FD0BF40 |. E8 1BA4FBFF CALL D2Game.6FCC6360
//6FC6A790 |. E8 4B03FEFF CALL D2Game.6FC4AAE0
// add client for the WorldEvent
mem_seek R7(D2Game, 0000, 0000, 1AEF, 3786A, 7055A, 6265F, CB0BF);
MEMC_REF4( D2AddClient , version_D2Game >= V111 ? caller_addClientForWE_111 : caller_addClientForWE);
//6FC31AEE |. E8 6D510000 CALL D2Game.6FC36C60
//01FB7869 |. E8 32C50A00 CALL D2Game.02063DA0
//01FE0559 |. E8 B27C0700 CALL D2Game.02058210
//6FC8265E |. E8 FD890800 CALL D2Game.6FD0B060
//6FCEB0BE |. E8 6DE8F7FF CALL D2Game.6FC69930
log_msg("\n");
isInstalled = true;
}
/*================================= END OF FILE =================================*/

19
PlugY/bigStash.h Normal file
View File

@ -0,0 +1,19 @@
/*=================================================================
File created by Yohann NICOLAS.
Use a more big stash
=================================================================*/
#ifndef __BIGSTASH_HPP__INCLUDED
#define __BIGSTASH_HPP__INCLUDED
#include <windows.h>
extern bool active_bigStash;
extern bool active_bigStash_tested;
void Install_BigStash();
#endif

16
PlugY/clientSaveFile.h Normal file
View File

@ -0,0 +1,16 @@
/*=================================================================
File created by Yohann NICOLAS.
Add an extra save file for each characters.
=================================================================*/
/*
#pragma once
#include "common.h"
DWORD loadClientSaveFile();
DWORD saveClientSaveFile();
/*================================= END OF FILE =================================*/

21
PlugY/commands.h Normal file
View File

@ -0,0 +1,21 @@
/*=================================================================
File created by Yohann NICOLAS.
Commands directly in game.
=================================================================*/
#ifndef __COMMANDS_H__INCLUDED
#define __COMMANDS_H__INCLUDED
extern bool active_Commands;
void savePlayers(Unit* ptChar);
void maxGold(Unit* ptChar);
void putGold(Unit* ptChar, DWORD amount);
void takeGold(Unit* ptChar, DWORD amount);
void updateSharedGold(DWORD goldAmount);
void Install_Commands();
#endif

149
PlugY/common.h Normal file
View File

@ -0,0 +1,149 @@
/*==============================================
File created by Yohann NICOLAS.
this file implements some common and useful
function related to some Diablo II mechanisms.
/*============================================*/
#pragma once
#include <windows.h>
#include "../Commons/d2Constants.h"
#include "../Commons/d2BinFile.h"
#include "../Commons/d2Struct.h"
#include "../Commons/d2StringTblStruct.h"
#include "../Commons/D2UnitStruct.h"
#include "../Commons/updatingConst.h"
#include "customData.h"
#include "modifMemory.h"
#include "parameters.h"
#include "globalVariable.h"
//#ifdef MSVC
#define FASTCALL __fastcall
//#else
//#define FASTCALL __msfastcall
//#endif
#define STDCALL __stdcall
#define FCT_ASM(N) __declspec(naked) void N() {__asm{
#define RANDOM(V) ((int)(rand()/(RAND_MAX+1.0)*(V)))
//#define RANDOM(V) (rand()%(V))
// Convertion to 1.09
struct s_shifting {
DWORD ptInventory;
DWORD ptSpecificData;
DWORD ptPYPlayerData;
DWORD ptGame;
DWORD ptClientGame;
DWORD ptSkills;
DWORD ptImage;
DWORD ptFrame;
};
extern s_shifting shifting;
//#define PY(C) (*(PYPlayerData**)((BYTE*)(ptChar)+shifting.ptPYPlayerData))
#define PCPlayerData (*(PlayerData**)((DWORD)(ptChar)+shifting.ptSpecificData)) //->ptPlayerData
#define PCGame (*(Game**)((DWORD)(ptChar)+shifting.ptGame)) //->ptGame
#define PClientGame (*(Game**)((DWORD)(ptClient)+shifting.ptClientGame)) //ptClient->ptGame
#define PCInventory (*(Inventory**)((DWORD)(ptChar)+shifting.ptInventory)) //->ptInventory
//#define PIItemData (*(ItemData**)((DWORD)(ptItem)+shifting.ptSpecificData)) //->ptItemData
//#define PCPY (*(PYPlayerData**)((DWORD)(ptChar)+shifting.ptPYPlayerData)) //->ptPYPlayerData
#define PCPY ((PYPlayerData*)((DWORD)PCPlayerData+shifting.ptPYPlayerData)) //->ptPYPlayerData
#define PCSkills (*(Skills**)((DWORD)(ptChar)+shifting.ptSkills)) //->ptSkills
#define R7(Z,A,B,C,D,E,F,G) (offset_##Z + (version_##Z == V113? 0x##G : (version_##Z == V112? 0x##F : (version_##Z == V111b? 0x##E : (version_##Z == V111? 0x##D : (version_##Z == V110? 0x##C : (version_##Z == V109d? 0x##B : 0x##A)))))))
#define V7(Z,A,B,C,D,E,F,G) (version_##Z == V113? 0x##G : (version_##Z == V112? 0x##F : (version_##Z == V111b? 0x##E : (version_##Z == V111? 0x##D : (version_##Z == V110? 0x##C : (version_##Z == V109d? 0x##B : 0x##A))))))
// Convert 4 char code in a DWORD code
#define BIN(A,B,C,D) ((DWORD)A) + (((DWORD)B) << 8) + (((DWORD)C) << 16) + (((DWORD)D) << 24)
#define RX(v) (WindowStartX+(v))
#define RY(v) (ResolutionY+NegWindowStartY-(v))
enum eFileVersion
{
V109b=0,
V109d,
V110,
V111,
V111b,
V112,
V113
};
extern int version_SmackW32;
extern int version_D2Common;
extern int version_ijl11;
extern int version_D2Gdi;
extern int version_D2Win;
extern int version_D2sound;
extern int version_D2MCPCLI;
extern int version_D2Launch;
extern int version_D2gfx;
extern int version_D2Client;
extern int version_D2Net;
extern int version_D2Lang;
extern int version_D2Game;
extern int version_D2CMP;
extern int version_Bnclient;
extern int version_Fog;
extern int version_Storm;
// Address in memory of external DLL
extern DWORD offset_SmackW32;
extern DWORD offset_D2Common;
extern DWORD offset_ijl11;
extern DWORD offset_D2Gdi;
extern DWORD offset_D2Win;
extern DWORD offset_D2sound;
extern DWORD offset_D2MCPCLI;
extern DWORD offset_D2Launch;
extern DWORD offset_D2gfx;
extern DWORD offset_D2Client;
extern DWORD offset_D2Net;
extern DWORD offset_D2Lang;
extern DWORD offset_D2Game;
extern DWORD offset_D2CMP;
extern DWORD offset_Bnclient;
extern DWORD offset_Fog;
extern DWORD offset_Storm;
extern const char* S_CloneBattles;
extern const char* S_DarkAlliance;
LPWSTR getTranslatedString(int stringID);
enum eStringList
{
STR_STATS_UNASSIGN_WITH_LIMIT=0,
STR_STATS_UNASSIGN_WITHOUT_LIMIT,
STR_STATS_BASE_MIN,
STR_SKILLS_UNASSIGN,
STR_STASH_PREVIOUS_PAGE,
STR_STASH_NEXT_PAGE,
STR_TOGGLE_TO_PERSONAL,
STR_TOGGLE_TO_SHARED,
STR_STASH_PREVIOUS_INDEX,
STR_STASH_NEXT_INDEX,
STR_PERSONAL_PAGE_NUMBER,
STR_SHARED_PAGE_NUMBER,
STR_NO_SELECTED_PAGE,
STR_PUT_GOLD,
STR_TAKE_GOLD,
STR_SHARED_GOLD_QUANTITY,
STR_PREVIOUS_PAGE,
STR_NEXT_PAGE
};
bool isOnRect(DWORD x, DWORD y, DWORD x0, DWORD y0, DWORD l, DWORD h);
void freeMessage(sWinMessage* msg);
LPWSTR getTypeUString (WORD id, LPWSTR lpText, DWORD size);
char* getTypeAString (WORD id, char* lpText, DWORD size);
/*================================= END OF FILE =================================*/

15
PlugY/customData.h Normal file
View File

@ -0,0 +1,15 @@
/*=================================================================
File created by Yohann NICOLAS.
Data added to D2 base-stucture
=================================================================*/
#pragma once
#include "playerCustomData.h"
#define CBPlayerData void
#define CBItemData void
/*================================= END OF FILE =================================*/

46
PlugY/customLibraries.h Normal file
View File

@ -0,0 +1,46 @@
/*=================================================================
File created by Yohann NICOLAS.
Language management.
=================================================================*/
#pragma once
typedef int (STDCALL *TsaveSaveFile) (Unit* ptChar, BYTE** data, DWORD* maxSize, DWORD* curSize);
typedef int (STDCALL *TloadSaveFile) (Unit* ptChar, BYTE* data, DWORD maxSize, DWORD* curSize);
typedef int (STDCALL *TinitSaveFile) (BYTE** data, DWORD* maxSize, DWORD* curSize);
class TCustomDll
{
public:
union {
HMODULE module;
DWORD offset;
};
TCustomDll* nextDll;
void initialize(DWORD offsetDll);
void init();
void release();
void saveExtendedSaveFile (Unit* ptChar, BYTE** data, DWORD* maxSize, DWORD* curSize);
int loadExtendedSaveFile (Unit* ptChar, BYTE* data, DWORD maxSize, DWORD* curSize);
int initExtendedSaveFile (BYTE** data, DWORD* maxSize, DWORD* curSize);
void saveSharedSaveFile (Unit* ptChar, BYTE** data, DWORD* maxSize, DWORD* curSize);
int loadSharedSaveFile (Unit* ptChar, BYTE* data, DWORD maxSize, DWORD* curSize);
int initSharedSaveFile (BYTE** data, DWORD* maxSize, DWORD* curSize);
// __inline TCustomDll() {ZeroMemory(this,sizeof(this));}
private:
FARPROC initFct;
FARPROC releaseFct;
TsaveSaveFile saveExtendedSaveFileFct;
TloadSaveFile loadExtendedSaveFileFct;
TinitSaveFile initExtendedSaveFileFct;
TsaveSaveFile saveSharedSaveFileFct;
TloadSaveFile loadSharedSaveFileFct;
TinitSaveFile initSharedSaveFileFct;
};
extern TCustomDll* customDlls;
/*================================= END OF FILE =================================*/

75
PlugY/d2functions.h Normal file
View File

@ -0,0 +1,75 @@
/*================================================
File created by Yohann NICOLAS.
This file implements some common and useful
function related to some Diablo II mechanisms.
================================================*/
#pragma once
#include "common.h"
#define D2S(F, I, R, N, P) typedef R (STDCALL *T##N) P; extern T##N N;//static D N = (D)(A);
#define D2F(F, I, R, N, P) typedef R (FASTCALL *T##N) P; extern T##N N;//static D N = (D)(A);
#define E2S(F, A, R, N, P) typedef R (STDCALL *T##N) P; extern T##N N;
#define E2F(F, A, R, N, P) typedef R (FASTCALL *T##N) P; extern T##N N;
#define E2C(F, A, T, N) extern T* pt##N;
#define F7(X, Z, A,B,C,D,E,F,G, R, N, P) typedef R (X##CALL *T##N) P; extern T##N N;
#define A7(X, Z, A,B,C,D,E,F,G, R, N, P) typedef R (X##CALL *T##N) P; extern T##N N;
#define C7(Z, A,B,C,D,E,F,G, T, N) extern T* pt##N;
#include "../Commons/D2Funcs.h"
extern DataTables* SgptDataTables;
//ONLY UNTIL 1.10 :
//E2F(D2Client,0, DWORD, D2isLODGame, ());
//E2F(D2Client,0, BYTE, D2GetDifficultyLevel, ());
//E2S(D2Client,0, DWORD, D2GetMouseX, ());
//E2S(D2Client,0, DWORD, D2GetMouseY, ());
//E2S(D2Client,0, Unit*, D2GetClientPlayer, ());
//E2F(D2Client,0, void, D2SendToServer3, (BYTE type, WORD p));
////E2F(D2Client,0, void, D2SendToServer7, (BYTE type, WORD p1, WORD p2, WORD p3));
////E2F(D2Client,0, void, D2SendToServer5, (BYTE type, DWORD p));
////E2F(D2Client,0, void, D2SendToServer9, (BYTE type, DWORD p1, DWORD p2));
////E2F(D2Client,0, void, D2SendToServer13,(BYTE type, DWORD p1, DWORD p2, DWORD p3));
//E2F(D2Game,0, NetClient*, D2GetClient, (Unit* ptUnit, char* lpszErrFile, DWORD ErrLine));
//E2F(D2Client,0, void, D2CleanStatMouseUp, ());
#undef F7
#undef A7
#undef C7
#undef D2S
#undef D2F
#undef E2S
#undef E2F
#undef E2C
extern TD2AddPlayerStat V2AddPlayerStat;
extern TD2GetGameByClientID V2GetGameByClientID;
extern TD2SpawnMonster V2SpawnMonster;
//extern TD2SetColorPopup V2SetColorPopup;
extern WORD (*getDescStrPos) (DWORD statID);
extern void* (STDCALL *compileTxtFile)(DWORD unused, const char* filename, BINField* ptFields, DWORD* ptRecordCount, DWORD recordLength);
void setImage(sDrawImageInfo* data, void* image);
void setFrame(sDrawImageInfo* data, DWORD frame);
void __inline fillRect(DWORD x, DWORD y, DWORD Width, DWORD Height, DWORD color, DWORD transTbl){D2FillArea(x,y,x+Width,y+Height,color,transTbl);};
//#define SgptDataTables (*ptSgptDataTables)
#define ResolutionY (*ptResolutionY)
#define ResolutionX (*ptResolutionX)
#define NegWindowStartY (*ptNegWindowStartY)
#define WindowStartX (*ptWindowStartX)
#define GameTypeMode (*ptGameTypeMode)
#define ClientTable (*ptClientTable)
#define IsLodGame (*ptIsLodGame)
#define DifficultyLevel (*ptDifficultyLevel)
#define MouseY (*ptMouseY)
#define MouseX (*ptMouseX)
#define ptClientChar (*ptptClientChar)
//#define CurrentNPCNum (*ptCurrentNPCNum)
bool initD2functions();
/*================================= END OF FILE =================================*/

24
PlugY/error.h Normal file
View File

@ -0,0 +1,24 @@
/*==============================================
File created by Yohann NICOLAS.
@file error.hpp
@brief Error logger definition.
This file defiens various functions related to
error handling in D2External functions.
==============================================*/
#ifndef __ERROR_H__INCLUDED__
#define __ERROR_H__INCLUDED__
#include <windows.h>
extern DWORD active_logFile;
void log_initfile();
void log_box( const char* pFormat, ... );
void log_msg( const char* pFormat, ... );
void d2_assert( bool pCondition, char* pLocation, char* pMessage, int pLineNbr );
#endif

21
PlugY/extendedSaveFile.h Normal file
View File

@ -0,0 +1,21 @@
/*=================================================================
File created by Yohann NICOLAS.
Add an extra save file for each characters.
=================================================================*/
#pragma once
#include "common.h"
#include <stdio.h>
BYTE* readExtendedSaveFile(char* name, DWORD* size);
void writeExtendedSaveFile(char* name, BYTE* data, DWORD size);
int loadExtendedSaveFile(Unit* ptChar, BYTE* data, DWORD maxSize);
void saveExtendedSaveFile(Unit* ptChar, BYTE** data, DWORD* maxSize, DWORD* curSize);
void backupExtendedSaveFile(char* name);
/*================================= END OF FILE =================================*/

31
PlugY/extraOptions.h Normal file
View File

@ -0,0 +1,31 @@
/*=================================================================
File created by Yohann NICOLAS.
More little options.
=================================================================*/
#ifndef __EXTRAOPTIONS_H__INCLUDED
#define __EXTRAOPTIONS_H__INCLUDED
extern int active_RunLODs;
extern int active_alwaysRegenMapInSP;
extern DWORD nbPlayersCommandByDefault;
extern int active_DisplayItemLevel;
extern int active_AlwaysDisplayLifeMana;
extern int active_EnabledTXTFilesWithMSExcel;
extern int active_DisplayBaseStatsValue;
extern int active_LadderRunewords;
extern int active_EnabledCowPortalWhenCowKingWasKill;
void Install_RunLODs();
void Install_AlwaysRegenMapInSP();
void Install_SendPlayersCommand();
void Install_DisplayItemLevel();
void Install_AlwaysDisplayLifeMana();
void Install_EnabledTXTFilesWithMSExcel();
void Install_DisplayBaseStatsValue();
void Install_LadderRunewords();
void Install_EnabledCowPortalWhenCowKingWasKill();
#endif

16
PlugY/globalVariable.h Normal file
View File

@ -0,0 +1,16 @@
/*=================================================================
File created by Yohann NICOLAS.
Set global variable.
=================================================================*/
#ifndef __GLOBAL_VARIABLE_H__INCLUDED
#define __GLOBAL_VARIABLE_H__INCLUDED
extern bool onRealm;
extern bool needToInit;
void Install_VariableOnRealm();
#endif

46
PlugY/infinityStash.h Normal file
View File

@ -0,0 +1,46 @@
/*=================================================================
File created by Yohann NICOLAS.
infinity Stash gestion
=================================================================*/
#pragma once
#include "common.h"
extern DWORD maxSelfPages;
extern DWORD maxSharedPages;
extern DWORD nbPagesPerIndex;
extern DWORD nbPagesPerIndex2;
extern bool active_multiPageStash;
extern bool active_sharedStash;
extern bool active_sharedGold;
extern bool separateHardSoftStash;
extern char* sharedStashFilename;
extern bool displaySharedSetItemNameInGreen;
extern int posXPreviousBtn,posYPreviousBtn,posXNextBtn,posYNextBtn,posXSharedBtn,posYSharedBtn,posXPreviousIndexBtn,posYPreviousIndexBtn,posXNextIndexBtn,posYNextIndexBtn,posXPutGoldBtn,posYPutGoldBtn,posXTakeGoldBtn,posYTakeGoldBtn;
void toggleToSharedStash(Unit* ptChar);
void toggleToSelfStash(Unit* ptChar);
void selectPreviousStash(Unit* ptChar);
void selectNextStash(Unit* ptChar);
void selectPreviousIndexStash(Unit* ptChar);
void selectNextIndexStash(Unit* ptChar);
void selectPrevious2Stash(Unit* ptChar);
void selectNext2Stash(Unit* ptChar);
void selectPreviousIndex2Stash(Unit* ptChar);
void selectNextIndex2Stash(Unit* ptChar);
void selectStash(Unit* ptChar, Stash* newStash);
void setSelectedStashClient(DWORD stashId, DWORD stashFlags, DWORD flags);
Stash* addStash(Unit* ptChar, bool isShared);
DWORD loadStashList(Unit* ptChar, BYTE* data, DWORD maxSize, DWORD* curSize, bool isShared);
void saveStashList(Unit* ptChar, Stash* ptStash, BYTE** data, DWORD* maxSize, DWORD* curSize);
void Install_MultiPageStash();
/*================================= END OF FILE =================================*/

13
PlugY/interface_Skills.h Normal file
View File

@ -0,0 +1,13 @@
/*=================================================================
File created by Yohann NICOLAS.
Interface Skills functions
=================================================================*/
#ifndef __INTERFACE_SKILLS_HPP__INCLUDED
#define __INTERFACE_SKILLS_HPP__INCLUDED
void Install_InterfaceSkills();
#endif

13
PlugY/interface_Stash.h Normal file
View File

@ -0,0 +1,13 @@
/*=================================================================
File created by Yohann NICOLAS.
Interface functions
=================================================================*/
#ifndef __INTERFACE_STASH_HPP__INCLUDED
#define __INTERFACE_STASH_HPP__INCLUDED
void Install_InterfaceStash();
#endif

13
PlugY/interface_Stats.h Normal file
View File

@ -0,0 +1,13 @@
/*=================================================================
File created by Yohann NICOLAS.
Interface Stats functions
=================================================================*/
#ifndef __INTERFACE_STATS_HPP__INCLUDED
#define __INTERFACE_STATS_HPP__INCLUDED
void Install_InterfaceStats();
#endif

39
PlugY/language.h Normal file
View File

@ -0,0 +1,39 @@
/*=================================================================
File created by Yohann NICOLAS.
Language management.
=================================================================*/
#ifndef __LANGUAGE_H__INCLUDED
#define __LANGUAGE_H__INCLUDED
extern bool active_ChangeLanguage;
extern DWORD selectedLanguage;
extern bool active_LanguageManagement;
extern DWORD defaultLanguage;
union t_availableLanguages
{
DWORD all;
struct {
DWORD eng:1;
DWORD esp:1;
DWORD deu:1;
DWORD fra:1;
DWORD por:1;
DWORD ita:1;
DWORD jpn:1;
DWORD kor:1;
DWORD sin:1;
DWORD chi:1;
DWORD pol:1;
DWORD rus:1;
};
};
extern t_availableLanguages availableLanguages;
void Install_LanguageManagement();
#endif

13
PlugY/loadPlayerData.h Normal file
View File

@ -0,0 +1,13 @@
/*=================================================================
File created by Yohann NICOLAS.
Load Player Custom Data.
=================================================================*/
#ifndef __LOADPLAYERDATA_H__INCLUDED
#define __LOADPLAYERDATA_H__INCLUDED
void Install_LoadPlayerData();
#endif

22
PlugY/mainScreen.h Normal file
View File

@ -0,0 +1,22 @@
/*=================================================================
File created by Yohann NICOLAS.
Add "plugY v1.00" on screen.
=================================================================*/
#ifndef __MAINSCREEN_H__INCLUDED
#define __MAINSCREEN_H__INCLUDED
#include <windows.h>
extern bool active_VersionTextChange;
extern char* versionText;
extern BYTE modVersionColor;
extern bool active_PrintPlugYVersion;
extern BYTE colorOfPlugYVersion;
void Install_PrintPlugYVersion();
void Install_VersionChange();
#endif

33
PlugY/modifMemory.h Normal file
View File

@ -0,0 +1,33 @@
/*==============================================
File created by Yohann NICOLAS.
Modification of code in memory functions.
/*============================================*/
#pragma once
extern void* currentMemoryPos;
DWORD mem_seek(DWORD newPos);
void memt_byte(BYTE old, BYTE val);
#define MEMT_DWORD(O, R) memt_dword((DWORD)(O), (DWORD)(R))
void memt_dword(DWORD old, DWORD val);
#define MEMT_REF4(O, R) memt_ref4((DWORD)(O), (DWORD)(R))
void memt_ref4(DWORD old, DWORD ref);
//CALL <JMP.&D2gfx.#10047>
#define MEMJ_REF4(O, R) memj_ref4((DWORD)(O), (DWORD)(R))
void memj_ref4(DWORD old, DWORD ref);
//CALL D2Common.6FD5F500
#define MEMC_REF4(O, R) memc_ref4((DWORD)(O), (DWORD)(R))
void memc_ref4(DWORD old, DWORD ref);
//CALL DWORD PTR DS:[<&USER32.GetKeyState>]
#define MEMD_REF4(O, R) memd_ref4((DWORD)(O), (DWORD)(R))
void memd_ref4(DWORD old, DWORD ref);
/*================================= END OF FILE =================================*/

View File

@ -0,0 +1,13 @@
/*=================================================================
File created by Yohann NICOLAS.
Cube Listing functions
=================================================================*/
#ifndef __NEWINTERFACE_CUBELISTING_H__INCLUDED
#define __NEWINTERFACE_CUBELISTING_H__INCLUDED
void listAllCubeFormula();
#endif

View File

@ -0,0 +1,15 @@
/*=================================================================
File created by Yohann NICOLAS.
New runeword Interface
=================================================================*/
#ifndef __NEWINTERFACE_RUNEWORDS_H__INCLUDED
#define __NEWINTERFACE_RUNEWORDS_H__INCLUDED
void STDCALL printRunewordsPage();
DWORD STDCALL mouseRunewordsPageLeftDown(sWinMessage* msg);
DWORD STDCALL mouseRunewordsPageLeftUp(sWinMessage* msg);
#endif

View File

@ -0,0 +1,15 @@
/*=================================================================
File created by Yohann NICOLAS.
New Stat Interface
=================================================================*/
#ifndef __NEWINTERFACE_STATS_H__INCLUDED
#define __NEWINTERFACE_STATS_H__INCLUDED
void STDCALL printNewStatsPage();
DWORD STDCALL mouseNewStatsPageLeftDown(sWinMessage* msg);
DWORD STDCALL mouseNewStatsPageLeftUp(sWinMessage* msg);
#endif

View File

@ -0,0 +1,15 @@
/*=================================================================
File created by Yohann NICOLAS.
New Stat Interface Page 2
=================================================================*/
#ifndef __NEWINTERFACE_STATSPAGETWO_H__INCLUDED
#define __NEWINTERFACE_STATSPAGETWO_H__INCLUDED
void STDCALL printNewStatsPageTwo(int currentPage);
DWORD STDCALL mouseNewStatsPageTwoLeftDown(sWinMessage* msg);
DWORD STDCALL mouseNewStatsPageTwoLeftUp(sWinMessage* msg);
#endif

27
PlugY/newInterfaces.h Normal file
View File

@ -0,0 +1,27 @@
/*=================================================================
File created by Yohann NICOLAS.
New Interfaces functions
=================================================================*/
#ifndef __NEW_INTERFACES_H__INCLUDED
#define __NEW_INTERFACES_H__INCLUDED
#define MILIEU(X,L,N) (X + ((N<L)? (L-N)/2 : 0))
#define isOnStatsPage(x,y) ((x<400) && (y<553))
extern DWORD bDontPrintBorder;
void GoNextStatPage();
void GoPreviousStatPage();
void GoStatPage(int page);
int GetCurrentPage();
extern bool active_newInterfaces;
extern bool selectMainPageOnOpenning;
extern bool printBackgroundOnMainPage;
void Install_NewInterfaces();
#endif

16
PlugY/othersFeatures.h Normal file
View File

@ -0,0 +1,16 @@
/*=================================================================
File created by Yohann NICOLAS.
Others features.
=================================================================*/
#ifndef __OTHERSFEATURES_H__INCLUDED
#define __OTHERSFEATURES_H__INCLUDED
extern bool active_othersFeatures;
void Install_OthersFeatures();
void Install_ChangeResolution();
#endif

30
PlugY/parameters.h Normal file
View File

@ -0,0 +1,30 @@
/*=================================================================
File created by Yohann NICOLAS.
Loading parameters from ini file.
=================================================================*/
#pragma once
#define PLUGY_VERSION "10.00"
#define LOG_FILE "PlugY.log"
enum TargetMod
{
MOD_NO = 0,
};
// Global variable (user parameters)
extern char* modDataDirectory;
extern bool active_plugin;
extern bool active_DisableBattleNet;
extern bool active_CheckMemory;
extern char* dllFilenames;
extern bool active_D2Mod;
extern TargetMod selectModParam;
void loadParameters();
/*================================= END OF FILE =================================*/

53
PlugY/playerCustomData.h Normal file
View File

@ -0,0 +1,53 @@
/*=================================================================
File created by Yohann NICOLAS.
Data added to Player base-stucture
=================================================================*/
#pragma once
#include "common.h"
extern bool active_PlayerCustomData;
struct Unit;
struct Stash
{
DWORD id;
union {
DWORD flags;
struct {
DWORD isShared:1; //
};
};
char* name;
Unit* ptListItem;
Stash* previousStash;
Stash* nextStash;
};
struct PYPlayerData
{
union {
DWORD flags;
struct {
DWORD selfStashIsOpened:1; //
DWORD sharedStashIsOpened:1;//
DWORD showSharedStash:1; //
// DWORD notOnRealm:1; //set to 1 when the player is load from client or in SP
};
};
DWORD sharedGold;
DWORD nbSelfPages;
DWORD nbSharedPages;
Stash* currentStash;
Stash* selfStash;
Stash* sharedStash;
};
void Install_PlayerCustomData();
/*================================= END OF FILE =================================*/

108
PlugY/plugYFiles.h Normal file
View File

@ -0,0 +1,108 @@
/*=================================================================
File created by Yohann NICOLAS.
Data added to D2 base-stucture
=================================================================*/
#pragma once
extern void* unassignSkillsBtnImages;
extern void* unassignStatsBtnImages;
extern void* stashBtnsImages;
extern void* newStatsInterfaceImages;
extern void* statsBackgroundImages;
extern void* sharedGoldBtnsImages;
#define CREATE_TABLE_DESCRIPTION( N ) \
BINField TableDesc[N]; int i=0
// 0 - null data, used by the End (Term) fields only
#define ADD_TERM_FIELD() \
TableDesc[i].fieldName = "end"; \
TableDesc[i].type = 0x00; \
TableDesc[i].strLength = 0x00; \
TableDesc[i].offset = 0x00; \
TableDesc[i].lookup = 0x00000000; i++
// 1 - String (needs length field)
#define ADD_STRING_FIELD( O,N,L ) \
TableDesc[i].fieldName = N; \
TableDesc[i].type = 0x01; \
TableDesc[i].strLength = L; \
TableDesc[i].offset = O; \
TableDesc[i].lookup = 0x00000000; i++
// 2 - DWORD field
#define ADD_DWORD_FIELD( O,N ) \
TableDesc[i].fieldName = N; \
TableDesc[i].type = 0x02; \
TableDesc[i].strLength = 0x00; \
TableDesc[i].offset = O; \
TableDesc[i].lookup = 0x00000000; i++
// 3 - WORD field
#define ADD_WORD_FIELD( O,N ) \
TableDesc[i].fieldName = N; \
TableDesc[i].type = 0x03; \
TableDesc[i].strLength = 0x00; \
TableDesc[i].offset = O; \
TableDesc[i].lookup = 0x00000000; i++
// 4 - BYTE field
#define ADD_BYTE_FIELD( O,N ) \
TableDesc[i].fieldName = N; \
TableDesc[i].type = 0x04; \
TableDesc[i].strLength = 0x00; \
TableDesc[i].offset = O; \
TableDesc[i].lookup = 0x00000000; i++
// 6 - UBYTE field
#define ADD_UBYTE_FIELD( O,N ) \
TableDesc[i].fieldName = N; \
TableDesc[i].type = 0x06; \
TableDesc[i].strLength = 0x00; \
TableDesc[i].offset = O; \
TableDesc[i].lookup = 0x00000000; i++
// 9 - three and four letter codes
#define ADD_STRCODE_FIELD( O,N ) \
TableDesc[i].fieldName = N; \
TableDesc[i].type = 0x09; \
TableDesc[i].strLength = 0x00; \
TableDesc[i].offset = O; \
TableDesc[i].lookup = 0x00000000; i++
// A,B,D,10,11 - Lookup code
#define ADD_LOOKUP_FIELD( O,N,T,L ) \
TableDesc[i].fieldName = N; \
TableDesc[i].type = T; \
TableDesc[i].strLength = 0x00; \
TableDesc[i].offset = O; \
TableDesc[i].lookup = L; i++
#define ADD_LOOKUP_WORD( O,N,L ) \
TableDesc[i].fieldName = N; \
TableDesc[i].type = 0x14; \
TableDesc[i].strLength = 0x00; \
TableDesc[i].offset = O; \
TableDesc[i].lookup = (void*)(L); i++
//D,F:Lookup for BYTE (F : UBYTE ?)
//17: call function
//14,16:Lookup for WORD
//11:Lookup fo DWORD
//1A: flag
#define BUILD_BIN( T,V,N,F ) V = (T*)compileTxtFile(mempool, F, TableDesc, (DWORD*)&nbStatsInterface, sizeof(T));
//extern void* lookupItemStatCost;
void Install_PlugYFiles();
void Install_PlugYImagesFiles();
void Install_PlugYTxtFiles();
/*================================= END OF FILE =================================*/

15
PlugY/resource.h Normal file
View File

@ -0,0 +1,15 @@
//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
// Used by PlugY.rc
//
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 106
#define _APS_NEXT_COMMAND_VALUE 40001
#define _APS_NEXT_CONTROL_VALUE 1001
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif

16
PlugY/savePath.h Normal file
View File

@ -0,0 +1,16 @@
/*=================================================================
File created by Yohann NICOLAS.
Changing the current save path.
=================================================================*/
#ifndef __SAVEPATH_H__INCLUDED
#define __SAVEPATH_H__INCLUDED
extern char* savePath;
extern bool active_changingSavePath;
void Install_ChangingSavePath();
#endif

13
PlugY/savePlayerData.h Normal file
View File

@ -0,0 +1,13 @@
/*=================================================================
File created by Yohann NICOLAS.
Save Player Custom Data.
=================================================================*/
#ifndef __SAVEPLAYERDATA_H__INCLUDED
#define __SAVEPLAYERDATA_H__INCLUDED
void Install_SavePlayerData();
#endif

21
PlugY/sharedSaveFile.h Normal file
View File

@ -0,0 +1,21 @@
/*=================================================================
File created by Yohann NICOLAS.
Add an extra save file shared by all own characters.
=================================================================*/
#pragma once
#include "common.h"
#include <stdio.h>
BYTE* readSharedSaveFile(char* name, DWORD* size);
void writeSharedSaveFile(char* name, BYTE* data, DWORD size, bool isHardcore);
int loadSharedSaveFile(Unit* ptChar, BYTE* data, DWORD maxSize);
void saveSharedSaveFile(Unit* ptChar, BYTE** data, DWORD* maxSize, DWORD* curSize);
void backupSharedSaveFile();
/*================================= END OF FILE =================================*/

17
PlugY/skillPerLevelUp.h Normal file
View File

@ -0,0 +1,17 @@
/*=================================================================
File created by Yohann NICOLAS.
Change Skill win per level up.
=================================================================*/
#pragma once
#include <windows.h>
extern bool active_SkillPerLevelUpChange;
extern DWORD skillPerLevelUp;
void Install_SkillPerLevelUp();
/*================================= END OF FILE =================================*/

20
PlugY/skillsPoints.h Normal file
View File

@ -0,0 +1,20 @@
/*=================================================================
File created by Yohann NICOLAS.
Unassign Skill Point for futher re-assignment.
=================================================================*/
#ifndef __SKILLSPOINTS_H__INCLUDED
#define __SKILLSPOINTS_H__INCLUDED
extern bool active_SkillsPoints;
extern bool unassignSkillsPointsOneByOne;
extern int posXUnassignSkillBtn, posYUnassignSkillBtn;
void UnassignAllSkillsPoints(Unit* ptChar);
void client_UnassignAllSkillsPoints();
void Install_SkillsPoints();
#endif

17
PlugY/statPerLevelUp.h Normal file
View File

@ -0,0 +1,17 @@
/*=================================================================
File created by Yohann NICOLAS.
Change Stat win per level up.
=================================================================*/
#pragma once
#include <windows.h>
extern bool active_StatPerLevelUpChange;
extern DWORD statPerLevelUp;
void Install_StatPerLevelUp();
/*================================= END OF FILE =================================*/

29
PlugY/statsPoints.h Normal file
View File

@ -0,0 +1,29 @@
/*=================================================================
File created by Yohann NICOLAS.
Unassign Stats Point for futher re-assignment.
=================================================================*/
#pragma once
#include <windows.h>
extern bool active_StatsPoints;
extern DWORD keyUsedForUnassignStatPoint;
extern bool active_StatsShiftClickLimit;
extern DWORD limitValueToShiftClick;
void UnassignStrPoint(Unit* ptChar);
void UnassignStrPoints(Unit* ptChar);
void UnassignDexPoint(Unit* ptChar);
void UnassignDexPoints(Unit* ptChar);
void UnassignVitPoint(Unit* ptChar);
void UnassignVitPoints(Unit* ptChar);
void UnassignEnePoint(Unit* ptChar);
void UnassignEnePoints(Unit* ptChar);
void Install_StatsLimitShiftClick();
void Install_StatsPoints();
/*================================= END OF FILE =================================*/

15
PlugY/uberQuest.h Normal file
View File

@ -0,0 +1,15 @@
/*=================================================================
File created by Yohann NICOLAS.
Uber Quest Management.
=================================================================*/
#pragma once
extern bool active_UberQuest;
void Install_UberQuest();
void resetQuestState();
/*================================= END OF FILE =================================*/

16
PlugY/updateClient.h Normal file
View File

@ -0,0 +1,16 @@
/*=================================================================
File created by Yohann NICOLAS.
Updating Client.
=================================================================*/
#ifndef __UPDATECLIENT_H__INCLUDED
#define __UPDATECLIENT_H__INCLUDED
#include "common.h"
void Install_UpdateClient();
void updateClient(Unit* ptChar, DWORD mFunc, DWORD p1, DWORD p2, DWORD p3);
#endif

16
PlugY/updateServer.h Normal file
View File

@ -0,0 +1,16 @@
/*=================================================================
File created by Yohann NICOLAS.
Updating Server.
=================================================================*/
#pragma once
#include "common.h"
#include "D2functions.h"
__inline void updateServer(WORD p) {if (!onRealm) D2SendToServer3(0x3A, p);};
void Install_UpdateServer();
/*================================= END OF FILE =================================*/

27
PlugY/worldEvent.h Normal file
View File

@ -0,0 +1,27 @@
/*=================================================================
File created by Yohann NICOLAS.
World Event Management.
=================================================================*/
#pragma once
extern bool active_WorldEvent;
extern DWORD showSOJSoldCounterInAllDiff;
extern char* itemsToSell;
extern DWORD worldEventmonsterID;
extern DWORD valueOfOwnSOJSold;
extern DWORD valueInitSOJSoldMin;
extern DWORD valueInitSOJSoldDelta;
extern DWORD triggerAtSolJSoldMin;
extern DWORD triggerAtSolJSoldDelta;
extern bool active_AutomaticSell;
extern DWORD timeBeforeAutoSellMin;
extern DWORD timeBeforeAutoSellDelta;
void initWorldEventVariables();
void Install_WorldEvent();
/*================================= END OF FILE =================================*/

Binary file not shown.

View File

@ -0,0 +1,456 @@
/*=================================================================
File created by Yohann NICOLAS.
Patch D2gfx.dll to install PlugY.
=================================================================*/
#include <windows.h>
#include <stdio.h>
const char* boxNameInstall = "Installation of PlugY, The Survival Kit Installation";
const char* boxNameUnInstall = "Uninstall PlugY, The Survival Kit ";
int CALL_LOAD[7] = {0x389B,0x389B,0x3870,0x8B23,0xB423,0x8F63,0xB423};
BYTE callNewLoad[7][6]={{0xE8,0x60,0x85,0x00,0x00,0x90},// JMP 6FA7BE00-6FA738A0 ;install loadlibrary
{0xE8,0x60,0x85,0x00,0x00,0x90},// JMP 6FA7BE00-6FA738A0 ;install loadlibrary
{0xE8,0x8B,0x85,0x00,0x00,0x90},// JMP 6FA7BE00-6FA73875 ;install loadlibrary
{0xE8,0xD8,0x42,0x00,0x00,0x90},// JMP 6FA8CE00-6FA88B28 ;install loadlibrary
{0xE8,0xD8,0x19,0x00,0x00,0x90},// JMP 6FA8CE00-6FA8B428 ;install loadlibrary
{0xE8,0x98,0x3E,0x00,0x00,0x90},// JMP 6FA8CE00-6FA88F68 ;install loadlibrary
{0xE8,0xD8,0x19,0x00,0x00,0x90}};// JMP 6FA8CE00-6FA8B428 ;install loadlibrary
BYTE callOldLoad[7][6]={{0xFF,0x15,0x3C,0xC0,0xA7,0x6F},
{0xFF,0x15,0x3C,0xC0,0xA7,0x6F},
{0xFF,0x15,0x40,0xC0,0xA7,0x6F},
{0xFF,0x15,0x1C,0xD1,0xA8,0x6F},
{0xFF,0x15,0x1C,0xD1,0xA8,0x6F},
{0xFF,0x15,0x1C,0xD1,0xA8,0x6F},
{0xFF,0x15,0x1C,0xD1,0xA8,0x6F}};
int CALL_FREE[7] = {0x3A8C,0x3A8C,0x3A6D,0x8ACA,0xB3CA,0x8F0A,0xB3CA};
BYTE callNewFree[7][6]={{0xE8,0xAF,0x83,0x00,0x00,0x90}, // JMP 6FA7BE40-6FA73A91 ;install freelibrary
{0xE8,0xAF,0x83,0x00,0x00,0x90}, // JMP 6FA7BE40-6FA73A91 ;install freelibrary
{0xE8,0xD2,0x83,0x00,0x00,0x90}, // JMP 6FA7BE44-6FA73A72 ;install freelibrary
{0xE8,0x75,0x43,0x00,0x00,0x90}, // JMP 6FA8CE44-6FA88ACF ;install freelibrary
{0xE8,0x75,0x1A,0x00,0x00,0x90}, // JMP 6FA8CE44-6FA8B3CF ;install freelibrary
{0xE8,0x35,0x3F,0x00,0x00,0x90}, // JMP 6FA8CE44-6FA88F0F ;install freelibrary
{0xE8,0x75,0x1A,0x00,0x00,0x90}};// JMP 6FA8CE44-6FA8B3CF ;install freelibrary
BYTE callOldFree[7][6]={{0xFF,0x15,0x44,0xC0,0xA7,0x6F}, // CALL DWORD PTR DS:[<&KERNEL32.FreeLibrary>]
{0xFF,0x15,0x44,0xC0,0xA7,0x6F}, // CALL DWORD PTR DS:[<&KERNEL32.FreeLibrary>]
{0xFF,0x15,0x48,0xC0,0xA7,0x6F}, // CALL DWORD PTR DS:[<&KERNEL32.FreeLibrary>]
{0xFF,0x15,0x2C,0xD1,0xA8,0x6F}, // CALL DWORD PTR DS:[<&KERNEL32.FreeLibrary>]
{0xFF,0x15,0x2C,0xD1,0xA8,0x6F}, // CALL DWORD PTR DS:[<&KERNEL32.FreeLibrary>]
{0xFF,0x15,0x2C,0xD1,0xA8,0x6F}, // CALL DWORD PTR DS:[<&KERNEL32.FreeLibrary>]
{0xFF,0x15,0x2C,0xD1,0xA8,0x6F}};// CALL DWORD PTR DS:[<&KERNEL32.FreeLibrary>]
int CALLER_LOADPLUGY = 0xBE00;//6FA7BE00-6FA70000
BYTE caller_LoadPlugY[]={
0xFF,0x74,0x24,0x04, //PUSH DWORD PTR SS:[ESP+4]
0xFF,0x15,0x40,0xC0,0xA7,0x6F, //CALL DWORD PTR DS:[<&KERNEL32.LoadLibraryA>] ; kernel32.LoadLibraryA
0x50, //PUSH EAX
0x68,0x80,0xBE,0xA7,0x6F, //PUSH d2gfx.6FA7BE80 ; ASCII "PlugY.dll"
0xFF,0x15,0x40,0xC0,0xA7,0x6F, //CALL DWORD PTR DS:[<&KERNEL32.LoadLibraryA>] ; kernel32.LoadLibraryA
0xA3,0xFC,0xEF,0xA8,0x6F, //MOV DWORD PTR DS:[6FA8EFFC],EAX
0x85,0xC0, //TEST EAX,EAX
0x74,0x18, //JE SHORT d2gfx.6FA7BE37
0x68,0x90,0xBE,0xA7,0x6F, //PUSH d2gfx.6FA7BE10 ;Init ID
0x50, //PUSH EAX
0xFF,0x15,0x3C,0xC0,0xA7,0x6F, //CALL DWORD PTR DS:[<&KERNEL32.GetProcAddress>] ; kernel32.GetProcAddress
0x85,0xC0, //TEST EAX,EAX
0x74,0x04, //JE SHORT d2gfx.6FA7BDC1
0x6A,0x00, //PUSH 0
0xFF,0xD0, //CALL EAX
0x58, //POP EAX
0xC2,0x04,0x00, //RETN 4
0x59, //POP ECX
0xB9,0x80,0xBE,0xA7,0x6F, //MOV ECX,d2gfx.6FA7BE80 ; ASCII "PlugY.dll"
0x83,0x04,0x24,0x11, //ADD DWORD PTR SS:[ESP],11
0xC2,0x04,0x00}; //RETN 4
int CALLER_FREEPLUGY = 0xBE44;//6FA7BE44-6FA70000
BYTE caller_FreePlugY[]={
0xFF,0x74,0x24,0x04, //PUSH DWORD PTR SS:[ESP+4]
0xFF,0x15,0x48,0xC0,0xA7,0x6F, //CALL DWORD PTR DS:[<&KERNEL32.FreeLibrary>] ; kernel32.FreeLibrary
0x50, //PUSH EAX
0xA1,0xFC,0xEF,0xA8,0x6F, //MOV EAX,DWORD PTR DS:[6FA8EFFC]
0x85,0xC0, //TEST EAX,EAX
0x74,0x20, //JE SHORT d2gfx.6FA7BE74
0x50, //PUSH EAX
0x68,0xA0,0xBE,0xA7,0x6F, //PUSH d2gfx.6FA7BE20 ;release
0x50, //PUSH EAX
0x33,0xC0, //XOR EAX,EAX
0xA3,0xFC,0xEF,0xA8,0x6F, //MOV DWORD PTR DS:[6FA8EFFC],EAX
0xFF,0x15,0x3C,0xC0,0xA7,0x6F, //CALL DWORD PTR DS:[<&KERNEL32.GetProcAdd>; kernel32.GetProcAddress
0x85,0xC0, //TEST EAX,EAX
0x74,0x02, //JE SHORT d2gfx.6FA7BDEF
0xFF,0xD0, //CALL EAX
0xFF,0x15,0x48,0xC0,0xA7,0x6F, //CALL DWORD PTR DS:[<&KERNEL32.FreeLibrar>; kernel32.FreeLibrary
0x58, //POP EAX
0xC2,0x04,0x00}; //RETN 4
int S_DLLNAME = 0xBE80;//6FA7BE30-6FA70000
BYTE sDllName[]={'P','l','u','g','Y','.','d','l','l',0};// Dll filename to load.
int S_INIT = 0xBE90;//6FA7BE10-6FA70000
BYTE sInit[]={'_','I','n','i','t','@','4',0};
int S_RELEASE = 0xBEA0;//6FA7BE20-6FA70000
BYTE sRelease[]={'_','R','e','l','e','a','s','e','@','0',0};
enum eFileVersion
{
V109b=0,
V109d,
V110,
V111,
V111b,
V112,
V113c,
UNKNOW
};
int getVersion(FILE *dll)
{
int ver;
//GET_VERSION(D2gfx, 80, 110, 0x00949FA8, 0x018866A8, 0x401526B2, 0x575C8A5E, 0x42E6C22A, 0x43028B19, 0xACBE1B9E, 0x00000000);
int addr;
fseek(dll,0x80,SEEK_SET);
fread(&addr,sizeof(addr),1,dll);
if (addr == 0x00949FA8)
ver = V109b;
else if (addr == 0x018866A8)
ver = V109d;
else if (addr == 0x401526B2)
ver = V110;
else if (addr == 0x575C8A5E)
{
fseek(dll,0x110,SEEK_SET);
fread(&addr,sizeof(addr),1,dll);
if (addr == 0x42E6C22A)
ver = V111;
else if (addr == 0x43028B19)
ver = V111b;
else
ver = UNKNOW;
}
else if (addr == 0xACBE1B9E)
ver = V112;
else if (addr == 0xACBE1BB6)
ver = V113c;
else
ver = UNKNOW;
return ver;
}
void updateData(int version)
{
switch(version)
{
case V109b:
case V109d:
caller_LoadPlugY[6] -= 4;
caller_LoadPlugY[18] -= 4;
caller_LoadPlugY[39] -= 4;
caller_FreePlugY[6] -= 4;
caller_FreePlugY[36] -= 4;
caller_FreePlugY[48] -= 4;
break;
case V110:
break;
case V111:
case V111b:
case V112:
case V113c:
CALLER_LOADPLUGY += 0x1000;
CALLER_FREEPLUGY += 0x1000;
S_INIT += 0x1000;
S_RELEASE += 0x1000;
S_DLLNAME += 0x1000;
*(DWORD*)(&caller_LoadPlugY[6]) = 0x6FA8D11C;
*(DWORD*)(&caller_LoadPlugY[18]) = 0x6FA8D11C;
*(DWORD*)(&caller_LoadPlugY[39]) = 0x6FA8D120;
*(DWORD*)(&caller_FreePlugY[6]) = 0x6FA8D12C;
*(DWORD*)(&caller_FreePlugY[36]) = 0x6FA8D120;
*(DWORD*)(&caller_FreePlugY[48]) = 0x6FA8D12C;
caller_LoadPlugY[13] += 0x10;
caller_LoadPlugY[14]++;
caller_LoadPlugY[25]++;
caller_LoadPlugY[33] += 0x10;
caller_LoadPlugY[34]++;
caller_LoadPlugY[58] += 0x10;
caller_LoadPlugY[59]++;
caller_FreePlugY[23] += 0x10;
caller_FreePlugY[24]++;
caller_FreePlugY[14]++;
caller_FreePlugY[32]++;
break;
}
}
////////////////////////////// EXPORTED FUNCTIONS //////////////////////////////
void Patch()
{
if (MessageBox(0,"This programm will modify the D2gfx.dll file of the current directory.\n"
"Before continue, don't forgot to backup D2gfx.dll if you want\n"
"Do you want patch D2gfx.dll for the launch of PlugY ?",
boxNameInstall, MB_YESNO|MB_ICONQUESTION) == IDNO)
{
MessageBox(0,"D2gfx.dll isn't patched.\n",
boxNameInstall, MB_OK|MB_ICONASTERISK);
exit(0);
}
FILE *dll=fopen("d2gfx.dll","rb+");
if(!dll)
{
MessageBox(0,"Can't open D2gfx.dll in read/write mode\n"
"If Diablo II is running you can\'t install PlugY, The Survival Kit.\n"
"Quit Diablo II and try again.",
boxNameInstall, MB_OK|MB_ICONEXCLAMATION);
exit(0);
}
int version = getVersion(dll);
if (version == UNKNOW)
{
MessageBox(0,"Bad version of D2gfx.dll.\n"
"You can try to uninstall any previous version of PlugY, The Survival Kit then retry.\n"
"Or re-install a clean version (between 1.09 and 1.12) of LOD.",
boxNameInstall, MB_OK|MB_ICONEXCLAMATION);
exit(0);
}
updateData(version);
bool error = false;
int ident = 0;
BYTE buffer[100];
BYTE zeros[100];
memset(zeros,0,sizeof(zeros));
fseek(dll,CALL_LOAD[version],SEEK_SET);
fread(buffer,6,1,dll);
if(memcmp(buffer, callOldLoad[version], 6) !=0 ) error = true;
if(memcmp(buffer, callNewLoad[version], 6) ==0 ) ident++;
fseek(dll,CALL_FREE[version],SEEK_SET);
fread(buffer,6,1,dll);
if(memcmp(buffer, callOldFree[version], 6) !=0 ) error = true;
if(memcmp(buffer, callNewFree[version], 6) ==0 ) ident++;
fseek(dll,CALLER_LOADPLUGY,SEEK_SET);
fread(buffer,sizeof(caller_LoadPlugY),1,dll);
if(memcmp(buffer, zeros, sizeof(caller_LoadPlugY)) !=0 ) error = true;
if(memcmp(buffer, caller_LoadPlugY, sizeof(caller_LoadPlugY)) ==0 ) ident++;
fseek(dll,CALLER_FREEPLUGY,SEEK_SET);
fread(buffer,sizeof(caller_FreePlugY),1,dll);
if(memcmp(buffer, zeros, sizeof(caller_FreePlugY)) !=0 ) error = true;
if(memcmp(buffer, caller_FreePlugY, sizeof(caller_FreePlugY)) ==0 ) ident++;
fseek(dll,S_INIT,SEEK_SET);
fread(buffer,sizeof(sInit),1,dll);
if(memcmp(buffer, zeros, sizeof(sInit)) !=0 ) error = true;
if(memcmp(buffer, sInit, sizeof(sInit)) ==0 ) ident++;
fseek(dll,S_RELEASE,SEEK_SET);
fread(buffer,sizeof(sRelease),1,dll);
if(memcmp(buffer, zeros, sizeof(sRelease)) !=0 ) error = true;
if(memcmp(buffer, sRelease, sizeof(sRelease)) ==0 ) ident++;
fseek(dll,S_DLLNAME,SEEK_SET);
fread(buffer,sizeof(sDllName),1,dll);
if(memcmp(buffer, zeros, sizeof(sDllName)) !=0 ) error = true;
if(memcmp(buffer, sDllName, sizeof(sDllName)) ==0 ) ident++;
if (error)
{
if (ident==7)
{
MessageBox(0, "PlugY, The Survival Kit already installed.",
boxNameInstall, MB_OK|MB_ICONASTERISK);
exit(0);
} else
{
MessageBox(0,"Bad version of D2gfx.dll.\n"
"You can try to uninstall any previous version of PlugY, The Survival Kit then retry.\n"
"Or re-install a clean version (between 1.09 and 1.11b) of LOD.",
boxNameInstall, MB_OK|MB_ICONEXCLAMATION);
exit(0);
}
}
fseek(dll,CALL_LOAD[version],SEEK_SET);
fwrite(callNewLoad[version], 6, 1, dll);
fseek(dll,CALL_FREE[version],SEEK_SET);
fwrite(callNewFree[version], 6, 1, dll);
fseek(dll,CALLER_LOADPLUGY,SEEK_SET);
fwrite(caller_LoadPlugY, sizeof(caller_LoadPlugY), 1, dll);
fseek(dll,CALLER_FREEPLUGY,SEEK_SET);
fwrite(caller_FreePlugY, sizeof(caller_FreePlugY), 1, dll);
fseek(dll,S_INIT,SEEK_SET);
fwrite(sInit, sizeof(sInit), 1, dll);
fseek(dll,S_RELEASE,SEEK_SET);
fwrite(sRelease, sizeof(sRelease), 1, dll);
fseek(dll,S_DLLNAME,SEEK_SET);
fwrite(sDllName, sizeof(sDllName), 1, dll);
fclose(dll);
MessageBox(0,"D2gfx.dll patched successfully.\n"
"PlugY, The Survival Kit installed successfully.",
boxNameInstall, MB_OK|MB_ICONASTERISK);
exit(0);
}
///////////////////////////////////////////////////////////////////////////////////////////////////
void Unpatch()
{
if (MessageBox(0,"This programm will modify the D2gfx.dll file of the current directory.\n"
"Before continue, don't forgot to backup D2gfx.dll if you want\n"
"Do you want patch D2gfx.dll for remove the launch of PlugY ?",
boxNameUnInstall, MB_YESNO|MB_ICONQUESTION) == IDNO)
{
MessageBox(0,"D2gfx.dll isn't patched.\n",
boxNameUnInstall, MB_OK|MB_ICONASTERISK);
exit(0);
}
FILE *dll=fopen("d2gfx.dll","rb+");
if(!dll)
{
MessageBox(0,"Can't open D2gfx.dll in read/write mode.\n"
"If Diablo II is running you can\'t install PlugY, The Survival Kit.\n"
"Quit Diablo and try again.",
boxNameUnInstall, MB_OK|MB_ICONEXCLAMATION);
exit(0);
}
int version = getVersion(dll);
if (version == UNKNOW)
{
MessageBox(0,"Bad version of D2gfx.dll.\n"
"You can try to uninstall any previous version of PlugY, The Survival Kit then retry.\n"
"Or re-install a clean version (between 1.09 and 1.12) of LOD.",
boxNameUnInstall, MB_OK|MB_ICONEXCLAMATION);
exit(0);
}
updateData(version);
bool error = false;
int ident = 0;
BYTE buffer[100];
BYTE zeros[100];
memset(zeros,0,sizeof(zeros));
fseek(dll,CALL_LOAD[version],SEEK_SET);
fread(buffer,6,1,dll);
if(memcmp(buffer, callNewLoad[version], 6) !=0 ) error = true;
if(memcmp(buffer, callOldLoad[version], 6) ==0 ) ident++;
fseek(dll,CALL_FREE[version],SEEK_SET);
fread(buffer,6,1,dll);
if(memcmp(buffer, callNewFree[version], 6) !=0 ) error = true;
if(memcmp(buffer, callOldFree[version], 6) ==0 ) ident++;
fseek(dll,CALLER_LOADPLUGY,SEEK_SET);
fread(buffer,sizeof(caller_LoadPlugY),1,dll);
if(memcmp(buffer, caller_LoadPlugY, sizeof(caller_LoadPlugY)) !=0 ) error = true;
if(memcmp(buffer, zeros, sizeof(caller_LoadPlugY)) ==0 ) ident++;
fseek(dll,CALLER_FREEPLUGY,SEEK_SET);
fread(buffer,sizeof(caller_FreePlugY),1,dll);
if(memcmp(buffer, caller_FreePlugY, sizeof(caller_FreePlugY)) !=0 ) error = true;
if(memcmp(buffer, zeros, sizeof(caller_FreePlugY)) ==0 ) ident++;
fseek(dll,S_INIT,SEEK_SET);
fread(buffer,sizeof(sInit),1,dll);
if(memcmp(buffer, sInit, sizeof(sInit)) !=0 ) error = true;
if(memcmp(buffer, zeros, sizeof(sInit)) ==0 ) ident++;
fseek(dll,S_RELEASE,SEEK_SET);
fread(buffer,sizeof(sRelease),1,dll);
if(memcmp(buffer, sRelease, sizeof(sRelease)) !=0 ) error = true;
if(memcmp(buffer, zeros, sizeof(sRelease)) ==0 ) ident++;
fseek(dll,S_DLLNAME,SEEK_SET);
fread(buffer,sizeof(sDllName),1,dll);
if(memcmp(buffer, sDllName, sizeof(sDllName)) !=0 ) error = true;
if(memcmp(buffer, zeros, sizeof(sDllName)) ==0 ) ident++;
if (error)
{
if (ident==7)
{
MessageBox(0,"PlugY, The Survival Kit already uninstalled.",
boxNameUnInstall, MB_OK|MB_ICONASTERISK);
exit(0);
} else {
MessageBox(0,"Bad version of D2gfx.dll.\n"
"Unable to uninstall PlugY, The Survival Kit.",
boxNameUnInstall, MB_OK|MB_ICONEXCLAMATION);
exit(0);
}
}
fseek(dll,CALL_LOAD[version],SEEK_SET);
fwrite(callOldLoad[version], 6, 1, dll);
fseek(dll,CALL_FREE[version],SEEK_SET);
fwrite(callOldFree[version], 6, 1, dll);
fseek(dll,CALLER_LOADPLUGY,SEEK_SET);
fwrite(zeros, sizeof(caller_LoadPlugY), 1, dll);
fseek(dll,CALLER_FREEPLUGY,SEEK_SET);
fwrite(zeros, sizeof(caller_FreePlugY), 1, dll);
fseek(dll,S_INIT,SEEK_SET);
fwrite(zeros, sizeof(sInit), 1, dll);
fseek(dll,S_RELEASE,SEEK_SET);
fwrite(zeros, sizeof(sRelease), 1, dll);
fseek(dll,S_DLLNAME,SEEK_SET);
fwrite(zeros, sizeof(sDllName), 1, dll);
fclose(dll);
MessageBox(0,"D2gfx.dll patched successfully.\n"
"PlugY, The Survival Kit uninstalled successfully.",
boxNameUnInstall, MB_OK|MB_ICONASTERISK);
exit(0);
}
int main(int argc, char * argv[])
{
// if ((argc>1) && !strcmp(argv[1],"-u"))
#ifdef RESTORE
Unpatch();
#else
if ((argc>1) && !strcmp(argv[1],"-u"))
Unpatch();
else
Patch();
#endif
}
/*================================= END OF FILE =================================*/

View File

@ -0,0 +1,110 @@
// Microsoft Visual C++ generated resource script.
//
#include "resource.h"
#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#include "afxres.h"
/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
// English (U.S.) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
#ifdef _WIN32
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
#pragma code_page(1252)
#endif //_WIN32
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//
1 TEXTINCLUDE
BEGIN
"resource.h\0"
END
2 TEXTINCLUDE
BEGIN
"#include ""afxres.h""\r\n"
"\0"
END
3 TEXTINCLUDE
BEGIN
"\r\n"
"\0"
END
#endif // APSTUDIO_INVOKED
#endif // English (U.S.) resources
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
// French (France) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_FRA)
#ifdef _WIN32
LANGUAGE LANG_FRENCH, SUBLANG_FRENCH
#pragma code_page(1252)
#endif //_WIN32
/////////////////////////////////////////////////////////////////////////////
//
// Version
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,0,4,0
PRODUCTVERSION 1,0,4,0
FILEFLAGSMASK 0x17L
#ifdef _DEBUG
FILEFLAGS 0x1L
#else
FILEFLAGS 0x0L
#endif
FILEOS 0x4L
FILETYPE 0x1L
FILESUBTYPE 0x0L
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040c04b0"
BEGIN
VALUE "FileVersion", "1.04"
VALUE "OriginalFilename", "PlugY_Install.exe"
VALUE "ProductName", "PlugY Installation"
VALUE "ProductVersion", "1.04"
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x40c, 1200
END
END
#endif // French (France) resources
/////////////////////////////////////////////////////////////////////////////
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED

Some files were not shown because too many files have changed in this diff Show More