blob: 1dd695e30bbd38e4496dd67c1c7cdddfc1c7c0fd [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
11code specific to the binary loader.
Alexandre Julliard889f7421997-04-15 17:19:52 +000012
Douglas Ridgway692389d1998-11-22 16:56:44 +000013Wine API directories:
14---------------------
Alexandre Julliard889f7421997-04-15 17:19:52 +000015
16KERNEL:
17
18 files/ - file I/O
19 loader/ - Win16-, Win32-binary loader
20 memory/ - memory management
Douglas Ridgway692389d1998-11-22 16:56:44 +000021 msdos/ - DOS features and BIOS calls (interrupts)
Alexandre Julliard889f7421997-04-15 17:19:52 +000022 scheduler/ - process and thread management
23
24GDI:
25
26 graphics/ - graphics drivers
Klaas van Gend0a7aa161999-06-05 11:52:46 +000027 x11drv/ - X11 display driver
28 win16drv/ -> see below
29 ttydrv/ - tty display driver
30 psdrv/ - PostScript graphics driver
Eric Pouech19dc2081999-10-31 22:15:58 +000031 metafiledrv/ - metafile driver
Klaas van Gend0a7aa161999-06-05 11:52:46 +000032 enhmetafiledrv/ - enhanced metafile driver
Alexandre Julliard889f7421997-04-15 17:19:52 +000033 objects/ - logical objects
34
35USER:
36
37 controls/ - built-in widgets
Klaas van Gend0a7aa161999-06-05 11:52:46 +000038 resources/ - built-in menu and message box resources
Alexandre Julliard889f7421997-04-15 17:19:52 +000039 windows/ - window management
40
Douglas Ridgway692389d1998-11-22 16:56:44 +000041Other DLLs:
42
Klaas van Gend0a7aa161999-06-05 11:52:46 +000043 dlls/ - Other system DLLs implemented by Wine
44 advapi32/ - crypto, systeminfo, security, eventlogging
45 avifil32/ - COM object to play AVI files
46 comctl32/ - common controls
47 commdlg/ - common dialog boxes (both 16 & 32 bit)
Jon Griffiths1db20bf2001-01-10 23:59:25 +000048 crtdll/ - Old C runtime library
Eric Pouech19dc2081999-10-31 22:15:58 +000049 dplayx/ - DirectX dplayx
50 dsound/ - DirectX dsound
Klaas van Gend0a7aa161999-06-05 11:52:46 +000051 imagehlp/ - PE (Portable Executable) Image Helper lib
Eric Pouech19dc2081999-10-31 22:15:58 +000052 imm32/
53 lzexpand/ - Liv-Zempel compression/decompression
54 mpr/ - Multi-Protocol Router (interface to various
55 network transport protocols)
56 msacm/ - audio compression manager (multimedia) (16 bit)
57 msacm32/ - audio compression manager (multimedia) (32 bit)
58 msnet/
Jon Griffiths1db20bf2001-01-10 23:59:25 +000059 msvcrt/ - C runtime library
Eric Pouech19dc2081999-10-31 22:15:58 +000060 msvideo/ - 16 bit video manager
Andreas Mohr7bed6962001-09-19 22:34:38 +000061 ole32/ - 32 bit OLE 2.0 libraries
Eric Pouech19dc2081999-10-31 22:15:58 +000062 oleaut32/ - 32 bit OLE 2.0 automation
63 olecli/ - 16 bit OLE client
64 oledlg/ - OLE 2.0 user interface support
65 olesvr/ - 16 bit OLE server
Klaas van Gend0a7aa161999-06-05 11:52:46 +000066 ntdll/ - NT implementation of kernel calls
67 psapi/ - process status API
68 rasapi32/ - remote access server API
69 shell32/ - COM object implementing shell views
Eric Pouech19dc2081999-10-31 22:15:58 +000070 sound/ - Sound on loudspeaker (not sound card)
Klaas van Gend0a7aa161999-06-05 11:52:46 +000071 tapi32/ - telephone API
72 ver/ - File Installation Library (16 bit)
73 version/ - File Installation Library (32 bit)
Eric Pouech19dc2081999-10-31 22:15:58 +000074 win32s
75 win87em - 80387 math-emulation
76 winaspi/ - 16 bit Advanced SCSI Peripheral Interface
77 windebug/ - Windows debugger
78 wing/ - WinG (for games) internface
79 winmm/ - multimedia (16 & 32 bit)
80 mciXXX/ - various MCI drivers
Chris Morgan9b0ba7c2002-03-21 01:38:19 +000081 winearts/ - ARTS audio driver
Eric Pouech19dc2081999-10-31 22:15:58 +000082 wineoss/- MM driver for OSS systems
83 wavemap/- audio mapper
84 midimap/- midi mapper
Klaas van Gend0a7aa161999-06-05 11:52:46 +000085 winspool/ - Printing & Print Spooler
Eric Pouech19dc2081999-10-31 22:15:58 +000086 wnaspi32/ - 32 bit ASPI
Douglas Ridgway692389d1998-11-22 16:56:44 +000087
Alexandre Julliard889f7421997-04-15 17:19:52 +000088Miscellaneous:
89
Douglas Ridgway692389d1998-11-22 16:56:44 +000090 misc/ - shell, registry, winsock, etc.
Douglas Ridgway692389d1998-11-22 16:56:44 +000091 ipc/ - SysV IPC based interprocess communication
Alexandre Julliard889f7421997-04-15 17:19:52 +000092 win32/ - misc Win32 functions
Klaas van Gend0a7aa161999-06-05 11:52:46 +000093 ole/ - OLE code
94 nls/ - National Language Support
95 configuration files
Alexandre Julliard889f7421997-04-15 17:19:52 +000096
97Tools:
Douglas Ridgway692389d1998-11-22 16:56:44 +000098------
Alexandre Julliard889f7421997-04-15 17:19:52 +000099
Douglas Ridgway692389d1998-11-22 16:56:44 +0000100 rc/ - old resource compiler
Klaas van Gend0a7aa161999-06-05 11:52:46 +0000101 tools/ - relay code builder, new rc, bugreport
102 generator, wineconfigurator, etc.
Alexandre Julliard889f7421997-04-15 17:19:52 +0000103 documentation/ - some documentation
104
105
Douglas Ridgway692389d1998-11-22 16:56:44 +0000106Binary loader specific directories:
107-----------------------------------
Alexandre Julliard889f7421997-04-15 17:19:52 +0000108
109 debugger/ - built-in debugger
110 if1632/ - relay code
111 miscemu/ - hardware instruction emulation
112 graphics/win16drv/ - Win16 printer driver
Klaas van Gend0a7aa161999-06-05 11:52:46 +0000113 server/ - the main, controlling thread of wine
114 tsx11/ - thread-safe X11 wrappers (auto generated)
Alexandre Julliard889f7421997-04-15 17:19:52 +0000115
Douglas Ridgway692389d1998-11-22 16:56:44 +0000116Winelib specific directories:
Alexandre Julliard889f7421997-04-15 17:19:52 +0000117-----------------------------
118
Douglas Ridgway692389d1998-11-22 16:56:44 +0000119 library/ - Required code for programs using Winelib
120 libtest/ - Small samples and tests
121 programs/ - Extended samples / system utilities
Alexandre Julliard889f7421997-04-15 17:19:52 +0000122
Klaas van Gend0a7aa161999-06-05 11:52:46 +0000123
Alexandre Julliardc7c217b1998-04-13 12:21:30 +0000124IMPLEMENTING NEW API CALLS
125==========================
126
127This is the simple version, and covers only Win32. Win16 is slightly uglier,
128because of the Pascal heritage and the segmented memory model.
129
130All of the Win32 APIs known to Wine are listed in [relay32/*.spec]. An
131unimplemented call will look like (from gdi32.spec)
132 269 stub PolyBezierTo
133To implement this call, you need to do the following four things.
134
1351. Find the appropriate parameters for the call, and add a prototype to
Klaas van Gend0a7aa161999-06-05 11:52:46 +0000136the correct header file. In this case, that means [include/wingdi.h],
137and it might look like
Alexandre Julliard9f69d891999-02-26 12:33:21 +0000138 BOOL WINAPI PolyBezierTo(HDC, LPCVOID, DWORD);
139If the function has both an ASCII and a Unicode version, you need to
140define both and add a #define WINELIB_NAME_AW declaration. See below
141for discussion of function naming conventions.
Alexandre Julliardc7c217b1998-04-13 12:21:30 +0000142
1432. Modify the .spec file to tell Wine that the function has an
144implementation, what the parameters look like and what Wine function
145to use for the implementation. In Win32, things are simple--everything
146is 32-bits. However, the relay code handles pointers and pointers to
147strings slightly differently, so you should use 'str' and 'wstr' for
148strings, 'ptr' for other pointer types, and 'long' for everything else.
Alexandre Julliard9f69d891999-02-26 12:33:21 +0000149 269 stdcall PolyBezierTo(long ptr long) PolyBezierTo
150The 'PolyBezierTo' at the end of the line is which Wine function to use
Alexandre Julliardc7c217b1998-04-13 12:21:30 +0000151for the implementation.
152
1533. Implement the function as a stub. Once you add the function to the .spec
154file, you must add the function to the Wine source before it will link.
Alexandre Julliard9f69d891999-02-26 12:33:21 +0000155Add a function called 'PolyBezierTo' somewhere. Good things to put
Alexandre Julliardc7c217b1998-04-13 12:21:30 +0000156into a stub:
157 o a correct prototype, including the WINAPI
158 o header comments, including full documentation for the function and
Klaas van Gend0a7aa161999-06-05 11:52:46 +0000159 arguments (see documentation/README.documentation)
Alexandre Julliardc7c217b1998-04-13 12:21:30 +0000160 o A FIXME message and an appropriate return value are good things to
161 put in a stub.
162
163 /************************************************************
Klaas van Gend0a7aa161999-06-05 11:52:46 +0000164 * PolyBezierTo (GDI32.269)
165 *
166 * Draw many Bezier curves
167 *
168 * RETURNS
169 * nonzero on success or zero on faillure
Alexandre Julliardc7c217b1998-04-13 12:21:30 +0000170 *
171 * BUGS
172 * Unimplemented
173 */
Klaas van Gend0a7aa161999-06-05 11:52:46 +0000174 BOOL WINAPI PolyBezierTo(HDC hdc, /* handle to device context */
175 LPCVOID p, /* ptr to array of Point structs */
176 DWORD count /* nr of points in array */
177 )
178 {
179 /* tell the user they've got a substandard implementation */
Alexandre Julliardc7c217b1998-04-13 12:21:30 +0000180 FIXME(gdi, ":(%x,%p,%d): stub\n", hdc, p, count);
Klaas van Gend0a7aa161999-06-05 11:52:46 +0000181
182 /* some programs may be able to compensate,
183 * if they know what happened
184 */
Alexandre Julliardc7c217b1998-04-13 12:21:30 +0000185 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
186 return FALSE; /* error value */
187 }
188
Klaas van Gend0a7aa161999-06-05 11:52:46 +00001894. Implement and test the rest of the function.
190
Alexandre Julliard889f7421997-04-15 17:19:52 +0000191
Eric Pouech19dc2081999-10-31 22:15:58 +0000192IMPLEMENTING A NEW DLL
193======================
194
Eric Pouech31b41cf1999-12-05 02:16:24 +0000195Generic directions
196------------------
197
Eric Pouech19dc2081999-10-31 22:15:58 +0000198Apart from writing the set of needed .c files, you also need to do the
199following:
200
2011. Create a directory <MyDll> where to store the implementation of
202 the DLL.
203
204 If the DLL exists under Windows as both 16 and 32 bit DLL, you can
205 either create one directory for each, or have a single directory
206 with both implementations.
207
208 This (those) directory(ies) have to be put under the dlls/
209 directory in Wine tree structure.
210
2112. Create the Makefile.in in the ./dlls/<MyDll>/ directory. You can
212 copy an existing Makefile.in from another ./dlls/ subdirectory.
213
214 You need at least to change the MODULE, SPEC_SRCS, and C_SRCS
215 macros.
216
2173. Add the directory (and the generated .o file for the module) in:
218 + ./configure.in (in AC_OUTPUT macro at the end of the file to
219 trigger the Makefile generation),
220 + ./Makefile.in (in LIBSUBDIRS and LIBOBJS macros)
Eric Pouech31b41cf1999-12-05 02:16:24 +0000221 + ./dlls/Makefile.in (in SUBDIRS macro)
Eric Pouech19dc2081999-10-31 22:15:58 +0000222
2234. You can now regenerate ./configure file (with 'make configure')
224 and the various Makefiles (with 'configure; make depend') (run
225 from the top of Wine's tree).
226
227 You shall now have a Makefile file in ./dlls/<MyDll>/
228
2295. You now need to declare the DLL in the module lists. This is done
230 by adding the corresponding descriptor in ./if1632/builtin.c if
231 your DLL is 16 bit (resp. ./relay32/builtin.c for a 32 bit DLL)
232 (or both if your directory contains the dual 16/32
233 implementations).
234
235 Note: the name of the descriptor is based on the module name, not
236 on the file name (they are the same in most of the case, but for
237 some DLLs it's not the case).
238
2396. You also need to define the loadorder for the created DLL
Eric Pouech31b41cf1999-12-05 02:16:24 +0000240 (./wine.ini and ./loader/loadorder.c). Usually, "native,builtin"
Eric Pouech19dc2081999-10-31 22:15:58 +0000241 is ok. If you have written a paired 16/32 bit implementation, don't
242 forget to define it also in those files.
243
2447. Create the .spec file for the DLL export points in your
245 directory. Refer to 'Implementation of new API calls' earlier in
246 this document for more information on this part.
247
Eric Pouech31b41cf1999-12-05 02:16:24 +00002488. Don't forget the .cvsignore file. The .cvsignore contain (on a per
249 directory basis) all the files generated by the compilation
250 process, why cvs shall ignore when processing the dir.
251 *.o is in there by default, but in Wine case you will find:
252 - Makefile (generated from Makefile.in)
253 - *.spec.c: those c files are generated by tools/build from the
254 .spec file
255 - when thunking down to 16 bit DLLs, you'll get some others (.glue.c)
256 - result of .y => .c translation (by yacc or bison)
257 - result of .rc compilation
258 - ...
259 For a simple DLL, listing in .cvsignore Makefile and
260 <MyDll>.spec.c will do.
Eric Pouech19dc2081999-10-31 22:15:58 +0000261
2629. You can now start adding .c files.
263
26410. For the .h files, if they are standard Windows one, put them in
265 include/. If they are linked to *your* implementation of the DLL,
266 put them in your newly created directory.
267
Eric Pouech31b41cf1999-12-05 02:16:24 +0000268Debug channels
269--------------
270
Eric Pouech19dc2081999-10-31 22:15:58 +0000271If you need to create a new debug channel, just add the
272DECLARE_DEBUG_CHANNEL to your .c file(s) and rerun
273tools/make_debug. When sending out your patch, you don't need to
Andreas Mohr7bed6962001-09-19 22:34:38 +0000274provide neither ./configure nor the ./include/debugdefs.h diffs. Just
Eric Pouech19dc2081999-10-31 22:15:58 +0000275indicate that those files need to be regenerated.
276
Eric Pouech31b41cf1999-12-05 02:16:24 +0000277Resources
278---------
279
280If you also need to add resources to your DLL, the create the .rc
281file. Since, the .rc file will be translated into a .s file, and then
282compiled as a .o file, its basename must be different from the
283basename of any .c file.
284Add to your ./dlls/<MyDll>/Makefile.in, in the RC_SRCS macro, the list
285of .rc files to add to the DLL. You may also have to add the following
286directives
2871/ to tell gnumake to translate .rc into .s files,
288 $(RC_SRCS:.rc=.s): $(WRC)
2892/ to give some parameters to wrc for helping the translation.
290 WRCEXTRA = -s -p$(MODULE)
291
292See dlls/comctl32/ for an example of this.
293
294Thunking
295--------
296
297If you're building a 16 & 32 bit DLLs pair, then from the 32 bit code
298you might need to call 16 bit routine. The way to do it to add in the
299code, fragments like:
300/* ### Start build ### */
301extern WORD CALLBACK <PREFIX>_CallTo16_word_wwlll(FARPROC16,WORD,WORD,LONG,LONG,LONG);
302/* ### stop build ### */
303Where <PREFIX>_ is an internal prefix for your module. The first
304parameter is always of type FARPROC16. Then, you can get the regular
305list of parameters. The _word_wwlll indicates the type of return (long
306or word) and the size of the parameters (here l=>long, w=>word; which
307maps to WORD,WORD,LONG,LONG,LONG.
308You can put several functions between the Start/Stop build pair.
309
310You can also read tools/build.txt for more details on this.
311
312Then, add to ./dlls/<MyDll>/Makefile.in to the macro GLUE the list of
313.c files containing the /* ### Start build ### */ directives.
314
315See dlls/winmm/ for an example of this.
316
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000317MEMORY AND SEGMENTS
318===================
Alexandre Julliarddba420a1994-02-02 06:48:31 +0000319
320NE (Win16) executables consist of multiple segments. The Wine loader
Alexandre Julliarde2abbb11995-03-19 17:39:39 +0000321loads each segment into a unique location in the Wine processes memory
322and assigns a selector to that segment. Because of this, it's not
323possible to exchange addresses freely between 16-bit and 32-bit code.
324Addresses used by 16-bit code are segmented addresses (16:16), formed
325by a 16-bit selector and a 16-bit offset. Those used by the Wine code
326are regular 32-bit linear addresses.
Alexandre Julliarddba420a1994-02-02 06:48:31 +0000327
Alexandre Julliard1e37a181996-08-18 16:21:52 +0000328There are four ways to obtain a segmented pointer:
329 - Use the SEGPTR_* macros in include/heap.h (recommended).
Alexandre Julliarde2abbb11995-03-19 17:39:39 +0000330 - Allocate a block of memory from the global heap and use
331 WIN16_GlobalLock to get its segmented address.
332 - Allocate a block of memory from a local heap, and build the
333 segmented address from the local heap selector (see the
334 USER_HEAP_* macros for an example of this).
335 - Declare the argument as 'segptr' instead of 'ptr' in the spec file
336 for a given API function.
Alexandre Julliarddba420a1994-02-02 06:48:31 +0000337
Alexandre Julliarde2abbb11995-03-19 17:39:39 +0000338Once you have a segmented pointer, it must be converted to a linear
339pointer before you can use it from 32-bit code. This can be done with
340the PTR_SEG_TO_LIN() and PTR_SEG_OFF_TO_LIN() macros. The linear
341pointer can then be used freely with standard Unix functions like
342memcpy() etc. without worrying about 64k boundaries. Note: there's no
343easy way to convert back from a linear to a segmented address.
Alexandre Julliarddba420a1994-02-02 06:48:31 +0000344
Alexandre Julliarde2abbb11995-03-19 17:39:39 +0000345In most cases, you don't need to worry about segmented address, as the
346conversion is made automatically by the callback code and the API
347functions only see linear addresses. However, in some cases it is
348necessary to manipulate segmented addresses; the most frequent cases
349are:
350 - API functions that return a pointer
351 - lParam of Windows messages that point to a structure
352 - Pointers contained inside structures accessed by 16-bit code.
Alexandre Julliarddba420a1994-02-02 06:48:31 +0000353
Alexandre Julliarde2abbb11995-03-19 17:39:39 +0000354It is usually a good practice to used the type 'SEGPTR' for segmented
355pointers, instead of something like 'LPSTR' or 'char *'. As SEGPTR is
356defined as a DWORD, you'll get a compilation warning if you mistakenly
357use it as a regular 32-bit pointer.
Alexandre Julliarddba420a1994-02-02 06:48:31 +0000358
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000359
Alexandre Julliard2d93d001996-05-21 15:01:41 +0000360STRUCTURE PACKING
361=================
362
363Under Windows, data structures are tightly packed, i.e. there is no
364padding between structure members. On the other hand, by default gcc
365aligns structure members (e.g. WORDs are on a WORD boundary, etc.).
366This means that a structure like
367
368struct { BYTE x; WORD y; };
369
370will take 3 bytes under Windows, but 4 with gcc, because gcc will add a
371dummy byte between x and y. To have the correct layout for structures
Klaas van Gend0a7aa161999-06-05 11:52:46 +0000372used by Windows code, you need to embed the struct within two special
373#include's which will take care of the packing for you:
374
375#include "pshpack1.h"
Eric Pouech19dc2081999-10-31 22:15:58 +0000376struct { BYTE x; WORD y; };
Klaas van Gend0a7aa161999-06-05 11:52:46 +0000377#include "poppack1.h"
378
379For alignment on a 2-byte boundary, there is a "pshpack2.h", etc.
380
381The use of the WINE_PACKED attribute is obsolete. Please remove these
382in favour of the above solution.
383Using WINE_PACKED, you would declare the above structure like this:
Alexandre Julliard2d93d001996-05-21 15:01:41 +0000384
385struct { BYTE x; WORD y WINE_PACKED; };
386
Klaas van Gend0a7aa161999-06-05 11:52:46 +0000387You had to do this every time a structure member is not aligned
Alexandre Julliard2d93d001996-05-21 15:01:41 +0000388correctly under Windows (i.e. a WORD not on an even address, or a
Klaas van Gend0a7aa161999-06-05 11:52:46 +0000389DWORD on a address that was not a multiple of 4).
Alexandre Julliard2d93d001996-05-21 15:01:41 +0000390
391
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000392NAMING CONVENTIONS FOR API FUNCTIONS AND TYPES
393==============================================
394
395In order to support both Win16 and Win32 APIs within the same source
Douglas Ridgway692389d1998-11-22 16:56:44 +0000396code, the following convention must be used in naming all API
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000397functions and types. If the Windows API uses the name 'xxx', the Wine
398code must use:
399
Alexandre Julliard9f69d891999-02-26 12:33:21 +0000400 - 'xxx16' for the Win16 version,
401 - 'xxx' for the Win32 version when no ASCII/Unicode strings are
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000402 involved,
Alexandre Julliard9f69d891999-02-26 12:33:21 +0000403 - 'xxxA' for the Win32 version with ASCII strings,
404 - 'xxxW' for the Win32 version with Unicode strings.
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000405
Alexandre Julliard9f69d891999-02-26 12:33:21 +0000406If the function has both ASCII and Unicode version, you should then
407use the macros WINELIB_NAME_AW(xxx) or DECL_WINELIB_TYPE_AW(xxx)
Jim Aston07684241999-07-18 13:28:59 +0000408(defined in include/windef.h) to define the correct 'xxx' function
Alexandre Julliard9f69d891999-02-26 12:33:21 +0000409or type for Winelib. When compiling Wine itself, 'xxx' is _not_
410defined, meaning that code inside of Wine must always specify
411explicitly the ASCII or Unicode version.
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000412
Alexandre Julliard9f69d891999-02-26 12:33:21 +0000413If 'xxx' is the same in Win16 and Win32, you can simply use the same
414name as Windows, i.e. just 'xxx'. If 'xxx' is Win16 only, you could
415use the name as is, but it's preferable to use 'xxx16' to make it
416clear it is a Win16 function.
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000417
418Examples:
419
Alexandre Julliard9f69d891999-02-26 12:33:21 +0000420typedef struct { /* Win32 ASCII data structure */ } WNDCLASSA;
421typedef struct { /* Win32 Unicode data structure */ } WNDCLASSW;
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000422typedef struct { /* Win16 data structure */ } WNDCLASS16;
423DECL_WINELIB_TYPE_AW(WNDCLASS);
424
425ATOM RegisterClass16( WNDCLASS16 * );
Alexandre Julliard9f69d891999-02-26 12:33:21 +0000426ATOM RegisterClassA( WNDCLASSA * );
427ATOM RegisterClassW( WNDCLASSW * );
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000428#define RegisterClass WINELIB_NAME_AW(RegisterClass)
429
430The Winelib user can then say:
431
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000432 WNDCLASS wc = { ... };
433 RegisterClass( &wc );
434
435and this will use the correct declaration depending on the definition
Alexandre Julliard9f69d891999-02-26 12:33:21 +0000436of the UNICODE symbol.
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000437
438
Klaas van Gend0a7aa161999-06-05 11:52:46 +0000439NAMING CONVENTIONS FOR NON-API FUNCTIONS AND TYPES
440==================================================
441
442Functions and data which are internal to your code (or at least shouldn't be
Francois Gougete550ebe2000-12-02 20:17:13 +0000443visible to any Winelib or Windows program) should be preceded by
Klaas van Gend0a7aa161999-06-05 11:52:46 +0000444an identifier to the module:
445
446Examples:
447
448ENUMPRINTERS_GetDWORDFromRegistryA() (in dlls/winspool/info.c)
449IAVIFile_fnRelease() (in dlls/avifil32/avifile.c)
450X11DRV_CreateDC() (in graphics/x11drv/init.c)
451TIMER_Init() (implemented in windows/timer.c,
452 used in loader/main.c )
453
454if you need prototypes for these, there are a few possibilities:
455- within same source file only:
456 put the prototypes at the top of your file and mark them as prototypes.
457- within the same module:
458 create a header file within the subdirectory where that module resides,
459 e.g. graphics/ddraw_private.h
460- from a totally different module, or for use in winelib:
461 put your header file entry in /include/wine/
462 but be careful not to clutter this directory!
463under no circumstances, you should add non-api calls to the standard
464windoze include files. Unfortunately, this is often the case, e.g.
465the above example of TIMER_Init is defined in include/message.h
466
467
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000468API ENTRY POINTS
469================
Alexandre Julliarddba420a1994-02-02 06:48:31 +0000470
471Because Win16 programs use a 16-bit stack and because they can only
472call 16:16 addressed functions, all API entry points must be at low
473address offsets and must have the arguments translated and moved to
474Wines 32-bit stack. This task is handled by the code in the "if1632"
475directory. To define a new API entry point handler you must place a
476new entry in the appropriate API specification file. These files are
Alexandre Julliardca22b331996-07-12 19:02:39 +0000477named *.spec. For example, the API specification file for the USER
478DLL is contained in the file user.spec. These entries are processed
479by the "build" program to create an assembly file containing the entry
480point code for each API call. The format of the *.spec files is
Alexandre Julliard8d24ae61994-04-05 21:42:43 +0000481documented in the file "tools/build-spec.txt".
482
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000483
484DEBUG MESSAGES
485==============
Alexandre Julliardaca05781994-10-17 18:12:41 +0000486
487To display a message only during debugging, you normally write something
488like this:
489
Alexandre Julliard54c27111998-03-29 19:44:57 +0000490 TRACE(win,"abc..."); or
491 FIXME(win,"abc..."); or
492 WARN(win,"abc..."); or
493 ERR(win,"abc...");
Alexandre Julliardaca05781994-10-17 18:12:41 +0000494
Alexandre Julliard54c27111998-03-29 19:44:57 +0000495depending on the seriousness of the problem. (documentation/degug-msgs
496explains when it is appropriate to use each of them)
Alexandre Julliardaca05781994-10-17 18:12:41 +0000497
Alexandre Julliard54c27111998-03-29 19:44:57 +0000498These macros are defined in include/debug.h. The macro-definitions are
499generated by the shell-script tools/make_debug. It scans the source
500code for symbols of this forms and puts the necessary macro
501definitions in include/debug.h and include/debugdefs.h. These macros
502test whether the debugging "channel" associated with the first
503argument of these macros (win in the above example) is enabled and
504thus decide whether to actually display the text. In addition you can
505change the types of displayed messages by supplying the "-debugmsg"
506option to Wine. If your debugging code is more complex than just
507printf, you can use the symbols TRACE_ON(xxx), WARN_ON(xxx),
508ERR_ON(xxx) and FIXME_ON(xxx) as well. These are true when channel xxx
509is enabled, either permanent or in the command line. Thus, you can
510write:
Alexandre Julliardaca05781994-10-17 18:12:41 +0000511
Alexandre Julliard54c27111998-03-29 19:44:57 +0000512 if(TRACE_ON(win))DumpSomeStructure(&str);
Alexandre Julliard234bc241994-12-10 13:02:28 +0000513
Alexandre Julliard234bc241994-12-10 13:02:28 +0000514Don't worry about the inefficiency of the test. If it is permanently
Alexandre Julliard54c27111998-03-29 19:44:57 +0000515disabled (that is TRACE_ON(win) is 0 at compile time), the compiler will
Alexandre Julliard234bc241994-12-10 13:02:28 +0000516eliminate the dead code.
Alexandre Julliardaca05781994-10-17 18:12:41 +0000517
Alexandre Julliardaca05781994-10-17 18:12:41 +0000518You have to start tools/make_debug only if you introduced a new macro,
Alexandre Julliard54c27111998-03-29 19:44:57 +0000519e.g. TRACE(win32).
520
521For more info about debugging messages, read:
522
523documentation/debug-msgs
524
Alexandre Julliard23946ad1997-06-16 17:43:53 +0000525
526MORE INFO
527=========
528
Alexandre Julliard33072e11997-06-29 18:08:02 +00005291. There is a FREE online version of the MSDN library (including
530 documentation for the Win32 API) on http://www.microsoft.com/msdn/
Alexandre Julliard23946ad1997-06-16 17:43:53 +0000531
Alexandre Julliard33072e11997-06-29 18:08:02 +00005322. http://www.sonic.net/~undoc/bookstore.html
Alexandre Julliard23946ad1997-06-16 17:43:53 +0000533
Alexandre Julliard33072e11997-06-29 18:08:02 +00005343. In 1993 Dr. Dobbs Journal published a column called "Undocumented Corner".
535
5364. You might want to check out BYTE from December 1983 as well :-)
Alexandre Julliard23946ad1997-06-16 17:43:53 +0000537