From c52d921f34dd4e2541da7577737f89ab5a75c84b Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Mon, 3 Mar 2008 15:22:35 +0100 Subject: [PATCH] kernel32: Added a winoldap.mod 16-bit exe to launch 32-bit processes. Based on a patch by Dmitry Timoshkov. --- .gitignore | 1 + dlls/Makefile.in | 3 ++- dlls/kernel32/Makefile.in | 4 ++++ dlls/kernel32/kernel16.c | 44 +++++++++++++++++++++++++++++++++++++++ dlls/kernel32/ne_module.c | 24 +++++++++++++++++---- include/wine/winbase16.h | 1 + tools/make_makefiles | 9 +++++++- 7 files changed, 80 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index 61d4f617088..a8ec7848e8c 100644 --- a/.gitignore +++ b/.gitignore @@ -559,6 +559,7 @@ dlls/winmm/tests/winmm_crosstest.exe dlls/winmm/winmm_res.res dlls/winnls.dll16 dlls/winnls32/libwinnls32.def +dlls/winoldap.mod16 dlls/winscard/libwinscard.def dlls/winscard/rsrc.res dlls/winsock.dll16 diff --git a/dlls/Makefile.in b/dlls/Makefile.in index 5b4145d1567..96e3a850988 100644 --- a/dlls/Makefile.in +++ b/dlls/Makefile.in @@ -419,6 +419,7 @@ WIN16_FILES = \ wineps16.drv16 \ wing.dll16 \ winnls.dll16 \ + winoldap.mod16 \ winsock.dll16 \ wintab.dll16 \ wprocs.dll16 @@ -446,7 +447,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: +comm.drv16 krnl386.exe16 stress.dll16 system.drv16 toolhelp.dll16 win87em.dll16 windebug.dll16 winoldap.mod16: echo "kernel32.dll" >$@ lzexpand.dll16: diff --git a/dlls/kernel32/Makefile.in b/dlls/kernel32/Makefile.in index aab68e6f533..2d57ea2f33c 100644 --- a/dlls/kernel32/Makefile.in +++ b/dlls/kernel32/Makefile.in @@ -96,6 +96,7 @@ MC_SRCS = \ nls/winerr_kor.mc EXTRA_OBJS = relay16asm.o +EXTRA_OBJS16 = winoldap.mod.o EXTRASUBDIRS = nls @@ -106,6 +107,9 @@ kernel.res: $(MC_SRCS:.mc=.mc.rc) relay16asm.o: $(WINEBUILD) $(WINEBUILD) $(WINEBUILDFLAGS) -o $@ --relay16 +winoldap.mod.o: $(WINEBUILD) + $(WINEBUILD) $(WINEBUILDFLAGS) --exe -o $@ --main-module $(MODULE) --entry WINOLDAP_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 50b11a057dc..81c9bee88b6 100644 --- a/dlls/kernel32/kernel16.c +++ b/dlls/kernel32/kernel16.c @@ -28,6 +28,9 @@ #include "toolhelp.h" #include "kernel_private.h" #include "kernel16_private.h" +#include "wine/debug.h" + +WINE_DEFAULT_DEBUG_CHANNEL(module); /************************************************************************** * DllEntryPoint (KERNEL.669) @@ -130,3 +133,44 @@ HANDLE WINAPI CreateThread16( SECURITY_ATTRIBUTES *sa, DWORD stack, args->param = param; return CreateThread( sa, stack, start_thread16, args, flags, id ); } + +/************************************************************************** + * WINOLDAP entry point + */ +void WINAPI WINOLDAP_EntryPoint( CONTEXT86 *context ) +{ + PDB16 *psp; + INT len; + LPSTR cmdline; + PROCESS_INFORMATION info; + STARTUPINFOA 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 = psp->cmdLine[0]; + cmdline = HeapAlloc( GetProcessHeap(), 0, len + 1 ); + memcpy( cmdline, psp->cmdLine + 1, len ); + cmdline[len] = 0; + ReleaseThunkLock( &count ); + + memset( &startup, 0, sizeof(startup) ); + startup.cb = sizeof(startup); + + /* FIXME: Should this be WinExec instead of CreateProcess? */ + if (CreateProcessA( NULL, cmdline, NULL, NULL, FALSE, + 0, NULL, NULL, &startup, &info )) + { + WaitForSingleObject( info.hProcess, INFINITE ); + GetExitCodeProcess( info.hProcess, &exit_code ); + CloseHandle( info.hThread ); + CloseHandle( info.hProcess ); + } + HeapFree( GetProcessHeap(), 0, cmdline ); + ExitThread( exit_code ); +} diff --git a/dlls/kernel32/ne_module.c b/dlls/kernel32/ne_module.c index 09e317592f0..27a0abc1199 100644 --- a/dlls/kernel32/ne_module.c +++ b/dlls/kernel32/ne_module.c @@ -1197,6 +1197,8 @@ HINSTANCE16 WINAPI LoadModule16( LPCSTR name, LPVOID paramBlock ) if (name == NULL) return 0; + TRACE("name %s, paramBlock %p\n", name, paramBlock); + /* Load module */ if ( (hModule = NE_GetModuleByFilename(name) ) != 0 ) @@ -1707,10 +1709,24 @@ HINSTANCE16 WINAPI WinExec16( LPCSTR lpCmdLine, UINT16 nCmdShow ) if (ret == 21 || ret == ERROR_BAD_FORMAT) /* 32-bit module or unknown executable*/ { - DWORD count; - ReleaseThunkLock( &count ); - ret = LOWORD( WinExec( lpCmdLine, nCmdShow ) ); - RestoreThunkLock( count ); + LOADPARAMS16 params; + WORD showCmd[2]; + showCmd[0] = 2; + showCmd[1] = nCmdShow; + + arglen = strlen( lpCmdLine ); + cmdline = HeapAlloc( GetProcessHeap(), 0, arglen + 1 ); + cmdline[0] = (BYTE)arglen; + memcpy( cmdline + 1, lpCmdLine, arglen ); + + params.hEnvironment = 0; + params.cmdLine = MapLS( cmdline ); + params.showCmd = MapLS( showCmd ); + params.reserved = 0; + + ret = LoadModule16( "winoldap.mod", ¶ms ); + UnMapLS( params.cmdLine ); + UnMapLS( params.showCmd ); } return ret; } diff --git a/include/wine/winbase16.h b/include/wine/winbase16.h index 365799401c7..21d8dca5b62 100644 --- a/include/wine/winbase16.h +++ b/include/wine/winbase16.h @@ -452,6 +452,7 @@ BOOL16 WINAPI GlobalUnlock16(HGLOBAL16); BOOL16 WINAPI GlobalUnWire16(HGLOBAL16); SEGPTR WINAPI GlobalWire16(HGLOBAL16); WORD WINAPI InitAtomTable16(WORD); +void WINAPI InitTask16(CONTEXT86*); BOOL16 WINAPI IsBadCodePtr16(SEGPTR); BOOL16 WINAPI IsBadHugeReadPtr16(SEGPTR,DWORD); BOOL16 WINAPI IsBadHugeWritePtr16(SEGPTR,DWORD); diff --git a/tools/make_makefiles b/tools/make_makefiles index 4de81a40840..98700dbcda7 100755 --- a/tools/make_makefiles +++ b/tools/make_makefiles @@ -225,7 +225,7 @@ sub parse_makefile($) $make{$1} = $2; next; } - if (/^(BISON_SRCS|LEX_SRCS|IDL_[CHIPS]_SRCS|IDL_TLB_SRCS|IMPLIB_SRCS|MC_SRCS|RC_SRCS|RC_SRCS16|RC_BINARIES|SPEC_SRCS16|MANPAGES|PROGRAMS)\s*=\s*(.*)/) + if (/^(BISON_SRCS|LEX_SRCS|IDL_[CHIPS]_SRCS|IDL_TLB_SRCS|IMPLIB_SRCS|MC_SRCS|RC_SRCS|RC_SRCS16|RC_BINARIES|SPEC_SRCS16|EXTRA_OBJS16|MANPAGES|PROGRAMS)\s*=\s*(.*)/) { my @list = split(/\s+/, $2); $make{$1} = \@list; @@ -422,6 +422,13 @@ sub update_dlls(@) my @list = map { $_ =~ s/\.spec$//; $_ .= ".dll" unless $_ =~ /\./; $_; } @{$makefile{"SPEC_SRCS16"}}; $altnames{$module} = \@list; } + if (defined $makefile{"EXTRA_OBJS16"}) + { + foreach my $obj (@{$makefile{"EXTRA_OBJS16"}}) + { + if ($obj =~ /^(.*\.(exe|mod))\.o/) { push @{$altnames{$module}}, $1; } + } + } } # output special dlls configure definitions