AzeorthCore 3.3.5a
OpenSource WoW Emulator
Loading...
Searching...
No Matches
AddonHandler Class Reference

#include "AddonHandler.h"

Public Member Functions

 AddonHandler ()
 
 ~AddonHandler ()
 
bool BuildAddonPacket (WorldPacket *Source, WorldPacket *Target)
 

Static Public Member Functions

static AddonHandlerinstance ()
 

Detailed Description

Constructor & Destructor Documentation

◆ AddonHandler()

AddonHandler::AddonHandler ( )
24{
25}

◆ ~AddonHandler()

AddonHandler::~AddonHandler ( )
28{
29}

Member Function Documentation

◆ BuildAddonPacket()

bool AddonHandler::BuildAddonPacket ( WorldPacket Source,
WorldPacket Target 
)
38{
39 ByteBuffer AddOnPacked;
40 uLongf AddonRealSize;
41 uint32 CurrentPosition;
42 uint32 TempValue;
43
44 // broken addon packet, can't be received from real client
45 if (Source->rpos() + 4 > Source->size())
46 return false;
47
48 *Source >> TempValue; // get real size of the packed structure
49
50 // empty addon packet, nothing process, can't be received from real client
51 if (!TempValue)
52 return false;
53
54 AddonRealSize = TempValue; // temp value because ZLIB only excepts uLongf
55
56 CurrentPosition = Source->rpos(); // get the position of the pointer in the structure
57
58 AddOnPacked.resize(AddonRealSize); // resize target for zlib action
59
60 if (uncompress(const_cast<uint8*>(AddOnPacked.contents()), &AddonRealSize, const_cast<uint8*>((*Source).contents() + CurrentPosition), (*Source).size() - CurrentPosition) == Z_OK)
61 {
63
64 uint32 addonsCount;
65 AddOnPacked >> addonsCount; // addons count?
66
67 for (uint32 i = 0; i < addonsCount; ++i)
68 {
69 std::string addonName;
70 uint8 enabled;
71 uint32 crc, unk2;
72
73 // check next addon data format correctness
74 if (AddOnPacked.rpos() + 1 > AddOnPacked.size())
75 return false;
76
77 AddOnPacked >> addonName;
78
79 // recheck next addon data format correctness
80 if (AddOnPacked.rpos() + 1 + 4 + 4 > AddOnPacked.size())
81 return false;
82
83 AddOnPacked >> enabled >> crc >> unk2;
84
85 LOG_DEBUG("network", "ADDON: Name: {}, Enabled: 0x{:x}, CRC: 0x{:x}, Unknown2: 0x{:x}", addonName, enabled, crc, unk2);
86
87 uint8 state = (enabled ? 2 : 1);
88 *Target << uint8(state);
89
90 uint8 unk1 = (enabled ? 1 : 0);
91 *Target << uint8(unk1);
92 if (unk1)
93 {
94 uint8 unk = (crc != 0x4c1c776d); // If addon is Standard addon CRC
95 *Target << uint8(unk);
96 if (unk)
97 {
98 unsigned char tdata[256] =
99 {
100 0xC3, 0x5B, 0x50, 0x84, 0xB9, 0x3E, 0x32, 0x42, 0x8C, 0xD0, 0xC7, 0x48, 0xFA, 0x0E, 0x5D, 0x54,
101 0x5A, 0xA3, 0x0E, 0x14, 0xBA, 0x9E, 0x0D, 0xB9, 0x5D, 0x8B, 0xEE, 0xB6, 0x84, 0x93, 0x45, 0x75,
102 0xFF, 0x31, 0xFE, 0x2F, 0x64, 0x3F, 0x3D, 0x6D, 0x07, 0xD9, 0x44, 0x9B, 0x40, 0x85, 0x59, 0x34,
103 0x4E, 0x10, 0xE1, 0xE7, 0x43, 0x69, 0xEF, 0x7C, 0x16, 0xFC, 0xB4, 0xED, 0x1B, 0x95, 0x28, 0xA8,
104 0x23, 0x76, 0x51, 0x31, 0x57, 0x30, 0x2B, 0x79, 0x08, 0x50, 0x10, 0x1C, 0x4A, 0x1A, 0x2C, 0xC8,
105 0x8B, 0x8F, 0x05, 0x2D, 0x22, 0x3D, 0xDB, 0x5A, 0x24, 0x7A, 0x0F, 0x13, 0x50, 0x37, 0x8F, 0x5A,
106 0xCC, 0x9E, 0x04, 0x44, 0x0E, 0x87, 0x01, 0xD4, 0xA3, 0x15, 0x94, 0x16, 0x34, 0xC6, 0xC2, 0xC3,
107 0xFB, 0x49, 0xFE, 0xE1, 0xF9, 0xDA, 0x8C, 0x50, 0x3C, 0xBE, 0x2C, 0xBB, 0x57, 0xED, 0x46, 0xB9,
108 0xAD, 0x8B, 0xC6, 0xDF, 0x0E, 0xD6, 0x0F, 0xBE, 0x80, 0xB3, 0x8B, 0x1E, 0x77, 0xCF, 0xAD, 0x22,
109 0xCF, 0xB7, 0x4B, 0xCF, 0xFB, 0xF0, 0x6B, 0x11, 0x45, 0x2D, 0x7A, 0x81, 0x18, 0xF2, 0x92, 0x7E,
110 0x98, 0x56, 0x5D, 0x5E, 0x69, 0x72, 0x0A, 0x0D, 0x03, 0x0A, 0x85, 0xA2, 0x85, 0x9C, 0xCB, 0xFB,
111 0x56, 0x6E, 0x8F, 0x44, 0xBB, 0x8F, 0x02, 0x22, 0x68, 0x63, 0x97, 0xBC, 0x85, 0xBA, 0xA8, 0xF7,
112 0xB5, 0x40, 0x68, 0x3C, 0x77, 0x86, 0x6F, 0x4B, 0xD7, 0x88, 0xCA, 0x8A, 0xD7, 0xCE, 0x36, 0xF0,
113 0x45, 0x6E, 0xD5, 0x64, 0x79, 0x0F, 0x17, 0xFC, 0x64, 0xDD, 0x10, 0x6F, 0xF3, 0xF5, 0xE0, 0xA6,
114 0xC3, 0xFB, 0x1B, 0x8C, 0x29, 0xEF, 0x8E, 0xE5, 0x34, 0xCB, 0xD1, 0x2A, 0xCE, 0x79, 0xC3, 0x9A,
115 0x0D, 0x36, 0xEA, 0x01, 0xE0, 0xAA, 0x91, 0x20, 0x54, 0xF0, 0x72, 0xD8, 0x1E, 0xC7, 0x89, 0xD2
116 };
117 Target->append(tdata, sizeof(tdata));
118 }
119
120 *Target << uint32(0);
121 }
122
123 uint8 unk3 = (enabled ? 0 : 1);
124 *Target << uint8(unk3);
125 if (unk3)
126 {
127 // String, 256 (null terminated?)
128 *Target << uint8(0);
129 }
130 }
131
132 uint32 unk4;
133 AddOnPacked >> unk4;
134
135 uint32 count = 0;
136 *Target << uint32(count);
137
138 if (AddOnPacked.rpos() != AddOnPacked.size())
139 LOG_DEBUG("network", "packet under read!");
140 }
141 else
142 {
143 LOG_ERROR("network", "Addon packet uncompress error :(");
144 return false;
145 }
146 return true;
147}
std::uint8_t uint8
Definition: Define.h:110
std::uint32_t uint32
Definition: Define.h:108
#define LOG_ERROR(filterType__,...)
Definition: Log.h:159
#define LOG_DEBUG(filterType__,...)
Definition: Log.h:171
@ SMSG_ADDON_INFO
Definition: Opcodes.h:781
void Initialize(uint16 opcode, size_t newres=200)
Definition: WorldPacket.h:69
Definition: ByteBuffer.h:70
size_t rpos() const
Definition: ByteBuffer.h:317
void resize(size_t newsize)
Definition: ByteBuffer.h:447
void append(T value)
Definition: ByteBuffer.h:129
size_t size() const
Definition: ByteBuffer.h:444
uint8 * contents()
Definition: ByteBuffer.h:424

References ByteBuffer::append(), ByteBuffer::contents(), WorldPacket::Initialize(), LOG_DEBUG, LOG_ERROR, ByteBuffer::resize(), ByteBuffer::rpos(), ByteBuffer::size(), and SMSG_ADDON_INFO.

◆ instance()

AddonHandler * AddonHandler::instance ( )
static
32{
34 return &instance;
35}
Definition: AddonHandler.h:26
static AddonHandler * instance()
Definition: AddonHandler.cpp:31

References instance().

Referenced by instance().