Name: Anonymous 2011-01-24 14:06
Anybody familiar with Hex Workshop and its structure libraries?
I've been coding a parser for a game file format and it works rather well. But I'd like to add support for a rare exception and thus have to add a conditional on a certain value.
typedef struct tagPIXELMAP
{
DWORD pixDtype;
DWORD pixUnknown;
BYTE pixIflag;
SIZE pixSize;
zstring null_terminated_str;
STATE pixRflag;
// if (pixRflag == 3)
// {
// blob cpixOne[15];
// zstring null_terminated_str;
// blob cpixTwo[1048];
// STATE pixRflag2;
// };
DWORD pixRatioA;
DWORD pixRatioB;
DWORD pixRend;
blob pixData[pixRatioA-8];
UQUAD pixEnd;
// Verify that the pixelmap looks sane
__verify(
(pixDtype == 0x3) && // Expected type: 03h
(pixIflag == 0x3) && // Should always be 3
(pixSize.pixWidthA == pixSize.pixWidthB) && // Both width should be the same
(pixSize.pixWidthH == (pixSize.pixWidthA / 2)) &&
(pixSize.pixHeightH == (pixSize.pixHeight / 2)) &&
(pixRflag == 0x21) && // Always 21h
(pixRend == 0x1) && // Always 1
(pixEnd == 0x0) // Always null
) ;
} PIXELMAP ;
The commented chunk is the conditional I mean. If pixRflag (which precedes the if statement directly) is equal to 0x21 everything's ok, if it's equal to 0x3 then its the exception etc. The problem is that the zstring that precedes pixRflag stops working correctly if I uncomment the damn chunk. While it's supposed to stop the string as soon as it finds a null byte, here it will stop after two bytes. Is this a fucking bug in Hex Workshop code parser or am I missing something...
I've been coding a parser for a game file format and it works rather well. But I'd like to add support for a rare exception and thus have to add a conditional on a certain value.
typedef struct tagPIXELMAP
{
DWORD pixDtype;
DWORD pixUnknown;
BYTE pixIflag;
SIZE pixSize;
zstring null_terminated_str;
STATE pixRflag;
// if (pixRflag == 3)
// {
// blob cpixOne[15];
// zstring null_terminated_str;
// blob cpixTwo[1048];
// STATE pixRflag2;
// };
DWORD pixRatioA;
DWORD pixRatioB;
DWORD pixRend;
blob pixData[pixRatioA-8];
UQUAD pixEnd;
// Verify that the pixelmap looks sane
__verify(
(pixDtype == 0x3) && // Expected type: 03h
(pixIflag == 0x3) && // Should always be 3
(pixSize.pixWidthA == pixSize.pixWidthB) && // Both width should be the same
(pixSize.pixWidthH == (pixSize.pixWidthA / 2)) &&
(pixSize.pixHeightH == (pixSize.pixHeight / 2)) &&
(pixRflag == 0x21) && // Always 21h
(pixRend == 0x1) && // Always 1
(pixEnd == 0x0) // Always null
) ;
} PIXELMAP ;
The commented chunk is the conditional I mean. If pixRflag (which precedes the if statement directly) is equal to 0x21 everything's ok, if it's equal to 0x3 then its the exception etc. The problem is that the zstring that precedes pixRflag stops working correctly if I uncomment the damn chunk. While it's supposed to stop the string as soon as it finds a null byte, here it will stop after two bytes. Is this a fucking bug in Hex Workshop code parser or am I missing something...