Merge pull request #6509 from akallabeth/glyph_parser_fix

Fixed parsing of FastGlyph order.
This commit is contained in:
Martin Fleisz 2020-10-15 14:08:24 +02:00 committed by GitHub
commit 65ee6e3280
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1061,76 +1061,94 @@ static INLINE BOOL update_read_delta_points(wStream* s, DELTA_POINT* points, int
return TRUE; return TRUE;
} }
#define ORDER_FIELD_BYTE(NO, TARGET) \
do \ static INLINE BOOL read_order_field_byte(const ORDER_INFO* orderInfo, wStream* s, BYTE number,
{ \ UINT32* target, BOOL optional)
if (orderInfo->fieldFlags & (1 << (NO - 1))) \
{ \
if (Stream_GetRemainingLength(s) < 1) \
{ \
WLog_ERR(TAG, "error reading %s", #TARGET); \
return FALSE; \
} \
Stream_Read_UINT8(s, TARGET); \
} \
} while (0)
#define ORDER_FIELD_2BYTE(NO, TARGET1, TARGET2) \
do \
{ \
if (orderInfo->fieldFlags & (1 << (NO - 1))) \
{ \
if (Stream_GetRemainingLength(s) < 2) \
{ \
WLog_ERR(TAG, "error reading %s or %s", #TARGET1, #TARGET2); \
return FALSE; \
} \
Stream_Read_UINT8(s, TARGET1); \
Stream_Read_UINT8(s, TARGET2); \
} \
} while (0)
#define ORDER_FIELD_UINT16(NO, TARGET) \
do \
{ \
if (orderInfo->fieldFlags & (1 << (NO - 1))) \
{ \
if (Stream_GetRemainingLength(s) < 2) \
{ \
WLog_ERR(TAG, "error reading %s", #TARGET); \
return FALSE; \
} \
Stream_Read_UINT16(s, TARGET); \
} \
} while (0)
#define ORDER_FIELD_UINT32(NO, TARGET) \
do \
{ \
if (orderInfo->fieldFlags & (1 << (NO - 1))) \
{ \
if (Stream_GetRemainingLength(s) < 4) \
{ \
WLog_ERR(TAG, "error reading %s", #TARGET); \
return FALSE; \
} \
Stream_Read_UINT32(s, TARGET); \
} \
} while (0)
#define ORDER_FIELD_COORD(NO, TARGET) \
do \
{ \
if ((orderInfo->fieldFlags & (1 << (NO - 1))) && \
!update_read_coord(s, &TARGET, orderInfo->deltaCoordinates)) \
{ \
WLog_ERR(TAG, "error reading %s", #TARGET); \
return FALSE; \
} \
} while (0)
static INLINE BOOL ORDER_FIELD_COLOR(const ORDER_INFO* orderInfo, wStream* s, UINT32 NO,
UINT32* TARGET)
{ {
if (!TARGET || !orderInfo) const BOOL set = orderInfo->fieldFlags & (1 << (number - 1));
if (!set)
return TRUE;
if (Stream_GetRemainingLength(s) < 1)
return FALSE;
Stream_Read_UINT8(s, *target);
return TRUE;
}
static INLINE BOOL read_order_field_2bytes(const ORDER_INFO* orderInfo, wStream* s, BYTE number,
UINT32* target1, UINT32* target2, BOOL optional)
{
const BOOL set = orderInfo->fieldFlags & (1 << (number - 1));
if (!set)
return TRUE;
if (Stream_GetRemainingLength(s) < 2)
return FALSE;
Stream_Read_UINT8(s, *target1);
Stream_Read_UINT8(s, *target2);
return TRUE;
}
static INLINE BOOL read_order_field_uint16(const ORDER_INFO* orderInfo, wStream* s, BYTE number,
UINT32* target, BOOL optional)
{
const BOOL set = orderInfo->fieldFlags & (1 << (number - 1));
if (!set)
return TRUE;
if (Stream_GetRemainingLength(s) < 2)
return FALSE; return FALSE;
if ((orderInfo->fieldFlags & (1 << (NO - 1))) && !update_read_color(s, TARGET)) Stream_Read_UINT16(s, *target);
return TRUE;
}
static INLINE BOOL read_order_field_int16(const ORDER_INFO* orderInfo, wStream* s, BYTE number,
INT32* target, BOOL optional)
{
const BOOL set = orderInfo->fieldFlags & (1 << (number - 1));
if (!set)
return TRUE;
if (Stream_GetRemainingLength(s) < 2)
return FALSE;
Stream_Read_INT16(s, *target);
return TRUE;
}
static INLINE BOOL read_order_field_uint32(const ORDER_INFO* orderInfo, wStream* s, BYTE number,
UINT32* target, BOOL optional)
{
const BOOL set = orderInfo->fieldFlags & (1 << (number - 1));
if (!set)
return TRUE;
if (Stream_GetRemainingLength(s) < 4)
return FALSE;
Stream_Read_UINT32(s, *target);
}
static INLINE BOOL read_order_field_coord(const ORDER_INFO* orderInfo, wStream* s, UINT32 NO,
INT32* TARGET, BOOL optional)
{
const BOOL set = (orderInfo->fieldFlags & (1 << (NO - 1)));
if (!TARGET || !orderInfo)
return FALSE;
if (!set)
return TRUE;
return update_read_coord(s, TARGET, orderInfo->deltaCoordinates);
}
static INLINE BOOL read_order_field_color(const ORDER_INFO* orderInfo, wStream* s, UINT32 NO,
UINT32* TARGET, BOOL optional)
{
const BOOL set = (orderInfo->fieldFlags & (1 << (NO - 1)));
if (!TARGET || !orderInfo)
return FALSE;
if (!set)
return TRUE;
if (!update_read_color(s, TARGET))
return FALSE; return FALSE;
return TRUE; return TRUE;
@ -1153,12 +1171,13 @@ static INLINE BOOL FIELD_SKIP_BUFFER16(wStream* s, UINT32 TARGET_LEN)
/* Primary Drawing Orders */ /* Primary Drawing Orders */
static BOOL update_read_dstblt_order(wStream* s, const ORDER_INFO* orderInfo, DSTBLT_ORDER* dstblt) static BOOL update_read_dstblt_order(wStream* s, const ORDER_INFO* orderInfo, DSTBLT_ORDER* dstblt)
{ {
ORDER_FIELD_COORD(1, dstblt->nLeftRect); if (read_order_field_coord(orderInfo, s, 1, &dstblt->nLeftRect, FALSE) &&
ORDER_FIELD_COORD(2, dstblt->nTopRect); read_order_field_coord(orderInfo, s, 2, &dstblt->nTopRect, FALSE) &&
ORDER_FIELD_COORD(3, dstblt->nWidth); read_order_field_coord(orderInfo, s, 3, &dstblt->nWidth, FALSE) &&
ORDER_FIELD_COORD(4, dstblt->nHeight); read_order_field_coord(orderInfo, s, 4, &dstblt->nHeight, FALSE) &&
ORDER_FIELD_BYTE(5, dstblt->bRop); read_order_field_byte(orderInfo, s, 5, &dstblt->bRop, TRUE))
return TRUE; return TRUE;
return FALSE;
} }
int update_approximate_dstblt_order(ORDER_INFO* orderInfo, const DSTBLT_ORDER* dstblt) int update_approximate_dstblt_order(ORDER_INFO* orderInfo, const DSTBLT_ORDER* dstblt)
{ {
@ -1184,14 +1203,16 @@ BOOL update_write_dstblt_order(wStream* s, ORDER_INFO* orderInfo, const DSTBLT_O
} }
static BOOL update_read_patblt_order(wStream* s, const ORDER_INFO* orderInfo, PATBLT_ORDER* patblt) static BOOL update_read_patblt_order(wStream* s, const ORDER_INFO* orderInfo, PATBLT_ORDER* patblt)
{ {
ORDER_FIELD_COORD(1, patblt->nLeftRect); if (read_order_field_coord(orderInfo, s, 1, &patblt->nLeftRect, FALSE) &&
ORDER_FIELD_COORD(2, patblt->nTopRect); read_order_field_coord(orderInfo, s, 2, &patblt->nTopRect, FALSE) &&
ORDER_FIELD_COORD(3, patblt->nWidth); read_order_field_coord(orderInfo, s, 3, &patblt->nWidth, FALSE) &&
ORDER_FIELD_COORD(4, patblt->nHeight); read_order_field_coord(orderInfo, s, 4, &patblt->nHeight, FALSE) &&
ORDER_FIELD_BYTE(5, patblt->bRop); read_order_field_byte(orderInfo, s, 5, &patblt->bRop, TRUE) &&
ORDER_FIELD_COLOR(orderInfo, s, 6, &patblt->backColor); read_order_field_color(orderInfo, s, 6, &patblt->backColor, TRUE) &&
ORDER_FIELD_COLOR(orderInfo, s, 7, &patblt->foreColor); read_order_field_color(orderInfo, s, 7, &patblt->foreColor, TRUE) &&
return update_read_brush(s, &patblt->brush, orderInfo->fieldFlags >> 7); update_read_brush(s, &patblt->brush, orderInfo->fieldFlags >> 7))
return TRUE;
return FALSE;
} }
int update_approximate_patblt_order(ORDER_INFO* orderInfo, PATBLT_ORDER* patblt) int update_approximate_patblt_order(ORDER_INFO* orderInfo, PATBLT_ORDER* patblt)
{ {
@ -1227,14 +1248,15 @@ BOOL update_write_patblt_order(wStream* s, ORDER_INFO* orderInfo, PATBLT_ORDER*
} }
static BOOL update_read_scrblt_order(wStream* s, const ORDER_INFO* orderInfo, SCRBLT_ORDER* scrblt) static BOOL update_read_scrblt_order(wStream* s, const ORDER_INFO* orderInfo, SCRBLT_ORDER* scrblt)
{ {
ORDER_FIELD_COORD(1, scrblt->nLeftRect); if (read_order_field_coord(orderInfo, s, 1, &scrblt->nLeftRect, FALSE) &&
ORDER_FIELD_COORD(2, scrblt->nTopRect); read_order_field_coord(orderInfo, s, 2, &scrblt->nTopRect, FALSE) &&
ORDER_FIELD_COORD(3, scrblt->nWidth); read_order_field_coord(orderInfo, s, 3, &scrblt->nWidth, FALSE) &&
ORDER_FIELD_COORD(4, scrblt->nHeight); read_order_field_coord(orderInfo, s, 4, &scrblt->nHeight, FALSE) &&
ORDER_FIELD_BYTE(5, scrblt->bRop); read_order_field_byte(orderInfo, s, 5, &scrblt->bRop, TRUE) &&
ORDER_FIELD_COORD(6, scrblt->nXSrc); read_order_field_coord(orderInfo, s, 6, &scrblt->nXSrc, FALSE) &&
ORDER_FIELD_COORD(7, scrblt->nYSrc); read_order_field_coord(orderInfo, s, 7, &scrblt->nYSrc, FALSE))
return TRUE; return TRUE;
return FALSE;
} }
int update_approximate_scrblt_order(ORDER_INFO* orderInfo, const SCRBLT_ORDER* scrblt) int update_approximate_scrblt_order(ORDER_INFO* orderInfo, const SCRBLT_ORDER* scrblt)
{ {
@ -1266,12 +1288,13 @@ static BOOL update_read_opaque_rect_order(wStream* s, const ORDER_INFO* orderInf
OPAQUE_RECT_ORDER* opaque_rect) OPAQUE_RECT_ORDER* opaque_rect)
{ {
BYTE byte; BYTE byte;
ORDER_FIELD_COORD(1, opaque_rect->nLeftRect); if (!read_order_field_coord(orderInfo, s, 1, &opaque_rect->nLeftRect, FALSE) ||
ORDER_FIELD_COORD(2, opaque_rect->nTopRect); !read_order_field_coord(orderInfo, s, 2, &opaque_rect->nTopRect, FALSE) ||
ORDER_FIELD_COORD(3, opaque_rect->nWidth); !read_order_field_coord(orderInfo, s, 3, &opaque_rect->nWidth, FALSE) ||
ORDER_FIELD_COORD(4, opaque_rect->nHeight); !read_order_field_coord(orderInfo, s, 4, &opaque_rect->nHeight, FALSE))
return FALSE;
if (orderInfo->fieldFlags & ORDER_FIELD_05) if ((orderInfo->fieldFlags & ORDER_FIELD_05) != 0)
{ {
if (Stream_GetRemainingLength(s) < 1) if (Stream_GetRemainingLength(s) < 1)
return FALSE; return FALSE;
@ -1280,7 +1303,7 @@ static BOOL update_read_opaque_rect_order(wStream* s, const ORDER_INFO* orderInf
opaque_rect->color = (opaque_rect->color & 0x00FFFF00) | ((UINT32)byte); opaque_rect->color = (opaque_rect->color & 0x00FFFF00) | ((UINT32)byte);
} }
if (orderInfo->fieldFlags & ORDER_FIELD_06) if ((orderInfo->fieldFlags & ORDER_FIELD_06) != 0)
{ {
if (Stream_GetRemainingLength(s) < 1) if (Stream_GetRemainingLength(s) < 1)
return FALSE; return FALSE;
@ -1289,7 +1312,7 @@ static BOOL update_read_opaque_rect_order(wStream* s, const ORDER_INFO* orderInf
opaque_rect->color = (opaque_rect->color & 0x00FF00FF) | ((UINT32)byte << 8); opaque_rect->color = (opaque_rect->color & 0x00FF00FF) | ((UINT32)byte << 8);
} }
if (orderInfo->fieldFlags & ORDER_FIELD_07) if ((orderInfo->fieldFlags & ORDER_FIELD_07) != 0)
{ {
if (Stream_GetRemainingLength(s) < 1) if (Stream_GetRemainingLength(s) < 1)
return FALSE; return FALSE;
@ -1338,24 +1361,26 @@ BOOL update_write_opaque_rect_order(wStream* s, ORDER_INFO* orderInfo,
static BOOL update_read_draw_nine_grid_order(wStream* s, const ORDER_INFO* orderInfo, static BOOL update_read_draw_nine_grid_order(wStream* s, const ORDER_INFO* orderInfo,
DRAW_NINE_GRID_ORDER* draw_nine_grid) DRAW_NINE_GRID_ORDER* draw_nine_grid)
{ {
ORDER_FIELD_COORD(1, draw_nine_grid->srcLeft); if (read_order_field_coord(orderInfo, s, 1, &draw_nine_grid->srcLeft, FALSE) &&
ORDER_FIELD_COORD(2, draw_nine_grid->srcTop); read_order_field_coord(orderInfo, s, 2, &draw_nine_grid->srcTop, FALSE) &&
ORDER_FIELD_COORD(3, draw_nine_grid->srcRight); read_order_field_coord(orderInfo, s, 3, &draw_nine_grid->srcRight, FALSE) &&
ORDER_FIELD_COORD(4, draw_nine_grid->srcBottom); read_order_field_coord(orderInfo, s, 4, &draw_nine_grid->srcBottom, FALSE) &&
ORDER_FIELD_UINT16(5, draw_nine_grid->bitmapId); read_order_field_uint16(orderInfo, s, 5, &draw_nine_grid->bitmapId, FALSE))
return TRUE; return TRUE;
return FALSE;
} }
static BOOL update_read_multi_dstblt_order(wStream* s, const ORDER_INFO* orderInfo, static BOOL update_read_multi_dstblt_order(wStream* s, const ORDER_INFO* orderInfo,
MULTI_DSTBLT_ORDER* multi_dstblt) MULTI_DSTBLT_ORDER* multi_dstblt)
{ {
ORDER_FIELD_COORD(1, multi_dstblt->nLeftRect); if (!read_order_field_coord(orderInfo, s, 1, &multi_dstblt->nLeftRect, FALSE) ||
ORDER_FIELD_COORD(2, multi_dstblt->nTopRect); !read_order_field_coord(orderInfo, s, 2, &multi_dstblt->nTopRect, FALSE) ||
ORDER_FIELD_COORD(3, multi_dstblt->nWidth); !read_order_field_coord(orderInfo, s, 3, &multi_dstblt->nWidth, FALSE) ||
ORDER_FIELD_COORD(4, multi_dstblt->nHeight); !read_order_field_coord(orderInfo, s, 4, &multi_dstblt->nHeight, FALSE) ||
ORDER_FIELD_BYTE(5, multi_dstblt->bRop); !read_order_field_byte(orderInfo, s, 5, &multi_dstblt->bRop, TRUE) ||
ORDER_FIELD_BYTE(6, multi_dstblt->numRectangles); !read_order_field_byte(orderInfo, s, 6, &multi_dstblt->numRectangles, TRUE))
return FALSE;
if (orderInfo->fieldFlags & ORDER_FIELD_07) if ((orderInfo->fieldFlags & ORDER_FIELD_07) != 0)
{ {
if (Stream_GetRemainingLength(s) < 2) if (Stream_GetRemainingLength(s) < 2)
return FALSE; return FALSE;
@ -1369,20 +1394,22 @@ static BOOL update_read_multi_dstblt_order(wStream* s, const ORDER_INFO* orderIn
static BOOL update_read_multi_patblt_order(wStream* s, const ORDER_INFO* orderInfo, static BOOL update_read_multi_patblt_order(wStream* s, const ORDER_INFO* orderInfo,
MULTI_PATBLT_ORDER* multi_patblt) MULTI_PATBLT_ORDER* multi_patblt)
{ {
ORDER_FIELD_COORD(1, multi_patblt->nLeftRect); if (!read_order_field_coord(orderInfo, s, 1, &multi_patblt->nLeftRect, FALSE) ||
ORDER_FIELD_COORD(2, multi_patblt->nTopRect); !read_order_field_coord(orderInfo, s, 2, &multi_patblt->nTopRect, FALSE) ||
ORDER_FIELD_COORD(3, multi_patblt->nWidth); !read_order_field_coord(orderInfo, s, 3, &multi_patblt->nWidth, FALSE) ||
ORDER_FIELD_COORD(4, multi_patblt->nHeight); !read_order_field_coord(orderInfo, s, 4, &multi_patblt->nHeight, FALSE) ||
ORDER_FIELD_BYTE(5, multi_patblt->bRop); !read_order_field_byte(orderInfo, s, 5, &multi_patblt->bRop, TRUE) ||
ORDER_FIELD_COLOR(orderInfo, s, 6, &multi_patblt->backColor); !read_order_field_color(orderInfo, s, 6, &multi_patblt->backColor, TRUE) ||
ORDER_FIELD_COLOR(orderInfo, s, 7, &multi_patblt->foreColor); !read_order_field_color(orderInfo, s, 7, &multi_patblt->foreColor, TRUE))
return FALSE;
if (!update_read_brush(s, &multi_patblt->brush, orderInfo->fieldFlags >> 7)) if (!update_read_brush(s, &multi_patblt->brush, orderInfo->fieldFlags >> 7))
return FALSE; return FALSE;
ORDER_FIELD_BYTE(13, multi_patblt->numRectangles); if (!read_order_field_byte(orderInfo, s, 13, &multi_patblt->numRectangles, TRUE))
return FALSE;
if (orderInfo->fieldFlags & ORDER_FIELD_14) if ((orderInfo->fieldFlags & ORDER_FIELD_14) != 0)
{ {
if (Stream_GetRemainingLength(s) < 2) if (Stream_GetRemainingLength(s) < 2)
return FALSE; return FALSE;
@ -1398,16 +1425,17 @@ static BOOL update_read_multi_patblt_order(wStream* s, const ORDER_INFO* orderIn
static BOOL update_read_multi_scrblt_order(wStream* s, const ORDER_INFO* orderInfo, static BOOL update_read_multi_scrblt_order(wStream* s, const ORDER_INFO* orderInfo,
MULTI_SCRBLT_ORDER* multi_scrblt) MULTI_SCRBLT_ORDER* multi_scrblt)
{ {
ORDER_FIELD_COORD(1, multi_scrblt->nLeftRect); if (!read_order_field_coord(orderInfo, s, 1, &multi_scrblt->nLeftRect, FALSE) ||
ORDER_FIELD_COORD(2, multi_scrblt->nTopRect); !read_order_field_coord(orderInfo, s, 2, &multi_scrblt->nTopRect, FALSE) ||
ORDER_FIELD_COORD(3, multi_scrblt->nWidth); !read_order_field_coord(orderInfo, s, 3, &multi_scrblt->nWidth, FALSE) ||
ORDER_FIELD_COORD(4, multi_scrblt->nHeight); !read_order_field_coord(orderInfo, s, 4, &multi_scrblt->nHeight, FALSE) ||
ORDER_FIELD_BYTE(5, multi_scrblt->bRop); !read_order_field_byte(orderInfo, s, 5, &multi_scrblt->bRop, TRUE) ||
ORDER_FIELD_COORD(6, multi_scrblt->nXSrc); !read_order_field_coord(orderInfo, s, 6, &multi_scrblt->nXSrc, FALSE) ||
ORDER_FIELD_COORD(7, multi_scrblt->nYSrc); !read_order_field_coord(orderInfo, s, 7, &multi_scrblt->nYSrc, FALSE) ||
ORDER_FIELD_BYTE(8, multi_scrblt->numRectangles); !read_order_field_byte(orderInfo, s, 8, &multi_scrblt->numRectangles, TRUE))
return FALSE;
if (orderInfo->fieldFlags & ORDER_FIELD_09) if ((orderInfo->fieldFlags & ORDER_FIELD_09) != 0)
{ {
if (Stream_GetRemainingLength(s) < 2) if (Stream_GetRemainingLength(s) < 2)
return FALSE; return FALSE;
@ -1422,12 +1450,13 @@ static BOOL update_read_multi_opaque_rect_order(wStream* s, const ORDER_INFO* or
MULTI_OPAQUE_RECT_ORDER* multi_opaque_rect) MULTI_OPAQUE_RECT_ORDER* multi_opaque_rect)
{ {
BYTE byte; BYTE byte;
ORDER_FIELD_COORD(1, multi_opaque_rect->nLeftRect); if (!read_order_field_coord(orderInfo, s, 1, &multi_opaque_rect->nLeftRect, FALSE) ||
ORDER_FIELD_COORD(2, multi_opaque_rect->nTopRect); !read_order_field_coord(orderInfo, s, 2, &multi_opaque_rect->nTopRect, FALSE) ||
ORDER_FIELD_COORD(3, multi_opaque_rect->nWidth); !read_order_field_coord(orderInfo, s, 3, &multi_opaque_rect->nWidth, FALSE) ||
ORDER_FIELD_COORD(4, multi_opaque_rect->nHeight); !read_order_field_coord(orderInfo, s, 4, &multi_opaque_rect->nHeight, FALSE))
return FALSE;
if (orderInfo->fieldFlags & ORDER_FIELD_05) if ((orderInfo->fieldFlags & ORDER_FIELD_05) != 0)
{ {
if (Stream_GetRemainingLength(s) < 1) if (Stream_GetRemainingLength(s) < 1)
return FALSE; return FALSE;
@ -1436,7 +1465,7 @@ static BOOL update_read_multi_opaque_rect_order(wStream* s, const ORDER_INFO* or
multi_opaque_rect->color = (multi_opaque_rect->color & 0x00FFFF00) | ((UINT32)byte); multi_opaque_rect->color = (multi_opaque_rect->color & 0x00FFFF00) | ((UINT32)byte);
} }
if (orderInfo->fieldFlags & ORDER_FIELD_06) if ((orderInfo->fieldFlags & ORDER_FIELD_06) != 0)
{ {
if (Stream_GetRemainingLength(s) < 1) if (Stream_GetRemainingLength(s) < 1)
return FALSE; return FALSE;
@ -1445,7 +1474,7 @@ static BOOL update_read_multi_opaque_rect_order(wStream* s, const ORDER_INFO* or
multi_opaque_rect->color = (multi_opaque_rect->color & 0x00FF00FF) | ((UINT32)byte << 8); multi_opaque_rect->color = (multi_opaque_rect->color & 0x00FF00FF) | ((UINT32)byte << 8);
} }
if (orderInfo->fieldFlags & ORDER_FIELD_07) if ((orderInfo->fieldFlags & ORDER_FIELD_07) != 0)
{ {
if (Stream_GetRemainingLength(s) < 1) if (Stream_GetRemainingLength(s) < 1)
return FALSE; return FALSE;
@ -1454,9 +1483,10 @@ static BOOL update_read_multi_opaque_rect_order(wStream* s, const ORDER_INFO* or
multi_opaque_rect->color = (multi_opaque_rect->color & 0x0000FFFF) | ((UINT32)byte << 16); multi_opaque_rect->color = (multi_opaque_rect->color & 0x0000FFFF) | ((UINT32)byte << 16);
} }
ORDER_FIELD_BYTE(8, multi_opaque_rect->numRectangles); if (!read_order_field_byte(orderInfo, s, 8, &multi_opaque_rect->numRectangles, TRUE))
return FALSE;
if (orderInfo->fieldFlags & ORDER_FIELD_09) if ((orderInfo->fieldFlags & ORDER_FIELD_09) != 0)
{ {
if (Stream_GetRemainingLength(s) < 2) if (Stream_GetRemainingLength(s) < 2)
return FALSE; return FALSE;
@ -1471,14 +1501,15 @@ static BOOL update_read_multi_opaque_rect_order(wStream* s, const ORDER_INFO* or
static BOOL update_read_multi_draw_nine_grid_order(wStream* s, const ORDER_INFO* orderInfo, static BOOL update_read_multi_draw_nine_grid_order(wStream* s, const ORDER_INFO* orderInfo,
MULTI_DRAW_NINE_GRID_ORDER* multi_draw_nine_grid) MULTI_DRAW_NINE_GRID_ORDER* multi_draw_nine_grid)
{ {
ORDER_FIELD_COORD(1, multi_draw_nine_grid->srcLeft); if (!read_order_field_coord(orderInfo, s, 1, &multi_draw_nine_grid->srcLeft, FALSE) ||
ORDER_FIELD_COORD(2, multi_draw_nine_grid->srcTop); !read_order_field_coord(orderInfo, s, 2, &multi_draw_nine_grid->srcTop, FALSE) ||
ORDER_FIELD_COORD(3, multi_draw_nine_grid->srcRight); !read_order_field_coord(orderInfo, s, 3, &multi_draw_nine_grid->srcRight, FALSE) ||
ORDER_FIELD_COORD(4, multi_draw_nine_grid->srcBottom); !read_order_field_coord(orderInfo, s, 4, &multi_draw_nine_grid->srcBottom, FALSE) ||
ORDER_FIELD_UINT16(5, multi_draw_nine_grid->bitmapId); !read_order_field_uint16(orderInfo, s, 5, &multi_draw_nine_grid->bitmapId, TRUE) ||
ORDER_FIELD_BYTE(6, multi_draw_nine_grid->nDeltaEntries); !read_order_field_byte(orderInfo, s, 6, &multi_draw_nine_grid->nDeltaEntries, TRUE))
return FALSE;
if (orderInfo->fieldFlags & ORDER_FIELD_07) if ((orderInfo->fieldFlags & ORDER_FIELD_07) != 0)
{ {
if (Stream_GetRemainingLength(s) < 2) if (Stream_GetRemainingLength(s) < 2)
return FALSE; return FALSE;
@ -1493,17 +1524,18 @@ static BOOL update_read_multi_draw_nine_grid_order(wStream* s, const ORDER_INFO*
static BOOL update_read_line_to_order(wStream* s, const ORDER_INFO* orderInfo, static BOOL update_read_line_to_order(wStream* s, const ORDER_INFO* orderInfo,
LINE_TO_ORDER* line_to) LINE_TO_ORDER* line_to)
{ {
ORDER_FIELD_UINT16(1, line_to->backMode); if (read_order_field_uint16(orderInfo, s, 1, &line_to->backMode, TRUE) &&
ORDER_FIELD_COORD(2, line_to->nXStart); read_order_field_coord(orderInfo, s, 2, &line_to->nXStart, FALSE) &&
ORDER_FIELD_COORD(3, line_to->nYStart); read_order_field_coord(orderInfo, s, 3, &line_to->nYStart, FALSE) &&
ORDER_FIELD_COORD(4, line_to->nXEnd); read_order_field_coord(orderInfo, s, 4, &line_to->nXEnd, FALSE) &&
ORDER_FIELD_COORD(5, line_to->nYEnd); read_order_field_coord(orderInfo, s, 5, &line_to->nYEnd, FALSE) &&
ORDER_FIELD_COLOR(orderInfo, s, 6, &line_to->backColor); read_order_field_color(orderInfo, s, 6, &line_to->backColor, TRUE) &&
ORDER_FIELD_BYTE(7, line_to->bRop2); read_order_field_byte(orderInfo, s, 7, &line_to->bRop2, TRUE) &&
ORDER_FIELD_BYTE(8, line_to->penStyle); read_order_field_byte(orderInfo, s, 8, &line_to->penStyle, TRUE) &&
ORDER_FIELD_BYTE(9, line_to->penWidth); read_order_field_byte(orderInfo, s, 9, &line_to->penWidth, TRUE) &&
ORDER_FIELD_COLOR(orderInfo, s, 10, &line_to->penColor); read_order_field_color(orderInfo, s, 10, &line_to->penColor, TRUE))
return TRUE; return TRUE;
return FALSE;
} }
int update_approximate_line_to_order(ORDER_INFO* orderInfo, const LINE_TO_ORDER* line_to) int update_approximate_line_to_order(ORDER_INFO* orderInfo, const LINE_TO_ORDER* line_to)
{ {
@ -1540,16 +1572,17 @@ BOOL update_write_line_to_order(wStream* s, ORDER_INFO* orderInfo, const LINE_TO
static BOOL update_read_polyline_order(wStream* s, const ORDER_INFO* orderInfo, static BOOL update_read_polyline_order(wStream* s, const ORDER_INFO* orderInfo,
POLYLINE_ORDER* polyline) POLYLINE_ORDER* polyline)
{ {
UINT16 word; UINT32 word;
UINT32 new_num = polyline->numDeltaEntries; UINT32 new_num = polyline->numDeltaEntries;
ORDER_FIELD_COORD(1, polyline->xStart); if (!read_order_field_coord(orderInfo, s, 1, &polyline->xStart, FALSE) ||
ORDER_FIELD_COORD(2, polyline->yStart); !read_order_field_coord(orderInfo, s, 2, &polyline->yStart, FALSE) ||
ORDER_FIELD_BYTE(3, polyline->bRop2); !read_order_field_byte(orderInfo, s, 3, &polyline->bRop2, TRUE) ||
ORDER_FIELD_UINT16(4, word); !read_order_field_uint16(orderInfo, s, 4, &word, TRUE) ||
ORDER_FIELD_COLOR(orderInfo, s, 5, &polyline->penColor); !read_order_field_color(orderInfo, s, 5, &polyline->penColor, TRUE) ||
ORDER_FIELD_BYTE(6, new_num); !read_order_field_byte(orderInfo, s, 6, &new_num, TRUE))
return FALSE;
if (orderInfo->fieldFlags & ORDER_FIELD_07) if ((orderInfo->fieldFlags & ORDER_FIELD_07) != 0)
{ {
DELTA_POINT* new_points; DELTA_POINT* new_points;
@ -1584,15 +1617,16 @@ static BOOL update_read_memblt_order(wStream* s, const ORDER_INFO* orderInfo, ME
if (!s || !orderInfo || !memblt) if (!s || !orderInfo || !memblt)
return FALSE; return FALSE;
ORDER_FIELD_UINT16(1, memblt->cacheId); if (!read_order_field_uint16(orderInfo, s, 1, &memblt->cacheId, TRUE) ||
ORDER_FIELD_COORD(2, memblt->nLeftRect); !read_order_field_coord(orderInfo, s, 2, &memblt->nLeftRect, FALSE) ||
ORDER_FIELD_COORD(3, memblt->nTopRect); !read_order_field_coord(orderInfo, s, 3, &memblt->nTopRect, FALSE) ||
ORDER_FIELD_COORD(4, memblt->nWidth); !read_order_field_coord(orderInfo, s, 4, &memblt->nWidth, FALSE) ||
ORDER_FIELD_COORD(5, memblt->nHeight); !read_order_field_coord(orderInfo, s, 5, &memblt->nHeight, FALSE) ||
ORDER_FIELD_BYTE(6, memblt->bRop); !read_order_field_byte(orderInfo, s, 6, &memblt->bRop, TRUE) ||
ORDER_FIELD_COORD(7, memblt->nXSrc); !read_order_field_coord(orderInfo, s, 7, &memblt->nXSrc, FALSE) ||
ORDER_FIELD_COORD(8, memblt->nYSrc); !read_order_field_coord(orderInfo, s, 8, &memblt->nYSrc, FALSE) ||
ORDER_FIELD_UINT16(9, memblt->cacheIndex); !read_order_field_uint16(orderInfo, s, 9, &memblt->cacheIndex, TRUE))
return FALSE;
memblt->colorIndex = (memblt->cacheId >> 8); memblt->colorIndex = (memblt->cacheId >> 8);
memblt->cacheId = (memblt->cacheId & 0xFF); memblt->cacheId = (memblt->cacheId & 0xFF);
memblt->bitmap = NULL; memblt->bitmap = NULL;
@ -1633,21 +1667,21 @@ BOOL update_write_memblt_order(wStream* s, ORDER_INFO* orderInfo, const MEMBLT_O
static BOOL update_read_mem3blt_order(wStream* s, const ORDER_INFO* orderInfo, static BOOL update_read_mem3blt_order(wStream* s, const ORDER_INFO* orderInfo,
MEM3BLT_ORDER* mem3blt) MEM3BLT_ORDER* mem3blt)
{ {
ORDER_FIELD_UINT16(1, mem3blt->cacheId); if (!read_order_field_uint16(orderInfo, s, 1, &mem3blt->cacheId, TRUE) ||
ORDER_FIELD_COORD(2, mem3blt->nLeftRect); !read_order_field_coord(orderInfo, s, 2, &mem3blt->nLeftRect, FALSE) ||
ORDER_FIELD_COORD(3, mem3blt->nTopRect); !read_order_field_coord(orderInfo, s, 3, &mem3blt->nTopRect, FALSE) ||
ORDER_FIELD_COORD(4, mem3blt->nWidth); !read_order_field_coord(orderInfo, s, 4, &mem3blt->nWidth, FALSE) ||
ORDER_FIELD_COORD(5, mem3blt->nHeight); !read_order_field_coord(orderInfo, s, 5, &mem3blt->nHeight, FALSE) ||
ORDER_FIELD_BYTE(6, mem3blt->bRop); !read_order_field_byte(orderInfo, s, 6, &mem3blt->bRop, TRUE) ||
ORDER_FIELD_COORD(7, mem3blt->nXSrc); !read_order_field_coord(orderInfo, s, 7, &mem3blt->nXSrc, FALSE) ||
ORDER_FIELD_COORD(8, mem3blt->nYSrc); !read_order_field_coord(orderInfo, s, 8, &mem3blt->nYSrc, FALSE) ||
ORDER_FIELD_COLOR(orderInfo, s, 9, &mem3blt->backColor); !read_order_field_color(orderInfo, s, 9, &mem3blt->backColor, TRUE) ||
ORDER_FIELD_COLOR(orderInfo, s, 10, &mem3blt->foreColor); !read_order_field_color(orderInfo, s, 10, &mem3blt->foreColor, TRUE))
if (!update_read_brush(s, &mem3blt->brush, orderInfo->fieldFlags >> 10))
return FALSE; return FALSE;
ORDER_FIELD_UINT16(16, mem3blt->cacheIndex); if (!update_read_brush(s, &mem3blt->brush, orderInfo->fieldFlags >> 10) ||
!read_order_field_uint16(orderInfo, s, 16, &mem3blt->cacheIndex, TRUE))
return FALSE;
mem3blt->colorIndex = (mem3blt->cacheId >> 8); mem3blt->colorIndex = (mem3blt->cacheId >> 8);
mem3blt->cacheId = (mem3blt->cacheId & 0xFF); mem3blt->cacheId = (mem3blt->cacheId & 0xFF);
mem3blt->bitmap = NULL; mem3blt->bitmap = NULL;
@ -1656,39 +1690,38 @@ static BOOL update_read_mem3blt_order(wStream* s, const ORDER_INFO* orderInfo,
static BOOL update_read_save_bitmap_order(wStream* s, const ORDER_INFO* orderInfo, static BOOL update_read_save_bitmap_order(wStream* s, const ORDER_INFO* orderInfo,
SAVE_BITMAP_ORDER* save_bitmap) SAVE_BITMAP_ORDER* save_bitmap)
{ {
ORDER_FIELD_UINT32(1, save_bitmap->savedBitmapPosition); if (read_order_field_uint32(orderInfo, s, 1, &save_bitmap->savedBitmapPosition, TRUE) &&
ORDER_FIELD_COORD(2, save_bitmap->nLeftRect); read_order_field_coord(orderInfo, s, 2, &save_bitmap->nLeftRect, FALSE) &&
ORDER_FIELD_COORD(3, save_bitmap->nTopRect); read_order_field_coord(orderInfo, s, 3, &save_bitmap->nTopRect, FALSE) &&
ORDER_FIELD_COORD(4, save_bitmap->nRightRect); read_order_field_coord(orderInfo, s, 4, &save_bitmap->nRightRect, FALSE) &&
ORDER_FIELD_COORD(5, save_bitmap->nBottomRect); read_order_field_coord(orderInfo, s, 5, &save_bitmap->nBottomRect, FALSE) &&
ORDER_FIELD_BYTE(6, save_bitmap->operation); read_order_field_byte(orderInfo, s, 6, &save_bitmap->operation, TRUE))
return TRUE; return TRUE;
return FALSE;
} }
static BOOL update_read_glyph_index_order(wStream* s, const ORDER_INFO* orderInfo, static BOOL update_read_glyph_index_order(wStream* s, const ORDER_INFO* orderInfo,
GLYPH_INDEX_ORDER* glyph_index) GLYPH_INDEX_ORDER* glyph_index)
{ {
ORDER_FIELD_BYTE(1, glyph_index->cacheId); if (!read_order_field_byte(orderInfo, s, 1, &glyph_index->cacheId, TRUE) ||
ORDER_FIELD_BYTE(2, glyph_index->flAccel); !read_order_field_byte(orderInfo, s, 2, &glyph_index->flAccel, TRUE) ||
ORDER_FIELD_BYTE(3, glyph_index->ulCharInc); !read_order_field_byte(orderInfo, s, 3, &glyph_index->ulCharInc, TRUE) ||
ORDER_FIELD_BYTE(4, glyph_index->fOpRedundant); !read_order_field_byte(orderInfo, s, 4, &glyph_index->fOpRedundant, TRUE) ||
ORDER_FIELD_COLOR(orderInfo, s, 5, &glyph_index->backColor); !read_order_field_color(orderInfo, s, 5, &glyph_index->backColor, TRUE) ||
ORDER_FIELD_COLOR(orderInfo, s, 6, &glyph_index->foreColor); !read_order_field_color(orderInfo, s, 6, &glyph_index->foreColor, TRUE) ||
ORDER_FIELD_UINT16(7, glyph_index->bkLeft); !read_order_field_int16(orderInfo, s, 7, &glyph_index->bkLeft, TRUE) ||
ORDER_FIELD_UINT16(8, glyph_index->bkTop); !read_order_field_int16(orderInfo, s, 8, &glyph_index->bkTop, TRUE) ||
ORDER_FIELD_UINT16(9, glyph_index->bkRight); !read_order_field_int16(orderInfo, s, 9, &glyph_index->bkRight, TRUE) ||
ORDER_FIELD_UINT16(10, glyph_index->bkBottom); !read_order_field_int16(orderInfo, s, 10, &glyph_index->bkBottom, TRUE) ||
ORDER_FIELD_UINT16(11, glyph_index->opLeft); !read_order_field_int16(orderInfo, s, 11, &glyph_index->opLeft, TRUE) ||
ORDER_FIELD_UINT16(12, glyph_index->opTop); !read_order_field_int16(orderInfo, s, 12, &glyph_index->opTop, TRUE) ||
ORDER_FIELD_UINT16(13, glyph_index->opRight); !read_order_field_int16(orderInfo, s, 13, &glyph_index->opRight, TRUE) ||
ORDER_FIELD_UINT16(14, glyph_index->opBottom); !read_order_field_int16(orderInfo, s, 14, &glyph_index->opBottom, TRUE) ||
!update_read_brush(s, &glyph_index->brush, orderInfo->fieldFlags >> 14) ||
if (!update_read_brush(s, &glyph_index->brush, orderInfo->fieldFlags >> 14)) !read_order_field_int16(orderInfo, s, 20, &glyph_index->x, TRUE) ||
!read_order_field_int16(orderInfo, s, 21, &glyph_index->y, TRUE))
return FALSE; return FALSE;
ORDER_FIELD_UINT16(20, glyph_index->x); if ((orderInfo->fieldFlags & ORDER_FIELD_22) != 0)
ORDER_FIELD_UINT16(21, glyph_index->y);
if (orderInfo->fieldFlags & ORDER_FIELD_22)
{ {
if (Stream_GetRemainingLength(s) < 1) if (Stream_GetRemainingLength(s) < 1)
return FALSE; return FALSE;
@ -1764,22 +1797,24 @@ BOOL update_write_glyph_index_order(wStream* s, ORDER_INFO* orderInfo,
static BOOL update_read_fast_index_order(wStream* s, const ORDER_INFO* orderInfo, static BOOL update_read_fast_index_order(wStream* s, const ORDER_INFO* orderInfo,
FAST_INDEX_ORDER* fast_index) FAST_INDEX_ORDER* fast_index)
{ {
ORDER_FIELD_BYTE(1, fast_index->cacheId); if (!read_order_field_byte(orderInfo, s, 1, &fast_index->cacheId, TRUE) ||
ORDER_FIELD_2BYTE(2, fast_index->ulCharInc, fast_index->flAccel); !read_order_field_2bytes(orderInfo, s, 2, &fast_index->ulCharInc, &fast_index->flAccel,
ORDER_FIELD_COLOR(orderInfo, s, 3, &fast_index->backColor); TRUE) ||
ORDER_FIELD_COLOR(orderInfo, s, 4, &fast_index->foreColor); !read_order_field_color(orderInfo, s, 3, &fast_index->backColor, TRUE) ||
ORDER_FIELD_COORD(5, fast_index->bkLeft); !read_order_field_color(orderInfo, s, 4, &fast_index->foreColor, TRUE) ||
ORDER_FIELD_COORD(6, fast_index->bkTop); !read_order_field_coord(orderInfo, s, 5, &fast_index->bkLeft, FALSE) ||
ORDER_FIELD_COORD(7, fast_index->bkRight); !read_order_field_coord(orderInfo, s, 6, &fast_index->bkTop, FALSE) ||
ORDER_FIELD_COORD(8, fast_index->bkBottom); !read_order_field_coord(orderInfo, s, 7, &fast_index->bkRight, FALSE) ||
ORDER_FIELD_COORD(9, fast_index->opLeft); !read_order_field_coord(orderInfo, s, 8, &fast_index->bkBottom, FALSE) ||
ORDER_FIELD_COORD(10, fast_index->opTop); !read_order_field_coord(orderInfo, s, 9, &fast_index->opLeft, FALSE) ||
ORDER_FIELD_COORD(11, fast_index->opRight); !read_order_field_coord(orderInfo, s, 10, &fast_index->opTop, FALSE) ||
ORDER_FIELD_COORD(12, fast_index->opBottom); !read_order_field_coord(orderInfo, s, 11, &fast_index->opRight, FALSE) ||
ORDER_FIELD_COORD(13, fast_index->x); !read_order_field_coord(orderInfo, s, 12, &fast_index->opBottom, FALSE) ||
ORDER_FIELD_COORD(14, fast_index->y); !read_order_field_coord(orderInfo, s, 13, &fast_index->x, FALSE) ||
!read_order_field_coord(orderInfo, s, 14, &fast_index->y, FALSE))
return FALSE;
if (orderInfo->fieldFlags & ORDER_FIELD_15) if ((orderInfo->fieldFlags & ORDER_FIELD_15) != 0)
{ {
if (Stream_GetRemainingLength(s) < 1) if (Stream_GetRemainingLength(s) < 1)
return FALSE; return FALSE;
@ -1799,71 +1834,68 @@ static BOOL update_read_fast_glyph_order(wStream* s, const ORDER_INFO* orderInfo
FAST_GLYPH_ORDER* fastGlyph) FAST_GLYPH_ORDER* fastGlyph)
{ {
GLYPH_DATA_V2* glyph = &fastGlyph->glyphData; GLYPH_DATA_V2* glyph = &fastGlyph->glyphData;
ORDER_FIELD_BYTE(1, fastGlyph->cacheId); if (!read_order_field_byte(orderInfo, s, 1, &fastGlyph->cacheId, TRUE))
ORDER_FIELD_2BYTE(2, fastGlyph->ulCharInc, fastGlyph->flAccel); return FALSE;
ORDER_FIELD_COLOR(orderInfo, s, 3, &fastGlyph->backColor); if (fastGlyph->cacheId > 9)
ORDER_FIELD_COLOR(orderInfo, s, 4, &fastGlyph->foreColor); return FALSE;
ORDER_FIELD_COORD(5, fastGlyph->bkLeft); if (!read_order_field_2bytes(orderInfo, s, 2, &fastGlyph->ulCharInc, &fastGlyph->flAccel,
ORDER_FIELD_COORD(6, fastGlyph->bkTop); TRUE) ||
ORDER_FIELD_COORD(7, fastGlyph->bkRight); !read_order_field_color(orderInfo, s, 3, &fastGlyph->backColor, TRUE) ||
ORDER_FIELD_COORD(8, fastGlyph->bkBottom); !read_order_field_color(orderInfo, s, 4, &fastGlyph->foreColor, TRUE) ||
ORDER_FIELD_COORD(9, fastGlyph->opLeft); !read_order_field_coord(orderInfo, s, 5, &fastGlyph->bkLeft, FALSE) ||
ORDER_FIELD_COORD(10, fastGlyph->opTop); !read_order_field_coord(orderInfo, s, 6, &fastGlyph->bkTop, FALSE) ||
ORDER_FIELD_COORD(11, fastGlyph->opRight); !read_order_field_coord(orderInfo, s, 7, &fastGlyph->bkRight, FALSE) ||
ORDER_FIELD_COORD(12, fastGlyph->opBottom); !read_order_field_coord(orderInfo, s, 8, &fastGlyph->bkBottom, FALSE) ||
ORDER_FIELD_COORD(13, fastGlyph->x); !read_order_field_coord(orderInfo, s, 9, &fastGlyph->opLeft, FALSE) ||
ORDER_FIELD_COORD(14, fastGlyph->y); !read_order_field_coord(orderInfo, s, 10, &fastGlyph->opTop, FALSE) ||
!read_order_field_coord(orderInfo, s, 11, &fastGlyph->opRight, FALSE) ||
!read_order_field_coord(orderInfo, s, 12, &fastGlyph->opBottom, FALSE) ||
!read_order_field_coord(orderInfo, s, 13, &fastGlyph->x, FALSE) ||
!read_order_field_coord(orderInfo, s, 14, &fastGlyph->y, FALSE))
return FALSE;
if (orderInfo->fieldFlags & ORDER_FIELD_15) if ((orderInfo->fieldFlags & ORDER_FIELD_15) != 0)
{ {
const BYTE* src;
wStream sub;
if (Stream_GetRemainingLength(s) < 1) if (Stream_GetRemainingLength(s) < 1)
return FALSE; return FALSE;
Stream_Read_UINT8(s, fastGlyph->cbData); Stream_Read_UINT8(s, fastGlyph->cbData);
if (Stream_GetRemainingLength(s) < fastGlyph->cbData) src = Stream_Pointer(s);
if (!Stream_SafeSeek(s, fastGlyph->cbData) || (fastGlyph->cbData == 0))
return FALSE; return FALSE;
CopyMemory(fastGlyph->data, Stream_Pointer(s), fastGlyph->cbData); CopyMemory(fastGlyph->data, src, fastGlyph->cbData);
if (Stream_GetRemainingLength(s) < fastGlyph->cbData) Stream_StaticInit(&sub, fastGlyph->data, fastGlyph->cbData);
return FALSE;
if (!Stream_SafeSeek(s, 1)) Stream_Read_UINT8(&sub, glyph->cacheIndex);
return FALSE;
if (fastGlyph->cbData > 1) if (fastGlyph->cbData > 1)
{ {
UINT32 new_cb; if (!update_read_2byte_signed(&sub, &glyph->x) ||
/* parse optional glyph data */ !update_read_2byte_signed(&sub, &glyph->y) ||
glyph->cacheIndex = fastGlyph->data[0]; !update_read_2byte_unsigned(&sub, &glyph->cx) ||
!update_read_2byte_unsigned(&sub, &glyph->cy))
if (!update_read_2byte_signed(s, &glyph->x) ||
!update_read_2byte_signed(s, &glyph->y) ||
!update_read_2byte_unsigned(s, &glyph->cx) ||
!update_read_2byte_unsigned(s, &glyph->cy))
return FALSE; return FALSE;
glyph->cb = ((glyph->cx + 7) / 8) * glyph->cy; glyph->cb = Stream_GetRemainingLength(&sub);
glyph->cb += ((glyph->cb % 4) > 0) ? 4 - (glyph->cb % 4) : 0; if (glyph->cb > 0)
new_cb = ((glyph->cx + 7) / 8) * glyph->cy;
new_cb += ((new_cb % 4) > 0) ? 4 - (new_cb % 4) : 0;
if (fastGlyph->cbData < new_cb)
return FALSE;
if (new_cb > 0)
{ {
BYTE* new_aj; BYTE* new_aj = (BYTE*)realloc(glyph->aj, glyph->cb);
new_aj = (BYTE*)realloc(glyph->aj, new_cb);
if (!new_aj) if (!new_aj)
return FALSE; return FALSE;
glyph->aj = new_aj; glyph->aj = new_aj;
glyph->cb = new_cb; Stream_Read(&sub, glyph->aj, glyph->cb);
Stream_Read(s, glyph->aj, glyph->cb); }
else
{
free(glyph->aj);
glyph->aj = NULL;
} }
Stream_Seek(s, fastGlyph->cbData - new_cb);
} }
} }
@ -1873,14 +1905,15 @@ static BOOL update_read_polygon_sc_order(wStream* s, const ORDER_INFO* orderInfo
POLYGON_SC_ORDER* polygon_sc) POLYGON_SC_ORDER* polygon_sc)
{ {
UINT32 num = polygon_sc->numPoints; UINT32 num = polygon_sc->numPoints;
ORDER_FIELD_COORD(1, polygon_sc->xStart); if (!read_order_field_coord(orderInfo, s, 1, &polygon_sc->xStart, FALSE) ||
ORDER_FIELD_COORD(2, polygon_sc->yStart); !read_order_field_coord(orderInfo, s, 2, &polygon_sc->yStart, FALSE) ||
ORDER_FIELD_BYTE(3, polygon_sc->bRop2); !read_order_field_byte(orderInfo, s, 3, &polygon_sc->bRop2, TRUE) ||
ORDER_FIELD_BYTE(4, polygon_sc->fillMode); !read_order_field_byte(orderInfo, s, 4, &polygon_sc->fillMode, TRUE) ||
ORDER_FIELD_COLOR(orderInfo, s, 5, &polygon_sc->brushColor); !read_order_field_color(orderInfo, s, 5, &polygon_sc->brushColor, TRUE) ||
ORDER_FIELD_BYTE(6, num); !read_order_field_byte(orderInfo, s, 6, &num, TRUE))
return FALSE;
if (orderInfo->fieldFlags & ORDER_FIELD_07) if ((orderInfo->fieldFlags & ORDER_FIELD_07) != 0)
{ {
DELTA_POINT* newpoints; DELTA_POINT* newpoints;
@ -1908,19 +1941,21 @@ static BOOL update_read_polygon_cb_order(wStream* s, const ORDER_INFO* orderInfo
POLYGON_CB_ORDER* polygon_cb) POLYGON_CB_ORDER* polygon_cb)
{ {
UINT32 num = polygon_cb->numPoints; UINT32 num = polygon_cb->numPoints;
ORDER_FIELD_COORD(1, polygon_cb->xStart); if (!read_order_field_coord(orderInfo, s, 1, &polygon_cb->xStart, FALSE) ||
ORDER_FIELD_COORD(2, polygon_cb->yStart); !read_order_field_coord(orderInfo, s, 2, &polygon_cb->yStart, FALSE) ||
ORDER_FIELD_BYTE(3, polygon_cb->bRop2); !read_order_field_byte(orderInfo, s, 3, &polygon_cb->bRop2, TRUE) ||
ORDER_FIELD_BYTE(4, polygon_cb->fillMode); !read_order_field_byte(orderInfo, s, 4, &polygon_cb->fillMode, TRUE) ||
ORDER_FIELD_COLOR(orderInfo, s, 5, &polygon_cb->backColor); !read_order_field_color(orderInfo, s, 5, &polygon_cb->backColor, TRUE) ||
ORDER_FIELD_COLOR(orderInfo, s, 6, &polygon_cb->foreColor); !read_order_field_color(orderInfo, s, 6, &polygon_cb->foreColor, TRUE))
return FALSE;
if (!update_read_brush(s, &polygon_cb->brush, orderInfo->fieldFlags >> 6)) if (!update_read_brush(s, &polygon_cb->brush, orderInfo->fieldFlags >> 6))
return FALSE; return FALSE;
ORDER_FIELD_BYTE(12, num); if (!read_order_field_byte(orderInfo, s, 12, &num, TRUE))
return FALSE;
if (orderInfo->fieldFlags & ORDER_FIELD_13) if ((orderInfo->fieldFlags & ORDER_FIELD_13) != 0)
{ {
DELTA_POINT* newpoints; DELTA_POINT* newpoints;
@ -1951,27 +1986,30 @@ static BOOL update_read_polygon_cb_order(wStream* s, const ORDER_INFO* orderInfo
static BOOL update_read_ellipse_sc_order(wStream* s, const ORDER_INFO* orderInfo, static BOOL update_read_ellipse_sc_order(wStream* s, const ORDER_INFO* orderInfo,
ELLIPSE_SC_ORDER* ellipse_sc) ELLIPSE_SC_ORDER* ellipse_sc)
{ {
ORDER_FIELD_COORD(1, ellipse_sc->leftRect); if (read_order_field_coord(orderInfo, s, 1, &ellipse_sc->leftRect, FALSE) &&
ORDER_FIELD_COORD(2, ellipse_sc->topRect); read_order_field_coord(orderInfo, s, 2, &ellipse_sc->topRect, FALSE) &&
ORDER_FIELD_COORD(3, ellipse_sc->rightRect); read_order_field_coord(orderInfo, s, 3, &ellipse_sc->rightRect, FALSE) &&
ORDER_FIELD_COORD(4, ellipse_sc->bottomRect); read_order_field_coord(orderInfo, s, 4, &ellipse_sc->bottomRect, FALSE) &&
ORDER_FIELD_BYTE(5, ellipse_sc->bRop2); read_order_field_byte(orderInfo, s, 5, &ellipse_sc->bRop2, TRUE) &&
ORDER_FIELD_BYTE(6, ellipse_sc->fillMode); read_order_field_byte(orderInfo, s, 6, &ellipse_sc->fillMode, TRUE) &&
ORDER_FIELD_COLOR(orderInfo, s, 7, &ellipse_sc->color); read_order_field_color(orderInfo, s, 7, &ellipse_sc->color, TRUE))
return TRUE; return TRUE;
return FALSE;
} }
static BOOL update_read_ellipse_cb_order(wStream* s, const ORDER_INFO* orderInfo, static BOOL update_read_ellipse_cb_order(wStream* s, const ORDER_INFO* orderInfo,
ELLIPSE_CB_ORDER* ellipse_cb) ELLIPSE_CB_ORDER* ellipse_cb)
{ {
ORDER_FIELD_COORD(1, ellipse_cb->leftRect); if (read_order_field_coord(orderInfo, s, 1, &ellipse_cb->leftRect, FALSE) &&
ORDER_FIELD_COORD(2, ellipse_cb->topRect); read_order_field_coord(orderInfo, s, 2, &ellipse_cb->topRect, FALSE) &&
ORDER_FIELD_COORD(3, ellipse_cb->rightRect); read_order_field_coord(orderInfo, s, 3, &ellipse_cb->rightRect, FALSE) &&
ORDER_FIELD_COORD(4, ellipse_cb->bottomRect); read_order_field_coord(orderInfo, s, 4, &ellipse_cb->bottomRect, FALSE) &&
ORDER_FIELD_BYTE(5, ellipse_cb->bRop2); read_order_field_byte(orderInfo, s, 5, &ellipse_cb->bRop2, TRUE) &&
ORDER_FIELD_BYTE(6, ellipse_cb->fillMode); read_order_field_byte(orderInfo, s, 6, &ellipse_cb->fillMode, TRUE) &&
ORDER_FIELD_COLOR(orderInfo, s, 7, &ellipse_cb->backColor); read_order_field_color(orderInfo, s, 7, &ellipse_cb->backColor, TRUE) &&
ORDER_FIELD_COLOR(orderInfo, s, 8, &ellipse_cb->foreColor); read_order_field_color(orderInfo, s, 8, &ellipse_cb->foreColor, TRUE) &&
return update_read_brush(s, &ellipse_cb->brush, orderInfo->fieldFlags >> 8); update_read_brush(s, &ellipse_cb->brush, orderInfo->fieldFlags >> 8))
return TRUE;
return FALSE;
} }
/* Secondary Drawing Orders */ /* Secondary Drawing Orders */
static CACHE_BITMAP_ORDER* update_read_cache_bitmap_order(rdpUpdate* update, wStream* s, static CACHE_BITMAP_ORDER* update_read_cache_bitmap_order(rdpUpdate* update, wStream* s,