Beginnings of a crt0 library.
diff --git a/configure b/configure index ef83746..81c95fa 100755 --- a/configure +++ b/configure
@@ -18341,7 +18341,7 @@ MAKE_PROG_RULES=programs/Makeprog.rules - ac_config_files="$ac_config_files Make.rules dlls/Makedll.rules dlls/Maketest.rules libs/Makelib.rules programs/Makeprog.rules Makefile dlls/Makefile dlls/activeds/Makefile dlls/advapi32/Makefile dlls/advapi32/tests/Makefile dlls/advpack/Makefile dlls/advpack/tests/Makefile dlls/amstream/Makefile dlls/atl/Makefile dlls/avicap32/Makefile dlls/avifil32/Makefile dlls/cabinet/Makefile dlls/capi2032/Makefile dlls/cards/Makefile dlls/cfgmgr32/Makefile dlls/comcat/Makefile dlls/comctl32/Makefile dlls/comctl32/tests/Makefile dlls/commdlg/Makefile dlls/crtdll/Makefile dlls/crypt32/Makefile dlls/crypt32/tests/Makefile dlls/cryptdll/Makefile dlls/ctl3d/Makefile dlls/d3d8/Makefile dlls/d3d9/Makefile dlls/d3dim/Makefile dlls/d3drm/Makefile dlls/d3dx8/Makefile dlls/d3dxof/Makefile dlls/dbghelp/Makefile dlls/dciman32/Makefile dlls/ddraw/Makefile dlls/ddraw/tests/Makefile dlls/devenum/Makefile dlls/dinput/Makefile dlls/dinput/tests/Makefile dlls/dinput8/Makefile dlls/dmband/Makefile dlls/dmcompos/Makefile dlls/dmime/Makefile dlls/dmloader/Makefile dlls/dmscript/Makefile dlls/dmstyle/Makefile dlls/dmsynth/Makefile dlls/dmusic/Makefile dlls/dmusic32/Makefile dlls/dplay/Makefile dlls/dplayx/Makefile dlls/dpnet/Makefile dlls/dpnhpast/Makefile dlls/dsound/Makefile dlls/dsound/tests/Makefile dlls/dswave/Makefile dlls/dxdiagn/Makefile dlls/dxerr8/Makefile dlls/dxerr9/Makefile dlls/dxguid/Makefile dlls/gdi/Makefile dlls/gdi/tests/Makefile dlls/glu32/Makefile dlls/glut32/Makefile dlls/hhctrl.ocx/Makefile dlls/iccvid/Makefile dlls/icmp/Makefile dlls/ifsmgr.vxd/Makefile dlls/imagehlp/Makefile dlls/imm32/Makefile dlls/iphlpapi/Makefile dlls/iphlpapi/tests/Makefile dlls/itss/Makefile dlls/kernel/Makefile dlls/kernel/tests/Makefile dlls/lzexpand/Makefile dlls/lzexpand/tests/Makefile dlls/mapi32/Makefile dlls/mapi32/tests/Makefile dlls/mciavi32/Makefile dlls/mcicda/Makefile dlls/mciseq/Makefile dlls/midimap/Makefile dlls/mlang/Makefile dlls/mlang/tests/Makefile dlls/mmdevldr.vxd/Makefile dlls/monodebg.vxd/Makefile dlls/mpr/Makefile dlls/msacm/Makefile dlls/msacm/imaadp32/Makefile dlls/msacm/msadp32/Makefile dlls/msacm/msg711/Makefile dlls/msacm/tests/Makefile dlls/msacm/winemp3/Makefile dlls/mscms/Makefile dlls/mscms/tests/Makefile dlls/msdmo/Makefile dlls/mshtml/Makefile dlls/mshtml/tests/Makefile dlls/msi/Makefile dlls/msi/tests/Makefile dlls/msimg32/Makefile dlls/msisys/Makefile dlls/msnet32/Makefile dlls/msrle32/Makefile dlls/msvcrt/Makefile dlls/msvcrt/tests/Makefile dlls/msvcrt20/Makefile dlls/msvcrt40/Makefile dlls/msvcrtd/Makefile dlls/msvcrtd/tests/Makefile dlls/msvidc32/Makefile dlls/msvideo/Makefile dlls/mswsock/Makefile dlls/msxml3/Makefile dlls/msxml3/tests/Makefile dlls/netapi32/Makefile dlls/netapi32/tests/Makefile dlls/newdev/Makefile dlls/ntdll/Makefile dlls/ntdll/tests/Makefile dlls/objsel/Makefile dlls/odbc32/Makefile dlls/odbccp32/Makefile dlls/ole32/Makefile dlls/ole32/tests/Makefile dlls/oleacc/Makefile dlls/oleaut32/Makefile dlls/oleaut32/tests/Makefile dlls/olecli/Makefile dlls/oledlg/Makefile dlls/olepro32/Makefile dlls/olesvr/Makefile dlls/opengl32/Makefile dlls/powrprof/Makefile dlls/psapi/Makefile dlls/psapi/tests/Makefile dlls/qcap/Makefile dlls/quartz/Makefile dlls/quartz/tests/Makefile dlls/rasapi32/Makefile dlls/riched20/Makefile dlls/richedit/Makefile dlls/rpcrt4/Makefile dlls/rpcrt4/tests/Makefile dlls/rsabase/Makefile dlls/rsabase/tests/Makefile dlls/rsaenh/Makefile dlls/rsaenh/tests/Makefile dlls/secur32/Makefile dlls/secur32/tests/Makefile dlls/sensapi/Makefile dlls/serialui/Makefile dlls/setupapi/Makefile dlls/shdocvw/Makefile dlls/shell32/Makefile dlls/shell32/tests/Makefile dlls/shfolder/Makefile dlls/shlwapi/Makefile dlls/shlwapi/tests/Makefile dlls/snmpapi/Makefile dlls/stdole2.tlb/Makefile dlls/stdole32.tlb/Makefile dlls/sti/Makefile dlls/strmiids/Makefile dlls/tapi32/Makefile dlls/ttydrv/Makefile dlls/twain/Makefile dlls/unicows/Makefile dlls/url/Makefile dlls/urlmon/Makefile dlls/urlmon/tests/Makefile dlls/user/Makefile dlls/user/tests/Makefile dlls/usp10/Makefile dlls/uuid/Makefile dlls/uxtheme/Makefile dlls/vdhcp.vxd/Makefile dlls/vdmdbg/Makefile dlls/version/Makefile dlls/version/tests/Makefile dlls/vmm.vxd/Makefile dlls/vnbt.vxd/Makefile dlls/vnetbios.vxd/Makefile dlls/vtdapi.vxd/Makefile dlls/vwin32.vxd/Makefile dlls/win32s/Makefile dlls/winaspi/Makefile dlls/wined3d/Makefile dlls/winedos/Makefile dlls/wineps/Makefile dlls/wininet/Makefile dlls/wininet/tests/Makefile dlls/winmm/Makefile dlls/winmm/joystick/Makefile dlls/winmm/mciwave/Makefile dlls/winmm/tests/Makefile dlls/winmm/wavemap/Makefile dlls/winmm/winealsa/Makefile dlls/winmm/winearts/Makefile dlls/winmm/wineaudioio/Makefile dlls/winmm/wineesd/Makefile dlls/winmm/winejack/Makefile dlls/winmm/winenas/Makefile dlls/winmm/wineoss/Makefile dlls/winnls/Makefile dlls/winsock/Makefile dlls/winsock/tests/Makefile dlls/winspool/Makefile dlls/winspool/tests/Makefile dlls/wintab32/Makefile dlls/wintrust/Makefile dlls/wldap32/Makefile dlls/wow32/Makefile dlls/wsock32/Makefile dlls/wtsapi32/Makefile dlls/x11drv/Makefile documentation/Makefile fonts/Makefile include/Makefile libs/Makefile libs/port/Makefile libs/unicode/Makefile libs/wine/Makefile libs/wpp/Makefile loader/Makefile programs/Makefile programs/avitools/Makefile programs/clock/Makefile programs/cmdlgtst/Makefile programs/control/Makefile programs/expand/Makefile programs/hh/Makefile programs/msiexec/Makefile programs/notepad/Makefile programs/progman/Makefile programs/regedit/Makefile programs/regsvr32/Makefile programs/rpcss/Makefile programs/rundll32/Makefile programs/start/Makefile programs/taskmgr/Makefile programs/uninstaller/Makefile programs/view/Makefile programs/wcmd/Makefile programs/wineboot/Makefile programs/winebrowser/Makefile programs/winecfg/Makefile programs/wineconsole/Makefile programs/winedbg/Makefile programs/winefile/Makefile programs/winemenubuilder/Makefile programs/winemine/Makefile programs/winepath/Makefile programs/winetest/Makefile programs/winevdm/Makefile programs/winhelp/Makefile programs/winver/Makefile server/Makefile tools/Makefile tools/widl/Makefile tools/winapi/Makefile tools/winebuild/Makefile tools/winedump/Makefile tools/winegcc/Makefile tools/wmc/Makefile tools/wrc/Makefile" + ac_config_files="$ac_config_files Make.rules dlls/Makedll.rules dlls/Maketest.rules libs/Makelib.rules programs/Makeprog.rules Makefile dlls/Makefile dlls/activeds/Makefile dlls/advapi32/Makefile dlls/advapi32/tests/Makefile dlls/advpack/Makefile dlls/advpack/tests/Makefile dlls/amstream/Makefile dlls/atl/Makefile dlls/avicap32/Makefile dlls/avifil32/Makefile dlls/cabinet/Makefile dlls/capi2032/Makefile dlls/cards/Makefile dlls/cfgmgr32/Makefile dlls/comcat/Makefile dlls/comctl32/Makefile dlls/comctl32/tests/Makefile dlls/commdlg/Makefile dlls/crtdll/Makefile dlls/crypt32/Makefile dlls/crypt32/tests/Makefile dlls/cryptdll/Makefile dlls/ctl3d/Makefile dlls/d3d8/Makefile dlls/d3d9/Makefile dlls/d3dim/Makefile dlls/d3drm/Makefile dlls/d3dx8/Makefile dlls/d3dxof/Makefile dlls/dbghelp/Makefile dlls/dciman32/Makefile dlls/ddraw/Makefile dlls/ddraw/tests/Makefile dlls/devenum/Makefile dlls/dinput/Makefile dlls/dinput/tests/Makefile dlls/dinput8/Makefile dlls/dmband/Makefile dlls/dmcompos/Makefile dlls/dmime/Makefile dlls/dmloader/Makefile dlls/dmscript/Makefile dlls/dmstyle/Makefile dlls/dmsynth/Makefile dlls/dmusic/Makefile dlls/dmusic32/Makefile dlls/dplay/Makefile dlls/dplayx/Makefile dlls/dpnet/Makefile dlls/dpnhpast/Makefile dlls/dsound/Makefile dlls/dsound/tests/Makefile dlls/dswave/Makefile dlls/dxdiagn/Makefile dlls/dxerr8/Makefile dlls/dxerr9/Makefile dlls/dxguid/Makefile dlls/gdi/Makefile dlls/gdi/tests/Makefile dlls/glu32/Makefile dlls/glut32/Makefile dlls/hhctrl.ocx/Makefile dlls/iccvid/Makefile dlls/icmp/Makefile dlls/ifsmgr.vxd/Makefile dlls/imagehlp/Makefile dlls/imm32/Makefile dlls/iphlpapi/Makefile dlls/iphlpapi/tests/Makefile dlls/itss/Makefile dlls/kernel/Makefile dlls/kernel/tests/Makefile dlls/lzexpand/Makefile dlls/lzexpand/tests/Makefile dlls/mapi32/Makefile dlls/mapi32/tests/Makefile dlls/mciavi32/Makefile dlls/mcicda/Makefile dlls/mciseq/Makefile dlls/midimap/Makefile dlls/mlang/Makefile dlls/mlang/tests/Makefile dlls/mmdevldr.vxd/Makefile dlls/monodebg.vxd/Makefile dlls/mpr/Makefile dlls/msacm/Makefile dlls/msacm/imaadp32/Makefile dlls/msacm/msadp32/Makefile dlls/msacm/msg711/Makefile dlls/msacm/tests/Makefile dlls/msacm/winemp3/Makefile dlls/mscms/Makefile dlls/mscms/tests/Makefile dlls/msdmo/Makefile dlls/mshtml/Makefile dlls/mshtml/tests/Makefile dlls/msi/Makefile dlls/msi/tests/Makefile dlls/msimg32/Makefile dlls/msisys/Makefile dlls/msnet32/Makefile dlls/msrle32/Makefile dlls/msvcrt/Makefile dlls/msvcrt/tests/Makefile dlls/msvcrt20/Makefile dlls/msvcrt40/Makefile dlls/msvcrtd/Makefile dlls/msvcrtd/tests/Makefile dlls/msvidc32/Makefile dlls/msvideo/Makefile dlls/mswsock/Makefile dlls/msxml3/Makefile dlls/msxml3/tests/Makefile dlls/netapi32/Makefile dlls/netapi32/tests/Makefile dlls/newdev/Makefile dlls/ntdll/Makefile dlls/ntdll/tests/Makefile dlls/objsel/Makefile dlls/odbc32/Makefile dlls/odbccp32/Makefile dlls/ole32/Makefile dlls/ole32/tests/Makefile dlls/oleacc/Makefile dlls/oleaut32/Makefile dlls/oleaut32/tests/Makefile dlls/olecli/Makefile dlls/oledlg/Makefile dlls/olepro32/Makefile dlls/olesvr/Makefile dlls/opengl32/Makefile dlls/powrprof/Makefile dlls/psapi/Makefile dlls/psapi/tests/Makefile dlls/qcap/Makefile dlls/quartz/Makefile dlls/quartz/tests/Makefile dlls/rasapi32/Makefile dlls/riched20/Makefile dlls/richedit/Makefile dlls/rpcrt4/Makefile dlls/rpcrt4/tests/Makefile dlls/rsabase/Makefile dlls/rsabase/tests/Makefile dlls/rsaenh/Makefile dlls/rsaenh/tests/Makefile dlls/secur32/Makefile dlls/secur32/tests/Makefile dlls/sensapi/Makefile dlls/serialui/Makefile dlls/setupapi/Makefile dlls/shdocvw/Makefile dlls/shell32/Makefile dlls/shell32/tests/Makefile dlls/shfolder/Makefile dlls/shlwapi/Makefile dlls/shlwapi/tests/Makefile dlls/snmpapi/Makefile dlls/stdole2.tlb/Makefile dlls/stdole32.tlb/Makefile dlls/sti/Makefile dlls/strmiids/Makefile dlls/tapi32/Makefile dlls/ttydrv/Makefile dlls/twain/Makefile dlls/unicows/Makefile dlls/url/Makefile dlls/urlmon/Makefile dlls/urlmon/tests/Makefile dlls/user/Makefile dlls/user/tests/Makefile dlls/usp10/Makefile dlls/uuid/Makefile dlls/uxtheme/Makefile dlls/vdhcp.vxd/Makefile dlls/vdmdbg/Makefile dlls/version/Makefile dlls/version/tests/Makefile dlls/vmm.vxd/Makefile dlls/vnbt.vxd/Makefile dlls/vnetbios.vxd/Makefile dlls/vtdapi.vxd/Makefile dlls/vwin32.vxd/Makefile dlls/win32s/Makefile dlls/winaspi/Makefile dlls/winecrt0/Makefile dlls/wined3d/Makefile dlls/winedos/Makefile dlls/wineps/Makefile dlls/wininet/Makefile dlls/wininet/tests/Makefile dlls/winmm/Makefile dlls/winmm/joystick/Makefile dlls/winmm/mciwave/Makefile dlls/winmm/tests/Makefile dlls/winmm/wavemap/Makefile dlls/winmm/winealsa/Makefile dlls/winmm/winearts/Makefile dlls/winmm/wineaudioio/Makefile dlls/winmm/wineesd/Makefile dlls/winmm/winejack/Makefile dlls/winmm/winenas/Makefile dlls/winmm/wineoss/Makefile dlls/winnls/Makefile dlls/winsock/Makefile dlls/winsock/tests/Makefile dlls/winspool/Makefile dlls/winspool/tests/Makefile dlls/wintab32/Makefile dlls/wintrust/Makefile dlls/wldap32/Makefile dlls/wow32/Makefile dlls/wsock32/Makefile dlls/wtsapi32/Makefile dlls/x11drv/Makefile documentation/Makefile fonts/Makefile include/Makefile libs/Makefile libs/port/Makefile libs/unicode/Makefile libs/wine/Makefile libs/wpp/Makefile loader/Makefile programs/Makefile programs/avitools/Makefile programs/clock/Makefile programs/cmdlgtst/Makefile programs/control/Makefile programs/expand/Makefile programs/hh/Makefile programs/msiexec/Makefile programs/notepad/Makefile programs/progman/Makefile programs/regedit/Makefile programs/regsvr32/Makefile programs/rpcss/Makefile programs/rundll32/Makefile programs/start/Makefile programs/taskmgr/Makefile programs/uninstaller/Makefile programs/view/Makefile programs/wcmd/Makefile programs/wineboot/Makefile programs/winebrowser/Makefile programs/winecfg/Makefile programs/wineconsole/Makefile programs/winedbg/Makefile programs/winefile/Makefile programs/winemenubuilder/Makefile programs/winemine/Makefile programs/winepath/Makefile programs/winetest/Makefile programs/winevdm/Makefile programs/winhelp/Makefile programs/winver/Makefile server/Makefile tools/Makefile tools/widl/Makefile tools/winapi/Makefile tools/winebuild/Makefile tools/winedump/Makefile tools/winegcc/Makefile tools/wmc/Makefile tools/wrc/Makefile" cat >confcache <<\_ACEOF @@ -19063,6 +19063,7 @@ "dlls/vwin32.vxd/Makefile" ) CONFIG_FILES="$CONFIG_FILES dlls/vwin32.vxd/Makefile" ;; "dlls/win32s/Makefile" ) CONFIG_FILES="$CONFIG_FILES dlls/win32s/Makefile" ;; "dlls/winaspi/Makefile" ) CONFIG_FILES="$CONFIG_FILES dlls/winaspi/Makefile" ;; + "dlls/winecrt0/Makefile" ) CONFIG_FILES="$CONFIG_FILES dlls/winecrt0/Makefile" ;; "dlls/wined3d/Makefile" ) CONFIG_FILES="$CONFIG_FILES dlls/wined3d/Makefile" ;; "dlls/winedos/Makefile" ) CONFIG_FILES="$CONFIG_FILES dlls/winedos/Makefile" ;; "dlls/wineps/Makefile" ) CONFIG_FILES="$CONFIG_FILES dlls/wineps/Makefile" ;;
diff --git a/configure.ac b/configure.ac index 13241c4..b7058c3 100644 --- a/configure.ac +++ b/configure.ac
@@ -1648,6 +1648,7 @@ dlls/vwin32.vxd/Makefile dlls/win32s/Makefile dlls/winaspi/Makefile +dlls/winecrt0/Makefile dlls/wined3d/Makefile dlls/winedos/Makefile dlls/wineps/Makefile
diff --git a/dlls/Makefile.in b/dlls/Makefile.in index b6a82b8..f1d8459 100644 --- a/dlls/Makefile.in +++ b/dlls/Makefile.in
@@ -191,6 +191,7 @@ opengl32 \ strmiids \ uuid \ + winecrt0 \ wined3d \ x11drv @@ -315,6 +316,7 @@ libdxguid.a \ libstrmiids.a \ libuuid.a \ + libwinecrt0.a \ lz32.dll.so \ mapi32.dll.so \ mciavi32.dll.so \ @@ -1046,6 +1048,9 @@ libuuid.a: uuid/libuuid.a $(RM) $@ && $(LN_S) uuid/libuuid.a $@ +libwinecrt0.a: winecrt0/libwinecrt0.a + $(RM) $@ && $(LN_S) winecrt0/libwinecrt0.a $@ + # Import libraries @@ -1071,7 +1076,8 @@ libdxerr9.a \ libdxguid.a \ libstrmiids.a \ - libuuid.a + libuuid.a \ + libwinecrt0.a IMPORT_LIBS = \ $(IMPORT_SYMLINKS) \ @@ -1750,6 +1756,7 @@ dxguid/libdxguid.a: dxguid strmiids/libstrmiids.a: strmiids uuid/libuuid.a: uuid +winecrt0/libwinecrt0.a: winecrt0 # Rules for auto documentation
diff --git a/dlls/winecrt0/.cvsignore b/dlls/winecrt0/.cvsignore new file mode 100644 index 0000000..f3c7a7c --- /dev/null +++ b/dlls/winecrt0/.cvsignore
@@ -0,0 +1 @@ +Makefile
diff --git a/dlls/winecrt0/Makefile.in b/dlls/winecrt0/Makefile.in new file mode 100644 index 0000000..d69f412 --- /dev/null +++ b/dlls/winecrt0/Makefile.in
@@ -0,0 +1,26 @@ +DLLDEFS = @DLLDEFS@ +DLLFLAGS = @DLLFLAGS@ +DEFS = -D__WINESRC__ $(DLLDEFS) +TOPSRCDIR = @top_srcdir@ +TOPOBJDIR = ../.. +SRCDIR = @srcdir@ +VPATH = @srcdir@ +MODULE = libwinecrt0.a + +C_SRCS = \ + dll_main.c \ + exe_main.c \ + exe_wmain.c + +all: $(MODULE) + +@MAKE_RULES@ + +$(MODULE): $(OBJS) Makefile.in + $(RM) $@ + $(AR) $@ $(OBJS) + $(RANLIB) $@ + +man doc-html doc-sgml: + +### Dependencies:
diff --git a/dlls/winecrt0/dll_main.c b/dlls/winecrt0/dll_main.c new file mode 100644 index 0000000..8d8db64 --- /dev/null +++ b/dlls/winecrt0/dll_main.c
@@ -0,0 +1,29 @@ +/* + * DllMain default entry point + * + * Copyright 2005 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include <stdarg.h> +#include "windef.h" +#include "winbase.h" + +BOOL WINAPI DllMain( HINSTANCE inst, DWORD reason, LPVOID reserved ) +{ + /* if (reason == DLL_PROCESS_ATTACH) DisableThreadLibraryCalls( inst ); */ + return TRUE; +}
diff --git a/dlls/winecrt0/exe_main.c b/dlls/winecrt0/exe_main.c new file mode 100644 index 0000000..4c77dd8 --- /dev/null +++ b/dlls/winecrt0/exe_main.c
@@ -0,0 +1,49 @@ +/* + * main default entry point for exe files + * + * Copyright 2005 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include <stdarg.h> +#include "windef.h" +#include "winbase.h" +#include "winuser.h" + +int main( int argc, char *argv[] ) +{ + STARTUPINFOA info; + char *cmdline = GetCommandLineA(); + int bcount = 0, in_quotes = 0; + + while (*cmdline) + { + if ((*cmdline == '\t' || *cmdline == ' ') && !in_quotes) break; + else if (*cmdline == '\\') bcount++; + else if (*cmdline == '\"') + { + if (!(bcount & 1)) in_quotes = !in_quotes; + bcount = 0; + } + else bcount = 0; + cmdline++; + } + while (*cmdline == '\t' || *cmdline == ' ') cmdline++; + + GetStartupInfoA( &info ); + if (!(info.dwFlags & STARTF_USESHOWWINDOW)) info.wShowWindow = SW_SHOWNORMAL; + return WinMain( GetModuleHandleA(0), 0, cmdline, info.wShowWindow ); +}
diff --git a/dlls/winecrt0/exe_wmain.c b/dlls/winecrt0/exe_wmain.c new file mode 100644 index 0000000..a8ae914 --- /dev/null +++ b/dlls/winecrt0/exe_wmain.c
@@ -0,0 +1,51 @@ +/* + * main default entry point for Unicode exe files + * + * Copyright 2005 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include <stdarg.h> +#include "windef.h" +#include "winbase.h" +#include "winuser.h" + +int WINAPI wWinMain(HINSTANCE,HINSTANCE,LPWSTR,int); + +int wmain( int argc, WCHAR *argv[] ) +{ + STARTUPINFOW info; + WCHAR *cmdline = GetCommandLineW(); + int bcount = 0, in_quotes = 0; + + while (*cmdline) + { + if ((*cmdline == '\t' || *cmdline == ' ') && !in_quotes) break; + else if (*cmdline == '\\') bcount++; + else if (*cmdline == '\"') + { + if (!(bcount & 1)) in_quotes = !in_quotes; + bcount = 0; + } + else bcount = 0; + cmdline++; + } + while (*cmdline == '\t' || *cmdline == ' ') cmdline++; + + GetStartupInfoW( &info ); + if (!(info.dwFlags & STARTF_USESHOWWINDOW)) info.wShowWindow = SW_SHOWNORMAL; + return wWinMain( GetModuleHandleW(0), 0, cmdline, info.wShowWindow ); +}
diff --git a/programs/uninstaller/Makefile.in b/programs/uninstaller/Makefile.in index f7a7403..c103300 100644 --- a/programs/uninstaller/Makefile.in +++ b/programs/uninstaller/Makefile.in
@@ -3,7 +3,7 @@ SRCDIR = @srcdir@ VPATH = @srcdir@ MODULE = uninstaller.exe -APPMODE = -mconsole +APPMODE = -mconsole -Wb,-e,wmain IMPORTS = shlwapi user32 gdi32 advapi32 kernel32 C_SRCS = \
diff --git a/programs/winepath/Makefile.in b/programs/winepath/Makefile.in index c094d2d..607dcc7 100644 --- a/programs/winepath/Makefile.in +++ b/programs/winepath/Makefile.in
@@ -3,7 +3,7 @@ SRCDIR = @srcdir@ VPATH = @srcdir@ MODULE = winepath.exe -APPMODE = -mconsole +APPMODE = -mconsole -Wb,-e,wmain IMPORTS = kernel32 C_SRCS = winepath.c
diff --git a/tools/winebuild/build.h b/tools/winebuild/build.h index c1c2fa5..73effae 100644 --- a/tools/winebuild/build.h +++ b/tools/winebuild/build.h
@@ -191,7 +191,7 @@ extern void add_delayed_import( const char *name ); extern void add_ignore_symbol( const char *name ); extern void add_extra_ld_symbol( const char *name ); -extern void read_undef_symbols( char **argv ); +extern void read_undef_symbols( DLLSPEC *spec, char **argv ); extern int resolve_imports( DLLSPEC *spec ); extern int output_imports( FILE *outfile, DLLSPEC *spec, int *nb_delayed ); extern void output_import_thunks( FILE *outfile, DLLSPEC *spec );
diff --git a/tools/winebuild/import.c b/tools/winebuild/import.c index f08551b..b04be4b 100644 --- a/tools/winebuild/import.c +++ b/tools/winebuild/import.c
@@ -585,7 +585,7 @@ } /* read in the list of undefined symbols */ -void read_undef_symbols( char **argv ) +void read_undef_symbols( DLLSPEC *spec, char **argv ) { size_t prefix_len; FILE *f; @@ -595,12 +595,15 @@ if (!argv[0]) return; + if (spec->init_func) add_extra_ld_symbol( spec->init_func ); + else if (spec->characteristics & IMAGE_FILE_DLL) add_extra_ld_symbol( "DllMain" ); + else if (spec->subsystem == IMAGE_SUBSYSTEM_NATIVE) add_extra_ld_symbol( "DriverEntry "); + else add_extra_ld_symbol( "main" ); + strcpy( name_prefix, asm_name("") ); prefix_len = strlen( name_prefix ); - /* if we have multiple object files, link them together */ - if (argv[1]) name = ldcombine_files( argv ); - else name = argv[0]; + name = ldcombine_files( argv ); if (!nm_command) nm_command = xstrdup("nm"); cmd = xmalloc( strlen(nm_command) + strlen(name) + 5 );
diff --git a/tools/winebuild/main.c b/tools/winebuild/main.c index 6024215..50d8715 100644 --- a/tools/winebuild/main.c +++ b/tools/winebuild/main.c
@@ -568,7 +568,7 @@ BuildSpec16File( output_file, spec ); break; case SPEC_WIN32: - read_undef_symbols( argv ); + read_undef_symbols( spec, argv ); BuildSpec32File( output_file, spec ); break; default: assert(0); @@ -580,7 +580,7 @@ load_resources( argv, spec ); load_import_libs( argv ); if (spec_file_name && !parse_input_file( spec )) break; - read_undef_symbols( argv ); + read_undef_symbols( spec, argv ); BuildSpec32File( output_file, spec ); break; case MODE_DEF:
diff --git a/tools/winebuild/spec32.c b/tools/winebuild/spec32.c index 2bb8edb..50746d4 100644 --- a/tools/winebuild/spec32.c +++ b/tools/winebuild/spec32.c
@@ -65,30 +65,6 @@ return buffer; } -/******************************************************************* - * declare_weak_function - * - * Output a prototype for a weak function. - */ -static void declare_weak_function( FILE *outfile, const char *ret_type, const char *name, const char *params) -{ - fprintf( outfile, "#ifdef __GNUC__\n" ); - if (target_platform == PLATFORM_APPLE) - { - fprintf( outfile, "extern %s %s(%s) __attribute__((weak_import));\n", ret_type, name, params ); - fprintf( outfile, "static %s (*__wine_spec_weak_%s)(%s) = %s;\n", ret_type, name, params, name ); - fprintf( outfile, "#define %s __wine_spec_weak_%s\n", name, name ); - fprintf( outfile, "asm(\".weak_reference %s\");\n", asm_name(name) ); - } - else fprintf( outfile, "extern %s %s(%s) __attribute__((weak));\n", ret_type, name, params ); - - fprintf( outfile, "#else\n" ); - fprintf( outfile, "extern %s %s(%s);\n", ret_type, name, params ); - fprintf( outfile, "static void __asm__dummy_%s(void)", name ); - fprintf( outfile, " { asm(\".weak %s\"); }\n", asm_name(name) ); - fprintf( outfile, "#endif\n\n" ); -} - /******************************************************************* * output_debug @@ -541,7 +517,6 @@ fprintf( outfile, "extern int __wine_main_argc;\n" ); fprintf( outfile, "extern char **__wine_main_argv;\n" ); fprintf( outfile, "extern char **__wine_main_environ;\n" ); - fprintf( outfile, "extern unsigned short **__wine_main_wargv;\n" ); if (target_platform == PLATFORM_APPLE) { fprintf( outfile, "extern _dyld_func_lookup(char *, void *);" ); @@ -568,22 +543,17 @@ if (spec->characteristics & IMAGE_FILE_DLL) { - if (init_func) - fprintf( outfile, "extern int __stdcall %s( void*, unsigned int, void* );\n\n", init_func ); - else - { - declare_weak_function( outfile, "int __stdcall", "DllMain", "void*, unsigned int, void*" ); - init_func = "DllMain"; - } + if (!init_func) init_func = "DllMain"; + fprintf( outfile, "extern int __stdcall %s( void*, unsigned int, void* );\n\n", init_func ); fprintf( outfile, "static int __stdcall __wine_dll_main( void *inst, unsigned int reason, void *reserved )\n" "{\n" " int ret;\n" " if (reason == %d && __wine_spec_init_state == 1)\n" " _init( __wine_main_argc, __wine_main_argv, __wine_main_environ );\n" - " ret = %s ? %s( inst, reason, reserved ) : 1;\n" + " ret = %s( inst, reason, reserved );\n" " if (reason == %d && __wine_spec_init_state == 1)\n", - DLL_PROCESS_ATTACH, init_func, init_func, DLL_PROCESS_DETACH ); + DLL_PROCESS_ATTACH, init_func, DLL_PROCESS_DETACH ); if (!nr_delayed) fprintf( outfile, " _fini();\n" ); else @@ -601,85 +571,54 @@ else switch(spec->subsystem) { case IMAGE_SUBSYSTEM_NATIVE: - if (init_func) - fprintf( outfile, "extern int __stdcall %s( void*, void* );\n\n", init_func ); - else - { - declare_weak_function( outfile, "int __stdcall", "DriverEntry", "void*, void*"); - init_func = "DriverEntry"; - } + if (!init_func) init_func = "DriverEntry"; + fprintf( outfile, "extern int __stdcall %s( void*, void* );\n\n", init_func ); fprintf( outfile, "static int __stdcall __wine_driver_entry( void *obj, void *path )\n" "{\n" " int ret;\n" " if (__wine_spec_init_state == 1)\n" " _init( __wine_main_argc, __wine_main_argv, __wine_main_environ );\n" - " ret = %s ? %s( obj, path ) : 0;\n" + " ret = %s( obj, path );\n" " if (__wine_spec_init_state == 1) _fini();\n" " return ret;\n" "}\n", - init_func, init_func ); + init_func ); init_func = "__wine_driver_entry"; break; case IMAGE_SUBSYSTEM_WINDOWS_GUI: case IMAGE_SUBSYSTEM_WINDOWS_CUI: - if (init_func) - fprintf( outfile, "extern int %s( int argc, char *argv[] );\n", init_func ); - else + if (!init_func) init_func = "main"; + else if (!strcmp( init_func, "wmain" )) /* FIXME: temp hack for crt0 support */ { - declare_weak_function( outfile, "int", "main", "int argc, char *argv[]" ); - declare_weak_function( outfile, "int", "wmain", "int argc, unsigned short *argv[]" ); - declare_weak_function( outfile, "int __stdcall", "WinMain", "void *,void *,char *,int" ); + fprintf( outfile, "extern int wmain( int argc, unsigned short *argv[] );\n" ); + fprintf( outfile, "extern unsigned short **__wine_main_wargv;\n" ); + fprintf( outfile, + "\nextern void __stdcall ExitProcess(unsigned int);\n" + "static void __wine_exe_wmain(void)\n" + "{\n" + " int ret;\n" + " if (__wine_spec_init_state == 1)\n" + " _init( __wine_main_argc, __wine_main_argv, __wine_main_environ );\n" + " ret = wmain( __wine_main_argc, __wine_main_wargv );\n" + " if (__wine_spec_init_state == 1) _fini();\n" + " ExitProcess( ret );\n" + "}\n\n" ); + init_func = "__wine_exe_wmain"; + break; } + fprintf( outfile, "extern int %s( int argc, char *argv[] );\n", init_func ); fprintf( outfile, - "\ntypedef struct {\n" - " unsigned int cb;\n" - " char *lpReserved, *lpDesktop, *lpTitle;\n" - " unsigned int dwX, dwY, dwXSize, dwYSize;\n" - " unsigned int dwXCountChars, dwYCountChars, dwFillAttribute, dwFlags;\n" - " unsigned short wShowWindow, cbReserved2;\n" - " char *lpReserved2;\n" - " void *hStdInput, *hStdOutput, *hStdError;\n" - "} STARTUPINFOA;\n" - "extern char * __stdcall GetCommandLineA(void);\n" - "extern void * __stdcall GetModuleHandleA(char *);\n" - "extern void __stdcall GetStartupInfoA(STARTUPINFOA *);\n" - "extern void __stdcall ExitProcess(unsigned int);\n" + "\nextern void __stdcall ExitProcess(unsigned int);\n" "static void __wine_exe_main(void)\n" "{\n" " int ret;\n" " if (__wine_spec_init_state == 1)\n" - " _init( __wine_main_argc, __wine_main_argv, __wine_main_environ );\n" ); - if (init_func) - fprintf( outfile, - " ret = %s( __wine_main_argc, __wine_main_argv );\n", init_func ); - else - fprintf( outfile, - " if (WinMain) {\n" - " STARTUPINFOA info;\n" - " char *cmdline = GetCommandLineA();\n" - " int bcount=0, in_quotes=0;\n" - " while (*cmdline) {\n" - " if ((*cmdline=='\\t' || *cmdline==' ') && !in_quotes) break;\n" - " else if (*cmdline=='\\\\') bcount++;\n" - " else if (*cmdline=='\\\"') {\n" - " if ((bcount & 1)==0) in_quotes=!in_quotes;\n" - " bcount=0;\n" - " }\n" - " else bcount=0;\n" - " cmdline++;\n" - " }\n" - " while (*cmdline=='\\t' || *cmdline==' ') cmdline++;\n" - " GetStartupInfoA( &info );\n" - " if (!(info.dwFlags & 1)) info.wShowWindow = 1;\n" - " ret = WinMain( GetModuleHandleA(0), 0, cmdline, info.wShowWindow );\n" - " }\n" - " else if (wmain) ret = wmain( __wine_main_argc, __wine_main_wargv );\n" - " else ret = main( __wine_main_argc, __wine_main_argv );\n" ); - fprintf( outfile, + " _init( __wine_main_argc, __wine_main_argv, __wine_main_environ );\n" + " ret = %s( __wine_main_argc, __wine_main_argv );\n" " if (__wine_spec_init_state == 1) _fini();\n" " ExitProcess( ret );\n" - "}\n\n" ); + "}\n\n", init_func ); init_func = "__wine_exe_main"; break; }
diff --git a/tools/winegcc/winegcc.c b/tools/winegcc/winegcc.c index 4e758c3..bc9d73f 100644 --- a/tools/winegcc/winegcc.c +++ b/tools/winegcc/winegcc.c
@@ -149,6 +149,7 @@ int use_msvcrt; int nostdinc; int nostdlib; + int nostartfiles; int nodefaultlibs; int noshortwchar; int gui_app; @@ -528,6 +529,14 @@ strarray_add(files, "-dkernel32"); } + if (!opts->nostartfiles) + { + char *fullname = NULL; + if (get_lib_type(lib_dirs, "winecrt0", &fullname) == file_arh) + strarray_add(files, strmake("-a%s", fullname)); + free( fullname ); + } + /* run winebuild to generate the .spec.c file */ spec_args = strarray_alloc(); spec_c_name = get_temp_file(output_name, ".spec.c"); @@ -888,6 +897,8 @@ opts.nodefaultlibs = 1; else if (strcmp("-nostdlib", argv[i]) == 0) opts.nostdlib = 1; + else if (strcmp("-nostartfiles", argv[i]) == 0) + opts.nostartfiles = 1; break; case 'o': opts.output_name = option_arg;