diff --git a/programs/winhlp32/hlpfile.c b/programs/winhlp32/hlpfile.c index 05d5347cef0..c941bbd8fe5 100644 --- a/programs/winhlp32/hlpfile.c +++ b/programs/winhlp32/hlpfile.c @@ -63,6 +63,7 @@ static BOOL HLPFILE_Uncompress_Topic(HLPFILE*); static BOOL HLPFILE_GetContext(HLPFILE*); static BOOL HLPFILE_GetKeywords(HLPFILE*); static BOOL HLPFILE_GetMap(HLPFILE*); +static BOOL HLPFILE_GetTOMap(HLPFILE*); static BOOL HLPFILE_AddPage(HLPFILE*, const BYTE*, const BYTE*, unsigned, unsigned); static BOOL HLPFILE_SkipParagraph(HLPFILE*, const BYTE*, const BYTE*, unsigned*); static void HLPFILE_Uncompress2(HLPFILE*, const BYTE*, const BYTE*, BYTE*, const BYTE*); @@ -293,6 +294,8 @@ static BOOL HLPFILE_DoReadHlpFile(HLPFILE *hlpfile, LPCSTR lpszPath) if (!HLPFILE_SystemCommands(hlpfile)) return FALSE; + if (hlpfile->version <= 16 && !HLPFILE_GetTOMap(hlpfile)) return FALSE; + /* load phrases support */ if (!HLPFILE_UncompressLZ77_Phrases(hlpfile)) HLPFILE_Uncompress_Phrases40(hlpfile); @@ -2575,6 +2578,26 @@ static BOOL HLPFILE_GetMap(HLPFILE *hlpfile) return TRUE; } +/*********************************************************************** + * + * HLPFILE_GetTOMap + */ +static BOOL HLPFILE_GetTOMap(HLPFILE *hlpfile) +{ + BYTE *cbuf, *cend; + unsigned clen; + + if (!HLPFILE_FindSubFile(hlpfile, "|TOMAP", &cbuf, &cend)) + {WINE_WARN("no tomap section\n"); return FALSE;} + + clen = cend - cbuf - 9; + hlpfile->TOMap = HeapAlloc(GetProcessHeap(), 0, clen); + if (!hlpfile->TOMap) return FALSE; + memcpy(hlpfile->TOMap, cbuf+9, clen); + hlpfile->wTOMapLen = clen/4; + return TRUE; +} + /*********************************************************************** * * DeleteMacro diff --git a/programs/winhlp32/hlpfile.h b/programs/winhlp32/hlpfile.h index 5097259d270..b0d1f23dcea 100644 --- a/programs/winhlp32/hlpfile.h +++ b/programs/winhlp32/hlpfile.h @@ -100,6 +100,8 @@ typedef struct tagHlpFileFile BYTE* kwdata; unsigned wMapLen; HLPFILE_MAP* Map; + unsigned wTOMapLen; + unsigned* TOMap; unsigned long contents_start; struct tagHlpFileFile* prev;