wine/loader/module.c
Alexandre Julliard d30dfd24d6 Release 980927
Sun Sep 27 14:25:38 1998  Petter Reinholdtsen <pere@td.org.uit.no>

	* [files/drive.c]
	Make sure GetDriveType32A() handles param NULL.  Added some
	doc on function.

Sun Sep 27 14:07:26 1998  Huw D M Davies <daviesh@abacus.physics.ox.ac.uk>

	* [controls/edit.c] [windows/win.c]
	Don't call SetWindowLong() in EDIT_WM_NCREATE.
	Fix SetWindowLong(GWL_[EX]STYLE) to work for 16bit windows. Remove
	UpdateWindow() call. 

Sun Sep 27 13:41:22 1998  Alexandre Julliard  <julliard@lrc.epfl.ch>

	* [scheduler/*.c] [server/event.c] [server/mutex.c]
	  [server/semaphore.c]
	Implemented server-side synchronisation objects.

Sun Sep 27 01:13:35 1998  Alex Priem <alexp@sci.kun.nl>

	* [dlls/comctl32/treeview.c] [include/treeview.h] [include/comctl.h]
	Treeview implementation.

	* [dlls/comctl32/trackbar.c] [include/trackbar.h] 
	Trackbar implementation.

Sat Sep 26 20:49:13 1998  Ulrich Weigand <weigand@informatik.uni-erlangen.de>

	* [if1632/thunk.c] [tools/build.c] [win32/kernel32.c]
	Bugfix: several problems with flat thunks fixed.

	* [memory/selector.c]
	Bugfix: IsBad...Ptr16 didn't work for limit_in_pages segments.

	* [scheduler/thread.c]
	Bugfix: CreateThread: Allow id parameter == NULL.

	* [objects/gdiobj.c]
	Bugfix: IsGDIObject: Return correct object type for stock objects.

	* [msdos/dpmi.c]
	Bugfix: fixed typo in INT_DoRealModeInt.

	* [msdos/int21.c]
	Bugfix: int21 READ *must* use WIN16_hread, not _hread16.

	* [if1632/kernel.spec] [if1632/dummy.c] [if1632/thunk.c]
	  [loader/ne/module.c] [scheduler/event.c] [scheduler/synchro.c]
	  [scheduler/thread.c] [win32/kernel32.c] [win32/ordinals.c]
	Added names/stubs for all undocumented KERNEL routines (Win95).
	Added the following undoc. 16-bit equivalents to Win32 routines:
	KERNEL.441-443,449-453,456-462,471-476,479-486,488.
	Added stubs for some other KERNEL routines.

	* [memory/heap.c] [memory/global.c] [include/global.h]
	Implemented Local32... 32-bit local heap routines (KERNEL.208-215, 229).

	* [miscemu/instr.c] [loader/module.c] [include/module.h]
	Implemented __GP fault handling and HasGPHandler (KERNEL.338).

	* [misc/error.c]
	Implemented LogParamErrorRegs (KERNEL.327).

	* [loader/task.c] [include/windows.h]
	Implemented GetCodeInfo (KERNEL.104).

	* [loader/task.c] [scheduler/thread.c] [include/thread.h]
	Implemented [GS]etThreadQueue and [GS]etFastQueue (KERNEL.463/4, 624/5).

	* [if1632/gdi.spec] [objects/dc.c] [objects/dib.c]
	  [objects/bitmap.c] [include/windows.h]
	Bugfix: fixed wrong parameter for CreateDIBSection16.
	Added [GS]etDIBColorTable16, stub for GetBoundsRect16.
	Partially implemented BITMAP_GetObject16 for DIBs.

	* [if1632/gdi.spec] [relay32/gdi32.spec] [objects/palette.c]
	Added some GDI stubs.

	* [if1632/Makefile.in] [if1632/display.spec] [if1632/mouse.spec]
	  [if1632/keyboard.spec] [if1632/builtin.c] [windows/keyboard.c]
	Added some stubs for Win16 drivers: KEYBOARD, MOUSE, DISPLAY.

	* [if1632/wprocs.spec] [msdos/vxd.c]
	Added some stubs for VxDs: VMM, ConfigMG, TimerAPI.

	* [msdos/int2f.c]
	Added some stubs for real-mode network drivers.

Sat Sep 26 18:18:18 1998  Marcus Meissner <marcus@jet.franken.de>

	* [configure.in]
	Merged in some more of the FreeBSD ports/emulators/wine patches. 
	(Maintainer(s) of this port: You can just submit these
	patches to Alexandre directly.)

	 * [loader/pe_image.c]
	Check filesize of image against size derived from header
	to spot truncated executeables without crashing.

	* [files/directory.c]
	Set envvar "COMSPEC". One win32(!!) program crashes without it.

	* [multimedia/mmio.c]
	Added mmioSetInfo32.

	* [include/file.h]
	Return STD_ERROR_HANDLE for AUX and PRT dos handles.

	* [loader/module.c]
	Handle executeables with spaces in their names a bit better in
	CreateProcess.

	* [relay32/msvfw32.spec][if1632/msvideo.spec][multimedia/msvideo.c][include/vfw.h]
	Started on MS Video support (can load Win32 ICMs).

	* [tools/testrun]
	A bit smarter use of ps.

	* [memory/virtual.c]
	Report PAGE_GUARDed pages as PAGE_PROTECTED (AutoCAD LT R17 fails
	without that check (since Win95 doesn't know about PAGE_GUARD)).

Sat Sep 26 15:04:05 1998  Ove Kaaven <ovek@arcticnet.no>

	* [include/miscemu.h] [if1632/builtin.c] [loader/task.c]
	  [miscemu/instr.c] [msdos/dpmi.c] [msdos/int21.c]
	  [msdos/interrupts.c] [windows/user.c]
	INT_[S|G]etHandler was renamed to INT_[S|G]etPMHandler.
	Added handlers to deal with real-mode interrupts; DOS
	programs are now able to hook real-mode interrupts.

	* [loader/dos/module.c] [msdos/dosmem.c] [msdos/int21.c]
	Moved real-mode interrupt table initialization to
	msdos/dosmem.c, and made new V86 tasks get a full copy
	of the existing "system memory" instead of almost empty
	space. Misc fixes.

	* [include/dosexe.h] [loader/dos/module.c] [msdos/dpmi.c]
	  [msdos/int2f.c]
	First shot at letting DOS programs start up DPMI (but DPMI
	is still disabled for DOS programs, for pkunzip's sake).

	* [include/debugger.h] [debugger/break.c] [debugger/dbg.y]
	  [debugger/registers.c] [debugger/memory.c] [debugger/info.c]
	  [loader/dos/dosvm.c]
	First shot at making Wine's debugger work for DOS programs.
	The -debug flag works, as do "nexti" and "stepi".

Sat Sep 26 13:13:13 1998  Juergen Schmied <juergen.schmied@metronet.de>

	* [dlls/shell32/dataobject.c]
	New classes IEnumFORMATETC implemented, IDataObject stubs.
	
	* [dlls/shell32/*.*][relay32/shell32.spec]
	Bugfixes.
	New: ICM_InsertItem(), ILCreateFromPath().
	Implemented: ILCloneFirst().
	Stubs: ILIsEqual(), ILFindChild(), SHLogILFromFSIL(),
	  PathMatchSpec(), PathIsExe().
	Changed: ILGetSize(), _ILIsDesktop(), PathCombine().

	* [include/shlobj.h]
	New SHLGUID's
	New structures: DVTARGETDEVICE32, STGMEDIUM32, FORMATETC32,
	CLIPFORMAT32.
	New interfaces: IEnumFORMATETC, IDataObject, ICommDlgBrowser
	IDockingWindowFrame, IServiceProvider.

	* [dlls/shell32/folders.c]
	Stubs for IShellLink.

	* [loader/resource.c]
	Small fixes.

	* [misc/crtdll.c][relay32/crtdll.spec]
	New __dllonexit().

	* [windows/message.c]
	SendNotifyMessageA, SendMessageCallBack32A half implemented.

	* [controls/edit.c]
	EDIT_WM_SetText set EF_UPDATE flag not for ES_MULTILINE.

	* [files/file.c]
	Handling of fileposition fixed.

Fri Sep 25 18:13:30 1998  Patrik Stridvall <ps@leissner.se>

	* [include/windows.h] [include/wintypes.h]
	  [ole/ole2nls.h] [relay32/kernel32.spec]
	Implemented EnumDateFormats and EnumTimeFormats.
	Only adds US English support.

	* [Makefile.in] [configure.in] 
	  [dlls/Makefile.in] [dlls/psapi/Makefile.in] 
	  [dlls/psapi/psapi_main.c] 
	New files to implement stubs for PSAPI.DLL (NT only).

	* [relay32/Makefile.in] [relay32/builtin32.c] 
	  [relay32/psapi.spec]
	New spec file for PSAPI.DLL (NT only).

	* [scheduler/handle.c]
	HANDLE_GetObjPtr should only interpret the pseudo handles as the
	current thread or the current process if a thread or a process is
	requested.

	* [include/winversion.h] [misc/version.c]
	Adds the global function VERSION_GetVersion() so functions can
	have different behavior depending on the -winver flag.

	* [include/oledlg.h] [ole/oledlg.c]
	Minor fixes. 

	* [windows/winproc.c]
	Minor changes.

	* [include/imm.h] [misc/imm.c]
	Now returns correct values under both Windows 95 and NT 4.0.

Thu Sep 24 22:11:44 1998  Kristian Nielsen  <kristian.nielsen@risoe.dk>

	* [configure.in] [include/acconfig.h] [include/thread.h]
	  [scheduler/sysdeps.c]
	Autoconfig test for non-reentrant libc.

Wed Sep 23 19:52:12 1998  Matthew Becker <mbecker@glasscity.net>

	* [*/*.c]
	Miscellaneous documentation updates and debugging output 
	standardizations.

	* [objects/clipping.c]
	Added ExtSelectClipRgn.

Wed Sep 23 00:03:28 EDT 1998  Pete Ratzlaff <pratzlaff@cfa.harvard.edu>

	* [include/windows.h] [if1632/user.spec] [relay32/user32.spec]
	  [windows/keyboard.c]
	Added, marginally implemented, GetKeyboardLayoutName().
	Only returns US English keyboard name.

Tue Sep 22 16:32:41 1998  Marcel Baur <mbaur@iiic.ethz.ch>

	* [programs/control/*]
	New Winelib application.

Mon Sep 21 00:29:18 1998  Peter Hunnisett <hunnise@nortel.ca>

	* [include/dplay.h][multimedia/dplay.c][ole/compobj.c]
	Added all DirectPlayLobby interfaces and enhanced DirectPlay
	and DirectPlayLobby support. Still not all that much. Useful
	enough if you just need to start a program, don't try any
	real dplay/lobby stuff.

	* [documentation/status/directplay]
	Added a very little bit.

	* [graphics/ddraw.c]
	- Call to SetWindowLong32A wasn't working because there was no
	  memory set aside when the window class was registered.
	- Fixed some xlib reference counting and change the behaviour
	  of DirectDrawSurface3_SetPalette to mimic observed behaviour
	  (palette is associated will all backbuffers)
	- Also stored all palette colour fields and spit back our saved
	  colour fields rather than query X for them.
	- Added plenty of AddRef and Release traces.
	- Added Xlib support for using -desktop option.
	- Fixed Xlib message handling. Messages weren't being passed to
	  the application. Fixes mouse movements in some xlib DDraw games.
	- Added a few stubs.

	* [windows/win.c][include/winerror.h]
	Fixed up some error handling in WIN_SetWindowLong. SetLastError
	wasn't being used. Could cause problems with 0 return codes.
	Added new error in winerror (1400).

	* [AUTHORS] [include/authors.h]
	Added myself as a Wine author.

Sun Sep 20 21:22:44 1998  Alexander Larsson  <alla@lysator.liu.se>

	* [loader/module.c]
	Changed GetModuleFileName32A so that is returns the
	long version of the filename. Note that just the name
	is long, not the directories.

Sat Sep 19 20:05:30 1998 Per Ångström <pang@mind.nu> 

	* [controls/menu.c]
	Made a couple of fixes to make life easier for applications that alter
	their menus at runtime.

	* [windows/defdlg.c]
	Removed the cast of the return value from dialog procedures to a 16-bit
	bool. The return value needs to retain all its 32 bits, since it is not 
	always a bool, such as when responding to the WM_NCHITTEST message.

Fri Sep 18 11:30:38 1998  Sergey Turchanov <turchanov@usa.net>

	* [loader/resource.c]
	Fixed very funny bug (though gravely affecting further excecution)
	with FindResource[Ex]32 functions.

	* [include/multimon.h] [windows/multimon.c] [relay32/user32.spec]
	  [include/windows.h] [windows/sysmetrics.c]
	Default implementation for Multimonitor API.

	* [include/windows.h] [windows/winpos.c]
	Fixed incorrect declaration (and behaviour) of GetWindowRect32.

Wed Sep 16 10:21:15 1998  Gerard Patel <G.Patel@Wanadoo.fr>

	* [controls/edit.c]
	Fixed EDIT_EM_GetLine to use correctly length of lines.

Tue Sep 15 20:40:16 1998  Eric Kohl <ekohl@abo.rhein-zeitung.de>

	* [misc/tweak.c][include/tweak.h][controls/menu.c]
	Replaced the tweak graphic routines by calls to DrawEdge32().

	* [misc/tweak.c][include/tweak.h][documentation/win95look]
	  [wine.ini][*/*]
	Changed "look and feel" selection. Allows Win3.1, Win95 and
	Win98 (no GUI code implemented) look and feel.

	* [dlls/comctl32/header.c][include/header.h][include/commctrl.h]
	Started callback item support and did some minor improvements.

	* [dlls/comctl32/imagelist.c]
	Fixed bug in transparent image display.
	ImageList_GetIcon is still buggy :-(

	* [dlls/comctl32/toolbar.c]
	Fixed button drawing (partial hack).

	* [dlls/comctl32/commctrl.c]
	Fixed MenuHelp().

	* [controls/button.c]
	Added 3d effect for groupbox.

	* [windows/msgbox.c]
	Added font support for message boxes.

	* [windows/nonclient.c]
	Fixed window moving bug.

	* [dlls/comctl32/*.c]
	Various improvements.

	* [dlls/comctl32/listview.c][dlls/comctl32/rebar.c]
	  [include/commctrl.h]
	More messages.

	* [windows/syscolor.c][include/windows.h]
	Introduced new Win98 system colors.

Tue Sep 15 18:29:45 1998 Wesley Filardo <eightknots@aol.com>

	* [files/profile.c]
	Added support in PROFILE_LoadWineIni for -config option

	* [misc/main.c] [include/options.h]
	Added -config option.

Tue Sep 15 18:22:26 1998  Petter Reinholdtsen <pere@td.org.uit.no>

	* [documentation/Makefile.in]
	Make sure directory exists before installing into it.

Tue Sep 15 01:47:33 1998  Pablo Saratxaga <pablo.sarachaga@ping.be>

	* [ole/nls/*] [ole/ole2nls.c] [include/winnls.h]
	Fixed a few errors and completed some NLS files.

Mon Sep 14 01:23:45 1998  Joseph Pranevich <knight@baltimore.wwaves.com>

	* [include/miscemu.h] [msdos/interrupts.c]
	Removed a compilation warning, added INT 25 to the list of interrupts
	callable from DOS applications, added a debug message when unsupported
	interrupts are used.

Sun Sep 13 19:55:22 1998  Lawson Whitney <lawson_whitney@juno.com>

	* [if1632/relay.c]
	CallProcEx32W should not reverse arguments.

Sun Aug 17 21:18:12 1998  Eric Pouech  <eric.pouech@lemel.fr>

	* [multimedia/midi.c] [multimedia/init.c] [multimedia/mmsys.c] 
	  [include/multimedia.h] [include/mmsystem.h] 
	  [multimedia/Makefile.in] [multimedia/midipatch.c]
	  [if1632/multimedia.spec]
	Made MIDI input and output functional on OSS capable systems.

	* [multimedia/timer.c]
	Changes to trigger callbacks at the accurate pace even when
	fake timers are used.
1998-09-27 18:28:36 +00:00

1083 lines
33 KiB
C

/*
* Modules
*
* Copyright 1995 Alexandre Julliard
*/
#include <assert.h>
#include <fcntl.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <unistd.h>
#include "windows.h"
#include "winerror.h"
#include "class.h"
#include "file.h"
#include "global.h"
#include "heap.h"
#include "module.h"
#include "neexe.h"
#include "pe_image.h"
#include "dosexe.h"
#include "process.h"
#include "thread.h"
#include "resource.h"
#include "selectors.h"
#include "stackframe.h"
#include "task.h"
#include "debug.h"
#include "callback.h"
extern BOOL32 THREAD_InitDone;
/*************************************************************************
* MODULE32_LookupHMODULE
* looks for the referenced HMODULE in the current process
*/
WINE_MODREF*
MODULE32_LookupHMODULE(PDB32 *process,HMODULE32 hmod) {
WINE_MODREF *wm;
if (!hmod)
return process->exe_modref;
if (!HIWORD(hmod)) {
ERR(module,"tried to lookup 0x%04x in win32 module handler!\n",hmod);
return NULL;
}
for (wm = process->modref_list;wm;wm=wm->next)
if (wm->module == hmod)
return wm;
return NULL;
}
/***********************************************************************
* MODULE_CreateDummyModule
*
* Create a dummy NE module for Win32 or Winelib.
*/
HMODULE32 MODULE_CreateDummyModule( const OFSTRUCT *ofs )
{
HMODULE32 hModule;
NE_MODULE *pModule;
SEGTABLEENTRY *pSegment;
char *pStr,*s;
int len;
const char* basename;
INT32 of_size = sizeof(OFSTRUCT) - sizeof(ofs->szPathName)
+ strlen(ofs->szPathName) + 1;
INT32 size = sizeof(NE_MODULE) +
/* loaded file info */
of_size +
/* segment table: DS,CS */
2 * sizeof(SEGTABLEENTRY) +
/* name table */
9 +
/* several empty tables */
8;
hModule = GlobalAlloc16( GMEM_MOVEABLE | GMEM_ZEROINIT, size );
if (!hModule) return (HMODULE32)11; /* invalid exe */
FarSetOwner( hModule, hModule );
pModule = (NE_MODULE *)GlobalLock16( hModule );
/* Set all used entries */
pModule->magic = IMAGE_OS2_SIGNATURE;
pModule->count = 1;
pModule->next = 0;
pModule->flags = 0;
pModule->dgroup = 1;
pModule->ss = 1;
pModule->cs = 2;
pModule->heap_size = 0xe000;
pModule->stack_size = 0x1000;
pModule->seg_count = 2;
pModule->modref_count = 0;
pModule->nrname_size = 0;
pModule->fileinfo = sizeof(NE_MODULE);
pModule->os_flags = NE_OSFLAGS_WINDOWS;
pModule->expected_version = 0x030a;
pModule->self = hModule;
/* Set loaded file information */
memcpy( pModule + 1, ofs, of_size );
((OFSTRUCT *)(pModule+1))->cBytes = of_size - 1;
pSegment = (SEGTABLEENTRY*)((char*)(pModule + 1) + of_size);
pModule->seg_table = pModule->dgroup_entry = (int)pSegment - (int)pModule;
/* Data segment */
pSegment->size = 0;
pSegment->flags = NE_SEGFLAGS_DATA;
pSegment->minsize = 0x1000;
pSegment++;
/* Code segment */
pSegment->flags = 0;
pSegment++;
/* Module name */
pStr = (char *)pSegment;
pModule->name_table = (int)pStr - (int)pModule;
basename = strrchr(ofs->szPathName,'\\');
if (!basename) basename = ofs->szPathName;
else basename++;
len = strlen(basename);
if ((s = strchr(basename,'.'))) len = s - basename;
if (len > 8) len = 8;
*pStr = len;
strncpy( pStr+1, basename, len );
if (len < 8) pStr[len+1] = 0;
pStr += 9;
/* All tables zero terminated */
pModule->res_table = pModule->import_table = pModule->entry_table =
(int)pStr - (int)pModule;
NE_RegisterModule( pModule );
return hModule;
}
/***********************************************************************
* MODULE_GetWndProcEntry16 (not a Windows API function)
*
* Return an entry point from the WPROCS dll.
*/
FARPROC16 MODULE_GetWndProcEntry16( LPCSTR name )
{
FARPROC16 ret = NULL;
if (__winelib)
{
/* FIXME: hack for Winelib */
extern LRESULT ColorDlgProc(HWND16,UINT16,WPARAM16,LPARAM);
extern LRESULT FileOpenDlgProc(HWND16,UINT16,WPARAM16,LPARAM);
extern LRESULT FileSaveDlgProc(HWND16,UINT16,WPARAM16,LPARAM);
extern LRESULT FindTextDlgProc16(HWND16,UINT16,WPARAM16,LPARAM);
extern LRESULT PrintDlgProc(HWND16,UINT16,WPARAM16,LPARAM);
extern LRESULT PrintSetupDlgProc(HWND16,UINT16,WPARAM16,LPARAM);
extern LRESULT ReplaceTextDlgProc16(HWND16,UINT16,WPARAM16,LPARAM);
if (!strcmp(name,"ColorDlgProc"))
return (FARPROC16)ColorDlgProc;
if (!strcmp(name,"FileOpenDlgProc"))
return (FARPROC16)FileOpenDlgProc;
if (!strcmp(name,"FileSaveDlgProc"))
return (FARPROC16)FileSaveDlgProc;
if (!strcmp(name,"FindTextDlgProc"))
return (FARPROC16)FindTextDlgProc16;
if (!strcmp(name,"PrintDlgProc"))
return (FARPROC16)PrintDlgProc;
if (!strcmp(name,"PrintSetupDlgProc"))
return (FARPROC16)PrintSetupDlgProc;
if (!strcmp(name,"ReplaceTextDlgProc"))
return (FARPROC16)ReplaceTextDlgProc16;
if (!strcmp(name,"DefResourceHandler"))
return (FARPROC16)NE_DefResourceHandler;
if (!strcmp(name,"LoadDIBIconHandler"))
return (FARPROC16)LoadDIBIconHandler;
if (!strcmp(name,"LoadDIBCursorHandler"))
return (FARPROC16)LoadDIBCursorHandler;
FIXME(module,"No mapping for %s(), add one in library/miscstubs.c\n",name);
assert( FALSE );
return NULL;
}
else
{
WORD ordinal;
static HMODULE32 hModule = 0;
if (!hModule) hModule = GetModuleHandle16( "WPROCS" );
ordinal = NE_GetOrdinal( hModule, name );
if (!(ret = NE_GetEntryPoint( hModule, ordinal )))
{
WARN( module, "%s not found\n", name );
assert( FALSE );
}
}
return ret;
}
/**********************************************************************
* MODULE_FindModule32
*
* Find a (loaded) win32 module depending on path
* The handling of '.' is a bit weird, but we need it that way,
* for sometimes the programs use '<name>.exe' and '<name>.dll' and
* this is the only way to differentiate. (mainly hypertrm.exe)
*
* RETURNS
* the module handle if found
* 0 if not
*/
HMODULE32 MODULE_FindModule32(
PDB32* process, /* [in] process in which to find the library */
LPCSTR path /* [in] pathname of module/library to be found */
) {
LPSTR filename;
LPSTR dotptr;
WINE_MODREF *wm;
if (!process)
return 0;
if (!(filename = strrchr( path, '\\' )))
filename = HEAP_strdupA(process->heap,0,path);
else
filename = HEAP_strdupA(process->heap,0,filename+1);
dotptr=strrchr(filename,'.');
for (wm=process->modref_list;wm;wm=wm->next) {
LPSTR xmodname,xdotptr;
assert (wm->modname);
xmodname = HEAP_strdupA(process->heap,0,wm->modname);
xdotptr=strrchr(xmodname,'.');
if ( (xdotptr && !dotptr) ||
(!xdotptr && dotptr)
) {
if (dotptr) *dotptr = '\0';
if (xdotptr) *xdotptr = '\0';
}
if (!strcasecmp( filename, xmodname)) {
HeapFree(process->heap,0,filename);
HeapFree(process->heap,0,xmodname);
return wm->module;
}
if (dotptr) *dotptr='.';
/* FIXME: add paths, shortname */
HeapFree(process->heap,0,xmodname);
}
/* if that fails, try looking for the filename... */
for (wm=process->modref_list;wm;wm=wm->next) {
LPSTR xlname,xdotptr;
assert (wm->longname);
xlname = strrchr(wm->longname,'/');
if (!xlname)
xlname = wm->longname;
else
xlname++;
xlname = HEAP_strdupA(process->heap,0,xlname);
xdotptr=strrchr(xlname,'.');
if ( (xdotptr && !dotptr) ||
(!xdotptr && dotptr)
) {
if (dotptr) *dotptr = '\0';
if (xdotptr) *xdotptr = '\0';
}
if (!strcasecmp( filename, xlname)) {
HeapFree(process->heap,0,filename);
HeapFree(process->heap,0,xlname);
return wm->module;
}
if (dotptr) *dotptr='.';
/* FIXME: add paths, shortname */
HeapFree(process->heap,0,xlname);
}
HeapFree(process->heap,0,filename);
return 0;
}
/**********************************************************************
* NE_CreateProcess
*/
static HINSTANCE16 NE_CreateProcess( LPCSTR name, LPCSTR cmd_line, LPCSTR env,
LPSTARTUPINFO32A startup,
LPPROCESS_INFORMATION info )
{
HMODULE16 hModule;
HINSTANCE16 hInstance, hPrevInstance;
NE_MODULE *pModule;
if (__winelib)
{
OFSTRUCT ofs;
lstrcpyn32A( ofs.szPathName, name, sizeof(ofs.szPathName) );
if ((hModule = MODULE_CreateDummyModule( &ofs )) < 32) return hModule;
pModule = (NE_MODULE *)GlobalLock16( hModule );
hInstance = NE_CreateInstance( pModule, &hPrevInstance, FALSE );
}
else
{
hInstance = NE_LoadModule( name, &hPrevInstance, FALSE, FALSE );
if (hInstance < 32) return hInstance;
if ( !(pModule = NE_GetPtr(hInstance))
|| (pModule->flags & NE_FFLAGS_LIBMODULE))
{
/* FIXME: cleanup */
return 11;
}
}
/* Create a task for this instance */
pModule->flags |= NE_FFLAGS_GUI; /* FIXME: is this necessary? */
PROCESS_Create( pModule, cmd_line, env, hInstance,
hPrevInstance, startup, info );
return hInstance;
}
/**********************************************************************
* LoadModule16 (KERNEL.45)
*/
HINSTANCE16 WINAPI LoadModule16( LPCSTR name, LPVOID paramBlock )
{
LOADPARAMS *params;
LPSTR cmd_line, new_cmd_line;
LPCVOID env = NULL;
STARTUPINFO32A startup;
PROCESS_INFORMATION info;
HINSTANCE16 hInstance, hPrevInstance;
NE_MODULE *pModule;
PDB32 *pdb;
/* Load module */
if (!paramBlock || (paramBlock == (LPVOID)-1))
return LoadLibrary16( name );
hInstance = NE_LoadModule( name, &hPrevInstance, FALSE, FALSE );
if ( hInstance < 32 || !(pModule = NE_GetPtr(hInstance))
|| (pModule->flags & NE_FFLAGS_LIBMODULE))
return hInstance;
/* Create a task for this instance */
pModule->flags |= NE_FFLAGS_GUI; /* FIXME: is this necessary? */
params = (LOADPARAMS *)paramBlock;
cmd_line = (LPSTR)PTR_SEG_TO_LIN( params->cmdLine );
if (!cmd_line) cmd_line = "";
else if (*cmd_line) cmd_line++; /* skip the length byte */
if (!(new_cmd_line = HeapAlloc( GetProcessHeap(), 0,
strlen(cmd_line)+strlen(name)+2 )))
return 0;
strcpy( new_cmd_line, name );
strcat( new_cmd_line, " " );
strcat( new_cmd_line, cmd_line );
if (params->hEnvironment) env = GlobalLock16( params->hEnvironment );
memset( &info, '\0', sizeof(info) );
memset( &startup, '\0', sizeof(startup) );
startup.cb = sizeof(startup);
if (params->showCmd)
{
startup.dwFlags = STARTF_USESHOWWINDOW;
startup.wShowWindow = ((UINT16 *)PTR_SEG_TO_LIN(params->showCmd))[1];
}
pdb = PROCESS_Create( pModule, new_cmd_line, env,
hInstance, hPrevInstance, &startup, &info );
CloseHandle( info.hThread );
CloseHandle( info.hProcess );
if (params->hEnvironment) GlobalUnlock16( params->hEnvironment );
HeapFree( GetProcessHeap(), 0, new_cmd_line );
/* Start task */
if (pdb) TASK_StartTask( pdb->task );
return hInstance;
}
/**********************************************************************
* LoadModule32 (KERNEL32.499)
*/
HINSTANCE32 WINAPI LoadModule32( LPCSTR name, LPVOID paramBlock )
{
LOADPARAMS32 *params = (LOADPARAMS32 *)paramBlock;
PROCESS_INFORMATION info;
STARTUPINFO32A startup;
HINSTANCE32 hInstance;
PDB32 *pdb;
TDB *tdb;
memset( &startup, '\0', sizeof(startup) );
startup.cb = sizeof(startup);
startup.dwFlags = STARTF_USESHOWWINDOW;
startup.wShowWindow = params->lpCmdShow? params->lpCmdShow[1] : 0;
if (!CreateProcess32A( name, params->lpCmdLine,
NULL, NULL, FALSE, 0, params->lpEnvAddress,
NULL, &startup, &info ))
return GetLastError(); /* guaranteed to be < 32 */
/* Get hInstance from process */
pdb = PROCESS_IdToPDB( info.dwProcessId );
tdb = pdb? (TDB *)GlobalLock16( pdb->task ) : NULL;
hInstance = tdb? tdb->hInstance : 0;
/* Close off the handles */
CloseHandle( info.hThread );
CloseHandle( info.hProcess );
return hInstance;
}
/**********************************************************************
* CreateProcess32A (KERNEL32.171)
*/
BOOL32 WINAPI CreateProcess32A( LPCSTR lpApplicationName, LPSTR lpCommandLine,
LPSECURITY_ATTRIBUTES lpProcessAttributes,
LPSECURITY_ATTRIBUTES lpThreadAttributes,
BOOL32 bInheritHandles, DWORD dwCreationFlags,
LPVOID lpEnvironment, LPCSTR lpCurrentDirectory,
LPSTARTUPINFO32A lpStartupInfo,
LPPROCESS_INFORMATION lpProcessInfo )
{
HINSTANCE16 hInstance;
LPCSTR cmdline;
PDB32 *pdb;
char name[256];
/* Get name and command line */
if (!lpApplicationName && !lpCommandLine)
{
SetLastError( ERROR_FILE_NOT_FOUND );
return FALSE;
}
cmdline = lpCommandLine? lpCommandLine : lpApplicationName;
if (lpApplicationName)
lstrcpyn32A(name, lpApplicationName, sizeof(name) - 4);
else {
char *ptr;
int len;
/* Take care off .exes with spaces in their names */
ptr = strchr(lpCommandLine, ' ');
do {
len = (ptr? ptr-lpCommandLine : strlen(lpCommandLine)) + 1;
if (len > sizeof(name) - 4) len = sizeof(name) - 4;
lstrcpyn32A(name, lpCommandLine, len);
if (!strchr(name, '\\') && !strchr(name, '.'))
strcat(name, ".exe");
fprintf(stderr,"looking for: %s\n",name);
if (GetFileAttributes32A(name)!=-1)
break;
/* if there is a space and no file found yet, include the word
* up to the next space too. If there is no next space, just
* use the first word.
*/
if (ptr) {
ptr = strchr(ptr+1, ' ');
} else {
ptr = strchr(lpCommandLine, ' ');
len = (ptr? ptr-lpCommandLine : strlen(lpCommandLine)) + 1;
if (len > sizeof(name) - 4) len = sizeof(name) - 4;
lstrcpyn32A(name, lpCommandLine, len);
break;
}
} while (1);
}
if (!strchr(name, '\\') && !strchr(name, '.'))
strcat(name, ".exe");
/* Warn if unsupported features are used */
if (lpProcessAttributes)
FIXME(module, "(%s,...): lpProcessAttributes ignored\n", name);
if (lpThreadAttributes)
FIXME(module, "(%s,...): lpThreadAttributes ignored\n", name);
if (bInheritHandles)
FIXME(module, "(%s,...): bInheritHandles ignored\n", name);
if (dwCreationFlags & DEBUG_PROCESS)
FIXME(module, "(%s,...): DEBUG_PROCESS ignored\n", name);
if (dwCreationFlags & DEBUG_ONLY_THIS_PROCESS)
FIXME(module, "(%s,...): DEBUG_ONLY_THIS_PROCESS ignored\n", name);
if (dwCreationFlags & CREATE_SUSPENDED)
FIXME(module, "(%s,...): CREATE_SUSPENDED ignored\n", name);
if (dwCreationFlags & DETACHED_PROCESS)
FIXME(module, "(%s,...): DETACHED_PROCESS ignored\n", name);
if (dwCreationFlags & CREATE_NEW_CONSOLE)
FIXME(module, "(%s,...): CREATE_NEW_CONSOLE ignored\n", name);
if (dwCreationFlags & NORMAL_PRIORITY_CLASS)
FIXME(module, "(%s,...): NORMAL_PRIORITY_CLASS ignored\n", name);
if (dwCreationFlags & IDLE_PRIORITY_CLASS)
FIXME(module, "(%s,...): IDLE_PRIORITY_CLASS ignored\n", name);
if (dwCreationFlags & HIGH_PRIORITY_CLASS)
FIXME(module, "(%s,...): HIGH_PRIORITY_CLASS ignored\n", name);
if (dwCreationFlags & REALTIME_PRIORITY_CLASS)
FIXME(module, "(%s,...): REALTIME_PRIORITY_CLASS ignored\n", name);
if (dwCreationFlags & CREATE_NEW_PROCESS_GROUP)
FIXME(module, "(%s,...): CREATE_NEW_PROCESS_GROUP ignored\n", name);
if (dwCreationFlags & CREATE_UNICODE_ENVIRONMENT)
FIXME(module, "(%s,...): CREATE_UNICODE_ENVIRONMENT ignored\n", name);
if (dwCreationFlags & CREATE_SEPARATE_WOW_VDM)
FIXME(module, "(%s,...): CREATE_SEPARATE_WOW_VDM ignored\n", name);
if (dwCreationFlags & CREATE_SHARED_WOW_VDM)
FIXME(module, "(%s,...): CREATE_SHARED_WOW_VDM ignored\n", name);
if (dwCreationFlags & CREATE_DEFAULT_ERROR_MODE)
FIXME(module, "(%s,...): CREATE_DEFAULT_ERROR_MODE ignored\n", name);
if (dwCreationFlags & CREATE_NO_WINDOW)
FIXME(module, "(%s,...): CREATE_NO_WINDOW ignored\n", name);
if (dwCreationFlags & PROFILE_USER)
FIXME(module, "(%s,...): PROFILE_USER ignored\n", name);
if (dwCreationFlags & PROFILE_KERNEL)
FIXME(module, "(%s,...): PROFILE_KERNEL ignored\n", name);
if (dwCreationFlags & PROFILE_SERVER)
FIXME(module, "(%s,...): PROFILE_SERVER ignored\n", name);
if (lpCurrentDirectory)
FIXME(module, "(%s,...): lpCurrentDirectory %s ignored\n",
name, lpCurrentDirectory);
if (lpStartupInfo->lpDesktop)
FIXME(module, "(%s,...): lpStartupInfo->lpDesktop %s ignored\n",
name, lpStartupInfo->lpDesktop);
if (lpStartupInfo->lpTitle)
FIXME(module, "(%s,...): lpStartupInfo->lpTitle %s ignored\n",
name, lpStartupInfo->lpTitle);
if (lpStartupInfo->dwFlags & STARTF_USECOUNTCHARS)
FIXME(module, "(%s,...): STARTF_USECOUNTCHARS (%ld,%ld) ignored\n",
name, lpStartupInfo->dwXCountChars, lpStartupInfo->dwYCountChars);
if (lpStartupInfo->dwFlags & STARTF_USEFILLATTRIBUTE)
FIXME(module, "(%s,...): STARTF_USEFILLATTRIBUTE %lx ignored\n",
name, lpStartupInfo->dwFillAttribute);
if (lpStartupInfo->dwFlags & STARTF_RUNFULLSCREEN)
FIXME(module, "(%s,...): STARTF_RUNFULLSCREEN ignored\n", name);
if (lpStartupInfo->dwFlags & STARTF_FORCEONFEEDBACK)
FIXME(module, "(%s,...): STARTF_FORCEONFEEDBACK ignored\n", name);
if (lpStartupInfo->dwFlags & STARTF_FORCEOFFFEEDBACK)
FIXME(module, "(%s,...): STARTF_FORCEOFFFEEDBACK ignored\n", name);
if (lpStartupInfo->dwFlags & STARTF_USEHOTKEY)
FIXME(module, "(%s,...): STARTF_USEHOTKEY ignored\n", name);
/* Try NE (or winelib) module */
hInstance = NE_CreateProcess( name, cmdline, lpEnvironment,
lpStartupInfo, lpProcessInfo );
/* Try PE module */
if (hInstance == 21)
hInstance = PE_CreateProcess( name, cmdline, lpEnvironment,
lpStartupInfo, lpProcessInfo );
/* Try DOS module */
if (hInstance == 11)
hInstance = MZ_CreateProcess( name, cmdline, lpEnvironment,
lpStartupInfo, lpProcessInfo );
if (hInstance < 32)
{
SetLastError( hInstance );
return FALSE;
}
/* Get hTask from process and start the task */
pdb = PROCESS_IdToPDB( lpProcessInfo->dwProcessId );
if (pdb) TASK_StartTask( pdb->task );
return TRUE;
}
/**********************************************************************
* CreateProcess32W (KERNEL32.172)
*/
BOOL32 WINAPI CreateProcess32W( LPCWSTR lpApplicationName, LPWSTR lpCommandLine,
LPSECURITY_ATTRIBUTES lpProcessAttributes,
LPSECURITY_ATTRIBUTES lpThreadAttributes,
BOOL32 bInheritHandles, DWORD dwCreationFlags,
LPVOID lpEnvironment, LPCWSTR lpCurrentDirectory,
LPSTARTUPINFO32W lpStartupInfo,
LPPROCESS_INFORMATION lpProcessInfo )
{
FIXME(win32, "(%s,%s,...): stub\n", debugstr_w(lpApplicationName),
debugstr_w(lpCommandLine));
/* make from lcc uses system as fallback if CreateProcess returns
FALSE, so return false */
return FALSE;
}
/***********************************************************************
* GetModuleHandle (KERNEL32.237)
*/
HMODULE32 WINAPI GetModuleHandle32A(LPCSTR module)
{
if (module == NULL)
return PROCESS_Current()->exe_modref->module;
else
return MODULE_FindModule32(PROCESS_Current(),module);
}
HMODULE32 WINAPI GetModuleHandle32W(LPCWSTR module)
{
HMODULE32 hModule;
LPSTR modulea = HEAP_strdupWtoA( GetProcessHeap(), 0, module );
hModule = GetModuleHandle32A( modulea );
HeapFree( GetProcessHeap(), 0, modulea );
return hModule;
}
/***********************************************************************
* GetModuleFileName32A (KERNEL32.235)
*/
DWORD WINAPI GetModuleFileName32A(
HMODULE32 hModule, /* [in] module handle (32bit) */
LPSTR lpFileName, /* [out] filenamebuffer */
DWORD size /* [in] size of filenamebuffer */
) {
WINE_MODREF *wm = MODULE32_LookupHMODULE(PROCESS_Current(),hModule);
char *p;
if (!wm) /* can happen on start up or the like */
return 0;
/* FIXME: we should probably get a real long name, but wm->longname
* is currently a UNIX filename!
* Use the module name to at least get the long version of the filename.
*/
lstrcpyn32A( lpFileName, wm->shortname, size );
if ( (p = strrchr( lpFileName, '\\' )) ) {
p++;
size -= (p-lpFileName);
lstrcpyn32A( p, wm->modname, size);
}
TRACE(module, "%s\n", lpFileName );
return strlen(lpFileName);
}
/***********************************************************************
* GetModuleFileName32W (KERNEL32.236)
*/
DWORD WINAPI GetModuleFileName32W( HMODULE32 hModule, LPWSTR lpFileName,
DWORD size )
{
LPSTR fnA = (char*)HeapAlloc( GetProcessHeap(), 0, size );
DWORD res = GetModuleFileName32A( hModule, fnA, size );
lstrcpynAtoW( lpFileName, fnA, size );
HeapFree( GetProcessHeap(), 0, fnA );
return res;
}
/***********************************************************************
* LoadLibraryEx32W (KERNEL.513)
* FIXME
*/
HMODULE32 WINAPI LoadLibraryEx32W16( LPCSTR libname, HANDLE16 hf,
DWORD flags )
{
TRACE(module,"(%s,%d,%08lx)\n",libname,hf,flags);
return LoadLibraryEx32A(libname, hf,flags);
}
/***********************************************************************
* LoadLibraryEx32A (KERNEL32)
*/
HMODULE32 WINAPI LoadLibraryEx32A(LPCSTR libname,HFILE32 hfile,DWORD flags)
{
HMODULE32 hmod;
hmod = PE_LoadLibraryEx32A(libname,PROCESS_Current(),hfile,flags);
if (hmod < 32) {
char buffer[256];
strcpy( buffer, libname );
strcat( buffer, ".dll" );
hmod = PE_LoadLibraryEx32A(buffer,PROCESS_Current(),hfile,flags);
}
/* initialize all DLLs, which haven't been initialized yet. */
if (hmod >= 32)
PE_InitializeDLLs( PROCESS_Current(), DLL_PROCESS_ATTACH, NULL);
return hmod;
}
/***********************************************************************
* LoadLibraryA (KERNEL32)
*/
HMODULE32 WINAPI LoadLibrary32A(LPCSTR libname) {
return LoadLibraryEx32A(libname,0,0);
}
/***********************************************************************
* LoadLibraryW (KERNEL32)
*/
HMODULE32 WINAPI LoadLibrary32W(LPCWSTR libnameW)
{
return LoadLibraryEx32W(libnameW,0,0);
}
/***********************************************************************
* LoadLibraryExW (KERNEL32)
*/
HMODULE32 WINAPI LoadLibraryEx32W(LPCWSTR libnameW,HFILE32 hfile,DWORD flags)
{
LPSTR libnameA = HEAP_strdupWtoA( GetProcessHeap(), 0, libnameW );
HMODULE32 ret = LoadLibraryEx32A( libnameA , hfile, flags );
HeapFree( GetProcessHeap(), 0, libnameA );
return ret;
}
/***********************************************************************
* FreeLibrary
*/
BOOL32 WINAPI FreeLibrary32(HINSTANCE32 hLibModule)
{
FIXME(module,"(0x%08x): stub\n", hLibModule);
return TRUE; /* FIXME */
}
/***********************************************************************
* PrivateLoadLibrary (KERNEL32)
*
* FIXME: rough guesswork, don't know what "Private" means
*/
HINSTANCE32 WINAPI PrivateLoadLibrary(LPCSTR libname)
{
return (HINSTANCE32)LoadLibrary16(libname);
}
/***********************************************************************
* PrivateFreeLibrary (KERNEL32)
*
* FIXME: rough guesswork, don't know what "Private" means
*/
void WINAPI PrivateFreeLibrary(HINSTANCE32 handle)
{
FreeLibrary16((HINSTANCE16)handle);
}
/***********************************************************************
* WinExec16 (KERNEL.166)
*/
HINSTANCE16 WINAPI WinExec16( LPCSTR lpCmdLine, UINT16 nCmdShow )
{
return WinExec32( lpCmdLine, nCmdShow );
}
/***********************************************************************
* WinExec32 (KERNEL32.566)
*/
HINSTANCE32 WINAPI WinExec32( LPCSTR lpCmdLine, UINT32 nCmdShow )
{
HINSTANCE32 handle = 2;
char *p, filename[256];
static int use_load_module = 1;
int spacelimit = 0, exhausted = 0;
LOADPARAMS32 params;
UINT16 paramCmdShow[2];
if (!lpCmdLine)
return 2; /* File not found */
/* Set up LOADPARAMS32 buffer for LoadModule32 */
memset( &params, '\0', sizeof(params) );
params.lpCmdLine = (LPSTR)lpCmdLine;
params.lpCmdShow = paramCmdShow;
params.lpCmdShow[0] = 2;
params.lpCmdShow[1] = nCmdShow;
/* Keep trying to load a file by trying different filenames; e.g.,
for the cmdline "abcd efg hij", try "abcd" with args "efg hij",
then "abcd efg" with arg "hij", and finally "abcd efg hij" with
no args */
while(!exhausted && handle == 2) {
int spacecount = 0;
/* Build the filename and command-line */
lstrcpyn32A(filename, lpCmdLine,
sizeof(filename) - 4 /* for extension */);
/* Keep grabbing characters until end-of-string, tab, or until the
number of spaces is greater than the spacelimit */
for (p = filename; ; p++) {
if(*p == ' ') {
++spacecount;
if(spacecount > spacelimit) {
++spacelimit;
break;
}
}
if(*p == '\0' || *p == '\t') {
exhausted = 1;
break;
}
}
*p = '\0';
/* Now load the executable file */
if (use_load_module)
{
/* Winelib: Use LoadModule() only for the program itself */
if (__winelib) use_load_module = 0;
handle = LoadModule32( filename, &params );
if (handle == 2) /* file not found */
{
/* Check that the original file name did not have a suffix */
p = strrchr(filename, '.');
/* if there is a '.', check if either \ OR / follow */
if (!p || strchr(p, '/') || strchr(p, '\\'))
{
p = filename + strlen(filename);
strcpy( p, ".exe" );
handle = LoadModule32( filename, &params );
*p = '\0'; /* Remove extension */
}
}
}
else
handle = 2; /* file not found */
if (handle < 32)
{
/* Try to start it as a unix program */
if (!fork())
{
/* Child process */
DOS_FULL_NAME full_name;
const char *unixfilename = NULL;
const char *argv[256], **argptr;
int iconic = (nCmdShow == SW_SHOWMINIMIZED ||
nCmdShow == SW_SHOWMINNOACTIVE);
THREAD_InitDone = FALSE; /* we didn't init this process */
/* get unixfilename */
if (strchr(filename, '/') ||
strchr(filename, ':') ||
strchr(filename, '\\'))
{
if (DOSFS_GetFullName( filename, TRUE, &full_name ))
unixfilename = full_name.long_name;
}
else unixfilename = filename;
if (unixfilename)
{
/* build argv */
argptr = argv;
if (iconic) *argptr++ = "-iconic";
*argptr++ = unixfilename;
p = strdup(lpCmdLine);
while (1)
{
while (*p && (*p == ' ' || *p == '\t')) *p++ = '\0';
if (!*p) break;
*argptr++ = p;
while (*p && *p != ' ' && *p != '\t') p++;
}
*argptr++ = 0;
/* Execute */
execvp(argv[0], (char**)argv);
}
/* Failed ! */
if (__winelib)
{
/* build argv */
argptr = argv;
*argptr++ = "wine";
if (iconic) *argptr++ = "-iconic";
*argptr++ = lpCmdLine;
*argptr++ = 0;
/* Execute */
execvp(argv[0] , (char**)argv);
/* Failed ! */
MSG("WinExec: can't exec 'wine %s'\n",
lpCmdLine);
}
exit(1);
}
}
} /* while (!exhausted && handle < 32) */
return handle;
}
/***********************************************************************
* WIN32_GetProcAddress16 (KERNEL32.36)
* Get procaddress in 16bit module from win32... (kernel32 undoc. ordinal func)
*/
FARPROC16 WINAPI WIN32_GetProcAddress16( HMODULE32 hModule, LPCSTR name )
{
WORD ordinal;
FARPROC16 ret;
if (!hModule) {
WARN(module,"hModule may not be 0!\n");
return (FARPROC16)0;
}
if (HIWORD(hModule))
{
WARN( module, "hModule is Win32 handle (%08x)\n", hModule );
return (FARPROC16)0;
}
hModule = GetExePtr( hModule );
if (HIWORD(name)) {
ordinal = NE_GetOrdinal( hModule, name );
TRACE(module, "%04x '%s'\n",
hModule, name );
} else {
ordinal = LOWORD(name);
TRACE(module, "%04x %04x\n",
hModule, ordinal );
}
if (!ordinal) return (FARPROC16)0;
ret = NE_GetEntryPoint( hModule, ordinal );
TRACE(module,"returning %08x\n",(UINT32)ret);
return ret;
}
/***********************************************************************
* GetProcAddress16 (KERNEL.50)
*/
FARPROC16 WINAPI GetProcAddress16( HMODULE16 hModule, SEGPTR name )
{
WORD ordinal;
FARPROC16 ret;
if (!hModule) hModule = GetCurrentTask();
hModule = GetExePtr( hModule );
if (HIWORD(name) != 0)
{
ordinal = NE_GetOrdinal( hModule, (LPSTR)PTR_SEG_TO_LIN(name) );
TRACE(module, "%04x '%s'\n",
hModule, (LPSTR)PTR_SEG_TO_LIN(name) );
}
else
{
ordinal = LOWORD(name);
TRACE(module, "%04x %04x\n",
hModule, ordinal );
}
if (!ordinal) return (FARPROC16)0;
ret = NE_GetEntryPoint( hModule, ordinal );
TRACE(module, "returning %08x\n", (UINT32)ret );
return ret;
}
/***********************************************************************
* GetProcAddress32 (KERNEL32.257)
*/
FARPROC32 WINAPI GetProcAddress32( HMODULE32 hModule, LPCSTR function )
{
return MODULE_GetProcAddress32( PROCESS_Current(), hModule, function );
}
/***********************************************************************
* MODULE_GetProcAddress32 (internal)
*/
FARPROC32 MODULE_GetProcAddress32(
PDB32 *process, /* [in] process context */
HMODULE32 hModule, /* [in] current module handle */
LPCSTR function ) /* [in] function to be looked up */
{
WINE_MODREF *wm = MODULE32_LookupHMODULE(process,hModule);
if (HIWORD(function))
TRACE(win32,"(%08lx,%s)\n",(DWORD)hModule,function);
else
TRACE(win32,"(%08lx,%p)\n",(DWORD)hModule,function);
if (!wm)
return (FARPROC32)0;
switch (wm->type)
{
case MODULE32_PE:
return PE_FindExportedFunction( process, wm, function);
default:
ERR(module,"wine_modref type %d not handled.\n",wm->type);
return (FARPROC32)0;
}
}
/***********************************************************************
* RtlImageNtHeaders (NTDLL)
*/
LPIMAGE_NT_HEADERS WINAPI RtlImageNtHeader(HMODULE32 hModule)
{
/* basically:
* return hModule+(((IMAGE_DOS_HEADER*)hModule)->e_lfanew);
* but we could get HMODULE16 or the like (think builtin modules)
*/
WINE_MODREF *wm = MODULE32_LookupHMODULE( PROCESS_Current(), hModule );
if (!wm || (wm->type != MODULE32_PE)) return (LPIMAGE_NT_HEADERS)0;
return PE_HEADER(wm->module);
}
/***************************************************************************
* HasGPHandler (KERNEL.338)
*/
#pragma pack(1)
typedef struct _GPHANDLERDEF
{
WORD selector;
WORD rangeStart;
WORD rangeEnd;
WORD handler;
} GPHANDLERDEF;
#pragma pack(4)
SEGPTR WINAPI HasGPHandler( SEGPTR address )
{
HMODULE16 hModule;
SEGPTR gpPtr;
GPHANDLERDEF *gpHandler;
if ( (hModule = FarGetOwner( SELECTOROF(address) )) != 0
&& (gpPtr = (SEGPTR)WIN32_GetProcAddress16( hModule, "__GP" )) != 0
&& !IsBadReadPtr16( gpPtr, sizeof(GPHANDLERDEF) )
&& (gpHandler = PTR_SEG_TO_LIN( gpPtr )) != NULL )
{
while (gpHandler->selector)
{
if ( SELECTOROF(address) == gpHandler->selector
&& OFFSETOF(address) >= gpHandler->rangeStart
&& OFFSETOF(address) < gpHandler->rangeEnd )
return PTR_SEG_OFF_TO_SEGPTR( gpHandler->selector,
gpHandler->handler );
gpHandler++;
}
}
return 0;
}