From 4d1cf9c8c4f7d7e903b513b407f7b3e69afb328f Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Tue, 13 May 2008 18:50:50 +0200 Subject: [PATCH] kernel32: Add a builtin 16-bit winhelp.exe. This should be moved to winhlp32.exe once we support 16-bit modules in executables. --- .gitignore | 1 + dlls/Makefile.in | 3 ++- dlls/kernel32/Makefile.in | 5 +++- dlls/kernel32/kernel16.c | 58 +++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 65 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index aaef4632494..9d9d24de1d7 100644 --- a/.gitignore +++ b/.gitignore @@ -446,6 +446,7 @@ dlls/wined3d/libwined3d.def dlls/winedos/libwinedos.def dlls/wineps16.drv16 dlls/wing.dll16 +dlls/winhelp.exe16 dlls/wininet/libwininet.def dlls/wininet/tests/*.ok dlls/wininet/tests/testlist.c diff --git a/dlls/Makefile.in b/dlls/Makefile.in index 755c75ad65f..155db3bf342 100644 --- a/dlls/Makefile.in +++ b/dlls/Makefile.in @@ -426,6 +426,7 @@ WIN16_FILES = \ windebug.dll16 \ wineps16.drv16 \ wing.dll16 \ + winhelp.exe16 \ winnls.dll16 \ winoldap.mod16 \ winsock.dll16 \ @@ -455,7 +456,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 winoldap.mod16: +comm.drv16 krnl386.exe16 stress.dll16 system.drv16 toolhelp.dll16 win87em.dll16 windebug.dll16 winhelp.exe16 winoldap.mod16: echo "kernel32.dll" >$@ lzexpand.dll16: diff --git a/dlls/kernel32/Makefile.in b/dlls/kernel32/Makefile.in index 3ac2567c736..b317953cbb7 100644 --- a/dlls/kernel32/Makefile.in +++ b/dlls/kernel32/Makefile.in @@ -96,7 +96,7 @@ MC_SRCS = \ nls/winerr_kor.mc EXTRA_OBJS = relay16asm.o -EXTRA_OBJS16 = winoldap.mod.o +EXTRA_OBJS16 = winhelp.exe.o winoldap.mod.o EXTRASUBDIRS = nls @@ -110,6 +110,9 @@ relay16asm.o: $(WINEBUILD) winoldap.mod.o: $(WINEBUILD) $(WINEBUILD) $(WINEBUILDFLAGS) --exe -o $@ --main-module $(MODULE) --entry WINOLDAP_EntryPoint +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 a330e57279a..01b5624ae33 100644 --- a/dlls/kernel32/kernel16.c +++ b/dlls/kernel32/kernel16.c @@ -206,3 +206,61 @@ void WINAPI WINOLDAP_EntryPoint( CONTEXT86 *context ) HeapFree( GetProcessHeap(), 0, cmdline ); ExitThread( exit_code ); } + + +/************************************************************************** + * 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 ); +} -- 2.11.4.GIT