1 This document should help new developers get started. Like all of Wine, it
8 The Wine source tree is loosely based on the original Windows modules.
9 Most of the source is concerned with implementing the Wine API, although
10 there are also various tools, documentation, sample Winelib code, and
11 code specific to the binary loader. Note that several of the libraries
12 listed here are "stubbed out", meaning they still need to be implemented.
17 activeds/ - Active Directory Service Interface
18 advapi32/ - Crypto, systeminfo, security, eventlogging
19 advpack/ - Reads and verifies .INF files
20 amstream/ - MultiMedia Streams
21 atl/ - Active Template Library
22 avicap32/ - AVI capture window class
23 avifil32/ - COM object to play AVI files
24 cabinet/ - Cabinet file interface
25 capi2032/ - Wrapper library for CAPI4Linux access
26 cards/ - Card graphics
27 cfgmgr32/ - Config manager
28 comcat/ - Component category manager
29 comctl32/ - Common controls
30 commdlg/ - Common dialog boxes (both 16 & 32 bit)
31 crtdll/ - Old C runtime library
32 crypt32/ - Cryptography
33 cryptdll/ - Cryptography Manager
34 ctl3d32/ - 3D Effects for Common GUI Components
35 d3d8/ - Direct3D (3D graphics)
36 d3d9/ - Direct3D (3D graphics)
37 d3dim/ - Direct3D Immediate Mode
38 d3drm/ - Direct3D Retained Mode
39 d3dx8/ - Direct3D (3D graphics)
40 d3dxof/ - DirectX Files Functions
41 dbghelp/ - Engine for symbol and module enumeration
42 dciman32/ - DCI Manager (graphics)
43 ddraw/ - DirectDraw (graphics)
44 devenum/ - Device enumeration (part of DirectShow)
45 dinput/ - DirectInput (device input)
46 dinput8/ - DirectInput (device input)
47 dmband/ - DirectMusic Band
48 dmcompos/ - DirectMusic Composer
49 dmime/ - DirectMusic Interactive Engine
50 dmloader/ - DirectMusic Loader
51 dmscript/ - DirectMusic Scripting
52 dmstyle/ - DirectMusic Style Engine
53 dmsynth/ - DirectMusic Software Synthesizer
54 dmusic/ - DirectMusic Core Services
55 dmusic32/ - DirectMusic Legacy Port
56 dplay/ - DirectPlay (networking)
57 dplayx/ - DirectPlay (networking)
58 dpnet/ - DirectPlay (networking)
59 dpnhpast/ - DirectPlay NAT Helper PAST
60 dsound/ - DirectSound (audio)
61 dswave/ - DirectMusic Wave
62 dxdiagn/ - DirectX Diagnostic Tool
64 glu32/ - OpenGL Utility library (graphics)
65 glut32/ - OpenGL Utility Toolkit
66 hhctrl.ocx/ - HHCTRL OCX implementation
67 iccvid/ - Radius Cinepak Video Decoder
68 icmp/ - ICMP protocol (networking)
69 ifsmgr.vxd/ - IFSMGR VxD implementation
70 imaadp32.acm/ - IMA ADPCM Audio Codec
71 imagehlp/ - PE (Portable Executable) Image Helper lib
72 imm32/ - Input Method Manager
73 iphlpapi/ - IP Helper API
74 itss/ - Infotech Structured Storage (HTML Help)
75 kernel/ - The Windows kernel
76 lz32/ - Lempel-Ziv compression/decompression
77 mapi32/ - Mail interface
78 mciavi32/ - MCI video driver
79 mcicda/ - MCI audio CD driver
80 mciseq/ - MCI MIDI driver
81 midimap/ - MIDI mapper
82 mlang/ - Multi Language Support
83 mmdevldr.vxd/ - MMDEVLDR VxD implementation
84 monodebg.vxd/ - MONODEBG VxD implementation
85 mpr/ - Multi-Protocol Router (networking)
86 msacm/ - Audio Compression Manager (multimedia)
87 msadp32.acm/ - MS ADPCM Audio Codec
88 mscms/ - Color Management System
89 msdmo/ - DirectX Media Objects
90 msftedit/ - Rich text editing control (Version 4.1)
91 msg711.acm/ - MS G711 Audio Codec (includes A-Law & MU-Law)
92 mshtml/ - MS HTML component
93 msi/ - Microsoft Installer
94 msimg32/ - Gradient and transparency (graphics)
95 msisys/ - System information
96 msnet32/ - Network interface
97 msrle32/ - Video codecs
98 msvcrt/ - C runtime library
99 msvcrt20/ - C runtime library version 2.0
100 msvcrt40/ - C runtime library version 4.0
101 msvcrtd/ - C runtime library debugging
102 msvfw32/ - 16 bit video manager
103 msvidc32/ - Microsoft Video-1 Decoder
104 mswsock/ - Misc networking
105 msxml3/ - MSXML Class Factory
106 netapi32/ - Network interface
107 newdev/ - New Hardware Device Library
108 ntdll/ - NT implementation of kernel calls
109 objsel/ - Object Picker Dialog
110 odbc32/ - Open DataBase Connectivity driver manager
111 odbccp32/ - Open DataBase Connectivity driver installer
112 ole32/ - 32 bit OLE 2.0 libraries
113 oleacc/ - OLE accessibility support
114 oleaut32/ - 32 bit OLE 2.0 automation
115 olecli32/ - 16 bit OLE client
116 oledlg/ - OLE 2.0 user interface support
117 olepro32/ - 32 bit OLE 2.0 automation
118 olesvr32/ - 16 bit OLE server
119 opengl32/ - OpenGL implementation (graphics)
120 powrprof/ - Power Management and Profiling
121 psapi/ - Process Status interface
122 qcap/ - DirectShow runtime
123 quartz/ - DirectShow runtime
124 rasapi32/ - Remote Access Server interface
125 riched20/ - Rich text editing control (Version 2.0 and 3.0)
126 richedit/ - Rich text editing control
127 rpcrt4/ - Remote Procedure Call runtime
128 rsabase/ - RSA encryption
129 rsaenh/ - Crypto API (DES, 3DES, RSA, etc.)
130 secur32/ - Contains Windows Security functions
131 security/ - Security Support Provider Interface
132 sensapi/ - System Event Notification Service
133 serialui/ - Serial port property pages
134 setupapi/ - Setup interface
135 sfc/ - System File Checker (Windows File Protection)
136 shdocvw/ - Shell document object and control
137 shell32/ - COM object implementing shell views
138 shfolder/ - Shell folder service
139 shlwapi/ - Shell Light-Weight interface
140 snmpapi/ - SNMP protocol interface (networking)
141 spoolss/ - Spooler Subsystem Library ("spooler" - Service)
142 stdole2.tlb/ - OLE Automation typelib
143 stdole32.tlb/ - Standard OLE typelib
144 sti/ - Still Image service
145 tapi32/ - Telephone interface
146 twain/ - TWAIN Imaging device communications
147 unicows/ - Unicows replacement (Unicode layer for Win9x)
148 url/ - Internet shortcut shell extension
149 urlmon/ - URL Moniker allows binding to a URL
150 user/ - Window management, standard controls, etc.
151 usp10/ - Uniscribe Script Processor
152 uxtheme/ - Theme library
153 vdhcp.vxd/ - VDHCP VxD implementation
154 vdmdbg/ - Virtual DOS machine debug library
155 version/ - File installation library
156 vmm.vxd/ - VMM VxD implementation
157 vnbt.vxd/ - VNBT VxD implementation
158 vnetbios.vxd/ - VNETBIOS VxD implementation
159 vtdapi.vxd/ - VTDAPI VxD implementation
160 vwin32.vxd/ - VWIN32 VxD implementation
161 win32skrnl/ - 32-bit function access for 16-bit systems
162 wined3d/ - Wine internal Direct3D helper
163 winedos/ - DOS features and BIOS calls (Wine specific)
164 winemp3.acm/ - Mpeg Layer 3 Audio Codec
165 wineps/ - Postscript driver (Wine specific)
166 wininet/ - Internet extensions
167 winmm/ - Multimedia (16 & 32 bit)
168 winmm/joystick/ - Joystick driver
169 winmm/mciwave/ - MCI wave driver
170 winmm/wavemap/ - Audio mapper
171 winmm/winealsa/ - ALSA audio driver
172 winmm/winearts/ - aRts audio driver
173 winmm/wineaudioio/ - audioio audio driver
174 winmm/winejack/ - JACK audio server driver
175 winmm/winenas/ - NAS audio driver
176 winmm/wineoss/ - OSS audio driver
177 winnls32/ - National Language Support
178 winspool/ - Printing & Print Spooler
179 wintab32/ - Tablet device interface
180 wintrust/ - Trust verification interface
181 wldap32/ - LDAP support
182 wnaspi32/ - 16 bit Advanced SCSI Peripheral Interface
183 wow32/ - WOW subsystem
184 ws2_32/ - Sockets 2.0 (networking)
185 wsock32/ - Sockets 1.1 (networking)
186 wtsapi32/ - Terminal Services
187 x11drv/ - X11 display driver (Wine specific)
189 Winelib programs (under programs/):
190 -----------------------------------
192 avitools/ - AVI information viewer and player
193 clock/ - Graphical clock
194 cmdlgtst/ - Common dialog tests
195 control/ - Control panel
196 expand/ - Decompress Lempel-Ziv compressed archive
197 msiexec/ - Microsoft Installer frontend
198 notepad/ - Notepad replacement
199 progman/ - Program manager
200 regedit/ - Registry editor
201 regsvr32/ - Register COM server
202 rpcss/ - RPC services
203 rundll32/ - Execute DLL functions directly
204 start/ - Replacement for start.exe
205 taskmgr/ - Manage running Windows/Winelib applications
206 uninstaller/ - Remove installed programs
207 view/ - Metafile viewer
208 wcmd/ - Command line interface
209 wineboot/ - Wine bootstrap process
210 winecfg/ - Wine configuration utility
211 wineconsole/ - Console
213 winefile/ - File manager
214 winemenubuilder/ - Helper program for building Unix menu entries
215 winemine/ - Mine game
216 winepath/ - Translate between Wine and Unix paths
217 winetest/ - Wine testing shell
218 winevdm/ - Wine virtual DOS machine
219 winhelp/ - Help viewer
220 winver/ - Windows Version Program
223 Support programs, libraries, etc:
224 ---------------------------------
226 dlls/dxerr8/ - DirectX 8 error import lib
227 dlls/dxerr9/ - DirectX 9 error import lib
228 dlls/dxguid/ - DirectX UUID import lib
229 dlls/strmiids/ - Exports class CLSIDs and interface IIDs
230 dlls/uuid/ - Windows-compatible UUID import lib
231 documentation/ - some documentation
232 include/ - Windows standard includes
233 include/msvcrt/ - MSVC compatible libc headers
234 include/wine/ - Wine specific headers
235 libs/ - the Wine libraries
236 libs/port/ - portability library
237 libs/unicode/ - Unicode support shared
238 libs/wine/ - Wine bootstrap library
239 libs/wpp/ - C preprocessor
240 loader/ - the main Wine loader
241 server/ - the Wine server
242 tools/ - various tools used to build/check Wine
243 tools/widl/ - the IDL compiler
244 tools/winapi/ - A Win32 API checker
245 tools/winebuild/ - Wine build tool
246 tools/winedump/ - a .DLL dump utility
247 tools/winegcc/ - a MinGW command line compatible gcc wrapper
248 tools/wmc/ - the message compiler
249 tools/wpp/ - the C pre-processor library
250 tools/wrc/ - the resource compiler
254 IMPLEMENTING NEW API CALLS
255 ==========================
257 This is the simple version, and covers only Win32. Win16 is slightly
258 uglier, because of the Pascal heritage and the segmented memory model.
260 All of the Win32 APIs known to Wine are listed in the .spec file of
261 their corresponding dll. An unimplemented call will look like (from
263 269 stub PolyBezierTo
264 To implement this call, you need to do the following four things.
266 1. Find the appropriate parameters for the call, and add a prototype to
267 the correct header file. In this case, that means [include/wingdi.h],
268 and it might look like
269 BOOL WINAPI PolyBezierTo(HDC, LPCVOID, DWORD);
270 If the function has both an ASCII and a Unicode version, you need to
271 define both and add a #define WINELIB_NAME_AW declaration. See below
272 for discussion of function naming conventions.
274 2. Modify the .spec file to tell Wine that the function has an
275 implementation, what the parameters look like and what Wine function
276 to use for the implementation. In Win32, things are simple--everything
277 is 32-bits. However, the relay code handles pointers and pointers to
278 strings slightly differently, so you should use 'str' and 'wstr' for
279 strings, 'ptr' for other pointer types, and 'long' for everything else.
280 269 stdcall PolyBezierTo(long ptr long) PolyBezierTo
281 The 'PolyBezierTo' at the end of the line is which Wine function to use
282 for the implementation.
284 3. Implement the function as a stub. Once you add the function to the .spec
285 file, you must add the function to the Wine source before it will link.
286 Add a function called 'PolyBezierTo' somewhere. Good things to put
288 o a correct prototype, including the WINAPI
289 o header comments, including full documentation for the function and
290 arguments (see documentation/README.documentation)
291 o A FIXME message and an appropriate return value are good things to
294 /************************************************************
295 * PolyBezierTo (GDI32.269)
297 * Draw many Bezier curves.
300 * hdc [I] Device context to draw to
301 * p [I] Array of POINT structs
302 * count [I] Number of points in p
306 * Failure: FALSE. Use GetLastError() to find the error cause.
311 BOOL WINAPI PolyBezierTo(HDC hdc, LPCVOID p, DWORD count)
313 /* tell the user they've got a substandard implementation */
314 FIXME("(%x,%p,%d): stub\n", hdc, p, count);
316 /* some programs may be able to compensate,
317 * if they know what happened
319 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
320 return FALSE; /* error value */
323 4. Implement and test the rest of the function.
326 IMPLEMENTING A NEW DLL
327 ======================
332 Apart from writing the set of needed .c files, you also need to do the
335 1. Create a directory <MyDll> where to store the implementation of
336 the DLL. This directory has to be put under the dlls/ directory.
337 If the DLL exists under Windows as both 16 and 32 bit DLL, you
338 should have a single directory with both implementations.
340 2. Create the Makefile.in in the ./dlls/<MyDll>/ directory. You can
341 copy an existing Makefile.in from another ./dlls/ subdirectory.
342 You need at least to change the MODULE and C_SRCS macros.
344 3. Add the directory in ./configure.ac (in AC_OUTPUT macro at the end
345 of the file to trigger the Makefile generation)
347 4. Run ./make_dlls in the dlls directory to update Makefile.in in
350 5. You can now regenerate ./configure file (with 'autoconf')
351 and the various Makefiles (with 'configure; make depend') (run
352 from the top of Wine's tree).
353 You should now have a Makefile file in ./dlls/<MyDll>/
355 6. Create the .spec file for the DLL exported functions in your
356 directory. Refer to 'Implementation of new API calls' earlier in
357 this document for more information on this part.
359 7. You can now start adding .c files. For the .h files, if they are
360 standard Windows one, put them in include/. If they are linked to
361 *your* implementation of the dll, put them in your newly created
367 If you need to create a new debug channel, just add the
368 WINE_DEFAULT_DEBUG_CHANNEL to your .c file(s), and use them.
369 All the housekeeping will happen automatically.
374 If you also need to add resources to your DLL, then create the .rc
375 file. Add to your ./dlls/<MyDll>/Makefile.in, in the RC_SRCS macro,
376 the list of .rc files to add to the DLL. See dlls/comctl32/ for an
382 If you're building a 16 & 32 bit DLLs pair, then from the 32 bit code
383 you might need to call 16 bit routine. The way to do it to add in the
384 code, fragments like:
385 /* ### Start build ### */
386 extern WORD CALLBACK <PREFIX>_CallTo16_word_wwlll(FARPROC16,WORD,WORD,LONG,LONG,LONG);
387 /* ### stop build ### */
388 Where <PREFIX>_ is an internal prefix for your module. The first
389 parameter is always of type FARPROC16. Then, you can get the regular
390 list of parameters. The _word_wwlll indicates the type of return (long
391 or word) and the size of the parameters (here l=>long, w=>word; which
392 maps to WORD,WORD,LONG,LONG,LONG.
393 You can put several functions between the Start/Stop build pair.
395 You can also read the winebuild manpage for more details on this.
397 Then, add to ./dlls/<MyDll>/Makefile.in a line like:
399 EXTRA_OBJS = $(MODULE).glue.o
401 See dlls/winmm/ for an example of this.
406 NE (Win16) executables consist of multiple segments. The Wine loader
407 loads each segment into a unique location in the Wine processes memory
408 and assigns a selector to that segment. Because of this, it's not
409 possible to exchange addresses freely between 16-bit and 32-bit code.
410 Addresses used by 16-bit code are segmented addresses (16:16), formed
411 by a 16-bit selector and a 16-bit offset. Those used by the Wine code
412 are regular 32-bit linear addresses.
414 There are four ways to obtain a segmented pointer:
415 - Using the MapLS function (recommended).
416 - Allocate a block of memory from the global heap and use
417 WIN16_GlobalLock to get its segmented address.
418 - Declare the argument as 'segptr' instead of 'ptr' in the spec file
419 for a given API function.
421 Once you have a segmented pointer, it must be converted to a linear
422 pointer before you can use it from 32-bit code. This can be done with
423 the MapSL function. The linear pointer can then be used freely with
424 standard Unix functions like memcpy() etc. without worrying about 64k
425 boundaries. Note: there's no easy way to convert back from a linear
426 to a segmented address.
428 In most cases, you don't need to worry about segmented address, as the
429 conversion is made automatically by the callback code and the API
430 functions only see linear addresses. However, in some cases it is
431 necessary to manipulate segmented addresses; the most frequent cases
433 - API functions that return a pointer
434 - lParam of Windows messages that point to a structure
435 - Pointers contained inside structures accessed by 16-bit code.
437 It is usually a good practice to used the type 'SEGPTR' for segmented
438 pointers, instead of something like 'LPSTR' or 'char *'. As SEGPTR is
439 defined as a DWORD, you'll get a compilation warning if you mistakenly
440 use it as a regular 32-bit pointer.
446 Under Windows, data structures are tightly packed, i.e. there is no
447 padding between structure members. On the other hand, by default gcc
448 aligns structure members (e.g. WORDs are on a WORD boundary, etc.).
449 This means that a structure like
451 struct { BYTE x; WORD y; };
453 will take 3 bytes under Windows, but 4 with gcc, because gcc will add a
454 dummy byte between x and y. To have the correct layout for structures
455 used by Windows code, you need to embed the struct within two special
456 #include's which will take care of the packing for you:
458 #include "pshpack1.h"
459 struct { BYTE x; WORD y; };
460 #include "poppack1.h"
462 For alignment on a 2-byte boundary, there is a "pshpack2.h", etc.
465 NAMING CONVENTIONS FOR API FUNCTIONS AND TYPES
466 ==============================================
468 In order to support both Win16 and Win32 APIs within the same source
469 code, the following convention must be used in naming all API
470 functions and types. If the Windows API uses the name 'xxx', the Wine
473 - 'xxx16' for the Win16 version,
474 - 'xxx' for the Win32 version when no strings are involved,
475 - 'xxxA' for the Win32 version with ASCII strings,
476 - 'xxxW' for the Win32 version with Unicode strings.
478 If the function has both ASCII and Unicode version, you should then
479 use the macros WINELIB_NAME_AW(xxx) or DECL_WINELIB_TYPE_AW(xxx)
480 (defined in include/windef.h) to define the correct 'xxx' function
481 or type for Winelib. When compiling Wine itself, 'xxx' is _not_
482 defined, meaning that code inside of Wine must always specify
483 explicitly the ASCII or Unicode version.
485 If 'xxx' is the same in Win16 and Win32, you can simply use the same
486 name as Windows, i.e. just 'xxx'. If 'xxx' is Win16 only, you could
487 use the name as is, but it's preferable to use 'xxx16' to make it
488 clear it is a Win16 function.
492 typedef struct { /* Win32 ASCII data structure */ } WNDCLASSA;
493 typedef struct { /* Win32 Unicode data structure */ } WNDCLASSW;
494 typedef struct { /* Win16 data structure */ } WNDCLASS16;
495 DECL_WINELIB_TYPE_AW(WNDCLASS);
497 ATOM RegisterClass16( WNDCLASS16 * );
498 ATOM RegisterClassA( WNDCLASSA * );
499 ATOM RegisterClassW( WNDCLASSW * );
500 #define RegisterClass WINELIB_NAME_AW(RegisterClass)
502 The Winelib user can then say:
504 WNDCLASS wc = { ... };
505 RegisterClass( &wc );
507 and this will use the correct declaration depending on the definition
508 of the UNICODE symbol.
514 To display a message only during debugging, you normally write something
522 depending on the seriousness of the problem. (documentation/debugging.sgml
523 explains when it is appropriate to use each of them). You need to declare
524 the debug channel name at the top of the file (after the includes) using
525 the WINE_DEFAULT_DEBUG_CHANNEL macro, like so:
527 WINE_DEFAULT_DEBUG_CHANNEL(win);
529 If your debugging code is more complex than just printf, you can use
532 TRACE_ON(xxx), WARN_ON(xxx), ERR_ON(xxx) and FIXME_ON(xxx)
534 to test if the given channel is enabled. Thus, you can write:
536 if (TRACE_ON(win)) DumpSomeStructure(&str);
538 Don't worry about the inefficiency of the test. If it is permanently
539 disabled (that is TRACE_ON(win) is 0 at compile time), the compiler will
540 eliminate the dead code.
542 For more info about debugging messages, read:
544 http://www.winehq.org/site/docs/wine-devel/debugging
550 1. There is a FREE online version of the MSDN library (including
551 documentation for the Win32 API) on http://msdn.microsoft.com/
552 or http://www.msdn.com/
554 2. Windows apilist: http://www.mentalis.org/apilist/apilist.php
556 3. http://www.sonic.net/~undoc/bookstore.html
558 4. In 1993 Dr. Dobbs Journal published a column called "Undocumented Corner".
560 5. www.geocities.com/SiliconValley/4942/