1 \input texinfo @c -*-texinfo-*-
4 @settitle Wine Reference Manual
13 * wine: (wine.info). The Windows Emulator.
23 This file documents Wine, the Windows Emulator.
26 Copyright @copyright{} 1997,1998 The Wine authors. @*
27 @xref{Authors, The Wine Authors, The Wine Authors},
28 for a list of the copyright holders.
30 Permission is granted to make and distribute verbatim
31 copies of this manual provided the copyright notice and
32 this permission notice are preserved on all copies.
35 Permission is granted to process this file through TeX
36 and print the results, provided the printed document
37 carries a copying permission notice identical to this
38 one except for the removal of this paragraph (this
39 paragraph not being relevant to the printed manual).
42 Permission is granted to copy and distribute modified
43 versions of this manual under the conditions stated in
44 the section entitled ``License, Warranty, and Authors of Wine''.
47 FIXME: X11 and POSIX trademarks. @*
48 UNIX is a registered trademark of the Open Group.
49 Microsoft, Windows, MS-Windows, Windows-NT, Windows 95, and MS-DOS are
50 registered trademarks of Microsoft Corporation.
51 NT is a trademark of Northern Telecom Limited.
52 C++Builder is a trademark of Borland International, Inc.
53 Postscript is a registered trademark of Adobe Systems Inc.
54 Other trademarks are the property of their respective owners, which may
55 be registered in certain jurisdictions.
58 @c begin chapters on right pages
59 @setchapternewpage odd
63 @title{The Wine Reference Manual}
64 @subtitle{Edition 0.0.5, February 1998}
66 @author{The Wine Team}
67 @c The following two commands start the copyright page.
69 @vskip 0pt plus 1filll
71 Copyright @copyright{} 1997, 1998 The Wine authors. @*
72 @xref{Authors, The Wine Authors, The Wine Authors},
73 for a list of the copyright holders.
75 Permission is granted to make and distribute verbatim
76 copies of this manual provided the copyright notice and
77 this permission notice are preserved on all copies.
79 Permission is granted to copy and distribute modified
80 versions of this manual under the conditions stated in
81 the section entitled ``License, Warranty, and Authors of Wine''.
84 FIXME: UNIX and POSIX trademarks. @*
86 Microsoft, Windows, MS-Windows, Windows-NT, Windows 95, and MS-DOS are
87 registered trademarks of Microsoft Corporation.
88 NT is a trademark of Northern Telecom Limited.
89 C++Builder is a trademark of Borland International, Inc.
90 Postscript is a registered trademark of Adobe Systems Inc.
91 Other trademarks are the property of their respective owners, which may
92 be registered in certain jurisdictions.
98 @c SETTINGS, DEFINES, MACROS
101 @c Edit this macro manually in the above parts of the document
102 @macro winemanualversion
106 @c Edit this macro manually in the above parts of the document
107 @macro winemanualdate
111 @c Edit this macro manually into the TeX titlepage
112 @macro winemanualtitle
113 The Wine Reference Manual
124 @c FIXME: automatic trademark reference
129 @c FIXME: automatic trademark reference
130 @c spell it always the same
138 @c FIXME: automatic trademark reference
143 @c FIXME: automatic trademark reference
148 @c FIXME: automatic trademark reference
157 @c FIXME: automatic trademark reference
162 @c FIXME: automatic trademark reference
179 @c flag out differences to MS-Windows
181 @emph{Differences to @mswindows{}:} @*
186 No differences known.
189 @c tell whether function is present in Windows 95 and/or NT
191 @emph{Conformance to @mswindows{}:} @*
196 Present in @WIN95{} and @WINNT{}.
199 @c give information about completion
201 @emph{Completion status:} @*
204 @macro completionnone
210 @c MACROS FOR FUNCTIONS, TYPES, CONSTANTS, VARIABLES
213 @c Constants in the WIN32 API
214 @macro defvr_cw32 {restofline}
215 @defvr Constant \restofline\
217 @macro defvrx_cw32 {restofline}
218 @defvrx Constant \restofline\
221 @c Functions in the WIN32 API
222 @macro deftypefn_w32 {restofline}
223 @deftypefn {WIN32 function} \restofline\
225 @macro deftypefnx_w32 {restofline}
226 @deftypefnx {WIN32 function} \restofline\
229 @c Types in the WIN32 API
230 @macro deftp_w32 {restofline}
231 @deftp {Data type} \restofline\
233 @macro deftpx_w32 {restofline}
234 @deftpx {Data type} \restofline\
237 @c Macros internal to Wine
238 @macro deffn_winemacro {restofline}
239 @deffn {Wine internal macro} \restofline\
241 @macro deffnx_winemacro {restofline}
242 @deffn {Wine internal macro} \restofline\
245 @c Constants internal to Wine
246 @macro defvr_cwine {restofline}
247 @defvr {Wine internal constant} \restofline\
249 @macro defvrx_cwine {restofline}
250 @defvrx {Wine internal constant} \restofline\
258 @node Top, Copying, (dir), (dir)
261 This is edition @winemanualversion{}, last updated @winemanualdate{},
262 of @winemanualtitle{}.
264 Wine (Wine Is Not an Emulator, or the WINdows Emulator)
265 is both an emulator that runs @mswindows{} executables and a library
266 that can be used to compile @mswindows{} source code.
268 Wine is free software. Wine is still in development-only state.
272 * Copying:: License, Warranty, and Authors of Wine.
273 * Introduction:: A short overview.
274 * Wine Design:: The design of Wine.
275 * Reference Manual:: The Wine reference manual.
276 * Installation:: Installing and configuring Wine.
277 * The Wine Project:: How to contribute to Wine.
278 * Concept Index:: Index of concepts and names.
279 * Type Index:: Index of types and type qualifiers.
280 * Function Index:: Index of functions and function-like
282 * Variable Index:: Index of variables, constants, and
283 variable-like macros.
284 * File Index:: Index of programs and files.
287 @node Copying, Introduction, Top, Top
289 @unnumbered License, Warranty, and Authors of Wine
290 @cindex copying conditions for Wine
291 @cindex conditions for copying Wine
292 @cindex Wine copying conditions
294 The Wine license, warranty, and list of authors together form the
295 copyright for Wine. Read these sections carefully.
298 * License:: The Wine license.
299 * Warranty:: Wine comes with no warranty.
300 * Authors:: The persons that contributed to Wine.
303 @node License, Warranty, , Copying
305 @cindex license of Wine
307 @unnumberedsec The Wine License
308 Wine is distributed under the following copyright.
314 @node Warranty, Authors, License, Copying
315 @cindex Wine warranty
316 @cindex warranty of Wine
318 @unnumberedsec The Wine Warranty
324 @node Authors, , Warranty, Copying
326 @cindex authors of Wine
327 @cindex copyright holders of Wine
328 @cindex Wine copyright holders
330 @unnumberedsec The Wine Authors
336 These persons also hold the copyright on Wine.
338 The overall coordination is done by @*
339 Alexandre Julliard @*
340 @email{julliard@@lrc.epfl.ch}
344 @node Introduction, Wine Design, Copying, Top
345 @chapter Introduction
347 @strong{What is Wine?}
349 Wine is a Windows-compatibility layer for Unix and X11.
350 The Wine system consists of several thing:
353 An API, sometimes referred to as the Wine API,
354 designed to be as compatible as possible with the
357 A library, called @winelib{}, which implements this API
359 A binary compatibility layer, sometimes referred to as the Wine
360 emulator, which acts as a program loader for native Windows binaries.
361 The emulator works for both 16 and 32 bit Intel binaries, and
362 provides all the appropriate translation between 16 and 32 bit code
363 (thunking). Real mode interrupts are also supported, and their
364 functionality is implemented in @winelib{}.
368 @strong{System Requirements}
371 Wine provides binary support for Intel code on Intel hardware only.
372 Neither hardware emulation
373 nor non-Intel binaries are supported.
374 @winelib{} should be possible to port to just about any Unix system.
376 Currently, you must have one of:
379 Linux version 0.99.13 or above
383 FreeBSD-current or FreeBSD 1.1
385 OpenBSD/i386 2.1 or later
387 Solaris x86 2.5 or later
389 You need X11, and you must have @file{libXpm} installed on your system.
391 @strong{Availability}
393 Wine is free software; the license is BSD-style. Basically, you can do
394 anything with it, except claim that you wrote it.
395 @xref{Copying}, for more information.
397 @strong{Further information}
399 You should consult the files @file{README}, @file{ANNOUNCE},
400 @file{RELEASE-NOTES}, @file{BUGS}, @file{LICENSE}, and @file{WARRANTY},
401 in the root directory of the Wine distribution.
403 The Wine USENET newsgroup @url{news:comp.emulators.ms-windows.wine}
404 is useful for both Wine developers and Wine users. The Wine home page
405 is @url{http://www.winehq.com/}.
407 @node Wine Design, Reference Manual, Introduction, Top
410 @subsection The Wine Graphics Driver Model
412 Wine, like Windows, abstracts drawing code so that applications may access
413 a wide variety of devices, from different kinds of graphics cards,
414 X displays and printers, using a single unified graphics model.
415 This model is referred to as GDI: _G_raphics _D_river _I_nterface.
416 This section discusses the Wine implementation of GDI.
417 There are 61 functions in the Wine graphics model, including Arc, BitBlt,
418 Chord, etc. For a complete list and prototypes, see the definition
419 of DC_FUNCTIONS in [include/gdi.h].
421 Wine, as of 2Q1998, has three native drivers: these provide support
422 for rendering to X displays, metafiles, and Win16 native printer drivers.
423 As far as Wine is concerned, a driver
424 simply consists of a name and a table of function pointers
425 (see [graphics/driver.c]). These functions
426 are the driver's implementation of the various Wine graphics
427 operations (the GDI). Wine maintains a linked list of all drivers which
428 register themselves with Wine, as well as a ``generic''
429 driver. Currently, the X11 driver registers itself as DISPLAY, the
430 win16 driver registers itself as the generic driver, and the metafile
431 driver doesn't register itself at all.
433 @subsubsection How a driver function gets invoked
435 All drawing by Wine applications
436 is done in terms of a Device Context (DC).
437 Before an application can draw, it must create a DC, and all drawing calls
438 must pass a handle to the DC they wish to draw to.
439 [include/gdi.h] defines several structures relating to DCs, including
440 DC, WIN_DC_INFO, and DeviceCaps. The DeviceCaps structure is at the lowest
442 information relating to specifics of the graphics display
443 hardware and associated
445 WIN_DC_INFO holds information about several device independent
446 modes the DC can be in, plus a pointer to DeviceCaps.
448 the DC structure is the toplevel structure usually passed around.
449 It holds viewport information, a pointer to WIN_DC_INFO, and a
450 pointer to the function table to be used while rendering that DC.
451 This function table is filled at the time of creating the DC.
455 @c Some discussion of the various modalities available to a DC would be nice.
457 @c Coordinate Systems
459 @c Some discussion of the maze of coordinate systems would also be nice.
461 @c Device Coordinates
463 @c Logical Coordinates
468 @subsubsection The X11 driver
470 As a part of the Wine loading process,
471 X11DRV_Init in [graphics/x11drv/init.c] is called.
472 This initializes various aspects of the X11 driver and
473 registers it as DISPLAY. This function first
474 calls initialization procedures for various parts of the X11 driver.
477 fills a static DeviceCaps
478 structure to be used for every X11 DC.
479 Finally, it fills the table of GDI functions to be used for X11
480 rendering and registers itself as ``DISPLAY''.
482 @subsubsection The Metafile Driver
484 The metafile driver is unusual, in that it is not a driver for any
485 kind of display device, but rather a mechanism which allows using
486 the Wine graphics model as a file format for saving graphics.
487 The advantage of this is that it allows using identical formats for
488 saving pictures as is actually used to display them; it is analogous
489 to Display PostScript.
491 The metafile driver is invoked explicitly by the application. The
492 application calls CreateMetaFile() to create a special DC for recording
493 graphics drawing operations in a metafile. Any drawing operations
494 performed in this DC are not drawn physically anywhere, they are
495 instead stored in the metafile. The DC is explicitly destroyed by a
496 call to CloseMetaFile(), which also finishes writing the metafile.
497 Metafiles may be written either to a file or to memory. Later, the
498 metafile can be rendered (in a physical DC) by PlayMetaFile().
500 The way that this works is that device contexts contain a pointer
501 to the function lookup table for drawing operations appropriate for
504 Not all functions in the Wine graphics model are relevant to metafiles, but
505 some relevant but rarely used functions are unimplemented.
507 @subsubsection The WIN16 Driver
509 WIN16DRV_Init is called by MAIN_EmulatorInit, and registers the
510 WIN16DRV function table WIN16DRV_Funcs [graphics/win16drv/init.c]
511 for the generic driver. The WIN16 driver is designed to load
512 specified native Windows printer drivers. I don't understand
513 how the whole scheme works,
514 start studying what happens when a printer DC is
515 created via WIN16DRV_CreateDC.
517 If a DC is created explicitly, via the
518 CreateDC() call, the driver name is specified explicitly and Wine
519 finds the appropriate driver by leafing through its table of registered
520 drivers. Metafile DCs can only be created by the CreateMetaFile function.
522 Alternatively, most of the time, the DISPLAY driver is invoked
524 The application creates a window with
525 CreateWindow(). If the CS_CLASSDC or CS_OWNDC flag is passed, a new DC
526 is created and saved for the window in a structure called DCE, which holds
527 a DC, a clipping region, and flags. Whenever the application wants to
528 paint in that window, it calls GetDC(hwnd), which returns the DC in the
529 DCE saved in the window.
531 If neither of those flags are used, the window gets a DCE assigned to it
532 from a pool of DCEs created during Wine initialization and temporarily
533 assigned during the GetDC() call.
534 All DCEs, whether part of the Wine DC pool or created by request of a window,
535 use the ``DISPLAY'' driver.
538 @node Reference Manual, Installation, Wine Design, Top
541 * @WIN32{} Reference Manual:: The @WIN32{} function calls and data types.
542 * Resources and INI files:: How to determine the appearance and
543 behaviour of Wine programs.
544 * Metafiles--Icons--Bitmaps:: FIXME missing.
545 * Debugging:: Debugging Wine.
546 * Programs:: Programs written to run in/with Wine.
547 * Tools:: Programs to support Wine.
550 @node @WIN32{} Reference Manual, Resources and INI files, , Reference Manual
551 @chapter The @WIN32{} Reference Manual
554 * Kernel Objects:: How the Wine kernel keeps information.
555 * Processes and Threads:: Job control and management in Wine.
556 * Users and Groups:: Security in Wine.
557 * Date and Time:: Functions for getting the date and time
558 and for conversion between formats.
559 * System Information:: Getting information about the hardware
560 and software the system runs on.
561 * Memory Management:: How your programs get memory from
563 * I/O Facilities:: Input/Output in Wine.
564 * Communication:: How processes can communicate.
565 * Windows and Graphics:: GUI functions of @WIN32{}.
566 * Errors and Exceptions:: How your program can report errors.
568 * Resources:: Functions for dealing with resources.
569 * The Registry:: FIXME missing.
570 * Dynamic Link Libraries:: Functions for dealing with DLL's.
573 @node Kernel Objects, Processes and Threads, , @WIN32{} Reference Manual
574 @section Kernel Objects
577 @node Processes and Threads, Users and Groups, Kernel Objects, @WIN32{} Reference Manual
578 @section Processes and Threads
580 @node Users and Groups, Date and Time, Processes and Threads, @WIN32{} Reference Manual
581 @section Users and Groups
583 @node Date and Time, System Information, Users and Groups, @WIN32{} Reference Manual
584 @section Date and Time
586 This section describes functions for manipulating dates and times. This
587 includes the current time, the creation or manipulation times of files
588 and other objects, and conversion between different time
592 * File Times:: Creation and manipulation times of files.
595 @node File Times, , , Date and Time
596 @subsection File Times
599 * Type FILETIME:: The data structure used for specifying
601 * Compare File Times:: Compare two file times.
605 @c *** struct FILETIME ***
607 @node Type FILETIME, Compare File Times, , File Times
608 @subsubsection Type FILETIME
611 File times in Wine are specified by the data type @code{FILETIME},
612 defined in @file{windows.h}.
614 @deftpx_w32 LPFILETIME
615 This is the data type for specifying file times. The file times are
616 stored with 64 bit precision. The actual data type is a structure with
617 two 32-bit values which are interpreted as the low and high parts of a
618 64-bit value. This value gives a time measured in a granularity of 100
619 nanoseconds, so 1.5 seconds are specified by a value of 15,000,000. In
620 Wine, this 64-bit value is signed, with the sign taken from the high
621 part. The lower part is used as unsigned.
623 The definition of @code{FILETIME} reads:
628 INT32 dwHighDateTime;
629 @} FILETIME, *LPFILETIME;
632 @cindex epoch in file time
633 The @code{FILETIME} structure may be used to hold absolute or relative
634 times. Absolute times are given as the number of 100 nanoseconds
635 intervals elapsed since 1 January 1601, 00:00:00 UTC (Coordinated
636 Universal Time, which is GMT, Greenwich Mean Time). This might be
637 called the @dfn{epoch} for file times. With a signed 64-bit value, this
638 representation covers absolute times of 29247 years around the epoch.
639 To convert this type to local time, use the function
640 @code{FileTimeToLocalFileTime}.
643 In @mswindows{}, the elements of the structure are apparently of type
644 @code{DWORD}. Whether the full 64 bit value is interpreted as signed or
645 unsigned I do not know.
649 @c *** CompareFileTime ***
651 @node Compare File Times, , Type FILETIME, File Times
654 The Wine function @code{CompareFileTime} compares two file times, and
655 returns whether the first time is less than, equal to, or greater than
656 the second file time. It is defined in @file{windows.h}.
657 @deftypefn_w32 LONG CompareFileTime (@w{CONST FILETIME* @var{time_1},} @w{CONST FILETIME* @var{time_2})}
658 This function returns @code{1}, if @var{time_1} is greater than
659 @var{time_2}, @code{-1} if it is less, and @code{0} if both times are
669 @node System Information, Memory Management, Date and Time, @WIN32{} Reference Manual
670 @section System Information
672 @node Memory Management, I/O Facilities, System Information, @WIN32{} Reference Manual
673 @section Memory Management
675 @node I/O Facilities, Communication, Memory Management, @WIN32{} Reference Manual
676 @section I/O Facilities
678 This section describes all input/output of a process, except for two
679 topics: communication with other processes, and communication with the
683 * I/O on Files:: Accessing the contents of files.
684 * File System Interface:: Functions for manipulating files as a whole.
687 @node I/O on Files, File System Interface, , I/O Facilities
688 @subsection I/O on Files
690 @node File System Interface, , I/O on Files, I/O Facilities
691 @subsection File System Interface
693 These functions are concerned with operating on files themselves, rather
694 than on their contents.
697 * Type BY_HANDLE_FILE_INFORMATION:: The data structure used to
698 specify file information.
699 * File attributes:: The file attributes flags in
700 a file information structure.
701 * Getting file information:: These functions let you obtain
702 information about a file.
705 @node Type BY_HANDLE_FILE_INFORMATION, File attributes, , File System Interface
706 @subsubsection The file information structure
708 The file information structure of Wine is used to obtain information
709 about files. It is declared in the header @file{winedows.h}.
710 @deftp_w32 BY_HANDLE_FILE_INFORMATION
711 This is the data type for specifying information about files as objects
712 of the file system. It contains the following members:
714 @item int dwFileAttributes
715 @cindex file attributes in file information
716 @cindex attributes of file in file information
717 @xref{File attributes}, for details.
718 @item FILETIME ftCreationTime
719 @cindex creation time in file information
720 @cindex time of file creation in file information
721 The time when the file was created.
722 @xref{Type FILETIME}, for details.
723 @item FILETIME ftLastAccessTime
724 @cindex access time in file information
725 @cindex time of file access in file information
726 The time when the file was last accessed.
727 @xref{Type FILETIME}, for details.
728 @item FILETIME ftLastWriteTime
729 @cindex write time in file information
730 @cindex time of last file write in file information
731 The time when the file was last written to.
732 @xref{Type FILETIME}, for details.
733 @item int dwVolumeSerialNumber
734 @cindex serial number of volume in file information
735 @cindex volume number (serial) in file information
736 The serial number of the volume containing the file. In Wine,
738 @item int nFileSizeHigh
739 @cindex file size in file information
740 @cindex size of file in file information
741 A 32 bit value which contains the high part of the 64 bit file size.
742 @item int nFileSizeLow
743 A 32 bit value which contains the low part of the 64 bit file size.
744 @item int nNumberOfLinks
745 @cindex hard links number in file information
746 @cindex links (number of hard) in file information
747 This is the number of hard links to the file. In a file system which
748 does not support hard links, this is 1.
749 @item int nFileIndexHigh
750 @cindex inode number in file information
751 @cindex file index in file information
752 @cindex index of file in file information
753 A 32 bit value which contains the high part of the 64 bit file
754 index. The file index is a unique number for a file on a volume.
755 This identifier cannot change while the file is opened by a process.
756 Together with the volume number, the file index is a unique
757 identifier for the file. This can be used by an application to check
758 whether two handles refer to the same file. Wine currently uses the
759 inode number for the file index.
760 @item int nFileIndexLow
761 A 32 bit value which contains the low part of the 64 bit file index.
764 The definition of @code{BY_HANDLE_FILE_INFORMATION} reads:
768 int dwFileAttributes;
769 FILETIME ftCreationTime;
770 FILETIME ftLastAccessTime;
771 FILETIME ftLastWriteTime;
772 int dwVolumeSerialNumber;
778 @} BY_HANDLE_FILE_INFORMATION ;
781 The @code{BY_HANDLE_FILE_INFORMATION} structure can be obtained by the
782 @code{GetFileInformationByHandle} function (@pxref{Getting file information}, for
786 In @mswindows{}, the @code{int} elements of the structure are apparently
787 of type @code{DWORD}.
790 @node File attributes, Getting file information, Type BY_HANDLE_FILE_INFORMATION, File System Interface
791 @subsubsection The file attributes in a file information structure
793 The file attributes in a file information structure and in other structures
794 are a logical @emph{or} of one or more of the following constants:
796 @defvr_cw32 FILE_ATTRIBUTE_READONLY
797 The file is a read-only file. (Wine value: 0x0001).
799 @defvr_cw32 FILE_ATTRIBUTE_HIDDEN
800 The file is a hidden file. Files in Wine do not have this attribute. (Wine value:
803 @defvr_cw32 FILE_ATTRIBUTE_SYSTEM
804 The file belongs to the operating system. Files in Wine do not have this
805 attribute. (Wine value: 0x0004).
807 @defvr_cw32 FILE_ATTRIBUTE_LABEL
808 This is not present in the @mswindows{} API. (Wine value: 0x0008).
810 @defvr_cw32 FILE_ATTRIBUTE_DIRECTORY
811 The file is a directory. (Wine value: 0x0010).
813 @defvr_cw32 FILE_ATTRIBUTE_ARCHIVE
814 The file is an archive file. Currently, all non-directory files are
815 reported by Wine to have this attribute. This attribute is normally set
816 by @mswindows{} to indicate that a file is to be archived; when the file
817 is archived, the flag is cleared. (Wine value: 0x0020).
819 @defvr_cw32 FILE_ATTRIBUTE_NORMAL
820 The file does not have any other attributes set. This value must be used
821 alone. In Wine, normal files are reported as archive files. (Wine value:
824 @defvr_cw32 FILE_ATTRIBUTE_TEMPORARY
825 The file is used as a temporary storage. Files in Wine do not have this
826 attribute. (Wine value: 0x0100).
828 @defvr_cw32 FILE_ATTRIBUTE_ATOMIC_WRITE
829 This is reserved for future use. Files in Wine do not have this
830 attribute. (Wine value: 0x0200).
832 @defvr_cw32 FILE_ATTRIBUTE_XACTION_WRITE
833 This is reserved for future use. Files in Wine do not have this
834 attribute. (Wine value: 0x0400).
836 @defvr_cw32 FILE_ATTRIBUTE_COMPRESSED
837 The file is compressed. Files in Wine do not have this attribute. (Wine
841 @node Getting file information, , File attributes, File System Interface
842 @subsubsection Getting file information
844 The functions in this section describe how to get information about
848 @c *** GetFileInformationByHandle
851 The Wine function @code{GetFileInformationByHandle} returns a file
852 information structure. It is defined in @file{windows.h}.
854 @deftypefn_w32 BOOL GetFileInformationByHandle (@w{HFILE32 @var{file},} @w{BY_HANDLE_FILE_INFORMATION *@var{info})}
855 This function obtains for the specified @var{file} the file information,
856 and stores it in @var{info}. The file information contains the file
857 attributes, the file times, the volume serial number, the file size, the
858 number of links, and a unique file identifier. The function returns
859 @code{TRUE} on success, @code{FALSE} on failure.
864 The Wine function can of course only give back information that is
865 accessible in the @unix{} file system. File times are produced in a
866 granularity of full seconds. Most file attributes are not present in the
867 @unix{} file system. @xref{File attributes}, for details. The volume
868 serial number is set to 0.
873 @c *** GetFileTime ***
876 The Wine function @code{GetFileTime} returns the creation time and
877 the times of last the read and modification access to a file. It is
878 defined in @file{windows.h}.
880 @deftypefn_w32 BOOL GetFileTime (@w{HANDLE @var{file},} @w{LPFILETIME @var{ctime},} @w{LPFILETIME @var{atime},} @w{LPFILETIME @var{mtime})}
881 This function obtains for the specified @var{file} the creation time
882 @var{ctime}, the time of the last access to the file @var{atime}, and
883 the time of the last modification (write) to the file, @var{mtime}.
884 The file time arguments of this function are pointers to @code{FILETIME}
885 variables, which are filled with a value that indicates an absolute time
886 in UTC. @xref{Type FILETIME}, for details. If you do not need some of
887 the times, you can pass a @code{NULL} pointer.
888 The function returns @code{TRUE} on
889 success, @code{FALSE} on failure.
894 The file times are produced in a granularity of full seconds, due to the
895 underlying @unix{} file system.
899 @c *** GetFileAttributes ***
902 The Wine function @code{GetFileAttributes} returns the file attributes
903 for a file. It is defined in @file{windows.h}.
905 @deftypefn_w32 DWORD GetFileAttributes (@w{LPCTSTR @var{name})}
906 This function looks up the file with name @var{name}, and returns the
907 attributes of the file. @xref{File attributes}, for details on the file
908 attributes. If the function is not successful, it returns a word with
909 all bits set (@samp{0xffffffff}).
914 Most file attributes are not present in the
915 @unix{} file system. @xref{File attributes}, for details.
921 @node Communication, Windows and Graphics, I/O Facilities, @WIN32{} Reference Manual
922 @section Communication
924 @node Windows and Graphics, Errors and Exceptions, Communication, @WIN32{} Reference Manual
925 @section Windows and Graphics
927 @node Errors and Exceptions, Resources, Windows and Graphics, @WIN32{} Reference Manual
928 @section Errors and Exceptions
930 @node Resources, The Registry, Errors and Exceptions, @WIN32{} Reference Manual
933 @node The Registry, Dynamic Link Libraries, Resources, @WIN32{} Reference Manual
934 @section The Registry
936 @node Dynamic Link Libraries, , The Registry, @WIN32{} Reference Manual
937 @section Dynamic Link Libraries (DLL's)
939 This section deals with API functions for handling DLL's (dynamic link
940 libraries). It does not describe DLL's themselves; nor does it give
941 information on how Wine handles DLL's. @xref{The build program}, for
942 information on how DLL's are integrated into Wine.
947 @node Resources and INI files, Metafiles--Icons--Bitmaps, @WIN32{} Reference Manual, Reference Manual
948 @chapter Resources and @file{INI} Files
950 @node Metafiles--Icons--Bitmaps, Debugging, Resources and INI files, Reference Manual
951 @chapter Metafiles --- Icons --- Bitmaps
953 @node Debugging, Programs, Metafiles--Icons--Bitmaps, Reference Manual
956 @node Programs, Tools, Debugging, Reference Manual
959 @node Tools, , Programs, Reference Manual
962 This chapter describes some of the tools that are used by Wine. These
963 are not user-level programs which the user of Wine will
964 run. @xref{Programs} for such programs.
966 Tools are internal programs that are used to help compile or configure
970 * The build program:: A program used to build the DLL entry
971 points from specifications in @file{if1632/}.
975 @node The build program, , , Tools
976 @section The @file{build} program
978 @cindex modules of Wine
980 @cindex DLL's built-in in Wine
981 @cindex Wine DLL's built-in
982 @cindex built-in DLL's in Wine
983 Wine contains several modules that implement various DLL's which are
984 required to run @mswindows{} programs.
986 The @file{build} program, located in the @file{tools/} directory, is
987 used to create the bindings for the DLL entry points of the API functions.
988 This program reads a @file{.spec}-file in the @file{if1632} directory
989 and creates the assembly code that translates the function arguments
994 * The spec files:: The format of the @file{.spec}-files.
997 FIXME: where in Wine are the DLL's affixed?
999 FIXME: write a description
1001 @xref{Implementing an API function}, for notes on using this program.
1003 @node The spec files, , , The build program
1004 @subsection The @file{.spec}-files
1005 @cindex DLL spec files
1006 @cindex spec files of DLL's
1007 @cindex entry points in DLL's
1009 This subsection describes the format of the @file{.spec}-files.
1011 A @file{.spec}-file contains the information about the functions,
1012 variables, and constants that are contained in a DLL (dynamic link
1015 To be able to interpret the contents of a @file{.spec}-file, you must
1016 know about the concept of ordinals.
1018 * The general format:: General format conventions.
1019 * Ordinals:: Ordinals are indexes of entry
1021 * Spec file header:: The header information.
1022 * Variable entry points:: Entries for DLL variables.
1023 * Function entry points:: Entries for DLL functions.
1024 * Special entries:: Entries for stubs, dummy
1025 functions, Wine symbols, and
1029 @node The general format, Ordinals, , The spec files
1030 @subsubsection The general format
1031 @cindex format of spec files
1032 @cindex spec files format
1034 The @file{.spec}-file contains a header and a sequence of declarations.
1035 Each declaration describes an ordinal.
1037 The header gives general information about the DLL and its properties.
1039 Ordinal declarations are optional. That means that there is a default
1040 behaviour assigned to ordinals which are not mentioned in the
1041 @file{.spec}-file. The default handler function of an ordinal will print
1042 an error message when called.
1044 Comments are indicated by hash marks (@samp{#}); everything between a
1045 hash mark and the end of the line is ignored.
1047 Empty lines are allowed.
1048 @* FIXME: is that so?
1050 @node Ordinals, Spec file header, The general format, The spec files
1051 @subsubsection Ordinals
1052 @cindex ordinals in DLL's
1053 @cindex DLL ordinals
1055 All references to DLL objects like functions or variables are indexed by
1056 unique nonnegative numbers. These numbers are called
1057 @dfn{ordinals}. Apparently, a program can refer to a DLL function or
1058 variable by specifying its name or its ordinal. Although reference by
1059 name is the common usage, some program parts (notably DLL's themselves)
1060 sometimes refer to DLL entries by ordinal. Therefore, the ordinals
1061 cannot be chosen arbitrarily.
1063 Regular programs that are compiled and linked against @mswindows{} DLL's
1064 will import DLL functions by name. This is therefore the default
1065 behaviour. Most DLL functions will be imported by name in all cases.
1066 Apparently, the @WIN32{} DLL's even show some difference in the mapping
1067 of functions and ordinals on @WINNT{} and @WIN95{}. For most DLL
1068 functions, the ordinal number will not matter.
1070 There are some exceptions to that. Notable the KERNEL32 ordinals below
1071 100 are (presently) unnamed and undocumented functions which can only be
1072 imported by ordinal. These functions are called by some @mswindows{}
1073 programs. Also the @file{shell32.dll} functions are reported to be
1074 imported by ordinal in some other DLL's.
1076 @xref{Getting information on the API}, for sources of further information.
1078 @node Spec file header, Variable entry points, Ordinals, The spec files
1079 @subsubsection The header of a @file{.spec}-file
1081 The @file{.spec}-file starts with two mandatory definitions. The first
1082 line gives the name of the DLL which the @file{.spec}-file describes,
1086 where @var{NAME} is the name of the DLL. The next line defines the type
1091 with @var{TYPE} being either @samp{win16} or @samp{win32}.
1093 An optional statement of the form
1097 can be used to define the offset of the first ordinal. @var{ORDINAL}
1098 must be an integer number. If no base is specified, the offset is zero.
1099 @* FIXME: is this the offset of the first or an offset that is added to all
1101 what is the offset? Is it added to the ordinals, or is it an address, or
1104 An optional statement like
1108 can be used to define the size of the module local heap. This is only
1109 used for @WIN16{} DLL's. The local heap is the place where the segments
1110 of 16 bit programs can locally allocate memory, without interfering with
1111 one another. The default size of the local heap, if not specified, is 0.
1113 @* FIXME: to my impression, a local heap in DLL's would only be required
1114 if DLL functions used it. As all DLL functions in Wine are truly 32 bit
1115 functions that are mapped from 16 bit on being called and back to 16 bit
1116 on returning, a local heap should never be necessary.
1117 If I receive a confirmation of that here, I will state so. Otherwise I
1118 am missing some information on local heaps.
1119 But why is a heap defined in user.spec and gdi.spec?
1121 @node Variable entry points, Function entry points, Spec file header, The spec files
1122 @subsubsection Variable entry points of @file{.spec}-files
1124 You can declare an ordinal that holds data. Data items may be of 8, 16,
1128 @var{ORDINAL} @var{VARTYPE} @var{EXPORTNAME} (@var{DATA} @var{[DATA @dots{}]})
1131 @var{ORDINAL} is the ordinal number corresponding to the
1132 variable. @var{VARTYPE} must be @samp{byte}, @samp{word}, or
1133 @samp{long}, for 8, 16, or 32 bits respectively. @var{EXPORTNAME} will
1134 be the name available for dynamic linking. @var{DATA} can be a decimal
1135 number or a hex number preceded by @samp{0x}. Each @var{DATA} item defines
1138 The following example defines the variable @samp{VariableA} at ordinal
1139 2, containing 4 bytes:
1141 2 byte VariableA(-1 0xff 0 0)
1145 @node Function entry points, Special entries, Variable entry points, The spec files
1146 @subsubsection Function entry points of @file{.spec}-files
1149 @var{ORDINAL} @var{FUNCTYPE} @var{EXPORTNAME} (@var{[ARGTYPE} @dots{} @var{]}) @var{HANDLERNAME}
1152 @var{ORDINAL} is the ordinal number corresponding to the
1153 function. @var{FUNCTYPE} must be chosen from this table:
1156 A @WIN16{} function that returns a 16 bit value.
1158 A @WIN16{} function that returns a 32 bit value.
1160 A function using CPU registers to pass arguments.
1162 A normal @WIN32{} function. @xref{Investigating the undocumented API},
1163 for an explanation of the stdcall calling convention.
1165 A @WIN32{} function using the C calling conventions. (This is presently
1166 only used for the built-in functions of the C runtime system).
1169 @var{EXPORTNAME} specifies the name (prototype) available for dynamic
1172 @var{ARGTYPE} must be chosen from this table:
1175 An 8 bit argument. Can be used in @WIN16{} functions only.
1177 A 16 bit argument. Can be used in @WIN16{} functions only.
1179 A 32 bit argument. Can be used in @WIN16{} or @WIN32{} functions.
1181 A linear pointer, unsegmented. Can be used in @WIN16{} or @WIN32{}
1184 A linear pointer, unsegmented, pointing to a null-terminated string.
1185 Can be used in @WIN16{} or @WIN32{} functions.
1187 A signed 8 bit argument. Can be used in @WIN16{} functions only.
1189 A signed 16 bit argument. Can be used in @WIN16{} functions only.
1191 A signed 32 bit argument. Can be used in @WIN16{} or @WIN32{}
1194 A segmented pointer. Can be used in @WIN16{} functions only.
1196 A segmented pointer to a null-terminated string. Can be used in
1197 @WIN16{} functions only.
1200 @var{HANDLERNAME} is the name of the actual Wine function that will
1201 process the request in 32-bit mode.
1205 Here are some examples. The first example defines an entry point for the
1206 @code{CreateWindow()} call (the ordinal 100 is just an example):
1208 100 pascal CreateWindow(ptr ptr long s_word s_word s_word s_word
1209 word word word ptr) WIN_CreateWindow
1212 The second example defines an entry point for the @code{GetFocus()} call
1213 (again, the ordinal 100 is an example):
1215 100 pascal GetFocus() WIN_GetFocus()
1218 To declare a function that uses a variable number of arguments, specify
1219 the function as taking no arguments. In this special case, in @WIN32{}
1220 the called function will be passed a pointer to the first arg; in
1221 @WIN16{}, the args are available as @code{CURRENT_STACK16->args}.
1222 @* FIXME: create a reference here
1223 See the @code{wsprintf}* functions in @file{user.spec} and
1224 @file{user32.spec} for an example.
1226 Sometimes it is not known how many arguments an undocumented DLL
1227 function takes. @xref{Getting information on the API}, for some hints on
1228 how to proceed in such a case.
1230 @node Special entries, , Function entry points, The spec files
1231 @subsubsection Special entries of @file{.spec}-files
1233 The @file{.spec}-files offer the possibility to use some special
1234 entries. These entries are used for stubs (which allow linking for
1235 non-existing functions), dummy functions that do not perform any
1236 operations, Wine symbols that must be referenced directly, and constant
1240 @strong{Stub ordinals}
1242 This pseudo function type defines a stub function. It makes the name and
1243 ordinal available for dynamic linking, but will terminate execution with
1244 an error message if the function is ever called.
1247 @var{ORDINAL} stub @var{EXPORTNAME}
1250 @var{ORDINAL} is the ordinal number corresponding to the
1251 function. @var{EXPORTNAME} specifies the name (prototype) available for dynamic
1254 @strong{Return ordinals}
1256 This pseudo function type defines a function entry point whose handler
1257 should do nothing but return a value.
1259 @var{ORDINAL} return @var{EXPORTNAME} @var{ARGLENGTH} @var{RETVALUE}
1262 @var{ORDINAL} is replaced by the ordinal number corresponding to the
1263 function. @var{ARGLENGTH} is the number of bytes that need to be removed
1264 from the stack before returning to the caller. @xref{Investigating the
1265 undocumented API}, for an explanation of the stdcall calling convention.
1266 @var{RETVALUE} is the return value which will be passed back to the
1269 @strong{Extern ordinals}
1272 @var{ORDINAL} extern @var{EXPORTNAME} @var{SYMBOLNAME}
1274 This type defines an entry that simply maps to a Wine symbol
1275 (variable or function); @var{EXPORTNAME} will point to the symbol
1276 @var{SYMBOLNAME} that must be defined in C code. This type only works with
1280 @strong{Equate ordinals}
1283 @var{ORDINAL} equate @var{EXPORTNAME} @var{DATA}
1286 This type defines an ordinal as an absolute value.
1287 @var{ORDINAL} is replaced by the ordinal number corresponding to the
1288 entry. @var{EXPORTNAME} will be the name available for dynamic linking.
1289 @var{DATA} can be a decimal number or a hex number preceeded by @samp{0x}.
1292 @node Installation, The Wine Project, Reference Manual, Top
1293 @chapter Wine installation and configuration
1294 FIXME: write installation guide
1297 * Applying patches:: How to update Wine to a newer version.
1300 @node Applying patches, , , Installation
1301 @section Applying patches
1302 @xref{Creating patches}, for instructions on creating patches.
1304 @kbd{cd} to the top source directory for Wine, and run
1305 @code{patch -p1 < @var{patchfile}}.
1306 What needs to be done next depends to some extent on what the
1307 patch touches. For small patches which only alter C source, it can be
1308 enough to rerun @code{make}. In general, the sequence @code{configure},
1309 @code{make depend}, @code{make} is sufficient, unless the patch alters
1310 @code{[config.in]}, in which case you must regenerate @code{configure}
1311 via @code{make configure} (which just runs @code{autoconf}).
1314 @node The Wine Project, , Installation, Top
1315 @chapter The Wine project
1316 @cindex Wine project contributions
1317 @cindex project contributions to Wine
1319 If you are new to Wine and want to support this project, here are
1323 * Getting information on the API:: Official and unofficial sources
1324 of information on the @WIN32{} API.
1325 * Investigating the undocumented API:: You can find out some API
1326 information on your own.
1327 * Implementing an API type:: How to implement a data type
1328 of the API (a checklist).
1329 * Implementing an API function:: How to implement one function
1330 of the API (a checklist).
1331 * API function and type naming:: How to name API functions in Wine.
1332 * Creating patches:: How to create patches for Wine.
1333 * Adding Documentation:: Templates for the documentation.
1334 * File names:: How Wine treats @mswindows{} and
1336 * Wide character strings:: How Wine treats wide character
1340 @xref{Debugging}, for advice on how to debug Wine.
1341 @xref{Applying patches}, for instructions on applying patches.
1344 @node Getting information on the API, Investigating the undocumented API, , The Wine Project
1345 @section Official and unofficial documentation on the @mswindows{} API
1346 @cindex documentation of API functions
1347 @cindex undocumented API functions
1350 @strong{Official documentation}
1352 For documentation on @WIN32{} API functions, you might try one of these
1358 There is a free online version of the MSDN library (including
1359 documentation for the @WIN32{} API) on
1360 @url{http://www.microsoft.com/msdn/}.
1363 The @WINNT{} DDK gives information about some kernel (``executive'')
1364 routines. Some of the function documentation might also apply to user
1368 @strong{Unofficial documentation}
1370 Not all of the @WIN32{} API is well documented. Some functions are
1371 obscured, and undocumented. @xref{Ordinals}, for information about
1372 undocumented functions imported by ordinal. Getting to know what these
1373 functions do can be tiresome and tedious. Here is a quote from a
1374 news posting concerning two books that might help:
1375 @c From: vischne@ibm.net-nospam (root)
1376 @c Subject: Re: Functions
1377 @c Newsgroups: comp.emulators.ms-windows.wine
1378 @c Date: 24 Jul 97 16:45:11 GMT
1379 @c Organization: The Light
1380 @c NNTP-Posting-Host: 129.37.246.203
1381 @c Message-ID: <33d78697.0@news3.ibm.net>
1384 Well actually, there are at least _two_ books that address these problems.
1385 One is by Matt Pietrek, ``Windows 95 System Programming Secrets'', which
1386 gives some auxiliary programs for helping ferret out the information, and
1387 the other is by Shulman, ``Undocumented Windows 95''.
1390 @xref{Ordinals}, for some notes on undocumented kernel functions.
1395 @cindex book on undocumented API features by Pietrik
1396 ``Windows 95 System Programming Secrets'' @*
1398 Book & Disk Edition @*
1399 Paperback, 778 pages @*
1400 Published by IDG Books Worldwide @*
1401 Publication date: November 1, 1995 @*
1402 Dimensions (in inches): 9.25 x 7.42 x 2.06 @*
1406 @cindex book on undocumented API features by Schulman
1407 ``Undocumented Windows; A Programmers Guide
1408 to Reserved Microsoft Windows API Functions'' @*
1409 by Andrew Schulman @*
1410 Paperback, 715 pages @*
1411 Published by Addison-Wesley Pub Co @*
1412 Publication date: February 1, 1994 @*
1413 Dimensions (in inches): 9.11 x 7.37 x 1.53 @*
1417 More books on these topics (including Schulman and Pietrik): @*
1418 @url{http://www.sonic.net/~undoc/bookstore.html}
1421 More details about calling undocumented functions can be found at
1422 @url{http://ftp.uni-mannheim.de/info/OReilly/windows/win95.update/dirty.html}.
1425 In 1993 Dr. Dobbs Journal published a column called ``Undocumented
1428 You might want to check out BYTE from December 1983 as well.
1429 @* FIXME: is that to be taken seriously?
1431 And you might try to find out something on your own. @xref{Investigating
1432 the undocumented API}, for details.
1435 But, all in all, @url{news:comp.emulators.ms-windows.wine} says
1436 @c From: dacut@henry.ece.cmu.edu (David A. Cuthbert)
1437 @c Subject: Re: Getting Internet Explorer to work
1438 @c Newsgroups: comp.emulators.ms-windows.wine
1439 @c Date: 24 Jul 1997 03:10:30 GMT
1440 @c Organization: Electrical & Computer Engineering, Carnegie Mellon University
1441 @c Reply-To: henry.ece.cmu.edu!dacut
1442 @c Message-ID: <5r6h36$86c@fs7.ece.cmu.edu>
1443 @c NNTP-Posting-Host: henry.ece.cmu.edu
1446 Unfortunately, short of getting something like NuMega's SoftIce, I
1447 don't think there's a ``good'' reference on the mystery <100 ordinals in
1452 @node Investigating the undocumented API, Implementing an API type, Getting information on the API, The Wine Project
1453 @section Investigating the undocumented API
1454 @cindex undocumented API investigation
1455 @cindex parameters of undocumented API functions
1456 @cindex stdcall calling convention
1457 @cindex C calling convention
1458 @cindex API function parameters investigation
1459 @cindex stack handling under stdcall calling
1461 Besides reading the documentation in @ref{Getting information on the API},
1462 you can find out some properties of API functions on your own.
1464 Sometimes it is not known how many arguments an undocumented DLL
1465 function takes. Here is a text from a news posting that gives some
1466 hints on how you might proceed in this case.
1468 @c The following text is closely quoted from:
1469 @c From: dacut@henry.ece.cmu.edu (David A. Cuthbert)
1470 @c Subject: Win32 stub functions (Claus Fischer, please read)
1471 @c Newsgroups: comp.emulators.ms-windows.wine
1472 @c Date: 7 Aug 1997 22:33:09 GMT
1473 @c Organization: Electrical & Computer Engineering, Carnegie Mellon University
1474 @c Reply-To: henry.ece.cmu.edu!dacut
1475 @c Message-ID: <5sdif5$qt3@fs7.ece.cmu.edu>
1477 The problem with implementing stubs for @WIN32{} functions is that it is
1478 not sufficient to return a default value (usually 0) and leave the
1479 stack the way we found it. For most @WIN32{} functions -- those that use
1480 the @dfn{stdcall} calling convention -- the arguments sent to the function
1481 are removed from the stack.
1483 Some background: On the i386 class of machines, stack entries are
1484 usually dword (4 bytes) in size, little-endian. The stack grows
1485 downward in memory. The stack pointer, maintained in the @samp{esp}
1486 register, points to the last valid entry; thus, the operation of
1487 pushing a value onto the stack involves decrementing @samp{esp} and then
1488 moving the value into the memory pointed to by esp (i.e., @code{push p}
1489 in assembly resembles @code{*(--esp) = p;} in C). Removing (popping)
1490 values off the stack is the reverse (i.e., @code{pop p} corresponds to
1491 @code{p = *(esp++);}).
1493 In the @dfn{stdcall} calling convention, arguments are pushed onto the
1494 stack right-to-left. For example, the C call
1497 myfunction(40, 20, 70, 30);
1500 is expressed in Intel assembly as:
1510 In addition, the called function is responsible for removing the
1511 arguments off the stack. Thus, before the call to myfunction, the
1512 stack would look like:
1515 [local variable or temporary]
1516 [local variable or temporary]
1523 After the call returns, it should look like:
1526 [local variable or temporary]
1527 esp -> [local variable or temporary]
1530 To restore the stack to this state, the called function must know how
1531 many arguments to remove (which is the number of arguments it takes).
1532 This is a problem if the function is undocumented.
1534 One way to attempt to document the number of arguments each function
1535 takes is to create a wrapper around that function that detects the
1536 stack offset. @file{WinRelay} (see below) was written to create such
1537 wrappers. Essentially, each wrapper assumes that the function will take
1538 a large number of arguments (by default, 64 in @file{WinRelay}). The
1539 wrapper copies each of these arguments into its stack, calls the actual
1540 function, and then calculates the number of arguments by checking esp
1541 before and after the call.
1543 @cindex bsod (blue screen of death)
1544 @cindex blue screen of death
1545 The main problem with this scheme is that the function must actually
1546 be called from another program. Many of these functions are seldom
1547 used. An attempt was made to aggressively query each function in a
1548 given library (@file{ntdll.dll}) by passing 64 arguments, all 0, to each
1549 function. Unfortunately, @WINNT40{} quickly goes to a blue screen
1550 of death (@dfn{bsod}), even if the program is run from a
1551 non-administrator account.
1553 Another method that has been much more successful is to attempt to
1554 figure out how many arguments each function is removing from the
1555 stack. This instruction, @code{ret hhll} (where @samp{hhll} is the
1556 number of bytes to remove, i.e. the number of arguments times 4), contains
1557 the bytes @samp{0xc2 ll hh} in memory. It is a reasonable assumption
1558 that few, if any, functions take more than 16 arguments; therefore,
1559 @samp{hh} is 0x0 and @samp{ll} is less than 0x40. This utility,
1560 @file{MakeSpec} (see below), simply queries the address of a function
1561 and looks for the first occurrence of the bytes @samp{0xc2 ll 0x0},
1562 where @math{@samp{ll} <= 0x40}.
1564 Of course, this is not without errors. @code{ret 00ll} is not the only
1565 instruction that can have the byte sequence @samp{0xc2 ll 0x0}; for
1566 example, @code{push 0x000040c2} has the byte sequence
1567 @samp{0x68 0xc2 0x40 0x0 0x0}, which matches the above. Properly, the
1568 utility should look for this sequence only on an instruction boundary;
1569 unfortunately, finding instruction boundaries on an i386 requires
1570 implementing a full disassemble -- quite a daunting task. Besides,
1571 the probability of having such a byte sequence that is not the actual
1572 return instruction is fairly low.
1574 Much more troublesome is the non-linear flow of a function. For
1575 example, consider the following two functions:
1579 jmp somefunction1_impl
1588 @file{MakeSpec} would incorrectly list both @code{somefunction1} and
1589 @code{somefunction2} as taking only a single argument, whereas
1590 @code{somefunction1} really takes two arguments.
1592 With these limitations in mind, it is possible to implement more stubs
1593 in Wine and, eventually, the functions themselves.
1597 The program @file{WinRelay} can be downloaded from
1598 @url{http://www.ece.cmu.edu/afs/ece/usr/dacut/www/src},
1599 and @file{MakeSpec} will be available from the same location. You can
1600 compile them with Borland's C++Builder; you should not optimize when
1601 compiling (@file{WinRelay} needs the stack frames).
1604 @node Implementing an API type, Implementing an API function, Investigating the undocumented API, The Wine Project
1605 @section Implementing an API type
1607 Here is a checklist that should help you writing your first API type. It
1608 will of course not tell you which elements to put into the type
1609 (assuming it is a structure), but it should help you along the way of
1610 integrating this type into Wine.
1611 @xref{Implementing an API function}, for comparison.
1615 Find out how the type should be named in Wine and in the DLL's.
1616 @xref{API function and type naming}, for details.
1619 Find out where the type should go. Please try to keep the header files
1620 structure as similar to @mswindows{} as possible.
1623 Prepare for the later patch (by saving the original files before you
1624 work on them). @xref{Creating patches}, for details.
1627 Put the type declaration into the header file.
1630 Make sure the declaration is syntactically correct, i.e. it does not
1631 keep Wine from compiling.
1634 Make sure the declared type is layout-compatible with
1635 @mswindows{}-compiled types. Especially keep an eye on the packing of
1637 @* FIXME: a reference to packed structures here.
1640 Build Wine and test the type, if possible. If you cannot test the
1641 type by implementing a proper API function, write a small test program
1642 to test it on its own. Or rather stop here.
1645 Write the documentation of the type in the @file{wine.texinfo}
1646 file. @xref{Adding Documentation}, for details.
1647 With types, be especially careful and document all the details. Also
1648 document all constants or flags that are used in the type.
1651 Create an entry in the @file{ChangeLog} file.
1654 Collect some of these changes, and create a patch. @xref{Creating
1655 patches}, for details.
1658 Mail the patch to Alexandre Julliard, @email{julliard@@lrc.epfl.ch}.
1661 Wait for the patch to appear in the official distribution.
1665 @node Implementing an API function, API function and type naming, Implementing an API type, The Wine Project
1666 @section Implementing an API function
1668 Here is a checklist that should help you writing your first API
1669 function. It will of course not tell you what to do in the function,
1670 but it should help you along the way of integrating this function into
1675 Make sure all data types that appear in function arguments are properly
1676 declared in Wine. Otherwise, start with the data types.
1679 Find out how the function should be named in Wine and in the DLL's.
1680 @xref{API function and type naming}, for details.
1683 Find out what the function should do. This may be tricky for
1684 undocumented functions. @xref{Getting information on the API}, for some
1688 Find out where the function should go:
1691 Which header file for the prototype.
1693 Which C source file.
1695 Which DLL(s), and which ordinal the function will take there. Perhaps
1696 the function name is already present in one of the @file{.spec}-files in
1697 the @file{if1632} directory.
1701 Prepare for the later patch (by saving the original files before you
1702 work on them). @xref{Creating patches}, for details.
1705 Put the prototype into the header file, and the code into the C file.
1708 Make sure the code compiles.
1711 Create or change the information for the DLL entry points in the
1712 @file{.spec}-file in the @file{if1632} directory.
1713 @xref{The build program}, for details of the DLL spec files.
1716 Build Wine and test the function, if possible. If you cannot test the
1717 function in Wine, write a small test program to test it on its own.
1720 Write the documentation of the function in the @file{wine.texinfo}
1721 file. @xref{Adding Documentation}, for details.
1724 Create an entry in the @file{ChangeLog} file.
1727 Collect some of these changes, and create a patch. @xref{Creating
1728 patches}, for details.
1731 Mail the patch to Alexandre Julliard, @email{julliard@@lrc.epfl.ch}.
1734 Wait for the patch to appear in the official distribution.
1738 @node API function and type naming, Creating patches, Implementing an API function, The Wine Project
1739 @section API function and data type naming conventions
1740 @cindex API function names
1741 @cindex API type names
1742 @cindex names of API functions and types
1743 @cindex naming scheme for API functions and types
1744 @cindex suffixes for API functions and types
1745 @cindex endings of API function and type names
1747 This section describes Wine's naming scheme for API functions and data
1750 The purpose of these naming conventions is to ensure that
1753 both the @WIN16{} and @WIN32{} API are supported within the same source
1756 both wide character functions (with @unicode{} strings) and 8 bit
1757 character functions (with @ascii{} or extended @ascii{} encoding) are
1760 the source code can be shared between the emulator and the library
1764 A function or data type whose name in the @mswindows{} API is @var{xxx}
1765 will in the Wine code have the following name(s):
1768 This is the version for the 16 bit API. You might call it the ``16 bit
1769 version'' except that the function itself of course runs in true 32 bit
1770 mode (being part of Wine). So, the correct meaning of the suffix is that
1771 this function is part of the 16 bit API.
1773 This is the version for the 32 bit API. Use this suffix only if the
1774 function does not use character strings in its parameters or return
1775 values. Otherwise use the next two.
1777 This is the version for the 32 bit API which uses @ascii{} strings (or
1778 rather, strings with 8 bit character encodings, i.e. the standard C
1779 @code{char} type). This version always goes together with another
1780 version, using the next suffix.
1782 This is the version for the 32 bit API which uses @unicode{} strings,
1783 i.e. strings with wide characters. It goes together with the @ascii{}
1787 So, where the @mswindows{} API offers one name, Wine actually has two or
1788 three different functions implemented (which will hopefully share a
1789 large part of the code).
1791 Wine allows to use its API functions in two ways. The emulator part of
1792 Wine provides DLL's for the @mswindows{} programs it can run. The
1793 library part of Wine provides a @unix{} programmer with the facility to
1794 use the Wine API's in a standard @unix{} program.
1797 * Access from the emulator:: How to access API functions and types
1798 from applications that are run in the
1800 * Access in the library:: How to access API functions and types
1801 from applications that are linked with
1803 * Access from inside Wine:: How to access API functions and types
1804 from inside the Wine code.
1807 @node Access from the emulator, Access in the library, , API function and type naming
1808 @subsection Accessing API functions and types from the emulator
1809 @cindex access to DLL API functions and types
1810 @cindex Wine emulator access to API functions and types
1811 @cindex emulator access to Wine API functions and types
1813 The emulator part of Wine provides the hooks for dynamically linking the
1814 API functions to the @mswindows{} executables (@file{.EXE}-files). The
1815 Wine emulator contains all versions (16 or 32 bit, @ascii{} or
1816 @unicode{}) of the API functions in one executable. The emulator
1817 performs a mapping from the @mswindows{} name of the function,
1818 by which the executable calls it, to one of the Wine internal names that
1819 have been used in coding it.
1821 This mapping is done by the built-in DLL handling code of Wine. A
1822 programmer of Wine has to declare the function in one of the virtual
1823 DLL's that are provided by Wine. The declarations are done in the
1824 @file{.spec}-files in the @file{if1632/} directory. @xref{The build
1825 program}, for details.
1827 The @mswindows{} application simply calls the API function by its
1828 standard @mswindows{} name. Wine will apply the correct mapping
1829 according to Wine's selected appearance (as a 16 bit or 32 bit emulator,
1830 which is a parameter on invocation of Wine).
1833 @node Access in the library, Access from inside Wine, Access from the emulator, API function and type naming
1834 @subsection Accessing API functions and types in the library
1835 @cindex Wine library API function and type access
1836 @cindex access to Wine library API functions and types
1838 If Wine is built as a library, and linked to a user-level main program,
1839 the user will also use the standard @mswindows{} names for the API
1842 Some macros are defined in @file{include/wintypes.h} which perform the
1843 necessary name mappings.
1845 These macros are (see the examples below):
1846 @deffn_winemacro WINELIB_NAME (@var{xxx})
1847 This macro replaces @var{xxx} by one of @var{xxx}16 or
1848 @var{xxx}32, depending on the definition of the symbols
1849 @code{WINELIB16} and @code{WINELIB32}. @var{xxx} should
1850 be the name of an API function that uses no string arguments.
1851 Use this macro with a @code{#define} to establish the API name @var{xxx}.
1853 @deffn_winemacro WINELIB_NAME_AW (@var{xxx})
1854 This macro replaces @var{xxx} by one of @var{xxx}16, @var{xxx}32A, or
1855 @var{xxx}32W, depending on the definition of the symbols
1856 @code{WINELIB16}, @code{WINELIB32}, and @code{UNICODE}. @var{xxx} should
1857 be the name of an API function that uses string arguments.
1858 Use this macro with a @code{#define} to establish the API name @var{xxx}.
1860 @deffn_winemacro DECL_WINELIB_TYPE (@var{xxx})
1861 This macro declares @var{xxx} to be an equivalent to @var{xxx}16 or
1862 @var{xxx}32, depending on the definition of the symbols
1863 @code{WINELIB16} and @code{WINELIB32}. @var{xxx} should
1864 be the name of an API data type that contains no string arguments.
1866 @deffn_winemacro DECL_WINELIB_TYPE_AW (@var{xxx})
1867 This macro declares the type @var{xxx} to be an equivalent to
1868 @var{xxx}16, @var{xxx}32A, or @var{xxx}32W, depending on the definition
1869 of the symbols @code{WINELIB16}, @code{WINELIB32}, and
1870 @code{UNICODE}. @var{xxx} should be the name of an API data type that
1871 contains string arguments.
1874 If Wine is compiled as an emulator, these macros have no effect, for the
1875 mapping is then done by the DLL code. This means that within Wine the
1876 name @var{xxx} itself will not be defined.
1878 Note: If the definition of @var{xxx} is exactly the same in @WIN16{} and
1879 @WIN32{}, you can simply use the same name as @mswindows{}.
1881 Here are some examples:
1883 /* A simple type without strings */
1884 typedef short INT16;
1886 DECL_WINELIB_TYPE(INT);
1888 /* A type with strings */
1889 typedef struct @{ /* Win32 ASCII data structure */ @} WNDCLASS32A;
1890 typedef struct @{ /* Win32 Unicode data structure */ @} WNDCLASS32W;
1891 typedef struct @{ /* Win16 data structure */ @} WNDCLASS16;
1892 DECL_WINELIB_TYPE_AW(WNDCLASS);
1894 /* A function with strings */
1895 ATOM RegisterClass16( WNDCLASS16 * );
1896 ATOM RegisterClass32A( WNDCLASS32A * );
1897 ATOM RegisterClass32W( WNDCLASS32W * );
1898 #define RegisterClass WINELIB_NAME_AW(RegisterClass)
1901 The Winelib user can then say (in the application program):
1904 WNDCLASS wc = @{ @dots{} @};
1905 RegisterClass( &wc );
1907 and this will use the correct declaration depending on the definitions
1908 @code{WINELIB16}, @code{WINELIB32}, and @code{UNICODE}.
1910 Here are the primary defines that are used when Wine is compiled as a
1912 @defvr_cwine WINELIB16
1913 If this @code{#define} is set, the Wine library is to be compiled in its
1914 16 bit form. That means, the 16 bit variants of all functions will be
1915 used and the appearance of the application linked with the Wine library
1916 will be that of a 16 bit application. Of course, both the application
1917 and the Wine library function really run in 32 bit mode. The switch only
1918 selects the function with the name ending in @code{@dots{}16}, which
1919 will perhaps have a behaviour different from its 32 bit counterpart.
1921 @defvr_cwine WINELIB32
1922 If this @code{#define} is set, the Wine library is to be compiled in its
1923 32 bit form. That means, the 32 bit variants of all functions will be
1924 used and the appearance of the application linked with the Wine library
1925 will be that of a 32 bit application.
1927 @defvr_cwine UNICODE
1928 This @code{define} is used to select one of two possible 32 bit
1929 variants. Functions and data types of the 32 bit API come in two
1930 flavours: one handling @ascii{} strings (or rather strings with
1931 characters encoded in 8 bit), the other @unicode{} strings. This define
1932 selects the correct variant. As a user of the Wine library, you are
1933 responsible to use the correct character type in your part of the
1934 application which accesses the Wine API functions and data types.
1937 These switches are automatically set when Wine is compiled as a library.
1940 @node Access from inside Wine, , Access in the library, API function and type naming
1941 @subsection Accessing API functions from within Wine
1942 @cindex explicit names of API functions and types
1944 Within Wine and during the compilation of Wine, you cannot rely on the
1945 @mswindows{} names of the API functions and data types. If Wine is
1946 compiled as a library, they will be defined; if Wine is compiled as an
1947 emulator, they won't.
1949 You therefore have to access all functions and data types by their full
1950 names, with the proper suffix explicitly appended. In Wine, the 16 bit
1951 and 32 bit versions of the functions are distinct entities, which might
1952 (theoretically) show a completely different behaviour. They may even
1953 call each other (and they will quite frequently).
1955 Therefore Wine is a conglomerate that contains all two or
1956 three flavours of each function at once, and exports to the
1957 application whichever of these is appropriate. Remember that inside
1958 Wine, there is no memory segmentation, so all functions are 32 bit.
1959 The 16-to-32 bit mapping is done on exporting the DLL functions.
1962 @node Creating patches, Adding Documentation, API function and type naming, The Wine Project
1963 @section Creating patches
1964 @xref{Applying patches}, for instructions on applying patches.
1966 Patches are created with the program @code{diff}. You need a copy
1967 of clean source tree to diff against. The @samp{-u} option, to create
1968 unified diffs, is popular but not obligatory.
1969 For changes to a single file,
1970 @code{diff -u wine990101/windows/win.c mywine/windows/win.c > win_patch}
1972 To generate a complete diff between your tree and the distribution,
1973 use @code{diff -uR wine990101 mywine}.
1975 This assumes that the original distribution and your personal tree
1976 have the same parent directory, from which you make the diff.
1977 This ensures a consistent format for the diffs, which in turn
1978 is necessary so that they can be applied consistently as described in
1979 @xref{Applying patches}.
1981 @node Adding Documentation, File names, Creating patches, The Wine Project
1982 @section Adding Documentation
1985 Here are some templates which should help you collaborate on this
1986 documentation. Read the text below before examining them.
1990 * Type Template:: How to document data types in Wine's
1992 * Function Template:: How to document an (API) function of
1997 These are my tips for adding documentation.
1999 Do not simply copy documentation from @mswindows{} related
2000 material. Except from risking copyright violations, which you would not
2001 want to do, there is another aspect to that:
2002 As Wine is a product to run on @unix{} and @unix{}-like workstations,
2003 it seems a good idea to me to organize this documentation primarily for
2004 the well-trained @unix{} reader. Please keep that in mind when you add
2007 Finally, read the info pages for @code{texinfo}.
2009 The rest of this section provides some templates which can serve as a
2010 start in writing documentation.
2012 @subsection Template introduction
2014 On the following pages you will find some @code{texinfo} templates, which
2015 should help you collaborate on this documentation.
2018 These templates give hints on how to document data types, functions,
2019 variables, constants etc. in Wine.
2020 As documentation evolves, you will find common features of data types
2021 that should be described in a unified fashion. In such a case, please
2022 add a corresponding style guide-line here, in this very place, to help
2023 keeping documentation of data types unified.
2026 Start out the type or function with a new node. Write a comment before
2027 the node, listing all data types (and functions) described in the node,
2031 @@c *** struct FILETIME ***
2033 @@node Type FILETIME, NextNodeName, PreviousNodeName, ParentNodeName
2036 The node command describes the node name and the names of the next node,
2037 the previous node, and the parent node. The parent node should contain
2038 a menu entry for this node. The previous node is the node that appears
2039 before this node in the parent node menu. The next node is the node
2040 succeeding this one in the parent node menu. If there is no previous or
2041 next node, omit the name (putting just a single space between the two
2044 The node name must be a unique sequence of words. Case is important, so
2045 @emph{Type} and @emph{type} are distinct. The node name must not contain
2046 special characters like @samp{@@, @{, @}} or the comma. If you need to
2047 give a node the same name as a function, data type, etc., use the words
2048 @samp{Type}, @samp{Function}, etc. before the identifier.
2050 Always put the names of the node and its links on the same line, even if
2051 it gets rather long.
2053 If there are two or more data types or functions described in the node,
2054 adapt the comment like this:
2058 @@c *** long Y() ***
2060 @@node Ints and Longs, NextNodeName, PreviousNodeName, ParentNodeName
2063 After the node name, put a sectioning command, such as @samp{@@chapter},
2064 @samp{@@section}, @samp{@@subsection}, or @samp{@@subsubsection}.
2065 Without that command, cross references to the node will fail.
2067 @@subsubsection Type FILETIME
2070 Start the description of the type(s) or function(s) with a single
2071 non-indented paragraph that gives a one-line description of the type(s)
2072 or function(s) and states the include files that are required.
2075 File times in Wine are specified by the data type @@code@{FILETIME@},
2076 defined in @@file@{windows.h@}.
2078 If several types or functions are closely connected, use one paragraph
2079 as a common description. If more paragraphs are required for a proper
2080 description, indent all but the first of them.
2082 Then start the definition of the data type or function. Use the proper
2083 macro, which you will find defined in the beginning of the texinfo file.
2084 If appropriate, add your own macros.
2085 Again, put everything that belongs to the header into a single line.
2086 Use continuation lines for additional headers.
2088 @@deftp_w32 FILETIME
2089 @@deftpx_w32 LPFILETIME
2092 In the definition, give a verbal explanation of the data type or
2093 function. The explanation should be rather complete, exact, and
2094 comprehensible, than well-structured. This is the point where you can
2095 tell everything you want. Do not be afraid of wasting space.
2096 Do not describe the @mswindows{} situation but only say what Wine
2097 does. That is important. (Sometimes they might even do the same.)
2099 This is the data type for specifying file times. The file times are
2100 stored with 64 bit precision. The actual data type is a structure with
2101 two 32 bit values which are interpreted as the low and high parts of a
2102 64-bit value. This value gives a time measured in a granularity of 100
2103 nanoseconds, so 1.5 seconds are specified by a value of 15,000,000. In
2104 Wine, this 64-bit value is signed, with the sign taken from the high
2105 part. The lower part is used as unsigned.
2108 For data types, it is recommended to quote the definition from the
2109 header file. For a function, you might give a short example of its
2110 usage. You may also put one example in the end of a node that explains
2111 several of the functions in the node. Remember that cut-and-paste from a
2112 well prepared example will help the readers write their code.
2114 The definition of @@code@{FILETIME@} reads:
2118 INT32 dwLowDateTime;
2119 INT32 dwHighDateTime;
2120 @@@} FILETIME, *LPFILETIME;
2124 You could also use the @code{cindex} command which creates an entry in
2125 the concept index. The @code{texinfo} manual recommends to keep concept
2126 entries distinct, so that a single concept index entry puts to one
2127 well-defined place in the document. Use lower case letters for index
2128 entries, unless they are proper names or quotes from actual code.
2130 @@cindex epoch in file time
2131 The @@code@{FILETIME@} structure may be used to hold absolute or relative
2132 times. Absolute times are given as the number of 100 nanoseconds
2133 intervals elapsed since 1 January 1601, 00:00:00 UTC (Coordinated
2134 Universal Time, which is GMT, Greenwich Mean Time). This might be
2135 called the @@dfn@{epoch@} for file times. With a signed 64-bit value, this
2136 representation covers absolute times of 29247 years around the epoch.
2139 After the verbal documentation, you can add some special fields
2140 describing bugs, implementation dependencies etc. Two of these are
2141 recommended to attach to all descriptions. One describes the
2142 conformance of the data type or function to @mswindows{} products,
2143 i.e. whether the item is also present in @WINNT{} and @WIN95{}. The
2144 other one describes known differences of the Wine item to its
2145 @mswindows{} counterpart. Both will greatly help in porting software
2146 from @mswindows{} to Wine and vice versa.
2151 In @@mswindows@{@}, the elements of the structure are apparently of type
2152 @@code@{DWORD@}. Whether the full 64 bit value is interpreted as signed or
2153 unsigned I do not know.
2156 If you find that more of these property attributes are necessary, feel
2157 free to create your own ones. But keep in mind that they should be
2158 applicable more or less to all described items. Very special properties
2159 will better be put into the verbal text.
2161 Finally end the definition of the data type or function:
2166 Do not forget to enter the node in the menu of its top node, and do
2167 properly link the node to its successor and predecessor.
2174 @node Type Template, Function Template, , Adding Documentation
2175 @subsection Data type template
2179 @node Function Template, , Type Template, Adding Documentation
2180 @subsection API function template
2182 Functions should be given category names, to indicate which API they
2183 belong to. Please add items to the list of categories possible.
2185 Category: WIN32 function
2189 @@c ***GetFileTime() ***
2191 @@node Get File Times, , Compare File Times, File Times
2193 The Wine function @@code@{GetFileTime@} returns the creation time and
2194 the times of last the read and modification access to a file. It is
2195 defined in @@file@{windows.h@}.
2197 @@deftypefn_w32 BOOL GetFileTime (@@w@{HANDLE @@var@{file@},@} @@w@{LPFILETIME @@var@{ctime@},@} @@w@{LPFILETIME @@var@{atime@},@} @@w@{LPFILETIME @@var@{mtime@})@}
2198 This function obtains for the specified @@var@{file@} the creation time
2199 @@var@{ctime@}, the time of the last access to the file @@var@{atime@}, and
2200 the time of the last modification (write) to the file, @@var@{mtime@}.
2201 The @@var@{file@} handle must have been obtained by opening the file with
2202 @@code@{GENERIC_READ@} access. The file time arguments of this function are
2203 pointers to @@code@{FILETIME@} variables, which are filled with a value that
2204 indicates an absolute time in UTC. To convert these values to local
2205 times, use the function @@code@{FileTimeToLocalFileTime@}. If you do not
2206 need some of the times, you can pass a @@code@{NULL@} pointer.
2207 The function returns @@code@{TRUE@} on success, @@code@{FALSE@} on failure.
2216 @node File names, Wide character strings, Adding Documentation, The Wine Project
2217 @section @mswindows{} and @unix{} file names in Wine
2218 @cindex file names in Wine
2219 @cindex Windows file names
2220 @cindex DOS file names in Wine
2221 @cindex UNIX file names in Wine
2222 @cindex POSIX file names in Wine
2226 @node Wide character strings, , File names, The Wine Project
2227 @section Wide character strings in API functions
2228 @cindex unicode strings in API functions
2229 @cindex wide character strings in API functions
2230 @cindex strings in API functions
2231 @cindex ascii strings in API functions
2232 @cindex 16 bit characters in API functions
2233 @cindex wchar_t in API functions
2235 Presently, all wide character strings in API functions of Wine are
2236 internally converted to 8 bit representation. Thus, the @WIN32{} API
2237 with @unicode{} strings is not fully functional for the application
2238 programmer at present.
2240 Even so, application programmers might consider developing their
2241 applications in wide character format with Wine, as future versions
2242 might bring a change. This might come when a @unix{} filesystem can
2243 handle @unicode{} file names.
2245 Furthermore, the @unicode{} API is required to let Wine run @mswindows{}
2246 applications which have been compiled for wide character strings.
2248 In Wine, wide characters are strictly 16 bit; the @code{wchar_t} type of
2249 standard C can therefore not be used.
2251 @node Concept Index, , , Top
2252 @comment node-name, next, previous, up
2253 @unnumbered Concept Index
2256 @node Type Index, , , Top
2257 @comment node-name, next, previous, up
2258 @unnumbered Type Index
2261 @node Function Index, , , Top
2262 @comment node-name, next, previous, up
2263 @unnumbered Function Index
2266 @node Variable Index, , , Top
2267 @comment node-name, next, previous, up
2268 @unnumbered Variable, Constants, and Variable-like Macros Index
2271 @node File Index, , , Top
2272 @comment node-name, next, previous, up
2273 @unnumbered File and Program Index