Release 980517
[wine] / documentation / wine.texinfo
1 \input texinfo   @c -*-texinfo-*-
2 @c %**start of header
3 @setfilename wine.info
4 @settitle Wine Reference Manual
5 @iftex
6 @afourpaper
7 @end iftex
8 @c %**end of header
9
10 @ifinfo
11 @format
12 START-INFO-DIR-ENTRY
13 * wine: (wine.info).             The Windows Emulator.
14 END-INFO-DIR-ENTRY
15 @end format
16 @end ifinfo
17
18 @iftex
19 @c @finalout
20 @end iftex
21
22 @ifinfo
23 This file documents Wine, the Windows Emulator.
24
25 @c 
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.
29
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.
33
34 @ignore
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).
40
41 @end ignore
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''.
45
46 @sp 4
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.
56 @end ifinfo
57
58 @c begin chapters on right pages
59 @setchapternewpage odd
60
61 @titlepage
62
63 @title{The Wine Reference Manual}
64 @subtitle{Edition 0.0.5, February 1998}
65
66 @author{The Wine Team}
67 @c The following two commands start the copyright page.
68 @page
69 @vskip 0pt plus 1filll
70
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.
74
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.
78
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''.
82
83 @sp 4
84 FIXME: UNIX and POSIX trademarks. @*
85 X11 @*
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.
93 @end titlepage
94
95
96
97 @c
98 @c SETTINGS, DEFINES, MACROS
99 @c
100
101 @c Edit this macro manually in the above parts of the document
102 @macro winemanualversion
103 0.0.4
104 @end macro
105
106 @c Edit this macro manually in the above parts of the document
107 @macro winemanualdate
108 February 1998
109 @end macro
110
111 @c Edit this macro manually into the TeX titlepage
112 @macro winemanualtitle
113 The Wine Reference Manual
114 @end macro
115
116 @c
117 @macro winelib
118 Winelib
119 @end macro
120 @c
121 @c MICROSOFT
122 @c
123
124 @c FIXME: automatic trademark reference
125 @macro mswindows
126 MS-Windows
127 @end macro
128
129 @c FIXME: automatic trademark reference
130 @c spell it always the same
131 @macro WIN32
132 WIN32
133 @end macro
134 @macro WIN16
135 WIN16
136 @end macro
137
138 @c FIXME: automatic trademark reference
139 @macro WINNT
140 Windows NT
141 @end macro
142
143 @c FIXME: automatic trademark reference
144 @macro WINNT40
145 Windows NT 4.0
146 @end macro
147
148 @c FIXME: automatic trademark reference
149 @macro WIN95
150 Windows 95
151 @end macro
152
153
154 @c
155 @c THE OTHERS
156 @c
157 @c FIXME: automatic trademark reference
158 @macro unix
159 UNIX
160 @end macro
161
162 @c FIXME: automatic trademark reference
163 @macro posix
164 POSIX
165 @end macro
166
167 @macro unicode
168 Unicode
169 @end macro
170
171 @macro ascii
172 ASCII
173 @end macro
174
175 @c
176 @c THIS MANUAL
177 @c
178
179 @c flag out differences to MS-Windows
180 @macro windiff
181 @emph{Differences to @mswindows{}:} @*
182 @end macro
183
184 @macro windiffnone
185 @windiff{}
186 No differences known.
187 @end macro
188
189 @c tell whether function is present in Windows 95 and/or NT
190 @macro winconf
191 @emph{Conformance to @mswindows{}:} @*
192 @end macro
193
194 @macro winconfall
195 @winconf{}
196 Present in @WIN95{} and @WINNT{}.
197 @end macro
198
199 @c give information about completion
200 @macro completion
201 @emph{Completion status:} @*
202 @end macro
203
204 @macro completionnone
205 @completion{}
206 Not yet implemented.
207 @end macro
208
209 @c
210 @c MACROS FOR FUNCTIONS, TYPES, CONSTANTS, VARIABLES
211 @c
212
213 @c Constants in the WIN32 API
214 @macro defvr_cw32 {restofline}
215 @defvr Constant \restofline\
216 @end macro
217 @macro defvrx_cw32 {restofline}
218 @defvrx Constant \restofline\
219 @end macro
220
221 @c Functions in the WIN32 API
222 @macro deftypefn_w32 {restofline}
223 @deftypefn {WIN32 function} \restofline\
224 @end macro
225 @macro deftypefnx_w32 {restofline}
226 @deftypefnx {WIN32 function} \restofline\
227 @end macro
228
229 @c Types in the WIN32 API
230 @macro deftp_w32 {restofline}
231 @deftp {Data type} \restofline\
232 @end macro
233 @macro deftpx_w32 {restofline}
234 @deftpx {Data type} \restofline\
235 @end macro
236
237 @c Macros internal to Wine
238 @macro deffn_winemacro {restofline}
239 @deffn {Wine internal macro} \restofline\
240 @end macro
241 @macro deffnx_winemacro {restofline}
242 @deffn {Wine internal macro} \restofline\
243 @end macro
244
245 @c Constants internal to Wine
246 @macro defvr_cwine {restofline}
247 @defvr {Wine internal constant} \restofline\
248 @end macro
249 @macro defvrx_cwine {restofline}
250 @defvrx {Wine internal constant} \restofline\
251 @end macro
252
253
254 @c
255 @c TOP NODE
256 @c
257 @ifinfo
258 @node Top, Copying, (dir), (dir)
259 @top Wine
260
261 This is edition @winemanualversion{}, last updated @winemanualdate{},
262 of @winemanualtitle{}.
263
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.
267
268 Wine is free software. Wine is still in development-only state.
269 @end ifinfo
270
271 @menu
272 * Copying::                     License, Warranty, and Authors of Wine.
273 * Introduction::                A short overview.
274 * Reference Manual::            The Wine reference manual.
275 * Installation::                Installing and configuring Wine.
276 * The Wine Project::            How to contribute to Wine.
277 * Concept Index::               Index of concepts and names.
278 * Type Index::                  Index of types and type qualifiers.
279 * Function Index::              Index of functions and function-like
280                                 macros.
281 * Variable Index::              Index of variables, constants, and
282                                 variable-like macros.
283 * File Index::                  Index of programs and files.
284 @end menu
285
286 @node Copying, Introduction, Top, Top
287
288 @unnumbered License, Warranty, and Authors of Wine
289 @cindex copying conditions for Wine
290 @cindex conditions for copying Wine
291 @cindex Wine copying conditions
292
293 The Wine license, warranty, and list of authors together form the
294 copyright for Wine. Read these sections carefully.
295
296 @menu
297 * License::                     The Wine license.
298 * Warranty::                    Wine comes with no warranty.
299 * Authors::                     The persons that contributed to Wine.
300 @end menu
301
302 @node License, Warranty, , Copying
303 @cindex Wine license
304 @cindex license of Wine
305
306 @unnumberedsec The Wine License
307 Wine is distributed under the following copyright.
308
309 @quotation
310 @include LICENSE
311 @end quotation
312
313 @node Warranty, Authors, License, Copying
314 @cindex Wine warranty
315 @cindex warranty of Wine
316
317 @unnumberedsec The Wine Warranty
318
319 @quotation
320 @include WARRANTY
321 @end quotation
322
323 @node Authors, , Warranty, Copying
324 @cindex Wine authors
325 @cindex authors of Wine
326 @cindex copyright holders of Wine
327 @cindex Wine copyright holders
328
329 @unnumberedsec The Wine Authors
330
331 @quotation
332 @include AUTHORS
333 @end quotation
334
335 These persons also hold the copyright on Wine.
336
337 The overall coordination is done by @*
338 Alexandre Julliard @*
339 @email{julliard@@lrc.epfl.ch}
340
341
342
343 @node Introduction, Reference Manual, Copying, Top
344 @chapter Introduction
345
346 @center Wine:
347 @center the WINdows Emulator,
348 @center or Wine Is Not an Emulator
349
350 FIXME: make an easy-readable fluent text out of this.
351
352 Welcome to @winemanualtitle{}. This is edition @winemanualversion{},
353 last updated @winemanualdate{}.
354
355 @strong{What is Wine?}
356
357 Wine is a program that allows running MS-Windows programs under X11.
358
359
360 Wine incorporates two features, the program loader and @winelib{}:
361 @enumerate
362 @item
363 You can run @mswindows{} binaries (programs) in Wine. Wine contains a
364 program loader which loads and executes an @mswindows{} binary. It uses
365 the @winelib{} features of Wine to translate @WIN32{} and @WIN16{} calls
366 to their @unix{}/X11 equivalent.
367
368 Both 16 bit and 32 bit binaries can be loaded.
369 @item
370 @winelib{}: Wine can also be used as a library which implements the 
371 @mswindows{} API on top of a @unix{} or @unix{}-like operating system
372 with X11. @winelib{} (i.e. the Wine library) translates @WIN16{} or
373 @WIN32{} API calls to their @unix{}/X11 equivalent.
374
375 You can write a user-level application program that calls the @WIN16{}
376 or @WIN32{} API functions and compile it on a @unix{} box.
377 @end enumerate
378
379 @strong{Status}
380
381 Wine is still at development stage. The file @file{ANNOUNCE} says,
382 ``This is still a developer's only release.  There are many bugs and
383 many unimplemented API features.  Most applications still do not work
384 correctly.''
385 @xref{Warranty}, for additional information.
386
387 @strong{Requirements}
388
389 Wine needs an 80x86 CPU to run on. Emulating the CPU is currently not
390 possible.
391
392 Currently, you must have one of:
393 @itemize @bullet
394 @item
395 Linux version 0.99.13 or above
396 @item
397 NetBSD-current
398 @item
399 FreeBSD-current or FreeBSD 1.1
400 @end itemize
401 You need X11, and you must have @file{libXpm} installed on your system.
402
403 @strong{Availability}
404
405 Wine is free software. The file @file{README} says, ``Basically, you can do
406 anything with it, except claim that you wrote it.''
407 @xref{Copying}, for more information.
408
409 @strong{Performance}
410
411 Wine is expected to run @mswindows{} binaries about the same speed as
412 @mswindows{} would. However, be aware that the 16 bit versions of
413 @mswindows{} programs are generally slower than their 32 bit
414 counterparts.
415
416 @strong{Further information}
417
418 You should consult the files @file{README}, @file{ANNOUNCE},
419 @file{RELEASE-NOTES}, @file{BUGS}, @file{LICENSE}, and @file{WARRANTY},
420 in the root directory of the Wine distribution.
421
422 The Wine FAQ, available from @*
423 @url{ftp://ftp.asgardpro.com/wine/dave/Wine.FAQ}, @*
424 @url{ftp://tsx-11.mit.edu/pub/linux/ALPHA/Wine/Wine.FAQ}, @*
425 @url{ftp://rtfm.mit.edu/pub/usenet-by-group/comp.emulators.ms-windows.wine/WINE_(WINdows_Emulator)_Frequently_Asked_Questions}, @*
426 @url{ftp://sunsite.unc.edu/pub/Linux/ALPHA/wine/Wine.FAQ}, @*
427 @url{http://www.asgardpro.com/wine/index.html}, @*
428 gives answer to a lot of questions.
429
430 The Wine USENET newsgroup is interesting for developers. It discusses technical
431 matters about Wine. The address is: @url{news:comp.emulators.ms-windows.wine}.
432
433
434
435 @xref{The Wine Project}, if you consider contributing some work.
436
437
438
439 @node Reference Manual, Installation, Introduction, Top
440
441 @menu
442 * WIN32 Reference Manual::      The @WIN32{} function calls and data types.
443 * Resources and INI files::     How to determine the appearance and
444                                 behaviour of Wine programs.
445 * Metafiles-Icons-Bitmaps::     FIXME missing.
446 * Debugging::                   Debugging Wine.
447 * Programs::                    Programs written to run in/with Wine.
448 * Tools::                       Programs to support Wine.
449 @end menu
450
451 @node @WIN32{} Reference Manual, Resources and INI files, , Reference Manual
452 @chapter The @WIN32{} Reference Manual
453
454 @menu
455 * Kernel Objects::              How the Wine kernel keeps information.
456 * Processes and Threads::       Job control and management in Wine.
457 * Users and Groups::            Security in Wine.
458 * Date and Time::               Functions for getting the date and time
459                                 and for conversion between formats.
460 * System Information::          Getting information about the hardware
461                                 and software the system runs on.
462 * Memory Management::           How your programs get memory from
463                                 Wine.
464 * I/O Facilities::              Input/Output in Wine.
465 * Communication::               How processes can communicate.
466 * Windows and Graphics::        GUI functions of @WIN32{}.
467 * Errors and Exceptions::       How your program can report errors.
468                                 (messaging)
469 * Resources::                   Functions for dealing with resources.
470 * The Registry::                FIXME missing.
471 * Dynamic Link Libraries::      Functions for dealing with DLL's.
472 @end menu
473
474 @node Kernel Objects, Processes and Threads, , @WIN32{} Reference Manual
475 @section Kernel Objects
476
477
478 @node Processes and Threads, Users and Groups, Kernel Objects, @WIN32{} Reference Manual
479 @section Processes and Threads
480
481 @node Users and Groups, Date and Time, Processes and Threads, @WIN32{} Reference Manual
482 @section Users and Groups
483
484 @node Date and Time, System Information, Users and Groups, @WIN32{} Reference Manual
485 @section Date and Time
486
487 This section describes functions for manipulating dates and times. This
488 includes the current time, the creation or manipulation times of files
489 and other objects, and conversion between different time
490 representations.
491
492 @menu
493 * File Times::                  Creation and manipulation times of files.
494 @end menu
495
496 @node File Times, , , Date and Time
497 @subsection File Times
498
499 @menu
500 * Type FILETIME::               The data structure used for specifying
501                                 file times.
502 * Compare File Times::          Compare two file times.
503 @end menu
504
505 @c
506 @c *** struct FILETIME ***
507 @c
508 @node Type FILETIME, Compare File Times, , File Times
509 @subsubsection Type FILETIME
510
511 @noindent
512 File times in Wine are specified by the data type @code{FILETIME},
513 defined in @file{windows.h}.
514 @deftp_w32  FILETIME
515 @deftpx_w32 LPFILETIME
516 This is the data type for specifying file times. The file times are
517 stored with 64 bit precision. The actual data type is a structure with
518 two 32-bit values which are interpreted as the low and high parts of a
519 64-bit value. This value gives a time measured in a granularity of 100
520 nanoseconds, so 1.5 seconds are specified by a value of 15,000,000.  In
521 Wine, this 64-bit value is signed, with the sign taken from the high
522 part. The lower part is used as unsigned.
523
524 The definition of @code{FILETIME} reads:
525 @example
526 typedef struct
527 @{
528     INT32 dwLowDateTime;
529     INT32 dwHighDateTime;
530 @} FILETIME, *LPFILETIME;
531 @end example
532
533 @cindex epoch in file time
534 The @code{FILETIME} structure may be used to hold absolute or relative
535 times. Absolute times are given as the number of 100 nanoseconds
536 intervals elapsed since 1 January 1601, 00:00:00 UTC (Coordinated
537 Universal Time, which is GMT, Greenwich Mean Time). This might be
538 called the @dfn{epoch} for file times. With a signed 64-bit value, this
539 representation covers absolute times of 29247 years around the epoch.
540 To convert this type to local time, use the function
541 @code{FileTimeToLocalFileTime}. 
542
543 @windiff{}
544 In @mswindows{}, the elements of the structure are apparently of type
545 @code{DWORD}. Whether the full 64 bit value is interpreted as signed or
546 unsigned I do not know.
547 @end deftp
548
549 @c
550 @c *** CompareFileTime ***
551 @c
552 @node Compare File Times, , Type FILETIME, File Times
553
554 @noindent
555 The Wine function @code{CompareFileTime} compares two file times, and
556 returns whether the first time is less than, equal to, or greater than
557 the second file time. It is defined in @file{windows.h}.
558 @deftypefn_w32 LONG CompareFileTime (@w{CONST FILETIME* @var{time_1},} @w{CONST FILETIME* @var{time_2})}
559 This function returns @code{1}, if @var{time_1} is greater than
560 @var{time_2}, @code{-1} if it is less, and @code{0} if both times are
561 equal. 
562
563 @winconfall{}
564
565 @windiffnone{}
566
567 @completionnone{}
568 @end deftypefn
569
570 @node System Information, Memory Management, Date and Time, @WIN32{} Reference Manual
571 @section System Information
572
573 @node Memory Management, I/O Facilities, System Information, @WIN32{} Reference Manual
574 @section Memory Management
575
576 @node I/O Facilities, Communication, Memory Management, @WIN32{} Reference Manual
577 @section I/O Facilities
578
579 This section describes all input/output of a process, except for two
580 topics: communication with other processes, and communication with the
581 windowing system.
582
583 @menu
584 * I/O on Files::                Accessing the contents of files.
585 * File System Interface::       Functions for manipulating files as a whole.
586 @end menu
587
588 @node I/O on Files, File System Interface, , I/O Facilities
589 @subsection I/O on Files
590
591 @node File System Interface, , I/O on Files, I/O Facilities
592 @subsection File System Interface
593
594 These functions are concerned with operating on files themselves, rather
595 than on their contents.
596
597 @menu
598 * Type BY_HANDLE_FILE_INFORMATION::     The data structure used to
599                                         specify file information.
600 * File attributes::                     The file attributes flags in
601                                         a file information structure.
602 * Getting file information::            These functions let you obtain
603                                         information about a file.
604 @end menu
605
606 @node Type BY_HANDLE_FILE_INFORMATION, File attributes, , File System Interface
607 @subsubsection The file information structure
608
609 The file information structure of Wine is used to obtain information
610 about files. It is declared in the header @file{winedows.h}.
611 @deftp_w32 BY_HANDLE_FILE_INFORMATION
612 This is the data type for specifying information about files as objects
613 of the file system. It contains the following members:
614 @table @code
615 @item int dwFileAttributes
616    @cindex file attributes in file information
617    @cindex attributes of file in file information
618    @xref{File attributes}, for details.
619 @item FILETIME ftCreationTime
620    @cindex creation time in file information
621    @cindex time of file creation in file information
622    The time when the file was created.
623    @xref{Type FILETIME}, for details.
624 @item FILETIME ftLastAccessTime
625    @cindex access time in file information
626    @cindex time of file access in file information
627    The time when the file was last accessed.
628    @xref{Type FILETIME}, for details.
629 @item FILETIME ftLastWriteTime
630    @cindex write time in file information
631    @cindex time of last file write in file information
632    The time when the file was last written to.
633    @xref{Type FILETIME}, for details.
634 @item int dwVolumeSerialNumber
635    @cindex serial number of volume in file information
636    @cindex volume number (serial) in file information
637    The serial number of the volume containing the file. In Wine,
638    currently 0.
639 @item int nFileSizeHigh
640    @cindex file size in file information
641    @cindex size of file in file information
642    A 32 bit value which contains the high part of the 64 bit file size.
643 @item int nFileSizeLow
644    A 32 bit value which contains the low part of the 64 bit file size.
645 @item int nNumberOfLinks
646    @cindex hard links number in file information
647    @cindex links (number of hard) in file information
648    This is the number of hard links to the file. In a file system which
649    does not support hard links, this is 1.
650 @item int nFileIndexHigh
651    @cindex inode number in file information
652    @cindex file index in file information
653    @cindex index of file in file information
654    A 32 bit value which contains the high part of the 64 bit file
655    index. The file index is a unique number for a file on a volume.
656    This identifier cannot change while the file is opened by a process.
657    Together with the volume number, the file index is a unique
658    identifier for the file. This can be used by an application to check
659    whether two handles refer to the same file. Wine currently uses the
660    inode number for the file index.
661 @item int nFileIndexLow
662    A 32 bit value which contains the low part of the 64 bit file index.
663 @end table
664
665 The definition of @code{BY_HANDLE_FILE_INFORMATION} reads:
666 @example
667 typedef struct
668 @{
669   int dwFileAttributes;
670   FILETIME ftCreationTime;
671   FILETIME ftLastAccessTime;
672   FILETIME ftLastWriteTime;
673   int dwVolumeSerialNumber;
674   int nFileSizeHigh;
675   int nFileSizeLow;
676   int nNumberOfLinks;
677   int nFileIndexHigh;
678   int nFileIndexLow;
679 @} BY_HANDLE_FILE_INFORMATION ;
680 @end example
681
682 The @code{BY_HANDLE_FILE_INFORMATION} structure can be obtained by the
683 @code{GetFileInformationByHandle} function (@pxref{Getting file information}, for
684 details).
685
686 @windiff{}
687 In @mswindows{}, the @code{int} elements of the structure are apparently
688 of type @code{DWORD}.
689 @end deftp
690
691 @node File attributes, Getting file information, Type BY_HANDLE_FILE_INFORMATION, File System Interface
692 @subsubsection The file attributes in a file information structure
693
694 The file attributes in a file information structure and in other structures
695 are a logical @emph{or} of one or more of the following constants:
696
697 @defvr_cw32 FILE_ATTRIBUTE_READONLY
698 The file is a read-only file. (Wine value: 0x0001).
699 @end defvr
700 @defvr_cw32 FILE_ATTRIBUTE_HIDDEN
701 The file is a hidden file. Files in Wine do not have this attribute. (Wine value:
702 0x0002).
703 @end defvr
704 @defvr_cw32 FILE_ATTRIBUTE_SYSTEM
705 The file belongs to the operating system. Files in Wine do not have this
706 attribute. (Wine value: 0x0004).
707 @end defvr
708 @defvr_cw32 FILE_ATTRIBUTE_LABEL
709 This is not present in the @mswindows{} API. (Wine value: 0x0008).
710 @end defvr
711 @defvr_cw32 FILE_ATTRIBUTE_DIRECTORY
712 The file is a directory. (Wine value: 0x0010).
713 @end defvr
714 @defvr_cw32 FILE_ATTRIBUTE_ARCHIVE
715 The file is an archive file. Currently, all non-directory files are
716 reported by Wine to have this attribute. This attribute is normally set
717 by @mswindows{} to indicate that a file is to be archived; when the file
718 is archived, the flag is cleared. (Wine value: 0x0020).
719 @end defvr
720 @defvr_cw32 FILE_ATTRIBUTE_NORMAL
721 The file does not have any other attributes set. This value must be used
722 alone. In Wine, normal files are reported as archive files. (Wine value:
723 0x0080).
724 @end defvr
725 @defvr_cw32 FILE_ATTRIBUTE_TEMPORARY
726 The file is used as a temporary storage. Files in Wine do not have this
727 attribute. (Wine value: 0x0100).
728 @end defvr
729 @defvr_cw32 FILE_ATTRIBUTE_ATOMIC_WRITE
730 This is reserved for future use. Files in Wine do not have this
731 attribute. (Wine value: 0x0200).
732 @end defvr
733 @defvr_cw32 FILE_ATTRIBUTE_XACTION_WRITE
734 This is reserved for future use. Files in Wine do not have this
735 attribute. (Wine value: 0x0400).
736 @end defvr
737 @defvr_cw32 FILE_ATTRIBUTE_COMPRESSED
738 The file is compressed. Files in Wine do not have this attribute. (Wine
739 value: 0x0800). 
740 @end defvr
741
742 @node Getting file information, , File attributes, File System Interface
743 @subsubsection Getting file information
744
745 The functions in this section describe how to get information about
746 files. 
747
748 @c
749 @c *** GetFileInformationByHandle
750 @c
751 @noindent
752 The Wine function @code{GetFileInformationByHandle} returns a file
753 information structure. It is defined in @file{windows.h}.
754
755 @deftypefn_w32 BOOL GetFileInformationByHandle (@w{HFILE32 @var{file},} @w{BY_HANDLE_FILE_INFORMATION *@var{info})}
756 This function obtains for the specified @var{file} the file information,
757 and stores it in @var{info}. The file information contains the file
758 attributes, the file times, the volume serial number, the file size, the
759 number of links, and a unique file identifier. The function returns
760 @code{TRUE} on success, @code{FALSE} on failure.
761
762 @winconfall{}
763
764 @windiff{}
765 The Wine function can of course only give back information that is
766 accessible in the @unix{} file system. File times are produced in a
767 granularity of full seconds. Most file attributes are not present in the
768 @unix{} file system. @xref{File attributes}, for details. The volume
769 serial number is set to 0.
770 @end deftypefn
771
772
773 @c
774 @c *** GetFileTime ***
775 @c
776 @noindent
777 The Wine function @code{GetFileTime} returns the creation time and
778 the times of last the read and modification access to a file. It is
779 defined in @file{windows.h}.
780
781 @deftypefn_w32 BOOL GetFileTime (@w{HANDLE @var{file},} @w{LPFILETIME @var{ctime},} @w{LPFILETIME @var{atime},} @w{LPFILETIME @var{mtime})}
782 This function obtains for the specified @var{file} the creation time
783 @var{ctime}, the time of the last access to the file @var{atime}, and
784 the time of the last modification (write) to the file, @var{mtime}.
785 The file time arguments of this function are pointers to @code{FILETIME}
786 variables, which are filled with a value that indicates an absolute time
787 in UTC. @xref{Type FILETIME}, for details. If you do not need some of
788 the times, you can pass a @code{NULL} pointer.
789 The function returns @code{TRUE} on
790 success, @code{FALSE} on failure.
791
792 @winconfall{}
793
794 @windiff{}
795 The file times are produced in a granularity of full seconds, due to the
796 underlying @unix{} file system. 
797 @end deftypefn
798
799 @c
800 @c *** GetFileAttributes ***
801 @c
802 @noindent
803 The Wine function @code{GetFileAttributes} returns the file attributes
804 for a file. It is defined in @file{windows.h}.
805
806 @deftypefn_w32 DWORD GetFileAttributes (@w{LPCTSTR @var{name})}
807 This function looks up the file with name @var{name}, and returns the
808 attributes of the file. @xref{File attributes}, for details on the file
809 attributes. If the function is not successful, it returns a word with
810 all bits set (@samp{0xffffffff}).
811
812 @winconfall{}
813
814 @windiff{}
815 Most file attributes are not present in the
816 @unix{} file system. @xref{File attributes}, for details.
817 @end deftypefn
818
819
820
821
822 @node Communication, Windows and Graphics, I/O Facilities, @WIN32{} Reference Manual
823 @section Communication
824
825 @node Windows and Graphics, Errors and Exceptions, Communication, @WIN32{} Reference Manual
826 @section Windows and Graphics
827
828 @node Errors and Exceptions, Resources, Windows and Graphics, @WIN32{} Reference Manual
829 @section Errors and Exceptions
830
831 @node Resources, The Registry, Errors and Exceptions, @WIN32{} Reference Manual
832 @section Resources
833
834 @node The Registry, Dynamic Link Libraries, Resources, @WIN32{} Reference Manual
835 @section The Registry
836
837 @node Dynamic Link Libraries, , The Registry, @WIN32{} Reference Manual
838 @section Dynamic Link Libraries (DLL's)
839
840 This section deals with API functions for handling DLL's (dynamic link
841 libraries). It does not describe DLL's themselves; nor does it give
842 information on how Wine handles DLL's. @xref{The build program}, for
843 information on how DLL's are integrated into Wine.
844
845
846
847
848 @node Resources and INI files, Metafiles--Icons--Bitmaps, @WIN32{} Reference Manual, Reference Manual
849 @chapter Resources and @file{INI} Files
850
851 @node Metafiles--Icons--Bitmaps, Debugging, Resources and INI files, Reference Manual
852 @chapter Metafiles --- Icons --- Bitmaps
853
854 @node Debugging, Programs, Metafiles--Icons--Bitmaps, Reference Manual
855 @chapter Debugging
856
857 @node Programs, Tools, Debugging, Reference Manual
858 @chapter Programs
859
860 @node Tools, , Programs, Reference Manual
861 @chapter Tools
862
863 This chapter describes some of the tools that are used by Wine. These
864 are not user-level programs which the user of Wine will
865 run. @xref{Programs} for such programs.
866
867 Tools are internal programs that are used to help compile or configure
868 Wine.
869
870 @menu
871 * The build program::           A program used to build the DLL entry
872                                 points from specifications in @file{if1632/}.
873 @end menu
874
875
876 @node The build program, , , Tools
877 @section The @file{build} program
878
879 @cindex modules of Wine
880 @cindex Wine modules
881 @cindex DLL's built-in in Wine
882 @cindex Wine DLL's built-in
883 @cindex built-in DLL's in Wine
884 Wine contains several modules that implement various DLL's which are
885 required to run @mswindows{} programs.
886
887 The @file{build} program, located in the @file{tools/} directory, is
888 used to create the bindings for the DLL entry points of the API functions.
889 This program reads a @file{.spec}-file in the @file{if1632} directory
890 and creates the assembly code that translates the function arguments
891 correctly. 
892
893
894 @menu
895 * The spec files::              The format of the @file{.spec}-files.
896 @end menu
897
898 FIXME: where in Wine are the DLL's affixed?
899
900 FIXME: write a description
901
902 @xref{Implementing an API function}, for notes on using this program.
903
904 @node The spec files, , , The build program
905 @subsection The @file{.spec}-files
906 @cindex DLL spec files
907 @cindex spec files of DLL's
908 @cindex entry points in DLL's
909
910 This subsection describes the format of the @file{.spec}-files.
911
912 A @file{.spec}-file contains the information about the functions,
913 variables, and constants that are contained in a DLL (dynamic link
914 library).
915
916 To be able to interpret the contents of a @file{.spec}-file, you must
917 know about the concept of ordinals.
918 @menu
919 * The general format::                  General format conventions.
920 * Ordinals::                            Ordinals are indexes of entry
921                                         points into DLL's.
922 * Spec file header::                    The header information.
923 * Variable entry points::               Entries for DLL variables.
924 * Function entry points::               Entries for DLL functions.
925 * Special entries::                     Entries for stubs, dummy
926                                         functions, Wine symbols, and
927                                         constant values.
928 @end menu
929
930 @node The general format, Ordinals, , The spec files
931 @subsubsection The general format
932 @cindex format of spec files
933 @cindex spec files format
934
935 The @file{.spec}-file contains a header and a sequence of declarations.
936 Each declaration describes an ordinal.
937
938 The header gives general information about the DLL and its properties.
939
940 Ordinal declarations are optional. That means that there is a default
941 behaviour assigned to ordinals which are not mentioned in the
942 @file{.spec}-file. The default handler function of an ordinal will print
943 an error message when called.
944
945 Comments are indicated by hash marks (@samp{#}); everything between a
946 hash mark and the end of the line is ignored.
947
948 Empty lines are allowed.
949 @* FIXME: is that so?
950
951 @node Ordinals, Spec file header, The general format, The spec files
952 @subsubsection Ordinals
953 @cindex ordinals in DLL's
954 @cindex DLL ordinals
955
956 All references to DLL objects like functions or variables are indexed by
957 unique nonnegative numbers. These numbers are called
958 @dfn{ordinals}. Apparently, a program can refer to a DLL function or
959 variable by specifying its name or its ordinal. Although reference by
960 name is the common usage, some program parts (notably DLL's themselves)
961 sometimes refer to DLL entries by ordinal. Therefore, the ordinals
962 cannot be chosen arbitrarily.
963
964 Regular programs that are compiled and linked against @mswindows{} DLL's
965 will import DLL functions by name. This is therefore the default
966 behaviour. Most DLL functions will be imported by name in all cases.
967 Apparently, the @WIN32{} DLL's even show some difference in the mapping
968 of functions and ordinals on @WINNT{} and @WIN95{}. For most DLL
969 functions, the ordinal number will not matter.
970
971 There are some exceptions to that. Notable the KERNEL32 ordinals below
972 100 are (presently) unnamed and undocumented functions which can only be
973 imported by ordinal. These functions are called by some @mswindows{}
974 programs. Also the @file{shell32.dll} functions are reported to be
975 imported by ordinal in some other DLL's.
976
977 @xref{Getting information on the API}, for sources of further information.
978
979 @node Spec file header, Variable entry points, Ordinals, The spec files
980 @subsubsection The header of a @file{.spec}-file
981
982 The @file{.spec}-file starts with two mandatory definitions. The first
983 line gives the name of the DLL which the @file{.spec}-file describes,
984 @example
985 name @var{NAME}
986 @end example
987 where @var{NAME} is the name of the DLL. The next line defines the type
988 of the DLL, 
989 @example
990 type @var{TYPE}
991 @end example
992 with @var{TYPE} being either @samp{win16} or @samp{win32}.
993
994 An optional statement of the form
995 @example
996 base @var{ORDINAL}
997 @end example
998 can be used to define the offset of the first ordinal. @var{ORDINAL}
999 must be an integer number. If no base is specified, the offset is zero.
1000 @* FIXME: is this the offset of the first or an offset that is added to all
1001 ordinals?
1002 what is the offset? Is it added to the ordinals, or is it an address, or
1003 xxx?
1004
1005 An optional statement like
1006 @example
1007 heap @var{SIZE}
1008 @end example
1009 can be used to define the size of the module local heap. This is only
1010 used for @WIN16{} DLL's. The local heap is the place where the segments
1011 of 16 bit programs can locally allocate memory, without interfering with
1012 one another. The default size of the local heap, if not specified, is 0.
1013
1014 @* FIXME: to my impression, a local heap in DLL's would only be required
1015 if DLL functions used it. As all DLL functions in Wine are truly 32 bit
1016 functions that are mapped from 16 bit on being called and back to 16 bit
1017 on returning, a local heap should never be necessary.
1018 If I receive a confirmation of that here, I will state so. Otherwise I
1019 am missing some information on local heaps.
1020 But why is a heap defined in user.spec and gdi.spec?
1021
1022 @node Variable entry points, Function entry points, Spec file header, The spec files
1023 @subsubsection Variable entry points of @file{.spec}-files
1024
1025 You can declare an ordinal that holds data. Data items may be of 8, 16,
1026 or 32 bit in size.
1027
1028 @example
1029 @var{ORDINAL} @var{VARTYPE} @var{EXPORTNAME} (@var{DATA} @var{[DATA @dots{}]})
1030 @end example
1031
1032 @var{ORDINAL} is the ordinal number corresponding to the
1033 variable. @var{VARTYPE} must be @samp{byte}, @samp{word}, or
1034 @samp{long}, for 8, 16, or 32 bits respectively. @var{EXPORTNAME} will
1035 be the name available for dynamic linking. @var{DATA} can be a decimal
1036 number or a hex number preceded by @samp{0x}. Each @var{DATA} item defines
1037 a unit of storage.
1038
1039 The following example defines the variable @samp{VariableA} at ordinal
1040 2, containing 4 bytes:
1041 @example
1042 2 byte VariableA(-1 0xff 0 0)
1043 @end example
1044
1045
1046 @node Function entry points, Special entries, Variable entry points, The spec files
1047 @subsubsection Function entry points of @file{.spec}-files
1048
1049 @example
1050 @var{ORDINAL} @var{FUNCTYPE} @var{EXPORTNAME} (@var{[ARGTYPE} @dots{} @var{]}) @var{HANDLERNAME}
1051 @end example
1052
1053 @var{ORDINAL} is the ordinal number corresponding to the
1054 function. @var{FUNCTYPE} must be chosen from this table:
1055 @table @samp
1056 @item pascal16
1057 A @WIN16{} function that returns a 16 bit value.
1058 @item pascal
1059 A @WIN16{} function that returns a 32 bit value.
1060 @item register
1061 A function using CPU registers to pass arguments.
1062 @item stdcall
1063 A normal @WIN32{} function. @xref{Investigating the undocumented API},
1064 for an explanation of the stdcall calling convention.
1065 @item cdecl
1066 A @WIN32{} function using the C calling conventions. (This is presently
1067 only used for the built-in functions of the C runtime system).
1068 @end table
1069
1070 @var{EXPORTNAME} specifies the name (prototype) available for dynamic
1071 linking.
1072
1073 @var{ARGTYPE} must be chosen from this table:
1074 @table @samp
1075 @item byte
1076   An 8 bit argument. Can be used in @WIN16{} functions only.
1077 @item word
1078   A 16 bit argument. Can be used in @WIN16{} functions only.
1079 @item long
1080   A 32 bit argument. Can be used in @WIN16{} or @WIN32{} functions.
1081 @item ptr
1082   A linear pointer, unsegmented. Can be used in @WIN16{} or @WIN32{}
1083   functions.
1084 @item str
1085   A linear pointer, unsegmented, pointing to a null-terminated string.
1086   Can be used in @WIN16{} or @WIN32{} functions.
1087 @item s_byte
1088   A signed 8 bit argument. Can be used in @WIN16{} functions only.
1089 @item s_word
1090   A signed 16 bit argument. Can be used in @WIN16{} functions only.
1091 @item s_long
1092   A signed 32 bit argument. Can be used in @WIN16{} or @WIN32{}
1093   functions.
1094 @item segptr
1095   A segmented pointer. Can be used in @WIN16{} functions only.
1096 @item segstr
1097   A segmented pointer to a null-terminated string. Can be used in
1098   @WIN16{} functions only.
1099 @end table
1100
1101 @var{HANDLERNAME} is the name of the actual Wine function that will
1102 process the request in 32-bit mode.
1103
1104
1105 @sp 2
1106 Here are some examples. The first example defines an entry point for the
1107 @code{CreateWindow()} call (the ordinal 100 is just an example):
1108 @example
1109 100 pascal CreateWindow(ptr ptr long s_word s_word s_word s_word
1110                         word word word ptr) WIN_CreateWindow
1111 @end example
1112
1113 The second example defines an entry point for the @code{GetFocus()} call
1114 (again, the ordinal 100 is an example):
1115 @example
1116 100 pascal GetFocus() WIN_GetFocus()
1117 @end example
1118
1119 To declare a function that uses a variable number of arguments, specify
1120 the function as taking no arguments. In this special case, in @WIN32{}
1121 the called function will be passed a pointer to the first arg; in
1122 @WIN16{}, the args are available as @code{CURRENT_STACK16->args}.
1123 @* FIXME: create a reference here
1124 See the @code{wsprintf}* functions in @file{user.spec} and 
1125 @file{user32.spec} for an example.
1126
1127 Sometimes it is not known how many arguments an undocumented DLL
1128 function takes. @xref{Getting information on the API}, for some hints on
1129 how to proceed in such a case.
1130
1131 @node Special entries, , Function entry points, The spec files
1132 @subsubsection Special entries of @file{.spec}-files
1133
1134 The @file{.spec}-files offer the possibility to use some special
1135 entries. These entries are used for stubs (which allow linking for
1136 non-existing functions), dummy functions that do not perform any
1137 operations, Wine symbols that must be referenced directly, and constant
1138 values.
1139
1140
1141 @strong{Stub ordinals}
1142
1143 This pseudo function type defines a stub function. It makes the name and
1144 ordinal available for dynamic linking, but will terminate execution with
1145 an error message if the function is ever called.
1146
1147 @example
1148 @var{ORDINAL} stub @var{EXPORTNAME}
1149 @end example
1150
1151 @var{ORDINAL} is the ordinal number corresponding to the
1152 function. @var{EXPORTNAME} specifies the name (prototype) available for dynamic
1153 linking.
1154
1155 @strong{Return ordinals}
1156
1157 This pseudo function type defines a function entry point whose handler
1158 should do nothing but return a value.
1159 @example
1160 @var{ORDINAL} return @var{EXPORTNAME} @var{ARGLENGTH} @var{RETVALUE}
1161 @end example
1162
1163 @var{ORDINAL} is replaced by the ordinal number corresponding to the
1164 function. @var{ARGLENGTH} is the number of bytes that need to be removed
1165 from the stack before returning to the caller. @xref{Investigating the
1166 undocumented API}, for an explanation of the stdcall calling convention.
1167 @var{RETVALUE} is the return value which will be passed back to the
1168 caller.
1169
1170 @strong{Extern ordinals}
1171
1172 @example
1173 @var{ORDINAL} extern @var{EXPORTNAME} @var{SYMBOLNAME}
1174 @end example
1175 This type defines an entry that simply maps to a Wine symbol
1176 (variable or function); @var{EXPORTNAME} will point to the symbol
1177 @var{SYMBOLNAME} that must be defined in C code. This type only works with
1178 @WIN32{}.
1179
1180
1181 @strong{Equate ordinals}
1182
1183 @example
1184 @var{ORDINAL} equate @var{EXPORTNAME} @var{DATA}
1185 @end example
1186
1187 This type defines an ordinal as an absolute value.
1188 @var{ORDINAL} is replaced by the ordinal number corresponding to the
1189 entry. @var{EXPORTNAME} will be the name available for dynamic linking.  
1190 @var{DATA} can be a decimal number or a hex number preceeded by @samp{0x}.
1191
1192
1193 @node Installation, The Wine Project, Reference Manual, Top
1194 @chapter Wine installation and configuration
1195 FIXME: write installation guide
1196
1197 @menu
1198 * Applying patches::            How to update Wine to a newer version.
1199 @end menu
1200
1201 @node Applying patches, , , Installation
1202 @section Applying patches
1203 @xref{Creating patches}, for instructions on creating patches.
1204
1205 @kbd{cd} to the top source directory for Wine, and run 
1206 @code{patch -p1 < @var{patchfile}}.
1207 What needs to be done next depends to some extent on what the
1208 patch touches. For small patches which only alter C source, it can be
1209 enough to rerun @code{make}. In general, the sequence @code{configure},
1210 @code{make depend}, @code{make} is sufficient, unless the patch alters
1211 @code{[config.in]}, in which case you must regenerate @code{configure}
1212 via @code{make configure} (which just runs @code{autoconf}).
1213
1214
1215 @node The Wine Project, , Installation, Top
1216 @chapter The Wine project
1217 @cindex Wine project contributions
1218 @cindex project contributions to Wine
1219
1220 If you are new to Wine and want to support this project, here are
1221 some suggestions. 
1222
1223 @menu
1224 * Getting information on the API::      Official and unofficial sources
1225                                         of information on the @WIN32{} API.
1226 * Investigating the undocumented API::  You can find out some API
1227                                         information on your own.
1228 * Implementing an API type::            How to implement a data type
1229                                         of the API (a checklist).
1230 * Implementing an API function::        How to implement one function
1231                                         of the API (a checklist).
1232 * API function and type naming::        How to name API functions in Wine.
1233 * Creating patches::                    How to create patches for Wine.
1234 * Adding Documentation::                Templates for the documentation.
1235 * File names::                          How Wine treats @mswindows{} and
1236                                         @unix{} file names.
1237 * Wide character strings::              How Wine treats wide character
1238                                         strings.
1239 @end menu
1240
1241 @xref{Debugging}, for advice on how to debug Wine.
1242 @xref{Applying patches}, for instructions on applying patches.
1243
1244
1245 @node Getting information on the API, Investigating the undocumented API, , The Wine Project
1246 @section Official and unofficial documentation on the @mswindows{} API
1247 @cindex documentation of API functions
1248 @cindex undocumented API functions
1249
1250
1251 @strong{Official documentation}
1252
1253 For documentation on @WIN32{} API functions, you might try one of these
1254 sources:
1255
1256 @itemize @bullet
1257
1258 @item
1259 There is a free online version of the MSDN library (including
1260 documentation for the @WIN32{} API) on
1261 @url{http://www.microsoft.com/msdn/}.
1262
1263 @item 
1264 The @WINNT{} DDK gives information about some kernel (``executive'')
1265 routines. Some of the function documentation might also apply to user
1266 accessible DLL's.
1267 @end itemize
1268
1269 @strong{Unofficial documentation}
1270
1271 Not all of the @WIN32{} API is well documented. Some functions are
1272 obscured, and undocumented. @xref{Ordinals}, for information about
1273 undocumented functions imported by ordinal. Getting to know what these
1274 functions do can be tiresome and tedious. Here is a quote from a
1275 news posting concerning two books that might help:
1276 @c From: vischne@ibm.net-nospam (root)
1277 @c Subject: Re: Functions
1278 @c Newsgroups: comp.emulators.ms-windows.wine
1279 @c Date: 24 Jul 97 16:45:11 GMT
1280 @c Organization: The Light
1281 @c NNTP-Posting-Host: 129.37.246.203
1282 @c Message-ID: <33d78697.0@news3.ibm.net>
1283
1284 @quotation
1285 Well actually, there are at least _two_ books that address these problems.
1286 One is by Matt Pietrek, ``Windows 95 System Programming Secrets'', which
1287 gives some auxiliary programs for helping ferret out the information, and
1288 the other is by Shulman, ``Undocumented Windows 95''.
1289 @end quotation
1290
1291 @xref{Ordinals}, for some notes on undocumented kernel functions.
1292
1293 @itemize @bullet
1294
1295 @item
1296 @cindex book on undocumented API features by Pietrik
1297 ``Windows 95 System Programming Secrets'' @*
1298 by Matt Pietrek @*
1299 Book & Disk Edition @*
1300 Paperback, 778 pages @*
1301 Published by IDG Books Worldwide @*
1302 Publication date: November 1, 1995 @*
1303 Dimensions (in inches): 9.25 x 7.42 x 2.06 @*
1304 ISBN: 1568843186 @*
1305
1306 @item
1307 @cindex book on undocumented API features by Schulman
1308 ``Undocumented Windows; A Programmers Guide
1309 to Reserved Microsoft Windows API Functions'' @*
1310 by Andrew Schulman @*
1311 Paperback, 715 pages @*
1312 Published by Addison-Wesley Pub Co @*
1313 Publication date: February 1, 1994 @*
1314 Dimensions (in inches): 9.11 x 7.37 x 1.53 @*
1315 ISBN: 0201608340  @*
1316
1317 @item
1318 More books on these topics (including Schulman and Pietrik): @*
1319 @url{http://www.sonic.net/~undoc/bookstore.html}
1320
1321 @item
1322 More details about calling undocumented functions can be found at
1323 @url{http://ftp.uni-mannheim.de/info/OReilly/windows/win95.update/dirty.html}.
1324
1325 @item
1326 In 1993 Dr. Dobbs Journal published a column called ``Undocumented
1327 Corner''.
1328 @item
1329 You might want to check out BYTE from December 1983 as well.
1330 @* FIXME: is that to be taken seriously?
1331 @item
1332 And you might try to find out something on your own. @xref{Investigating
1333 the undocumented API}, for details.
1334 @end itemize
1335
1336 But, all in all, @url{news:comp.emulators.ms-windows.wine} says
1337 @c From: dacut@henry.ece.cmu.edu (David A. Cuthbert)
1338 @c Subject: Re: Getting Internet Explorer to work
1339 @c Newsgroups: comp.emulators.ms-windows.wine
1340 @c Date: 24 Jul 1997 03:10:30 GMT
1341 @c Organization: Electrical & Computer Engineering, Carnegie Mellon University
1342 @c Reply-To: henry.ece.cmu.edu!dacut
1343 @c Message-ID: <5r6h36$86c@fs7.ece.cmu.edu>
1344 @c NNTP-Posting-Host: henry.ece.cmu.edu
1345
1346 @quotation
1347 Unfortunately, short of getting something like NuMega's SoftIce, I
1348 don't think there's a ``good'' reference on the mystery <100 ordinals in
1349 KERNEL32.DLL.
1350 @end quotation
1351
1352
1353 @node Investigating the undocumented API, Implementing an API type, Getting information on the API, The Wine Project
1354 @section Investigating the undocumented API
1355 @cindex undocumented API investigation
1356 @cindex parameters of undocumented API functions
1357 @cindex stdcall calling convention
1358 @cindex C calling convention
1359 @cindex API function parameters investigation
1360 @cindex stack handling under stdcall calling
1361
1362 Besides reading the documentation in @ref{Getting information on the API},
1363 you can find out some properties of API functions on your own.
1364
1365 Sometimes it is not known how many arguments an undocumented DLL
1366 function takes. Here is a text from a news posting that gives some
1367 hints on how you might proceed in this case.
1368
1369 @c The following text is closely quoted from:
1370 @c From: dacut@henry.ece.cmu.edu (David A. Cuthbert)
1371 @c Subject: Win32 stub functions (Claus Fischer, please read)
1372 @c Newsgroups: comp.emulators.ms-windows.wine
1373 @c Date: 7 Aug 1997 22:33:09 GMT
1374 @c Organization: Electrical & Computer Engineering, Carnegie Mellon University
1375 @c Reply-To: henry.ece.cmu.edu!dacut
1376 @c Message-ID: <5sdif5$qt3@fs7.ece.cmu.edu>
1377
1378 The problem with implementing stubs for @WIN32{} functions is that it is
1379 not sufficient to return a default value (usually 0) and leave the
1380 stack the way we found it. For most @WIN32{} functions -- those that use
1381 the @dfn{stdcall} calling convention -- the arguments sent to the function
1382 are removed from the stack.
1383
1384 Some background:  On the i386 class of machines, stack entries are
1385 usually dword (4 bytes) in size, little-endian.  The stack grows
1386 downward in memory.  The stack pointer, maintained in the @samp{esp}
1387 register, points to the last valid entry; thus, the operation of
1388 pushing a value onto the stack involves decrementing @samp{esp} and then
1389 moving the value into the memory pointed to by esp (i.e., @code{push p}
1390 in assembly resembles @code{*(--esp) = p;} in C).  Removing (popping)
1391 values off the stack is the reverse (i.e., @code{pop p} corresponds to
1392 @code{p = *(esp++);}).
1393
1394 In the @dfn{stdcall} calling convention, arguments are pushed onto the
1395 stack right-to-left.  For example, the C call
1396
1397 @example
1398     myfunction(40, 20, 70, 30);
1399 @end example
1400
1401 is expressed in Intel assembly as:
1402
1403 @example
1404     push 30
1405     push 70
1406     push 20
1407     push 40
1408     call myfunction
1409 @end example
1410
1411 In addition, the called function is responsible for removing the
1412 arguments off the stack.  Thus, before the call to myfunction, the
1413 stack would look like:
1414
1415 @example
1416              [local variable or temporary]
1417              [local variable or temporary]
1418               30
1419               70
1420               20
1421     esp ->    40
1422 @end example
1423
1424 After the call returns, it should look like:
1425
1426 @example
1427              [local variable or temporary]
1428     esp ->   [local variable or temporary]
1429 @end example
1430
1431 To restore the stack to this state, the called function must know how
1432 many arguments to remove (which is the number of arguments it takes).
1433 This is a problem if the function is undocumented.
1434
1435 One way to attempt to document the number of arguments each function
1436 takes is to create a wrapper around that function that detects the
1437 stack offset.  @file{WinRelay} (see below) was written to create such
1438 wrappers. Essentially, each wrapper assumes that the function will take
1439 a large number of arguments (by default, 64 in @file{WinRelay}).  The
1440 wrapper copies each of these arguments into its stack, calls the actual
1441 function, and then calculates the number of arguments by checking esp
1442 before and after the call.
1443
1444 @cindex bsod (blue screen of death)
1445 @cindex blue screen of death
1446 The main problem with this scheme is that the function must actually
1447 be called from another program.  Many of these functions are seldom
1448 used.  An attempt was made to aggressively query each function in a
1449 given library (@file{ntdll.dll}) by passing 64 arguments, all 0, to each
1450 function.  Unfortunately, @WINNT40{} quickly goes to a blue screen
1451 of death (@dfn{bsod}), even if the program is run from a
1452 non-administrator account.
1453
1454 Another method that has been much more successful is to attempt to
1455 figure out how many arguments each function is removing from the
1456 stack.  This instruction, @code{ret hhll} (where @samp{hhll} is the
1457 number of bytes to remove, i.e. the number of arguments times 4), contains
1458 the bytes @samp{0xc2 ll hh} in memory.  It is a reasonable assumption
1459 that few, if any, functions take more than 16 arguments; therefore,
1460 @samp{hh} is 0x0 and @samp{ll} is less than 0x40.  This utility,
1461 @file{MakeSpec} (see below), simply queries the address of a function
1462 and looks for the first occurrence of the bytes @samp{0xc2 ll 0x0},
1463 where @math{@samp{ll} <= 0x40}.
1464
1465 Of course, this is not without errors. @code{ret 00ll} is not the only
1466 instruction that can have the byte sequence @samp{0xc2 ll 0x0}; for
1467 example, @code{push 0x000040c2} has the byte sequence
1468 @samp{0x68 0xc2 0x40 0x0 0x0}, which matches the above.  Properly, the
1469 utility should look for this sequence only on an instruction boundary;
1470 unfortunately, finding instruction boundaries on an i386 requires
1471 implementing a full disassemble -- quite a daunting task.  Besides,
1472 the probability of having such a byte sequence that is not the actual
1473 return instruction is fairly low.
1474
1475 Much more troublesome is the non-linear flow of a function.  For
1476 example, consider the following two functions:
1477
1478 @example
1479     somefunction1:
1480         jmp  somefunction1_impl
1481
1482     somefunction2:
1483         ret  0004
1484
1485     somefunction1_impl:
1486         ret  0008
1487 @end example
1488
1489 @file{MakeSpec} would incorrectly list both @code{somefunction1} and
1490 @code{somefunction2} as taking only a single argument, whereas
1491 @code{somefunction1} really takes two arguments.
1492
1493 With these limitations in mind, it is possible to implement more stubs
1494 in Wine and, eventually, the functions themselves.
1495
1496 @c end of quote
1497
1498 The program @file{WinRelay} can be downloaded from
1499 @url{http://www.ece.cmu.edu/afs/ece/usr/dacut/www/src},
1500 and @file{MakeSpec} will be available from the same location. You can
1501 compile them with Borland's C++Builder; you should not optimize when
1502 compiling (@file{WinRelay} needs the stack frames).
1503
1504
1505 @node Implementing an API type, Implementing an API function, Investigating the undocumented API, The Wine Project
1506 @section Implementing an API type
1507
1508 Here is a checklist that should help you writing your first API type. It
1509 will of course not tell you which elements to put into the type
1510 (assuming it is a structure), but it should help you along the way of
1511 integrating this type into Wine.
1512 @xref{Implementing an API function}, for comparison.
1513
1514 @enumerate
1515 @item
1516 Find out how the type should be named in Wine and in the DLL's.
1517 @xref{API function and type naming}, for details.
1518
1519 @item
1520 Find out where the type should go. Please try to keep the header files
1521 structure as similar to @mswindows{} as possible. 
1522
1523 @item
1524 Prepare for the later patch (by saving the original files before you
1525 work on them). @xref{Creating patches}, for details.
1526
1527 @item
1528 Put the type declaration into the header file.
1529
1530 @item
1531 Make sure the declaration is syntactically correct, i.e. it does not
1532 keep Wine from compiling.
1533
1534 @item
1535 Make sure the declared type is layout-compatible with
1536 @mswindows{}-compiled types. Especially keep an eye on the packing of
1537 the structure.
1538 @* FIXME: a reference to packed structures here.
1539
1540 @item
1541 Build Wine and test the type, if possible. If you cannot test the
1542 type by implementing a proper API function, write a small test program
1543 to test it on its own. Or rather stop here.
1544
1545 @item
1546 Write the documentation of the type in the @file{wine.texinfo}
1547 file. @xref{Adding Documentation}, for details.
1548 With types, be especially careful and document all the details. Also
1549 document all constants or flags that are used in the type.
1550
1551 @item
1552 Create an entry in the @file{ChangeLog} file.
1553
1554 @item
1555 Collect some of these changes, and create a patch. @xref{Creating
1556 patches}, for details.
1557
1558 @item
1559 Mail the patch to Alexandre Julliard, @email{julliard@@lrc.epfl.ch}.
1560
1561 @item
1562 Wait for the patch to appear in the official distribution.
1563 @end enumerate
1564
1565
1566 @node Implementing an API function, API function and type naming, Implementing an API type, The Wine Project
1567 @section Implementing an API function
1568
1569 Here is a checklist that should help you writing your first API
1570 function. It will of course not tell you what to do in the function,
1571 but it should help you along the way of integrating this function into
1572 Wine.
1573
1574 @enumerate
1575 @item
1576 Make sure all data types that appear in function arguments are properly
1577 declared in Wine. Otherwise, start with the data types.
1578
1579 @item
1580 Find out how the function should be named in Wine and in the DLL's.
1581 @xref{API function and type naming}, for details.
1582
1583 @item
1584 Find out what the function should do. This may be tricky for
1585 undocumented functions. @xref{Getting information on the API}, for some
1586 hints.
1587
1588 @item
1589 Find out where the function should go:
1590 @enumerate
1591 @item
1592 Which header file for the prototype.
1593 @item
1594 Which C source file.
1595 @item
1596 Which DLL(s), and which ordinal the function will take there. Perhaps
1597 the function name is already present in one of the @file{.spec}-files in
1598 the @file{if1632} directory.
1599 @end enumerate
1600
1601 @item
1602 Prepare for the later patch (by saving the original files before you
1603 work on them). @xref{Creating patches}, for details.
1604
1605 @item
1606 Put the prototype into the header file, and the code into the C file.
1607
1608 @item
1609 Make sure the code compiles.
1610
1611 @item
1612 Create or change the information for the DLL entry points in the
1613 @file{.spec}-file in the @file{if1632} directory.
1614 @xref{The build program}, for details of the DLL spec files.
1615
1616 @item
1617 Build Wine and test the function, if possible. If you cannot test the
1618 function in Wine, write a small test program to test it on its own.
1619
1620 @item
1621 Write the documentation of the function in the @file{wine.texinfo}
1622 file. @xref{Adding Documentation}, for details.
1623
1624 @item
1625 Create an entry in the @file{ChangeLog} file.
1626
1627 @item
1628 Collect some of these changes, and create a patch. @xref{Creating
1629 patches}, for details.
1630
1631 @item
1632 Mail the patch to Alexandre Julliard, @email{julliard@@lrc.epfl.ch}.
1633
1634 @item
1635 Wait for the patch to appear in the official distribution.
1636 @end enumerate
1637
1638
1639 @node API function and type naming, Creating patches, Implementing an API function, The Wine Project
1640 @section API function and data type naming conventions
1641 @cindex API function names
1642 @cindex API type names
1643 @cindex names of API functions and types
1644 @cindex naming scheme for API functions and types
1645 @cindex suffixes for API functions and types
1646 @cindex endings of API function and type names
1647
1648 This section describes Wine's naming scheme for API functions and data
1649 types.
1650
1651 The purpose of these naming conventions is to ensure that
1652 @itemize @bullet
1653 @item
1654 both the @WIN16{} and @WIN32{} API are supported within the same source
1655 code,
1656 @item
1657 both wide character functions (with @unicode{} strings) and 8 bit
1658 character functions (with @ascii{} or extended @ascii{} encoding) are
1659 supported, and
1660 @item
1661 the source code can be shared between the emulator and the library
1662 version of Wine.
1663 @end itemize
1664
1665 A function or data type whose name in the @mswindows{} API is @var{xxx}
1666 will in the Wine code have the following name(s):
1667 @table @code
1668 @item @var{xxx}16
1669 This is the version for the 16 bit API. You might call it the ``16 bit
1670 version'' except that the function itself of course runs in true 32 bit
1671 mode (being part of Wine). So, the correct meaning of the suffix is that
1672 this function is part of the 16 bit API.
1673 @item @var{xxx}32
1674 This is the version for the 32 bit API. Use this suffix only if the
1675 function does not use character strings in its parameters or return
1676 values. Otherwise use the next two.
1677 @item @var{xxx}32A
1678 This is the version for the 32 bit API which uses @ascii{} strings (or
1679 rather, strings with 8 bit character encodings, i.e. the standard C
1680 @code{char} type). This version always goes together with another
1681 version, using the next suffix.
1682 @item @var{xxx}32W
1683 This is the version for the 32 bit API which uses @unicode{} strings,
1684 i.e. strings with wide characters. It goes together with the @ascii{}
1685 version.
1686 @end table
1687
1688 So, where the @mswindows{} API offers one name, Wine actually has two or
1689 three different functions implemented (which will hopefully share a
1690 large part of the code).
1691
1692 Wine allows to use its API functions in two ways. The emulator part of
1693 Wine provides DLL's for the @mswindows{} programs it can run. The
1694 library part of Wine provides a @unix{} programmer with the facility to
1695 use the Wine API's in a standard @unix{} program.
1696
1697 @menu
1698 * Access from the emulator::    How to access API functions and types
1699                                 from applications that are run in the
1700                                 Wine emulator.
1701 * Access in the library::       How to access API functions and types
1702                                 from applications that are linked with
1703                                 the Wine library.
1704 * Access from inside Wine::     How to access API functions and types
1705                                 from inside the Wine code.
1706 @end menu
1707
1708 @node Access from the emulator, Access in the library, , API function and type naming
1709 @subsection Accessing API functions and types from the emulator
1710 @cindex access to DLL API functions and types
1711 @cindex Wine emulator access to API functions and types
1712 @cindex emulator access to Wine API functions and types
1713
1714 The emulator part of Wine provides the hooks for dynamically linking the
1715 API functions to the @mswindows{} executables (@file{.EXE}-files). The
1716 Wine emulator contains all versions (16 or 32 bit, @ascii{} or
1717 @unicode{}) of the API functions in one executable. The emulator
1718 performs a mapping from the @mswindows{} name of the function,
1719 by which the executable calls it, to one of the Wine internal names that
1720 have been used in coding it.
1721
1722 This mapping is done by the built-in DLL handling code of Wine. A
1723 programmer of Wine has to declare the function in one of the virtual
1724 DLL's that are provided by Wine. The declarations are done in the
1725 @file{.spec}-files in the @file{if1632/} directory. @xref{The build
1726 program}, for details.
1727
1728 The @mswindows{} application simply calls the API function by its
1729 standard @mswindows{} name. Wine will apply the correct mapping
1730 according to Wine's selected appearance (as a 16 bit or 32 bit emulator,
1731 which is a parameter on invocation of Wine).
1732
1733
1734 @node Access in the library, Access from inside Wine, Access from the emulator, API function and type naming
1735 @subsection Accessing API functions and types in the library
1736 @cindex Wine library API function and type access
1737 @cindex access to Wine library API functions and types
1738
1739 If Wine is built as a library, and linked to a user-level main program,
1740 the user will also use the standard @mswindows{} names for the API
1741 functions.
1742
1743 Some macros are defined in @file{include/wintypes.h} which perform the
1744 necessary name mappings. 
1745
1746 These macros are (see the examples below):
1747 @deffn_winemacro WINELIB_NAME (@var{xxx})
1748 This macro replaces @var{xxx} by one of @var{xxx}16 or
1749 @var{xxx}32, depending on the definition of the symbols
1750 @code{WINELIB16} and @code{WINELIB32}. @var{xxx} should
1751 be the name of an API function that uses no string arguments.
1752 Use this macro with a @code{#define} to establish the API name @var{xxx}.
1753 @end deffn
1754 @deffn_winemacro WINELIB_NAME_AW (@var{xxx})
1755 This macro replaces @var{xxx} by one of @var{xxx}16, @var{xxx}32A, or
1756 @var{xxx}32W, depending on the definition of the symbols
1757 @code{WINELIB16}, @code{WINELIB32}, and @code{UNICODE}. @var{xxx} should
1758 be the name of an API function that uses string arguments.
1759 Use this macro with a @code{#define} to establish the API name @var{xxx}.
1760 @end deffn
1761 @deffn_winemacro DECL_WINELIB_TYPE (@var{xxx})
1762 This macro declares @var{xxx} to be an equivalent to @var{xxx}16 or
1763 @var{xxx}32, depending on the definition of the symbols
1764 @code{WINELIB16} and @code{WINELIB32}. @var{xxx} should
1765 be the name of an API data type that contains no string arguments.
1766 @end deffn
1767 @deffn_winemacro DECL_WINELIB_TYPE_AW (@var{xxx})
1768 This macro declares the type @var{xxx} to be an equivalent to
1769 @var{xxx}16, @var{xxx}32A, or @var{xxx}32W, depending on the definition
1770 of the symbols @code{WINELIB16}, @code{WINELIB32}, and
1771 @code{UNICODE}. @var{xxx} should be the name of an API data type that
1772 contains string arguments. 
1773 @end deffn
1774
1775 If Wine is compiled as an emulator, these macros have no effect, for the
1776 mapping is then done by the DLL code. This means that within Wine the
1777 name @var{xxx} itself will not be defined.
1778
1779 Note: If the definition of @var{xxx} is exactly the same in @WIN16{} and
1780 @WIN32{}, you can simply use the same name as @mswindows{}.
1781
1782 Here are some examples:
1783 @example
1784 /* A simple type without strings */
1785 typedef short INT16;
1786 typedef int INT32;
1787 DECL_WINELIB_TYPE(INT);
1788
1789 /* A type with strings */
1790 typedef struct @{ /* Win32 ASCII data structure */ @} WNDCLASS32A;
1791 typedef struct @{ /* Win32 Unicode data structure */ @} WNDCLASS32W;
1792 typedef struct @{ /* Win16 data structure */ @} WNDCLASS16;
1793 DECL_WINELIB_TYPE_AW(WNDCLASS);
1794
1795 /* A function with strings */
1796 ATOM RegisterClass16( WNDCLASS16 * );
1797 ATOM RegisterClass32A( WNDCLASS32A * );
1798 ATOM RegisterClass32W( WNDCLASS32W * );
1799 #define RegisterClass WINELIB_NAME_AW(RegisterClass)
1800 @end example
1801
1802 The Winelib user can then say (in the application program):
1803 @example
1804     INT i;
1805     WNDCLASS wc = @{ @dots{} @};
1806     RegisterClass( &wc );
1807 @end example
1808 and this will use the correct declaration depending on the definitions
1809 @code{WINELIB16}, @code{WINELIB32}, and @code{UNICODE}.
1810
1811 Here are the primary defines that are used when Wine is compiled as a
1812 library:
1813 @defvr_cwine WINELIB16
1814 If this @code{#define} is set, the Wine library is to be compiled in its
1815 16 bit form. That means, the 16 bit variants of all functions will be
1816 used and the appearance of the application linked with the Wine library
1817 will be that of a 16 bit application. Of course, both the application
1818 and the Wine library function really run in 32 bit mode. The switch only
1819 selects the function with the name ending in @code{@dots{}16}, which
1820 will perhaps have a behaviour different from its 32 bit counterpart.
1821 @end defvr
1822 @defvr_cwine WINELIB32
1823 If this @code{#define} is set, the Wine library is to be compiled in its
1824 32 bit form. That means, the 32 bit variants of all functions will be
1825 used and the appearance of the application linked with the Wine library
1826 will be that of a 32 bit application.
1827 @end defvr
1828 @defvr_cwine UNICODE
1829 This @code{define} is used to select one of two possible 32 bit
1830 variants. Functions and data types of the 32 bit API come in two
1831 flavours: one handling @ascii{} strings (or rather strings with
1832 characters encoded in 8 bit), the other @unicode{} strings. This define
1833 selects the correct variant. As a user of the Wine library, you are
1834 responsible to use the correct character type in your part of the
1835 application which accesses the Wine API functions and data types.
1836 @end defvr
1837
1838 These switches are automatically set when Wine is compiled as a library.
1839
1840
1841 @node Access from inside Wine, , Access in the library, API function and type naming
1842 @subsection Accessing API functions from within Wine
1843 @cindex explicit names of API functions and types
1844
1845 Within Wine and during the compilation of Wine, you cannot rely on the
1846 @mswindows{} names of the API functions and data types. If Wine is
1847 compiled as a library, they will be defined; if Wine is compiled as an
1848 emulator, they won't.
1849
1850 You therefore have to access all functions and data types by their full
1851 names, with the proper suffix explicitly appended. In Wine, the 16 bit
1852 and 32 bit versions of the functions are distinct entities, which might
1853 (theoretically) show a completely different behaviour. They may even
1854 call each other (and they will quite frequently).
1855
1856 Therefore Wine is a conglomerate that contains all two or
1857 three flavours of each function at once, and exports to the
1858 application whichever of these is appropriate. Remember that inside
1859 Wine, there is no memory segmentation, so all functions are 32 bit.
1860 The 16-to-32 bit mapping is done on exporting the DLL functions.
1861
1862
1863 @node Creating patches, Adding Documentation, API function and type naming, The Wine Project
1864 @section Creating patches
1865 @xref{Applying patches}, for instructions on applying patches.
1866
1867 Patches are created with the program @code{diff}. You need a copy
1868 of clean source tree to diff against. The @samp{-u} option, to create 
1869 unified diffs, is popular but not obligatory.
1870 For changes to a single file,
1871 @code{diff -u wine990101/windows/win.c mywine/windows/win.c > win_patch}
1872 is sufficient.
1873 To generate a complete diff between your tree and the distribution,
1874 use @code{diff -uR wine990101 mywine}.
1875
1876 This assumes that the original distribution and your personal tree
1877 have the same parent directory, from which you make the diff.
1878 This ensures a consistent format for the diffs, which in turn
1879 is necessary so that they can be applied consistently as described in
1880 @xref{Applying patches}.
1881
1882 @node Adding Documentation, File names, Creating patches, The Wine Project
1883 @section Adding Documentation
1884
1885 @ifinfo
1886 Here are some templates which should help you collaborate on this
1887 documentation. Read the text below before examining them.
1888 @end ifinfo
1889
1890 @menu
1891 * Type Template::               How to document data types in Wine's
1892                                 include files.
1893 * Function Template::           How to document an (API) function of
1894                                 Wine. 
1895 @end menu
1896
1897
1898 These are my tips for adding documentation.
1899
1900 Do not simply copy documentation from @mswindows{} related
1901 material. Except from risking copyright violations, which you would not
1902 want to do, there is another aspect to that:
1903 As Wine is a product to run on @unix{} and @unix{}-like workstations,
1904 it seems a good idea to me to organize this documentation primarily for
1905 the well-trained @unix{} reader. Please keep that in mind when you add
1906 some documentation.
1907
1908 Finally, read the info pages for @code{texinfo}.
1909
1910 The rest of this section provides some templates which can serve as a
1911 start in writing documentation.
1912
1913 @subsection Template introduction
1914 @iftex
1915 On the following pages you will find some @code{texinfo} templates, which
1916 should help you collaborate on this documentation.
1917 @end iftex
1918
1919 These templates give hints on how to document data types, functions,
1920 variables, constants etc. in Wine.
1921 As documentation evolves, you will find common features of data types
1922 that should be described in a unified fashion. In such a case, please
1923 add a corresponding style guide-line here, in this very place, to help
1924 keeping documentation of data types unified.
1925
1926
1927 Start out the type or function with a new node. Write a comment before
1928 the node, listing all data types (and functions) described in the node,
1929 like this:
1930 @example
1931 @@c
1932 @@c *** struct FILETIME ***
1933 @@c
1934 @@node Type FILETIME, NextNodeName, PreviousNodeName, ParentNodeName
1935 @end example
1936
1937 The node command describes the node name and the names of the next node,
1938 the previous node, and the parent node. The parent node should contain
1939 a menu entry for this node. The previous node is the node that appears
1940 before this node in the parent node menu. The next node is the node
1941 succeeding this one in the parent node menu. If there is no previous or
1942 next node, omit the name (putting just a single space between the two
1943 commata).
1944
1945 The node name must be a unique sequence of words. Case is important, so
1946 @emph{Type} and @emph{type} are distinct. The node name must not contain
1947 special characters like @samp{@@, @{, @}} or the comma. If you need to
1948 give a node the same name as a function, data type, etc., use the words
1949 @samp{Type}, @samp{Function}, etc. before the identifier.
1950
1951 Always put the names of the node and its links on the same line, even if
1952 it gets rather long.
1953
1954 If there are two or more data types or functions described in the node,
1955 adapt the comment like this:
1956 @example
1957 @@c
1958 @@c *** int  X   ***
1959 @@c *** long Y() ***
1960 @@c
1961 @@node Ints and Longs, NextNodeName, PreviousNodeName, ParentNodeName
1962 @end example
1963
1964 After the node name, put a sectioning command, such as @samp{@@chapter},
1965 @samp{@@section}, @samp{@@subsection}, or @samp{@@subsubsection}.
1966 Without that command, cross references to the node will fail.
1967 @example
1968 @@subsubsection Type FILETIME
1969 @end example
1970
1971 Start the description of the type(s) or function(s) with a single
1972 non-indented paragraph that gives a one-line description of the type(s)
1973 or function(s) and states the include files that are required.
1974 @example
1975 @@noindent
1976 File times in Wine are specified by the data type @@code@{FILETIME@},
1977 defined in @@file@{windows.h@}.
1978 @end example
1979 If several types or functions are closely connected, use one paragraph
1980 as a common description. If more paragraphs are required for a proper
1981 description, indent all but the first of them.
1982
1983 Then start the definition of the data type or function. Use the proper
1984 macro, which you will find defined in the beginning of the texinfo file.
1985 If appropriate, add your own macros.
1986 Again, put everything that belongs to the header into a single line.
1987 Use continuation lines for additional headers.
1988 @example
1989 @@deftp_w32  FILETIME
1990 @@deftpx_w32 LPFILETIME
1991 @end example
1992
1993 In the definition, give a verbal explanation of the data type or
1994 function. The explanation should be rather complete, exact, and
1995 comprehensible, than well-structured. This is the point where you can
1996 tell everything you want. Do not be afraid of wasting space.
1997 Do not describe the @mswindows{} situation but only say what Wine
1998 does. That is important. (Sometimes they might even do the same.)
1999 @example
2000 This is the data type for specifying file times. The file times are
2001 stored with 64 bit precision. The actual data type is a structure with
2002 two 32 bit values which are interpreted as the low and high parts of a
2003 64-bit value. This value gives a time measured in a granularity of 100
2004 nanoseconds, so 1.5 seconds are specified by a value of 15,000,000.  In
2005 Wine, this 64-bit value is signed, with the sign taken from the high
2006 part. The lower part is used as unsigned.
2007 @end example
2008
2009 For data types, it is recommended to quote the definition from the
2010 header file. For a function, you might give a short example of its
2011 usage. You may also put one example in the end of a node that explains
2012 several of the functions in the node. Remember that cut-and-paste from a
2013 well prepared example will help the readers write their code.
2014 @example
2015 The definition of @@code@{FILETIME@} reads:
2016 @@example
2017 typedef struct
2018 @@@{
2019     INT32 dwLowDateTime;
2020     INT32 dwHighDateTime;
2021 @@@} FILETIME, *LPFILETIME;
2022 @@end example
2023 @end example
2024
2025 You could also use the @code{cindex} command which creates an entry in
2026 the concept index. The @code{texinfo} manual recommends to keep concept
2027 entries distinct, so that a single concept index entry puts to one
2028 well-defined place in the document. Use lower case letters for index
2029 entries, unless they are proper names or quotes from actual code.
2030 @example
2031 @@cindex epoch in file time
2032 The @@code@{FILETIME@} structure may be used to hold absolute or relative
2033 times. Absolute times are given as the number of 100 nanoseconds
2034 intervals elapsed since 1 January 1601, 00:00:00 UTC (Coordinated
2035 Universal Time, which is GMT, Greenwich Mean Time). This might be
2036 called the @@dfn@{epoch@} for file times. With a signed 64-bit value, this
2037 representation covers absolute times of 29247 years around the epoch.
2038 @end example
2039
2040 After the verbal documentation, you can add some special fields
2041 describing bugs, implementation dependencies etc. Two of these are
2042 recommended to attach to all descriptions. One describes the
2043 conformance of the data type or function to @mswindows{} products,
2044 i.e. whether the item is also present in @WINNT{} and @WIN95{}. The
2045 other one describes known differences of the Wine item to its
2046 @mswindows{} counterpart. Both will greatly help in porting software
2047 from @mswindows{} to Wine and vice versa.
2048 @example
2049 @@winconfall@{@}
2050
2051 @@windiff@{@}
2052 In @@mswindows@{@}, the elements of the structure are apparently of type
2053 @@code@{DWORD@}. Whether the full 64 bit value is interpreted as signed or
2054 unsigned I do not know.
2055 @end example
2056
2057 If you find that more of these property attributes are necessary, feel
2058 free to create your own ones. But keep in mind that they should be
2059 applicable more or less to all described items. Very special properties
2060 will better be put into the verbal text.
2061
2062 Finally end the definition of the data type or function:
2063 @example
2064 @@end deftp
2065 @end example
2066
2067 Do not forget to enter the node in the menu of its top node, and do
2068 properly link the node to its successor and predecessor.
2069
2070
2071
2072
2073
2074
2075 @node Type Template, Function Template, , Adding Documentation
2076 @subsection Data type template
2077
2078 Category: Data type
2079
2080 @node Function Template, , Type Template, Adding Documentation
2081 @subsection API function template
2082
2083 Functions should be given category names, to indicate which API they
2084 belong to. Please add items to the list of categories possible.
2085
2086 Category: WIN32 function
2087
2088 @example
2089 @@c
2090 @@c ***GetFileTime() ***
2091 @@c
2092 @@node Get File Times, , Compare File Times, File Times
2093 @@noindent
2094 The Wine function @@code@{GetFileTime@} returns the creation time and
2095 the times of last the read and modification access to a file. It is
2096 defined in @@file@{windows.h@}.
2097
2098 @@deftypefn_w32 BOOL GetFileTime (@@w@{HANDLE @@var@{file@},@} @@w@{LPFILETIME @@var@{ctime@},@} @@w@{LPFILETIME @@var@{atime@},@} @@w@{LPFILETIME @@var@{mtime@})@}
2099 This function obtains for the specified @@var@{file@} the creation time
2100 @@var@{ctime@}, the time of the last access to the file @@var@{atime@}, and
2101 the time of the last modification (write) to the file, @@var@{mtime@}.
2102 The @@var@{file@} handle must have been obtained by opening the file with
2103 @@code@{GENERIC_READ@} access. The file time arguments of this function are
2104 pointers to @@code@{FILETIME@} variables, which are filled with a value that
2105 indicates an absolute time in UTC. To convert these values to local
2106 times, use the function @@code@{FileTimeToLocalFileTime@}. If you do not
2107 need some of the times, you can pass a @@code@{NULL@} pointer.
2108 The function returns @@code@{TRUE@} on success, @@code@{FALSE@} on failure.
2109
2110 @@winconfall@{@}
2111
2112 @@windiffnone@{@}
2113 @@end deftypefn
2114 @end example
2115
2116
2117 @node File names, Wide character strings, Adding Documentation, The Wine Project
2118 @section @mswindows{} and @unix{} file names in Wine
2119 @cindex file names in Wine
2120 @cindex Windows file names
2121 @cindex DOS file names in Wine
2122 @cindex UNIX file names in Wine
2123 @cindex POSIX file names in Wine
2124
2125 FIXME:
2126
2127 @node Wide character strings, , File names, The Wine Project
2128 @section Wide character strings in API functions
2129 @cindex unicode strings in API functions
2130 @cindex wide character strings in API functions
2131 @cindex strings in API functions
2132 @cindex ascii strings in API functions
2133 @cindex 16 bit characters in API functions
2134 @cindex wchar_t in API functions
2135
2136 Presently, all wide character strings in API functions of Wine are
2137 internally converted to 8 bit representation. Thus, the @WIN32{} API
2138 with @unicode{} strings is not fully functional for the application
2139 programmer at present.
2140
2141 Even so, application programmers might consider developing their
2142 applications in wide character format with Wine, as future versions
2143 might bring a change. This might come when a @unix{} filesystem can
2144 handle @unicode{} file names.
2145
2146 Furthermore, the @unicode{} API is required to let Wine run @mswindows{}
2147 applications which have been compiled for wide character strings.
2148
2149 In Wine, wide characters are strictly 16 bit; the @code{wchar_t} type of
2150 standard C can therefore not be used.
2151
2152 @node Concept Index, , , Top
2153 @comment  node-name,  next,  previous,  up
2154 @unnumbered Concept Index
2155 @printindex cp
2156
2157 @node Type Index, , , Top
2158 @comment  node-name,  next,  previous,  up
2159 @unnumbered Type Index
2160 @printindex tp
2161
2162 @node Function Index, , , Top
2163 @comment  node-name,  next,  previous,  up
2164 @unnumbered Function Index
2165 @printindex fn
2166
2167 @node Variable Index, , , Top
2168 @comment  node-name,  next,  previous,  up
2169 @unnumbered Variable, Constants, and Variable-like Macros Index
2170 @printindex vr
2171
2172 @node File Index, , , Top
2173 @comment  node-name,  next,  previous,  up
2174 @unnumbered File and Program Index
2175 @printindex pg
2176
2177
2178 @contents
2179 @bye