📄 948-951.html
字号:
<HTML>
<HEAD>
<TITLE>Linux Unleashed, Third Edition:The Wine Project</TITLE>
<SCRIPT>
<!--
function displayWindow(url, width, height) {
var Win = window.open(url,"displayWindow",'width=' + width +
',height=' + height + ',resizable=1,scrollbars=yes');
}
//-->
</SCRIPT>
</HEAD>
-->
<!--ISBN=0672313723//-->
<!--TITLE=Linux Unleashed, Third Edition//-->
<!--AUTHOR=Tim Parker//-->
<!--PUBLISHER=Macmillan Computer Publishing//-->
<!--IMPRINT=Sams//-->
<!--CHAPTER=59//-->
<!--PAGES=948-951//-->
<!--UNASSIGNED1//-->
<!--UNASSIGNED2//-->
<CENTER>
<TABLE BORDER>
<TR>
<TD><A HREF="945-948.html">Previous</A></TD>
<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>
<TD><A HREF="951-954.html">Next</A></TD>
</TR>
</TABLE>
</CENTER>
<P><BR></P>
<H3><A NAME="Heading13"></A><FONT COLOR="#000077">How Wine Works</FONT></H3>
<P>Wine is composed of a MS-Windows program loader and a library of MS-Windows functions.
</P>
<H4 ALIGN="LEFT"><A NAME="Heading14"></A><FONT COLOR="#000077">How Wine Loads Programs</FONT></H4>
<P>Wine’s first duty is to load an MS-Windows executable image into memory. This also includes any DLL files and other resources that the application needs. MS-Windows uses a different executable image type than DOS which is called NE, or new executable. DLLs and font files also use this NE format, which makes Wine’s job easier.
</P>
<P>Individual segments of the NE image must be loaded into memory, and references to other DLL and Windows calls need to be resolved. Calls to functions outside an image are referred to by the module name and function number. A call to <TT>Ellipse</TT> is actually stored as GDI.24.</P>
<P>After an executable image is loaded into memory, Wine simply jumps to the <TT>WinMain()</TT> function defined in the image. A call to MS-Windows graphics function <TT>Ellipse</TT> is stored as <I>GDI.24</I>. <I>GDI</I> is the name of the MS-Windows graphics library, and 24 is the position in that DLL where <TT>Ellipse</TT> starts. Wine does not need to do any instruction emulation because both Linux and MS-Windows use the i386 instruction set. When an MS-Windows primitive function is called, Wine intercepts that call and passes it to a matching library routine.</P>
<H4 ALIGN="LEFT"><A NAME="Heading15"></A><FONT COLOR="#000077">The Wine Library</FONT></H4>
<P>Wine converts the MS-Windows API to the matching X or UNIX API calls. A call to the MS-Windows <TT>Ellipse</TT> function to draw an ellipse in a window has the following format:</P>
<!-- CODE SNIP //-->
<PRE>
Ellipse (hdc, xLeft, yTop, xRight, yBottom);
</PRE>
<!-- END CODE SNIP //-->
<P>The definitions of <TT>xLeft</TT>, <TT>yTop</TT>, <TT>xRight</TT>, and <TT>yBottom</TT> are a bounding box for an ellipse.</P>
<P>The same ellipse is drawn under the X API <TT>XDrawArc</TT> function:</P>
<!-- CODE SNIP //-->
<PRE>
XDrawArc(display, d, gc, x, y, width, height, angle1, angle2);
</PRE>
<!-- END CODE SNIP //-->
<P>Wine needs to do a little math to convert the coordinates from an <TT>Ellipse</TT> call to that of an <TT>XDrawArc</TT> call. Other parameters of the <TT>XDrawArc</TT> call are a bit easier to map. The <I>d</I> refers to a drawable area, which is typically a handle to a window. Under MS-Windows, this is contained in the <TT>hdc</TT> structure. The <I>gc</I> is a graphics context and is analogous in functionality to the <I>hdc</I> under MS-Windows. As X is capable of displaying on different machines over a network, the <I>display</I> parameter describes which display to use. The <I>display</I> parameter remains constant over the life of a Wine session. The last thing Wine has to consider is that an MS-Windows <TT>Ellipse</TT> call can also specify a filled ellipse. Wine checks the <TT>hdc</TT> and possibly uses <TT>XFillArc</TT> instead.</P>
<P>There are nearly 300 graphics primitives available under MS-Windows that need to undergo similar translations. While this might seem to be a bit of work, the graphics conversions are among the simpler things to emulate under MS-Windows.</P>
<H3><A NAME="Heading16"></A><FONT COLOR="#000077">Where Does Wine End and MS-Windows Begin?</FONT></H3>
<P>Because Wine currently requires parts of MS-Windows to operate, it is a bit confusing to know where Wine ends and MS-Windows begins. Wine currently provides API calls for the following parts of a typical MS-Windows installation:
</P>
<CENTER>
<TABLE WIDTH="80%"><TR>
<TD WIDTH="30%"><TT>commdlg</TT>
<TD WIDTH="70%">Common Windows Dialogs
<TR>
<TD><TT>gdi</TT>
<TD>Graphics Device Interface
<TR>
<TD><TT>kernel</TT>
<TD>Kernel Interface
<TR>
<TD><TT>keyboard</TT>
<TD>Keyboard Interface
<TR>
<TD><TT>mmsystem</TT>
<TD>Multimedia System Interface
<TR>
<TD><TT>mouse</TT>
<TD>Mouse Interface
<TR>
<TD><TT>shell</TT>
<TD>Windows 3.1 Shell API Library
<TR>
<TD><TT>sound</TT>
<TD>Windows sound system
<TR>
<TD><TT>toolhelp</TT>
<TD>Debugging and tools helper calls
<TR>
<TD><TT>user</TT>
<TD>Microsoft Windows User Interface
<TR>
<TD><TT>win87em</TT>
<TD>Coprocessor/Emulator Library
<TR>
<TD><TT>winsock</TT>
<TD>Windows Socket interface (TCP/IP)
</TABLE>
</CENTER>
<P>Wine requires access to some parts of MS-Windows to use features that are not implemented by Wine. One example is the MS-Windows dynamic link library <TT>OLECLI</TT>, which implements the OLE client. The Wine team has made significant headway in reducing the amount of files needed. The Wine project charter includes removing any dependency on MS-Windows files. This includes utilities and file organizations to install MS-Windows applications.</P>
<P>Some of the simplest MS-Windows applications run today under Wine without need of any MS-Windows code or access to any MS-Windows directories. <TT>WINMINE.EXE</TT> and <TT>SOL.EXE</TT> are examples of such applications. Although no suggested directory organization exists to support this, a quick example of doing this is the following:</P>
<DL>
<DD><B>1.</B> Copy <TT>winmine.exe</TT> and <TT>win.ini</TT> to a Linux directory such as <TT>/users/windows</TT>.
<DD><B>2.</B> Change the Windows path options in <TT>wine.conf</TT> to <TT>/users/windows</TT>, for example.
<DD><B>3.</B> Dismount your MS-DOS partition.
<DD><B>4.</B> Run Wine.
</DL>
<H3><A NAME="Heading17"></A><FONT COLOR="#000077">Limitations of Wine</FONT></H3>
<P>Only a few MS-Windows software packages run correctly under Wine. Luckily, it is possible to estimate how likely a program is to run correctly without actually executing it. Unfortunately, there are some classes of applications that are unlikely to ever run under Wine.
</P>
<H4 ALIGN="LEFT"><A NAME="Heading18"></A><FONT COLOR="#000077">Software That Works</FONT></H4>
<P>The most recent versions of Wine support a good number of the MS-Windows applets and games included with the stock MS-Windows 3.1. There are considerable variations between each release of Wine. Changes that help some applications often break others. But here are some of the accessories and games that work reasonably well under Wine:
</P>
<DL>
<DD><B>•</B> <TT>calc.exe</TT>
<DD><B>•</B> <TT>clock.exe</TT>
<DD><B>•</B> <TT>cruel.exe</TT>
<DD><B>•</B> <TT>golf.exe</TT>
<DD><B>•</B> <TT>notepad.exe</TT>
<DD><B>•</B> <TT>pipe.exe</TT>
<DD><B>•</B> <TT>pegged.exe</TT>
<DD><B>•</B> <TT>reversi.exe</TT>
<DD><B>•</B> <TT>winmine.exe</TT>
</DL>
<P><BR></P>
<CENTER>
<TABLE BORDER>
<TR>
<TD><A HREF="945-948.html">Previous</A></TD>
<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>
<TD><A HREF="951-954.html">Next</A></TD>
</TR>
</TABLE>
</CENTER>
</td>
</tr>
</table>
<!-- begin footer information -->
</body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -