diff --git a/Build.h b/Build.h index 062ba77..e18e692 100644 --- a/Build.h +++ b/Build.h @@ -1 +1 @@ -#define __BUILDNO__ 4827 \ No newline at end of file +#define __BUILDNO__ 4853 \ No newline at end of file diff --git a/CommonStructs.h b/CommonStructs.h new file mode 100644 index 0000000..fa03cf3 --- /dev/null +++ b/CommonStructs.h @@ -0,0 +1,452 @@ +#ifndef COMMONSTRUCTS_H__ +#define COMMONSTRUCTS_H__ + +struct UnitAny; +struct StormMsg; +struct CellContext; +struct CellFile; +struct Control; +struct ScrollBar; + +#pragma pack(push, 1) +struct D2Config // sizeof 0x5C +{ + char szSection[27]; // 0x00 + char szKeyName[27]; // 0x1B + char szParamter[27]; // 0x36 + BYTE bType; // 0x51 - specify if config entry is byte (0) int(1) or char(2) + BYTE _1; // 0x52 + BYTE _2; // 0x53 + DWORD dwStructOffset; // 0x54 Offset on BnetData * struct + DWORD dwDefaultValue; // 0x58 +}; + +struct KeyBinding //size 0xA +{ + DWORD nHotkey; // 0x00 + WORD wKey; // 0x04 + BOOL bPrimary;// 0x06 +}; + +struct KeyConfigEntry //size 0xA +{ + DWORD dwEntryNo; //0x00 + WORD wLocaleNo; //0x04 + wchar_t* wText; //0x06 +}; + +struct StormMsg +{ + HWND hWnd; + UINT Msg; + WPARAM wParam; + LPARAM lParam; + DWORD hiWParam16; // wParam shifted by 16 + BOOL _1; + BOOL _2; + BOOL _3; +}; + +struct sMsg //size 0x0C +{ + DWORD MsgType; //0x00 ,0 = WM_MSG , 1 = COMMAND(?), 2 = KEY_UP, 3 = KEY_DOWN + union { + WPARAM wParam; //0x04 + DWORD wKey; //0x04 + }; + void(__stdcall *fnCallBack)(StormMsg *); //0x08 +}; + +#pragma pack(pop) + + + +struct D2PacketTable //1.11b : (0x6FB8BC30 + (4 *(0xPacket*3))) +{ + BOOL(__fastcall *CallBack)(BYTE* aPacket); + int PacketLen; + BOOL(__fastcall *CallBack2)(UnitAny * ptUnit, BYTE* aPacket); +}; + + +struct UiCallArray +{ + void(__cdecl *OnKeyDown)(); + void(__cdecl *OnKeyUp)(); + BOOL bOverride; +}; + +struct ItemConfig +{ + int Code; + int Quality; + int Color; + int Type; +}; + +struct PacketData +{ + DWORD ClientID; + BYTE aPacket[510]; +}; + +struct COORDS +{ + unsigned short x; + unsigned short y; +}; + + +struct D2RECT +{ + DWORD left; + DWORD top; + DWORD right; + DWORD bottom; +}; + +#pragma pack(push, 1) +struct GameView // size 0xEABC +{ + DWORD dwFlags; // 0x00 + RECT ViewRadius; // 0x04 + RECT ToCheck; // 0x14 + DWORD _1; // 0x24 + DWORD _2; // 0x28 + DWORD* pGouraudTblX; // 0x2C + DWORD* pGouraudTblY; // 0x30 + DWORD* pGouraudTblXVal; // 0x34 + DWORD _6; // 0x38 + BYTE _7[60000]; // 0x3C + DWORD _8; + BYTE _9[8]; + DWORD* pWall; // pointer to 36 byte structure pWall structure * nWalls + DWORD* nWalls; + DWORD _12; + DWORD _13[2]; +}; +#pragma pack(pop) + +struct GFXSettings // size 0x18 +{ + DWORD bPerspectiveEnable; // 0 + DWORD bPerspectiveCapable; // 1 + DWORD bLowQuality; //2 + DWORD dwGammaValue; //3 + DWORD bVSync; //4 + DWORD bBlendedShadows; // 5 +}; + +struct GFXHelpers +{ + void(__fastcall *FillYBufferTable)(void *ppvBits, int nWidth, int nHeight, int aZero); + void(__fastcall *f2)(int a1, int a2, int a3); + void(__fastcall *f3)(int a1, int a2, int a3, int a4); + void(__fastcall *f4)(int a1, int a2, int a3, int a4); + void(__fastcall *f5)(int a1, int a2, int a3, int a4); + void(__fastcall *f6)(int a1, int a2, int a3, int a4); + void(__fastcall *f7)(int a1, int a2, int a3, int a4, int a5); +}; + + +struct fnDriverCallbacks +{ + BOOL(__fastcall *InitWindow)(HINSTANCE); // 0 + BOOL(__fastcall *InitPerspective)(GFXSettings * pgfxSettings, int * pfnHelpers); // 1 + BOOL(__fastcall *Release)(); // 2 + BOOL(__fastcall *Init)(HANDLE hWnd, int nResolution); // 3 + BOOL(__fastcall *Shutdown)(); // 4 + BOOL(__fastcall *EndCutscene)(HANDLE hWnd, int nResolution, int); // 5 + BOOL(__fastcall *BeginScene)(BOOL bClear, BYTE nRed, BYTE nGreen, BYTE nBlue); // 6 + BOOL(__fastcall *EndScene1)(); // 7 + BOOL(__fastcall *EndScene2)(); // 8 + BOOL(__fastcall *ResizeWin)(HANDLE HWND, int bResolution); // 9 + BOOL(__fastcall *GetBackBuffer)(BYTE* pBuffer); // 10 + BOOL(__fastcall *ActivateWindow)(int Unk, int Contrast); // 11 + BOOL(__fastcall *SetOption)(int nOption, int nValue); // 12 + BOOL(__fastcall *BeginCutscene)(); // 13 + BOOL(__fastcall *PlayCutscene)(const char* szFile, int nResolution, void *pfframe); // 14 + BOOL(__fastcall *CheckCutscene)(); // 15 + BOOL(__fastcall *DecodeSmacker)(const char *szsmacker, BYTE *pbuffer, int nVersion); // 16 + BOOL(__fastcall *PlaySmacker)(void *pcontext); // 17 + BOOL(__fastcall *CloseSmacker)(void *pcontext); // 18 + int(__fastcall *GetRenderStats)(); // 19 + void(__fastcall *GetScreenSize)(int *pwidth, int *pheight); // 20 + BOOL(__fastcall *SetScaleFactor)(); // 21 + BOOL(__fastcall *SetGamma)(int nGamma); // 22 + BOOL(__fastcall *CheckGamma)(); // 23 + BOOL(__fastcall *SetPerspectiveScale)(); // 24 + BOOL(__fastcall *AdjustPerspective)(int nXpos, int nYpos, int nBais, int *pxadjust, int *pyadjust); // 25 + BOOL(__fastcall *ScalePerspectivepos)(int nXpos, int nYpos, int nAngle, int *pxpos, int *pypos, BOOL bOrder); // 26 + BOOL(__fastcall *SetDefperspectivefactor)(); // 27 + BOOL(__fastcall *SetPalette)(BYTE* pPalette); // 28 + BOOL(__fastcall *SetPalettetable)(BYTE** pPalette); // 29 + BOOL(__fastcall *SetGlobalLight)(BYTE nRed, BYTE nGreen, BYTE nBlue); // 30 + BOOL(__fastcall *DrawGroundTile)(void* pTile, DWORD** pLight, int nXpos, int nYpos, int nWorldXpos, int nWorldYpos, BYTE nAlpha, int nScreenPanels, void* pTileData); // 31 + BOOL(__fastcall *DrawPerspectiveImage)(CellContext* pData, int nXpos, int nYpos, DWORD dwGamma, int nDrawMode, int nScreenMode, BYTE* pPalette); // 32 + BOOL(__fastcall *DrawImage)(CellContext* pData, int nXpos, int nYpos, DWORD dwGamma, int nDrawMode, BYTE* pPalette); // 33 + BOOL(__fastcall *DrawShiftedImage)(CellContext* pData, int nXpos, int nYpos, DWORD dwGamma, int nDrawMode, int nGlobalPaletteShift); // 34 + BOOL(__fastcall *DrawVerticalCropImage)(CellContext* pData, int nXpos, int nYpos, int nSkipLines, int nDrawLines, int nDrawMode); // 35 + BOOL(__fastcall *DrawShadows)(CellContext* pData, int nXpos, int nYpos); // 36 + BOOL(__fastcall *DrawImageFast)(CellContext* pData, int nXpos, int nYpos, BYTE nPaletteIndex); // 37 + BOOL(__fastcall *DrawClippedImage)(CellContext* pData, int nXpos, int nYpos, void* pCropRect, int nDrawMode); // 38 + BOOL(__fastcall *DrawWallTile)(void* pTile, int nXpos, int nYpos, DWORD** pLight, int nScreenPanels, BYTE nAlpha); // 39 + BOOL(__fastcall *DrawRoofTile)(void* pTile, int nXpos, int nYpos, DWORD** pLight, int nScreenPanels, BYTE nAlpha); // 40 + BOOL(__fastcall *DrawVisTile)(void* pTile, int nXpos, int nYpos, int nDrawMode, int nScreenPanels); // 41 + BOOL(__fastcall *DrawRect)(RECT *Prect, BYTE nPaletteIndex); // 42 + BOOL(__fastcall *DrawRectEx)(RECT *Prect, BYTE nPaletteIndex); // 43 + BOOL(__fastcall *DrawSolidRect)(RECT *Prect, BYTE nPaletteIndex); // 44 + BOOL(__fastcall *DrawSolidSquare)(RECT *Prect, BYTE nPaletteIndex, int nSize); // 45 + BOOL(__fastcall *DrawSolidRectEx)(int nXStart, int nYStart, int nXEnd, int nYEnd, DWORD dwColor, int nDrawMode); // 46 + BOOL(__fastcall *DrawSolidRectAlpha)(int nXStart, int nYStart, int nXEnd, int nYEnd, DWORD dwColor, BYTE nAlpha); // 47 + BOOL(__fastcall *DrawLine)(int nXStart, int nYStart, int nXEnd, int nYEnd, BYTE nColor, BYTE nAlpha); // 48 + BOOL(__fastcall *ClearScreen)(BOOL bPartial); // 49 + BOOL(__fastcall *DrawString)(int nXpos, int nYpos, const char *Szformat, ...); // 50 + BOOL(__fastcall *DrawLight)(DWORD *plight, DWORD *pplayerlight, int nXpos, int nYpos); // 51 + BOOL(__fastcall *DebugFillBackBuffer)(int xPos, int yPos); // 52 + BOOL(__fastcall *ClearCaches)(); // 53 +}; + +struct SpellStrc //size 0x1C // Valid for 22 -> on target & 21 -> on xy +{ + DWORD SkillId; //0x00 + DWORD UnitId; //0x04 + DWORD xPos; //0x08 //Also TargetType + DWORD yPos; //0x0C //Also TargetId + DWORD _1; //0x10 + DWORD _2; //0x14 + DWORD _3; //0x18 +}; + +struct BitBuffer // Taken from Nefarius @PhrozenKeep, thx +{ + BYTE *pBuffer; //0x00 + DWORD bitsInBuffer; //0x04 + DWORD bufferPos; //0x08 + DWORD bitsAtPos; //0x0C num bits already read or written at cur pos + DWORD unk; //0x10 could be a bit bucket +}; + + +struct CollMap { + DWORD dwPosGameX; //0x00 + DWORD dwPosGameY; //0x04 + DWORD dwSizeGameX; //0x08 + DWORD dwSizeGameY; //0x0C + DWORD dwPosRoomX; //0x10 + DWORD dwPosRoomY; //0x14 + DWORD dwSizeRoomX; //0x18 + DWORD dwSizeRoomY; //0x1C + WORD *pMapStart; //0x20 + WORD *pMapEnd; //0x22 +}; + + +struct cStylePrefs +{ + DWORD dwFontType; //0x00 + DWORD dwColor; //0x04 +}; + +struct cTextPrefs +{ + DWORD dwPosX; //0x00 + DWORD dwPosY; //0x04 + DWORD dwSizeY; //0x08 +}; + + +struct ControlText // size = 0x20 +{ + wchar_t* wText[5]; //0x00 for each field + DWORD dwColor; //0x14 + DWORD dwAlign; //0x18 + ControlText* pNext; //0x1C +}; + +struct ControlMsg { + Control *pControl; + UINT uMsg; + WPARAM wParam; +}; + +struct Control { + DWORD dwType; //0x00 + CellFile *pCellFile; //0x04 + DWORD dwState; //0x08 0x05 - enabled, 0x04 - disabled, 0x03-0x00 - not visible + DWORD dwPosX; //0x0C + DWORD dwPosY; //0x10 + DWORD dwSizeX; //0x14 + DWORD dwSizeY; //0x18 + BOOL(__fastcall *Draw)(Control*); //0x1C + BOOL(__fastcall *DrawEx)(Control*); //0x20 used by timer/popup + BOOL(__stdcall *Push)(ControlMsg*); //0x24 + BOOL(__stdcall *Mouse)(ControlMsg*); //0x28 + BOOL(__stdcall *ListCheck)(ControlMsg*); //0x2C used only by list + BOOL(__stdcall *Key)(ControlMsg*); //0x30 WM_CHAR MSG + BOOL(__stdcall *OnPress)(Control*); //0x34 User Defined + BOOL(__fastcall*DrawAnim)(Control*); //0x38 used by animimage + Control* pNext; //0x3C +}; + +struct EditBox : Control //(size 0x284) +{ + // Control Header; //0x00 + DWORD dwLeftOffset; //0x40 + DWORD dwTopOffset; //0x44 + DWORD dwMaxLength; //0x48 + DWORD dwTextOffset; //0x4C + DWORD dwTextLen; //0x50 (strlen -1) + DWORD dwSelectEnd; //0x54 + DWORD dwSelectStart; //0x58 + wchar_t wText[256]; //0x5C + DWORD dwCursorPos; //0x25C + DWORD dwEditFlags; //0x260 0x08 allows multiline + BOOL(__stdcall *OnAccept)(char*); //0x264 + BOOL(__stdcall *InputHandle)(Control*, DWORD len, char* Key); //0x268 + BOOL(__stdcall *LengthHandle)(int aNull); //0x26C hmm weird arg = always 0 + cStylePrefs Style; //0x270 + Control * pTabNext; //0x278 + Control * pTabPrev; //0x27C + BOOL bLeftButtonPressed; //0x280 +}; + +struct TextBox : Control // (size 0xAC) +{ + // Control Header; //0x00 + DWORD dwLeftOffset; //0x40 + DWORD dwTopOffset; //0x44 + ControlText* pFirstText; //0x48 + ControlText* pLastText; //0x4C + ControlText* pSelectedText; //0x50 + DWORD dwMaxLines; //0x54 + DWORD dwCurrentLine; //0x58 + DWORD dwTextFlags; //0x5C 0x00 - left align 0x01 - SelectBox 0x2 - center 0x4 Create ScrollBar 0x40 - scrolling from right 0x80 - scrolling from bottom + DWORD dwSelectedItem; //0x60 + DWORD dwFields; //0x64 + DWORD dwFieldXSize[5]; //0x68 for each field + DWORD dwFieldAlign[5]; //0x7C + ScrollBar* ptScrollBar; //0x90 + cStylePrefs Style; //0x94 + DWORD dwMaxTextWidth; //0x9C + DWORD dwMaxTextHeight; //0xA0 + DWORD dwInterline; //0xA4 + DWORD dwInterline2; //0xA8 +}; + +struct Image : Control // (size 0x4C) +{ + // Control Header; //0x00 + DWORD CellFrame; //0x40 + DWORD TransLvl; //0x44 + void* _1; //0x48 image struct? +}; + +struct AnimImage : Control // 0x60 +{ + // Control Header; //0x00 + void* AnimStruct; //0x40 pointer to struct which holds all cellfile frames + DWORD dwAnimSpeed; //0x44 + DWORD dwTickCount; //0x48 creation time + DWORD dwCurrentFrame; //0x4C + BOOL bisHovered; //0x50 + DWORD dwTransLvl; //0x54 + void(__stdcall *OnHover)(AnimImage*); //0x58 + BOOL bisAnimation; //0x5C +}; + +struct Button : Control // (size 0x274) +{ + // Control Header; //0x00 + DWORD dwButtonFlags; //0x40 0x00 - normal 0x01 - radio 0x02 - switch 0x04 - play sound 0x20 - sth with disabled/enabled 0x40 - multi line + DWORD dwIsPushed; //0x44 + BOOL dwIsSwitched; //0x48 + BOOL _1; //0x4C + DWORD dwHotKey; //0x50 + DWORD dwButtonType; //0x54 0x00 - Normal Button, 0x01 - Switch Button 0x02 - Long Button + DWORD _2; //0x58 + DWORD dwCellFrame; //0x5C + DWORD dwFont; //0x60 hardcoded + wchar_t wText[256]; //0x64 + DWORD dwColor; //0x264 hardcoded + BOOL(__stdcall *OnHover)(Button*); //0x268 + BOOL bisHovered; //0x26C + DWORD dwStrTbl2ndLine; //0x270 +}; + +struct ScrollBar : Control // (size 0x60) +{ + // Control Header; //0x00 + BOOL bMovedUp; //0x40 + BOOL bMovedDown; //0x44 + DWORD dwScrollEntries; //0x48 + DWORD dwScrollPosition; //0x4C + DWORD dwClickStep; //0x50 + TextBox * ptParent; //0x54 + BOOL bLeftButtonPressed; //0x58 + BOOL(__stdcall *Unk)(ControlMsg*); //0x5C +}; + +struct List : Control // (size 0x6C) +{ + // Control Header; //0x00 + DWORD dwFont; //0x40 + DWORD _2; //0x44 + DWORD _3; //0x48 + DWORD _4; //0x4C + DWORD _5; //0x50 + DWORD _6; //0x54 + DWORD _7; //0x58 + DWORD _8; //0x5C + DWORD _9; //0x60 + DWORD*_10; //0x64 + DWORD _11; //0x68 +}; + +struct D2Menu // size 0x18 +{ + DWORD dwEntriesNo; //0x00 + DWORD dwInterline; //0x04 + DWORD dwTextHeight; //0x08 + DWORD dwMenuOffset; //0x0C + DWORD dwBarHeight; //0x10 + DWORD _1; //0x14 unused? +}; + +struct D2MenuEntry //size 0x550 +{ + DWORD dwMenuType; //0x00 //-1 - static text, 0 -selectable, 1- switchbar , 2- with bar, 3 - key config (added) + DWORD dwExpansion; //0x04 //if set, shows only in d2exp + DWORD dwYOffset; //0x08 //generated dynamicaly + union { + char szCellFile[260]; //0x0C DATA\\LOCAL\\UI\\LANG\\%s used only in LoadMenu Func + wchar_t wItemName[130]; //my addition + }; + BOOL(__fastcall* EnableCheck)(D2MenuEntry*, DWORD ItemNo); //0x110 if return false, its disabled + BOOL(__fastcall* OnPress)(D2MenuEntry*, StormMsg*); //0x114 28.12.11 - added StormMsg* + BOOL(__fastcall* OptionHandle)(D2MenuEntry*); //0x118 called when option value is changed + BOOL(__fastcall* ChangeHandle)(D2MenuEntry*); //0x11C if return true OnPress is called, and option gfx is switched + union { + DWORD dwMaxValue; //0x120 + DWORD dwSwitchesNo; //0x120 (max 4) + DWORD* Bind; //0x120 -> KeyConfig (my add) + }; + union { + DWORD dwCurrentValue; //0x124 + DWORD dwCurrentSwitch; + DWORD dwColor; //my addition ONLY for MenuType = -1, 1, 3(?) + }; + union { + DWORD dwBarType; //0x128 + DWORD dwFontType; //my add valid for all + }; + union { + char szSwitchCellFiles[4][260]; //0x12C DATA\\LOCAL\\UI\\LANG\\%s used only in LoadMenu Func + wchar_t wSwitchItemName[4][130]; //my addition + }; + CellFile* ptCellFile; //0x53C + CellFile* ptSwitchCellFile[4]; //0x540 +}; + + +#endif \ No newline at end of file diff --git a/Constants.h b/Constants.h index 66a67bd..fecf77a 100644 --- a/Constants.h +++ b/Constants.h @@ -5,12 +5,28 @@ enum D2VideoModes { VIDEO_MODE_GDI = 1, + VIDEO_MODE_RAVE = 2, // UNUSED VIDEO_MODE_DDRAW = 3, VIDEO_MODE_GLIDE = 4, VIDEO_MODE_OPENGL = 5, // UNUSED VIDEO_MODE_D3D = 6 }; + +/* + Game modes set by cmdline parameter -client, -server etc... + Causes game loads specific dll instead of default D2Launch.dll +*/ +enum D2GameModes +{ + GAME_MODE_MODSTATE0 = 0, // "none.dll" + GAME_MODE_CLIENT = 1, // "D2Client.dll" + GAME_MODE_SERVER = 2, // "D2Server.dll" + GAME_MODE_MULTIPLAYER = 3, // "D2Multi.dll" + GAME_MODE_LAUNCHER = 4, // "D2Launch.dll" + GAME_MODE_EXPAND = 5 // "D2EClient.dll" +}; + enum UICover { COVER_NONE = 0, diff --git a/D2Ex2.cpp b/D2Ex2.cpp index 533f1f0..9284a0a 100644 --- a/D2Ex2.cpp +++ b/D2Ex2.cpp @@ -324,7 +324,6 @@ if (!ExMultiRes::InitImages()) { D2EXERROR("One or more D2Ex resources weren't loaded. Check if your D2Ex2.MPQ is valid!"); } -Misc::WriteDword(*(DWORD**)&D2Vars::D2GFX_Helpers, (DWORD)&ExMultiRes::FillYBufferTable); //END PATCHES----------------------------------------------------------------------------------- @@ -476,20 +475,32 @@ DWORD WINAPI DllMain(HMODULE hModule, int dwReason, void* lpReserved) #ifdef D2EX_EXAIM_ENABLED InitializeCriticalSectionAndSpinCount(&TELE_CRITSECT,1000); #endif - - /* switch (*D2Vars::D2GFX_DriverType) + Misc::Patch(JUMP, GetDllOffset("D2Gfx.dll", -10073), (DWORD)ExMultiRes::InitWindow, 7, "D2GFX_InitWindow"); + ; + Misc::WriteDword((DWORD*)&((GFXHelpers*)GetDllOffset("D2Gfx.dll", 0x10BFC))->FillYBufferTable, (DWORD)&ExMultiRes::FillYBufferTable); + switch (ExMultiRes::GetRenderMode()) { - case VIDEO_MODE_GDI: - {*/ - typedef fnDriverCallbacks* (__fastcall * GetCallbacks_t)(); - GetCallbacks_t GetCallbacks = (GetCallbacks_t)GetDllOffset("D2Gdi.dll", -10000); - fnDriverCallbacks * fns = GetCallbacks(); - - Misc::WriteDword((DWORD*)&(fns->Init), (DWORD)&ExMultiRes::GDI_Init); - Misc::WriteDword((DWORD*)&(fns->ResizeWin), (DWORD)&ExMultiRes::GDI_ResizeWindow); - //} - // break; - //} + case VIDEO_MODE_GDI: + { + DEBUGMSG("Using GDI video mode") + typedef fnDriverCallbacks* (__stdcall * GetCallbacks_t)(); + GetCallbacks_t GetCallbacks = (GetCallbacks_t)GetDllOffset("D2Gdi.dll", -10000); + fnDriverCallbacks * fns = GetCallbacks(); + + Misc::WriteDword((DWORD*)&(fns->Init), (DWORD)&ExMultiRes::GDI_Init); + Misc::WriteDword((DWORD*)&(fns->ResizeWin), (DWORD)&ExMultiRes::GDI_ResizeWindow); + } + break; + case VIDEO_MODE_GLIDE: + { + DEBUGMSG("Using GLIDE video mode!") + } + default: + { + DEBUGMSG("Video mode : %d", ExMultiRes::GetRenderMode()) + } + break; + } Handle = (HANDLE)_beginthreadex(0,0,&Thread,&hEvent,0,&Id); ASSERT(Handle) diff --git a/D2Ex2.vcxproj b/D2Ex2.vcxproj index 252a0e1..40db63e 100644 --- a/D2Ex2.vcxproj +++ b/D2Ex2.vcxproj @@ -44,7 +44,9 @@ $(SolutionDir)$(Configuration)\ $(Configuration)\ false - C:\boost_1_55_0;$(IncludePath) + C:\boost_1_55_0;C:\glfw-3.0.4.bin.WIN32\include;$(IncludePath) + $(ReferencePath) + C:\glfw-3.0.4.bin.WIN32\lib-msvc120;$(LibraryPath) $(SolutionDir)files\ @@ -154,6 +156,7 @@ + diff --git a/D2Ex2.vcxproj.filters b/D2Ex2.vcxproj.filters index 462928f..feb26f1 100644 --- a/D2Ex2.vcxproj.filters +++ b/D2Ex2.vcxproj.filters @@ -289,5 +289,8 @@ Header Files\Main + + Header Files\D2 Internals + \ No newline at end of file diff --git a/D2Ptrs_113D.h b/D2Ptrs_113D.h index 6ee3790..3dd530f 100644 --- a/D2Ptrs_113D.h +++ b/D2Ptrs_113D.h @@ -274,7 +274,11 @@ D2VARPTR(D2GFX, gpbBuffer, void*, 0x14320) D2VARPTR(D2GFX, Width, int, 0x14324) D2VARPTR(D2GFX, Height, int, 0x14328) D2VARPTR(D2GFX, ScreenShift, int, 0x14A50) -D2VARPTR(D2GFX, Helpers, DWORD*, 0x10BFC) // table of 7 functions +D2VARPTR(D2GFX, fnHelpers, GFXHelpers, 0x10BFC) // table of 7 functions +D2VARPTR(D2GFX, Settings, GFXSettings, 0x10BE4) +D2VARPTR(D2GFX, hInstance, HINSTANCE, 0x14A30) +D2VARPTR(D2GFX, hDriverModHandle, HMODULE, 0x14A4C) +D2VARPTR(D2GFX, bPerspective, BOOL, 0x10BE8) D2VARPTR(D2GDI, WindowWidth, int, 0xCA98) D2VARPTR(D2GDI, BitmapHeight, int, 0xC980) diff --git a/D2Structs_111B.h b/D2Structs_111B.h index 0a36356..fd11e01 100644 --- a/D2Structs_111B.h +++ b/D2Structs_111B.h @@ -42,191 +42,6 @@ struct List; struct Arena; struct CellContext; -struct fnDriverCallbacks -{ - BOOL(__fastcall *InitWindow)(HINSTANCE); // 0 - BOOL(__fastcall *InitPerspective)(int * fPerspective, int * _1); // 1 - BOOL(__fastcall *Release)(); // 2 - BOOL(__fastcall *Init)(HANDLE hWnd, int nResolution); // 3 - BOOL(__fastcall *Shutdown)(); // 4 - BOOL(__fastcall *EndCutscene)(HANDLE hWnd, int nResolution, int); // 5 - BOOL(__fastcall *BeginScene)(BOOL bClear, BYTE nRed, BYTE nGreen, BYTE nBlue); // 6 - BOOL(__fastcall *EndScene1)(); // 7 - BOOL(__fastcall *EndScene2)(); // 8 - BOOL(__fastcall *ResizeWin)(HANDLE HWND, int bResolution); // 9 - BOOL(__fastcall *GetBackBuffer)(BYTE* pBuffer); // 10 - BOOL(__fastcall *ActivateWindow)(int Unk, int Contrast); // 11 - BOOL(__fastcall *SetOption)(int nOption, int nValue); // 12 - BOOL(__fastcall *BeginCutscene)(); // 13 - BOOL(__fastcall *PlayCutscene)(const char* szFile, int nResolution, void *pfframe); // 14 - BOOL(__fastcall *CheckCutscene)(); // 15 - BOOL(__fastcall *DecodeSmacker)(const char *szsmacker, BYTE *pbuffer, int nVersion); // 16 - BOOL(__fastcall *PlaySmacker)(void *pcontext); // 17 - BOOL(__fastcall *CloseSmacker)(void *pcontext); // 18 - int(__fastcall *GetRenderStats)(); // 19 - void(__fastcall *GetScreenSize)(int *pwidth, int *pheight); // 20 - BOOL(__fastcall *SetScaleFactor)(); // 21 - BOOL(__fastcall *SetGamma)(int nGamma); // 22 - BOOL(__fastcall *CheckGamma)(); // 23 - BOOL(__fastcall *SetPerspectiveScale)(); // 24 - BOOL(__fastcall *AdjustPerspective)(int nXpos, int nYpos, int nBais, int *pxadjust, int *pyadjust); // 25 - BOOL(__fastcall *ScalePerspectivepos)(int nXpos, int nYpos, int nAngle, int *pxpos, int *pypos, BOOL bOrder); // 26 - BOOL(__fastcall *SetDefperspectivefactor)(); // 27 - BOOL(__fastcall *SetPalette)(BYTE* pPalette); // 28 - BOOL(__fastcall *SetPalettetable)(BYTE** pPalette); // 29 - BOOL(__fastcall *SetGlobalLight)(BYTE nRed, BYTE nGreen, BYTE nBlue); // 30 - BOOL(__fastcall *DrawGroundTile)(void* pTile, DWORD** pLight, int nXpos, int nYpos, int nWorldXpos, int nWorldYpos, BYTE nAlpha, int nScreenPanels, void* pTileData); // 31 - BOOL(__fastcall *DrawPerspectiveImage)(CellContext* pData, int nXpos, int nYpos, DWORD dwGamma, int nDrawMode, int nScreenMode, BYTE* pPalette); // 32 - BOOL(__fastcall *DrawImage)(CellContext* pData, int nXpos, int nYpos, DWORD dwGamma, int nDrawMode, BYTE* pPalette); // 33 - BOOL(__fastcall *DrawShiftedImage)(CellContext* pData, int nXpos, int nYpos, DWORD dwGamma, int nDrawMode, int nGlobalPaletteShift); // 34 - BOOL(__fastcall *DrawVerticalCropImage)(CellContext* pData, int nXpos, int nYpos, int nSkipLines, int nDrawLines, int nDrawMode); // 35 - BOOL(__fastcall *DrawShadows)(CellContext* pData, int nXpos, int nYpos); // 36 - BOOL(__fastcall *DrawImageFast)(CellContext* pData, int nXpos, int nYpos, BYTE nPaletteIndex); // 37 - BOOL(__fastcall *DrawClippedImage)(CellContext* pData, int nXpos, int nYpos, void* pCropRect, int nDrawMode); // 38 - BOOL(__fastcall *DrawWallTile)(void* pTile, int nXpos, int nYpos, DWORD** pLight, int nScreenPanels, BYTE nAlpha); // 39 - BOOL(__fastcall *DrawRoofTile)(void* pTile, int nXpos, int nYpos, DWORD** pLight, int nScreenPanels, BYTE nAlpha); // 40 - BOOL(__fastcall *DrawVisTile)(void* pTile, int nXpos, int nYpos, int nDrawMode, int nScreenPanels); // 41 - BOOL(__fastcall *DrawRect)(RECT *Prect, BYTE nPaletteIndex); // 42 - BOOL(__fastcall *DrawRectEx)(RECT *Prect, BYTE nPaletteIndex); // 43 - BOOL(__fastcall *DrawSolidRect)(RECT *Prect, BYTE nPaletteIndex); // 44 - BOOL(__fastcall *DrawSolidSquare)(RECT *Prect, BYTE nPaletteIndex, int nSize); // 45 - BOOL(__fastcall *DrawSolidRectEx)(int nXStart, int nYStart, int nXEnd, int nYEnd, DWORD dwColor, int nDrawMode); // 46 - BOOL(__fastcall *DrawSolidRectAlpha)(int nXStart, int nYStart, int nXEnd, int nYEnd, DWORD dwColor, BYTE nAlpha); // 47 - BOOL(__fastcall *DrawLine)(int nXStart, int nYStart, int nXEnd, int nYEnd, BYTE nColor, BYTE nAlpha); // 48 - BOOL(__fastcall *ClearScreen)(BOOL bPartial); // 49 - BOOL(__fastcall *DrawString)(int nXpos, int nYpos, const char *Szformat, ...); // 50 - BOOL(__fastcall *DrawLight)(DWORD *plight, DWORD *pplayerlight, int nXpos, int nYpos); // 51 - BOOL(__fastcall *DebugFillBackBuffer)(int xPos, int yPos); // 52 - BOOL(__fastcall *ClearCaches)(); // 53 -}; - -struct D2RECT -{ - DWORD left; - DWORD top; - DWORD right; - DWORD bottom; -}; - -#pragma pack(push, 1) -struct GameView -{ - DWORD dwFlags; - D2RECT ViewRadius; - D2RECT ToCheck; - DWORD _1; - DWORD _2; - DWORD _3; - DWORD _4; - DWORD _5; - DWORD _6; - BYTE _7[60000]; - DWORD _8; - BYTE _9[8]; - DWORD _10; - BYTE _11[4]; - DWORD _12; - DWORD _13[2]; -}; -#pragma pack(pop) - -struct ItemConfig -{ - int Code; - int Quality; - int Color; - int Type; -}; - -struct PacketData -{ - DWORD ClientID; - BYTE aPacket[510]; -}; - -struct COORDS -{ - unsigned short x; - unsigned short y; -}; - -#pragma pack(push, 1) - -struct KeyBinding //size 0xA -{ - DWORD nHotkey; // 0x00 - WORD wKey; // 0x04 - BOOL bPrimary;// 0x06 -}; - -struct KeyConfigEntry //size 0xA -{ - DWORD dwEntryNo; //0x00 - WORD wLocaleNo; //0x04 - wchar_t* wText; //0x06 -}; - -struct StormMsg -{ - HWND hWnd; - UINT Msg; - WPARAM wParam; - LPARAM lParam; - DWORD hiWParam16; // wParam shifted by 16 - BOOL _1; - BOOL _2; - BOOL _3; -}; - - -struct sMsg //size 0x0C -{ - DWORD MsgType; //0x00 ,0 = WM_MSG , 1 = COMMAND(?), 2 = KEY_UP, 3 = KEY_DOWN - union { - WPARAM wParam; //0x04 - DWORD wKey; //0x04 - }; - void(__stdcall *fnCallBack)(StormMsg *); //0x08 -}; - -#pragma pack(pop) - - -struct UiCallArray -{ - void(__cdecl *OnKeyDown)(); - void(__cdecl *OnKeyUp)(); - BOOL bOverride; -}; - - -struct SpellStrc //size 0x1C // Valid for 22 -> on target & 21 -> on xy -{ - DWORD SkillId; //0x00 - DWORD UnitId; //0x04 - DWORD xPos; //0x08 //Also TargetType - DWORD yPos; //0x0C //Also TargetId - DWORD _1; //0x10 - DWORD _2; //0x14 - DWORD _3; //0x18 -}; - -struct BitBuffer -{ - unsigned char *pBuffer; //0x00 - unsigned int bitsInBuffer; //0x04 - unsigned int bufferPos; //0x08 - unsigned int bitsAtPos; //0x0C num bits already read or written at cur pos - unsigned int unk; //0x10 could be a bit bucket -}; - - -struct COORDS -{ - unsigned short x; - unsigned short y; -}; - struct RoomTile { DWORD _1; //0x00 @@ -235,59 +50,9 @@ struct RoomTile { DWORD *nNum; //0x0C }; -struct SpellStrc //size 0x1C // Valid for 22 -> on target & 21 -> on xy -{ - DWORD SkillId; //0x00 - DWORD UnitId; //0x04 - DWORD xPos; //0x08 //Also TargetType - DWORD yPos; //0x0C //Also TargetId - DWORD _1; //0x10 - DWORD _2; //0x14 - DWORD _3; //0x18 -}; - -struct CollMap { - DWORD dwPosGameX; //0x00 - DWORD dwPosGameY; //0x04 - DWORD dwSizeGameX; //0x08 - DWORD dwSizeGameY; //0x0C - DWORD dwPosRoomX; //0x10 - DWORD dwPosRoomY; //0x14 - DWORD dwSizeRoomX; //0x18 - DWORD dwSizeRoomY; //0x1C - WORD *pMapStart; //0x20 - WORD *pMapEnd; //0x22 -}; #pragma pack(push, 1) -struct KeyBinding //size 0xA -{ - DWORD nHotkey; // 0x00 - WORD wKey; // 0x04 - BOOL bPrimary;// 0x06 -}; - -struct KeyConfigEntry //size 0xA -{ - DWORD dwEntryNo; //0x00 - WORD wLocaleNo; //0x04 - wchar_t* wText; //0x06 -}; - -struct StormMsg -{ - HWND hWnd; - UINT Msg; - WPARAM wParam; - LPARAM lParam; - DWORD hiWParam16; // wParam shifted by 16 - BOOL _1; - BOOL _2; - BOOL _3; -}; - - struct StaticPath // size 0x20 { Room1 *pRoom1; //0x00 @@ -299,32 +64,6 @@ struct StaticPath // size 0x20 DWORD dwFlags; //0x1C }; -struct sMsg //size 0x0C -{ - DWORD MsgType; //0x00 ,0 = WM_MSG , 1 = COMMAND(?), 2 = KEY_UP, 3 = KEY_DOWN - union { - WPARAM wParam; //0x04 - DWORD wKey; //0x04 - }; - void (__stdcall *fnCallBack)(StormMsg *); //0x08 -}; - -#pragma pack(pop) - -struct pMsg -{ - pMsg* pMsgNext; - BYTE aPacket[510]; -}; - -struct D2PacketTable //(0x6FB8BC30 + (4 *(0xPacket*3))) -{ - BOOL (__fastcall *CallBack)(BYTE* aPacket); - int PacketLen; - BOOL (__fastcall *CallBack2)(UnitAny * ptUnit, BYTE* aPacket); -}; - - struct HoverText //size 0x110 { DWORD dwDisplayTime; //0x00 8 * strlen + 125 @@ -831,14 +570,14 @@ struct BnetData DWORD Unk2; //0x10 DWORD Id3; //0x14 WORD Unk3; //0x18 - char GameName[22]; //0x1A - char GameIp[16]; //0x30 + char szGameName[22]; //0x1A + char szGameIp[16]; //0x30 DWORD Unk4[16]; //0x40 DWORD Id4; //0x80 DWORD Unk6; //0x84 - char AccountName[48]; //0x88 - char PlayerName[24]; //0xB8 - char RealmName[8]; //0xD0 + char szAccountName[48]; //0x88 + char szPlayerName[24]; //0xB8 + char szRealmName[8]; //0xD0 BYTE Unk7[273]; //0xD8 BYTE CharType; //0x1E9 00 - 06 BYTE CharFlags; //0x1EA LoD, Ladder, Hc Flags + 4 Unk @@ -853,9 +592,9 @@ struct BnetData BYTE Unk12; //0x223 WORD Unk13; //0x224 BYTE Unk14; //0x226 - char RealmName2[24]; //0x227 - char GamePass[24]; //0x23F - char GameDesc[32]; //0x257 + char szRealmName2[24]; //0x227 + char szGamePass[24]; //0x23F + char szGameDesc[32]; //0x257 }; @@ -964,211 +703,6 @@ struct RosterUnit { RosterUnit * pNext; //0x80 }; -struct cStylePrefs -{ - DWORD dwFontType; //0x00 - DWORD dwColor; //0x04 -}; - -struct cTextPrefs -{ - DWORD dwPosX; //0x00 - DWORD dwPosY; //0x04 - DWORD dwSizeY; //0x08 -}; - - -struct ControlText // size = 0x20 - { - wchar_t* wText[5]; //0x00 for each field - DWORD dwColor; //0x14 - DWORD dwAlign; //0x18 - ControlText* pNext; //0x1C -}; - -struct ControlMsg { -Control *pControl; -UINT uMsg; -WPARAM wParam; -}; - -struct Control { - DWORD dwType; //0x00 - CellFile *pCellFile; //0x04 - DWORD dwState; //0x08 0x05 - enabled, 0x04 - disabled, 0x03-0x00 - not visible - DWORD dwPosX; //0x0C - DWORD dwPosY; //0x10 - DWORD dwSizeX; //0x14 - DWORD dwSizeY; //0x18 - BOOL (__fastcall *Draw)(Control*); //0x1C - BOOL (__fastcall *DrawEx)(Control*); //0x20 used by timer/popup - BOOL (__stdcall *Push)(ControlMsg*); //0x24 - BOOL (__stdcall *Mouse)(ControlMsg*); //0x28 - BOOL (__stdcall *ListCheck)(ControlMsg*); //0x2C used only by list - BOOL (__stdcall *Key)(ControlMsg*); //0x30 WM_CHAR MSG - BOOL (__stdcall *OnPress)(Control*); //0x34 User Defined - BOOL (__fastcall*DrawAnim)(Control*); //0x38 used by animimage - Control* pNext; //0x3C -}; - -struct EditBox : Control //(size 0x284) -{ -// Control Header; //0x00 - DWORD dwLeftOffset; //0x40 - DWORD dwTopOffset; //0x44 - DWORD dwMaxLength; //0x48 - DWORD dwTextOffset; //0x4C - DWORD dwTextLen; //0x50 (strlen -1) - DWORD dwSelectEnd; //0x54 - DWORD dwSelectStart; //0x58 - wchar_t wText[256]; //0x5C - DWORD dwCursorPos; //0x25C - DWORD dwEditFlags; //0x260 0x08 allows multiline - BOOL (__stdcall *OnAccept)(char*); //0x264 - BOOL (__stdcall *InputHandle)(Control*,DWORD len, char* Key); //0x268 - BOOL (__stdcall *LengthHandle)(int aNull); //0x26C hmm weird arg = always 0 - cStylePrefs Style; //0x270 - Control * pTabNext; //0x278 - Control * pTabPrev; //0x27C - BOOL bLeftButtonPressed; //0x280 -}; - -struct TextBox : Control // (size 0xAC) -{ -// Control Header; //0x00 - DWORD dwLeftOffset; //0x40 - DWORD dwTopOffset; //0x44 - ControlText* pFirstText; //0x48 - ControlText* pLastText; //0x4C - ControlText* pSelectedText; //0x50 - DWORD dwMaxLines; //0x54 - DWORD dwCurrentLine; //0x58 - DWORD dwTextFlags; //0x5C 0x00 - left align 0x01 - SelectBox 0x2 - center 0x4 Create ScrollBar 0x40 - scrolling from right 0x80 - scrolling from bottom - DWORD dwSelectedItem; //0x60 - DWORD dwFields; //0x64 - DWORD dwFieldXSize[5]; //0x68 for each field - DWORD dwFieldAlign[5]; //0x7C - ScrollBar* ptScrollBar; //0x90 - cStylePrefs Style; //0x94 - DWORD dwMaxTextWidth; //0x9C - DWORD dwMaxTextHeight; //0xA0 - DWORD dwInterline; //0xA4 - DWORD dwInterline2; //0xA8 -}; - -struct Image : Control // (size 0x4C) -{ -// Control Header; //0x00 - DWORD CellFrame; //0x40 - DWORD TransLvl; //0x44 - void* _1; //0x48 image struct? -}; - -struct AnimImage : Control // 0x60 -{ -// Control Header; //0x00 - void* AnimStruct; //0x40 pointer to struct which holds all cellfile frames - DWORD dwAnimSpeed; //0x44 - DWORD dwTickCount; //0x48 creation time - DWORD dwCurrentFrame; //0x4C - BOOL bisHovered; //0x50 - DWORD dwTransLvl; //0x54 - void (__stdcall *OnHover)(AnimImage*); //0x58 - BOOL bisAnimation; //0x5C -}; - -struct Button : Control // (size 0x274) -{ -// Control Header; //0x00 - DWORD dwButtonFlags; //0x40 0x00 - normal 0x01 - radio 0x02 - switch 0x04 - play sound 0x20 - sth with disabled/enabled 0x40 - multi line - DWORD dwIsPushed; //0x44 - BOOL dwIsSwitched; //0x48 - BOOL _1; //0x4C - DWORD dwHotKey; //0x50 - DWORD dwButtonType; //0x54 0x00 - Normal Button, 0x01 - Switch Button 0x02 - Long Button - DWORD _2; //0x58 - DWORD dwCellFrame; //0x5C - DWORD dwFont; //0x60 hardcoded - wchar_t wText[256]; //0x64 - DWORD dwColor; //0x264 hardcoded - BOOL (__stdcall *OnHover)(Button*); //0x268 - BOOL bisHovered; //0x26C - DWORD dwStrTbl2ndLine; //0x270 -}; - -struct ScrollBar : Control // (size 0x60) -{ -// Control Header; //0x00 - BOOL bMovedUp; //0x40 - BOOL bMovedDown; //0x44 - DWORD dwScrollEntries; //0x48 - DWORD dwScrollPosition; //0x4C - DWORD dwClickStep; //0x50 - TextBox * ptParent; //0x54 - BOOL bLeftButtonPressed; //0x58 - BOOL (__stdcall *Unk)(ControlMsg*); //0x5C -}; - -struct List : Control // (size 0x6C) -{ -// Control Header; //0x00 - DWORD dwFont; //0x40 - DWORD _2; //0x44 - DWORD _3; //0x48 - DWORD _4; //0x4C - DWORD _5; //0x50 - DWORD _6; //0x54 - DWORD _7; //0x58 - DWORD _8; //0x5C - DWORD _9; //0x60 - DWORD*_10; //0x64 - DWORD _11; //0x68 -}; - -struct D2Menu // size 0x18 -{ -DWORD dwEntriesNo; //0x00 -DWORD dwInterline; //0x04 -DWORD dwTextHeight; //0x08 -DWORD dwMenuOffset; //0x0C -DWORD dwBarHeight; //0x10 -DWORD _1; //0x14 unused? -}; - -struct D2MenuEntry //size 0x550 -{ - DWORD dwMenuType; //0x00 //-1 - static text, 0 -selectable, 1- switchbar , 2- with bar, 3 - key config (added) - DWORD dwExpansion; //0x04 //if set, shows only in d2exp - DWORD dwYOffset; //0x08 //generated dynamicaly - union { - char szCellFile[260]; //0x0C DATA\\LOCAL\\UI\\LANG\\%s used only in LoadMenu Func - wchar_t wItemName[130]; //my addition - }; - BOOL (__fastcall* EnableCheck)(D2MenuEntry*, DWORD ItemNo); //0x110 if return false, its disabled - BOOL (__fastcall* OnPress)(D2MenuEntry*, StormMsg*); //0x114 28.12.11 - added StormMsg* - BOOL (__fastcall* OptionHandle)(D2MenuEntry*); //0x118 called when option value is changed - BOOL (__fastcall* ChangeHandle)(D2MenuEntry*); //0x11C if return true OnPress is called, and option gfx is switched - union { - DWORD dwMaxValue; //0x120 - DWORD dwSwitchesNo; //0x120 (max 4) - DWORD* Bind; //0x120 -> KeyConfig (my add) - }; - union { - DWORD dwCurrentValue; //0x124 - DWORD dwCurrentSwitch; - DWORD dwColor; //my addition ONLY for MenuType = -1, 1, 3(?) - }; - union { - DWORD dwBarType; //0x128 - DWORD dwFontType; //my add valid for all - }; - union { - char szSwitchCellFiles[4][260]; //0x12C DATA\\LOCAL\\UI\\LANG\\%s used only in LoadMenu Func - wchar_t wSwitchItemName[4][130]; //my addition - }; - CellFile* ptCellFile; //0x53C - CellFile* ptSwitchCellFile[4]; //0x540 -}; #endif \ No newline at end of file diff --git a/D2Structs_113D.h b/D2Structs_113D.h index 8729576..20b8989 100644 --- a/D2Structs_113D.h +++ b/D2Structs_113D.h @@ -2,7 +2,6 @@ #define D2STRUCTS_H__ #include "D2DataTables.h" - struct UnitAny; struct ClientInfo; struct PlayerData; @@ -40,206 +39,10 @@ struct List; struct Arena; struct pMsg; struct QuestFlags; +struct CollMap; struct CellContext; -struct fnDriverCallbacks -{ - BOOL(__fastcall *InitWindow)(HINSTANCE); // 0 - BOOL(__fastcall *InitPerspective)(int * fPerspective, int * _1); // 1 - BOOL(__fastcall *Release)(); // 2 - BOOL(__fastcall *Init)(HANDLE hWnd, int nResolution); // 3 - BOOL(__fastcall *Shutdown)(); // 4 - BOOL(__fastcall *EndCutscene)(HANDLE hWnd, int nResolution, int); // 5 - BOOL(__fastcall *BeginScene)(BOOL bClear, BYTE nRed, BYTE nGreen, BYTE nBlue); // 6 - BOOL(__fastcall *EndScene1)(); // 7 - BOOL(__fastcall *EndScene2)(); // 8 - BOOL(__fastcall *ResizeWin)(HANDLE HWND, int bResolution); // 9 - BOOL(__fastcall *GetBackBuffer)(BYTE* pBuffer); // 10 - BOOL(__fastcall *ActivateWindow)(int Unk, int Contrast); // 11 - BOOL(__fastcall *SetOption)(int nOption, int nValue); // 12 - BOOL(__fastcall *BeginCutscene)(); // 13 - BOOL(__fastcall *PlayCutscene)(const char* szFile, int nResolution, void *pfframe); // 14 - BOOL(__fastcall *CheckCutscene)(); // 15 - BOOL(__fastcall *DecodeSmacker)(const char *szsmacker, BYTE *pbuffer, int nVersion); // 16 - BOOL(__fastcall *PlaySmacker)(void *pcontext); // 17 - BOOL(__fastcall *CloseSmacker)(void *pcontext); // 18 - int(__fastcall *GetRenderStats)(); // 19 - void(__fastcall *GetScreenSize)(int *pwidth, int *pheight); // 20 - BOOL(__fastcall *SetScaleFactor)(); // 21 - BOOL(__fastcall *SetGamma)(int nGamma); // 22 - BOOL(__fastcall *CheckGamma)(); // 23 - BOOL(__fastcall *SetPerspectiveScale)(); // 24 - BOOL(__fastcall *AdjustPerspective)(int nXpos, int nYpos, int nBais, int *pxadjust, int *pyadjust); // 25 - BOOL(__fastcall *ScalePerspectivepos)(int nXpos, int nYpos, int nAngle, int *pxpos, int *pypos, BOOL bOrder); // 26 - BOOL(__fastcall *SetDefperspectivefactor)(); // 27 - BOOL(__fastcall *SetPalette)(BYTE* pPalette); // 28 - BOOL(__fastcall *SetPalettetable)(BYTE** pPalette); // 29 - BOOL(__fastcall *SetGlobalLight)(BYTE nRed, BYTE nGreen, BYTE nBlue); // 30 - BOOL(__fastcall *DrawGroundTile)(void* pTile, DWORD** pLight, int nXpos, int nYpos, int nWorldXpos, int nWorldYpos, BYTE nAlpha, int nScreenPanels, void* pTileData); // 31 - BOOL(__fastcall *DrawPerspectiveImage)(CellContext* pData, int nXpos, int nYpos, DWORD dwGamma, int nDrawMode, int nScreenMode, BYTE* pPalette); // 32 - BOOL(__fastcall *DrawImage)(CellContext* pData, int nXpos, int nYpos, DWORD dwGamma, int nDrawMode, BYTE* pPalette); // 33 - BOOL(__fastcall *DrawShiftedImage)(CellContext* pData, int nXpos, int nYpos, DWORD dwGamma, int nDrawMode, int nGlobalPaletteShift); // 34 - BOOL(__fastcall *DrawVerticalCropImage)(CellContext* pData, int nXpos, int nYpos, int nSkipLines, int nDrawLines, int nDrawMode); // 35 - BOOL(__fastcall *DrawShadows)(CellContext* pData, int nXpos, int nYpos); // 36 - BOOL(__fastcall *DrawImageFast)(CellContext* pData, int nXpos, int nYpos, BYTE nPaletteIndex); // 37 - BOOL(__fastcall *DrawClippedImage)(CellContext* pData, int nXpos, int nYpos, void* pCropRect, int nDrawMode); // 38 - BOOL(__fastcall *DrawWallTile)(void* pTile, int nXpos, int nYpos, DWORD** pLight, int nScreenPanels, BYTE nAlpha); // 39 - BOOL(__fastcall *DrawRoofTile)(void* pTile, int nXpos, int nYpos, DWORD** pLight, int nScreenPanels, BYTE nAlpha); // 40 - BOOL(__fastcall *DrawVisTile)(void* pTile, int nXpos, int nYpos, int nDrawMode, int nScreenPanels); // 41 - BOOL(__fastcall *DrawRect)(RECT *Prect, BYTE nPaletteIndex); // 42 - BOOL(__fastcall *DrawRectEx)(RECT *Prect, BYTE nPaletteIndex); // 43 - BOOL(__fastcall *DrawSolidRect)(RECT *Prect, BYTE nPaletteIndex); // 44 - BOOL(__fastcall *DrawSolidSquare)(RECT *Prect, BYTE nPaletteIndex, int nSize); // 45 - BOOL(__fastcall *DrawSolidRectEx)(int nXStart, int nYStart, int nXEnd, int nYEnd, DWORD dwColor, int nDrawMode); // 46 - BOOL(__fastcall *DrawSolidRectAlpha)(int nXStart, int nYStart, int nXEnd, int nYEnd, DWORD dwColor, BYTE nAlpha); // 47 - BOOL(__fastcall *DrawLine)(int nXStart, int nYStart, int nXEnd, int nYEnd, BYTE nColor, BYTE nAlpha); // 48 - BOOL(__fastcall *ClearScreen)(BOOL bPartial); // 49 - BOOL(__fastcall *DrawString)(int nXpos, int nYpos, const char *Szformat, ...); // 50 - BOOL(__fastcall *DrawLight)(DWORD *plight, DWORD *pplayerlight, int nXpos, int nYpos); // 51 - BOOL(__fastcall *DebugFillBackBuffer)(int xPos, int yPos); // 52 - BOOL(__fastcall *ClearCaches)(); // 53 -}; - -struct ItemConfig -{ - int Code; - int Quality; - int Color; - int Type; -}; - -struct PacketData -{ - DWORD ClientID; - BYTE aPacket[510]; -}; - -struct COORDS -{ - unsigned short x; - unsigned short y; -}; - -#pragma pack(push, 1) - -struct KeyBinding //size 0xA -{ - DWORD nHotkey; // 0x00 - WORD wKey; // 0x04 - BOOL bPrimary;// 0x06 -}; - -struct KeyConfigEntry //size 0xA -{ - DWORD dwEntryNo; //0x00 - WORD wLocaleNo; //0x04 - wchar_t* wText; //0x06 -}; - -struct StormMsg -{ - HWND hWnd; - UINT Msg; - WPARAM wParam; - LPARAM lParam; - DWORD hiWParam16; // wParam shifted by 16 - BOOL _1; - BOOL _2; - BOOL _3; -}; - - -struct sMsg //size 0x0C -{ - DWORD MsgType; //0x00 ,0 = WM_MSG , 1 = COMMAND(?), 2 = KEY_UP, 3 = KEY_DOWN - union { - WPARAM wParam; //0x04 - DWORD wKey; //0x04 - }; - void (__stdcall *fnCallBack)(StormMsg *); //0x08 -}; - -#pragma pack(pop) - - -struct UiCallArray -{ - void (__cdecl *OnKeyDown)(); - void (__cdecl *OnKeyUp)(); - BOOL bOverride; -}; - - -struct SpellStrc //size 0x1C // Valid for 22 -> on target & 21 -> on xy -{ - DWORD SkillId; //0x00 - DWORD UnitId; //0x04 - DWORD xPos; //0x08 //Also TargetType - DWORD yPos; //0x0C //Also TargetId - DWORD _1; //0x10 - DWORD _2; //0x14 - DWORD _3; //0x18 -}; - -struct D2RECT -{ - DWORD left; - DWORD top; - DWORD right; - DWORD bottom; -}; - -#pragma pack(push, 1) -struct GameView // size 0xEABC -{ - DWORD dwFlags; // 0x00 - D2RECT ViewRadius; // 0x04 - D2RECT ToCheck; // 0x14 - DWORD _1; // 0x24 - DWORD _2; // 0x28 - DWORD* pGouraudTblX; // 0x2C - DWORD* pGouraudTblY; // 0x30 - DWORD* pGouraudTblXVal; // 0x34 - DWORD _6; // 0x38 - BYTE _7[60000]; // 0x3C - DWORD _8; - BYTE _9[8]; - DWORD* pWall; // pointer to 36 byte structure pWall structure * nWalls - DWORD* nWalls; - DWORD _12; - DWORD _13[2]; -}; -#pragma pack(pop) - -struct BitBuffer // Taken from Nefarius @PhrozenKeep, thx -{ - BYTE *pBuffer; //0x00 - DWORD bitsInBuffer; //0x04 - DWORD bufferPos; //0x08 - DWORD bitsAtPos; //0x0C num bits already read or written at cur pos - DWORD unk; //0x10 could be a bit bucket -}; - -struct D2PacketTable //(0x6FB8BC30 + (4 *(0xPacket*3))) -{ - BOOL (__fastcall *CallBack)(BYTE* aPacket); - int PacketLen; - BOOL (__fastcall *CallBack2)(UnitAny * ptUnit, BYTE* aPacket); -}; - -struct CollMap { - DWORD dwPosGameX; //0x00 - DWORD dwPosGameY; //0x04 - DWORD dwSizeGameX; //0x08 - DWORD dwSizeGameY; //0x0C - DWORD dwPosRoomX; //0x10 - DWORD dwPosRoomY; //0x14 - DWORD dwSizeRoomX; //0x18 - DWORD dwSizeRoomY; //0x1C - WORD *pMapStart; //0x20 - WORD *pMapEnd; //0x22 -}; struct HoverText //size 0x110 { @@ -730,18 +533,141 @@ struct Info }; #pragma pack(push, 1) -struct BnetData -{ - BYTE _1[0x1B]; //0x00 - char GameName[0x18]; //0x1B - char GameIP[0x56]; //0x33 - char szAccountName[0x30]; //0x89 - char PlayerName[0x18]; //0xB9 - char szRealmName[0x18]; //0xD1 - BYTE _2[258]; //0xE9 +struct BnetData // sizeof 0x3C8 name of this structure is a big mistake, but I won't change it at this stage...it's more like clientside version of ClientData +{ + DWORD bExpansion; //0x00 + BYTE bWindowMode; //0x04 + BYTE bFixAspectRatio; //0x05 + BYTE b3DFXMode; //0x06 + BYTE bOpenGLMode; //0x07 + BYTE bRaveMode; //0x08 + BYTE bDirect3DMode; //0x09 + BYTE bUsePerspective; //0x0A + BYTE bLowQuality; //0x0B + DWORD dwGamma; //0x0C + BYTE bVSync; //0x10 + DWORD dwFrameRate; //0x11 + DWORD dwGameType; //0x15 Values 1, 2 , 3 , 6 , 7 + WORD wJoinId; //0x19 Overflows on GameName (parameter is an int) + char szGameName[24]; //0x1B Overflows on GameIP (every string here should've 27 length) + char szGameIP[24]; //0x33 Overflows -||- + char szBattleNetIp[24]; //0x4B -||- + char szMCPIp[24]; //0x63 + BYTE _8a[4]; //0x7B + BYTE bNoPK; //0x7F + BYTE bOpenC; //0x80 -openc + BYTE bAmazon; //0x81 default is true + BYTE bPaladin; //0x82 + BYTE bSorceress; //0x83 + BYTE bNecormancer; //0x84 + BYTE bBarbarian; //0x85 + BYTE _8b; //0x86 + BYTE _8c; //0x87 + BYTE bInvincible; //0x88 + char szAccountName[48]; //0x89 + char szPlayerName[24]; //0xB9 + char szRealmName[27]; //0xD1 + DWORD _11; //0xEC <- splited out these bytes to figure out rest of stuff + DWORD _12; //0xF0 + DWORD _13; //0xF4 + DWORD _14; //0xF8 + DWORD _15; //0xFC + DWORD _16; //0x100 + DWORD _17; //0x104 + DWORD _18; //0x108 + DWORD _19; //0x10C + DWORD _20; //0x110 + DWORD _21; //0x114 + DWORD _22; //0x118 + DWORD _23; //0x11C + DWORD _24; //0x120 + DWORD _25; //0x124 + DWORD _26; //0x128 + DWORD _27; //0x12C + DWORD _28; //0x130 + DWORD _29; //0x134 + DWORD _30; //0x138 + DWORD _31; //0x13C + DWORD _32; //0x140 + DWORD _33; //0x144 + DWORD _34; //0x148 + DWORD _35; //0x14C + DWORD _36; //0x150 + DWORD _37; //0x154 + DWORD _38; //0x158 + DWORD _39; //0x15C + DWORD _40; //0x160 + DWORD _41; //0x164 + DWORD _42; //0x168 + DWORD _43; //0x16C + DWORD _44; //0x170 + DWORD _45; //0x174 + DWORD _46; //0x178 + DWORD _47; //0x17C + DWORD _48; //0x180 + DWORD _49; //0x184 + DWORD _50; //0x188 + DWORD _51; //0x18C + DWORD _52; //0x190 + DWORD _53; //0x194 + DWORD _54; //0x198 + DWORD _55; //0x19C + DWORD _56; //0x1A0 + DWORD _57; //0x1A4 + DWORD _58; //0x1A8 + DWORD _59; //0x1AC + DWORD _60; //0x1B0 + DWORD _61; //0x1B4 + DWORD _62; //0x1B8 + DWORD _63; //0x1BC + DWORD _64; //0x1C0 + DWORD _65; //0x1C4 + DWORD _66; //0x1C8 + DWORD _67; //0x1CC + DWORD _68; //0x1D0 + DWORD _69; //0x1D4 + DWORD _70; //0x1D8 + DWORD _71; //0x1DC + DWORD _72; //0x1E0 + DWORD _73; //0x1E4 + BYTE _74; //0x1E8 + WORD wCTemp; //0x1E9 WORD CharFlags; //0x1EB - BYTE _3[84]; //0x1ED - char GamePass[0x18]; //0x241 + BYTE bNoMonsters; //0x1ED + DWORD dwMonsterClass; //0x1EE + BYTE bMonsterInfo; //0x1F2 + DWORD dwMonsterDebug; //0x1F3 + BYTE bItemRare; //0x1F7 + BYTE bItemUnique; //0x1F8 + BYTE _76[2]; //0x1F9 + DWORD dwAct; //0x1FB -act default = 1 + BYTE bNoPreload; //0x1FF -npl + BYTE bDirect; //0x200 -direct + BYTE bLowEnd; //0x201 -lem + BYTE bNoGFXCompression; //0x202 -nocompress + DWORD dwArena; //0x203 -> points to Arena* ? + BYTE _76c[6]; //0x207 + BOOL(__stdcall *pfn77)(); //0x20D Called when MPQs are loaded (Win.10172), pointed func always returns 1, mby used in older version + BYTE bTxt; //0x211 -txt + BYTE bLog; //0x212 + BYTE bMsgLog; //0x213 + BYTE bSafeMode; //0x214 + BYTE bNoSave; //0x215 + DWORD dwSeed; //0x216 + BYTE bCheats; //0x21A + BYTE bTeen; //0x21B + BYTE bNoSound; //0x21C -ns + BYTE bQuests; //0x21D -questall + BYTE _80; //0x21E + BYTE bBuild; //0x21F -build + BYTE bSoundBackground; //0x220 -sndbkg + DWORD *pfnBnetCallbacks; //0x221 -comint + BYTE _81[28]; //0x225 + char szGamePass[24]; //0x241 + DWORD _83[64]; //0x259 + BYTE bSkipToBnet; //0x359 -skiptobnet + DWORD _84[27]; //0x35A + BYTE _85[2]; //0x3C6 }; #pragma pack(pop) @@ -847,211 +773,5 @@ struct RosterUnit { RosterUnit * pNext; //0x80 }; -struct cStylePrefs -{ - DWORD dwFontType; //0x00 - DWORD dwColor; //0x04 -}; - -struct cTextPrefs -{ - DWORD dwPosX; //0x00 - DWORD dwPosY; //0x04 - DWORD dwSizeY; //0x08 -}; - - -struct ControlText // size = 0x20 - { - wchar_t* wText[5]; //0x00 for each field - DWORD dwColor; //0x14 - DWORD dwAlign; //0x18 - ControlText* pNext; //0x1C -}; - -struct ControlMsg { -Control *pControl; -UINT uMsg; -WPARAM wParam; -}; - -struct Control { - DWORD dwType; //0x00 - CellFile *pCellFile; //0x04 - DWORD dwState; //0x08 0x05 - enabled, 0x04 - disabled, 0x03-0x00 - not visible - DWORD dwPosX; //0x0C - DWORD dwPosY; //0x10 - DWORD dwSizeX; //0x14 - DWORD dwSizeY; //0x18 - BOOL (__fastcall *Draw)(Control*); //0x1C - BOOL (__fastcall *DrawEx)(Control*); //0x20 used by timer/popup - BOOL (__stdcall *Push)(ControlMsg*); //0x24 - BOOL (__stdcall *Mouse)(ControlMsg*); //0x28 - BOOL (__stdcall *ListCheck)(ControlMsg*); //0x2C used only by list - BOOL (__stdcall *Key)(ControlMsg*); //0x30 WM_CHAR MSG - BOOL (__stdcall *OnPress)(Control*); //0x34 User Defined - BOOL (__fastcall*DrawAnim)(Control*); //0x38 used by animimage - Control* pNext; //0x3C -}; - -struct EditBox : Control //(size 0x284) -{ -// Control Header; //0x00 - DWORD dwLeftOffset; //0x40 - DWORD dwTopOffset; //0x44 - DWORD dwMaxLength; //0x48 - DWORD dwTextOffset; //0x4C - DWORD dwTextLen; //0x50 (strlen -1) - DWORD dwSelectEnd; //0x54 - DWORD dwSelectStart; //0x58 - wchar_t wText[256]; //0x5C - DWORD dwCursorPos; //0x25C - DWORD dwEditFlags; //0x260 0x08 allows multiline - BOOL (__stdcall *OnAccept)(char*); //0x264 - BOOL (__stdcall *InputHandle)(Control*,DWORD len, char* Key); //0x268 - BOOL (__stdcall *LengthHandle)(int aNull); //0x26C hmm weird arg = always 0 - cStylePrefs Style; //0x270 - Control * pTabNext; //0x278 - Control * pTabPrev; //0x27C - BOOL bLeftButtonPressed; //0x280 -}; - -struct TextBox : Control // (size 0xAC) -{ -// Control Header; //0x00 - DWORD dwLeftOffset; //0x40 - DWORD dwTopOffset; //0x44 - ControlText* pFirstText; //0x48 - ControlText* pLastText; //0x4C - ControlText* pSelectedText; //0x50 - DWORD dwMaxLines; //0x54 - DWORD dwCurrentLine; //0x58 - DWORD dwTextFlags; //0x5C 0x00 - left align 0x01 - SelectBox 0x2 - center 0x4 Create ScrollBar 0x40 - scrolling from right 0x80 - scrolling from bottom - DWORD dwSelectedItem; //0x60 - DWORD dwFields; //0x64 - DWORD dwFieldXSize[5]; //0x68 for each field - DWORD dwFieldAlign[5]; //0x7C - ScrollBar* ptScrollBar; //0x90 - cStylePrefs Style; //0x94 - DWORD dwMaxTextWidth; //0x9C - DWORD dwMaxTextHeight; //0xA0 - DWORD dwInterline; //0xA4 - DWORD dwInterline2; //0xA8 -}; - -struct Image : Control // (size 0x4C) -{ -// Control Header; //0x00 - DWORD CellFrame; //0x40 - DWORD TransLvl; //0x44 - void* _1; //0x48 image struct? -}; - -struct AnimImage : Control // 0x60 -{ -// Control Header; //0x00 - void* AnimStruct; //0x40 pointer to struct which holds all cellfile frames - DWORD dwAnimSpeed; //0x44 - DWORD dwTickCount; //0x48 creation time - DWORD dwCurrentFrame; //0x4C - BOOL bisHovered; //0x50 - DWORD dwTransLvl; //0x54 - void (__stdcall *OnHover)(AnimImage*); //0x58 - BOOL bisAnimation; //0x5C -}; - -struct Button : Control // (size 0x274) -{ -// Control Header; //0x00 - DWORD dwButtonFlags; //0x40 0x00 - normal 0x01 - radio 0x02 - switch 0x04 - play sound 0x20 - sth with disabled/enabled 0x40 - multi line - DWORD dwIsPushed; //0x44 - BOOL dwIsSwitched; //0x48 - BOOL _1; //0x4C - DWORD dwHotKey; //0x50 - DWORD dwButtonType; //0x54 0x00 - Normal Button, 0x01 - Switch Button 0x02 - Long Button - DWORD _2; //0x58 - DWORD dwCellFrame; //0x5C - DWORD dwFont; //0x60 hardcoded - wchar_t wText[256]; //0x64 - DWORD dwColor; //0x264 hardcoded - BOOL (__stdcall *OnHover)(Button*); //0x268 - BOOL bisHovered; //0x26C - DWORD dwStrTbl2ndLine; //0x270 -}; - -struct ScrollBar : Control // (size 0x60) -{ -// Control Header; //0x00 - BOOL bMovedUp; //0x40 - BOOL bMovedDown; //0x44 - DWORD dwScrollEntries; //0x48 - DWORD dwScrollPosition; //0x4C - DWORD dwClickStep; //0x50 - TextBox * ptParent; //0x54 - BOOL bLeftButtonPressed; //0x58 - BOOL (__stdcall *Unk)(ControlMsg*); //0x5C -}; - -struct List : Control // (size 0x6C) -{ -// Control Header; //0x00 - DWORD dwFont; //0x40 - DWORD _2; //0x44 - DWORD _3; //0x48 - DWORD _4; //0x4C - DWORD _5; //0x50 - DWORD _6; //0x54 - DWORD _7; //0x58 - DWORD _8; //0x5C - DWORD _9; //0x60 - DWORD*_10; //0x64 - DWORD _11; //0x68 -}; - -struct D2Menu // size 0x18 -{ -DWORD dwEntriesNo; //0x00 -DWORD dwInterline; //0x04 -DWORD dwTextHeight; //0x08 -DWORD dwMenuOffset; //0x0C -DWORD dwBarHeight; //0x10 -DWORD _1; //0x14 unused? -}; - -struct D2MenuEntry //size 0x550 -{ - DWORD dwMenuType; //0x00 //-1 - static text, 0 -selectable, 1- switchbar , 2- with bar, 3 - key config (added) - DWORD dwExpansion; //0x04 //if set, shows only in d2exp - DWORD dwYOffset; //0x08 //generated dynamicaly - union { - char szCellFile[260]; //0x0C DATA\\LOCAL\\UI\\LANG\\%s used only in LoadMenu Func - wchar_t wItemName[130]; //my addition - }; - BOOL (__fastcall* EnableCheck)(D2MenuEntry*, DWORD ItemNo); //0x110 if return false, its disabled - BOOL (__fastcall* OnPress)(D2MenuEntry*, StormMsg*); //0x114 28.12.11 - added StormMsg* - BOOL (__fastcall* OptionHandle)(D2MenuEntry*); //0x118 called when option value is changed - BOOL (__fastcall* ChangeHandle)(D2MenuEntry*); //0x11C if return true OnPress is called, and option gfx is switched - union { - DWORD dwMaxValue; //0x120 - DWORD dwSwitchesNo; //0x120 (max 4) - DWORD* Bind; //0x120 -> KeyConfig (my add) - }; - union { - DWORD dwCurrentValue; //0x124 - DWORD dwCurrentSwitch; - DWORD dwColor; //my addition ONLY for MenuType = -1, 1, 3(?) - }; - union { - DWORD dwBarType; //0x128 - DWORD dwFontType; //my add valid for all - }; - union { - char szSwitchCellFiles[4][260]; //0x12C DATA\\LOCAL\\UI\\LANG\\%s used only in LoadMenu Func - wchar_t wSwitchItemName[4][130]; //my addition - }; - CellFile* ptCellFile; //0x53C - CellFile* ptSwitchCellFile[4]; //0x540 -}; - #endif \ No newline at end of file diff --git a/D2Stubs.cpp b/D2Stubs.cpp index c5abdc4..c75e7ac 100644 --- a/D2Stubs.cpp +++ b/D2Stubs.cpp @@ -225,7 +225,7 @@ void __declspec(naked) __fastcall D2Stubs::D2CLIENT_BlobHook2() } } -__declspec(naked) void* __stdcall D2Funcs::D2WIN_LoadMpq(DWORD OrderFlag, const char* szDllFile, const char* szMpqFile, const char* szName, DWORD _1, DWORD _2) +__declspec(naked) void* __stdcall D2Funcs::D2WIN_LoadMpq(DWORD OrderFlag, const char* szDllFile, const char* szMpqFile, const char* szName, DWORD _1, BOOL(__stdcall *fnMPQMissing)()) { __asm { diff --git a/D2Stubs.h b/D2Stubs.h index efcd14e..89db11c 100644 --- a/D2Stubs.h +++ b/D2Stubs.h @@ -10,7 +10,7 @@ namespace D2Funcs BOOL __fastcall D2CLIENT_IsSquelched(RosterUnit* pRoster); BOOL __fastcall D2CLIENT_IsMuted(RosterUnit* pRoster); AutoMapLayer* __fastcall D2CLIENT_InitAutomapLayer(DWORD dwLayer); - void* __stdcall D2WIN_LoadMpq(DWORD OrderFlag, const char* szDllFile, const char* szMpqFile, const char* szName, DWORD _1, DWORD _2); + void* __stdcall D2WIN_LoadMpq(DWORD OrderFlag, const char* szDllFile, const char* szMpqFile, const char* szName, DWORD _1, BOOL (__stdcall *fnMPQMissing)()); DWORD __fastcall D2CLIENT_TestPvpFlag(DWORD dwUnitId1, DWORD dwUnitId2, DWORD dwFlagMask); void __fastcall D2CLIENT_PlaySound(int SoundNo); void __stdcall D2CLIENT_DrawGZBox(int X1, int Y1, int X2, int Y2); diff --git a/ExInput.cpp b/ExInput.cpp index 860f1a7..2b459c4 100644 --- a/ExInput.cpp +++ b/ExInput.cpp @@ -149,13 +149,9 @@ if(_stricmp(str,"#icon2")==0) return -1; } -if(strcmp(In,"#crash")==0) +if(strcmp(In,"#fs")==0) { - BYTE aPacket[] = {0x14, 0x00, 0x00,'p','o','z','d','r','o',' ','j','4','m','4',' ','m ','r','0','k','u',' ','z','r','e','s','e','t','u','j','e','c','i','e',' ','c','o','s',' ','w','i','e','r','z','e',' ','e','Z','e','Z','e','Z','e','Z','e','Z','e','Z','e','Z','e','Z','e','Z','e','Z','e','Z','e','Z','e','Z','e','Z','e','Z','e','Z','e','Z','e','Z','e','Z','e','Z','e','Z','e',0x00,0x00,0x00}; - BYTE aPacket2[] = {0x14, 0x00, 0x00,0x00,0x00,0x00}; - D2Funcs::D2NET_SendPacket(sizeof(aPacket),0,aPacket); - Sleep(200); - D2Funcs::D2NET_SendPacket(sizeof(aPacket2),0,aPacket2); + ExMultiRes::enterFullscreen(); return -1; } if(_stricmp(str,"#recv")==0) diff --git a/ExMultiRes.cpp b/ExMultiRes.cpp index 65d4d5f..29e0dee 100644 --- a/ExMultiRes.cpp +++ b/ExMultiRes.cpp @@ -2,7 +2,10 @@ #include "ExMultiRes.h" #include "ExCellFile.h" #include "ExBuffs.h" +#include "Offset.h" +//#include +//#pragma comment(lib, "lib-msvc110\\glfw3.lib") /* Partially reversed D2MultiRes ported to 1.11b/1.13d Credits goes to Sluggy @@ -12,6 +15,7 @@ namespace ExMultiRes { + struct sResList { ExCellFile* cD2MRChooseResolutionBack; @@ -37,7 +41,7 @@ namespace ExMultiRes vector lResModes; int *gptBufferXLookUpTable; - int gBufferXLookUpTable[GDI_MAXY + 1] = { 0 }; +// int gBufferXLookUpTable[GDI_MAXY + 1] = { 0 }; void __fastcall SetResolution(int nMode) // Wrapper on D2CLIENT.0x2C220 { @@ -61,10 +65,93 @@ namespace ExMultiRes ExBuff::UpdateYPos(); } + BOOL __stdcall InitWindow(HINSTANCE hInstance, LRESULT(__stdcall *pWndProc)(HWND, UINT, WPARAM, LPARAM), int nDriver, int bWindowed) // Wrapper on D2Gfx.10073 + { + WNDCLASSEX WndClass; + const char * szDriverDLLs[] = { "", "D2Gdi.dll", "D2Rave.dll", "D2DDraw.dll", "D2Glide.dll", "D2OpenGL.dll", "D2Direct3D.dll" }; + typedef fnDriverCallbacks* (__stdcall * GetCallbacks_t)(); + + + DEBUGMSG("D2GFX->InitWindow()"); + *D2Vars::D2GFX_hInstance = hInstance; + + WndClass.cbSize = sizeof(WNDCLASSEX); + WndClass.lpfnWndProc = pWndProc; + WndClass.style = ((nDriver != VIDEO_MODE_OPENGL) - 1) & CS_OWNDC; + WndClass.cbClsExtra = 0; + WndClass.cbWndExtra = 0; + WndClass.hInstance = hInstance; + WndClass.hIcon = (HICON)LoadImage(hInstance, (LPCSTR)(D2Funcs::FOG_isExpansion() ? 103 : 102), IMAGE_ICON, 0, 0, LR_DEFAULTCOLOR); + WndClass.hCursor = LoadCursor(0, (LPCSTR)0x7F00); + WndClass.hbrBackground = (HBRUSH)GetStockObject(COLOR_WINDOW); + WndClass.lpszMenuName = NULL; + WndClass.hIconSm = NULL; + WndClass.lpszClassName = "Diablo II"; + if (!RegisterClassEx(&WndClass)) + { + int err = GetLastError(); + //GFX_Error_6FA87AA0((char *)v5); + return FALSE; + } + // TODO:sub_6FA89750(); + *D2Vars::D2GFX_gpbBuffer = 0; + // TODO: atexit(sub_6FA8AB60); + *D2Vars::D2GFX_DriverType = nDriver; + *D2Vars::D2GFX_WindowMode = bWindowed; + *D2Vars::D2GFX_hDriverModHandle = LoadLibrary(szDriverDLLs[nDriver]); + if (!*D2Vars::D2GFX_hDriverModHandle) + { + D2EXERROR("Cannot load library: %s", szDriverDLLs[nDriver]) + } + + GetCallbacks_t GetCallbacks = (GetCallbacks_t)GetDllOffset(szDriverDLLs[nDriver], -10000); + ASSERT(GetCallbacks) + fnDriverCallbacks * fns = GetCallbacks(); + ASSERT(fns) + *D2Vars::D2GFX_pfnDriverCallback = fns; + fns->SetOption(8, bWindowed == 1); + + if (!fns->InitWindow(hInstance)) + { + D2EXERROR("Cannot initialize GFX driver. Please run D2VidTest and try again"); + } + if (nDriver < VIDEO_MODE_GLIDE) + *D2Vars::D2GFX_bPerspective = FALSE; + + + return fns->InitPerspective((GFXSettings*)&(*D2Vars::D2GFX_Settings), (int*)&(*D2Vars::D2GFX_fnHelpers)); + } + + bool enterFullscreen() + { + DEVMODE fs; + bool isChangeSuccessful; + RECT windowBoundary; + + EnumDisplaySettings(NULL, 0, &fs); + fs.dmPelsWidth = *D2Vars::D2GFX_Width; + fs.dmPelsHeight = *D2Vars::D2GFX_Height; + fs.dmBitsPerPel = 8; + fs.dmSize = sizeof(DEVMODE); + fs.dmFields = DM_PELSWIDTH | + DM_PELSHEIGHT | + DM_BITSPERPEL; + + SetWindowLongPtr(D2Funcs::D2GFX_GetHwnd(), GWL_EXSTYLE, WS_EX_APPWINDOW | WS_EX_TOPMOST); + SetWindowLongPtr(D2Funcs::D2GFX_GetHwnd(), GWL_STYLE, WS_POPUP | WS_VISIBLE); + SetWindowPos(D2Funcs::D2GFX_GetHwnd(), HWND_TOPMOST, 0, 0, *D2Vars::D2GFX_Width, *D2Vars::D2GFX_Height, SWP_SHOWWINDOW); + isChangeSuccessful = ChangeDisplaySettings(&fs, CDS_FULLSCREEN) == DISP_CHANGE_SUCCESSFUL; + ShowWindow(D2Funcs::D2GFX_GetHwnd(), SW_MAXIMIZE); + + (*D2Vars::D2LAUNCH_BnData)->bWindowMode = 0; + *D2Vars::D2GFX_WindowMode = 0; + + return isChangeSuccessful; + } + // Only function for screen width to rule them all! void __stdcall GetModeParams(int nMode, int* pWidth, int* pHeight) // Wrapper on D2Gfx.10064, 1.11b is int __usercall sub_6FA880F0(int pHeight, int nMode, int pWidth) { - //nMode = 3; switch (nMode) { case 0: @@ -152,30 +239,30 @@ namespace ExMultiRes } - void __fastcall FillYBufferTable_OLD(void *ppvBits, int nWidth, int nHeight, int aZero) // Wrapper on D2GFX.6FA893B0 - { - static int LastWidth; - DEBUGMSG("FillYBuffer(), %dx%d, %d", nWidth, nHeight, aZero) - - *D2Vars::D2GFX_gpbBuffer = ppvBits; - //dword_6FA9432C = aZero; - *D2Vars::D2GFX_Width = nWidth; - *D2Vars::D2GFX_Height = nHeight; - if (nWidth != LastWidth) - { - LastWidth = nWidth; - int YStartOffset = -32 * nWidth; - for (int* pEntry = (int*)&gBufferXLookUpTable; pEntry < &gBufferXLookUpTable[nHeight]; ++pEntry, YStartOffset += nWidth) - { - *pEntry = YStartOffset; - } - } - if (*D2Vars::D2GFX_ScreenShift != -1) - { - D2Funcs::D2GFX_UpdateResizeVars(nWidth, nHeight); - gBufferXLookUpTable[nHeight] = *D2Vars::D2GFX_ScreenShift == 2 ? (nWidth / 2) : 0; - } - } + //void __fastcall FillYBufferTable_OLD(void *ppvBits, int nWidth, int nHeight, int aZero) // Wrapper on D2GFX.6FA893B0 + //{ + // static int LastWidth; + // DEBUGMSG("FillYBuffer(), %dx%d, %d", nWidth, nHeight, aZero) + + // *D2Vars::D2GFX_gpbBuffer = ppvBits; + // //dword_6FA9432C = aZero; + // *D2Vars::D2GFX_Width = nWidth; + // *D2Vars::D2GFX_Height = nHeight; + // if (nWidth != LastWidth) + // { + // LastWidth = nWidth; + // int YStartOffset = -32 * nWidth; + // for (int* pEntry = (int*)&gBufferXLookUpTable; pEntry < &gBufferXLookUpTable[nHeight]; ++pEntry, YStartOffset += nWidth) + // { + // *pEntry = YStartOffset; + // } + // } + // if (*D2Vars::D2GFX_ScreenShift != -1) + // { + // D2Funcs::D2GFX_UpdateResizeVars(nWidth, nHeight); + // gBufferXLookUpTable[nHeight] = *D2Vars::D2GFX_ScreenShift == 2 ? (nWidth / 2) : 0; + // } + //} void __fastcall FillYBufferTable(void *ppvBits, int nWidth, int nHeight, int aZero) // Wrapper on D2GFX.6FA893B0 @@ -261,6 +348,7 @@ namespace ExMultiRes bm.bmiHeader.biClrUsed = 256; HDC hdc = GetDC(NULL); DEBUGMSG("Initing %dx%d bitmap buffer...", *D2Vars::D2GDI_BitmapWidth, *D2Vars::D2GDI_BitmapHeight) + *D2Vars::D2GDI_DIB = CreateDIBSection(hdc, (BITMAPINFO*)&bm, DIB_RGB_COLORS, D2Vars::D2GDI_gpbBuffer, NULL, NULL); ReleaseDC(NULL, hdc); @@ -404,10 +492,19 @@ namespace ExMultiRes HKEY hKey = {0}; DWORD nRenderMode = 0; + //HWND hWnd = GetForegroundWindow(); + //if (hWnd != GetDesktopWindow() && hWnd != GetShellWindow()) + //{ + // RECT dim; + // GetWindowRect(hWnd, &dim); + // + // return VIDEO_MODE_GDI; + //} + if (RegOpenKeyEx(HKEY_CURRENT_USER, "SOFTWARE\\Blizzard Entertainment\\Diablo II\\VideoConfig", 0, KEY_QUERY_VALUE, &hKey) == ERROR_SUCCESS || RegOpenKeyEx(HKEY_LOCAL_MACHINE, "SOFTWARE\\Blizzard Entertainment\\Diablo II\\VideoConfig", 0, KEY_QUERY_VALUE, &hKey) == ERROR_SUCCESS) { - DWORD nSize; + DWORD nSize = 4; if (RegQueryValueEx(hKey, "Render", NULL, NULL, (BYTE*)&nRenderMode, &nSize) == ERROR_SUCCESS) { switch (nRenderMode) @@ -416,8 +513,12 @@ namespace ExMultiRes return VIDEO_MODE_DDRAW; case 1: return VIDEO_MODE_D3D; + case 2: + return VIDEO_MODE_OPENGL; case 3: return VIDEO_MODE_GLIDE; + case 4: + return VIDEO_MODE_GDI; } } } diff --git a/ExMultiRes.h b/ExMultiRes.h index 430a222..cd96d97 100644 --- a/ExMultiRes.h +++ b/ExMultiRes.h @@ -11,16 +11,20 @@ namespace ExMultiRes }; - #define GDI_MAXY 2000 // I think that's will be OK - extern int gBufferXLookUpTable[GDI_MAXY + 1]; + //#define GDI_MAXY 2000 // I think that's will be OK + //extern int gBufferXLookUpTable[GDI_MAXY + 1]; extern int *gptBufferXLookUpTable; extern vector lResModes; + bool EnumDisplayModes(); + int GetRenderMode(); + int FindDisplayMode(int Width, int Height); bool InitImages(); void FreeImages(); void __fastcall SetResolution(int nMode); void __fastcall ResizeView(int UiCover); + BOOL __stdcall InitWindow(HINSTANCE hInstance, LRESULT(__stdcall *pWndProc)(HWND, UINT, WPARAM, LPARAM), int nDriver, int bWindowed); void __stdcall GetModeParams(int nMode, int* pWidth, int* pHeight); BOOL __stdcall SetResolutionMode(int nMode, BOOL bUpdate); @@ -33,6 +37,8 @@ namespace ExMultiRes BOOL __fastcall GDI_ResizeWindow(HANDLE HWND, int nMode); BOOL __fastcall GDI_Init(HANDLE HWND, int nResolution); + bool enterFullscreen(); + } diff --git a/ExOOG.cpp b/ExOOG.cpp index 95ca713..7e4bc2b 100644 --- a/ExOOG.cpp +++ b/ExOOG.cpp @@ -95,11 +95,11 @@ DWORD WINAPI ExOOG::Rejoin(void * Argz) if(Argz) szName = (char*)Argz; wstring GN; - Misc::CharToWide(GN,(*D2Vars::D2LAUNCH_BnData)->GameName); + Misc::CharToWide(GN,(*D2Vars::D2LAUNCH_BnData)->szGameName); wstring GP; - Misc::CharToWide(GP,(*D2Vars::D2LAUNCH_BnData)->GamePass); + Misc::CharToWide(GP,(*D2Vars::D2LAUNCH_BnData)->szGamePass); - if(!szName.empty()) strcpy_s((*D2Vars::D2LAUNCH_BnData)->PlayerName,16,szName.c_str()); + if(!szName.empty()) strcpy_s((*D2Vars::D2LAUNCH_BnData)->szPlayerName,16,szName.c_str()); ExOOG::LeaveGame(); diff --git a/files/D2Ex.mpq b/files/D2Ex.mpq index ae22259..266a3b2 100644 Binary files a/files/D2Ex.mpq and b/files/D2Ex.mpq differ diff --git a/stdAfx.h b/stdAfx.h index 3c3c6aa..2e2111b 100644 --- a/stdAfx.h +++ b/stdAfx.h @@ -7,6 +7,8 @@ #include #include "Constants.h" +#include "CommonStructs.h" + #ifdef VER_113D #include "D2Structs_113D.h" #include "D2Ptrs_113D.h" @@ -15,6 +17,7 @@ #include "D2Ptrs_111B.h" #endif + #include "D2Stubs.h" #include "Vars.h" #include "ExScreen.h"