blob: 6ce5549e037e45a96e7c8646e4bbc3786f3370b2 [file] [log] [blame]
Douglas Ridgway692389d1998-11-22 16:56:44 +00001This document should help new developers get started. Like all of Wine, it
2is a work in progress.
Alexandre Julliarddba420a1994-02-02 06:48:31 +00003
Klaas van Gend0a7aa161999-06-05 11:52:46 +00004
Alexandre Julliard889f7421997-04-15 17:19:52 +00005SOURCE TREE STRUCTURE
6=====================
7
Douglas Ridgway692389d1998-11-22 16:56:44 +00008The Wine source tree is loosely based on the original Windows modules.
9Most of the source is concerned with implementing the Wine API, although
10there are also various tools, documentation, sample Winelib code, and
Jeff Smith344ed412002-12-24 00:56:33 +000011code specific to the binary loader. Note that several of the libraries
12listed here are "stubbed out", meaning they still need to be implemented.
Alexandre Julliard889f7421997-04-15 17:19:52 +000013
Dimitrie O. Paunab9cd6e2003-12-08 21:48:39 +000014DLLs (under dlls/):
15-------------------
Alexandre Julliard889f7421997-04-15 17:19:52 +000016
Dimitrie O. Paunab9cd6e2003-12-08 21:48:39 +000017 advapi32/ - Crypto, systeminfo, security, eventlogging
Tom Wicklined8f4a0a2004-11-22 18:28:18 +000018 advpack/ - Reads and verifies .INF files
Tom Wicklinec5da9b22004-05-13 19:40:53 +000019 amstream/ - MultiMedia Streams
Dimitrie O. Paun206937e2004-09-22 19:10:37 +000020 atl/ - Active Template Library
Dimitrie O. Paunab9cd6e2003-12-08 21:48:39 +000021 avicap32/ - AVI capture window class
22 avifil32/ - COM object to play AVI files
23 cabinet/ - Cabinet file interface
24 capi2032/ - Wrapper library for CAPI4Linux access
Tom Wicklinec5da9b22004-05-13 19:40:53 +000025 cards/ - Card graphics
Dimitrie O. Paunab9cd6e2003-12-08 21:48:39 +000026 cfgmgr32/ - Config manager
27 comcat/ - Component category manager
28 comctl32/ - Common controls
29 commdlg/ - Common dialog boxes (both 16 & 32 bit)
30 crtdll/ - Old C runtime library
31 crypt32/ - Cryptography
Dimitrie O. Paun1b5bc2a2005-04-11 12:52:20 +000032 cryptdll/ - Cryptography Manager
Dimitrie O. Paunab9cd6e2003-12-08 21:48:39 +000033 ctl3d/ - 3D Effects for Common GUI Components
34 d3d8/ - Direct3D (3D graphics)
35 d3d9/ - Direct3D (3D graphics)
36 d3dim/ - Direct3D Immediate Mode
Ivan Leo Murray-Smith8f14eb02004-05-18 00:54:12 +000037 d3drm/ - Direct3D Retained Mode
Dimitrie O. Paunab9cd6e2003-12-08 21:48:39 +000038 d3dx8/ - Direct3D (3D graphics)
Tom Wickline49e5fda2004-08-11 23:46:01 +000039 d3dxof/ - DirectX Files Functions
Tom Wicklinec5da9b22004-05-13 19:40:53 +000040 dbghelp/ - Engine for symbol and module enumeration
Dimitrie O. Paunab9cd6e2003-12-08 21:48:39 +000041 dciman32/ - DCI Manager (graphics)
42 ddraw/ - DirectDraw (graphics)
43 devenum/ - Device enumeration (part of DirectShow)
44 dinput/ - DirectInput (device input)
45 dinput8/ - DirectInput (device input)
Tom Wicklinec24c30f2003-12-31 00:11:25 +000046 dmband/ - DirectMusic Band
47 dmcompos/ - DirectMusic Composer
48 dmime/ - DirectMusic Interactive Engine
49 dmloader/ - DirectMusic Loader
50 dmscript/ - DirectMusic Scripting
51 dmstyle/ - DirectMusic Style Engine
52 dmsynth/ - DirectMusic Software Synthesizer
53 dmusic/ - DirectMusic Core Services
54 dmusic32/ - DirectMusic Legacy Port
Dimitrie O. Paunab9cd6e2003-12-08 21:48:39 +000055 dplay/ - DirectPlay (networking)
56 dplayx/ - DirectPlay (networking)
Tom Wicklinec5da9b22004-05-13 19:40:53 +000057 dpnet/ - DirectPlay (networking)
Tom Wicklinec24c30f2003-12-31 00:11:25 +000058 dpnhpast/ - DirectPlay NAT Helper PAST
Dimitrie O. Paunab9cd6e2003-12-08 21:48:39 +000059 dsound/ - DirectSound (audio)
Dimitrie O. Paund9e53ca2004-02-11 23:58:16 +000060 dswave/ - DirectMusic Wave
Tom Wicklinec5da9b22004-05-13 19:40:53 +000061 dxdiagn/ - DirectX Diagnostic Tool
Dimitrie O. Paunab9cd6e2003-12-08 21:48:39 +000062 gdi/ - GDI (graphics)
Dimitrie O. Paunab9cd6e2003-12-08 21:48:39 +000063 glu32/ - OpenGL Utility library (graphics)
Dimitrie O. Paun7470fa72003-12-13 03:20:03 +000064 glut32/ - OpenGL Utility Toolkit
Tom Wicklinec5da9b22004-05-13 19:40:53 +000065 hhctrl.ocx/ - HHCTRL OCX implementation
Dimitrie O. Paund9e53ca2004-02-11 23:58:16 +000066 iccvid/ - Radius Cinepak Video Decoder
Dimitrie O. Paunab9cd6e2003-12-08 21:48:39 +000067 icmp/ - ICMP protocol (networking)
Dimitrie O. Paun29872b82004-02-20 05:13:05 +000068 ifsmgr.vxd/ - IFSMGR VxD implementation
Dimitrie O. Paunab9cd6e2003-12-08 21:48:39 +000069 imagehlp/ - PE (Portable Executable) Image Helper lib
70 imm32/ - Input Method Manager
71 iphlpapi/ - IP Helper API
Mike McCormack91207422004-09-14 17:43:24 +000072 itss/ - Infotech Structured Storage (HTML Help)
Dimitrie O. Paunab9cd6e2003-12-08 21:48:39 +000073 kernel/ - The Windows kernel
74 lzexpand/ - Lempel-Ziv compression/decompression
75 mapi32/ - Mail interface
Tom Wickline49e5fda2004-08-11 23:46:01 +000076 mlang/ - Multi Language Support
Dimitrie O. Paun29872b82004-02-20 05:13:05 +000077 mmdevldr.vxd/ - MMDEVLDR VxD implementation
78 monodebg.vxd/ - MONODEBG VxD implementation
Dimitrie O. Paunab9cd6e2003-12-08 21:48:39 +000079 mpr/ - Multi-Protocol Router (networking)
80 msacm/ - Audio Compression Manager (multimedia)
Dimitrie O. Paun7470fa72003-12-13 03:20:03 +000081 msacm/imaadp32/ - IMA ADPCM Audio Codec
82 msacm/msadp32/ - MS ADPCM Audio Codec
83 msacm/msg711/ - MS G711 Audio Codec (includes A-Law & MU-Law)
84 msacm/winemp3/ - Mpeg Layer 3 Audio Codec
Hans Leidekker51647572004-09-22 04:08:38 +000085 mscms/ - Color Management System
Dimitrie O. Paunab9cd6e2003-12-08 21:48:39 +000086 msdmo/ - DirectX Media Objects
Dimitrie O. Paun7470fa72003-12-13 03:20:03 +000087 mshtml/ - MS HTML component
Tom Wicklinec5da9b22004-05-13 19:40:53 +000088 msi/ - Microsoft Installer
Dimitrie O. Paunab9cd6e2003-12-08 21:48:39 +000089 msimg32/ - Gradient and transparency (graphics)
90 msisys/ - System information
Dimitrie O. Paunab9cd6e2003-12-08 21:48:39 +000091 msnet32/ - Network interface
Tom Wickline49e5fda2004-08-11 23:46:01 +000092 msrle32/ - Video codecs
Dimitrie O. Paunab9cd6e2003-12-08 21:48:39 +000093 msvcrt/ - C runtime library
94 msvcrt20/ - C runtime library version 2.0
Dimitrie O. Paund9e53ca2004-02-11 23:58:16 +000095 msvcrt40/ - C runtime library version 4.0
Dimitrie O. Paunab9cd6e2003-12-08 21:48:39 +000096 msvcrtd/ - C runtime library debugging
Dimitrie O. Paund9e53ca2004-02-11 23:58:16 +000097 msvidc32/ - Microsoft Video-1 Decoder
Dimitrie O. Paunab9cd6e2003-12-08 21:48:39 +000098 msvideo/ - 16 bit video manager
Dimitrie O. Paunab9cd6e2003-12-08 21:48:39 +000099 mswsock/ - Misc networking
100 netapi32/ - Network interface
Tom Wicklinec24c30f2003-12-31 00:11:25 +0000101 newdev/ - New Hardware Device Library
Dimitrie O. Paunab9cd6e2003-12-08 21:48:39 +0000102 ntdll/ - NT implementation of kernel calls
103 odbc32/ - Open DataBase Connectivity driver manager
104 ole32/ - 32 bit OLE 2.0 libraries
Dimitrie O. Paun7470fa72003-12-13 03:20:03 +0000105 oleacc/ - OLE accessibility support
Dimitrie O. Paunab9cd6e2003-12-08 21:48:39 +0000106 oleaut32/ - 32 bit OLE 2.0 automation
107 olecli/ - 16 bit OLE client
108 oledlg/ - OLE 2.0 user interface support
109 olepro32/ - 32 bit OLE 2.0 automation
110 olesvr/ - 16 bit OLE server
111 opengl32/ - OpenGL implementation (graphics)
Benjamin Cutler250a8ae2005-04-20 19:15:31 +0000112 powrprof/ - Power Management and Profiling
Dimitrie O. Paunab9cd6e2003-12-08 21:48:39 +0000113 psapi/ - Process Status interface
114 qcap/ - DirectShow runtime
115 quartz/ - DirectShow runtime
116 rasapi32/ - Remote Access Server interface
Tom Wicklinea812b612005-03-15 15:39:51 +0000117 riched20/ - Rich text editing control version 2.0
Dimitrie O. Paunab9cd6e2003-12-08 21:48:39 +0000118 richedit/ - Rich text editing control
119 rpcrt4/ - Remote Procedure Call runtime
Dimitrie O. Paun8e7f81c2004-02-16 20:33:37 +0000120 rsabase/ - RSA encryption
Tom Wicklined8f4a0a2004-11-22 18:28:18 +0000121 rsaenh/ - Crypto API that provides algorithms for DES, 3DES, and RSA among others
Tom Wicklinec5da9b22004-05-13 19:40:53 +0000122 secur32/ - Contains Windows Security functions
Tom Wicklinea812b612005-03-15 15:39:51 +0000123 sensapi/ - System Event Notification Service
Dimitrie O. Paunab9cd6e2003-12-08 21:48:39 +0000124 serialui/ - Serial port property pages
125 setupapi/ - Setup interface
126 shdocvw/ - Shell document object and control
Dimitrie O. Paunab9cd6e2003-12-08 21:48:39 +0000127 shell32/ - COM object implementing shell views
Tom Wicklinec5da9b22004-05-13 19:40:53 +0000128 shfolder/ - Shell folder service
Dimitrie O. Paunab9cd6e2003-12-08 21:48:39 +0000129 shlwapi/ - Shell Light-Weight interface
130 snmpapi/ - SNMP protocol interface (networking)
Dimitrie O. Paun1b5bc2a2005-04-11 12:52:20 +0000131 stdole32.tlb/ - Standard OLE typelib
Dimitrie O. Paunab9cd6e2003-12-08 21:48:39 +0000132 sti/ - Still Image service
133 tapi32/ - Telephone interface
134 ttydrv/ - TTY display driver (Wine specific)
135 twain/ - TWAIN Imaging device communications
Dimitrie O. Paun7470fa72003-12-13 03:20:03 +0000136 unicows/ - Unicows replacement (Unicode layer for Win9x)
Dimitrie O. Paunab9cd6e2003-12-08 21:48:39 +0000137 url/ - Internet shortcut shell extension
138 urlmon/ - URL Moniker allows binding to a URL (like KIO/gnome-vfs)
139 user/ - Window management, standard controls, etc.
140 uxtheme/ - Theme library
Dimitrie O. Paun29872b82004-02-20 05:13:05 +0000141 vdhcp.vxd/ - VDHCP VxD implementation
Tom Wickline49e5fda2004-08-11 23:46:01 +0000142 vdmdbg/ - Virtual DOS machine debug library
Dimitrie O. Paunab9cd6e2003-12-08 21:48:39 +0000143 version/ - File installation library
Dimitrie O. Paun31dd6892004-02-25 01:25:21 +0000144 vmm.vxd/ - VMM VxD implementation
Tom Wicklinec5da9b22004-05-13 19:40:53 +0000145 vnbt.vxd/ - VNBT VxD implementation
Dimitrie O. Paun29872b82004-02-20 05:13:05 +0000146 vnetbios.vxd/ - VNETBIOS VxD implementation
147 vtdapi.vxd/ - VTDAPI VxD implementation
148 vwin32.vxd/ - VWIN32 VxD implementation
Dimitrie O. Paunab9cd6e2003-12-08 21:48:39 +0000149 win32s/ - 32-bit function access for 16-bit systems
150 winaspi/ - 16 bit Advanced SCSI Peripheral Interface
Dimitrie O. Paun7470fa72003-12-13 03:20:03 +0000151 wined3d/ - Wine internal Direct3D helper
Dimitrie O. Paunab9cd6e2003-12-08 21:48:39 +0000152 winedos/ - DOS features and BIOS calls (interrupts) (wine specific)
153 wineps/ - Postscript driver (Wine specific)
154 wininet/ - Internet extensions
155 winmm/ - Multimedia (16 & 32 bit)
156 winmm/joystick/ - Joystick driver
157 winmm/mcianim/ - MCI animation driver
158 winmm/mciavi/ - MCI video driver
159 winmm/mcicda/ - MCI audio CD driver
160 winmm/mciseq/ - MCI MIDI driver
161 winmm/mciwave/ - MCI wave driver
162 winmm/midimap/ - MIDI mapper
163 winmm/wavemap/ - Audio mapper
164 winmm/winealsa/ - ALSA audio driver
165 winmm/winearts/ - aRts audio driver
166 winmm/wineaudioio/ - audioio audio driver
167 winmm/winejack/ - JACK audio server driver
168 winmm/winenas/ - NAS audio driver
169 winmm/wineoss/ - OSS audio driver
170 winnls/ - National Language Support
171 winsock/ - Sockets 2.0 (networking)
Dimitrie O. Paunab9cd6e2003-12-08 21:48:39 +0000172 winspool/ - Printing & Print Spooler
Tom Wicklinec5da9b22004-05-13 19:40:53 +0000173 wintab32/ - Tablet device interface
Dimitrie O. Paunab9cd6e2003-12-08 21:48:39 +0000174 wintrust/ - Trust verification interface
175 wow32/ - WOW subsystem
Tom Wicklinec5da9b22004-05-13 19:40:53 +0000176 wsock32/ - Sockets 1.1 (networking)
Tom Wicklinea812b612005-03-15 15:39:51 +0000177 wtsapi32/ - Terminal Services
Dimitrie O. Paunab9cd6e2003-12-08 21:48:39 +0000178 x11drv/ - X11 display driver (Wine specific)
Douglas Ridgway692389d1998-11-22 16:56:44 +0000179
Dimitrie O. Paunab9cd6e2003-12-08 21:48:39 +0000180Winelib programs (under programs/):
181-----------------------------------
Alexandre Julliard889f7421997-04-15 17:19:52 +0000182
Dimitrie O. Paunab9cd6e2003-12-08 21:48:39 +0000183 avitools/ - AVI information viewer and player
184 clock/ - Graphical clock
185 cmdlgtst/ - Common dialog tests
186 control/ - Control panel
187 expand/ - Decompress Lempel-Ziv compressed archive
Mike McCormack3565f5f2004-08-17 22:07:44 +0000188 msiexec/ - Microsoft Installer frontend
Steven Edwards26fe9142004-05-05 05:53:37 +0000189 notepad/ - Notepad replacement
Dimitrie O. Paunab9cd6e2003-12-08 21:48:39 +0000190 progman/ - Program manager
191 regedit/ - Registry editor
192 regsvr32/ - Register COM server
193 rpcss/ - RPC services
194 rundll32/ - Execute DLL functions directly
195 start/ - Replacement for start.exe
Steven Edwards26fe9142004-05-05 05:53:37 +0000196 taskmgr/ - Manage running Windows/Winelib applications
Dimitrie O. Paunab9cd6e2003-12-08 21:48:39 +0000197 uninstaller/ - Remove installed programs
198 view/ - Metafile viewer
199 wcmd/ - Command line interface
200 wineboot/ - Wine bootstrap process
201 winecfg/ - Wine configuration utility
202 wineconsole/ - Console
203 winedbg/ - Debugger
204 winefile/ - File manager
205 winemenubuilder/ - Helper program for building Unix menu entries
206 winemine/ - Mine game
207 winepath/ - Translate between Wine and Unix paths
208 winetest/ - Wine testing shell
209 winevdm/ - Wine virtual DOS machine
210 winhelp/ - Help viewer
211 winver/ - Windows Version Program
Alexandre Julliard889f7421997-04-15 17:19:52 +0000212
Alexandre Julliard889f7421997-04-15 17:19:52 +0000213
Alexandre Julliardc513a302002-09-18 23:11:19 +0000214Support programs, libraries, etc:
215---------------------------------
216
Robert Reifcc02d952004-03-09 23:25:57 +0000217 dlls/dxerr8/ - DirectX 8 error import lib
218 dlls/dxerr9/ - DirectX 9 error import lib
Dimitrie O. Paun6d4e3922004-01-27 20:07:43 +0000219 dlls/dxguid/ - DirectX UUID import lib
Tom Wicklined8f4a0a2004-11-22 18:28:18 +0000220 dlls/strmiids/ - Exports class (CLSIDs) and interface (IIDs) identifiers
Dimitrie O. Paun6d4e3922004-01-27 20:07:43 +0000221 dlls/uuid/ - Windows-compatible UUID import lib
Alexandre Julliardc513a302002-09-18 23:11:19 +0000222 documentation/ - some documentation
Dimitrie O. Paun6d4e3922004-01-27 20:07:43 +0000223 documentation/samples/ - sample configuration files
Alexandre Julliardc513a302002-09-18 23:11:19 +0000224 include/ - Windows standard includes
Dimitrie O. Paun6d4e3922004-01-27 20:07:43 +0000225 include/msvcrt/ - MSVC compatible libc headers
226 include/wine/ - Wine specific headers
Mike Hearn4ebc8062003-08-27 02:03:52 +0000227 libs/ - the Wine libraries
Dimitrie O. Paun7d2aefd2003-09-22 19:26:32 +0000228 libs/port/ - portability library
229 libs/unicode/ - Unicode support shared
Dimitrie O. Paun7d2aefd2003-09-22 19:26:32 +0000230 libs/wine/ - Wine bootstrap library
231 libs/wpp/ - C preprocessor
Alexandre Julliard357c7402003-11-06 01:17:56 +0000232 loader/ - the main Wine loader
Jeff Smith344ed412002-12-24 00:56:33 +0000233 server/ - the Wine server
Dimitrie O. Paun6be19972003-12-12 04:09:12 +0000234 tools/ - various tools used to build/check Wine
Dimitrie O. Paun6d4e3922004-01-27 20:07:43 +0000235 tools/widl/ - the IDL compiler
236 tools/winapi{,_check}/ - A Win32 API checker
237 tools/winebuild/ - Wine build tool
238 tools/winedump/ - a .DLL dump utility
239 tools/winegcc/ - a MinGW command line compatible gcc wrapper
240 tools/wmc/ - the message compiler
241 tools/wpp/ - the C pre-processor library
242 tools/wrc/ - the resource compiler
Alexandre Julliard889f7421997-04-15 17:19:52 +0000243
244
Klaas van Gend0a7aa161999-06-05 11:52:46 +0000245
Alexandre Julliardc7c217b1998-04-13 12:21:30 +0000246IMPLEMENTING NEW API CALLS
247==========================
248
Alexandre Julliardc513a302002-09-18 23:11:19 +0000249This is the simple version, and covers only Win32. Win16 is slightly
250uglier, because of the Pascal heritage and the segmented memory model.
Alexandre Julliardc7c217b1998-04-13 12:21:30 +0000251
Alexandre Julliardc513a302002-09-18 23:11:19 +0000252All of the Win32 APIs known to Wine are listed in the .spec file of
253their corresponding dll. An unimplemented call will look like (from
254gdi32.spec)
Alexandre Julliardc7c217b1998-04-13 12:21:30 +0000255 269 stub PolyBezierTo
256To implement this call, you need to do the following four things.
257
2581. Find the appropriate parameters for the call, and add a prototype to
Klaas van Gend0a7aa161999-06-05 11:52:46 +0000259the correct header file. In this case, that means [include/wingdi.h],
260and it might look like
Alexandre Julliard9f69d891999-02-26 12:33:21 +0000261 BOOL WINAPI PolyBezierTo(HDC, LPCVOID, DWORD);
262If the function has both an ASCII and a Unicode version, you need to
263define both and add a #define WINELIB_NAME_AW declaration. See below
264for discussion of function naming conventions.
Alexandre Julliardc7c217b1998-04-13 12:21:30 +0000265
2662. Modify the .spec file to tell Wine that the function has an
267implementation, what the parameters look like and what Wine function
268to use for the implementation. In Win32, things are simple--everything
269is 32-bits. However, the relay code handles pointers and pointers to
270strings slightly differently, so you should use 'str' and 'wstr' for
271strings, 'ptr' for other pointer types, and 'long' for everything else.
Alexandre Julliard9f69d891999-02-26 12:33:21 +0000272 269 stdcall PolyBezierTo(long ptr long) PolyBezierTo
273The 'PolyBezierTo' at the end of the line is which Wine function to use
Alexandre Julliardc7c217b1998-04-13 12:21:30 +0000274for the implementation.
275
2763. Implement the function as a stub. Once you add the function to the .spec
277file, you must add the function to the Wine source before it will link.
Alexandre Julliard9f69d891999-02-26 12:33:21 +0000278Add a function called 'PolyBezierTo' somewhere. Good things to put
Alexandre Julliardc7c217b1998-04-13 12:21:30 +0000279into a stub:
280 o a correct prototype, including the WINAPI
281 o header comments, including full documentation for the function and
Klaas van Gend0a7aa161999-06-05 11:52:46 +0000282 arguments (see documentation/README.documentation)
Alexandre Julliardc7c217b1998-04-13 12:21:30 +0000283 o A FIXME message and an appropriate return value are good things to
284 put in a stub.
285
286 /************************************************************
Klaas van Gend0a7aa161999-06-05 11:52:46 +0000287 * PolyBezierTo (GDI32.269)
288 *
Jon Griffithsf554f8f2003-07-18 22:54:14 +0000289 * Draw many Bezier curves.
Klaas van Gend0a7aa161999-06-05 11:52:46 +0000290 *
Dimitrie O. Paund0bc4c22004-02-13 04:00:52 +0000291 * PARAMS
292 * hdc [I] Device context to draw to
293 * p [I] Array of POINT structs
294 * count [I] Number of points in p
295 *
Klaas van Gend0a7aa161999-06-05 11:52:46 +0000296 * RETURNS
Jon Griffithsf554f8f2003-07-18 22:54:14 +0000297 * Success: Non-zero.
298 * Failure: FALSE. Use GetLastError() to find the error cause.
Alexandre Julliardc7c217b1998-04-13 12:21:30 +0000299 *
300 * BUGS
301 * Unimplemented
302 */
Dimitrie O. Paund0bc4c22004-02-13 04:00:52 +0000303 BOOL WINAPI PolyBezierTo(HDC hdc, LPCVOID p, DWORD count)
Klaas van Gend0a7aa161999-06-05 11:52:46 +0000304 {
Dimitrie O. Paund0bc4c22004-02-13 04:00:52 +0000305 /* tell the user they've got a substandard implementation */
Jon Griffithsb9aba912004-11-30 17:23:37 +0000306 FIXME("(%x,%p,%d): stub\n", hdc, p, count);
Klaas van Gend0a7aa161999-06-05 11:52:46 +0000307
Dimitrie O. Paund0bc4c22004-02-13 04:00:52 +0000308 /* some programs may be able to compensate,
309 * if they know what happened
310 */
311 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
312 return FALSE; /* error value */
Alexandre Julliardc7c217b1998-04-13 12:21:30 +0000313 }
314
Klaas van Gend0a7aa161999-06-05 11:52:46 +00003154. Implement and test the rest of the function.
316
Alexandre Julliard889f7421997-04-15 17:19:52 +0000317
Eric Pouech19dc2081999-10-31 22:15:58 +0000318IMPLEMENTING A NEW DLL
319======================
320
Eric Pouech31b41cf1999-12-05 02:16:24 +0000321Generic directions
322------------------
323
Eric Pouech19dc2081999-10-31 22:15:58 +0000324Apart from writing the set of needed .c files, you also need to do the
325following:
326
3271. Create a directory <MyDll> where to store the implementation of
Alexandre Julliardc513a302002-09-18 23:11:19 +0000328 the DLL. This directory has to be put under the dlls/ directory.
329 If the DLL exists under Windows as both 16 and 32 bit DLL, you
330 should have a single directory with both implementations.
Eric Pouech19dc2081999-10-31 22:15:58 +0000331
3322. Create the Makefile.in in the ./dlls/<MyDll>/ directory. You can
333 copy an existing Makefile.in from another ./dlls/ subdirectory.
Alexandre Julliardc513a302002-09-18 23:11:19 +0000334 You need at least to change the MODULE and C_SRCS macros.
Eric Pouech19dc2081999-10-31 22:15:58 +0000335
Alexandre Julliardc513a302002-09-18 23:11:19 +00003363. Add the directory in ./configure.ac (in AC_OUTPUT macro at the end
337 of the file to trigger the Makefile generation)
Eric Pouech19dc2081999-10-31 22:15:58 +0000338
Alexandre Julliardc513a302002-09-18 23:11:19 +00003394. Run ./make_dlls in the dlls directory to update Makefile.in in
340 that directory.
Eric Pouech19dc2081999-10-31 22:15:58 +0000341
Mike McCormack69653da2005-07-03 11:21:43 +00003425. You can now regenerate ./configure file (with 'autoconf')
Eric Pouech19dc2081999-10-31 22:15:58 +0000343 and the various Makefiles (with 'configure; make depend') (run
344 from the top of Wine's tree).
Alexandre Julliardc513a302002-09-18 23:11:19 +0000345 You should now have a Makefile file in ./dlls/<MyDll>/
Eric Pouech19dc2081999-10-31 22:15:58 +0000346
Alexandre Julliardc513a302002-09-18 23:11:19 +00003476. Create the .spec file for the DLL exported functions in your
Eric Pouech19dc2081999-10-31 22:15:58 +0000348 directory. Refer to 'Implementation of new API calls' earlier in
349 this document for more information on this part.
350
Alexandre Julliardc513a302002-09-18 23:11:19 +00003517. You can now start adding .c files. For the .h files, if they are
352 standard Windows one, put them in include/. If they are linked to
353 *your* implementation of the dll, put them in your newly created
354 directory.
Eric Pouech19dc2081999-10-31 22:15:58 +0000355
Eric Pouech31b41cf1999-12-05 02:16:24 +0000356Debug channels
357--------------
358
Eric Pouech19dc2081999-10-31 22:15:58 +0000359If you need to create a new debug channel, just add the
Dimitrie O. Paund95ce8c2002-09-18 18:29:59 +0000360WINE_DEFAULT_DEBUG_CHANNEL to your .c file(s), and use them.
361All the housekeeping will happen automatically.
Eric Pouech19dc2081999-10-31 22:15:58 +0000362
Eric Pouech31b41cf1999-12-05 02:16:24 +0000363Resources
364---------
365
Jeff Smith344ed412002-12-24 00:56:33 +0000366If you also need to add resources to your DLL, then create the .rc
Alexandre Julliardc513a302002-09-18 23:11:19 +0000367file. Add to your ./dlls/<MyDll>/Makefile.in, in the RC_SRCS macro,
368the list of .rc files to add to the DLL. See dlls/comctl32/ for an
369example of this.
Eric Pouech31b41cf1999-12-05 02:16:24 +0000370
371Thunking
372--------
373
374If you're building a 16 & 32 bit DLLs pair, then from the 32 bit code
375you might need to call 16 bit routine. The way to do it to add in the
376code, fragments like:
377/* ### Start build ### */
378extern WORD CALLBACK <PREFIX>_CallTo16_word_wwlll(FARPROC16,WORD,WORD,LONG,LONG,LONG);
379/* ### stop build ### */
380Where <PREFIX>_ is an internal prefix for your module. The first
381parameter is always of type FARPROC16. Then, you can get the regular
382list of parameters. The _word_wwlll indicates the type of return (long
383or word) and the size of the parameters (here l=>long, w=>word; which
384maps to WORD,WORD,LONG,LONG,LONG.
385You can put several functions between the Start/Stop build pair.
386
Alexandre Julliardc513a302002-09-18 23:11:19 +0000387You can also read the winebuild manpage for more details on this.
Eric Pouech31b41cf1999-12-05 02:16:24 +0000388
Alexandre Julliardc513a302002-09-18 23:11:19 +0000389Then, add to ./dlls/<MyDll>/Makefile.in a line like:
390
391EXTRA_OBJS = $(MODULE).glue.o
Eric Pouech31b41cf1999-12-05 02:16:24 +0000392
393See dlls/winmm/ for an example of this.
394
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000395MEMORY AND SEGMENTS
396===================
Alexandre Julliarddba420a1994-02-02 06:48:31 +0000397
398NE (Win16) executables consist of multiple segments. The Wine loader
Alexandre Julliarde2abbb11995-03-19 17:39:39 +0000399loads each segment into a unique location in the Wine processes memory
400and assigns a selector to that segment. Because of this, it's not
401possible to exchange addresses freely between 16-bit and 32-bit code.
402Addresses used by 16-bit code are segmented addresses (16:16), formed
403by a 16-bit selector and a 16-bit offset. Those used by the Wine code
404are regular 32-bit linear addresses.
Alexandre Julliarddba420a1994-02-02 06:48:31 +0000405
Alexandre Julliard1e37a181996-08-18 16:21:52 +0000406There are four ways to obtain a segmented pointer:
Alexandre Julliardc513a302002-09-18 23:11:19 +0000407 - Using the MapLS function (recommended).
Alexandre Julliarde2abbb11995-03-19 17:39:39 +0000408 - Allocate a block of memory from the global heap and use
409 WIN16_GlobalLock to get its segmented address.
Alexandre Julliarde2abbb11995-03-19 17:39:39 +0000410 - Declare the argument as 'segptr' instead of 'ptr' in the spec file
411 for a given API function.
Alexandre Julliarddba420a1994-02-02 06:48:31 +0000412
Alexandre Julliarde2abbb11995-03-19 17:39:39 +0000413Once you have a segmented pointer, it must be converted to a linear
414pointer before you can use it from 32-bit code. This can be done with
Alexandre Julliardc513a302002-09-18 23:11:19 +0000415the MapSL function. The linear pointer can then be used freely with
416standard Unix functions like memcpy() etc. without worrying about 64k
417boundaries. Note: there's no easy way to convert back from a linear
418to a segmented address.
Alexandre Julliarddba420a1994-02-02 06:48:31 +0000419
Alexandre Julliarde2abbb11995-03-19 17:39:39 +0000420In most cases, you don't need to worry about segmented address, as the
421conversion is made automatically by the callback code and the API
422functions only see linear addresses. However, in some cases it is
423necessary to manipulate segmented addresses; the most frequent cases
424are:
425 - API functions that return a pointer
426 - lParam of Windows messages that point to a structure
427 - Pointers contained inside structures accessed by 16-bit code.
Alexandre Julliarddba420a1994-02-02 06:48:31 +0000428
Alexandre Julliarde2abbb11995-03-19 17:39:39 +0000429It is usually a good practice to used the type 'SEGPTR' for segmented
430pointers, instead of something like 'LPSTR' or 'char *'. As SEGPTR is
431defined as a DWORD, you'll get a compilation warning if you mistakenly
432use it as a regular 32-bit pointer.
Alexandre Julliarddba420a1994-02-02 06:48:31 +0000433
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000434
Alexandre Julliard2d93d001996-05-21 15:01:41 +0000435STRUCTURE PACKING
436=================
437
438Under Windows, data structures are tightly packed, i.e. there is no
439padding between structure members. On the other hand, by default gcc
440aligns structure members (e.g. WORDs are on a WORD boundary, etc.).
441This means that a structure like
442
443struct { BYTE x; WORD y; };
444
445will take 3 bytes under Windows, but 4 with gcc, because gcc will add a
446dummy byte between x and y. To have the correct layout for structures
Klaas van Gend0a7aa161999-06-05 11:52:46 +0000447used by Windows code, you need to embed the struct within two special
448#include's which will take care of the packing for you:
449
450#include "pshpack1.h"
Eric Pouech19dc2081999-10-31 22:15:58 +0000451struct { BYTE x; WORD y; };
Klaas van Gend0a7aa161999-06-05 11:52:46 +0000452#include "poppack1.h"
453
454For alignment on a 2-byte boundary, there is a "pshpack2.h", etc.
455
Alexandre Julliard2d93d001996-05-21 15:01:41 +0000456
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000457NAMING CONVENTIONS FOR API FUNCTIONS AND TYPES
458==============================================
459
460In order to support both Win16 and Win32 APIs within the same source
Douglas Ridgway692389d1998-11-22 16:56:44 +0000461code, the following convention must be used in naming all API
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000462functions and types. If the Windows API uses the name 'xxx', the Wine
463code must use:
464
Alexandre Julliard9f69d891999-02-26 12:33:21 +0000465 - 'xxx16' for the Win16 version,
Dimitrie O. Paund0bc4c22004-02-13 04:00:52 +0000466 - 'xxx' for the Win32 version when no strings are involved,
Alexandre Julliard9f69d891999-02-26 12:33:21 +0000467 - 'xxxA' for the Win32 version with ASCII strings,
468 - 'xxxW' for the Win32 version with Unicode strings.
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000469
Alexandre Julliard9f69d891999-02-26 12:33:21 +0000470If the function has both ASCII and Unicode version, you should then
471use the macros WINELIB_NAME_AW(xxx) or DECL_WINELIB_TYPE_AW(xxx)
Jim Aston07684241999-07-18 13:28:59 +0000472(defined in include/windef.h) to define the correct 'xxx' function
Alexandre Julliard9f69d891999-02-26 12:33:21 +0000473or type for Winelib. When compiling Wine itself, 'xxx' is _not_
474defined, meaning that code inside of Wine must always specify
475explicitly the ASCII or Unicode version.
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000476
Alexandre Julliard9f69d891999-02-26 12:33:21 +0000477If 'xxx' is the same in Win16 and Win32, you can simply use the same
478name as Windows, i.e. just 'xxx'. If 'xxx' is Win16 only, you could
479use the name as is, but it's preferable to use 'xxx16' to make it
480clear it is a Win16 function.
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000481
482Examples:
483
Alexandre Julliard9f69d891999-02-26 12:33:21 +0000484typedef struct { /* Win32 ASCII data structure */ } WNDCLASSA;
485typedef struct { /* Win32 Unicode data structure */ } WNDCLASSW;
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000486typedef struct { /* Win16 data structure */ } WNDCLASS16;
487DECL_WINELIB_TYPE_AW(WNDCLASS);
488
489ATOM RegisterClass16( WNDCLASS16 * );
Alexandre Julliard9f69d891999-02-26 12:33:21 +0000490ATOM RegisterClassA( WNDCLASSA * );
491ATOM RegisterClassW( WNDCLASSW * );
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000492#define RegisterClass WINELIB_NAME_AW(RegisterClass)
493
494The Winelib user can then say:
495
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000496 WNDCLASS wc = { ... };
497 RegisterClass( &wc );
498
499and this will use the correct declaration depending on the definition
Alexandre Julliard9f69d891999-02-26 12:33:21 +0000500of the UNICODE symbol.
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000501
502
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000503DEBUG MESSAGES
504==============
Alexandre Julliardaca05781994-10-17 18:12:41 +0000505
506To display a message only during debugging, you normally write something
507like this:
508
Dimitrie O. Paund95ce8c2002-09-18 18:29:59 +0000509 TRACE("abc..."); or
510 FIXME("abc..."); or
511 WARN("abc..."); or
512 ERR("abc...");
Alexandre Julliardaca05781994-10-17 18:12:41 +0000513
Dimitrie O. Paun7d2aefd2003-09-22 19:26:32 +0000514depending on the seriousness of the problem. (documentation/debugging.sgml
Dimitrie O. Paund95ce8c2002-09-18 18:29:59 +0000515explains when it is appropriate to use each of them). You need to declare
516the debug channel name at the top of the file (after the includes) using
517the WINE_DEFAULT_DEBUG_CHANNEL macro, like so:
Alexandre Julliardaca05781994-10-17 18:12:41 +0000518
Dimitrie O. Paund95ce8c2002-09-18 18:29:59 +0000519 WINE_DEFAULT_DEBUG_CHANNEL(win);
Alexandre Julliardaca05781994-10-17 18:12:41 +0000520
Dimitrie O. Paund95ce8c2002-09-18 18:29:59 +0000521If your debugging code is more complex than just printf, you can use
522the macros:
523
524 TRACE_ON(xxx), WARN_ON(xxx), ERR_ON(xxx) and FIXME_ON(xxx)
525
526to test if the given channel is enabled. Thus, you can write:
527
528 if (TRACE_ON(win)) DumpSomeStructure(&str);
Alexandre Julliard234bc241994-12-10 13:02:28 +0000529
Alexandre Julliard234bc241994-12-10 13:02:28 +0000530Don't worry about the inefficiency of the test. If it is permanently
Alexandre Julliard54c27111998-03-29 19:44:57 +0000531disabled (that is TRACE_ON(win) is 0 at compile time), the compiler will
Alexandre Julliard234bc241994-12-10 13:02:28 +0000532eliminate the dead code.
Alexandre Julliardaca05781994-10-17 18:12:41 +0000533
Alexandre Julliard54c27111998-03-29 19:44:57 +0000534For more info about debugging messages, read:
535
Dimitrie O. Paun7d2aefd2003-09-22 19:26:32 +0000536http://www.winehq.org/site/docs/wine-devel/debugging
Alexandre Julliard54c27111998-03-29 19:44:57 +0000537
Alexandre Julliard23946ad1997-06-16 17:43:53 +0000538
539MORE INFO
540=========
541
Alexandre Julliard33072e11997-06-29 18:08:02 +00005421. There is a FREE online version of the MSDN library (including
Jeff Smith344ed412002-12-24 00:56:33 +0000543 documentation for the Win32 API) on http://msdn.microsoft.com/
Mike Hearn4ebc8062003-08-27 02:03:52 +0000544 or http://www.msdn.com/
Alexandre Julliard23946ad1997-06-16 17:43:53 +0000545
Tom Wickline7be37f42003-06-30 02:05:07 +00005462. Windows apilist: http://www.mentalis.org/apilist/apilist.php
Alexandre Julliard23946ad1997-06-16 17:43:53 +0000547
Tom Wickline7be37f42003-06-30 02:05:07 +00005483. http://www.sonic.net/~undoc/bookstore.html
Alexandre Julliard33072e11997-06-29 18:08:02 +0000549
Tom Wickline7be37f42003-06-30 02:05:07 +00005504. In 1993 Dr. Dobbs Journal published a column called "Undocumented Corner".
Dimitrie O. Paun64ed0842003-10-09 19:47:23 +0000551
5525. www.geocities.com/SiliconValley/4942/