Added stub implementations for NtDeleteFile and NtCancelIoFile.
[wine] / dlls / ntdll / version.c
1 /*
2  * Windows and DOS version functions
3  *
4  * Copyright 1997 Marcus Meissner
5  * Copyright 1998 Patrik Stridvall
6  * Copyright 1998, 2003 Andreas Mohr
7  * Copyright 1997, 2003 Alexandre Julliard
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 "config.h"
25 #include "wine/port.h"
26
27 #include <string.h>
28 #include <stdlib.h>
29 #include <stdarg.h>
30 #include <stdio.h>
31 #include "ntstatus.h"
32 #include "windef.h"
33 #include "winbase.h"
34 #include "wingdi.h"
35 #include "winuser.h"
36 #include "winreg.h"
37 #include "winternl.h"
38 #include "winerror.h"
39 #include "wine/unicode.h"
40 #include "wine/debug.h"
41 #include "ntdll_misc.h"
42
43 WINE_DEFAULT_DEBUG_CHANNEL(ver);
44
45 typedef enum
46 {
47     WIN20,   /* Windows 2.0 */
48     WIN30,   /* Windows 3.0 */
49     WIN31,   /* Windows 3.1 */
50     WIN95,   /* Windows 95 */
51     WIN98,   /* Windows 98 */
52     WINME,   /* Windows Me */
53     NT351,   /* Windows NT 3.51 */
54     NT40,    /* Windows NT 4.0 */
55     NT2K,    /* Windows 2000 */
56     WINXP,   /* Windows XP */
57     WIN2K3,  /* Windows 2003 */
58     NB_WINDOWS_VERSIONS
59 } WINDOWS_VERSION;
60
61 /* FIXME: compare values below with original and fix.
62  * An *excellent* win9x version page (ALL versions !)
63  * can be found at members.aol.com/axcel216/ver.htm */
64 static const RTL_OSVERSIONINFOEXW VersionData[NB_WINDOWS_VERSIONS] =
65 {
66     /* WIN20 FIXME: verify values */
67     {
68         sizeof(RTL_OSVERSIONINFOEXW), 2, 0, 0, VER_PLATFORM_WIN32s,
69         {'W','i','n','3','2','s',' ','1','.','3',0},
70         0, 0, 0, 0, 0
71     },
72     /* WIN30 FIXME: verify values */
73     {
74         sizeof(RTL_OSVERSIONINFOEXW), 3, 0, 0, VER_PLATFORM_WIN32s,
75         {'W','i','n','3','2','s',' ','1','.','3',0},
76         0, 0, 0, 0, 0
77     },
78     /* WIN31 */
79     {
80         sizeof(RTL_OSVERSIONINFOEXW), 3, 10, 0, VER_PLATFORM_WIN32s,
81         {'W','i','n','3','2','s',' ','1','.','3',0},
82         0, 0, 0, 0, 0
83     },
84     /* WIN95 */
85     {
86         /* Win95:       4, 0, 0x40003B6, ""
87          * Win95sp1:    4, 0, 0x40003B6, " A " (according to doc)
88          * Win95osr2:   4, 0, 0x4000457, " B " (according to doc)
89          * Win95osr2.1: 4, 3, 0x40304BC, " B " (according to doc)
90          * Win95osr2.5: 4, 3, 0x40304BE, " C " (according to doc)
91          * Win95a/b can be discerned via regkey SubVersionNumber
92          * See also:
93          * http://support.microsoft.com/support/kb/articles/q158/2/38.asp
94          */
95         sizeof(RTL_OSVERSIONINFOEXW), 4, 0, 0x40003B6, VER_PLATFORM_WIN32_WINDOWS,
96         {0},
97         0, 0, 0, 0, 0
98     },
99     /* WIN98 (second edition) */
100     {
101         /* Win98:   4, 10, 0x40A07CE, " "   4.10.1998
102          * Win98SE: 4, 10, 0x40A08AE, " A " 4.10.2222
103          */
104         sizeof(RTL_OSVERSIONINFOEXW), 4, 10, 0x40A08AE, VER_PLATFORM_WIN32_WINDOWS,
105         {' ','A',' ',0},
106         0, 0, 0, 0, 0
107     },
108     /* WINME */
109     {
110         sizeof(RTL_OSVERSIONINFOEXW), 4, 90, 0x45A0BB8, VER_PLATFORM_WIN32_WINDOWS,
111         {' ',0},
112         0, 0, 0, 0, 0
113     },
114     /* NT351 */
115     {
116         sizeof(RTL_OSVERSIONINFOEXW), 3, 51, 0x421, VER_PLATFORM_WIN32_NT,
117         {'S','e','r','v','i','c','e',' ','P','a','c','k',' ','2',0},
118         0, 0, 0, 0, 0
119     },
120     /* NT40 */
121     {
122         sizeof(RTL_OSVERSIONINFOEXW), 4, 0, 0x565, VER_PLATFORM_WIN32_NT,
123         {'S','e','r','v','i','c','e',' ','P','a','c','k',' ','6','a',0},
124         6, 0, 0, VER_NT_WORKSTATION, 0
125     },
126     /* NT2K */
127     {
128         sizeof(RTL_OSVERSIONINFOEXW), 5, 0, 0x893, VER_PLATFORM_WIN32_NT,
129         {'S','e','r','v','i','c','e',' ','P','a','c','k',' ','4',0},
130         4, 0, 0, VER_NT_WORKSTATION, 30 /* FIXME: Great, a reserved field with a value! */
131     },
132     /* WINXP */
133     {
134         sizeof(RTL_OSVERSIONINFOEXW), 5, 1, 0xA28, VER_PLATFORM_WIN32_NT,
135         {'S','e','r','v','i','c','e',' ','P','a','c','k',' ','2',0},
136         2, 0, VER_SUITE_SINGLEUSERTS, VER_NT_WORKSTATION, 30 /* FIXME: Great, a reserved field with a value! */
137     },
138     /* WIN2K3 */
139     {
140         sizeof(RTL_OSVERSIONINFOEXW), 5, 2, 0xECE, VER_PLATFORM_WIN32_NT,
141         {0},
142         0, 0, VER_SUITE_SINGLEUSERTS, VER_NT_SERVER, 0
143     }
144 };
145
146 static const char * const WinVersionNames[NB_WINDOWS_VERSIONS] =
147 { /* no spaces in here ! */
148     "win20",                      /* WIN20 */
149     "win30",                      /* WIN30 */
150     "win31",                      /* WIN31 */
151     "win95",                      /* WIN95 */
152     "win98",                      /* WIN98 */
153     "winme",                      /* WINME */
154     "nt351",                      /* NT351 */
155     "nt40",                       /* NT40 */
156     "win2000,win2k,nt2k,nt2000",  /* NT2K */
157     "winxp",                      /* WINXP */
158     "win2003,win2k3"              /* WIN2K3 */
159 };
160
161 /* names to print out in debug traces */
162 static const char * const debug_names[NB_WINDOWS_VERSIONS] =
163 {
164     "Windows 2.0",       /* WIN20 */
165     "Windows 3.0",       /* WIN30 */
166     "Windows 3.1",       /* WIN31 */
167     "Windows 95",        /* WIN95 */
168     "Windows 98",        /* WIN98 */
169     "Windows Me",        /* WINME */
170     "Windows NT 3.51",   /* NT351 */
171     "Windows NT 4.0",    /* NT40 */
172     "Windows 2000",      /* NT2K */
173     "Windows XP",        /* WINXP */
174     "Windows Server 2003"/* WIN2K3 */
175 };
176
177 /* if one of the following dlls is importing ntdll the windows
178 version autodetection switches wine to unicode (nt 3.51 or 4.0) */
179 static const WCHAR special_dlls[][16] =
180 {
181     {'c','o','m','d','l','g','3','2','.','d','l','l',0},
182     {'c','o','m','c','t','l','3','2','.','d','l','l',0},
183     {'s','h','e','l','l','3','2','.','d','l','l',0},
184     {'o','l','e','3','2','.','d','l','l',0},
185     {'r','p','c','r','t','4','.','d','l','l',0}
186 };
187
188 /* the current version has not been autodetected but forced via cmdline */
189 static BOOL versionForced = FALSE;
190 static WINDOWS_VERSION forcedWinVersion; /* init value irrelevant */
191
192 /**********************************************************************
193  *         parse_win_version
194  *
195  * Parse the contents of the Version key.
196  */
197 static BOOL parse_win_version( HKEY hkey )
198 {
199     static const WCHAR WindowsW[] = {'W','i','n','d','o','w','s',0};
200
201     UNICODE_STRING valueW;
202     char tmp[64], buffer[50];
203     KEY_VALUE_PARTIAL_INFORMATION *info = (KEY_VALUE_PARTIAL_INFORMATION *)tmp;
204     DWORD count, len;
205     int i;
206
207     RtlInitUnicodeString( &valueW, WindowsW );
208     if (NtQueryValueKey( hkey, &valueW, KeyValuePartialInformation, tmp, sizeof(tmp), &count ))
209         return FALSE;
210
211     RtlUnicodeToMultiByteN( buffer, sizeof(buffer)-1, &len, (WCHAR *)info->Data, info->DataLength );
212     buffer[len] = 0;
213
214     for (i = 0; i < NB_WINDOWS_VERSIONS; i++)
215     {
216         const char *p, *pCurr = WinVersionNames[i];
217         /* iterate through all winver aliases separated by comma */
218         do {
219             p = strchr(pCurr, ',');
220             len = p ? p - pCurr : strlen(pCurr);
221             if ( (!strncmp( pCurr, buffer, len )) && (buffer[len] == 0) )
222             {
223                 forcedWinVersion = i;
224                 versionForced = TRUE;
225                 TRACE( "got win version %s\n", WinVersionNames[forcedWinVersion] );
226                 return TRUE;
227             }
228             pCurr = p+1;
229         } while (p);
230     }
231
232     MESSAGE("Invalid Windows version value '%s' specified in config file.\n", buffer );
233     MESSAGE("Valid versions are:" );
234     for (i = 0; i < NB_WINDOWS_VERSIONS; i++)
235     {
236         /* only list the first, "official" alias in case of aliases */
237         const char *pCurr = WinVersionNames[i];
238         const char *p = strchr(pCurr, ',');
239         len = (p) ? p - pCurr : strlen(pCurr);
240
241         MESSAGE(" '%.*s'%c", (int)len, pCurr, (i == NB_WINDOWS_VERSIONS - 1) ? '\n' : ',' );
242     }
243     return FALSE;
244 }
245
246
247 /**********************************************************************
248  *         VERSION_Init
249  */
250 void VERSION_Init( const WCHAR *appname )
251 {
252     OBJECT_ATTRIBUTES attr;
253     UNICODE_STRING nameW;
254     HKEY hkey, config_key;
255     static const WCHAR configW[] = {'M','a','c','h','i','n','e','\\',
256                                     'S','o','f','t','w','a','r','e','\\',
257                                     'W','i','n','e','\\',
258                                     'W','i','n','e','\\',
259                                     'C','o','n','f','i','g',0};
260     static const WCHAR appdefaultsW[] = {'A','p','p','D','e','f','a','u','l','t','s','\\',0};
261     static const WCHAR versionW[] = {'\\','V','e','r','s','i','o','n',0};
262
263     attr.Length = sizeof(attr);
264     attr.RootDirectory = 0;
265     attr.ObjectName = &nameW;
266     attr.Attributes = 0;
267     attr.SecurityDescriptor = NULL;
268     attr.SecurityQualityOfService = NULL;
269     RtlInitUnicodeString( &nameW, configW );
270
271     if (NtOpenKey( &config_key, KEY_ALL_ACCESS, &attr )) return;
272     attr.RootDirectory = config_key;
273
274     /* open AppDefaults\\appname\\Version key */
275     if (appname && *appname)
276     {
277         const WCHAR *p;
278         WCHAR appversion[MAX_PATH+20];
279         BOOL got_win_ver = FALSE;
280
281         if ((p = strrchrW( appname, '/' ))) appname = p + 1;
282         if ((p = strrchrW( appname, '\\' ))) appname = p + 1;
283
284         strcpyW( appversion, appdefaultsW );
285         strcatW( appversion, appname );
286         strcatW( appversion, versionW );
287         TRACE( "getting version from %s\n", debugstr_w(appversion) );
288         RtlInitUnicodeString( &nameW, appversion );
289
290         if (!NtOpenKey( &hkey, KEY_ALL_ACCESS, &attr ))
291         {
292             got_win_ver = parse_win_version( hkey );
293             NtClose( hkey );
294         }
295         if (got_win_ver) goto done;
296     }
297
298     TRACE( "getting default version\n" );
299     RtlInitUnicodeString( &nameW, versionW + 1 );
300     if (!NtOpenKey( &hkey, KEY_ALL_ACCESS, &attr ))
301     {
302         parse_win_version( hkey );
303         NtClose( hkey );
304     }
305
306  done:
307     NtClose( config_key );
308 }
309
310
311 /**********************************************************************
312  *      VERSION_GetSystemDLLVersion
313  *
314  * This function tries to figure out if a given (native) dll comes from
315  * win95/98 or winnt. Since all values in the OptionalHeader are not a
316  * usable hint, we test if a dll imports the ntdll.
317  * This is at least working for all system dlls like comctl32, comdlg32 and
318  * shell32.
319  * If you have a better idea to figure this out...
320  */
321 static DWORD VERSION_GetSystemDLLVersion( HMODULE hmod )
322 {
323     DWORD size;
324     IMAGE_IMPORT_DESCRIPTOR *pe_imp;
325
326     if ((pe_imp = RtlImageDirectoryEntryToData( hmod, TRUE, IMAGE_DIRECTORY_ENTRY_IMPORT, &size )))
327     {
328         for ( ; pe_imp->Name; pe_imp++)
329         {
330             char * name = (char *)hmod + (unsigned int)pe_imp->Name;
331             TRACE("%s\n", name);
332
333             if (!strncasecmp(name, "ntdll", 5))
334             {
335               switch(RtlImageNtHeader(hmod)->OptionalHeader.MajorOperatingSystemVersion) {
336                   case 3:
337                           MESSAGE("WARNING: very old native DLL (NT 3.x) used, might cause instability.\n");
338                           return NT351;
339                   case 4: return NT40;
340                   case 5: switch (RtlImageNtHeader(hmod)->OptionalHeader.MinorOperatingSystemVersion){
341                           case 0: return NT2K;
342                           case 1: return WINXP;
343                           case 2: return WIN2K3;
344                           }
345                   default:
346                           FIXME("Unknown DLL OS version, please report !!\n");
347                           return WIN2K3;
348               }
349             }
350         }
351     }
352     return WIN95;
353 }
354
355
356 /**********************************************************************
357  *      VERSION_GetLinkedDllVersion
358  *
359  * Some version data (not reliable!):
360  * linker/OS/image/subsys
361  *
362  * x.xx/1.00/0.00/3.10  Win32s          (any version ?)
363  * 2.39/1.00/0.00/3.10  Win32s          freecell.exe (any version)
364  * 2.50/1.00/4.00/4.00  Win32s 1.30     winhlp32.exe
365  * 2.60/3.51/3.51/3.51  NT351SP5        system dlls
366  * 2.60/3.51/3.51/4.00  NT351SP5        comctl32 dll
367  * 2.xx/1.00/0.00/4.00  Win95           system files
368  * x.xx/4.00/0.00/4.00  Win95           most applications
369  * 3.10/4.00/0.00/4.00  Win98           notepad
370  * x.xx/5.00/5.00/4.00  Win98           system dlls (e.g. comctl32.dll)
371  * x.xx/4.00/4.00/4.00  NT 4            most apps
372  * 5.12/5.00/5.00/4.00  NT4+IE5         comctl32.dll
373  * 5.12/5.00/5.00/4.00  Win98           calc
374  * x.xx/5.00/5.00/4.00  win95/win98/NT4 IE5 files
375  */
376 static DWORD VERSION_GetLinkedDllVersion(void)
377 {
378     WINDOWS_VERSION WinVersion = NB_WINDOWS_VERSIONS;
379     PIMAGE_OPTIONAL_HEADER ophd;
380     IMAGE_NT_HEADERS *nt;
381     const WCHAR *name;
382     PLIST_ENTRY mark, entry;
383     PLDR_MODULE mod;
384     unsigned int i;
385
386     /* First check the native dlls provided. These have to be
387        from one windows version */
388
389     mark = &NtCurrentTeb()->Peb->LdrData->InLoadOrderModuleList;
390     for (entry = mark->Flink; entry != mark; entry = entry->Flink)
391     {
392         mod = CONTAINING_RECORD(entry, LDR_MODULE, InLoadOrderModuleList);
393         if (mod->Flags & LDR_WINE_INTERNAL) continue;
394         nt = RtlImageNtHeader(mod->BaseAddress);
395         ophd = &nt->OptionalHeader;
396         name = strrchrW( mod->FullDllName.Buffer, '\\' );
397         if (name) name++;
398         else name = mod->FullDllName.Buffer;
399
400         TRACE("%s: %02x.%02x/%02x.%02x/%02x.%02x/%02x.%02x\n",
401               debugstr_w(name), ophd->MajorLinkerVersion, ophd->MinorLinkerVersion,
402               ophd->MajorOperatingSystemVersion, ophd->MinorOperatingSystemVersion,
403               ophd->MajorImageVersion, ophd->MinorImageVersion,
404               ophd->MajorSubsystemVersion, ophd->MinorSubsystemVersion);
405
406         for (i = 0; i < sizeof(special_dlls)/sizeof(special_dlls[0]); i++)
407         {
408             /* test if it is a special dll */
409             if (!strcmpiW(name, special_dlls[i]))
410             {
411                 DWORD DllVersion = VERSION_GetSystemDLLVersion(mod->BaseAddress);
412                 if (WinVersion == NB_WINDOWS_VERSIONS) WinVersion = DllVersion;
413                 else if (WinVersion != DllVersion)
414                 {
415                     ERR("You mixed system DLLs from different windows versions! Expect a crash! (%s: expected version %s, but is %s)\n",
416                         debugstr_w(name),
417                         debugstr_w(VersionData[WinVersion].szCSDVersion),
418                         debugstr_w(VersionData[DllVersion].szCSDVersion));
419                     return WIN20; /* this may let the exe exit */
420                 }
421                 break;
422             }
423         }
424     }
425
426     if(WinVersion != NB_WINDOWS_VERSIONS) return WinVersion;
427
428     /* we are using no external system dlls, look at the exe */
429     nt = RtlImageNtHeader(NtCurrentTeb()->Peb->ImageBaseAddress);
430     ophd = &nt->OptionalHeader;
431
432     TRACE("%02x.%02x/%02x.%02x/%02x.%02x/%02x.%02x\n",
433           ophd->MajorLinkerVersion, ophd->MinorLinkerVersion,
434           ophd->MajorOperatingSystemVersion, ophd->MinorOperatingSystemVersion,
435           ophd->MajorImageVersion, ophd->MinorImageVersion,
436           ophd->MajorSubsystemVersion, ophd->MinorSubsystemVersion);
437
438     /* special nt 3.51 */
439     if (3 == ophd->MajorOperatingSystemVersion && 51 == ophd->MinorOperatingSystemVersion)
440     {
441         return NT351;
442     }
443
444     /* the MajorSubsystemVersion is the only usable sign */
445     if (ophd->MajorSubsystemVersion < 4)
446     {
447         if ( ophd->MajorOperatingSystemVersion == 1
448              && ophd->MinorOperatingSystemVersion == 0)
449         {
450             return WIN31; /* win32s */
451         }
452
453         if (ophd->Subsystem == IMAGE_SUBSYSTEM_WINDOWS_CUI)
454             return NT351; /* FIXME: NT 3.1, not tested */
455         else
456             return WIN98;
457     }
458
459     return WIN98;
460 }
461
462 /**********************************************************************
463  *         VERSION_GetVersion
464  *
465  * WARNING !!!
466  * Don't call this function too early during the Wine init,
467  * as pdb->exe_modref (required by VERSION_GetImageVersion()) might still
468  * be NULL in such cases, which causes the winver to ALWAYS be detected
469  * as WIN31.
470  * And as we cache the winver once it has been determined, this is bad.
471  * This can happen much easier than you might think, as this function
472  * is called by EVERY GetVersion*() API !
473  *
474  */
475 static const RTL_OSVERSIONINFOEXW *VERSION_GetVersion(void)
476 {
477     static WORD winver = 0xffff;
478
479     if (versionForced)
480         return &VersionData[forcedWinVersion];  /* user has overridden any sensible checks */
481
482     if (winver == 0xffff) /* to be determined */
483     {
484         WINDOWS_VERSION retver = VERSION_GetLinkedDllVersion();
485
486         /* cache determined value, but do not store in case of WIN31 */
487         if (retver != WIN31) winver = retver;
488         return &VersionData[retver];
489     }
490     return &VersionData[winver];
491 }
492
493
494 /***********************************************************************
495  *         RtlGetVersion   (NTDLL.@)
496  */
497 NTSTATUS WINAPI RtlGetVersion( RTL_OSVERSIONINFOEXW *info )
498 {
499     const RTL_OSVERSIONINFOEXW * const current = VERSION_GetVersion();
500
501     info->dwMajorVersion = current->dwMajorVersion;
502     info->dwMinorVersion = current->dwMinorVersion;
503     info->dwBuildNumber  = current->dwBuildNumber;
504     info->dwPlatformId   = current->dwPlatformId;
505     strcpyW( info->szCSDVersion, current->szCSDVersion );
506     if(info->dwOSVersionInfoSize == sizeof(RTL_OSVERSIONINFOEXW))
507     {
508         info->wServicePackMajor = current->wServicePackMajor;
509         info->wServicePackMinor = current->wServicePackMinor;
510         info->wSuiteMask        = current->wSuiteMask;
511         info->wProductType      = current->wProductType;
512     }
513     TRACE("<-- %s (%s)\n", debug_names[current - VersionData], debugstr_w(current->szCSDVersion) );
514     return STATUS_SUCCESS;
515 }
516
517
518 /******************************************************************************
519  *  RtlGetNtVersionNumbers   (NTDLL.@)
520  *
521  * Get the version numbers of the run time library.
522  *
523  * PARAMS
524  *  major [O] Destination for the Major version
525  *  minor [O] Destination for the Minor version
526  *  build [O] Destination for the Build version
527  *
528  * RETURNS
529  *  Nothing.
530  *
531  * NOTES
532  * Introduced in Windows XP (NT5.1)
533  */
534 void WINAPI RtlGetNtVersionNumbers( LPDWORD major, LPDWORD minor, LPDWORD build )
535 {
536     const RTL_OSVERSIONINFOEXW * const current = VERSION_GetVersion();
537
538     if (major) *major = current->dwMajorVersion;
539     if (minor) *minor = current->dwMinorVersion;
540     /* FIXME: Does anybody know the real formula? */
541     if (build) *build = (0xF0000000 | current->dwBuildNumber);
542 }
543
544
545 /******************************************************************************
546  *        VerifyVersionInfoW   (KERNEL32.@)
547  */
548 NTSTATUS WINAPI RtlVerifyVersionInfo( const RTL_OSVERSIONINFOEXW *info,
549                                       DWORD dwTypeMask, DWORDLONG dwlConditionMask )
550 {
551     RTL_OSVERSIONINFOEXW ver;
552     NTSTATUS status;
553
554     FIXME("(%p,%lu,%llx): Not all cases correctly implemented yet\n",
555           info, dwTypeMask, dwlConditionMask);
556
557     /* FIXME:
558         - Check the following special case on Windows (various versions):
559           o lp->wSuiteMask == 0 and ver.wSuiteMask != 0 and VER_AND/VER_OR
560           o lp->dwOSVersionInfoSize != sizeof(OSVERSIONINFOEXW)
561         - MSDN talks about some tests being impossible. Check what really happens.
562      */
563
564     ver.dwOSVersionInfoSize = sizeof(ver);
565     if ((status = RtlGetVersion( &ver )) != STATUS_SUCCESS) return status;
566
567     if(!(dwTypeMask && dwlConditionMask)) return STATUS_INVALID_PARAMETER;
568
569     if(dwTypeMask & VER_PRODUCT_TYPE)
570         switch(dwlConditionMask >> 7*3 & 0x07) {
571             case VER_EQUAL:
572                 if(ver.wProductType != info->wProductType) return STATUS_REVISION_MISMATCH;
573                 break;
574             case VER_GREATER:
575                 if(ver.wProductType <= info->wProductType) return STATUS_REVISION_MISMATCH;
576                 break;
577             case VER_GREATER_EQUAL:
578                 if(ver.wProductType < info->wProductType) return STATUS_REVISION_MISMATCH;
579                 break;
580             case VER_LESS:
581                 if(ver.wProductType >= info->wProductType) return STATUS_REVISION_MISMATCH;
582                 break;
583             case VER_LESS_EQUAL:
584                 if(ver.wProductType > info->wProductType) return STATUS_REVISION_MISMATCH;
585                 break;
586             default:
587                 return STATUS_INVALID_PARAMETER;
588         }
589     if(dwTypeMask & VER_SUITENAME)
590         switch(dwlConditionMask >> 6*3 & 0x07)
591         {
592             case VER_AND:
593                 if((info->wSuiteMask & ver.wSuiteMask) != info->wSuiteMask)
594                     return STATUS_REVISION_MISMATCH;
595                 break;
596             case VER_OR:
597                 if(!(info->wSuiteMask & ver.wSuiteMask) && info->wSuiteMask)
598                     return STATUS_REVISION_MISMATCH;
599                 break;
600             default:
601                 return STATUS_INVALID_PARAMETER;
602         }
603     if(dwTypeMask & VER_PLATFORMID)
604         switch(dwlConditionMask >> 3*3 & 0x07)
605         {
606             case VER_EQUAL:
607                 if(ver.dwPlatformId != info->dwPlatformId) return STATUS_REVISION_MISMATCH;
608                 break;
609             case VER_GREATER:
610                 if(ver.dwPlatformId <= info->dwPlatformId) return STATUS_REVISION_MISMATCH;
611                 break;
612             case VER_GREATER_EQUAL:
613                 if(ver.dwPlatformId < info->dwPlatformId) return STATUS_REVISION_MISMATCH;
614                 break;
615             case VER_LESS:
616                 if(ver.dwPlatformId >= info->dwPlatformId) return STATUS_REVISION_MISMATCH;
617                 break;
618             case VER_LESS_EQUAL:
619                 if(ver.dwPlatformId > info->dwPlatformId) return STATUS_REVISION_MISMATCH;
620                 break;
621             default:
622                 return STATUS_INVALID_PARAMETER;
623         }
624     if(dwTypeMask & VER_BUILDNUMBER)
625         switch(dwlConditionMask >> 2*3 & 0x07)
626         {
627             case VER_EQUAL:
628                 if(ver.dwBuildNumber != info->dwBuildNumber) return STATUS_REVISION_MISMATCH;
629                 break;
630             case VER_GREATER:
631                 if(ver.dwBuildNumber <= info->dwBuildNumber) return STATUS_REVISION_MISMATCH;
632                 break;
633             case VER_GREATER_EQUAL:
634                 if(ver.dwBuildNumber < info->dwBuildNumber) return STATUS_REVISION_MISMATCH;
635                 break;
636             case VER_LESS:
637                 if(ver.dwBuildNumber >= info->dwBuildNumber) return STATUS_REVISION_MISMATCH;
638                 break;
639             case VER_LESS_EQUAL:
640                 if(ver.dwBuildNumber > info->dwBuildNumber) return STATUS_REVISION_MISMATCH;
641                 break;
642             default:
643                 return STATUS_INVALID_PARAMETER;
644         }
645     if(dwTypeMask & VER_MAJORVERSION)
646         switch(dwlConditionMask >> 1*3 & 0x07)
647         {
648             case VER_EQUAL:
649                 if(ver.dwMajorVersion != info->dwMajorVersion) return STATUS_REVISION_MISMATCH;
650                 break;
651             case VER_GREATER:
652                 if(ver.dwMajorVersion <= info->dwMajorVersion) return STATUS_REVISION_MISMATCH;
653                 break;
654             case VER_GREATER_EQUAL:
655                 if(ver.dwMajorVersion < info->dwMajorVersion) return STATUS_REVISION_MISMATCH;
656                 break;
657             case VER_LESS:
658                 if(ver.dwMajorVersion >= info->dwMajorVersion) return STATUS_REVISION_MISMATCH;
659                 break;
660             case VER_LESS_EQUAL:
661                 if(ver.dwMajorVersion > info->dwMajorVersion) return STATUS_REVISION_MISMATCH;
662                 break;
663             default:
664                 return STATUS_INVALID_PARAMETER;
665         }
666     if(dwTypeMask & VER_MINORVERSION)
667         switch(dwlConditionMask >> 0*3 & 0x07)
668         {
669             case VER_EQUAL:
670                 if(ver.dwMinorVersion != info->dwMinorVersion) return STATUS_REVISION_MISMATCH;
671                 break;
672             case VER_GREATER:
673                 if(ver.dwMinorVersion <= info->dwMinorVersion) return STATUS_REVISION_MISMATCH;
674                 break;
675             case VER_GREATER_EQUAL:
676                 if(ver.dwMinorVersion < info->dwMinorVersion) return STATUS_REVISION_MISMATCH;
677                 break;
678             case VER_LESS:
679                 if(ver.dwMinorVersion >= info->dwMinorVersion) return STATUS_REVISION_MISMATCH;
680                 break;
681             case VER_LESS_EQUAL:
682                 if(ver.dwMinorVersion > info->dwMinorVersion) return STATUS_REVISION_MISMATCH;
683                 break;
684             default:
685                 return STATUS_INVALID_PARAMETER;
686         }
687     if(dwTypeMask & VER_SERVICEPACKMAJOR)
688         switch(dwlConditionMask >> 5*3 & 0x07)
689         {
690             case VER_EQUAL:
691                 if(ver.wServicePackMajor != info->wServicePackMajor) return STATUS_REVISION_MISMATCH;
692                 break;
693             case VER_GREATER:
694                 if(ver.wServicePackMajor <= info->wServicePackMajor) return STATUS_REVISION_MISMATCH;
695                 break;
696             case VER_GREATER_EQUAL:
697                 if(ver.wServicePackMajor < info->wServicePackMajor) return STATUS_REVISION_MISMATCH;
698                 break;
699             case VER_LESS:
700                 if(ver.wServicePackMajor >= info->wServicePackMajor) return STATUS_REVISION_MISMATCH;
701                 break;
702             case VER_LESS_EQUAL:
703                 if(ver.wServicePackMajor > info->wServicePackMajor) return STATUS_REVISION_MISMATCH;
704                 break;
705             default:
706                 return STATUS_INVALID_PARAMETER;
707         }
708     if(dwTypeMask & VER_SERVICEPACKMINOR)
709         switch(dwlConditionMask >> 4*3 & 0x07)
710         {
711             case VER_EQUAL:
712                 if(ver.wServicePackMinor != info->wServicePackMinor) return STATUS_REVISION_MISMATCH;
713                 break;
714             case VER_GREATER:
715                 if(ver.wServicePackMinor <= info->wServicePackMinor) return STATUS_REVISION_MISMATCH;
716                 break;
717             case VER_GREATER_EQUAL:
718                 if(ver.wServicePackMinor < info->wServicePackMinor) return STATUS_REVISION_MISMATCH;
719                 break;
720             case VER_LESS:
721                 if(ver.wServicePackMinor >= info->wServicePackMinor) return STATUS_REVISION_MISMATCH;
722                 break;
723             case VER_LESS_EQUAL:
724                 if(ver.wServicePackMinor > info->wServicePackMinor) return STATUS_REVISION_MISMATCH;
725                 break;
726             default:
727                 return STATUS_INVALID_PARAMETER;
728         }
729
730     return STATUS_SUCCESS;
731 }