From 3f0d9d12c3de7fef78b0cb5404ae0e8acf7da5e3 Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Tue, 24 Feb 2009 18:22:47 +0100 Subject: [PATCH] kernel32: Make winhelp.exe into a stand-alone 16-bit executable. --- .gitignore | 1 - configure | 11 ++++ configure.ac | 2 + dlls/Makefile.in | 3 +- dlls/kernel32/Makefile.in | 5 -- dlls/kernel32/kernel16.c | 83 ------------------------------ programs/winhelp.exe16/Makefile.in | 13 +++++ programs/winhelp.exe16/winhelp.c | 47 +++++++++++++++++ 8 files changed, 74 insertions(+), 91 deletions(-) create mode 100644 programs/winhelp.exe16/Makefile.in create mode 100644 programs/winhelp.exe16/winhelp.c diff --git a/.gitignore b/.gitignore index 4d0ceadf279..113321dd778 100644 --- a/.gitignore +++ b/.gitignore @@ -124,7 +124,6 @@ dlls/winaspi.dll16 dlls/windebug.dll16 dlls/wineps16.drv16 dlls/wing.dll16 -dlls/winhelp.exe16 dlls/winnls.dll16 dlls/winsock.dll16 dlls/wintab.dll16 diff --git a/configure b/configure index 1162edc400c..34b8217b751 100755 --- a/configure +++ b/configure @@ -3909,6 +3909,7 @@ then enable_w32skrnl=${enable_w32skrnl:-no} enable_winedos=${enable_winedos:-no} enable_winevdm=${enable_winevdm:-no} + enable_winhelp_exe16=${enable_winhelp_exe16:-no} enable_winoldap_mod16=${enable_winoldap_mod16:-no} fi @@ -27880,6 +27881,15 @@ ALL_MAKEFILE_DEPENDS="$ALL_MAKEFILE_DEPENDS programs/winevdm/Makefile: programs/winevdm/Makefile.in programs/Makeprog.rules" ac_config_files="$ac_config_files programs/winevdm/Makefile" +ALL_MAKEFILES="$ALL_MAKEFILES \\ + programs/winhelp.exe16/Makefile" +test "x$enable_winhelp_exe16" != xno && ALL_PROGRAM_DIRS="$ALL_PROGRAM_DIRS \\ + winhelp.exe16" && ALL_PROGRAM_INSTALL_DIRS="$ALL_PROGRAM_INSTALL_DIRS \\ + winhelp.exe16" +ALL_MAKEFILE_DEPENDS="$ALL_MAKEFILE_DEPENDS +programs/winhelp.exe16/Makefile: programs/winhelp.exe16/Makefile.in programs/Makeprog.rules" +ac_config_files="$ac_config_files programs/winhelp.exe16/Makefile" + ALL_MAKEFILES="$ALL_MAKEFILES \\ programs/winhlp32/Makefile" test "x$enable_winhlp32" != xno && ALL_PROGRAM_DIRS="$ALL_PROGRAM_DIRS \\ @@ -29061,6 +29071,7 @@ do "programs/winepath/Makefile") CONFIG_FILES="$CONFIG_FILES programs/winepath/Makefile" ;; "programs/winetest/Makefile") CONFIG_FILES="$CONFIG_FILES programs/winetest/Makefile" ;; "programs/winevdm/Makefile") CONFIG_FILES="$CONFIG_FILES programs/winevdm/Makefile" ;; + "programs/winhelp.exe16/Makefile") CONFIG_FILES="$CONFIG_FILES programs/winhelp.exe16/Makefile" ;; "programs/winhlp32/Makefile") CONFIG_FILES="$CONFIG_FILES programs/winhlp32/Makefile" ;; "programs/winoldap.mod16/Makefile") CONFIG_FILES="$CONFIG_FILES programs/winoldap.mod16/Makefile" ;; "programs/winver/Makefile") CONFIG_FILES="$CONFIG_FILES programs/winver/Makefile" ;; diff --git a/configure.ac b/configure.ac index 5ca0a977f24..f154b401cfc 100644 --- a/configure.ac +++ b/configure.ac @@ -146,6 +146,7 @@ then enable_w32skrnl=${enable_w32skrnl:-no} enable_winedos=${enable_winedos:-no} enable_winevdm=${enable_winevdm:-no} + enable_winhelp_exe16=${enable_winhelp_exe16:-no} enable_winoldap_mod16=${enable_winoldap_mod16:-no} fi @@ -2306,6 +2307,7 @@ WINE_CONFIG_MAKEFILE([programs/winemine/Makefile],[programs/Makeprog.rules],[pro WINE_CONFIG_MAKEFILE([programs/winepath/Makefile],[programs/Makeprog.rules],[programs],[ALL_PROGRAM_DIRS,ALL_PROGRAM_INSTALL_DIRS,ALL_PROGRAM_BIN_INSTALL_DIRS]) WINE_CONFIG_MAKEFILE([programs/winetest/Makefile],[programs/Makeprog.rules],[programs],[ALL_PROGRAM_DIRS]) WINE_CONFIG_MAKEFILE([programs/winevdm/Makefile],[programs/Makeprog.rules],[programs],[ALL_PROGRAM_DIRS,ALL_PROGRAM_INSTALL_DIRS]) +WINE_CONFIG_MAKEFILE([programs/winhelp.exe16/Makefile],[programs/Makeprog.rules],[programs],[ALL_PROGRAM_DIRS,ALL_PROGRAM_INSTALL_DIRS]) WINE_CONFIG_MAKEFILE([programs/winhlp32/Makefile],[programs/Makeprog.rules],[programs],[ALL_PROGRAM_DIRS,ALL_PROGRAM_INSTALL_DIRS]) WINE_CONFIG_MAKEFILE([programs/winoldap.mod16/Makefile],[programs/Makeprog.rules],[programs],[ALL_PROGRAM_DIRS,ALL_PROGRAM_INSTALL_DIRS]) WINE_CONFIG_MAKEFILE([programs/winver/Makefile],[programs/Makeprog.rules],[programs],[ALL_PROGRAM_DIRS,ALL_PROGRAM_INSTALL_DIRS]) diff --git a/dlls/Makefile.in b/dlls/Makefile.in index 79b48a079b3..b35daf0efe7 100644 --- a/dlls/Makefile.in +++ b/dlls/Makefile.in @@ -63,7 +63,6 @@ WIN16_FILES = \ windebug.dll16 \ wineps16.drv16 \ wing.dll16 \ - winhelp.exe16 \ winnls.dll16 \ winsock.dll16 \ wintab.dll16 \ @@ -92,7 +91,7 @@ dispdib.dll16 gdi.exe16 wing.dll16: imm.dll16: echo "imm32.dll" >$@ -comm.drv16 krnl386.exe16 stress.dll16 system.drv16 toolhelp.dll16 win87em.dll16 windebug.dll16 winhelp.exe16: +comm.drv16 krnl386.exe16 stress.dll16 system.drv16 toolhelp.dll16 win87em.dll16 windebug.dll16: echo "kernel32.dll" >$@ lzexpand.dll16: diff --git a/dlls/kernel32/Makefile.in b/dlls/kernel32/Makefile.in index c2922c6767e..49e6caf8966 100644 --- a/dlls/kernel32/Makefile.in +++ b/dlls/kernel32/Makefile.in @@ -96,8 +96,6 @@ MC_SRCS = \ nls/winerr_nor.mc EXTRA_OBJS = relay16asm.o -EXTRA_OBJS16 = winhelp.exe.o - EXTRASUBDIRS = nls @MAKE_DLL_RULES@ @@ -107,9 +105,6 @@ kernel.res: $(MC_SRCS:.mc=.mc.rc) relay16asm.o: $(WINEBUILD) $(WINEBUILD) $(WINEBUILDFLAGS) -o $@ --relay16 -winhelp.exe.o: $(WINEBUILD) - $(WINEBUILD) $(WINEBUILDFLAGS) --exe -o $@ --main-module $(MODULE) --entry WINHELP_EntryPoint - # Special rules for 16-bit resource and spec files krnl386.exe.spec.o: krnl386.exe.spec version16.res diff --git a/dlls/kernel32/kernel16.c b/dlls/kernel32/kernel16.c index d06756f8ea0..094156dfbf8 100644 --- a/dlls/kernel32/kernel16.c +++ b/dlls/kernel32/kernel16.c @@ -29,7 +29,6 @@ #include "toolhelp.h" #include "kernel_private.h" #include "kernel16_private.h" -#include "wine/server.h" #include "wine/debug.h" WINE_DEFAULT_DEBUG_CHANNEL(module); @@ -136,88 +135,6 @@ HANDLE WINAPI CreateThread16( SECURITY_ATTRIBUTES *sa, DWORD stack, return CreateThread( sa, stack, start_thread16, args, flags, id ); } - -/*********************************************************************** - * wait_input_idle - * - * user32.WaitForInputIdle releases the win16 lock, so here is a replacement. - */ -static DWORD wait_input_idle( HANDLE process, DWORD timeout ) -{ - DWORD ret; - HANDLE handles[2]; - - handles[0] = process; - SERVER_START_REQ( get_process_idle_event ) - { - req->handle = wine_server_obj_handle(process); - if (!(ret = wine_server_call_err( req ))) handles[1] = wine_server_ptr_handle( reply->event ); - } - SERVER_END_REQ; - if (ret) return WAIT_FAILED; /* error */ - if (!handles[1]) return 0; /* no event to wait on */ - - return WaitForMultipleObjects( 2, handles, FALSE, timeout ); -} - - -/************************************************************************** - * WINHELP entry point - * - * FIXME: should go into winhlp32.exe, but we don't support 16-bit modules in executables yet. - */ -void WINAPI WINHELP_EntryPoint( CONTEXT86 *context ) -{ - static const WCHAR winhlp32W[] = {'\\','w','i','n','h','l','p','3','2','.','e','x','e',0}; - PDB16 *psp; - INT len, total; - WCHAR *cmdline, *p; - PROCESS_INFORMATION info; - STARTUPINFOW startup; - DWORD count, exit_code = 1; - - InitTask16( context ); - - TRACE( "(ds=%x es=%x fs=%x gs=%x, bx=%04x cx=%04x di=%04x si=%x)\n", - context->SegDs, context->SegEs, context->SegFs, context->SegGs, - context->Ebx, context->Ecx, context->Edi, context->Esi ); - - psp = GlobalLock16( context->SegEs ); - len = MultiByteToWideChar( CP_ACP, 0, (char *)psp->cmdLine + 1, psp->cmdLine[0], NULL, 0 ); - total = (GetSystemDirectoryW( NULL, 0 ) + len + 1) * sizeof(WCHAR) + sizeof(winhlp32W); - cmdline = HeapAlloc( GetProcessHeap(), 0, total ); - GetSystemDirectoryW( cmdline, total ); - lstrcatW( cmdline, winhlp32W ); - p = cmdline + lstrlenW(cmdline); - if (len) - { - *p++ = ' '; - MultiByteToWideChar( CP_ACP, 0, (char *)psp->cmdLine + 1, psp->cmdLine[0], p, len ); - p[len] = 0; - } - - memset( &startup, 0, sizeof(startup) ); - startup.cb = sizeof(startup); - - if (CreateProcessW( NULL, cmdline, NULL, NULL, FALSE, 0, NULL, NULL, &startup, &info )) - { - /* Give 10 seconds to the app to come up */ - if (wait_input_idle( info.hProcess, 10000 ) == WAIT_FAILED) - WARN("WaitForInputIdle failed: Error %d\n", GetLastError() ); - ReleaseThunkLock( &count ); - - WaitForSingleObject( info.hProcess, INFINITE ); - GetExitCodeProcess( info.hProcess, &exit_code ); - CloseHandle( info.hThread ); - CloseHandle( info.hProcess ); - } - else - ReleaseThunkLock( &count ); - - HeapFree( GetProcessHeap(), 0, cmdline ); - ExitThread( exit_code ); -} - /*********************************************************************** * _DebugOutput (KERNEL.328) */ diff --git a/programs/winhelp.exe16/Makefile.in b/programs/winhelp.exe16/Makefile.in new file mode 100644 index 00000000000..a41791b08cc --- /dev/null +++ b/programs/winhelp.exe16/Makefile.in @@ -0,0 +1,13 @@ +TOPSRCDIR = @top_srcdir@ +TOPOBJDIR = ../.. +SRCDIR = @srcdir@ +VPATH = @srcdir@ +MODULE = winhelp.exe16 +APPMODE = -mwindows -Wb,--subsystem,win16 +IMPORTS = kernel32 + +C_SRCS = winhelp.c + +@MAKE_PROG_RULES@ + +@DEPENDENCIES@ # everything below this line is overwritten by make depend diff --git a/programs/winhelp.exe16/winhelp.c b/programs/winhelp.exe16/winhelp.c new file mode 100644 index 00000000000..6bfa3f62461 --- /dev/null +++ b/programs/winhelp.exe16/winhelp.c @@ -0,0 +1,47 @@ +/* + * 16-bit winhelp implementation + * + * Copyright 2009 Alexandre Julliard + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include +#include + +#include "wine/winbase16.h" +#include "wine/debug.h" + +WINE_DEFAULT_DEBUG_CHANNEL(winhelp); + +/************************************************************************** + * WINHELP entry point + */ +WORD WINAPI WinMain16( HINSTANCE16 inst, HINSTANCE16 prev, LPSTR cmdline, WORD show ) +{ + int len = GetSystemDirectoryA( NULL, 0 ) + sizeof("\\winhlp32.exe") + strlen(cmdline); + char *buffer = HeapAlloc( GetProcessHeap(), 0, len ); + + GetSystemDirectoryA( buffer, len ); + strcat( buffer, "\\winhlp32.exe" ); + strcat( buffer, cmdline ); + + WINE_TRACE( "starting %s\n", wine_dbgstr_a(buffer) ); + + WinExec16( buffer, show ); + + HeapFree( GetProcessHeap(), 0, buffer ); + ExitThread( 0 ); +}