From 515d472b0f9dc5d7d26d68e3eeefdc3abcb77128 Mon Sep 17 00:00:00 2001 From: "KJK::Hyperion" Date: Sun, 7 Nov 2004 13:08:24 +0000 Subject: [PATCH] Implemented VerSetConditionMask. [HEADER HELL] VER_XXX macros defined inside the source file. Sorry svn path=/trunk/; revision=11571 --- reactos/lib/ntdll/def/ntdll.def | 3 +- reactos/lib/ntdll/makefile | 8 +++- reactos/lib/ntdll/ver/.cvsignore | 3 ++ reactos/lib/ntdll/ver/ver.c | 76 ++++++++++++++++++++++++++++++++ 4 files changed, 87 insertions(+), 3 deletions(-) create mode 100644 reactos/lib/ntdll/ver/.cvsignore create mode 100644 reactos/lib/ntdll/ver/ver.c diff --git a/reactos/lib/ntdll/def/ntdll.def b/reactos/lib/ntdll/def/ntdll.def index 6af815d2588..d0a9898bc3d 100644 --- a/reactos/lib/ntdll/def/ntdll.def +++ b/reactos/lib/ntdll/def/ntdll.def @@ -1,4 +1,4 @@ -; $Id: ntdll.def,v 1.132 2004/09/23 17:03:59 weiden Exp $ +; $Id: ntdll.def,v 1.133 2004/11/07 13:08:24 hyperion Exp $ ; ; ReactOS Operating System ; @@ -681,6 +681,7 @@ RtlxOemStringToUnicodeSize@4 RtlxUnicodeStringToAnsiSize@4 RtlxUnicodeStringToOemSize@4 ;SaveEm87Context +VerSetConditionMask@16 ZwAcceptConnectPort@24 ZwAccessCheck@32 ZwAccessCheckAndAuditAlarm@44 diff --git a/reactos/lib/ntdll/makefile b/reactos/lib/ntdll/makefile index bc194336f0a..56e681b1ff6 100644 --- a/reactos/lib/ntdll/makefile +++ b/reactos/lib/ntdll/makefile @@ -1,4 +1,4 @@ -# $Id: makefile,v 1.109 2004/09/10 23:29:18 sedwards Exp $ +# $Id: makefile,v 1.110 2004/11/07 13:08:24 hyperion Exp $ PATH_TO_TOP = ../.. @@ -122,6 +122,9 @@ STRING_OBJECTS = \ string/strupr.o \ string/wstring.o +VER_OBJECTS = \ + ver/ver.o + ARCH_OBJECTS = \ $(RTL_I386_OBJECTS) @@ -134,7 +137,8 @@ TARGET_OBJECTS = \ $(RTL_OBJECTS) \ $(STDIO_OBJECTS) \ $(STDLIB_OBJECTS) \ - $(STRING_OBJECTS) + $(STRING_OBJECTS) \ + $(VER_OBJECTS) DEP_OBJECTS = $(TARGET_OBJECTS) DEP_EXCLUDE_FILTER = napi.% diff --git a/reactos/lib/ntdll/ver/.cvsignore b/reactos/lib/ntdll/ver/.cvsignore new file mode 100644 index 00000000000..bd0e3dfd3ef --- /dev/null +++ b/reactos/lib/ntdll/ver/.cvsignore @@ -0,0 +1,3 @@ +*.d +*.o +*.sym diff --git a/reactos/lib/ntdll/ver/ver.c b/reactos/lib/ntdll/ver/ver.c new file mode 100644 index 00000000000..73fb0117bff --- /dev/null +++ b/reactos/lib/ntdll/ver/ver.c @@ -0,0 +1,76 @@ +/* $Id: ver.c,v 1.1 2004/11/07 13:08:24 hyperion Exp $ + * + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: ReactOS NT Layer DLL + * FILE: lib/ntdll/ver/ver.c + * PURPOSE: Operating system version checking + * PROGRAMMERS: KJK::Hyperion + * HISTORY: 2004-11-07: Created (imported from Wine) + */ + +#include + +/* + Header hell made me do it, don't blame me. Please move these somewhere more + sensible +*/ +#define VER_EQUAL 1 +#define VER_GREATER 2 +#define VER_GREATER_EQUAL 3 +#define VER_LESS 4 +#define VER_LESS_EQUAL 5 +#define VER_AND 6 +#define VER_OR 7 + +#define VER_CONDITION_MASK 7 +#define VER_NUM_BITS_PER_CONDITION_MASK 3 + +#define VER_MINORVERSION 0x0000001 +#define VER_MAJORVERSION 0x0000002 +#define VER_BUILDNUMBER 0x0000004 +#define VER_PLATFORMID 0x0000008 +#define VER_SERVICEPACKMINOR 0x0000010 +#define VER_SERVICEPACKMAJOR 0x0000020 +#define VER_SUITENAME 0x0000040 +#define VER_PRODUCT_TYPE 0x0000080 + +#define VER_NT_WORKSTATION 0x0000001 +#define VER_NT_DOMAIN_CONTROLLER 0x0000002 +#define VER_NT_SERVER 0x0000003 + +ULONGLONG NTAPI VerSetConditionMask +( + IN ULONGLONG dwlConditionMask, + IN DWORD dwTypeBitMask, + IN BYTE dwConditionMask +) +{ + if(dwTypeBitMask == 0) + return dwlConditionMask; + + dwConditionMask &= VER_CONDITION_MASK; + + if(dwConditionMask == 0) + return dwlConditionMask; + + if(dwTypeBitMask & VER_PRODUCT_TYPE) + dwlConditionMask |= dwConditionMask << 7 * VER_NUM_BITS_PER_CONDITION_MASK; + else if(dwTypeBitMask & VER_SUITENAME) + dwlConditionMask |= dwConditionMask << 6 * VER_NUM_BITS_PER_CONDITION_MASK; + else if(dwTypeBitMask & VER_SERVICEPACKMAJOR) + dwlConditionMask |= dwConditionMask << 5 * VER_NUM_BITS_PER_CONDITION_MASK; + else if(dwTypeBitMask & VER_SERVICEPACKMINOR) + dwlConditionMask |= dwConditionMask << 4 * VER_NUM_BITS_PER_CONDITION_MASK; + else if(dwTypeBitMask & VER_PLATFORMID) + dwlConditionMask |= dwConditionMask << 3 * VER_NUM_BITS_PER_CONDITION_MASK; + else if(dwTypeBitMask & VER_BUILDNUMBER) + dwlConditionMask |= dwConditionMask << 2 * VER_NUM_BITS_PER_CONDITION_MASK; + else if(dwTypeBitMask & VER_MAJORVERSION) + dwlConditionMask |= dwConditionMask << 1 * VER_NUM_BITS_PER_CONDITION_MASK; + else if(dwTypeBitMask & VER_MINORVERSION) + dwlConditionMask |= dwConditionMask << 0 * VER_NUM_BITS_PER_CONDITION_MASK; + + return dwlConditionMask; +} + +/* EOF */