|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Command | Meaning | |
| break | Set a breakpoint at a specified address or symbolic value. Wine will stop before executing instructions at this address. For example, break * GDI_Ordinal_24 sets a breakpoint at the start of Windows Ellipse function known internally as GDI.24. | |
| bt | Backtrace, or show the history of Wine calls leading to the current place. The addresses shown are the return addresses, not the calling addresses. | |
| cont | Continue program execution until a breakpoint or error condition is reached. | |
| define | Equates a symbol to a value. For example: define myproc 0x000001c6. | |
| disable | Disable a specific breakpoint. Breakpoints defined by the break command are stored by breakpoint numbers. To disable a breakpoint, you need to find the breakpoint number with the info command. To disable breakpoint number 1, simply type disable 1. | |
| enable | Enables a breakpoint number, the opposite of disable. To enable the previously disabled breakpoint number 1, simply type enable 1. | |
| help | Prints a help text of the available commands. | |
| info | Provides information on the following: | |
| reg registers information. | ||
| stack dumps the current stack. | ||
| break shows the current breakpoints and if they are enabled. | ||
| segments shows information about memory segments in use. | ||
| mode | Switches between 16- and 32-bit modes. | |
| Prints out values of expressions given. | ||
| quit | Exits debugger and ends any MS Windows program in progress. | |
| set | Enables depositing of values in registers and memory. | |
| symbolfile | Loads a symbol file containing symbolic values. The file wine.sym is created as part of the Wine build. | |
| x | Examines memory values in several different formats. The format of x is x / format address, where format can be one of the following: | |
| x | longword hexadecimal (32-bit integer) | |
| d | longword decimal | |
| w | word hexadecimal | |
| b | byte | |
| c | single character | |
| s | null-terminated ASCII string | |
| I | i386 instruction | |
| A number can be specified before the format to indicate a repeating group. For example, listing 10 instructions after a given address would be x / 10 I 0x000001cd. |
In order to benefit from using the Wine debugger, an understanding of debugging i386 assembly is essential. If you are serious about debugging Wine, an assembly language output from GCC is essential.
Wine is composed of a MS Windows program loader and a library of MS Windows functions.
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 does DOS that is called NE, or new
executable. DLLs and font files also use this NE format, which makes Wine's job easier.
Individual segments of the NE image must be load 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 Ellipse is actually
stored as GDI.24.
After an executable image is loaded into memory, Wine simply jumps to the WinMain() function defined in the image. A call to MS Windows graphics function Ellipse is stored as GDI.24. GDI is the name of the MS Windows graphics library, and 24 is the
position in that DLL where Ellipse 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.
Wine converts the MS Windows API to the matching X or UNIX API calls. A call to the MS Windows Ellipse function to draw an ellipse in a window has the following format:
Ellipse (hdc, xLeft, yTop, xRight, yBottom);
The definitions are of xLeft, yTop, xRight, and yBottom are a bounding box for an ellipse as shown in Figure 58.2.
Figure 58.2. MS Windows ellipse coordinates.
The same ellipse is drawn under the X API XDrawArc function:
XDrawArc(display, d, gc, x, y, width, height, angle1, angle2);
The definitions of x, y, width, height, angle1, and angle2 are shown in Figure 58.3.
Figure 58.3. XDrawArc coordinates.
Wine needs to do a little math to convert the coordinates from an Ellipse call to that of an XDrawArc call. Other parameters of the XDrawArc call are a bit easier to map. The d refers to a drawable area, which is typically a handle to a window. Under MS
Windows, this is contained in the hdc structure. The gc is a graphics context and is analogous in functionality to the hdc under MS Windows. As X is capable of displaying on different machines over a network, the display parameter describes which display
to use. The display parameter remains constant over the life of a Wine session. The last thing Wine has to consider is that an MS Windows Ellipse call can also specify a filled ellipse. Wine checks the hdc, and possibly uses XFillArc instead.
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.
As 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:
| commdlg | Common Windows Dialogs |
| gdi | Graphics Device Interface |
| kernel | Kernel Interface |
| keyboard | Keyboard Interface |
| mmsystem | Multimedia System Interface |
| mouse | Mouse Interface |
| shell | Windows 3.1 Shell API Library |
| sound | Windows sound system |
| toolhelp | Debugging and tools helper calls |
| user | Microsoft Windows User Interface |
| win87em | Coprocessor/Emulator Library |
| winsock | Windows Socket interface (TCP/IP) |
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 OLECLI, 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.
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. WINMINE.EXE and SOL.EXE are examples of such applications. Although no suggested directory organization exists
to support this, a quick example of doing this is the following:
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 running it. Unfortunately there are some classes of applications that are unlikely to ever run
under Wine.
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:
Part of Wine is the winestat utility. This is actually the same program as Wine, but instead of running an MS Windows executable, winestat simply attempts to load a Windows executable and reports on how successful the load was. In loading an executable,
winestat also loads any DLLs necessary, and reports if any are missing. winestat looks for Windows API calls that are used by either the executable or any DLL, and verifies their existence. A sample winestat run on the MS Windows Paintbrush applet pbrush
yields the following:
KERNEL.1 not implemented KERNEL.54 not implemented KERNEL.113 not implemented KERNEL.114 not implemented KERNEL.121 not implemented KERNEL.154 not implemented KERNEL.178 not implemented KERNEL.207 not implemented KERNEL: 52 of 60 (86.7 %) USER: 150 of 150 (100.0 %) GDI.151 not implemented GDI.307 not implemented GDI.366 not implemented GDI.439 not implemented GDI: 80 of 84 (95.2 %) SHELL: 9 of 9 (100.0 %) KEYBOARD: 2 of 2 (100.0 %) TOTAL: 293 of 305 winapi functions implemented (96.1 %)
winestat calls out the individual functions by number and module that are not implemented by Wine. If you are curious as to the function name, rather than number, look at the Wine sources in the if1632 directory for the given module name's spec file. A
sample kernel.spec file is as follows:
#1 FATALEXIT #2 EXITKERNEL 3 pascal GetVersion() GetVersion() ... ... ... #54 pascal16 GETINSTANCEDATA
Any line in a .spec file that starts with a # is considered a comment, not an implemented function. In this example, both 1 and 54 are commented, with the respective names of FATALEXIT, and GETINSTANCEDATA. FATALEXIT is used for debugging MS Windows
programs under error conditions and is not important for most MS Windows users. GETINSTANCEDATA copies configuration data from a previous instance of an application. If you are running only one instance of an application, this does not apply.
The final percentage shows which MS Windows API calls are implemented. This is often a good measure of how much of an application could work under Wine. Unfortunately, if a single, unimplemented API call is needed to initialize your MS Windows
application, anything less than 100 percent is not good enough.
MS Windows applications to which winestat gives an overall implementation rating over 95 percent are worth a try. Unlike DOSemu, Wine is not as prone to leaving Linux in an unusable state. However it is not always a trivial matter to kill an errant Wine
session. The easiest thing to do is to start Wine with a separate desktop: wine -desktop 800´600 filename. Normal methods of killing a Windows process from your window manager should work.
When all else fails trying to stop an errant Wine session, switch to a free virtual console and kill the errant Wine process.
For example, Alt-Ctrl and F2 would switch to virtual console number 2. You can log into a virtual console and use ps -ax | grep wine to find your Wine sessions. Use kill -15 pid where pid is the process id returned by ps to stop the process. You can return to your X session by switching to the virtual console that is running X. If you don't know what console number that is, hold down the Alt and Ctrl keys, and press F1 through F8 until you find it.
Perhaps the most obvious omission from Wine is the lack of a printer interface. As this is a complex process, work on a printer interface is little more than a few ideas. It would be a huge task to support all of the types of printers supported under MS
Windows. Wine will likely implement only a PostScript driver. Existing Linux utilities such as GhostScript are already capable of converting PostScript to other types of printer types, such as HP laser and inkjet printers.
The 32-bit Windows API (win32) is mostly unsupported. This is the executable image format for Windows NT and Windows 95, and is known as PE (portable executable). Wine currently supports the loading of resource files, such as fonts, that are in PE
format, but is unable to handle executables or DLLs.
The Wine project has no plans to support Windows Virtual Device Drivers. (VDDs). VDDs use a different image format, called LE for linear executable, that the Wine loader is unable to handle. Because VDDs do things like direct hardware manipulation,
coexistence of a VDD with Linux device drivers would be a tough problem indeed. One of the uses of VDDs in commercial MS Windows is for TCP/IP stacks. Wine supports TCP/IP through the winsock DLL, which uses the TCP/IP inherent in the Linux kernel.
The first parts of Wine were made available in July 1993. The first versions had problems running the MS Windows Solitaire game, and were quite limited. Notably missing was support for menus. Since then a huge number of changes have been made by many
dedicated people. It would be nearly impossible to mention everyone who contributed to Wine, or to parts of Linux that make Wine possible, but here is a list of people anyway:
Bob Amstadt, Dag Asheim, Martin Ayotte, Ross Biro, Uwe Bonnes, Erik Bos, Fons Botman, John Brezak, Andrew Bulhak, John Burton, Niels de Carpentier, Roman Dolejsi, Frans van Dorsselaer, Paul Falstad, Olaf Flebbe, Peter Galbavy, Ramon Garcia, Hans de
Graaff, Charles M. Hannum, John Harvey, Cameron Heide, Jochen Hoenicke, Onno Hovers, Jeffrey Hsu, Miguel de Icaza, Jukka Iivonen, Alexandre Julliard, Jochen Karrer, Andreas Kirschbaum, Albrecht Kleine, Jon Konrath, Alex Korobka, Greg Kreider, Anand Kumria,
Scott A. Laird, Martin von Loewis, Kenneth MacDonald, Peter MacDonald, William Magro, Juergen Marquardt, Marcus Meissner, Graham Menhennitt, David Metcalfe, Steffen Moeller, Philippe De Muyter, Itai Nahshon, Michael Patra, Jim Peterson, Robert Pouliot,
Keith Reynolds, John Richardson, Johannes Ruscheinski, Thomas Sandford, Constantine Sapuntzakis, Daniel Schepler, Ulrich Schmid, Bernd Schmidt, Yngvi Sigurjonsson, Rick Sladkey, William Smith, Erik Svendsen, Tristan Tarrant, Andrew Taylor, Duncan C.
Thomson, Goran Thyni, Jimmy Tirtawangsa, Jon Tombs, Linus Torvalds, Gregory Trubetskoy, Michael Veksler, Sven Verdoolaege, Eric Warnke, Manfred Weichel, Morten Welinder, Jan Willamowius, Carl Williams, Karl Guenter Wuensch, Eric Youngdale, and James
Youngman.
For more information about the Wine project, get the FAQ at http://www.asgardpro.com/dave/wine-faq.asp or visit the project's home page at http://daedalus.dra.hmg.gb/gale/wine/wine.asp.