1 \input texinfo @c -*-texinfo-*-
4 @settitle Wine Reference Manual
13 * wine: (wine.info). Windows on Unix.
23 This file documents Wine, a system providing Microsoft Windows compatibility
27 Copyright @copyright{} 1997,1998 The Wine authors. @*
28 @xref{Authors, The Wine Authors, The Wine Authors},
29 for a list of the copyright holders.
31 Permission is granted to make and distribute verbatim
32 copies of this manual provided the copyright notice and
33 this permission notice are preserved on all copies.
36 Permission is granted to process this file through TeX
37 and print the results, provided the printed document
38 carries a copying permission notice identical to this
39 one except for the removal of this paragraph (this
40 paragraph not being relevant to the printed manual).
43 Permission is granted to copy and distribute modified
44 versions of this manual under the conditions stated in
45 the section entitled ``License, Warranty, and Authors of Wine''.
48 UNIX is a registered trademark of the Open Group.
49 POSIX is a registered trademark of the IEEE Inc.
50 X Window System is a trademark of X Consortium, Inc.
51 Microsoft, Windows, MS-Windows, Windows-NT, Windows 95, and MS-DOS are
52 registered trademarks of Microsoft Corporation.
53 NT is a trademark of Northern Telecom Limited.
54 C++Builder is a trademark of Borland International, Inc.
55 Postscript is a registered trademark of Adobe Systems Inc.
56 Other trademarks are the property of their respective owners, which may
57 be registered in certain jurisdictions.
60 @c begin chapters on right pages
61 @setchapternewpage odd
65 @title{The Wine Reference Manual}
66 @subtitle{Edition 0.0.5, February 1998}
68 @author{The Wine Team}
69 @c The following two commands start the copyright page.
71 @vskip 0pt plus 1filll
73 Copyright @copyright{} 1997, 1998 The Wine authors. @*
74 @xref{Authors, The Wine Authors, The Wine Authors},
75 for a list of the copyright holders.
77 Permission is granted to make and distribute verbatim
78 copies of this manual provided the copyright notice and
79 this permission notice are preserved on all copies.
81 Permission is granted to copy and distribute modified
82 versions of this manual under the conditions stated in
83 the section entitled ``License, Warranty, and Authors of Wine''.
86 UNIX is a registered trademark of the Open Group.
87 POSIX is a registered trademark of the IEEE Inc.
88 X Window System is a trademark of X Consortium, Inc.
89 Microsoft, Windows, MS-Windows, Windows-NT, Windows 95, and MS-DOS are
90 registered trademarks of Microsoft Corporation.
91 NT is a trademark of Northern Telecom Limited.
92 C++Builder is a trademark of Borland International, Inc.
93 Postscript is a registered trademark of Adobe Systems Inc.
94 Other trademarks are the property of their respective owners, which may
95 be registered in certain jurisdictions.
101 @c SETTINGS, DEFINES, MACROS
104 @c Edit this macro manually in the above parts of the document
105 @macro winemanualversion
109 @c Edit this macro manually in the above parts of the document
110 @macro winemanualdate
114 @c Edit this macro manually into the TeX titlepage
115 @macro winemanualtitle
116 The Wine Reference Manual
127 @c FIXME: automatic trademark reference
132 @c FIXME: automatic trademark reference
133 @c spell it always the same
141 @c FIXME: automatic trademark reference
146 @c FIXME: automatic trademark reference
151 @c FIXME: automatic trademark reference
160 @c FIXME: automatic trademark reference
165 @c FIXME: automatic trademark reference
182 @c flag out differences to MS-Windows
184 @emph{Differences to @mswindows{}:} @*
189 No differences known.
192 @c tell whether function is present in Windows 95 and/or NT
194 @emph{Conformance to @mswindows{}:} @*
199 Present in @WIN95{} and @WINNT{}.
202 @c give information about completion
204 @emph{Completion status:} @*
207 @macro completionnone
213 @c MACROS FOR FUNCTIONS, TYPES, CONSTANTS, VARIABLES
216 @c Constants in the WIN32 API
217 @macro defvr_cw32 {restofline}
218 @defvr Constant \restofline\
220 @macro defvrx_cw32 {restofline}
221 @defvrx Constant \restofline\
224 @c Functions in the WIN32 API
225 @macro deftypefn_w32 {restofline}
226 @deftypefn {WIN32 function} \restofline\
228 @macro deftypefnx_w32 {restofline}
229 @deftypefnx {WIN32 function} \restofline\
232 @c Types in the WIN32 API
233 @macro deftp_w32 {restofline}
234 @deftp {Data type} \restofline\
236 @macro deftpx_w32 {restofline}
237 @deftpx {Data type} \restofline\
240 @c Macros internal to Wine
241 @macro deffn_winemacro {restofline}
242 @deffn {Wine internal macro} \restofline\
244 @macro deffnx_winemacro {restofline}
245 @deffn {Wine internal macro} \restofline\
248 @c Constants internal to Wine
249 @macro defvr_cwine {restofline}
250 @defvr {Wine internal constant} \restofline\
252 @macro defvrx_cwine {restofline}
253 @defvrx {Wine internal constant} \restofline\
261 @node Top, Copying, (dir), (dir)
264 This is edition @winemanualversion{}, last updated @winemanualdate{},
265 of @winemanualtitle{}.
267 Wine provides both source and binary compatibility with Microsoft Windows.
268 The Wine API is designed to be as compatible as possible with various
269 implementations of the Windows APIs. The Wine library allows porting
270 Windows source to Unix, and a program loader allows unaltered Windows binaries
273 Wine is free software. Wine is still under development.
277 * Copying:: License, Warranty, and Authors of Wine.
278 * Introduction:: A short overview.
279 * Wine Design:: The design of Wine.
280 * Reference Manual:: The Wine reference manual.
281 * Installation:: Installing and configuring Wine.
282 * The Wine Project:: How to contribute to Wine.
283 * Concept Index:: Index of concepts and names.
284 * Type Index:: Index of types and type qualifiers.
285 * Function Index:: Index of functions and function-like
287 * Variable Index:: Index of variables, constants, and
288 variable-like macros.
289 * File Index:: Index of programs and files.
292 @node Copying, Introduction, Top, Top
294 @unnumbered License, Warranty, and Authors of Wine
295 @cindex copying conditions for Wine
296 @cindex conditions for copying Wine
297 @cindex Wine copying conditions
299 The Wine license, warranty, and list of authors together form the
300 copyright for Wine. Read these sections carefully.
303 * License:: The Wine license.
304 * Warranty:: Wine comes with no warranty.
305 * Authors:: The persons that contributed to Wine.
308 @node License, Warranty, , Copying
310 @cindex license of Wine
312 @unnumberedsec The Wine License
313 Wine is distributed under the following copyright.
319 @node Warranty, Authors, License, Copying
320 @cindex Wine warranty
321 @cindex warranty of Wine
323 @unnumberedsec The Wine Warranty
326 Wine comes with no warranty.
329 @node Authors, , Warranty, Copying
331 @cindex authors of Wine
332 @cindex copyright holders of Wine
333 @cindex Wine copyright holders
335 @unnumberedsec The Wine Authors
341 These persons also hold the copyright on Wine.
343 The overall coordination is done by @*
344 Alexandre Julliard @*
345 @email{julliard@@winehq.com}
349 @node Introduction, Wine Design, Copying, Top
350 @chapter Introduction
352 @strong{What is Wine?}
354 Wine is a Windows-compatibility layer for Unix and X11.
355 The Wine system consists of several thing:
358 An API, sometimes referred to as the Wine API,
359 designed to be as compatible as possible with the
362 A library, called @winelib{}, which implements this API
364 A binary compatibility layer
365 acts as a program loader for native Windows binaries.
366 It works for both 16 and 32 bit Intel binaries, and
367 provides all the appropriate translation between 16 and 32 bit code
368 (thunking). Real mode interrupts are also supported, and their
369 functionality is implemented in @winelib{}.
373 @strong{System Requirements}
376 Wine provides binary support for Intel code on Intel hardware only.
377 Neither hardware emulation
378 nor non-Intel binaries are supported.
379 @winelib{} should be possible to port to just about any Unix system.
381 Currently, you must have one of:
384 Linux version 0.99.13 or above
388 FreeBSD-current or FreeBSD 1.1
390 OpenBSD/i386 2.1 or later
392 Solaris x86 2.5 or later
394 You need X11, and you must have @file{libXpm} installed on your system.
396 @strong{Availability}
398 Wine is free software; the license is BSD-style. Basically, you can do
399 anything with it, except claim that you wrote it.
400 @xref{Copying}, for more information.
402 @strong{Further information}
404 You should consult the files @file{README}, @file{ANNOUNCE},
405 @file{RELEASE-NOTES}, @file{BUGS}, @file{LICENSE}, and @file{WARRANTY},
406 in the root directory of the Wine distribution.
408 The Wine USENET newsgroup @url{news:comp.emulators.ms-windows.wine}
409 is useful for both Wine developers and Wine users. The Wine home page
410 is @url{http://www.winehq.com/}.
412 @node Wine Design, Reference Manual, Introduction, Top
415 @subsection The Wine Graphics Driver Model
417 Wine, like Windows, abstracts drawing code so that applications may access
418 a wide variety of devices, from different kinds of graphics cards,
419 X displays and printers, using a single unified graphics model.
420 This model is referred to as GDI: _G_raphics _D_river _I_nterface.
421 This section discusses the Wine implementation of GDI.
422 There are 61 functions in the Wine graphics model, including Arc, BitBlt,
423 Chord, etc. For a complete list and prototypes, see the definition
424 of DC_FUNCTIONS in [include/gdi.h].
426 Wine, as of 2Q1998, has three native drivers: these provide support
427 for rendering to X displays, metafiles, and Win16 native printer drivers.
428 As far as Wine is concerned, a driver
429 simply consists of a name and a table of function pointers
430 (see [graphics/driver.c]). These functions
431 are the driver's implementation of the various Wine graphics
432 operations (the GDI). Wine maintains a linked list of all drivers which
433 register themselves with Wine, as well as a ``generic''
434 driver. Currently, the X11 driver registers itself as DISPLAY, the
435 win16 driver registers itself as the generic driver, and the metafile
436 driver doesn't register itself at all.
438 @subsubsection How a driver function gets invoked
440 All drawing by Wine applications
441 is done in terms of a Device Context (DC).
442 Before an application can draw, it must create a DC, and all drawing calls
443 must pass a handle to the DC they wish to draw to.
444 [include/gdi.h] defines several structures relating to DCs, including
445 DC, WIN_DC_INFO, and DeviceCaps. The DeviceCaps structure is at the lowest
447 information relating to specifics of the graphics display
448 hardware and associated
450 WIN_DC_INFO holds information about several device independent
451 modes the DC can be in, plus a pointer to DeviceCaps.
453 the DC structure is the toplevel structure usually passed around.
454 It holds viewport information, a pointer to WIN_DC_INFO, and a
455 pointer to the function table to be used while rendering that DC.
456 This function table is filled at the time of creating the DC.
460 @c Some discussion of the various modalities available to a DC would be nice.
462 @c Coordinate Systems
464 @c Some discussion of the maze of coordinate systems would also be nice.
466 @c Device Coordinates
468 @c Logical Coordinates
473 @subsubsection The X11 driver
475 As a part of the Wine loading process,
476 X11DRV_Init in [graphics/x11drv/init.c] is called.
477 This initializes various aspects of the X11 driver and
478 registers it as DISPLAY. This function first
479 calls initialization procedures for various parts of the X11 driver.
482 fills a static DeviceCaps
483 structure to be used for every X11 DC.
484 Finally, it fills the table of GDI functions to be used for X11
485 rendering and registers itself as ``DISPLAY''.
487 @subsubsection The Metafile Driver
489 The metafile driver is unusual, in that it is not a driver for any
490 kind of display device, but rather a mechanism which allows using
491 the Wine graphics model as a file format for saving graphics.
492 The advantage of this is that it allows using identical formats for
493 saving pictures as is actually used to display them; it is analogous
494 to Display PostScript.
496 The metafile driver is invoked explicitly by the application. The
497 application calls CreateMetaFile() to create a special DC for recording
498 graphics drawing operations in a metafile. Any drawing operations
499 performed in this DC are not drawn physically anywhere, they are
500 instead stored in the metafile. The DC is explicitly destroyed by a
501 call to CloseMetaFile(), which also finishes writing the metafile.
502 Metafiles may be written either to a file or to memory. Later, the
503 metafile can be rendered (in a physical DC) by PlayMetaFile().
505 The way that this works is that device contexts contain a pointer
506 to the function lookup table for drawing operations appropriate for
509 Not all functions in the Wine graphics model are relevant to metafiles, but
510 some relevant but rarely used functions are unimplemented.
512 @subsubsection The WIN16 Driver
514 WIN16DRV_Init is called by MAIN_EmulatorInit, and registers the
515 WIN16DRV function table WIN16DRV_Funcs [graphics/win16drv/init.c]
516 for the generic driver. The WIN16 driver is designed to load
517 specified native Windows printer drivers. I don't understand
518 how the whole scheme works,
519 start studying what happens when a printer DC is
520 created via WIN16DRV_CreateDC.
522 If a DC is created explicitly, via the
523 CreateDC() call, the driver name is specified explicitly and Wine
524 finds the appropriate driver by leafing through its table of registered
525 drivers. Metafile DCs can only be created by the CreateMetaFile function.
527 Alternatively, most of the time, the DISPLAY driver is invoked
529 The application creates a window with
530 CreateWindow(). If the CS_CLASSDC or CS_OWNDC flag is passed, a new DC
531 is created and saved for the window in a structure called DCE, which holds
532 a DC, a clipping region, and flags. Whenever the application wants to
533 paint in that window, it calls GetDC(hwnd), which returns the DC in the
534 DCE saved in the window.
536 If neither of those flags are used, the window gets a DCE assigned to it
537 from a pool of DCEs created during Wine initialization and temporarily
538 assigned during the GetDC() call.
539 All DCEs, whether part of the Wine DC pool or created by request of a window,
540 use the ``DISPLAY'' driver.
543 @node Reference Manual, Installation, Wine Design, Top
546 * @WIN32{} Reference Manual:: The @WIN32{} function calls and data types.
547 * Resources and INI files:: How to determine the appearance and
548 behaviour of Wine programs.
549 * Metafiles--Icons--Bitmaps:: FIXME missing.
550 * Debugging:: Debugging Wine.
551 * Programs:: Programs written to run in/with Wine.
552 * Tools:: Programs to support Wine.
555 @node @WIN32{} Reference Manual, Resources and INI files, , Reference Manual
556 @chapter The @WIN32{} Reference Manual
559 * Kernel Objects:: How the Wine kernel keeps information.
560 * Processes and Threads:: Job control and management in Wine.
561 * Users and Groups:: Security in Wine.
562 * Date and Time:: Functions for getting the date and time
563 and for conversion between formats.
564 * System Information:: Getting information about the hardware
565 and software the system runs on.
566 * Memory Management:: How your programs get memory from
568 * I/O Facilities:: Input/Output in Wine.
569 * Communication:: How processes can communicate.
570 * Windows and Graphics:: GUI functions of @WIN32{}.
571 * Errors and Exceptions:: How your program can report errors.
573 * Resources:: Functions for dealing with resources.
574 * The Registry:: FIXME missing.
575 * Dynamic Link Libraries:: Functions for dealing with DLL's.
578 @node Kernel Objects, Processes and Threads, , @WIN32{} Reference Manual
579 @section Kernel Objects
582 @node Processes and Threads, Users and Groups, Kernel Objects, @WIN32{} Reference Manual
583 @section Processes and Threads
585 @node Users and Groups, Date and Time, Processes and Threads, @WIN32{} Reference Manual
586 @section Users and Groups
588 @node Date and Time, System Information, Users and Groups, @WIN32{} Reference Manual
589 @section Date and Time
591 This section describes functions for manipulating dates and times. This
592 includes the current time, the creation or manipulation times of files
593 and other objects, and conversion between different time
597 * File Times:: Creation and manipulation times of files.
600 @node File Times, , , Date and Time
601 @subsection File Times
604 * Type FILETIME:: The data structure used for specifying
606 * Compare File Times:: Compare two file times.
610 @c *** struct FILETIME ***
612 @node Type FILETIME, Compare File Times, , File Times
613 @subsubsection Type FILETIME
616 File times in Wine are specified by the data type @code{FILETIME},
617 defined in @file{windows.h}.
619 @deftpx_w32 LPFILETIME
620 This is the data type for specifying file times. The file times are
621 stored with 64 bit precision. The actual data type is a structure with
622 two 32-bit values which are interpreted as the low and high parts of a
623 64-bit value. This value gives a time measured in a granularity of 100
624 nanoseconds, so 1.5 seconds are specified by a value of 15,000,000. In
625 Wine, this 64-bit value is signed, with the sign taken from the high
626 part. The lower part is used as unsigned.
628 The definition of @code{FILETIME} reads:
633 INT32 dwHighDateTime;
634 @} FILETIME, *LPFILETIME;
637 @cindex epoch in file time
638 The @code{FILETIME} structure may be used to hold absolute or relative
639 times. Absolute times are given as the number of 100 nanoseconds
640 intervals elapsed since 1 January 1601, 00:00:00 UTC (Coordinated
641 Universal Time, which is GMT, Greenwich Mean Time). This might be
642 called the @dfn{epoch} for file times. With a signed 64-bit value, this
643 representation covers absolute times of 29247 years around the epoch.
644 To convert this type to local time, use the function
645 @code{FileTimeToLocalFileTime}.
648 In @mswindows{}, the elements of the structure are apparently of type
649 @code{DWORD}. Whether the full 64 bit value is interpreted as signed or
650 unsigned I do not know.
654 @c *** CompareFileTime ***
656 @node Compare File Times, , Type FILETIME, File Times
659 The Wine function @code{CompareFileTime} compares two file times, and
660 returns whether the first time is less than, equal to, or greater than
661 the second file time. It is defined in @file{windows.h}.
662 @deftypefn_w32 LONG CompareFileTime (@w{CONST FILETIME* @var{time_1},} @w{CONST FILETIME* @var{time_2})}
663 This function returns @code{1}, if @var{time_1} is greater than
664 @var{time_2}, @code{-1} if it is less, and @code{0} if both times are
674 @node System Information, Memory Management, Date and Time, @WIN32{} Reference Manual
675 @section System Information
677 @node Memory Management, I/O Facilities, System Information, @WIN32{} Reference Manual
678 @section Memory Management
680 @node I/O Facilities, Communication, Memory Management, @WIN32{} Reference Manual
681 @section I/O Facilities
683 This section describes all input/output of a process, except for two
684 topics: communication with other processes, and communication with the
688 * I/O on Files:: Accessing the contents of files.
689 * File System Interface:: Functions for manipulating files as a whole.
692 @node I/O on Files, File System Interface, , I/O Facilities
693 @subsection I/O on Files
695 @node File System Interface, , I/O on Files, I/O Facilities
696 @subsection File System Interface
698 These functions are concerned with operating on files themselves, rather
699 than on their contents.
702 * Type BY_HANDLE_FILE_INFORMATION:: The data structure used to
703 specify file information.
704 * File attributes:: The file attributes flags in
705 a file information structure.
706 * Getting file information:: These functions let you obtain
707 information about a file.
710 @node Type BY_HANDLE_FILE_INFORMATION, File attributes, , File System Interface
711 @subsubsection The file information structure
713 The file information structure of Wine is used to obtain information
714 about files. It is declared in the header @file{winedows.h}.
715 @deftp_w32 BY_HANDLE_FILE_INFORMATION
716 This is the data type for specifying information about files as objects
717 of the file system. It contains the following members:
719 @item int dwFileAttributes
720 @cindex file attributes in file information
721 @cindex attributes of file in file information
722 @xref{File attributes}, for details.
723 @item FILETIME ftCreationTime
724 @cindex creation time in file information
725 @cindex time of file creation in file information
726 The time when the file was created.
727 @xref{Type FILETIME}, for details.
728 @item FILETIME ftLastAccessTime
729 @cindex access time in file information
730 @cindex time of file access in file information
731 The time when the file was last accessed.
732 @xref{Type FILETIME}, for details.
733 @item FILETIME ftLastWriteTime
734 @cindex write time in file information
735 @cindex time of last file write in file information
736 The time when the file was last written to.
737 @xref{Type FILETIME}, for details.
738 @item int dwVolumeSerialNumber
739 @cindex serial number of volume in file information
740 @cindex volume number (serial) in file information
741 The serial number of the volume containing the file. In Wine,
743 @item int nFileSizeHigh
744 @cindex file size in file information
745 @cindex size of file in file information
746 A 32 bit value which contains the high part of the 64 bit file size.
747 @item int nFileSizeLow
748 A 32 bit value which contains the low part of the 64 bit file size.
749 @item int nNumberOfLinks
750 @cindex hard links number in file information
751 @cindex links (number of hard) in file information
752 This is the number of hard links to the file. In a file system which
753 does not support hard links, this is 1.
754 @item int nFileIndexHigh
755 @cindex inode number in file information
756 @cindex file index in file information
757 @cindex index of file in file information
758 A 32 bit value which contains the high part of the 64 bit file
759 index. The file index is a unique number for a file on a volume.
760 This identifier cannot change while the file is opened by a process.
761 Together with the volume number, the file index is a unique
762 identifier for the file. This can be used by an application to check
763 whether two handles refer to the same file. Wine currently uses the
764 inode number for the file index.
765 @item int nFileIndexLow
766 A 32 bit value which contains the low part of the 64 bit file index.
769 The definition of @code{BY_HANDLE_FILE_INFORMATION} reads:
773 int dwFileAttributes;
774 FILETIME ftCreationTime;
775 FILETIME ftLastAccessTime;
776 FILETIME ftLastWriteTime;
777 int dwVolumeSerialNumber;
783 @} BY_HANDLE_FILE_INFORMATION ;
786 The @code{BY_HANDLE_FILE_INFORMATION} structure can be obtained by the
787 @code{GetFileInformationByHandle} function (@pxref{Getting file information}, for
791 In @mswindows{}, the @code{int} elements of the structure are apparently
792 of type @code{DWORD}.
795 @node File attributes, Getting file information, Type BY_HANDLE_FILE_INFORMATION, File System Interface
796 @subsubsection The file attributes in a file information structure
798 The file attributes in a file information structure and in other structures
799 are a logical @emph{or} of one or more of the following constants:
801 @defvr_cw32 FILE_ATTRIBUTE_READONLY
802 The file is a read-only file. (Wine value: 0x0001).
804 @defvr_cw32 FILE_ATTRIBUTE_HIDDEN
805 The file is a hidden file. Wine can set this attribute for files starting
806 with a dot (normally considered hidden in a Unix environment). This behaviour
807 is controlled by the @code{ShowDotFiles} configuration setting.
808 (Wine value: 0x0002).
810 @defvr_cw32 FILE_ATTRIBUTE_SYSTEM
811 The file belongs to the operating system. Files in Wine do not have this
812 attribute. (Wine value: 0x0004).
814 @defvr_cw32 FILE_ATTRIBUTE_LABEL
815 This is not present in the @mswindows{} API. (Wine value: 0x0008).
817 @defvr_cw32 FILE_ATTRIBUTE_DIRECTORY
818 The file is a directory. (Wine value: 0x0010).
820 @defvr_cw32 FILE_ATTRIBUTE_ARCHIVE
821 The file is an archive file. Currently, all non-directory files are
822 reported by Wine to have this attribute. This attribute is normally set
823 by @mswindows{} to indicate that a file is to be archived; when the file
824 is archived, the flag is cleared. (Wine value: 0x0020).
826 @defvr_cw32 FILE_ATTRIBUTE_NORMAL
827 The file does not have any other attributes set. This value must be used
828 alone. In Wine, normal files are reported as archive files. (Wine value:
831 @defvr_cw32 FILE_ATTRIBUTE_TEMPORARY
832 The file is used as a temporary storage. Files in Wine do not have this
833 attribute. (Wine value: 0x0100).
835 @defvr_cw32 FILE_ATTRIBUTE_ATOMIC_WRITE
836 This is reserved for future use. Files in Wine do not have this
837 attribute. (Wine value: 0x0200).
839 @defvr_cw32 FILE_ATTRIBUTE_XACTION_WRITE
840 This is reserved for future use. Files in Wine do not have this
841 attribute. (Wine value: 0x0400).
843 @defvr_cw32 FILE_ATTRIBUTE_COMPRESSED
844 The file is compressed. Files in Wine do not have this attribute. (Wine
848 @node Getting file information, , File attributes, File System Interface
849 @subsubsection Getting file information
851 The functions in this section describe how to get information about
855 @c *** GetFileInformationByHandle
858 The Wine function @code{GetFileInformationByHandle} returns a file
859 information structure. It is defined in @file{windows.h}.
861 @deftypefn_w32 BOOL GetFileInformationByHandle (@w{HFILE32 @var{file},} @w{BY_HANDLE_FILE_INFORMATION *@var{info})}
862 This function obtains for the specified @var{file} the file information,
863 and stores it in @var{info}. The file information contains the file
864 attributes, the file times, the volume serial number, the file size, the
865 number of links, and a unique file identifier. The function returns
866 @code{TRUE} on success, @code{FALSE} on failure.
871 The Wine function can of course only give back information that is
872 accessible in the @unix{} file system. File times are produced in a
873 granularity of full seconds. Most file attributes are not present in the
874 @unix{} file system. @xref{File attributes}, for details. The volume
875 serial number is set to 0.
880 @c *** GetFileTime ***
883 The Wine function @code{GetFileTime} returns the creation time and
884 the times of last the read and modification access to a file. It is
885 defined in @file{windows.h}.
887 @deftypefn_w32 BOOL GetFileTime (@w{HANDLE @var{file},} @w{LPFILETIME @var{ctime},} @w{LPFILETIME @var{atime},} @w{LPFILETIME @var{mtime})}
888 This function obtains for the specified @var{file} the creation time
889 @var{ctime}, the time of the last access to the file @var{atime}, and
890 the time of the last modification (write) to the file, @var{mtime}.
891 The file time arguments of this function are pointers to @code{FILETIME}
892 variables, which are filled with a value that indicates an absolute time
893 in UTC. @xref{Type FILETIME}, for details. If you do not need some of
894 the times, you can pass a @code{NULL} pointer.
895 The function returns @code{TRUE} on
896 success, @code{FALSE} on failure.
901 The file times are produced in a granularity of full seconds, due to the
902 underlying @unix{} file system.
906 @c *** GetFileAttributes ***
909 The Wine function @code{GetFileAttributes} returns the file attributes
910 for a file. It is defined in @file{windows.h}.
912 @deftypefn_w32 DWORD GetFileAttributes (@w{LPCTSTR @var{name})}
913 This function looks up the file with name @var{name}, and returns the
914 attributes of the file. @xref{File attributes}, for details on the file
915 attributes. If the function is not successful, it returns a word with
916 all bits set (@samp{0xffffffff}).
921 Most file attributes are not present in the
922 @unix{} file system. @xref{File attributes}, for details.
928 @node Communication, Windows and Graphics, I/O Facilities, @WIN32{} Reference Manual
929 @section Communication
931 @node Windows and Graphics, Errors and Exceptions, Communication, @WIN32{} Reference Manual
932 @section Windows and Graphics
934 @node Errors and Exceptions, Resources, Windows and Graphics, @WIN32{} Reference Manual
935 @section Errors and Exceptions
937 @node Resources, The Registry, Errors and Exceptions, @WIN32{} Reference Manual
940 @node The Registry, Dynamic Link Libraries, Resources, @WIN32{} Reference Manual
941 @section The Registry
943 @node Dynamic Link Libraries, , The Registry, @WIN32{} Reference Manual
944 @section Dynamic Link Libraries (DLL's)
946 This section deals with API functions for handling DLL's (dynamic link
947 libraries). It does not describe DLL's themselves; nor does it give
948 information on how Wine handles DLL's. @xref{The build program}, for
949 information on how DLL's are integrated into Wine.
954 @node Resources and INI files, Metafiles--Icons--Bitmaps, @WIN32{} Reference Manual, Reference Manual
955 @chapter Resources and @file{INI} Files
957 @node Metafiles--Icons--Bitmaps, Debugging, Resources and INI files, Reference Manual
958 @chapter Metafiles --- Icons --- Bitmaps
960 @node Debugging, Programs, Metafiles--Icons--Bitmaps, Reference Manual
963 @node Programs, Tools, Debugging, Reference Manual
966 @node Tools, , Programs, Reference Manual
969 This chapter describes some of the tools that are used by Wine. These
970 are not user-level programs which the user of Wine will
971 run. @xref{Programs}, for such programs.
973 Tools are internal programs that are used to help compile or configure
977 * The build program:: A program used to build the DLL entry
978 points from specifications in @file{if1632/}.
982 @node The build program, , , Tools
983 @section The @file{build} program
985 @cindex modules of Wine
987 @cindex DLL's built-in in Wine
988 @cindex Wine DLL's built-in
989 @cindex built-in DLL's in Wine
990 Wine contains several modules that implement various DLL's which are
991 required to run @mswindows{} programs.
993 The @file{build} program, located in the @file{tools/} directory, is
994 used to create the bindings for the DLL entry points of the API functions.
995 This program reads a @file{.spec}-file in the @file{if1632} directory
996 and creates the assembly code that translates the function arguments
1001 * The spec files:: The format of the @file{.spec}-files.
1004 FIXME: where in Wine are the DLL's affixed?
1006 FIXME: write a description
1008 @xref{Implementing an API function}, for notes on using this program.
1010 @node The spec files, , , The build program
1011 @subsection The @file{.spec}-files
1012 @cindex DLL spec files
1013 @cindex spec files of DLL's
1014 @cindex entry points in DLL's
1016 This subsection describes the format of the @file{.spec}-files.
1018 A @file{.spec}-file contains the information about the functions,
1019 variables, and constants that are contained in a DLL (dynamic link
1022 To be able to interpret the contents of a @file{.spec}-file, you must
1023 know about the concept of ordinals.
1025 * The general format:: General format conventions.
1026 * Ordinals:: Ordinals are indexes of entry
1028 * Spec file header:: The header information.
1029 * Variable entry points:: Entries for DLL variables.
1030 * Function entry points:: Entries for DLL functions.
1031 * Special entries:: Entries for stubs, dummy
1032 functions, Wine symbols, and
1036 @node The general format, Ordinals, , The spec files
1037 @subsubsection The general format
1038 @cindex format of spec files
1039 @cindex spec files format
1041 The @file{.spec}-file contains a header and a sequence of declarations.
1042 Each declaration describes an ordinal.
1044 The header gives general information about the DLL and its properties.
1046 Ordinal declarations are optional. That means that there is a default
1047 behaviour assigned to ordinals which are not mentioned in the
1048 @file{.spec}-file. The default handler function of an ordinal will print
1049 an error message when called.
1051 Comments are indicated by hash marks (@samp{#}); everything between a
1052 hash mark and the end of the line is ignored.
1054 Empty lines are allowed.
1055 @* FIXME: is that so?
1057 @node Ordinals, Spec file header, The general format, The spec files
1058 @subsubsection Ordinals
1059 @cindex ordinals in DLL's
1060 @cindex DLL ordinals
1062 All references to DLL objects like functions or variables are indexed by
1063 unique nonnegative numbers. These numbers are called
1064 @dfn{ordinals}. Apparently, a program can refer to a DLL function or
1065 variable by specifying its name or its ordinal. Although reference by
1066 name is the common usage, some program parts (notably DLL's themselves)
1067 sometimes refer to DLL entries by ordinal. Therefore, the ordinals
1068 cannot be chosen arbitrarily.
1070 Regular programs that are compiled and linked against @mswindows{} DLL's
1071 will import DLL functions by name. This is therefore the default
1072 behaviour. Most DLL functions will be imported by name in all cases.
1073 Apparently, the @WIN32{} DLL's even show some difference in the mapping
1074 of functions and ordinals on @WINNT{} and @WIN95{}. For most DLL
1075 functions, the ordinal number will not matter.
1077 There are some exceptions to that. Notable the KERNEL32 ordinals below
1078 100 are (presently) unnamed and undocumented functions which can only be
1079 imported by ordinal. These functions are called by some @mswindows{}
1080 programs. Also the @file{shell32.dll} functions are reported to be
1081 imported by ordinal in some other DLL's.
1083 @xref{Getting information on the API}, for sources of further information.
1085 @node Spec file header, Variable entry points, Ordinals, The spec files
1086 @subsubsection The header of a @file{.spec}-file
1088 The @file{.spec}-file starts with two mandatory definitions. The first
1089 line gives the name of the DLL which the @file{.spec}-file describes,
1093 where @var{NAME} is the name of the DLL. The next line defines the type
1098 with @var{TYPE} being either @samp{win16} or @samp{win32}.
1100 An optional statement of the form
1104 can be used to define the offset of the first ordinal. @var{ORDINAL}
1105 must be an integer number. If no base is specified, the offset is zero.
1106 @* FIXME: is this the offset of the first or an offset that is added to all
1108 what is the offset? Is it added to the ordinals, or is it an address, or
1111 An optional statement like
1115 can be used to define the size of the module local heap. This is only
1116 used for @WIN16{} DLL's. The local heap is the place where the segments
1117 of 16 bit programs can locally allocate memory, without interfering with
1118 one another. The default size of the local heap, if not specified, is 0.
1120 @* FIXME: to my impression, a local heap in DLL's would only be required
1121 if DLL functions used it. As all DLL functions in Wine are truly 32 bit
1122 functions that are mapped from 16 bit on being called and back to 16 bit
1123 on returning, a local heap should never be necessary.
1124 If I receive a confirmation of that here, I will state so. Otherwise I
1125 am missing some information on local heaps.
1126 But why is a heap defined in user.spec and gdi.spec?
1128 @node Variable entry points, Function entry points, Spec file header, The spec files
1129 @subsubsection Variable entry points of @file{.spec}-files
1131 You can declare an ordinal that holds data. Data items may be of 8, 16,
1135 @var{ORDINAL} @var{VARTYPE} @var{EXPORTNAME} (@var{DATA} @var{DATA @dots{}})
1138 @var{ORDINAL} is the ordinal number corresponding to the
1139 variable. @var{VARTYPE} must be @samp{byte}, @samp{word}, or
1140 @samp{long}, for 8, 16, or 32 bits respectively. @var{EXPORTNAME} will
1141 be the name available for dynamic linking. @var{DATA} can be a decimal
1142 number or a hex number preceded by @samp{0x}. Each @var{DATA} item defines
1145 The following example defines the variable @samp{VariableA} at ordinal
1146 2, containing 4 bytes:
1148 2 byte VariableA(-1 0xff 0 0)
1152 @node Function entry points, Special entries, Variable entry points, The spec files
1153 @subsubsection Function entry points of @file{.spec}-files
1156 @var{ORDINAL} @var{FUNCTYPE} @var{EXPORTNAME} (@var{ARGTYPE} @dots{} @var{}) @var{HANDLERNAME}
1159 @var{ORDINAL} is the ordinal number corresponding to the
1160 function. @var{FUNCTYPE} must be chosen from this table:
1163 A @WIN16{} function that returns a 16 bit value.
1165 A @WIN16{} function that returns a 32 bit value.
1167 A function using CPU registers to pass arguments.
1169 A normal @WIN32{} function. @xref{Investigating the undocumented API},
1170 for an explanation of the stdcall calling convention.
1172 A @WIN32{} function using the C calling conventions. (This is presently
1173 only used for the built-in functions of the C runtime system).
1176 @var{EXPORTNAME} specifies the name (prototype) available for dynamic
1179 @var{ARGTYPE} must be chosen from this table:
1182 An 8 bit argument. Can be used in @WIN16{} functions only.
1184 A 16 bit argument. Can be used in @WIN16{} functions only.
1186 A 32 bit argument. Can be used in @WIN16{} or @WIN32{} functions.
1188 A linear pointer, unsegmented. Can be used in @WIN16{} or @WIN32{}
1191 A linear pointer, unsegmented, pointing to a null-terminated string.
1192 Can be used in @WIN16{} or @WIN32{} functions.
1194 A signed 8 bit argument. Can be used in @WIN16{} functions only.
1196 A signed 16 bit argument. Can be used in @WIN16{} functions only.
1198 A signed 32 bit argument. Can be used in @WIN16{} or @WIN32{}
1201 A segmented pointer. Can be used in @WIN16{} functions only.
1203 A segmented pointer to a null-terminated string. Can be used in
1204 @WIN16{} functions only.
1207 @var{HANDLERNAME} is the name of the actual Wine function that will
1208 process the request in 32-bit mode.
1212 Here are some examples. The first example defines an entry point for the
1213 @code{CreateWindow()} call (the ordinal 100 is just an example):
1215 100 pascal CreateWindow(ptr ptr long s_word s_word s_word s_word
1216 word word word ptr) WIN_CreateWindow
1219 The second example defines an entry point for the @code{GetFocus()} call
1220 (again, the ordinal 100 is an example):
1222 100 pascal GetFocus() WIN_GetFocus()
1225 To declare a function that uses a variable number of arguments, specify
1226 the function as taking no arguments. In this special case, in @WIN32{}
1227 the called function will be passed a pointer to the first arg; in
1228 @WIN16{}, the args are available as @code{CURRENT_STACK16->args}.
1229 @* FIXME: create a reference here
1230 See the @code{wsprintf}* functions in @file{user.spec} and
1231 @file{user32.spec} for an example.
1233 Sometimes it is not known how many arguments an undocumented DLL
1234 function takes. @xref{Getting information on the API}, for some hints on
1235 how to proceed in such a case.
1237 @node Special entries, , Function entry points, The spec files
1238 @subsubsection Special entries of @file{.spec}-files
1240 The @file{.spec}-files offer the possibility to use some special
1241 entries. These entries are used for stubs (which allow linking for
1242 non-existing functions), dummy functions that do not perform any
1243 operations, Wine symbols that must be referenced directly, and constant
1247 @strong{Stub ordinals}
1249 This pseudo function type defines a stub function. It makes the name and
1250 ordinal available for dynamic linking, but will terminate execution with
1251 an error message if the function is ever called.
1254 @var{ORDINAL} stub @var{EXPORTNAME}
1257 @var{ORDINAL} is the ordinal number corresponding to the
1258 function. @var{EXPORTNAME} specifies the name (prototype) available for dynamic
1261 @strong{Return ordinals}
1263 This pseudo function type defines a function entry point whose handler
1264 should do nothing but return a value.
1266 @var{ORDINAL} return @var{EXPORTNAME} @var{ARGLENGTH} @var{RETVALUE}
1269 @var{ORDINAL} is replaced by the ordinal number corresponding to the
1270 function. @var{ARGLENGTH} is the number of bytes that need to be removed
1271 from the stack before returning to the caller. @xref{Investigating the
1272 undocumented API}, for an explanation of the stdcall calling convention.
1273 @var{RETVALUE} is the return value which will be passed back to the
1276 @strong{Extern ordinals}
1279 @var{ORDINAL} extern @var{EXPORTNAME} @var{SYMBOLNAME}
1281 This type defines an entry that simply maps to a Wine symbol
1282 (variable or function); @var{EXPORTNAME} will point to the symbol
1283 @var{SYMBOLNAME} that must be defined in C code. This type only works with
1287 @strong{Equate ordinals}
1290 @var{ORDINAL} equate @var{EXPORTNAME} @var{DATA}
1293 This type defines an ordinal as an absolute value.
1294 @var{ORDINAL} is replaced by the ordinal number corresponding to the
1295 entry. @var{EXPORTNAME} will be the name available for dynamic linking.
1296 @var{DATA} can be a decimal number or a hex number preceeded by @samp{0x}.
1299 @node Installation, The Wine Project, Reference Manual, Top
1300 @chapter Wine installation and configuration
1301 FIXME: write installation guide
1304 * Applying patches:: How to update Wine to a newer version.
1307 @node Applying patches, , , Installation
1308 @section Applying patches
1309 @xref{Creating patches}, for instructions on creating patches.
1311 @kbd{cd} to the top source directory for Wine, and run
1312 @code{patch -p1 < @var{patchfile}}.
1313 What needs to be done next depends to some extent on what the
1314 patch touches. For small patches which only alter C source, it can be
1315 enough to rerun @code{make}. In general, the sequence @code{configure},
1316 @code{make depend}, @code{make} is sufficient, unless the patch alters
1317 @code{[config.in]}, in which case you must regenerate @code{configure}
1318 via @code{make configure} (which just runs @code{autoconf}).
1321 @node The Wine Project, , Installation, Top
1322 @chapter The Wine project
1323 @cindex Wine project contributions
1324 @cindex project contributions to Wine
1326 If you are new to Wine and want to support this project, here are
1330 * Getting information on the API:: Official and unofficial sources
1331 of information on the @WIN32{} API.
1332 * Investigating the undocumented API:: You can find out some API
1333 information on your own.
1334 * Implementing an API type:: How to implement a data type
1335 of the API (a checklist).
1336 * Implementing an API function:: How to implement one function
1337 of the API (a checklist).
1338 * API function and type naming:: How to name API functions in Wine.
1339 * Creating patches:: How to create patches for Wine.
1340 * Adding Documentation:: Templates for the documentation.
1341 * File names:: How Wine treats @mswindows{} and
1343 * Wide character strings:: How Wine treats wide character
1347 @xref{Debugging}, for advice on how to debug Wine.
1348 @xref{Applying patches}, for instructions on applying patches.
1351 @node Getting information on the API, Investigating the undocumented API, , The Wine Project
1352 @section Official and unofficial documentation on the @mswindows{} API
1353 @cindex documentation of API functions
1354 @cindex undocumented API functions
1357 @strong{Official documentation}
1359 For documentation on @WIN32{} API functions, you might try one of these
1365 There is a free online version of the MSDN library (including
1366 documentation for the @WIN32{} API) on
1367 @url{http://www.microsoft.com/msdn/}.
1370 The @WINNT{} DDK gives information about some kernel (``executive'')
1371 routines. Some of the function documentation might also apply to user
1375 @strong{Unofficial documentation}
1377 Not all of the @WIN32{} API is well documented. Some functions are
1378 obscured, and undocumented. @xref{Ordinals}, for information about
1379 undocumented functions imported by ordinal. Getting to know what these
1380 functions do can be tiresome and tedious. Here is a quote from a
1381 news posting concerning two books that might help:
1382 @c From: vischne@ibm.net-nospam (root)
1383 @c Subject: Re: Functions
1384 @c Newsgroups: comp.emulators.ms-windows.wine
1385 @c Date: 24 Jul 97 16:45:11 GMT
1386 @c Organization: The Light
1387 @c NNTP-Posting-Host: 129.37.246.203
1388 @c Message-ID: <33d78697.0@news3.ibm.net>
1391 Well actually, there are at least _two_ books that address these problems.
1392 One is by Matt Pietrek, ``Windows 95 System Programming Secrets'', which
1393 gives some auxiliary programs for helping ferret out the information, and
1394 the other is by Shulman, ``Undocumented Windows 95''.
1397 @xref{Ordinals}, for some notes on undocumented kernel functions.
1402 @cindex book on undocumented API features by Pietrik
1403 ``Windows 95 System Programming Secrets'' @*
1405 Book & Disk Edition @*
1406 Paperback, 778 pages @*
1407 Published by IDG Books Worldwide @*
1408 Publication date: November 1, 1995 @*
1409 Dimensions (in inches): 9.25 x 7.42 x 2.06 @*
1413 @cindex book on undocumented API features by Schulman
1414 ``Undocumented Windows; A Programmers Guide
1415 to Reserved Microsoft Windows API Functions'' @*
1416 by Andrew Schulman @*
1417 Paperback, 715 pages @*
1418 Published by Addison-Wesley Pub Co @*
1419 Publication date: February 1, 1994 @*
1420 Dimensions (in inches): 9.11 x 7.37 x 1.53 @*
1424 More books on these topics (including Schulman and Pietrik): @*
1425 @url{http://www.sonic.net/~undoc/bookstore.html}
1428 More details about calling undocumented functions can be found at
1429 @url{http://ftp.uni-mannheim.de/info/OReilly/windows/win95.update/dirty.html}.
1432 In 1993 Dr. Dobbs Journal published a column called ``Undocumented
1435 You might want to check out BYTE from December 1983 as well.
1436 @* FIXME: is that to be taken seriously?
1438 And you might try to find out something on your own. @xref{Investigating
1439 the undocumented API}, for details.
1442 But, all in all, @url{news:comp.emulators.ms-windows.wine} says
1443 @c From: dacut@henry.ece.cmu.edu (David A. Cuthbert)
1444 @c Subject: Re: Getting Internet Explorer to work
1445 @c Newsgroups: comp.emulators.ms-windows.wine
1446 @c Date: 24 Jul 1997 03:10:30 GMT
1447 @c Organization: Electrical & Computer Engineering, Carnegie Mellon University
1448 @c Reply-To: henry.ece.cmu.edu!dacut
1449 @c Message-ID: <5r6h36$86c@fs7.ece.cmu.edu>
1450 @c NNTP-Posting-Host: henry.ece.cmu.edu
1453 Unfortunately, short of getting something like NuMega's SoftIce, I
1454 don't think there's a ``good'' reference on the mystery <100 ordinals in
1459 @node Investigating the undocumented API, Implementing an API type, Getting information on the API, The Wine Project
1460 @section Investigating the undocumented API
1461 @cindex undocumented API investigation
1462 @cindex parameters of undocumented API functions
1463 @cindex stdcall calling convention
1464 @cindex C calling convention
1465 @cindex API function parameters investigation
1466 @cindex stack handling under stdcall calling
1468 Besides reading the documentation in @ref{Getting information on the API},
1469 you can find out some properties of API functions on your own.
1471 Sometimes it is not known how many arguments an undocumented DLL
1472 function takes. Here is a text from a news posting that gives some
1473 hints on how you might proceed in this case.
1475 @c The following text is closely quoted from:
1476 @c From: dacut@henry.ece.cmu.edu (David A. Cuthbert)
1477 @c Subject: Win32 stub functions (Claus Fischer, please read)
1478 @c Newsgroups: comp.emulators.ms-windows.wine
1479 @c Date: 7 Aug 1997 22:33:09 GMT
1480 @c Organization: Electrical & Computer Engineering, Carnegie Mellon University
1481 @c Reply-To: henry.ece.cmu.edu!dacut
1482 @c Message-ID: <5sdif5$qt3@fs7.ece.cmu.edu>
1484 The problem with implementing stubs for @WIN32{} functions is that it is
1485 not sufficient to return a default value (usually 0) and leave the
1486 stack the way we found it. For most @WIN32{} functions -- those that use
1487 the @dfn{stdcall} calling convention -- the arguments sent to the function
1488 are removed from the stack.
1490 Some background: On the i386 class of machines, stack entries are
1491 usually dword (4 bytes) in size, little-endian. The stack grows
1492 downward in memory. The stack pointer, maintained in the @samp{esp}
1493 register, points to the last valid entry; thus, the operation of
1494 pushing a value onto the stack involves decrementing @samp{esp} and then
1495 moving the value into the memory pointed to by esp (i.e., @code{push p}
1496 in assembly resembles @code{*(--esp) = p;} in C). Removing (popping)
1497 values off the stack is the reverse (i.e., @code{pop p} corresponds to
1498 @code{p = *(esp++);}).
1500 In the @dfn{stdcall} calling convention, arguments are pushed onto the
1501 stack right-to-left. For example, the C call
1504 myfunction(40, 20, 70, 30);
1507 is expressed in Intel assembly as:
1517 In addition, the called function is responsible for removing the
1518 arguments off the stack. Thus, before the call to myfunction, the
1519 stack would look like:
1522 [local variable or temporary]
1523 [local variable or temporary]
1530 After the call returns, it should look like:
1533 [local variable or temporary]
1534 esp -> [local variable or temporary]
1537 To restore the stack to this state, the called function must know how
1538 many arguments to remove (which is the number of arguments it takes).
1539 This is a problem if the function is undocumented.
1541 One way to attempt to document the number of arguments each function
1542 takes is to create a wrapper around that function that detects the
1543 stack offset. @file{WinRelay} (see below) was written to create such
1544 wrappers. Essentially, each wrapper assumes that the function will take
1545 a large number of arguments (by default, 64 in @file{WinRelay}). The
1546 wrapper copies each of these arguments into its stack, calls the actual
1547 function, and then calculates the number of arguments by checking esp
1548 before and after the call.
1550 @cindex bsod (blue screen of death)
1551 @cindex blue screen of death
1552 The main problem with this scheme is that the function must actually
1553 be called from another program. Many of these functions are seldom
1554 used. An attempt was made to aggressively query each function in a
1555 given library (@file{ntdll.dll}) by passing 64 arguments, all 0, to each
1556 function. Unfortunately, @WINNT40{} quickly goes to a blue screen
1557 of death (@dfn{bsod}), even if the program is run from a
1558 non-administrator account.
1560 Another method that has been much more successful is to attempt to
1561 figure out how many arguments each function is removing from the
1562 stack. This instruction, @code{ret hhll} (where @samp{hhll} is the
1563 number of bytes to remove, i.e. the number of arguments times 4), contains
1564 the bytes @samp{0xc2 ll hh} in memory. It is a reasonable assumption
1565 that few, if any, functions take more than 16 arguments; therefore,
1566 @samp{hh} is 0x0 and @samp{ll} is less than 0x40. This utility,
1567 @file{MakeSpec} (see below), simply queries the address of a function
1568 and looks for the first occurrence of the bytes @samp{0xc2 ll 0x0},
1569 where @math{@samp{ll} <= 0x40}.
1571 Of course, this is not without errors. @code{ret 00ll} is not the only
1572 instruction that can have the byte sequence @samp{0xc2 ll 0x0}; for
1573 example, @code{push 0x000040c2} has the byte sequence
1574 @samp{0x68 0xc2 0x40 0x0 0x0}, which matches the above. Properly, the
1575 utility should look for this sequence only on an instruction boundary;
1576 unfortunately, finding instruction boundaries on an i386 requires
1577 implementing a full disassemble -- quite a daunting task. Besides,
1578 the probability of having such a byte sequence that is not the actual
1579 return instruction is fairly low.
1581 Much more troublesome is the non-linear flow of a function. For
1582 example, consider the following two functions:
1586 jmp somefunction1_impl
1595 @file{MakeSpec} would incorrectly list both @code{somefunction1} and
1596 @code{somefunction2} as taking only a single argument, whereas
1597 @code{somefunction1} really takes two arguments.
1599 With these limitations in mind, it is possible to implement more stubs
1600 in Wine and, eventually, the functions themselves.
1604 The program @file{WinRelay} can be downloaded from
1605 @url{http://www.ece.cmu.edu/afs/ece/usr/dacut/www/src},
1606 and @file{MakeSpec} will be available from the same location. You can
1607 compile them with Borland's C++Builder; you should not optimize when
1608 compiling (@file{WinRelay} needs the stack frames).
1611 @node Implementing an API type, Implementing an API function, Investigating the undocumented API, The Wine Project
1612 @section Implementing an API type
1614 Here is a checklist that should help you writing your first API type. It
1615 will of course not tell you which elements to put into the type
1616 (assuming it is a structure), but it should help you along the way of
1617 integrating this type into Wine.
1618 @xref{Implementing an API function}, for comparison.
1622 Find out how the type should be named in Wine and in the DLL's.
1623 @xref{API function and type naming}, for details.
1626 Find out where the type should go. Please try to keep the header files
1627 structure as similar to @mswindows{} as possible.
1630 Prepare for the later patch (by saving the original files before you
1631 work on them). @xref{Creating patches}, for details.
1634 Put the type declaration into the header file.
1637 Make sure the declaration is syntactically correct, i.e. it does not
1638 keep Wine from compiling.
1641 Make sure the declared type is layout-compatible with
1642 @mswindows{}-compiled types. Especially keep an eye on the packing of
1644 @* FIXME: a reference to packed structures here.
1647 Build Wine and test the type, if possible. If you cannot test the
1648 type by implementing a proper API function, write a small test program
1649 to test it on its own. Or rather stop here.
1652 Write the documentation of the type in the @file{wine.texinfo}
1653 file. @xref{Adding Documentation}, for details.
1654 With types, be especially careful and document all the details. Also
1655 document all constants or flags that are used in the type.
1658 Create an entry in the @file{ChangeLog} file.
1661 Collect some of these changes, and create a patch. @xref{Creating
1662 patches}, for details.
1665 Mail the patch to Alexandre Julliard, @email{julliard@@winehq.com}.
1668 Wait for the patch to appear in the official distribution.
1672 @node Implementing an API function, API function and type naming, Implementing an API type, The Wine Project
1673 @section Implementing an API function
1675 Here is a checklist that should help you writing your first API
1676 function. It will of course not tell you what to do in the function,
1677 but it should help you along the way of integrating this function into
1682 Make sure all data types that appear in function arguments are properly
1683 declared in Wine. Otherwise, start with the data types.
1686 Find out how the function should be named in Wine and in the DLL's.
1687 @xref{API function and type naming}, for details.
1690 Find out what the function should do. This may be tricky for
1691 undocumented functions. @xref{Getting information on the API}, for some
1695 Find out where the function should go:
1698 Which header file for the prototype.
1700 Which C source file.
1702 Which DLL(s), and which ordinal the function will take there. Perhaps
1703 the function name is already present in one of the @file{.spec}-files in
1704 the @file{if1632} directory.
1708 Prepare for the later patch (by saving the original files before you
1709 work on them). @xref{Creating patches}, for details.
1712 Put the prototype into the header file, and the code into the C file.
1715 Make sure the code compiles.
1718 Create or change the information for the DLL entry points in the
1719 @file{.spec}-file in the @file{if1632} directory.
1720 @xref{The build program}, for details of the DLL spec files.
1723 Build Wine and test the function, if possible. If you cannot test the
1724 function in Wine, write a small test program to test it on its own.
1727 Write the documentation of the function in the @file{wine.texinfo}
1728 file. @xref{Adding Documentation}, for details.
1731 Create an entry in the @file{ChangeLog} file.
1734 Collect some of these changes, and create a patch. @xref{Creating
1735 patches}, for details.
1738 Mail the patch to Alexandre Julliard, @email{julliard@@winehq.com}.
1741 Wait for the patch to appear in the official distribution.
1745 @node API function and type naming, Creating patches, Implementing an API function, The Wine Project
1746 @section API function and data type naming conventions
1747 @cindex API function names
1748 @cindex API type names
1749 @cindex names of API functions and types
1750 @cindex naming scheme for API functions and types
1751 @cindex suffixes for API functions and types
1752 @cindex endings of API function and type names
1754 This section describes Wine's naming scheme for API functions and data
1757 The purpose of these naming conventions is to ensure that
1760 both the @WIN16{} and @WIN32{} API are supported within the same source
1763 both wide character functions (with @unicode{} strings) and 8 bit
1764 character functions (with @ascii{} or extended @ascii{} encoding) are
1767 the source code can be shared between the emulator and the library
1771 A function or data type whose name in the @mswindows{} API is @var{xxx}
1772 will in the Wine code have the following name(s):
1775 This is the version for the 16 bit API. You might call it the ``16 bit
1776 version'' except that the function itself of course runs in true 32 bit
1777 mode (being part of Wine). So, the correct meaning of the suffix is that
1778 this function is part of the 16 bit API.
1780 This is the version for the 32 bit API. Use this suffix only if the
1781 function does not use character strings in its parameters or return
1782 values. Otherwise use the next two.
1784 This is the version for the 32 bit API which uses @ascii{} strings (or
1785 rather, strings with 8 bit character encodings, i.e. the standard C
1786 @code{char} type). This version always goes together with another
1787 version, using the next suffix.
1789 This is the version for the 32 bit API which uses @unicode{} strings,
1790 i.e. strings with wide characters. It goes together with the @ascii{}
1794 So, where the @mswindows{} API offers one name, Wine actually has two or
1795 three different functions implemented (which will hopefully share a
1796 large part of the code).
1798 Wine allows to use its API functions in two ways. The emulator part of
1799 Wine provides DLL's for the @mswindows{} programs it can run. The
1800 library part of Wine provides a @unix{} programmer with the facility to
1801 use the Wine API's in a standard @unix{} program.
1804 * Access from the emulator:: How to access API functions and types
1805 from applications that are run in the
1807 * Access in the library:: How to access API functions and types
1808 from applications that are linked with
1810 * Access from inside Wine:: How to access API functions and types
1811 from inside the Wine code.
1814 @node Access from the emulator, Access in the library, , API function and type naming
1815 @subsection Accessing API functions and types from the emulator
1816 @cindex access to DLL API functions and types
1817 @cindex Wine emulator access to API functions and types
1818 @cindex emulator access to Wine API functions and types
1820 The emulator part of Wine provides the hooks for dynamically linking the
1821 API functions to the @mswindows{} executables (@file{.EXE}-files). The
1822 Wine emulator contains all versions (16 or 32 bit, @ascii{} or
1823 @unicode{}) of the API functions in one executable. The emulator
1824 performs a mapping from the @mswindows{} name of the function,
1825 by which the executable calls it, to one of the Wine internal names that
1826 have been used in coding it.
1828 This mapping is done by the built-in DLL handling code of Wine. A
1829 programmer of Wine has to declare the function in one of the virtual
1830 DLL's that are provided by Wine. The declarations are done in the
1831 @file{.spec}-files in the @file{if1632/} directory. @xref{The build
1832 program}, for details.
1834 The @mswindows{} application simply calls the API function by its
1835 standard @mswindows{} name. Wine will apply the correct mapping
1836 according to Wine's selected appearance (as a 16 bit or 32 bit emulator,
1837 which is a parameter on invocation of Wine).
1840 @node Access in the library, Access from inside Wine, Access from the emulator, API function and type naming
1841 @subsection Accessing API functions and types in the library
1842 @cindex Wine library API function and type access
1843 @cindex access to Wine library API functions and types
1845 If Wine is built as a library, and linked to a user-level main program,
1846 the user will also use the standard @mswindows{} names for the API
1849 Some macros are defined in @file{include/wintypes.h} which perform the
1850 necessary name mappings.
1852 These macros are (see the examples below):
1853 @deffn_winemacro WINELIB_NAME (@var{xxx})
1854 This macro replaces @var{xxx} by one of @var{xxx}16 or
1855 @var{xxx}32, depending on the definition of the symbols
1856 @code{WINELIB16} and @code{WINELIB32}. @var{xxx} should
1857 be the name of an API function that uses no string arguments.
1858 Use this macro with a @code{#define} to establish the API name @var{xxx}.
1860 @deffn_winemacro WINELIB_NAME_AW (@var{xxx})
1861 This macro replaces @var{xxx} by one of @var{xxx}16, @var{xxx}32A, or
1862 @var{xxx}32W, depending on the definition of the symbols
1863 @code{WINELIB16}, @code{WINELIB32}, and @code{UNICODE}. @var{xxx} should
1864 be the name of an API function that uses string arguments.
1865 Use this macro with a @code{#define} to establish the API name @var{xxx}.
1867 @deffn_winemacro DECL_WINELIB_TYPE (@var{xxx})
1868 This macro declares @var{xxx} to be an equivalent to @var{xxx}16 or
1869 @var{xxx}32, depending on the definition of the symbols
1870 @code{WINELIB16} and @code{WINELIB32}. @var{xxx} should
1871 be the name of an API data type that contains no string arguments.
1873 @deffn_winemacro DECL_WINELIB_TYPE_AW (@var{xxx})
1874 This macro declares the type @var{xxx} to be an equivalent to
1875 @var{xxx}16, @var{xxx}32A, or @var{xxx}32W, depending on the definition
1876 of the symbols @code{WINELIB16}, @code{WINELIB32}, and
1877 @code{UNICODE}. @var{xxx} should be the name of an API data type that
1878 contains string arguments.
1881 If Wine is compiled as an emulator, these macros have no effect, for the
1882 mapping is then done by the DLL code. This means that within Wine the
1883 name @var{xxx} itself will not be defined.
1885 Note: If the definition of @var{xxx} is exactly the same in @WIN16{} and
1886 @WIN32{}, you can simply use the same name as @mswindows{}.
1888 Here are some examples:
1890 /* A simple type without strings */
1891 typedef short INT16;
1893 DECL_WINELIB_TYPE(INT);
1895 /* A type with strings */
1896 typedef struct @{ /* Win32 ASCII data structure */ @} WNDCLASS32A;
1897 typedef struct @{ /* Win32 Unicode data structure */ @} WNDCLASS32W;
1898 typedef struct @{ /* Win16 data structure */ @} WNDCLASS16;
1899 DECL_WINELIB_TYPE_AW(WNDCLASS);
1901 /* A function with strings */
1902 ATOM RegisterClass16( WNDCLASS16 * );
1903 ATOM RegisterClass32A( WNDCLASS32A * );
1904 ATOM RegisterClass32W( WNDCLASS32W * );
1905 #define RegisterClass WINELIB_NAME_AW(RegisterClass)
1908 The Winelib user can then say (in the application program):
1911 WNDCLASS wc = @{ @dots{} @};
1912 RegisterClass( &wc );
1914 and this will use the correct declaration depending on the definitions
1915 @code{WINELIB16}, @code{WINELIB32}, and @code{UNICODE}.
1917 Here are the primary defines that are used when Wine is compiled as a
1919 @defvr_cwine WINELIB16
1920 If this @code{#define} is set, the Wine library is to be compiled in its
1921 16 bit form. That means, the 16 bit variants of all functions will be
1922 used and the appearance of the application linked with the Wine library
1923 will be that of a 16 bit application. Of course, both the application
1924 and the Wine library function really run in 32 bit mode. The switch only
1925 selects the function with the name ending in @code{@dots{}16}, which
1926 will perhaps have a behaviour different from its 32 bit counterpart.
1928 @defvr_cwine WINELIB32
1929 If this @code{#define} is set, the Wine library is to be compiled in its
1930 32 bit form. That means, the 32 bit variants of all functions will be
1931 used and the appearance of the application linked with the Wine library
1932 will be that of a 32 bit application.
1934 @defvr_cwine UNICODE
1935 This @code{define} is used to select one of two possible 32 bit
1936 variants. Functions and data types of the 32 bit API come in two
1937 flavours: one handling @ascii{} strings (or rather strings with
1938 characters encoded in 8 bit), the other @unicode{} strings. This define
1939 selects the correct variant. As a user of the Wine library, you are
1940 responsible to use the correct character type in your part of the
1941 application which accesses the Wine API functions and data types.
1944 These switches are automatically set when Wine is compiled as a library.
1947 @node Access from inside Wine, , Access in the library, API function and type naming
1948 @subsection Accessing API functions from within Wine
1949 @cindex explicit names of API functions and types
1951 Within Wine and during the compilation of Wine, you cannot rely on the
1952 @mswindows{} names of the API functions and data types. If Wine is
1953 compiled as a library, they will be defined; if Wine is compiled as an
1954 emulator, they won't.
1956 You therefore have to access all functions and data types by their full
1957 names, with the proper suffix explicitly appended. In Wine, the 16 bit
1958 and 32 bit versions of the functions are distinct entities, which might
1959 (theoretically) show a completely different behaviour. They may even
1960 call each other (and they will quite frequently).
1962 Therefore Wine is a conglomerate that contains all two or
1963 three flavours of each function at once, and exports to the
1964 application whichever of these is appropriate. Remember that inside
1965 Wine, there is no memory segmentation, so all functions are 32 bit.
1966 The 16-to-32 bit mapping is done on exporting the DLL functions.
1969 @node Creating patches, Adding Documentation, API function and type naming, The Wine Project
1970 @section Creating patches
1971 @xref{Applying patches}, for instructions on applying patches.
1973 Patches are created with the program @code{diff}. You need a copy
1974 of clean source tree to diff against. The @samp{-u} option, to create
1975 unified diffs, is popular but not obligatory.
1976 For changes to a single file,
1977 @code{diff -u wine990101/windows/win.c mywine/windows/win.c > win_patch}
1979 To generate a complete diff between your tree and the distribution,
1980 use @code{diff -uR wine990101 mywine}.
1982 This assumes that the original distribution and your personal tree
1983 have the same parent directory, from which you make the diff.
1984 This ensures a consistent format for the diffs, which in turn
1985 is necessary so that they can be applied consistently as described in
1986 @xref{Applying patches}.
1988 @node Adding Documentation, File names, Creating patches, The Wine Project
1989 @section Adding Documentation
1992 Here are some templates which should help you collaborate on this
1993 documentation. Read the text below before examining them.
1997 * Type Template:: How to document data types in Wine's
1999 * Function Template:: How to document an (API) function of
2004 These are my tips for adding documentation.
2006 Do not simply copy documentation from @mswindows{} related
2007 material. Except from risking copyright violations, which you would not
2008 want to do, there is another aspect to that:
2009 As Wine is a product to run on @unix{} and @unix{}-like workstations,
2010 it seems a good idea to me to organize this documentation primarily for
2011 the well-trained @unix{} reader. Please keep that in mind when you add
2014 Finally, read the info pages for @code{texinfo}.
2016 The rest of this section provides some templates which can serve as a
2017 start in writing documentation.
2019 @subsection Template introduction
2021 On the following pages you will find some @code{texinfo} templates, which
2022 should help you collaborate on this documentation.
2025 These templates give hints on how to document data types, functions,
2026 variables, constants etc. in Wine.
2027 As documentation evolves, you will find common features of data types
2028 that should be described in a unified fashion. In such a case, please
2029 add a corresponding style guide-line here, in this very place, to help
2030 keeping documentation of data types unified.
2033 Start out the type or function with a new node. Write a comment before
2034 the node, listing all data types (and functions) described in the node,
2038 @@c *** struct FILETIME ***
2040 @@node Type FILETIME, NextNodeName, PreviousNodeName, ParentNodeName
2043 The node command describes the node name and the names of the next node,
2044 the previous node, and the parent node. The parent node should contain
2045 a menu entry for this node. The previous node is the node that appears
2046 before this node in the parent node menu. The next node is the node
2047 succeeding this one in the parent node menu. If there is no previous or
2048 next node, omit the name (putting just a single space between the two
2051 The node name must be a unique sequence of words. Case is important, so
2052 @emph{Type} and @emph{type} are distinct. The node name must not contain
2053 special characters like @samp{@@, @{, @}} or the comma. If you need to
2054 give a node the same name as a function, data type, etc., use the words
2055 @samp{Type}, @samp{Function}, etc. before the identifier.
2057 Always put the names of the node and its links on the same line, even if
2058 it gets rather long.
2060 If there are two or more data types or functions described in the node,
2061 adapt the comment like this:
2065 @@c *** long Y() ***
2067 @@node Ints and Longs, NextNodeName, PreviousNodeName, ParentNodeName
2070 After the node name, put a sectioning command, such as @samp{@@chapter},
2071 @samp{@@section}, @samp{@@subsection}, or @samp{@@subsubsection}.
2072 Without that command, cross references to the node will fail.
2074 @@subsubsection Type FILETIME
2077 Start the description of the type(s) or function(s) with a single
2078 non-indented paragraph that gives a one-line description of the type(s)
2079 or function(s) and states the include files that are required.
2082 File times in Wine are specified by the data type @@code@{FILETIME@},
2083 defined in @@file@{windows.h@}.
2085 If several types or functions are closely connected, use one paragraph
2086 as a common description. If more paragraphs are required for a proper
2087 description, indent all but the first of them.
2089 Then start the definition of the data type or function. Use the proper
2090 macro, which you will find defined in the beginning of the texinfo file.
2091 If appropriate, add your own macros.
2092 Again, put everything that belongs to the header into a single line.
2093 Use continuation lines for additional headers.
2095 @@deftp_w32 FILETIME
2096 @@deftpx_w32 LPFILETIME
2099 In the definition, give a verbal explanation of the data type or
2100 function. The explanation should be rather complete, exact, and
2101 comprehensible, than well-structured. This is the point where you can
2102 tell everything you want. Do not be afraid of wasting space.
2103 Do not describe the @mswindows{} situation but only say what Wine
2104 does. That is important. (Sometimes they might even do the same.)
2106 This is the data type for specifying file times. The file times are
2107 stored with 64 bit precision. The actual data type is a structure with
2108 two 32 bit values which are interpreted as the low and high parts of a
2109 64-bit value. This value gives a time measured in a granularity of 100
2110 nanoseconds, so 1.5 seconds are specified by a value of 15,000,000. In
2111 Wine, this 64-bit value is signed, with the sign taken from the high
2112 part. The lower part is used as unsigned.
2115 For data types, it is recommended to quote the definition from the
2116 header file. For a function, you might give a short example of its
2117 usage. You may also put one example in the end of a node that explains
2118 several of the functions in the node. Remember that cut-and-paste from a
2119 well prepared example will help the readers write their code.
2121 The definition of @@code@{FILETIME@} reads:
2125 INT32 dwLowDateTime;
2126 INT32 dwHighDateTime;
2127 @@@} FILETIME, *LPFILETIME;
2131 You could also use the @code{cindex} command which creates an entry in
2132 the concept index. The @code{texinfo} manual recommends to keep concept
2133 entries distinct, so that a single concept index entry puts to one
2134 well-defined place in the document. Use lower case letters for index
2135 entries, unless they are proper names or quotes from actual code.
2137 @@cindex epoch in file time
2138 The @@code@{FILETIME@} structure may be used to hold absolute or relative
2139 times. Absolute times are given as the number of 100 nanoseconds
2140 intervals elapsed since 1 January 1601, 00:00:00 UTC (Coordinated
2141 Universal Time, which is GMT, Greenwich Mean Time). This might be
2142 called the @@dfn@{epoch@} for file times. With a signed 64-bit value, this
2143 representation covers absolute times of 29247 years around the epoch.
2146 After the verbal documentation, you can add some special fields
2147 describing bugs, implementation dependencies etc. Two of these are
2148 recommended to attach to all descriptions. One describes the
2149 conformance of the data type or function to @mswindows{} products,
2150 i.e. whether the item is also present in @WINNT{} and @WIN95{}. The
2151 other one describes known differences of the Wine item to its
2152 @mswindows{} counterpart. Both will greatly help in porting software
2153 from @mswindows{} to Wine and vice versa.
2158 In @@mswindows@{@}, the elements of the structure are apparently of type
2159 @@code@{DWORD@}. Whether the full 64 bit value is interpreted as signed or
2160 unsigned I do not know.
2163 If you find that more of these property attributes are necessary, feel
2164 free to create your own ones. But keep in mind that they should be
2165 applicable more or less to all described items. Very special properties
2166 will better be put into the verbal text.
2168 Finally end the definition of the data type or function:
2173 Do not forget to enter the node in the menu of its top node, and do
2174 properly link the node to its successor and predecessor.
2181 @node Type Template, Function Template, , Adding Documentation
2182 @subsection Data type template
2186 @node Function Template, , Type Template, Adding Documentation
2187 @subsection API function template
2189 Functions should be given category names, to indicate which API they
2190 belong to. Please add items to the list of categories possible.
2192 Category: WIN32 function
2196 @@c ***GetFileTime() ***
2198 @@node Get File Times, , Compare File Times, File Times
2200 The Wine function @@code@{GetFileTime@} returns the creation time and
2201 the times of last the read and modification access to a file. It is
2202 defined in @@file@{windows.h@}.
2204 @@deftypefn_w32 BOOL GetFileTime (@@w@{HANDLE @@var@{file@},@} @@w@{LPFILETIME @@var@{ctime@},@} @@w@{LPFILETIME @@var@{atime@},@} @@w@{LPFILETIME @@var@{mtime@})@}
2205 This function obtains for the specified @@var@{file@} the creation time
2206 @@var@{ctime@}, the time of the last access to the file @@var@{atime@}, and
2207 the time of the last modification (write) to the file, @@var@{mtime@}.
2208 The @@var@{file@} handle must have been obtained by opening the file with
2209 @@code@{GENERIC_READ@} access. The file time arguments of this function are
2210 pointers to @@code@{FILETIME@} variables, which are filled with a value that
2211 indicates an absolute time in UTC. To convert these values to local
2212 times, use the function @@code@{FileTimeToLocalFileTime@}. If you do not
2213 need some of the times, you can pass a @@code@{NULL@} pointer.
2214 The function returns @@code@{TRUE@} on success, @@code@{FALSE@} on failure.
2223 @node File names, Wide character strings, Adding Documentation, The Wine Project
2224 @section @mswindows{} and @unix{} file names in Wine
2225 @cindex file names in Wine
2226 @cindex Windows file names
2227 @cindex DOS file names in Wine
2228 @cindex UNIX file names in Wine
2229 @cindex POSIX file names in Wine
2233 @node Wide character strings, , File names, The Wine Project
2234 @section Wide character strings in API functions
2235 @cindex unicode strings in API functions
2236 @cindex wide character strings in API functions
2237 @cindex strings in API functions
2238 @cindex ascii strings in API functions
2239 @cindex 16 bit characters in API functions
2240 @cindex wchar_t in API functions
2242 Presently, all wide character strings in API functions of Wine are
2243 internally converted to 8 bit representation. Thus, the @WIN32{} API
2244 with @unicode{} strings is not fully functional for the application
2245 programmer at present.
2247 Even so, application programmers might consider developing their
2248 applications in wide character format with Wine, as future versions
2249 might bring a change. This might come when a @unix{} filesystem can
2250 handle @unicode{} file names.
2252 Furthermore, the @unicode{} API is required to let Wine run @mswindows{}
2253 applications which have been compiled for wide character strings.
2255 In Wine, wide characters are strictly 16 bit; the @code{wchar_t} type of
2256 standard C can therefore not be used.
2258 @node Concept Index, , , Top
2259 @comment node-name, next, previous, up
2260 @unnumbered Concept Index
2263 @node Type Index, , , Top
2264 @comment node-name, next, previous, up
2265 @unnumbered Type Index
2268 @node Function Index, , , Top
2269 @comment node-name, next, previous, up
2270 @unnumbered Function Index
2273 @node Variable Index, , , Top
2274 @comment node-name, next, previous, up
2275 @unnumbered Variable, Constants, and Variable-like Macros Index
2278 @node File Index, , , Top
2279 @comment node-name, next, previous, up
2280 @unnumbered File and Program Index