Replaced -dosver and -winver options by config file parameters.
[wine] / misc / version.c
1 /*
2  * Windows and DOS version functions
3  *
4  * Copyright 1997 Alexandre Julliard
5  * Copyright 1997 Marcus Meissner
6  * Copyright 1998 Patrik Stridvall
7  * Copyright 1998 Andreas Mohr
8  *
9  * This library is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU Lesser General Public
11  * License as published by the Free Software Foundation; either
12  * version 2.1 of the License, or (at your option) any later version.
13  *
14  * This library is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17  * Lesser General Public License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public
20  * License along with this library; if not, write to the Free Software
21  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
22  */
23
24 #include <string.h>
25 #include <stdlib.h>
26 #include <stdio.h>
27 #include "windef.h"
28 #include "winbase.h"
29 #include "winreg.h"
30 #include "wingdi.h"
31 #include "winuser.h"
32 #include "wine/winbase16.h"
33 #include "module.h"
34 #include "wine/debug.h"
35 #include "winerror.h"
36
37 WINE_DEFAULT_DEBUG_CHANNEL(ver);
38
39 typedef enum
40 {
41     WIN20,   /* Windows 2.0 */
42     WIN30,   /* Windows 3.0 */
43     WIN31,   /* Windows 3.1 */
44     WIN95,   /* Windows 95 */
45     WIN98,   /* Windows 98 */
46     WINME,   /* Windows Me */
47     NT351,   /* Windows NT 3.51 */
48     NT40,    /* Windows NT 4.0 */
49     NT2K,    /* Windows 2000 */
50     WINXP,   /* Windows XP */
51     NB_WINDOWS_VERSIONS
52 } WINDOWS_VERSION;
53
54 typedef struct
55 {
56     LONG             getVersion16; 
57     LONG             getVersion32;
58     OSVERSIONINFOA getVersionEx;
59 } VERSION_DATA;
60
61 /* FIXME: compare values below with original and fix */
62 static VERSION_DATA VersionData[NB_WINDOWS_VERSIONS] =
63 {
64     /* WIN20 FIXME: verify values */
65     {
66         MAKELONG( 0x0002, 0x0303 ), /* assume DOS 3.3 */
67         MAKELONG( 0x0003, 0x8000 ),
68         {
69             sizeof(OSVERSIONINFOA), 2, 0, 0,
70             VER_PLATFORM_WIN32s, "Win32s 1.3" 
71         }
72     },
73     /* WIN30 FIXME: verify values */
74     {
75         MAKELONG( 0x0003, 0x0500 ), /* assume DOS 5.00 */
76         MAKELONG( 0x0003, 0x8000 ),
77         {
78             sizeof(OSVERSIONINFOA), 3, 0, 0,
79             VER_PLATFORM_WIN32s, "Win32s 1.3" 
80         }
81     },
82     /* WIN31 */
83     {
84         MAKELONG( 0x0a03, 0x0616 ), /* DOS 6.22 */
85         MAKELONG( 0x0a03, 0x8000 ),
86         {
87             sizeof(OSVERSIONINFOA), 3, 10, 0,
88             VER_PLATFORM_WIN32s, "Win32s 1.3" 
89         }
90     },
91     /* WIN95 */
92     {
93         0x07005F03,
94         0xC0000004,
95         {
96             /* Win95:       4, 0, 0x40003B6, ""
97              * Win95sp1:    4, 0, 0x40003B6, " A " (according to doc)
98              * Win95osr2:   4, 0, 0x4000457, " B " (according to doc)
99              * Win95osr2.1: 4, 3, 0x40304BC, " B " (according to doc)
100              * Win95osr2.5: 4, 3, 0x40304BE, " C " (according to doc)
101              * Win95a/b can be discerned via regkey SubVersionNumber
102              * See also:
103              * http://support.microsoft.com/support/kb/articles/q158/2/38.asp
104              */
105             sizeof(OSVERSIONINFOA), 4, 0, 0x40003B6,
106             VER_PLATFORM_WIN32_WINDOWS, ""
107         }
108     },
109     /* WIN98 */
110     {
111         0x070A5F03,
112         0xC0000A04,
113         {
114             /* Win98:   4, 10, 0x40A07CE, " "
115              * Win98SE: 4, 10, 0x40A08AE, " A "
116              */
117             sizeof(OSVERSIONINFOA), 4, 10, 0x40A07CE,
118             VER_PLATFORM_WIN32_WINDOWS, " "
119         }
120     },
121     /* WINME */
122     {
123         0x07005F03, /* Assuming DOS 7 like the other Win9x */
124         0xC0005A04,
125         {
126             sizeof(OSVERSIONINFOA), 4, 90, 0x45A0BB8,
127             VER_PLATFORM_WIN32_WINDOWS, " "
128         }
129     },
130     /* NT351 */
131     {
132         0x05000A03,
133         0x04213303,
134         {
135             sizeof(OSVERSIONINFOA), 3, 51, 0x421,
136             VER_PLATFORM_WIN32_NT, "Service Pack 2"
137         }
138     },
139     /* NT40 */
140     {
141         0x05000A03,
142         0x05650004,
143         {
144             sizeof(OSVERSIONINFOA), 4, 0, 0x565,
145             VER_PLATFORM_WIN32_NT, "Service Pack 6"
146         }
147     },
148     /* NT2K */
149     {
150         0x05005F03,
151         0x08930005,
152         {
153             sizeof(OSVERSIONINFOA), 5, 0, 0x893,
154             VER_PLATFORM_WIN32_NT, "Service Pack 2"
155         }
156     },
157     /* WINXP */
158     {
159         0x05005F03, /* Assuming DOS 5 like the other NT */
160         0x0A280105,
161         {
162             sizeof(OSVERSIONINFOA), 5, 1, 0xA28,
163             VER_PLATFORM_WIN32_NT, ""
164         }
165     }
166 };
167
168 static const char *WinVersionNames[NB_WINDOWS_VERSIONS] =
169 { /* no spaces in here ! */
170     "win20",
171     "win30",
172     "win31",
173     "win95",
174     "win98",
175     "winme",
176     "nt351",
177     "nt40",
178     "win2000,win2k,nt2k,nt2000",
179     "winxp"
180 };
181
182 /* if one of the following dlls is importing ntdll the windows
183 version autodetection switches wine to unicode (nt 3.51 or 4.0) */
184 static char * special_dlls[] =
185 {
186         "COMDLG32",
187         "COMCTL32",
188         "SHELL32",
189         "OLE32",
190         "RPCRT4",
191         NULL
192 };
193
194 /* the current version has not been autodetected but forced via cmdline */
195 static BOOL versionForced = FALSE;
196 static WINDOWS_VERSION defaultWinVersion = WIN31;
197
198 /**********************************************************************
199  *         VERSION_ParseWinVersion
200  */
201 static void VERSION_ParseWinVersion( const char *arg )
202 {
203     int i, len;
204     const char *pCurr, *p;
205     for (i = 0; i < NB_WINDOWS_VERSIONS; i++)
206     {
207         pCurr = WinVersionNames[i];
208         /* iterate through all winver aliases separated by comma */
209         do {
210             p = strchr(pCurr, ',');
211             len = p ? (int)p - (int)pCurr : strlen(pCurr);
212             if ( (!strncmp( pCurr, arg, len )) && (arg[len] == '\0') )
213             {
214                 defaultWinVersion = (WINDOWS_VERSION)i;
215                 versionForced = TRUE;
216                 return;
217             }
218             pCurr = p+1;
219         } while (p);
220     }
221     MESSAGE("Invalid Windows version value '%s' specified in config file.\n", arg );
222     MESSAGE("Valid versions are:" );
223     for (i = 0; i < NB_WINDOWS_VERSIONS; i++)
224     {
225         /* only list the first, "official" alias in case of aliases */
226         pCurr = WinVersionNames[i];
227         p = strchr(pCurr, ',');
228         len = (p) ? (int)p - (int)pCurr : strlen(pCurr);
229
230         MESSAGE(" '%.*s'%c", len, pCurr,
231                 (i == NB_WINDOWS_VERSIONS - 1) ? '\n' : ',' );
232     }
233     ExitProcess(1);
234 }
235
236
237 /**********************************************************************
238  *         VERSION_ParseDosVersion
239  */
240 static void VERSION_ParseDosVersion( const char *arg )
241 {
242     int hi, lo;
243     if (sscanf( arg, "%d.%d", &hi, &lo ) == 2)
244     {
245         VersionData[WIN31].getVersion16 =
246             MAKELONG(LOWORD(VersionData[WIN31].getVersion16),
247                      (hi<<8) + lo);
248     }
249     else
250     {
251         MESSAGE("Wrong format for DOS version in config file. Use \"x.xx\"\n");
252         ExitProcess(1);
253     }
254 }
255
256
257 /**********************************************************************
258  *         VERSION_Init
259  */
260 static void VERSION_Init(void)
261 {
262     HKEY hkey, appkey;
263     DWORD count, type;
264     BOOL got_win_ver = FALSE, got_dos_ver = FALSE;
265     char buffer[MAX_PATH+16], *appname, *p;
266     static BOOL init_done;
267
268     if (init_done) return;
269     if (!GetModuleFileName16( GetCurrentTask(), buffer, MAX_PATH ) &&
270         !GetModuleFileNameA( 0, buffer, MAX_PATH ))
271     {
272         WARN( "could not get module file name\n" );
273         return;
274     }
275     init_done = TRUE;
276     appname = buffer;
277     if ((p = strrchr( appname, '/' ))) appname = p + 1;
278     if ((p = strrchr( appname, '\\' ))) appname = p + 1;
279
280     if (!RegOpenKeyA( HKEY_LOCAL_MACHINE, "Software\\Wine\\Wine\\Config\\AppDefaults", &hkey ))
281     {
282         /* open AppDefaults\\appname\\Version key */
283         strcat( appname, "\\Version" );
284         if (!RegOpenKeyA( hkey, appname, &appkey ))
285         {
286             count = sizeof(buffer);
287             if (!RegQueryValueExA( appkey, "Windows", NULL, &type, buffer, &count ))
288             {
289                 VERSION_ParseWinVersion( buffer );
290                 TRACE( "got app win version %s\n", WinVersionNames[defaultWinVersion] );
291                 got_win_ver = TRUE;
292             }
293             count = sizeof(buffer);
294             if (!RegQueryValueExA( appkey, "DOS", NULL, &type, buffer, &count ))
295             {
296                 VERSION_ParseDosVersion( buffer );
297                 TRACE( "got app dos version %lx\n", VersionData[WIN31].getVersion16 );
298                 got_dos_ver = TRUE;
299             }
300             RegCloseKey( appkey );
301         }
302         RegCloseKey( hkey );
303     }
304
305     if (got_win_ver && got_dos_ver) return;
306
307     if (!RegOpenKeyA( HKEY_LOCAL_MACHINE, "Software\\Wine\\Wine\\Config\\Version", &hkey ))
308     {
309         if (!got_win_ver)
310         {
311             count = sizeof(buffer);
312             if (!RegQueryValueExA( hkey, "Windows", NULL, &type, buffer, &count ))
313             {
314                 VERSION_ParseWinVersion( buffer );
315                 TRACE( "got default win version %s\n", WinVersionNames[defaultWinVersion] );
316             }
317         }
318         if (!got_dos_ver)
319         {
320             count = sizeof(buffer);
321             if (!RegQueryValueExA( hkey, "DOS", NULL, &type, buffer, &count ))
322             {
323                 VERSION_ParseDosVersion( buffer );
324                 TRACE( "got default dos version %lx\n", VersionData[WIN31].getVersion16 );
325             }
326         }
327         RegCloseKey( hkey );
328     }
329 }
330
331
332 /**********************************************************************
333  *      VERSION_GetSystemDLLVersion
334  *
335  * This function tries to figure out if a given (native) dll comes from
336  * win95/98 or winnt. Since all values in the OptionalHeader are not a 
337  * usable hint, we test if a dll imports the ntdll.
338  * This is at least working for all system dlls like comctl32, comdlg32 and
339  * shell32.
340  * If you have a better idea to figure this out...
341  */
342 static DWORD VERSION_GetSystemDLLVersion( HMODULE hmod )
343 {
344     IMAGE_DATA_DIRECTORY *dir = PE_HEADER(hmod)->OptionalHeader.DataDirectory
345                                 + IMAGE_DIRECTORY_ENTRY_IMPORT;
346     if (dir->Size && dir->VirtualAddress)
347     {
348         IMAGE_IMPORT_DESCRIPTOR *pe_imp = (IMAGE_IMPORT_DESCRIPTOR *)((char *)hmod + dir->VirtualAddress);
349         for ( ; pe_imp->Name; pe_imp++)
350         {
351             char * name = (char *)hmod + (unsigned int)pe_imp->Name;
352             TRACE("%s\n", name);
353             
354             if (!strncasecmp(name, "ntdll", 5))
355             {
356               if (3 == PE_HEADER(hmod)->OptionalHeader.MajorOperatingSystemVersion)
357                 return NT351;
358               else
359                 return NT40;
360             }
361         }
362     }
363     return WIN95;
364 }
365 /**********************************************************************
366  *      VERSION_GetLinkedDllVersion
367  *
368  * Some version data (not reliable!):
369  * linker/OS/image/subsys
370  *
371  * x.xx/1.00/0.00/3.10  Win32s          (any version ?)
372  * 2.39/1.00/0.00/3.10  Win32s          freecell.exe (any version)
373  * 2.50/1.00/4.00/4.00  Win32s 1.30     winhlp32.exe    
374  * 2.60/3.51/3.51/3.51  NT351SP5        system dlls 
375  * 2.60/3.51/3.51/4.00  NT351SP5        comctl32 dll
376  * 2.xx/1.00/0.00/4.00  Win95           system files
377  * x.xx/4.00/0.00/4.00  Win95           most applications
378  * 3.10/4.00/0.00/4.00  Win98           notepad
379  * x.xx/5.00/5.00/4.00  Win98           system dlls
380  * x.xx/4.00/4.00/4.00  NT 4            most apps
381  * 5.12/5.00/5.00/4.00  NT4+IE5         comctl32.dll
382  * 5.12/5.00/5.00/4.00  Win98           calc
383  * x.xx/5.00/5.00/4.00  win95/win98/NT4 IE5 files
384  */
385 DWORD VERSION_GetLinkedDllVersion(void)
386 {
387         WINE_MODREF *wm;
388         DWORD WinVersion = NB_WINDOWS_VERSIONS;
389         PIMAGE_OPTIONAL_HEADER ophd;
390
391         /* First check the native dlls provided. These have to be
392         from one windows version */
393         for ( wm = MODULE_modref_list; wm; wm=wm->next )
394         {
395           ophd = &(PE_HEADER(wm->module)->OptionalHeader);
396
397           TRACE("%s: %02x.%02x/%02x.%02x/%02x.%02x/%02x.%02x\n",
398             wm->modname,
399             ophd->MajorLinkerVersion, ophd->MinorLinkerVersion,
400             ophd->MajorOperatingSystemVersion, ophd->MinorOperatingSystemVersion,
401             ophd->MajorImageVersion, ophd->MinorImageVersion,
402             ophd->MajorSubsystemVersion, ophd->MinorSubsystemVersion);
403
404           /* test if it is an external (native) dll */
405           if (!(wm->flags & WINE_MODREF_INTERNAL))
406           {
407             int i;
408             for (i = 0; special_dlls[i]; i++)
409             {
410               /* test if it is a special dll */
411               if (!strncasecmp(wm->modname, special_dlls[i], strlen(special_dlls[i]) ))
412               {
413                 DWORD DllVersion = VERSION_GetSystemDLLVersion(wm->module);
414                 if (WinVersion == NB_WINDOWS_VERSIONS) 
415                   WinVersion = DllVersion;
416                 else {
417                   if (WinVersion != DllVersion) {
418                     ERR("You mixed system dlls from different windows versions! Expect a crash! (%s: expected version '%s', but is '%s')\n",
419                         wm->modname,
420                         VersionData[WinVersion].getVersionEx.szCSDVersion,
421                         VersionData[DllVersion].getVersionEx.szCSDVersion);
422                     return WIN31; /* this may let the exe exiting */
423                   }
424                 }
425                 break;
426               }
427             }
428           }
429         }
430         
431         if(WinVersion != NB_WINDOWS_VERSIONS) return WinVersion;
432         
433         /* we are using no external system dlls, look at the exe */
434         ophd = &(PE_HEADER(GetModuleHandleA(NULL))->OptionalHeader);
435         
436         TRACE("%02x.%02x/%02x.%02x/%02x.%02x/%02x.%02x\n",
437             ophd->MajorLinkerVersion, ophd->MinorLinkerVersion,
438             ophd->MajorOperatingSystemVersion, ophd->MinorOperatingSystemVersion,
439             ophd->MajorImageVersion, ophd->MinorImageVersion,
440             ophd->MajorSubsystemVersion, ophd->MinorSubsystemVersion);
441
442         /* special nt 3.51 */
443         if (3 == ophd->MajorOperatingSystemVersion && 51 == ophd->MinorOperatingSystemVersion)
444         {
445             return NT351;
446         }
447
448         /* the MajorSubsystemVersion is the only usable sign */
449         if (ophd->MajorSubsystemVersion < 4)
450         {
451           if ( ophd->MajorOperatingSystemVersion == 1 
452             && ophd->MinorOperatingSystemVersion == 0)
453           {
454             return WIN31; /* win32s */
455           }
456           
457           if (ophd->Subsystem == IMAGE_SUBSYSTEM_WINDOWS_CUI)
458             return NT351; /* FIXME: NT 3.1, not tested */
459           else
460             return WIN95;
461         }       
462
463         return WIN95;
464 }
465
466 /**********************************************************************
467  *         VERSION_GetVersion
468  *
469  * WARNING !!!
470  * Don't call this function too early during the Wine init,
471  * as pdb->exe_modref (required by VERSION_GetImageVersion()) might still
472  * be NULL in such cases, which causes the winver to ALWAYS be detected
473  * as WIN31.
474  * And as we cache the winver once it has been determined, this is bad.
475  * This can happen much easier than you might think, as this function
476  * is called by EVERY GetVersion*() API !
477  *
478  */
479 static WINDOWS_VERSION VERSION_GetVersion(void)
480 {
481     static WORD winver = 0xffff;
482
483     if (winver == 0xffff) /* to be determined */
484     {
485         WINDOWS_VERSION retver;
486
487         VERSION_Init();
488         if (versionForced) /* user has overridden any sensible checks */
489             winver = defaultWinVersion;
490         else
491         {
492             retver = VERSION_GetLinkedDllVersion();
493
494             /* cache determined value, but do not store in case of WIN31 */
495             if (retver != WIN31) winver = retver;
496
497             return retver;
498         }
499     }
500
501     return winver;
502 }
503
504
505 /***********************************************************************
506  *         GetVersion   (KERNEL.3)
507  */
508 LONG WINAPI GetVersion16(void)
509 {
510     WINDOWS_VERSION ver = VERSION_GetVersion();
511     return VersionData[ver].getVersion16;
512 }
513
514
515 /***********************************************************************
516  *         GetVersion   (KERNEL32.@)
517  */
518 LONG WINAPI GetVersion(void)
519 {
520     WINDOWS_VERSION ver = VERSION_GetVersion();
521     return VersionData[ver].getVersion32;
522 }
523
524
525 /***********************************************************************
526  *         GetVersionEx   (KERNEL.149)
527  */
528 BOOL16 WINAPI GetVersionEx16(OSVERSIONINFO16 *v)
529 {
530     WINDOWS_VERSION ver = VERSION_GetVersion();
531     if (v->dwOSVersionInfoSize < sizeof(OSVERSIONINFO16))
532     {
533         WARN("wrong OSVERSIONINFO size from app\n");
534         SetLastError(ERROR_INSUFFICIENT_BUFFER);
535         return FALSE;
536     }
537     v->dwMajorVersion = VersionData[ver].getVersionEx.dwMajorVersion;
538     v->dwMinorVersion = VersionData[ver].getVersionEx.dwMinorVersion;
539     v->dwBuildNumber  = VersionData[ver].getVersionEx.dwBuildNumber;
540     v->dwPlatformId   = VersionData[ver].getVersionEx.dwPlatformId;
541     strcpy( v->szCSDVersion, VersionData[ver].getVersionEx.szCSDVersion );
542     return TRUE;
543 }
544
545
546 /***********************************************************************
547  *         GetVersionExA   (KERNEL32.@)
548  */
549 BOOL WINAPI GetVersionExA(OSVERSIONINFOA *v)
550 {
551     WINDOWS_VERSION ver = VERSION_GetVersion();
552     if (v->dwOSVersionInfoSize < sizeof(OSVERSIONINFOA))
553     {
554         WARN("wrong OSVERSIONINFO size from app (got: %ld, expected: %d)\n",
555                         v->dwOSVersionInfoSize, sizeof(OSVERSIONINFOA));
556         SetLastError(ERROR_INSUFFICIENT_BUFFER);
557         return FALSE;
558     }
559     v->dwMajorVersion = VersionData[ver].getVersionEx.dwMajorVersion;
560     v->dwMinorVersion = VersionData[ver].getVersionEx.dwMinorVersion;
561     v->dwBuildNumber  = VersionData[ver].getVersionEx.dwBuildNumber;
562     v->dwPlatformId   = VersionData[ver].getVersionEx.dwPlatformId;
563     strcpy( v->szCSDVersion, VersionData[ver].getVersionEx.szCSDVersion );
564     return TRUE;
565 }
566
567
568 /***********************************************************************
569  *         GetVersionExW   (KERNEL32.@)
570  */
571 BOOL WINAPI GetVersionExW(OSVERSIONINFOW *v)
572 {
573     WINDOWS_VERSION ver = VERSION_GetVersion();
574
575     if (v->dwOSVersionInfoSize < sizeof(OSVERSIONINFOW))
576     {
577         WARN("wrong OSVERSIONINFO size from app (got: %ld, expected: %d)\n",
578                         v->dwOSVersionInfoSize, sizeof(OSVERSIONINFOW));
579         SetLastError(ERROR_INSUFFICIENT_BUFFER);
580         return FALSE;
581     }
582     v->dwMajorVersion = VersionData[ver].getVersionEx.dwMajorVersion;
583     v->dwMinorVersion = VersionData[ver].getVersionEx.dwMinorVersion;
584     v->dwBuildNumber  = VersionData[ver].getVersionEx.dwBuildNumber;
585     v->dwPlatformId   = VersionData[ver].getVersionEx.dwPlatformId;
586     MultiByteToWideChar( CP_ACP, 0, VersionData[ver].getVersionEx.szCSDVersion, -1,
587                          v->szCSDVersion, sizeof(v->szCSDVersion)/sizeof(WCHAR) );
588     return TRUE;
589 }
590
591
592
593 /******************************************************************************
594  *        VerifyVersionInfoW   (KERNEL32.@)
595  */
596 BOOL WINAPI VerifyVersionInfoW( /* LPOSVERSIONINFOEXW */ LPVOID lpVersionInfo, DWORD dwTypeMask,
597                                 DWORDLONG dwlConditionMask)
598 {
599     FIXME("%p %lu %llx\n", lpVersionInfo, dwTypeMask, dwlConditionMask);
600     return TRUE;
601 }
602
603
604 /***********************************************************************
605  *          GetWinFlags   (KERNEL.132)
606  */
607 DWORD WINAPI GetWinFlags16(void)
608 {
609   static const long cpuflags[5] =
610     { WF_CPU086, WF_CPU186, WF_CPU286, WF_CPU386, WF_CPU486 };
611   SYSTEM_INFO si;
612   OSVERSIONINFOA ovi;
613   DWORD result;
614
615   GetSystemInfo(&si);
616
617   /* There doesn't seem to be any Pentium flag.  */
618   result = cpuflags[min(si.wProcessorLevel, 4)] | WF_ENHANCED | WF_PMODE | WF_80x87 | WF_PAGING;
619   if (si.wProcessorLevel >= 4) result |= WF_HASCPUID;
620   ovi.dwOSVersionInfoSize = sizeof(ovi);
621   GetVersionExA(&ovi);
622   if (ovi.dwPlatformId == VER_PLATFORM_WIN32_NT)
623       result |= WF_WIN32WOW; /* undocumented WF_WINNT */
624   return result;
625 }
626
627
628 #if 0
629 /* Not used at this time. This is here for documentation only */
630
631 /* WINDEBUGINFO flags values */
632 #define WDI_OPTIONS         0x0001
633 #define WDI_FILTER          0x0002
634 #define WDI_ALLOCBREAK      0x0004
635
636 /* dwOptions values */
637 #define DBO_CHECKHEAP       0x0001
638 #define DBO_BUFFERFILL      0x0004
639 #define DBO_DISABLEGPTRAPPING 0x0010
640 #define DBO_CHECKFREE       0x0020
641
642 #define DBO_SILENT          0x8000
643
644 #define DBO_TRACEBREAK      0x2000
645 #define DBO_WARNINGBREAK    0x1000
646 #define DBO_NOERRORBREAK    0x0800
647 #define DBO_NOFATALBREAK    0x0400
648 #define DBO_INT3BREAK       0x0100
649
650 /* DebugOutput flags values */
651 #define DBF_TRACE           0x0000
652 #define DBF_WARNING         0x4000
653 #define DBF_ERROR           0x8000
654 #define DBF_FATAL           0xc000
655
656 /* dwFilter values */
657 #define DBF_KERNEL          0x1000
658 #define DBF_KRN_MEMMAN      0x0001
659 #define DBF_KRN_LOADMODULE  0x0002
660 #define DBF_KRN_SEGMENTLOAD 0x0004
661 #define DBF_USER            0x0800
662 #define DBF_GDI             0x0400
663 #define DBF_MMSYSTEM        0x0040
664 #define DBF_PENWIN          0x0020
665 #define DBF_APPLICATION     0x0008
666 #define DBF_DRIVER          0x0010
667
668 #endif /* NOLOGERROR */
669
670
671 /***********************************************************************
672  *          GetWinDebugInfo   (KERNEL.355)
673  */
674 BOOL16 WINAPI GetWinDebugInfo16(WINDEBUGINFO16 *lpwdi, UINT16 flags)
675 {
676     FIXME("(%8lx,%d): stub returning 0\n",
677           (unsigned long)lpwdi, flags);
678     /* 0 means not in debugging mode/version */
679     /* Can this type of debugging be used in wine ? */
680     /* Constants: WDI_OPTIONS WDI_FILTER WDI_ALLOCBREAK */
681     return 0;
682 }
683
684
685 /***********************************************************************
686  *          SetWinDebugInfo   (KERNEL.356)
687  */
688 BOOL16 WINAPI SetWinDebugInfo16(WINDEBUGINFO16 *lpwdi)
689 {
690     FIXME("(%8lx): stub returning 0\n", (unsigned long)lpwdi);
691     /* 0 means not in debugging mode/version */
692     /* Can this type of debugging be used in wine ? */
693     /* Constants: WDI_OPTIONS WDI_FILTER WDI_ALLOCBREAK */
694     return 0;
695 }
696
697
698 /***********************************************************************
699  *           K329                    (KERNEL.329)
700  *
701  * TODO:
702  * Should fill lpBuffer only if DBO_BUFFERFILL has been set by SetWinDebugInfo()
703  */
704 void WINAPI DebugFillBuffer(LPSTR lpBuffer, WORD wBytes)
705 {
706         memset(lpBuffer, DBGFILL_BUFFER, wBytes);
707 }
708
709 /***********************************************************************
710  *           DiagQuery                          (KERNEL.339)
711  *
712  * returns TRUE if Win called with "/b" (bootlog.txt)
713  */
714 BOOL16 WINAPI DiagQuery16()
715 {
716         /* perhaps implement a Wine "/b" command line flag sometime ? */
717         return FALSE;
718 }
719
720 /***********************************************************************
721  *           DiagOutput                         (KERNEL.340)
722  *
723  * writes a debug string into <windir>\bootlog.txt
724  */
725 void WINAPI DiagOutput16(LPCSTR str)
726 {
727         /* FIXME */
728         DPRINTF("DIAGOUTPUT:%s\n", debugstr_a(str));
729 }