Commit 4ea0b700 authored by Eric Pouech's avatar Eric Pouech Committed by Alexandre Julliard

- added some missing strings to resources

- made the decompression code a bit more pedantic to avoid crashes - fixed startup without .HLP filename passed on command line - passed a few more commands from remote applications to the macros
parent 24d0a839
...@@ -62,6 +62,7 @@ STID_CONTENTS, "&Teme pomoi" ...@@ -62,6 +62,7 @@ STID_CONTENTS, "&Teme pomoi"
STID_SEARCH, "&Iskanje" STID_SEARCH, "&Iskanje"
STID_BACK, "&Nazaj" STID_BACK, "&Nazaj"
STID_HISTORY, "&Zgodovina" STID_HISTORY, "&Zgodovina"
STID_TOPICS, "&Topics"
STID_ALL_FILES, "Vse datiteke (*.*)" STID_ALL_FILES, "Vse datiteke (*.*)"
STID_HELP_FILES_HLP, "Datoteke s pomojo (*.hlp)" STID_HELP_FILES_HLP, "Datoteke s pomojo (*.hlp)"
} }
...@@ -59,6 +59,7 @@ STID_CONTENTS, "&Obsah" ...@@ -59,6 +59,7 @@ STID_CONTENTS, "&Obsah"
STID_SEARCH, "&Hada" STID_SEARCH, "&Hada"
STID_BACK, "&Sp" STID_BACK, "&Sp"
STID_HISTORY, "&Histria" STID_HISTORY, "&Histria"
STID_TOPICS, "&Topics"
STID_ALL_FILES, "Vetky sbory (*.*)" STID_ALL_FILES, "Vetky sbory (*.*)"
STID_HELP_FILES_HLP, "Sbory pomoci (*.hlp)" STID_HELP_FILES_HLP, "Sbory pomoci (*.hlp)"
} }
...@@ -85,7 +85,7 @@ static BOOL HLPFILE_AddPage(HLPFILE*, BYTE*, BYTE*, unsigned); ...@@ -85,7 +85,7 @@ static BOOL HLPFILE_AddPage(HLPFILE*, BYTE*, BYTE*, unsigned);
static BOOL HLPFILE_AddParagraph(HLPFILE*, BYTE *, BYTE*, unsigned*); static BOOL HLPFILE_AddParagraph(HLPFILE*, BYTE *, BYTE*, unsigned*);
static void HLPFILE_Uncompress2(const BYTE*, const BYTE*, BYTE*, const BYTE*); static void HLPFILE_Uncompress2(const BYTE*, const BYTE*, BYTE*, const BYTE*);
static BOOL HLPFILE_Uncompress3(char*, const char*, const BYTE*, const BYTE*); static BOOL HLPFILE_Uncompress3(char*, const char*, const BYTE*, const BYTE*);
static void HLPFILE_UncompressRLE(const BYTE* src, unsigned sz, BYTE** dst); static void HLPFILE_UncompressRLE(const BYTE* src, const BYTE* end, BYTE** dst, unsigned dstsz);
static BOOL HLPFILE_ReadFont(HLPFILE* hlpfile); static BOOL HLPFILE_ReadFont(HLPFILE* hlpfile);
/*********************************************************************** /***********************************************************************
...@@ -523,15 +523,15 @@ static BYTE* HLPFILE_DecompressGfx(BYTE* src, unsigned csz, unsigned sz, BYTE ...@@ -523,15 +523,15 @@ static BYTE* HLPFILE_DecompressGfx(BYTE* src, unsigned csz, unsigned sz, BYTE
{ {
case 0: /* uncompressed */ case 0: /* uncompressed */
if (sz != csz) if (sz != csz)
WINE_WARN("Bogus gfx sizes: %u / %u\n", sz, csz); WINE_WARN("Bogus gfx sizes (uncompressed): %u / %u\n", sz, csz);
dst = src; dst = src;
break; break;
case 1: /* RunLen */ case 1: /* RunLen */
tmp = dst = HeapAlloc(GetProcessHeap(), 0, sz); tmp = dst = HeapAlloc(GetProcessHeap(), 0, sz);
if (!dst) return NULL; if (!dst) return NULL;
HLPFILE_UncompressRLE(src, csz, &tmp); HLPFILE_UncompressRLE(src, src + csz, &tmp, sz);
if (tmp - dst != sz) if (tmp - dst != sz)
WINE_FIXME("Bogus gfx sizes: %u/%u\n", tmp - dst, sz); WINE_FIXME("Bogus gfx sizes (RunLen): %u/%u\n", tmp - dst, sz);
break; break;
case 2: /* LZ77 */ case 2: /* LZ77 */
sz77 = HLPFILE_UncompressedLZ77_Size(src, src + csz); sz77 = HLPFILE_UncompressedLZ77_Size(src, src + csz);
...@@ -539,18 +539,18 @@ static BYTE* HLPFILE_DecompressGfx(BYTE* src, unsigned csz, unsigned sz, BYTE ...@@ -539,18 +539,18 @@ static BYTE* HLPFILE_DecompressGfx(BYTE* src, unsigned csz, unsigned sz, BYTE
if (!dst) return NULL; if (!dst) return NULL;
HLPFILE_UncompressLZ77(src, src + csz, dst); HLPFILE_UncompressLZ77(src, src + csz, dst);
if (sz77 != sz) if (sz77 != sz)
WINE_WARN("Bogus gfx sizes: %u / %u\n", sz77, sz); WINE_WARN("Bogus gfx sizes (LZ77): %u / %u\n", sz77, sz);
break; break;
case 3: /* LZ77 then RLE */ case 3: /* LZ77 then RLE */
sz77 = HLPFILE_UncompressedLZ77_Size(src, src + csz); sz77 = HLPFILE_UncompressedLZ77_Size(src, src + csz);
tmp = HeapAlloc(GetProcessHeap(), 0, sz/*sz77*/); tmp = HeapAlloc(GetProcessHeap(), 0, sz77);
if (!tmp) return FALSE; if (!tmp) return FALSE;
HLPFILE_UncompressLZ77(src, src + csz, tmp); HLPFILE_UncompressLZ77(src, src + csz, tmp);
dst = tmp2 = HeapAlloc(GetProcessHeap(), 0, sz); dst = tmp2 = HeapAlloc(GetProcessHeap(), 0, sz);
if (!dst) return FALSE; if (!dst) return FALSE;
HLPFILE_UncompressRLE(tmp, sz77, &tmp2); HLPFILE_UncompressRLE(tmp, tmp + sz77, &tmp2, sz);
if (tmp2 - dst != sz) if (tmp2 - dst != sz)
WINE_WARN("Bogus gfx: %u / %u\n", tmp2 - dst, sz); WINE_WARN("Bogus gfx sizes (LZ77+RunLen): %u / %u\n", tmp2 - dst, sz);
HeapFree(GetProcessHeap(), 0, tmp); HeapFree(GetProcessHeap(), 0, tmp);
break; break;
default: default:
...@@ -592,6 +592,9 @@ static BOOL HLPFILE_LoadBitmap(BYTE* beg, BYTE type, BYTE pack, ...@@ -592,6 +592,9 @@ static BOOL HLPFILE_LoadBitmap(BYTE* beg, BYTE type, BYTE pack,
if (bi->bmiHeader.biBitCount > 32) WINE_FIXME("Unknown bit count %u\n", bi->bmiHeader.biBitCount); if (bi->bmiHeader.biBitCount > 32) WINE_FIXME("Unknown bit count %u\n", bi->bmiHeader.biBitCount);
if (bi->bmiHeader.biPlanes != 1) WINE_FIXME("Unsupported planes %u\n", bi->bmiHeader.biPlanes); if (bi->bmiHeader.biPlanes != 1) WINE_FIXME("Unsupported planes %u\n", bi->bmiHeader.biPlanes);
bi->bmiHeader.biSizeImage = (((bi->bmiHeader.biWidth * bi->bmiHeader.biBitCount + 31) & ~31) / 8) * bi->bmiHeader.biHeight; bi->bmiHeader.biSizeImage = (((bi->bmiHeader.biWidth * bi->bmiHeader.biBitCount + 31) & ~31) / 8) * bi->bmiHeader.biHeight;
WINE_TRACE("planes=%d bc=%d size=(%ld,%ld)\n",
bi->bmiHeader.biPlanes, bi->bmiHeader.biBitCount,
bi->bmiHeader.biWidth, bi->bmiHeader.biHeight);
csz = fetch_ulong(&ptr); csz = fetch_ulong(&ptr);
fetch_ulong(&ptr); /* hotspot size */ fetch_ulong(&ptr); /* hotspot size */
...@@ -1406,7 +1409,7 @@ static BOOL HLPFILE_SystemCommands(HLPFILE* hlpfile) ...@@ -1406,7 +1409,7 @@ static BOOL HLPFILE_SystemCommands(HLPFILE* hlpfile)
wi->style = (flags & 0x0080) ? GET_USHORT(ptr, 84) : SW_SHOW; wi->style = (flags & 0x0080) ? GET_USHORT(ptr, 84) : SW_SHOW;
wi->sr_color = (flags & 0x0100) ? GET_UINT(ptr, 86) : 0xFFFFFF; wi->sr_color = (flags & 0x0100) ? GET_UINT(ptr, 86) : 0xFFFFFF;
wi->nsr_color = (flags & 0x0200) ? GET_UINT(ptr, 90) : 0xFFFFFF; wi->nsr_color = (flags & 0x0200) ? GET_UINT(ptr, 90) : 0xFFFFFF;
WINE_FIXME("System-Window: flags=%c%c%c%c%c%c%c%c type=%s name=%s caption=%s (%ld,%ld)x(%ld,%ld)\n", WINE_TRACE("System-Window: flags=%c%c%c%c%c%c%c%c type=%s name=%s caption=%s (%ld,%ld)x(%ld,%ld)\n",
flags & 0x0001 ? 'T' : 't', flags & 0x0001 ? 'T' : 't',
flags & 0x0002 ? 'N' : 'n', flags & 0x0002 ? 'N' : 'n',
flags & 0x0004 ? 'C' : 'c', flags & 0x0004 ? 'C' : 'c',
...@@ -1715,7 +1718,8 @@ static BOOL HLPFILE_Uncompress3(char* dst, const char* dst_end, ...@@ -1715,7 +1718,8 @@ static BOOL HLPFILE_Uncompress3(char* dst, const char* dst_end,
else else
{ {
len = phrases.offsets[idx + 1] - phrases.offsets[idx]; len = phrases.offsets[idx + 1] - phrases.offsets[idx];
memcpy(dst, &phrases.buffer[phrases.offsets[idx]], len); if (dst + len <= dst_end)
memcpy(dst, &phrases.buffer[phrases.offsets[idx]], len);
} }
} }
else if ((*src & 0x03) == 0x01) else if ((*src & 0x03) == 0x01)
...@@ -1730,19 +1734,22 @@ static BOOL HLPFILE_Uncompress3(char* dst, const char* dst_end, ...@@ -1730,19 +1734,22 @@ static BOOL HLPFILE_Uncompress3(char* dst, const char* dst_end,
else else
{ {
len = phrases.offsets[idx + 1] - phrases.offsets[idx]; len = phrases.offsets[idx + 1] - phrases.offsets[idx];
memcpy(dst, &phrases.buffer[phrases.offsets[idx]], len); if (dst + len <= dst_end)
memcpy(dst, &phrases.buffer[phrases.offsets[idx]], len);
} }
} }
else if ((*src & 0x07) == 0x03) else if ((*src & 0x07) == 0x03)
{ {
len = (*src / 8) + 1; len = (*src / 8) + 1;
memcpy(dst, src + 1, len); if (dst + len <= dst_end)
memcpy(dst, src + 1, len);
src += len; src += len;
} }
else else
{ {
len = (*src / 16) + 1; len = (*src / 16) + 1;
memset(dst, ((*src & 0x0F) == 0x07) ? ' ' : 0, len); if (dst + len <= dst_end)
memset(dst, ((*src & 0x0F) == 0x07) ? ' ' : 0, len);
} }
dst += len; dst += len;
} }
...@@ -1756,27 +1763,37 @@ static BOOL HLPFILE_Uncompress3(char* dst, const char* dst_end, ...@@ -1756,27 +1763,37 @@ static BOOL HLPFILE_Uncompress3(char* dst, const char* dst_end,
* *
* *
*/ */
static void HLPFILE_UncompressRLE(const BYTE* src, unsigned sz, BYTE** dst) static void HLPFILE_UncompressRLE(const BYTE* src, const BYTE* end, BYTE** dst, unsigned dstsz)
{ {
unsigned i;
BYTE ch; BYTE ch;
BYTE* sdst = *dst + dstsz;
for (i = 0; i < sz; i++) while (src < end)
{ {
ch = src[i]; ch = *src++;
if (ch & 0x80) if (ch & 0x80)
{ {
ch &= 0x7F; ch &= 0x7F;
memcpy(*dst, src + i + 1, ch); if (ch == 0) WINE_FIXME("Null length 1, next is %u\n", *src);
i += ch; if ((*dst) + ch < sdst)
memcpy(*dst, src, ch);
src += ch;
} }
else else
{ {
memset(*dst, (char)src[i + 1], ch); if ((*dst) + ch < sdst)
i++; memset(*dst, (char)*src, ch);
src++;
if (ch == 0)
{
WINE_FIXME("Null length 2, next is %u\n", *src);
}
} }
*dst += ch; *dst += ch;
} }
if (*dst != sdst)
WINE_FIXME("Buffer X-flow: d(%u) instead of d(%u)\n",
*dst - (sdst - dstsz), dstsz);
} }
/****************************************************************** /******************************************************************
......
...@@ -91,9 +91,10 @@ HLPFILE_WINDOWINFO* WINHELP_GetWindowInfo(HLPFILE* hlpfile, LPCSTR name) ...@@ -91,9 +91,10 @@ HLPFILE_WINDOWINFO* WINHELP_GetWindowInfo(HLPFILE* hlpfile, LPCSTR name)
if (!name || !name[0]) if (!name || !name[0])
name = Globals.active_win->lpszName; name = Globals.active_win->lpszName;
for (i = 0; i < hlpfile->numWindows; i++) if (hlpfile)
if (!strcmp(hlpfile->windows[i].name, name)) for (i = 0; i < hlpfile->numWindows; i++)
return &hlpfile->windows[i]; if (!strcmp(hlpfile->windows[i].name, name))
return &hlpfile->windows[i];
if (strcmp(name, "main") != 0) if (strcmp(name, "main") != 0)
{ {
...@@ -196,9 +197,12 @@ int PASCAL WinMain(HINSTANCE hInstance, HINSTANCE prev, LPSTR cmdline, int show) ...@@ -196,9 +197,12 @@ int PASCAL WinMain(HINSTANCE hInstance, HINSTANCE prev, LPSTR cmdline, int show)
/* Create primary window */ /* Create primary window */
WINHELP_RegisterWinClasses(); WINHELP_RegisterWinClasses();
hlpfile = WINHELP_LookupHelpFile(cmdline); if (*cmdline)
if (!hlpfile) {
return 0; hlpfile = WINHELP_LookupHelpFile(cmdline);
if (!hlpfile) return 0;
}
else hlpfile = NULL;
WINHELP_CreateHelpWindowByHash(hlpfile, lHash, WINHELP_CreateHelpWindowByHash(hlpfile, lHash,
WINHELP_GetWindowInfo(hlpfile, "main"), show); WINHELP_GetWindowInfo(hlpfile, "main"), show);
...@@ -285,33 +289,60 @@ static LRESULT WINHELP_HandleCommand(HWND hSrcWnd, LPARAM lParam) ...@@ -285,33 +289,60 @@ static LRESULT WINHELP_HandleCommand(HWND hSrcWnd, LPARAM lParam)
if (wh) if (wh)
{ {
char* ptr = (wh->ofsFilename) ? (LPSTR)wh + wh->ofsFilename : NULL;
WINE_TRACE("Got[%u]: cmd=%u data=%08lx fn=%s\n", WINE_TRACE("Got[%u]: cmd=%u data=%08lx fn=%s\n",
wh->size, wh->command, wh->data, wh->size, wh->command, wh->data, ptr);
wh->ofsFilename ? (LPSTR)wh + wh->ofsFilename : "");
switch (wh->command) switch (wh->command)
{ {
case HELP_CONTEXT:
if (ptr)
{
MACRO_JumpContext(ptr, "main", wh->data);
}
break;
case HELP_QUIT: case HELP_QUIT:
MACRO_Exit(); MACRO_Exit();
break; break;
case HELP_FINDER: case HELP_CONTENTS:
/* in fact, should be the topic dialog box */ if (ptr)
if (wh->ofsFilename)
{ {
MACRO_JumpHash((LPSTR)wh + wh->ofsFilename, "main", 0); MACRO_JumpContents(ptr, "main");
} }
break; break;
case HELP_CONTEXT: case HELP_HELPONHELP:
MACRO_HelpOn();
break;
/* case HELP_SETINDEX: */
case HELP_SETCONTENTS: case HELP_SETCONTENTS:
case HELP_CONTENTS: if (ptr)
{
MACRO_SetContents(ptr, wh->data);
}
break;
case HELP_CONTEXTPOPUP: case HELP_CONTEXTPOPUP:
case HELP_FORCEFILE: if (ptr)
case HELP_HELPONHELP: {
case HELP_KEY: MACRO_PopupContext(ptr, wh->data);
case HELP_PARTIALKEY: }
case HELP_COMMAND: break;
case HELP_MULTIKEY: /* case HELP_FORCEFILE:*/
case HELP_SETWINPOS: /* case HELP_CONTEXTMENU: */
WINE_FIXME("NIY\n"); case HELP_FINDER:
/* in fact, should be the topic dialog box */
if (ptr)
{
MACRO_JumpHash(ptr, "main", 0);
}
break;
/* case HELP_WM_HELP: */
/* case HELP_SETPOPUP_POS: */
/* case HELP_KEY: */
/* case HELP_COMMAND: */
/* case HELP_PARTIALKEY: */
/* case HELP_MULTIKEY: */
/* case HELP_SETWINPOS: */
WINE_FIXME("Unknown command (%x) for remote winhelp control\n", wh->command);
break; break;
} }
} }
...@@ -478,6 +509,7 @@ BOOL WINHELP_CreateHelpWindow(HLPFILE_PAGE* page, HLPFILE_WINDOWINFO* wi, ...@@ -478,6 +509,7 @@ BOOL WINHELP_CreateHelpWindow(HLPFILE_PAGE* page, HLPFILE_WINDOWINFO* wi,
MACRO_ExecuteMacro(macro->lpszMacro); MACRO_ExecuteMacro(macro->lpszMacro);
} }
win->histIndex = win->backIndex = 0;
/* Reuse existing window */ /* Reuse existing window */
if (!bPopup) if (!bPopup)
{ {
...@@ -488,13 +520,13 @@ BOOL WINHELP_CreateHelpWindow(HLPFILE_PAGE* page, HLPFILE_WINDOWINFO* wi, ...@@ -488,13 +520,13 @@ BOOL WINHELP_CreateHelpWindow(HLPFILE_PAGE* page, HLPFILE_WINDOWINFO* wi,
return WINHELP_ReuseWindow(win, oldwin, page, nCmdShow); return WINHELP_ReuseWindow(win, oldwin, page, nCmdShow);
} }
} }
if (page)
win->histIndex = win->backIndex = 1; {
win->history[0] = win->back[0] = page; win->histIndex = win->backIndex = 1;
page->file->wRefCount += 2; win->history[0] = win->back[0] = page;
page->file->wRefCount += 2;
}
} }
else
win->histIndex = win->backIndex = 0;
hWnd = CreateWindow(bPopup ? TEXT_WIN_CLASS_NAME : MAIN_WIN_CLASS_NAME, hWnd = CreateWindow(bPopup ? TEXT_WIN_CLASS_NAME : MAIN_WIN_CLASS_NAME,
wi->caption, wi->win_style, wi->caption, wi->win_style,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment