Browse Source

pack the TMegaPkt struct. define TMEGAPKT_SIZE.

memcpy((char *)&packeta[1] - packeta->dwSpaceLeft, packet, dwSize);

Source/msg.cpp does this calculation, which will be wrong if any padding is
added. To get this to work correctly, pack the structures, as suggested by
@AJenbo.

Also, define TMEGAPKT_SIZE because pNext can be 4 or 8 bytes.
pull/256/head
Nam Nguyen 7 years ago committed by Robin Eklind
parent
commit
f7ceadf6dc
  1. 2
      Source/msg.cpp
  2. 3
      structs.h

2
Source/msg.cpp

@ -55,7 +55,7 @@ TMegaPkt *msg_get_next_packet()
{
TMegaPkt *result;
sgpCurrPkt = (TMegaPkt *)DiabloAllocPtr(32008);
sgpCurrPkt = (TMegaPkt *)DiabloAllocPtr(TMEGAPKT_SIZE);
sgpCurrPkt->pNext = NULL;
sgpCurrPkt->dwSpaceLeft = 32000;

3
structs.h

@ -955,11 +955,14 @@ typedef struct DJunk {
} DJunk;
#pragma pack(pop)
#pragma pack(push, 1)
typedef struct TMegaPkt {
struct TMegaPkt *pNext;
DWORD dwSpaceLeft;
BYTE data[32000];
} TMegaPkt;
#pragma pack(pop)
#define TMEGAPKT_SIZE sizeof(TMegaPkt)
typedef struct TBuffer {
DWORD dwNextWriteOffset;

Loading…
Cancel
Save