[Mono-winforms-list] When will winforms be working?

Peter Dennis Bartok peter@novonyx.com
Wed, 18 Feb 2004 22:15:24 -0700


Vlad, please have a look at the patch I attached to my earlier message.

I did not pick/patch a particular part of wine, I simply prevented wine
from running WinMain and instead it returns control to the app that called
wine_init. To take care of initialization without having to plow through
too much code I created a winelib binary that is used for a)
initialization of wine itself (passed to wine_init as argument) and b) to
actually do the initialization of wine (by calling wine_init)

I have not done extensive tests yet, but it seems to work. The advantage
is that I don't need to specifically recompile wine as a shared library;
it inherently is a shared library and this patch allows me to use it as
such. The same wine code will allow to run regular apps and mono.

I tried to coordinate with you, but by the time I got your first response
the patch was already finished; also tried your ICQ address, but you never
added me to your contact list.

Cheers,
  Peter



-----Original Message-----
From: "Vlad kaluzhny" <vkaluzhny@openlinksw.co.uk>
To: "Peter Dennis Bartok" <peter@novonyx.com>
Cc: "M. Scott Ford" <vaderpi@scottandlaurie.com>; "'Miguel de Icaza'"
<miguel@ximian.com>; <mono-winforms-list@lists.ximian.com>
Date: 18 February, 2004 22:05
Subject: Re: [Mono-winforms-list] When will winforms be working?


Hi All.

Peter  It  definitely is not clear to me - which part of Wine are  you
patching?
And second - lets coordinate our efforts in patches writing,
otherwise we will duplicate  our work

I have already patched ntdll.dll and now working on kernel32.dll.......

Regards, Vlad

Peter Dennis Bartok wrote:

> Hi All,
>
> Sorry for having been so quiet. I was hoping I'd get all the changes
> done and could just present a 'complete solution'. But I'm not quite
> there yet.
>
> The first patch is in CVS already, it's located under
> mcs/class/System.Windows.Forms/wine-patch
>
> I've also attached the patch and a readme.
>
> Keep in mind that it's not complete yet. The patches will allow you to
> use Wine as a shared library. Unlike the previous patch, where wine
> itself was hacked up to be compiled either the traditional way or as a
> shared library I tried to have a patch that could make it back to the
> main wine repository. So the only actual changes to wine itself was
> that I prevent wine from calling the WinMain of a passed-in winelib
> executable, if the name of the executable is 'mono-winelib'.
>
> Everything else is handled in the mono-winelib executable. It acts as
> a winelib binary as well as the library that gets loaded to initialize
> wine as a shared library. Simply dlopen() and import the
> MonoWineInit() function and run it. That function in turn will
> initialize wine and then return. At that point any caller should be
> able to import and use any symbols/functions from wine.
>
> Keep in mind that I have done only minimal testing with the approach
> so far, since I still need to develop a second patch, to make the
> x11drv coexist with cairo. It seems that there's some offscreen
> caching happening in cairo and when wine draws on the screen cairo
> isn't aware and 'overwrites' the wine changes. I'm still in the
> process of debugging the issues, give me a few days more on that.
>
> Check the readme that goes along with the patch for some symbolic
> links that have to be created manually currently before the wine patch
> can be used.
>
> I have also attached a patch that's not in CVS yet (mcs-0.30.patch)
> which fixes up SWF to properly load the new wine library. Pathnames
> are currently fixed to /usr/local/lib/wine. Once the hard problems are
> worked out I'll take care of these things.
>
> Hope this wasn't too much detail. Please send me any feedback you may
> have, but keep in mind that SWF (while it may start displaying windows
> again) will still not work properly due to the cairo/x11drv issue (and
> potentially some of the new work done in System.Drawing)
>
> I'm also working on a roadmap for SWF itself, so that we can
> coordinate work on the library, but I figure the basic framework
> (Wine/Cairo/SWF) needs to be in working order first.
>
>
> Cheers,
>  Peter
>
>
>
> M. Scott Ford wrote:
>
>> Miguel,
>>
>> Thanks for the update. I remember seeing the Cairo/GDI+ conversation,
>> but I
>> had no idea that it had led to so many cool changes. WINE as a
>> library will
>> be great! Please let us know as soon as the changes are committed. I am
>> eager to start working. :)
>>
>> Are there any other lists that we should be watching to keep up with
the
>> news?
>>
>> Thanks,
>> -Scott
>>
>> -----Original Message-----
>> From: mono-winforms-list-admin@lists.ximian.com
>> [mailto:mono-winforms-list-admin@lists.ximian.com] On Behalf Of
>> Miguel de
>> Icaza
>> Sent: Wednesday, February 18, 2004 12:14 AM
>> To: Scott Ford
>> Cc: mono-winforms-list@lists.ximian.com
>> Subject: RE: [Mono-winforms-list] When will winforms be working?
>>
>> Hello,
>>
>>
>>> What are the problems? I have not really seen mention of any in this
>>> list. If they are being discussed, where is the discussion taking
>>> place?
>>> I am sure that many of us are willing to help, but have no idea what
is
>>> going on.
>>
>>
>>
>> The short answer is "soon".  The long answer is:
>>
>> * When Peter was fixing the Wine/Cairo integration issues, he found
>>   a way of doing this cleanly: to build a driver that knows about
>>   Cairo/GDI+.
>>
>> * When he started writing the driver, we noticed that our patches Wine
>>   was too old, and that the code we wrote would have to be discarded
>>   when we upgraded to Wine.  So...
>>
>> * Peter started working on porting/patching the latest Wine to work
>> as   a library.  Peter noticed that the new Wine requires even less
>> changes
>>   to turn into a library and found a fairly clever way of even being
>> able
>>   to turn Wine into a library and minimizing the changes.
>>   These are good news, because we might be able to merge the few
changes
>>   into the main Wine.
>>
>> * We will be building packages of the modified Wine very soon now ;-)
>>
>> * Work on the C#-side of Windows.Forms will resume in a couple of days.
>>
>> Miguel.
>> _______________________________________________
>> Mono-winforms-list maillist  -  Mono-winforms-list@lists.ximian.com
>> http://lists.ximian.com/mailman/listinfo/mono-winforms-list
>>
>>
>> _______________________________________________
>> Mono-winforms-list maillist  -  Mono-winforms-list@lists.ximian.com
>> http://lists.ximian.com/mailman/listinfo/mono-winforms-list
>>
>------------------------------------------------------------------------
>
>diff -ruN wine-20040121/configure wine-20040121-mono/configure
>--- wine-20040121/configure 2004-01-21 18:02:29.000000000 -0700
>+++ wine-20040121-mono/configure 2004-02-12 14:33:46.000000000 -0700
>@@ -19070,7 +19070,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/advapi32/Makefile dlls/advapi32/tests/Makefile
dlls/avicap32/Makefile dlls/avifil32/Makefile dlls/cabinet/Makefile
dlls/capi2032/Makefile dlls/cfgmgr32/Makefile dlls/comcat/Makefile
dlls/comctl32/Makefile dlls/comctl32/tests/Makefile dlls/commdlg/Makefile
dlls/crtdll/Makefile dlls/crypt32/Makefile dlls/ctl3d/Makefile
dlls/wined3d/Makefile dlls/d3d8/Makefile dlls/d3d9/Makefile
dlls/d3dim/Makefile dlls/d3dx8/Makefile dlls/dciman32/Makefile
dlls/ddraw/Makefile dlls/ddraw/tests/Makefile dlls/devenum/Makefile
dlls/dinput/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/dpnhpast/Makefile dlls/dsound/Makefile
dlls/dsound/tests/Makefile dlls/dswave/Makefile dlls/gdi/Makefile
dlls/gdi/tests/Makefile dlls/glu32/Makefile dlls/glut32/Makefile
dlls/iccvid/Makefile dlls/icmp/Makefile dlls/imagehlp/Makefile
dlls/imm32/Makefile dlls/iphlpapi/Makefile dlls/iphlpapi/tests/Makefile
dlls/kernel/Makefile dlls/kernel/tests/Makefile dlls/lzexpand/Makefile
dlls/mapi32/Makefile dlls/mpr/Makefile dlls/msacm/Makefile
dlls/msacm/imaadp32/Makefile dlls/msacm/msadp32/Makefile
dlls/msacm/msg711/Makefile dlls/msacm/winemp3/Makefile dlls/msdmo/Makefile
dlls/mshtml/Makefile dlls/msi/Makefile dlls/msimg32/Makefile
dlls/msisys/Makefile dlls/msnet32/Makefile dlls/msvcrt/Makefile
dlls/msvcrt/tests/Makefile dlls/msvcrt20/Makefile dlls/msvcrt40/Makefile
dlls/msvcrtd/Makefile dlls/msvideo/Makefile dlls/msvideo/msrle32/Makefile
dlls/mswsock/Makefile dlls/netapi32/Makefile dlls/netapi32/tests/Makefile
dlls/newdev/Makefile dlls/ntdll/Makefile dlls/ntdll/tests/Makefile
dlls/odbc32/Makefile dlls/ole32/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/psapi/Makefile dlls/qcap/Makefile
dlls/quartz/Makefile dlls/rasapi32/Makefile dlls/richedit/Makefile
dlls/rpcrt4/Makefile dlls/rpcrt4/tests/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/sti/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/uxtheme/Makefile dlls/version/Makefile dlls/win32s/Makefile
dlls/winaspi/Makefile dlls/winedos/Makefile dlls/wineps/Makefile
dlls/wininet/Makefile dlls/wininet/tests/Makefile dlls/winmm/Makefile
dlls/winmm/joystick/Makefile dlls/winmm/mcianim/Makefile
dlls/winmm/mciavi/Makefile dlls/winmm/mcicda/Makefile
dlls/winmm/mciseq/Makefile dlls/winmm/mciwave/Makefile
dlls/winmm/midimap/Makefile dlls/winmm/tests/Makefile
dlls/winmm/wavemap/Makefile dlls/winmm/winealsa/Makefile
dlls/winmm/winearts/Makefile dlls/winmm/wineaudioio/Makefile
dlls/winmm/winenas/Makefile dlls/winmm/winejack/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/wow32/Makefile dlls/wsock32/Makefile dlls/x11drv/Makefile
documentation/Makefile include/Makefile libs/Makefile libs/port/Makefile
libs/unicode/Makefile libs/uuid/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/notepad/Makefile
programs/progman/Makefile programs/regedit/Makefile
programs/regsvr32/Makefile programs/rpcss/Makefile
programs/rundll32/Makefile programs/start/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/advapi32/Makefile dlls/advapi32/tests/Makefile
dlls/avicap32/Makefile dlls/avifil32/Makefile dlls/cabinet/Makefile
dlls/capi2032/Makefile dlls/cfgmgr32/Makefile dlls/comcat/Makefile
dlls/comctl32/Makefile dlls/comctl32/tests/Makefile dlls/commdlg/Makefile
dlls/crtdll/Makefile dlls/crypt32/Makefile dlls/ctl3d/Makefile
dlls/wined3d/Makefile dlls/d3d8/Makefile dlls/d3d9/Makefile
dlls/d3dim/Makefile dlls/d3dx8/Makefile dlls/dciman32/Makefile
dlls/ddraw/Makefile dlls/ddraw/tests/Makefile dlls/devenum/Makefile
dlls/dinput/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/dpnhpast/Makefile dlls/dsound/Makefile
dlls/dsound/tests/Makefile dlls/dswave/Makefile dlls/gdi/Makefile
dlls/gdi/tests/Makefile dlls/glu32/Makefile dlls/glut32/Makefile
dlls/iccvid/Makefile dlls/icmp/Makefile dlls/imagehlp/Makefile
dlls/imm32/Makefile dlls/iphlpapi/Makefile dlls/iphlpapi/tests/Makefile
dlls/kernel/Makefile dlls/kernel/tests/Makefile dlls/lzexpand/Makefile
dlls/mapi32/Makefile dlls/mpr/Makefile dlls/msacm/Makefile
dlls/msacm/imaadp32/Makefile dlls/msacm/msadp32/Makefile
dlls/msacm/msg711/Makefile dlls/msacm/winemp3/Makefile dlls/msdmo/Makefile
dlls/mshtml/Makefile dlls/msi/Makefile dlls/msimg32/Makefile
dlls/msisys/Makefile dlls/msnet32/Makefile dlls/msvcrt/Makefile
dlls/msvcrt/tests/Makefile dlls/msvcrt20/Makefile dlls/msvcrt40/Makefile
dlls/msvcrtd/Makefile dlls/msvideo/Makefile dlls/msvideo/msrle32/Makefile
dlls/mswsock/Makefile dlls/netapi32/Makefile dlls/netapi32/tests/Makefile
dlls/newdev/Makefile dlls/ntdll/Makefile dlls/ntdll/tests/Makefile
dlls/odbc32/Makefile dlls/ole32/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/psapi/Makefile dlls/qcap/Makefile
dlls/quartz/Makefile dlls/rasapi32/Makefile dlls/richedit/Makefile
dlls/rpcrt4/Makefile dlls/rpcrt4/tests/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/sti/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/uxtheme/Makefile dlls/version/Makefile dlls/win32s/Makefile
dlls/winaspi/Makefile dlls/winedos/Makefile dlls/wineps/Makefile
dlls/wininet/Makefile dlls/wininet/tests/Makefile dlls/winmm/Makefile
dlls/winmm/joystick/Makefile dlls/winmm/mcianim/Makefile
dlls/winmm/mciavi/Makefile dlls/winmm/mcicda/Makefile
dlls/winmm/mciseq/Makefile dlls/winmm/mciwave/Makefile
dlls/winmm/midimap/Makefile dlls/winmm/tests/Makefile
dlls/winmm/wavemap/Makefile dlls/winmm/winealsa/Makefile
dlls/winmm/winearts/Makefile dlls/winmm/wineaudioio/Makefile
dlls/winmm/winenas/Makefile dlls/winmm/winejack/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/wow32/Makefile dlls/wsock32/Makefile dlls/x11drv/Makefile
documentation/Makefile include/Makefile libs/Makefile libs/port/Makefile
libs/unicode/Makefile libs/uuid/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/mono-winelib/Makefile
programs/notepad/Makefile programs/progman/Makefile
programs/regedit/Makefile programs/regsvr32/Makefile
programs/rpcss/Makefile programs/rundll32/Makefile programs/start/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
>@@ -19772,6 +19772,7 @@
>   "programs/cmdlgtst/Makefile" ) CONFIG_FILES="$CONFIG_FILES
programs/cmdlgtst/Makefile" ;;
>   "programs/control/Makefile" ) CONFIG_FILES="$CONFIG_FILES
programs/control/Makefile" ;;
>   "programs/expand/Makefile" ) CONFIG_FILES="$CONFIG_FILES
programs/expand/Makefile" ;;
>+  "programs/mono-winelib/Makefile" ) CONFIG_FILES="$CONFIG_FILES
programs/mono-winelib/Makefile" ;;
>   "programs/notepad/Makefile" ) CONFIG_FILES="$CONFIG_FILES
programs/notepad/Makefile" ;;
>   "programs/progman/Makefile" ) CONFIG_FILES="$CONFIG_FILES
programs/progman/Makefile" ;;
>   "programs/regedit/Makefile" ) CONFIG_FILES="$CONFIG_FILES
programs/regedit/Makefile" ;;
>diff -ruN wine-20040121/dlls/kernel/process.c
wine-20040121-mono/dlls/kernel/process.c
>--- wine-20040121/dlls/kernel/process.c 2004-01-20
14:51:27.000000000 -0700
>+++ wine-20040121-mono/dlls/kernel/process.c 2004-02-13
15:14:40.000000000 -0700
>@@ -752,8 +752,12 @@
>
>         SetLastError( 0 );  /* clear error code */
>         if (peb->BeingDebugged) DbgBreakPoint();
>-        ExitProcess( entry( peb ) );
>+        if (__wine_main_argc!=1 || !(__wine_main_argc==1 &&
strlen(__wine_main_argv[0])>=19 &&
strncasecmp(__wine_main_argv[0]+strlen(__wine_main_argv[0])-19,
"mono-winelib.exe.so", 19)==0)) {
>+            // This starts the main app and then exits wine
>+            ExitProcess( entry( peb ) );
>+        }
>     }
>+
>     __EXCEPT(UnhandledExceptionFilter)
>     {
>         TerminateThread( GetCurrentThread(), GetExceptionCode() );
>@@ -897,7 +901,16 @@
>     if (!THREAD_InitStack( NtCurrentTeb(), stack_size )) goto error;
>
>     /* switch to the new stack */
>-    wine_switch_to_stack( start_process, NULL,
NtCurrentTeb()->Tib.StackBase );
>+
>+    if (__wine_main_argc==1 && strlen(__wine_main_argv[0])>=19 &&
strncasecmp(__wine_main_argv[0]+strlen(__wine_main_argv[0])-19,
"mono-winelib.exe.so", 19)==0) {
>+        /* We don't want a new stack. Screws up our return path */
>+        start_process(NULL);
>+    } else {
>+        /* Regular wine startup */
>+        wine_switch_to_stack( start_process, NULL,
NtCurrentTeb()->Tib.StackBase );
>+    }
>+    return;
>+
>
>  error:
>     ExitProcess( GetLastError() );
>diff -ruN wine-20040121/dlls/ntdll/loader.c
wine-20040121-mono/dlls/ntdll/loader.c
>--- wine-20040121/dlls/ntdll/loader.c 2004-01-07 20:36:53.000000000 -0700
>+++ wine-20040121-mono/dlls/ntdll/loader.c 2004-02-13
15:17:45.000000000 -0700
>@@ -1955,7 +1955,9 @@
>     WINE_MODREF *wm;
>     NTSTATUS status;
>     ANSI_STRING func_name;
>-    void (* DECLSPEC_NORETURN init_func)();
>+    /* We might return for shared-lib startup */
>+    /* void (* DECLSPEC_NORETURN init_func)(); */
>+    void (* init_func)();
>     extern void __wine_dbg_ntdll_init(void);
>
>     thread_init();
>diff -ruN wine-20040121/programs/Makefile.in
wine-20040121-mono/programs/Makefile.in
>--- wine-20040121/programs/Makefile.in 2004-01-06
13:49:59.000000000 -0700
>+++ wine-20040121-mono/programs/Makefile.in 2004-02-12
14:32:58.000000000 -0700
>@@ -11,6 +11,7 @@
> cmdlgtst \
> control \
> expand \
>+ mono-winelib \
> notepad \
> progman \
> regedit \
>@@ -41,6 +42,7 @@
> clock \
> control \
> expand \
>+ mono-winelib \
> notepad \
> progman \
> regedit \
>@@ -179,6 +181,9 @@
> icinfo.exe$(DLLEXT): avitools/icinfo.exe$(DLLEXT)
> $(RM) $@ && $(LN_S) avitools/icinfo.exe$(DLLEXT) $@
>
>+mono-winelib.exe$(DLLEXT): mono-winelib/mono-winelib.exe$(DLLEXT)
>+ $(RM) $@ && $(LN_S) mono-winelib/mono-winelib.exe$(DLLEXT) $@
>+
> notepad.exe$(DLLEXT): notepad/notepad.exe$(DLLEXT)
> $(RM) $@ && $(LN_S) notepad/notepad.exe$(DLLEXT) $@
>
>@@ -255,6 +260,7 @@
> control/control.exe$(DLLEXT): control
> expand/expand.exe$(DLLEXT): expand
> avitools/icinfo.exe$(DLLEXT): avitools
>+mono-winelib/mono-winelib.exe$(DLLEXT): mono-winelib
> notepad/notepad.exe$(DLLEXT): notepad
> progman/progman.exe$(DLLEXT): progman
> regedit/regedit.exe$(DLLEXT): regedit
>diff -ruN wine-20040121/programs/mono-winelib/Makefile.in
wine-20040121-mono/programs/mono-winelib/Makefile.in
>--- wine-20040121/programs/mono-winelib/Makefile.in 1969-12-31
17:00:00.000000000 -0700
>+++ wine-20040121-mono/programs/mono-winelib/Makefile.in 2004-02-12
14:36:36.000000000 -0700
>@@ -0,0 +1,26 @@
>+TOPSRCDIR = @top_srcdir@
>+TOPOBJDIR = ../..
>+SRCDIR    = @srcdir@
>+VPATH     = @srcdir@
>+MODULE    = mono-winelib.exe
>+APPMODE   = gui
>+IMPORTS   = kernel32
>+DELAYIMPORTS = user32
>+EXTRAINCL =
>+EXTRADEFS =
>+
>+C_SRCS = \
>+ mono-winelib.c \
>+ ../../loader/pthread.c
>+
>+RC_SRCS =
>+RC_BINSRC =
>+RC_BINARIES =
>+
>+PLTESTS =
>+
>+EXTRASUBDIRS =
>+
>+@MAKE_PROG_RULES@
>+
>+### Dependencies:
>diff -ruN wine-20040121/programs/mono-winelib/mono-winelib.c
wine-20040121-mono/programs/mono-winelib/mono-winelib.c
>--- wine-20040121/programs/mono-winelib/mono-winelib.c 1969-12-31
17:00:00.000000000 -0700
>+++ wine-20040121-mono/programs/mono-winelib/mono-winelib.c 2004-02-13
14:52:52.000000000 -0700
>@@ -0,0 +1,86 @@
>+/*
>+ * mono-winelib code
>+ *
>+ * Copyright 2004 Novell, Inc. (http://www.novell.com/)
>+ *
>+ * 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 <wine/library.h>
>+#include <windows.h>
>+#include <winsock.h>
>+#include <dlfcn.h>
>+
>+/*
>+ Dummy WinMain. Wine is modified so that this function is never actually
called
>+*/
>+
>+int WINAPI
>+WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszCmdLine,
int nCmdShow)
>+{
>+ int dummy;
>+
>+   dummy=GetSystemMetrics(SM_CXSCREEN);
>+ wine_pthread_init_process(NULL);
>+
>+   return(0);
>+}
>+
>+/*
>+ WineLoadLibrary is used by System.Windows.Forms to import the Wine dlls
>+*/
>+void *(*NTDLL_LoadLibraryA)(unsigned char *);
>+
>+void *
>+WineLoadLibrary(unsigned char *dll)
>+{
>+   return(NTDLL_LoadLibraryA(dll));
>+}
>+
>+
>+/*
>+ MonoWineInit() Must be called to initialize wine. We pass special
arguments
>+ which will tell wine to not actually run the specified
>+ application
>+*/
>+
>+int
>+MonoWineInit(void)
>+{
>+ unsigned char Error[1024]="";
>+ char *WineArguments[] = {"monoapp",
"/usr/local/lib/wine/mono-winelib.exe.so", NULL};
>+ void *hModule;
>+ int FileExists;
>+
>+ wine_init(2, WineArguments, Error, sizeof(Error));
>+ if (Error[0]!='\0') {
>+ printf("Wine initialization error:%s\n", Error);
>+ exit(-1);
>+ }
>+
>+   /* Now load kernel32 go get the pointers for LoadLibraryA and
GetProcAddress */
>+   hModule=wine_dll_load("kernel32.dll", Error, sizeof(Error),
&FileExists);
>+   if (hModule==NULL) {
>+      printf("Error loading kernel32.dll: %s\n", Error);
>+      exit(-2);
>+   }
>+
>+   NTDLL_LoadLibraryA=dlsym(hModule, "LoadLibraryA");
>+   if (NTDLL_LoadLibraryA==NULL) {
>+      printf("Did not find symbol LoadLibraryA in kernel32.dll\n");
>+      exit(-3);
>+   }
>+}
>
>
>------------------------------------------------------------------------
>
>System.Windows.Forms wine-patch README
>
>After applying the patch to wine, run ./configure in the wine directory
and
>'make && make depend && make install'.
>For now the patch assumes that the prefix_dir is /usr/local.
>
>Also, once the install is done you will need to create symbolic links for
>all the dlls you plan on using in System.Windows.Forms:
>ln -s /usr/local/lib/wine/kernel32.dll.so
/usr/local/lib/libkernel32.dll.so
>ln -s /usr/local/lib/wine/user32.dll.so /usr/local/lib/libuser32.dll.so
>ln -s /usr/local/lib/wine/gdi32.dll.so /usr/local/lib/libgdi32.dll.so
>ln -s /usr/local/lib/wine/advapi32.dll.so /usr/local/lib/libgdi32.dll.so
>
>I still need to work out how to teach mono to load the libs from the wine
>directory and without the lib prefix.
>
>Peter
>pbartok@novell.com
>
>
>------------------------------------------------------------------------
>
>--- 
mcs-0.29/class/System.Windows.Forms/System.Windows.Forms/win32functions.cs
2003-11-12 03:16:24.000000000 -0700
>+++ mcs/class/System.Windows.Forms/System.Windows.Forms/win32functions.cs
2004-02-12 16:47:29.000000000 -0700
>@@ -1288,12 +1288,8 @@
> return 0;
> }
>
>-
>- [DllImport ("libwinnt.dll.so", EntryPoint="PROCESS_InitWine")]
>- extern static void PROCESS_InitWine (int argc, string [] args);
>-
>- [DllImport ("libwinnt.dll.so", EntryPoint="LoadLibraryA")]
>- extern static void NTDLL_LoadLibraryA (string s);
>+ [DllImport ("/usr/local/lib/wine/mono-winelib.exe.so",
EntryPoint="WineLoadLibrary")]
>+ extern static void WineLoadLibrary(string s);
>
> static string[] WinColors = {
> "COLOR_SCROLLBAR",
>@@ -1389,14 +1385,12 @@
> Console.WriteLine ("MonoWin32: Needs Wine MonoStub");
> return;
> }
>-
>- string [] args = new string [1];
>- args [0] = "mono";
>-
>- PROCESS_InitWine (0, args);
>- NTDLL_LoadLibraryA ("kernel32.dll");
>- NTDLL_LoadLibraryA ("user32.dll");
>- NTDLL_LoadLibraryA ("comctl32.dll");
>+ Console.WriteLine("Loading Wine dlls");
>+ WineLoadLibrary("gdi32.dll");
>+ WineLoadLibrary("kernel32.dll");
>+ WineLoadLibrary("comctl32.dll");
>+ WineLoadLibrary("user32.dll");
>+ Console.WriteLine("Loading Wine dlls complete");
>
> string gtk_colors = Environment.GetEnvironmentVariable
("SWF_GTK_COLORS");
> if (gtk_colors == "1") {
>--- mcs-0.29/class/System.Windows.Forms/System.Windows.Forms/Form.cs
2003-11-14 21:25:32.000000000 -0700
>+++ mcs/class/System.Windows.Forms/System.Windows.Forms/Form.cs
2004-02-13 11:59:08.000000000 -0700
>@@ -105,8 +105,13 @@
> cancelButton = null;
> }
>
>- static Form () {
>+   // Initialization for Wine
>+ [DllImport ("/usr/local/lib/wine/mono-winelib.exe.so",
EntryPoint="MonoWineInit")]
>+ extern static int MonoWineInit();
>
>+ static Form () {
>+            Console.WriteLine("Initializing wine\n");
>+            MonoWineInit();
> }
>
> //  --- Public Properties
>
>