winhelp: There are files without Phrases or Phrases40 compression, add support for them.
This commit is contained in:
parent
c1b3549106
commit
7f2c72498a
|
@ -412,11 +412,13 @@ static BOOL HLPFILE_AddPage(HLPFILE *hlpfile, BYTE *buf, BYTE *end, unsigned off
|
||||||
{
|
{
|
||||||
HLPFILE_PAGE* page;
|
HLPFILE_PAGE* page;
|
||||||
BYTE* title;
|
BYTE* title;
|
||||||
UINT titlesize;
|
UINT titlesize, blocksize, datalen;
|
||||||
char* ptr;
|
char* ptr;
|
||||||
HLPFILE_MACRO*macro;
|
HLPFILE_MACRO*macro;
|
||||||
|
|
||||||
title = buf + GET_UINT(buf, 0x10);
|
blocksize = GET_UINT(buf, 0);
|
||||||
|
datalen = GET_UINT(buf, 0x10);
|
||||||
|
title = buf + datalen;
|
||||||
if (title > end) {WINE_WARN("page2\n"); return FALSE;};
|
if (title > end) {WINE_WARN("page2\n"); return FALSE;};
|
||||||
|
|
||||||
titlesize = GET_UINT(buf, 4);
|
titlesize = GET_UINT(buf, 4);
|
||||||
|
@ -424,23 +426,22 @@ static BOOL HLPFILE_AddPage(HLPFILE *hlpfile, BYTE *buf, BYTE *end, unsigned off
|
||||||
if (!page) return FALSE;
|
if (!page) return FALSE;
|
||||||
page->lpszTitle = (char*)page + sizeof(HLPFILE_PAGE);
|
page->lpszTitle = (char*)page + sizeof(HLPFILE_PAGE);
|
||||||
|
|
||||||
if (hlpfile->hasPhrases)
|
if (titlesize > blocksize - datalen)
|
||||||
{
|
|
||||||
HLPFILE_Uncompress2(title, end, (BYTE*)page->lpszTitle, (BYTE*)page->lpszTitle + titlesize);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (GET_UINT(buf, 0x4) > GET_UINT(buf, 0) - GET_UINT(buf, 0x10))
|
|
||||||
{
|
{
|
||||||
/* need to decompress */
|
/* need to decompress */
|
||||||
HLPFILE_Uncompress3(page->lpszTitle, page->lpszTitle + titlesize,
|
if (hlpfile->hasPhrases)
|
||||||
title, end);
|
HLPFILE_Uncompress2(title, end, (BYTE*)page->lpszTitle, (BYTE*)page->lpszTitle + titlesize);
|
||||||
}
|
else if (hlpfile->hasPhrases40)
|
||||||
|
HLPFILE_Uncompress3(page->lpszTitle, page->lpszTitle + titlesize, title, end);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
WINE_FIXME("Text size is too long, splitting\n");
|
||||||
|
titlesize = blocksize - datalen;
|
||||||
memcpy(page->lpszTitle, title, titlesize);
|
memcpy(page->lpszTitle, title, titlesize);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
memcpy(page->lpszTitle, title, titlesize);
|
||||||
|
|
||||||
page->lpszTitle[titlesize] = '\0';
|
page->lpszTitle[titlesize] = '\0';
|
||||||
|
|
||||||
|
@ -888,7 +889,7 @@ static BOOL HLPFILE_AddParagraph(HLPFILE *hlpfile, BYTE *buf, BYTE *end, unsigne
|
||||||
UINT textsize;
|
UINT textsize;
|
||||||
BYTE *format, *format_end;
|
BYTE *format, *format_end;
|
||||||
char *text, *text_base, *text_end;
|
char *text, *text_base, *text_end;
|
||||||
long size;
|
long size, blocksize, datalen;
|
||||||
unsigned short bits;
|
unsigned short bits;
|
||||||
unsigned nc, ncol = 1;
|
unsigned nc, ncol = 1;
|
||||||
|
|
||||||
|
@ -900,25 +901,28 @@ static BOOL HLPFILE_AddParagraph(HLPFILE *hlpfile, BYTE *buf, BYTE *end, unsigne
|
||||||
|
|
||||||
if (buf + 0x19 > end) {WINE_WARN("header too small\n"); return FALSE;};
|
if (buf + 0x19 > end) {WINE_WARN("header too small\n"); return FALSE;};
|
||||||
|
|
||||||
|
blocksize = GET_UINT(buf, 0);
|
||||||
size = GET_UINT(buf, 0x4);
|
size = GET_UINT(buf, 0x4);
|
||||||
|
datalen = GET_UINT(buf, 0x10);
|
||||||
text = text_base = HeapAlloc(GetProcessHeap(), 0, size);
|
text = text_base = HeapAlloc(GetProcessHeap(), 0, size);
|
||||||
if (!text) return FALSE;
|
if (!text) return FALSE;
|
||||||
|
if (size > blocksize - datalen)
|
||||||
|
{
|
||||||
|
/* need to decompress */
|
||||||
if (hlpfile->hasPhrases)
|
if (hlpfile->hasPhrases)
|
||||||
{
|
HLPFILE_Uncompress2(buf + datalen, end, (BYTE*)text, (BYTE*)text + size);
|
||||||
HLPFILE_Uncompress2(buf + GET_UINT(buf, 0x10), end, (BYTE*)text, (BYTE*)text + size);
|
else if (hlpfile->hasPhrases40)
|
||||||
}
|
HLPFILE_Uncompress3(text, text + size, buf + datalen, end);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (GET_UINT(buf, 0x4) > GET_UINT(buf, 0) - GET_UINT(buf, 0x10))
|
WINE_FIXME("Text size is too long, splitting\n");
|
||||||
{
|
size = blocksize - datalen;
|
||||||
/* block is compressed */
|
memcpy(text, buf + datalen, size);
|
||||||
HLPFILE_Uncompress3(text, text + size, buf + GET_UINT(buf, 0x10), end);
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
memcpy(text, buf + datalen, size);
|
||||||
text = (char*)buf + GET_UINT(buf, 0x10);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
text_end = text + size;
|
text_end = text + size;
|
||||||
|
|
||||||
format = buf + 0x15;
|
format = buf + 0x15;
|
||||||
|
@ -1694,7 +1698,7 @@ static BOOL HLPFILE_Uncompress_Phrases40(HLPFILE* hlpfile)
|
||||||
else
|
else
|
||||||
HLPFILE_UncompressLZ77(buf_phs + 9, end_phs, (BYTE*)phrases.buffer);
|
HLPFILE_UncompressLZ77(buf_phs + 9, end_phs, (BYTE*)phrases.buffer);
|
||||||
|
|
||||||
hlpfile->hasPhrases = FALSE;
|
hlpfile->hasPhrases40 = TRUE;
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -137,7 +137,8 @@ typedef struct tagHlpFileFile
|
||||||
unsigned short tbsize; /* topic block size */
|
unsigned short tbsize; /* topic block size */
|
||||||
unsigned short dsize; /* decompress size */
|
unsigned short dsize; /* decompress size */
|
||||||
unsigned short compressed;
|
unsigned short compressed;
|
||||||
unsigned hasPhrases; /* Phrases or PhrIndex/PhrImage */
|
unsigned hasPhrases; /* file has |Phrases */
|
||||||
|
unsigned hasPhrases40; /* file has |PhrIndex/|PhrImage */
|
||||||
|
|
||||||
unsigned numBmps;
|
unsigned numBmps;
|
||||||
HBITMAP* bmps;
|
HBITMAP* bmps;
|
||||||
|
|
Loading…
Reference in New Issue