1. added irql checks to various rtl and security functions

2. RtlGetVersion needs to be implemented differently in ntoskrnl and ntdll, ntoskrnl's version must not access the PEB (which might not be present) while ntdlls gets most information from the PEB structure
3. can't use spinlocks to serialize access to the security descriptor cache since it calls sd rtl functions which require to run < apc level

svn path=/trunk/; revision=13712
This commit is contained in:
Thomas Bluemel 2005-02-22 17:58:19 +00:00
parent 2020a93026
commit ea5929db62
26 changed files with 399 additions and 86 deletions

View file

@ -129,7 +129,7 @@ typedef union _SLIST_HEADER
ULONGLONG Alignment;
struct
{
SINGLE_LIST_ENTRY Next;
SLIST_ENTRY Next;
USHORT Depth;
USHORT Sequence;
}; /* now anonymous */

View file

@ -42,3 +42,10 @@
#define MAGIC(c1,c2,c3,c4) ((c1) + ((c2)<<8) + ((c3)<<16) + ((c4)<<24))
#define MAGIC_HEAP MAGIC( 'H','E','A','P' )
#ifdef DBG
extern VOID FASTCALL CHECK_PAGED_CODE_RTL(char *file, int line);
#define PAGED_CODE_RTL() CHECK_PAGED_CODE_RTL(__FILE__, __LINE__)
#else
#define PAGED_CODE_RTL()
#endif

View file

@ -14,6 +14,12 @@
extern "C" {
#endif /* __cplusplus */
#ifdef DBG
extern VOID FASTCALL CHECK_PAGED_CODE_RTL(char *file, int line);
#define PAGED_CODE_RTL() CHECK_PAGED_CODE_RTL(__FILE__, __LINE__)
#else
#define PAGED_CODE_RTL()
#endif
#ifndef __USE_W32API

View file

@ -13,6 +13,10 @@ TARGET_CFLAGS = -g -D__NTDLL__ -Werror -Wall
# require os code to explicitly request A/W version of structs/functions
TARGET_CFLAGS += -D_DISABLE_TIDENTS
ifneq ($(DBG), 0)
TARGET_CFLAGS += -DDBG
endif
TARGET_ASFLAGS = -I $(PATH_TO_TOP)/include
TARGET_LFLAGS = -Wl,--file-alignment,0x1000 \

View file

@ -55,3 +55,12 @@ ExFreePool(IN PVOID Mem)
0,
Mem);
}
#ifdef DBG
VOID FASTCALL
CHECK_PAGED_CODE_RTL(char *file, int line)
{
/* meaningless in user mode */
}
#endif

View file

@ -324,4 +324,47 @@ RtlCreateUserProcess(PUNICODE_STRING ImageFileName,
return(STATUS_SUCCESS);
}
/*
* @implemented
*/
NTSTATUS STDCALL
RtlGetVersion(RTL_OSVERSIONINFOW *Info)
{
if (Info->dwOSVersionInfoSize == sizeof(RTL_OSVERSIONINFOW) ||
Info->dwOSVersionInfoSize == sizeof(RTL_OSVERSIONINFOEXW))
{
PPEB Peb = NtCurrentPeb();
Info->dwMajorVersion = Peb->OSMajorVersion;
Info->dwMinorVersion = Peb->OSMinorVersion;
Info->dwBuildNumber = Peb->OSBuildNumber;
Info->dwPlatformId = Peb->OSPlatformId;
if(((Peb->OSCSDVersion >> 8) & 0xFF) != 0)
{
int i = _snwprintf(Info->szCSDVersion,
(sizeof(Info->szCSDVersion) / sizeof(Info->szCSDVersion[0])) - 1,
L"Service Pack %d",
((Peb->OSCSDVersion >> 8) & 0xFF));
Info->szCSDVersion[i] = L'\0';
}
else
{
RtlZeroMemory(Info->szCSDVersion, sizeof(Info->szCSDVersion));
}
if (Info->dwOSVersionInfoSize == sizeof(RTL_OSVERSIONINFOEXW))
{
RTL_OSVERSIONINFOEXW *InfoEx = (RTL_OSVERSIONINFOEXW *)Info;
InfoEx->wServicePackMajor = (Peb->OSCSDVersion >> 8) & 0xFF;
InfoEx->wServicePackMinor = Peb->OSCSDVersion & 0xFF;
InfoEx->wSuiteMask = SharedUserData->SuiteMask;
InfoEx->wProductType = SharedUserData->NtProductType;
}
return STATUS_SUCCESS;
}
return STATUS_INVALID_PARAMETER;
}
/* EOF */

View file

@ -12,7 +12,7 @@
/* INCLUDES *****************************************************************/
#include <ddk/ntddk.h>
#include <ntos/rtl.h>
#include <ntdll/rtl.h>
#define NDEBUG
#include <debug.h>
@ -26,6 +26,8 @@ RtlFirstFreeAce(PACL Acl,
PACE Current;
PVOID AclEnd;
ULONG i;
PAGED_CODE_RTL();
Current = (PACE)(Acl + 1);
*Ace = NULL;
@ -70,6 +72,8 @@ RtlGetAce(PACL Acl,
PACE *Ace)
{
ULONG i;
PAGED_CODE_RTL();
*Ace = (PACE)(Acl + 1);
@ -111,6 +115,8 @@ RtlpAddKnownAce (PACL Acl,
ULONG Type)
{
PACE Ace;
PAGED_CODE_RTL();
if (!RtlValidSid(Sid))
{
@ -158,6 +164,8 @@ RtlAddAccessAllowedAce (IN OUT PACL Acl,
IN ACCESS_MASK AccessMask,
IN PSID Sid)
{
PAGED_CODE_RTL();
return RtlpAddKnownAce (Acl,
Revision,
0,
@ -177,6 +185,8 @@ RtlAddAccessAllowedAceEx (IN OUT PACL Acl,
IN ACCESS_MASK AccessMask,
IN PSID Sid)
{
PAGED_CODE_RTL();
return RtlpAddKnownAce (Acl,
Revision,
Flags,
@ -195,6 +205,8 @@ RtlAddAccessDeniedAce (PACL Acl,
ACCESS_MASK AccessMask,
PSID Sid)
{
PAGED_CODE_RTL();
return RtlpAddKnownAce (Acl,
Revision,
0,
@ -214,6 +226,8 @@ RtlAddAccessDeniedAceEx (IN OUT PACL Acl,
IN ACCESS_MASK AccessMask,
IN PSID Sid)
{
PAGED_CODE_RTL();
return RtlpAddKnownAce (Acl,
Revision,
Flags,
@ -259,6 +273,8 @@ RtlAddAce(PACL Acl,
ULONG i;
PACE Current;
ULONG j;
PAGED_CODE_RTL();
if (Acl->AclRevision < MIN_ACL_REVISION ||
Acl->AclRevision > MAX_ACL_REVISION)
@ -339,6 +355,8 @@ RtlAddAuditAccessAce(PACL Acl,
{
PACE Ace;
ULONG Flags = 0;
PAGED_CODE_RTL();
if (Success != FALSE)
{
@ -408,6 +426,8 @@ RtlAddAuditAccessAceEx(PACL Acl,
BOOLEAN Failure)
{
PACE Ace;
PAGED_CODE_RTL();
if (Success != FALSE)
{
@ -494,6 +514,8 @@ RtlDeleteAce(PACL Acl,
{
PACE Ace;
PACE Current;
PAGED_CODE_RTL();
if (Acl->AclRevision < MIN_ACL_REVISION ||
Acl->AclRevision > MAX_ACL_REVISION)
@ -535,6 +557,8 @@ RtlCreateAcl(PACL Acl,
ULONG AclSize,
ULONG AclRevision)
{
PAGED_CODE_RTL();
if (AclSize < 8)
{
return(STATUS_BUFFER_TOO_SMALL);
@ -572,6 +596,8 @@ RtlQueryInformationAcl(PACL Acl,
ACL_INFORMATION_CLASS InformationClass)
{
PACE Ace;
PAGED_CODE_RTL();
if (Acl->AclRevision < MIN_ACL_REVISION ||
Acl->AclRevision > MAX_ACL_REVISION)
@ -638,6 +664,8 @@ RtlSetInformationAcl(PACL Acl,
ULONG InformationLength,
ACL_INFORMATION_CLASS InformationClass)
{
PAGED_CODE_RTL();
if (Acl->AclRevision < MIN_ACL_REVISION ||
Acl->AclRevision > MAX_ACL_REVISION)
{
@ -680,6 +708,8 @@ RtlValidAcl (PACL Acl)
{
PACE Ace;
USHORT Size;
PAGED_CODE_RTL();
Size = ROUND_UP(Acl->AclSize, 4);

View file

@ -12,6 +12,7 @@
/* INCLUDES *****************************************************************/
#include <ddk/ntddk.h>
#include <ntdll/rtl.h>
#define NDEBUG
#include <debug.h>
@ -22,6 +23,8 @@ VOID STDCALL
RtlCopyLuid(PLUID LuidDest,
PLUID LuidSrc)
{
PAGED_CODE_RTL();
LuidDest->LowPart = LuidSrc->LowPart;
LuidDest->HighPart = LuidSrc->HighPart;
}
@ -36,6 +39,8 @@ RtlCopyLuidAndAttributesArray(ULONG Count,
PLUID_AND_ATTRIBUTES Dest)
{
ULONG i;
PAGED_CODE_RTL();
for (i = 0; i < Count; i++)
{
@ -53,6 +58,8 @@ BOOLEAN STDCALL
RtlEqualLuid(PLUID Luid1,
PLUID Luid2)
{
PAGED_CODE_RTL();
return (Luid1->LowPart == Luid2->LowPart &&
Luid1->HighPart == Luid2->HighPart);
}

View file

@ -12,6 +12,10 @@ TARGET_CFLAGS = -Wall -Werror -ffreestanding
# require os code to explicitly request A/W version of structs/functions
TARGET_CFLAGS += -D_DISABLE_TIDENTS
ifneq ($(DBG), 0)
TARGET_CFLAGS += -DDBG
endif
TARGET_OBJECTS = \
acl.o \
bit.o \

View file

@ -113,6 +113,8 @@ NTSTATUS STDCALL
RtlCreateSecurityDescriptor(PSECURITY_DESCRIPTOR SecurityDescriptor,
ULONG Revision)
{
PAGED_CODE_RTL();
if (Revision != SECURITY_DESCRIPTOR_REVISION1)
{
return STATUS_UNKNOWN_REVISION;
@ -134,6 +136,8 @@ NTSTATUS STDCALL
RtlCreateSecurityDescriptorRelative (PSECURITY_DESCRIPTOR_RELATIVE SecurityDescriptor,
ULONG Revision)
{
PAGED_CODE_RTL();
if (Revision != SECURITY_DESCRIPTOR_REVISION1)
{
return STATUS_UNKNOWN_REVISION;
@ -161,6 +165,8 @@ RtlLengthSecurityDescriptor(PSECURITY_DESCRIPTOR SecurityDescriptor)
PACL Sacl, Dacl;
ULONG Length = sizeof(SECURITY_DESCRIPTOR);
PAGED_CODE_RTL();
RtlpQuerySecurityDescriptorPointers(SecurityDescriptor,
&Owner,
&Group,
@ -200,6 +206,8 @@ RtlGetDaclSecurityDescriptor(PSECURITY_DESCRIPTOR SecurityDescriptor,
PACL* Dacl,
PBOOLEAN DaclDefaulted)
{
PAGED_CODE_RTL();
if (SecurityDescriptor->Revision != SECURITY_DESCRIPTOR_REVISION1)
{
return STATUS_UNKNOWN_REVISION;
@ -233,6 +241,8 @@ RtlSetDaclSecurityDescriptor(PSECURITY_DESCRIPTOR SecurityDescriptor,
PACL Dacl,
BOOLEAN DaclDefaulted)
{
PAGED_CODE_RTL();
if (SecurityDescriptor->Revision != SECURITY_DESCRIPTOR_REVISION1)
{
return STATUS_UNKNOWN_REVISION;
@ -270,6 +280,8 @@ RtlValidSecurityDescriptor(PSECURITY_DESCRIPTOR SecurityDescriptor)
{
PSID Owner, Group;
PACL Sacl, Dacl;
PAGED_CODE_RTL();
if (SecurityDescriptor->Revision != SECURITY_DESCRIPTOR_REVISION1)
{
@ -302,6 +314,8 @@ RtlSetOwnerSecurityDescriptor(PSECURITY_DESCRIPTOR SecurityDescriptor,
PSID Owner,
BOOLEAN OwnerDefaulted)
{
PAGED_CODE_RTL();
if (SecurityDescriptor->Revision != SECURITY_DESCRIPTOR_REVISION1)
{
return STATUS_UNKNOWN_REVISION;
@ -332,6 +346,8 @@ RtlGetOwnerSecurityDescriptor(PSECURITY_DESCRIPTOR SecurityDescriptor,
PSID* Owner,
PBOOLEAN OwnerDefaulted)
{
PAGED_CODE_RTL();
if (SecurityDescriptor->Revision != SECURITY_DESCRIPTOR_REVISION1)
{
return STATUS_UNKNOWN_REVISION;
@ -357,6 +373,8 @@ RtlSetGroupSecurityDescriptor(PSECURITY_DESCRIPTOR SecurityDescriptor,
PSID Group,
BOOLEAN GroupDefaulted)
{
PAGED_CODE_RTL();
if (SecurityDescriptor->Revision != SECURITY_DESCRIPTOR_REVISION1)
{
return STATUS_UNKNOWN_REVISION;
@ -386,6 +404,8 @@ RtlGetGroupSecurityDescriptor(PSECURITY_DESCRIPTOR SecurityDescriptor,
PSID* Group,
PBOOLEAN GroupDefaulted)
{
PAGED_CODE_RTL();
if (SecurityDescriptor->Revision != SECURITY_DESCRIPTOR_REVISION1)
{
return STATUS_UNKNOWN_REVISION;
@ -421,6 +441,8 @@ RtlMakeSelfRelativeSD(PSECURITY_DESCRIPTOR AbsSD,
ULONG DaclLength;
ULONG TotalLength;
ULONG_PTR Current;
PAGED_CODE_RTL();
RtlpQuerySecurityDescriptor(AbsSD,
&Owner,
@ -494,6 +516,8 @@ RtlAbsoluteToSelfRelativeSD(PSECURITY_DESCRIPTOR AbsSD,
PSECURITY_DESCRIPTOR_RELATIVE RelSD,
PULONG BufferLength)
{
PAGED_CODE_RTL();
if (AbsSD->Control & SE_SELF_RELATIVE)
{
return STATUS_BAD_DESCRIPTOR_FORMAT;
@ -511,6 +535,8 @@ RtlGetControlSecurityDescriptor(PSECURITY_DESCRIPTOR SecurityDescriptor,
PSECURITY_DESCRIPTOR_CONTROL Control,
PULONG Revision)
{
PAGED_CODE_RTL();
*Revision = SecurityDescriptor->Revision;
if (SecurityDescriptor->Revision != SECURITY_DESCRIPTOR_REVISION1)
@ -532,6 +558,8 @@ RtlSetControlSecurityDescriptor(IN PSECURITY_DESCRIPTOR SecurityDescriptor,
IN SECURITY_DESCRIPTOR_CONTROL ControlBitsOfInterest,
IN SECURITY_DESCRIPTOR_CONTROL ControlBitsToSet)
{
PAGED_CODE_RTL();
if (SecurityDescriptor->Revision != SECURITY_DESCRIPTOR_REVISION1)
{
return STATUS_UNKNOWN_REVISION;
@ -556,6 +584,8 @@ RtlGetSaclSecurityDescriptor(PSECURITY_DESCRIPTOR SecurityDescriptor,
PACL *Sacl,
PBOOLEAN SaclDefaulted)
{
PAGED_CODE_RTL();
if (SecurityDescriptor->Revision != SECURITY_DESCRIPTOR_REVISION1)
{
return STATUS_UNKNOWN_REVISION;
@ -589,6 +619,8 @@ RtlSetSaclSecurityDescriptor(PSECURITY_DESCRIPTOR SecurityDescriptor,
PACL Sacl,
BOOLEAN SaclDefaulted)
{
PAGED_CODE_RTL();
if (SecurityDescriptor->Revision != SECURITY_DESCRIPTOR_REVISION1)
{
return STATUS_UNKNOWN_REVISION;
@ -642,6 +674,8 @@ RtlSelfRelativeToAbsoluteSD(PSECURITY_DESCRIPTOR_RELATIVE RelSD,
PSID pGroup;
PACL pDacl;
PACL pSacl;
PAGED_CODE_RTL();
if (RelSD->Revision != SECURITY_DESCRIPTOR_REVISION1)
{
@ -713,6 +747,8 @@ RtlValidRelativeSecurityDescriptor(IN PSECURITY_DESCRIPTOR_RELATIVE SecurityDesc
IN ULONG SecurityDescriptorLength,
IN SECURITY_INFORMATION RequiredInformation)
{
PAGED_CODE_RTL();
if (SecurityDescriptorLength < sizeof(SECURITY_DESCRIPTOR_RELATIVE) ||
SecurityDescriptorInput->Revision != SECURITY_DESCRIPTOR_REVISION1 ||
!(SecurityDescriptorInput->Control & SE_SELF_RELATIVE))
@ -783,6 +819,8 @@ BOOLEAN STDCALL
RtlGetSecurityDescriptorRMControl(PSECURITY_DESCRIPTOR SecurityDescriptor,
PUCHAR RMControl)
{
PAGED_CODE_RTL();
if (!(SecurityDescriptor->Control & SE_RM_CONTROL_VALID))
{
*RMControl = 0;
@ -802,6 +840,8 @@ VOID STDCALL
RtlSetSecurityDescriptorRMControl(PSECURITY_DESCRIPTOR SecurityDescriptor,
PUCHAR RMControl)
{
PAGED_CODE_RTL();
if (RMControl == NULL)
{
SecurityDescriptor->Control &= ~SE_RM_CONTROL_VALID;
@ -823,6 +863,8 @@ RtlSetAttributesSecurityDescriptor(IN PSECURITY_DESCRIPTOR SecurityDescriptor,
IN SECURITY_DESCRIPTOR_CONTROL Control,
OUT PULONG Revision)
{
PAGED_CODE_RTL();
*Revision = SecurityDescriptor->Revision;
if (SecurityDescriptor->Revision != SECURITY_DESCRIPTOR_REVISION1)

View file

@ -28,7 +28,9 @@ RtlImpersonateSelf(IN SECURITY_IMPERSONATION_LEVEL ImpersonationLevel)
HANDLE ImpersonationToken;
NTSTATUS Status;
OBJECT_ATTRIBUTES ObjAttr;
SECURITY_QUALITY_OF_SERVICE Sqos;
SECURITY_QUALITY_OF_SERVICE Sqos;
PAGED_CODE_RTL();
Status = NtOpenProcessToken(NtCurrentProcess(),
TOKEN_DUPLICATE,
@ -97,6 +99,8 @@ RtlAdjustPrivilege(IN ULONG Privilege,
ULONG ReturnLength;
HANDLE TokenHandle;
NTSTATUS Status;
PAGED_CODE_RTL();
DPRINT ("RtlAdjustPrivilege() called\n");

View file

@ -13,6 +13,7 @@
#define __NTDRIVER__
#include <ddk/ntddk.h>
#include <ntdll/rtl.h>
#include <string.h>
@ -26,6 +27,8 @@ RtlValidSid(IN PSID Sid_)
{
PISID Sid = Sid_;
PAGED_CODE_RTL();
if ((Sid->Revision != SID_REVISION) ||
(Sid->SubAuthorityCount > SID_MAX_SUB_AUTHORITIES))
{
@ -42,6 +45,8 @@ RtlValidSid(IN PSID Sid_)
ULONG STDCALL
RtlLengthRequiredSid(IN UCHAR SubAuthorityCount)
{
PAGED_CODE_RTL();
return (sizeof(SID) + (SubAuthorityCount - 1) * sizeof(ULONG));
}
@ -56,6 +61,8 @@ RtlInitializeSid(IN PSID Sid_,
{
PISID Sid = Sid_;
PAGED_CODE_RTL();
Sid->Revision = SID_REVISION;
Sid->SubAuthorityCount = SubAuthorityCount;
memcpy(&Sid->IdentifierAuthority,
@ -75,6 +82,8 @@ RtlSubAuthoritySid(IN PSID Sid_,
{
PISID Sid = Sid_;
PAGED_CODE_RTL();
return &Sid->SubAuthority[SubAuthority];
}
@ -87,6 +96,8 @@ RtlSubAuthorityCountSid(IN PSID Sid_)
{
PISID Sid = Sid_;
PAGED_CODE_RTL();
return &Sid->SubAuthorityCount;
}
@ -100,6 +111,8 @@ RtlEqualSid(IN PSID Sid1_,
{
PISID Sid1 = Sid1_;
PISID Sid2 = Sid2_;
PAGED_CODE_RTL();
if (Sid1->Revision != Sid2->Revision)
{
@ -125,6 +138,8 @@ RtlLengthSid(IN PSID Sid_)
{
PISID Sid = Sid_;
PAGED_CODE_RTL();
return (sizeof(SID) + (Sid->SubAuthorityCount-1) * sizeof(ULONG));
}
@ -137,6 +152,8 @@ RtlCopySid(ULONG BufferLength,
PSID Dest,
PSID Src)
{
PAGED_CODE_RTL();
if (BufferLength < RtlLengthSid(Src))
{
return STATUS_UNSUCCESSFUL;
@ -165,6 +182,8 @@ RtlCopySidAndAttributesArray(ULONG Count,
ULONG SidLength;
ULONG Length;
ULONG i;
PAGED_CODE_RTL();
Length = SidAreaSize;
@ -197,6 +216,8 @@ RtlIdentifierAuthoritySid(IN PSID Sid_)
{
PISID Sid = Sid_;
PAGED_CODE_RTL();
return &Sid->IdentifierAuthority;
}
@ -218,6 +239,8 @@ RtlAllocateAndInitializeSid(PSID_IDENTIFIER_AUTHORITY IdentifierAuthority,
PSID *Sid)
{
PISID pSid;
PAGED_CODE_RTL();
if (SubAuthorityCount > 8)
return STATUS_INVALID_SID;
@ -273,6 +296,8 @@ RtlAllocateAndInitializeSid(PSID_IDENTIFIER_AUTHORITY IdentifierAuthority,
PVOID STDCALL
RtlFreeSid(IN PSID Sid)
{
PAGED_CODE_RTL();
ExFreePool(Sid);
return NULL;
}
@ -287,6 +312,8 @@ RtlEqualPrefixSid(IN PSID Sid1_,
{
PISID Sid1 = Sid1_;
PISID Sid2 = Sid2_;
PAGED_CODE_RTL();
return(Sid1->SubAuthorityCount == Sid2->SubAuthorityCount &&
!RtlCompareMemory(Sid1, Sid2,
@ -307,6 +334,8 @@ RtlConvertSidToUnicodeString(PUNICODE_STRING String,
ULONG Length;
ULONG i;
PISID Sid = Sid_;
PAGED_CODE_RTL();
if (RtlValidSid (Sid) == FALSE)
return STATUS_INVALID_SID;

View file

@ -14,6 +14,7 @@
#include <ddk/ntddk.h>
#include <ntos/registry.h>
#include <ntos/time.h>
#include <ntdll/rtl.h>
#define NDEBUG
#include <debug.h>
@ -33,6 +34,8 @@ RtlQueryTimeZoneInformation(PTIME_ZONE_INFORMATION TimeZoneInformation)
NTSTATUS Status;
DPRINT("RtlQueryTimeZoneInformation()\n");
PAGED_CODE_RTL();
RtlZeroMemory(QueryTable,
sizeof(QueryTable));
@ -93,6 +96,8 @@ RtlSetTimeZoneInformation(PTIME_ZONE_INFORMATION TimeZoneInformation)
NTSTATUS Status;
DPRINT("RtlSetTimeZoneInformation()\n");
PAGED_CODE_RTL();
Status = RtlWriteRegistryValue(RTL_REGISTRY_CONTROL,
L"TimeZoneInformation",

View file

@ -39,37 +39,6 @@
/* FUNCTIONS ****************************************************************/
/*
* @implemented
*/
NTSTATUS STDCALL
RtlGetVersion(RTL_OSVERSIONINFOW *Info)
{
WCHAR CSDString[] = L"Service Pack 6";
if (Info->dwOSVersionInfoSize == sizeof(RTL_OSVERSIONINFOW) ||
Info->dwOSVersionInfoSize == sizeof(RTL_OSVERSIONINFOEXW))
{
Info->dwMajorVersion = 4;
Info->dwMinorVersion = 0;
Info->dwBuildNumber = 1381;
Info->dwPlatformId = VER_PLATFORM_WIN32_NT;
RtlCopyMemory(Info->szCSDVersion, CSDString, sizeof(CSDString));
if (Info->dwOSVersionInfoSize == sizeof(RTL_OSVERSIONINFOEXW))
{
RTL_OSVERSIONINFOEXW *InfoEx = (RTL_OSVERSIONINFOEXW *)Info;
InfoEx->wServicePackMajor = 6;
InfoEx->wServicePackMinor = 0;
InfoEx->wSuiteMask = 0;
InfoEx->wProductType = VER_NT_WORKSTATION;
}
return STATUS_SUCCESS;
}
return STATUS_INVALID_PARAMETER;
}
/*
* @unimplemented
*/
@ -114,39 +83,37 @@ RtlVerifyVersionInfo(
/*
* @implemented
*/
ULONGLONG NTAPI VerSetConditionMask
(
IN ULONGLONG dwlConditionMask,
IN DWORD dwTypeBitMask,
IN BYTE dwConditionMask
)
ULONGLONG NTAPI
VerSetConditionMask(IN ULONGLONG dwlConditionMask,
IN DWORD dwTypeBitMask,
IN BYTE dwConditionMask)
{
if(dwTypeBitMask == 0)
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;
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 */

View file

@ -54,6 +54,10 @@ else
TARGET_BASE = 0x80000000
endif
ifneq ($(DBG), 0)
TARGET_CFLAGS += -DDBG
endif
# enable thread event pair features (NT4 only!)
# TARGET_CFLAGS += -D_ENABLE_THRDEVTPAIR

View file

@ -65,4 +65,23 @@
#include <pseh.h>
#ifdef DBG
#ifndef PAGED_CODE
#define PAGED_CODE() \
do { \
if(KeGetCurrentIrql() > APC_LEVEL) { \
DbgPrint("%s:%i: Pagable code called at IRQL > APC_LEVEL (%d)\n", \
__FILE__, __LINE__, KeGetCurrentIrql()); \
KEBUGCHECK(0); \
} \
} while(0)
#endif
#define PAGED_CODE_RTL PAGED_CODE
#else
#ifndef PAGED_CODE
#define PAGED_CODE()
#endif
#define PAGED_CODE_RTL()
#endif
#endif /* INCLUDE_NTOSKRNL_H */

View file

@ -31,6 +31,10 @@
/* GLOBALS *******************************************************************/
#define BUILD_OSCSDVERSION(major, minor) (((major & 0xFF) << 8) | (minor & 0xFF))
ULONG NtMajorVersion = 4;
ULONG NtMinorVersion = 0;
ULONG NtOSCSDVersion = BUILD_OSCSDVERSION(6, 0);
#ifdef __GNUC__
ULONG EXPORTED NtBuildNumber = KERNEL_VERSION_BUILD;
ULONG EXPORTED NtGlobalFlag = 0;

View file

@ -28,13 +28,11 @@ typedef struct _SD_CACHE_ENTRY
/* GLOBALS ******************************************************************/
PLIST_ENTRY ObpSdCache;
KSPIN_LOCK ObpSdCacheSpinLock;
KIRQL ObpSdCacheIrql;
#define SD_CACHE_ENTRIES 0x100
LIST_ENTRY ObpSdCache[SD_CACHE_ENTRIES];
FAST_MUTEX ObpSdCacheMutex;
/* FUNCTIONS ****************************************************************/
NTSTATUS
@ -42,37 +40,36 @@ ObpInitSdCache(VOID)
{
ULONG i;
ObpSdCache = ExAllocatePool(NonPagedPool,
SD_CACHE_ENTRIES * sizeof(LIST_ENTRY));
if (ObpSdCache == NULL)
{
return STATUS_INSUFFICIENT_RESOURCES;
}
for (i = 0; i < SD_CACHE_ENTRIES; i++)
for (i = 0; i < (sizeof(ObpSdCache) / sizeof(ObpSdCache[0])); i++)
{
InitializeListHead(&ObpSdCache[i]);
}
KeInitializeSpinLock(&ObpSdCacheSpinLock);
ExInitializeFastMutex(&ObpSdCacheMutex);
return STATUS_SUCCESS;
}
static VOID
static inline VOID
ObpSdCacheLock(VOID)
{
KeAcquireSpinLock(&ObpSdCacheSpinLock,
&ObpSdCacheIrql);
/* can't acquire a fast mutex in the early boot process... */
if(KeGetCurrentThread() != NULL)
{
ExAcquireFastMutex(&ObpSdCacheMutex);
}
}
static VOID
static inline VOID
ObpSdCacheUnlock(VOID)
{
KeReleaseSpinLock(&ObpSdCacheSpinLock,
ObpSdCacheIrql);
/* can't acquire a fast mutex in the early boot process... */
if(KeGetCurrentThread() != NULL)
{
ExReleaseFastMutex(&ObpSdCacheMutex);
}
}

View file

@ -1,4 +1,4 @@
/* $Id:$
/* $Id$
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@ -109,4 +109,17 @@ RtlInitializeCriticalSectionAndSpinCount(
return STATUS_SUCCESS;
}
#ifdef DBG
VOID FASTCALL
CHECK_PAGED_CODE_RTL(char *file, int line)
{
if(KeGetCurrentIrql() > APC_LEVEL)
{
DbgPrint("%s:%i: Pagable code called at IRQL > APC_LEVEL (%d)\n", file, line, KeGetCurrentIrql());
KEBUGCHECK(0);
}
}
#endif
/* EOF */

View file

@ -17,6 +17,37 @@
/* GLOBALS *******************************************************************/
extern ULONG NtGlobalFlag;
extern ULONG NtMajorVersion;
extern ULONG NtMinorVersion;
extern ULONG NtOSCSDVersion;
/* header hell made me do this...sorry */
typedef struct _OSVERSIONINFOW {
DWORD dwOSVersionInfoSize;
DWORD dwMajorVersion;
DWORD dwMinorVersion;
DWORD dwBuildNumber;
DWORD dwPlatformId;
WCHAR szCSDVersion[ 128 ];
} OSVERSIONINFOW, *POSVERSIONINFOW, *LPOSVERSIONINFOW, RTL_OSVERSIONINFOW, *PRTL_OSVERSIONINFOW;
typedef struct _OSVERSIONINFOEXW {
DWORD dwOSVersionInfoSize;
DWORD dwMajorVersion;
DWORD dwMinorVersion;
DWORD dwBuildNumber;
DWORD dwPlatformId;
WCHAR szCSDVersion[ 128 ];
WORD wServicePackMajor;
WORD wServicePackMinor;
WORD wSuiteMask;
BYTE wProductType;
BYTE wReserved;
} OSVERSIONINFOEXW, *POSVERSIONINFOEXW, *LPOSVERSIONINFOEXW, RTL_OSVERSIONINFOEXW, *PRTL_OSVERSIONINFOEXW;
#ifndef VER_PLATFORM_WIN32_NT
#define VER_PLATFORM_WIN32_NT (2)
#endif
/* FUNCTIONS *****************************************************************/
@ -29,3 +60,45 @@ RtlGetNtGlobalFlags(VOID)
{
return(NtGlobalFlag);
}
/*
* @implemented
*/
NTSTATUS STDCALL
RtlGetVersion(IN OUT PRTL_OSVERSIONINFOW lpVersionInformation)
{
if (lpVersionInformation->dwOSVersionInfoSize == sizeof(RTL_OSVERSIONINFOW) ||
lpVersionInformation->dwOSVersionInfoSize == sizeof(RTL_OSVERSIONINFOEXW))
{
lpVersionInformation->dwMajorVersion = NtMajorVersion;
lpVersionInformation->dwMinorVersion = NtMinorVersion;
lpVersionInformation->dwBuildNumber = NtBuildNumber;
lpVersionInformation->dwPlatformId = VER_PLATFORM_WIN32_NT;
if(((NtOSCSDVersion >> 8) & 0xFF) != 0)
{
int i = _snwprintf(lpVersionInformation->szCSDVersion,
(sizeof(lpVersionInformation->szCSDVersion) / sizeof(lpVersionInformation->szCSDVersion[0])) - 1,
L"Service Pack %d",
((NtOSCSDVersion >> 8) & 0xFF));
lpVersionInformation->szCSDVersion[i] = L'\0';
}
else
{
RtlZeroMemory(lpVersionInformation->szCSDVersion, sizeof(lpVersionInformation->szCSDVersion));
}
if (lpVersionInformation->dwOSVersionInfoSize == sizeof(OSVERSIONINFOEXW))
{
RTL_OSVERSIONINFOEXW *InfoEx = (RTL_OSVERSIONINFOEXW *)lpVersionInformation;
InfoEx->wServicePackMajor = (NtOSCSDVersion >> 8) & 0xFF;
InfoEx->wServicePackMinor = NtOSCSDVersion & 0xFF;
InfoEx->wSuiteMask = SharedUserData->SuiteMask;
InfoEx->wProductType = SharedUserData->NtProductType;
}
return STATUS_SUCCESS;
}
return STATUS_INVALID_PARAMETER;
}

View file

@ -26,6 +26,8 @@ RtlAreAllAccessesGranted (
ACCESS_MASK DesiredAccess
)
{
PAGED_CODE_RTL();
return ((GrantedAccess & DesiredAccess) == DesiredAccess);
}
@ -40,6 +42,8 @@ RtlAreAnyAccessesGranted (
ACCESS_MASK DesiredAccess
)
{
PAGED_CODE_RTL();
return ((GrantedAccess & DesiredAccess) != 0);
}
@ -54,6 +58,8 @@ RtlMapGenericMask (
PGENERIC_MAPPING GenericMapping
)
{
PAGED_CODE_RTL();
if (*AccessMask & GENERIC_READ)
*AccessMask |= GenericMapping->GenericRead;

View file

@ -225,6 +225,8 @@ SepCreateImpersonationTokenDacl(PTOKEN Token,
{
ULONG AclLength;
PVOID TokenDacl;
PAGED_CODE();
AclLength = sizeof(ACL) +
(sizeof(ACE) + RtlLengthSid(SeAliasAdminsSid)) +

View file

@ -63,6 +63,8 @@ NtAllocateLocallyUniqueId(OUT LUID *LocallyUniqueId)
KPROCESSOR_MODE PreviousMode;
NTSTATUS Status = STATUS_SUCCESS;
PAGED_CODE();
PreviousMode = ExGetPreviousMode();
if(PreviousMode != KernelMode)
@ -108,6 +110,8 @@ VOID STDCALL
RtlCopyLuid(IN PLUID LuidDest,
IN PLUID LuidSrc)
{
PAGED_CODE_RTL();
LuidDest->LowPart = LuidSrc->LowPart;
LuidDest->HighPart = LuidSrc->HighPart;
}
@ -120,6 +124,8 @@ BOOLEAN STDCALL
RtlEqualLuid(IN PLUID Luid1,
IN PLUID Luid2)
{
PAGED_CODE_RTL();
return (Luid1->LowPart == Luid2->LowPart &&
Luid1->HighPart == Luid2->HighPart);
}

View file

@ -108,6 +108,8 @@ SepPrivilegeCheck (PTOKEN Token,
ULONG k;
DPRINT ("SepPrivilegeCheck() called\n");
PAGED_CODE();
if (PreviousMode == KernelMode)
{
@ -167,6 +169,8 @@ SeCaptureLuidAndAttributesArray (PLUID_AND_ATTRIBUTES Src,
{
PLUID_AND_ATTRIBUTES* NewMem;
ULONG SrcLength;
PAGED_CODE();
if (PrivilegeCount == 0)
{
@ -212,6 +216,8 @@ SeReleaseLuidAndAttributesArray (PLUID_AND_ATTRIBUTES Privilege,
KPROCESSOR_MODE PreviousMode,
ULONG a)
{
PAGED_CODE();
ExFreePool (Privilege);
}
@ -227,6 +233,8 @@ NtPrivilegeCheck (IN HANDLE ClientToken,
ULONG PrivilegeControl;
ULONG Length;
NTSTATUS Status;
PAGED_CODE();
Status = ObReferenceObjectByHandle (ClientToken,
0,
@ -291,6 +299,8 @@ SePrivilegeCheck (PPRIVILEGE_SET Privileges,
KPROCESSOR_MODE PreviousMode)
{
PACCESS_TOKEN Token = NULL;
PAGED_CODE();
if (SubjectContext->ClientToken == NULL)
{
@ -323,6 +333,8 @@ SeSinglePrivilegeCheck (IN LUID PrivilegeValue,
SECURITY_SUBJECT_CONTEXT SubjectContext;
PRIVILEGE_SET Priv;
BOOLEAN Result;
PAGED_CODE();
SeCaptureSubjectContext (&SubjectContext);

View file

@ -198,6 +198,8 @@ SeCaptureSubjectContext(OUT PSECURITY_SUBJECT_CONTEXT SubjectContext)
PETHREAD Thread;
BOOLEAN CopyOnOpen;
BOOLEAN EffectiveOnly;
PAGED_CODE();
Thread = PsGetCurrentThread();
if (Thread == NULL)
@ -226,6 +228,8 @@ SeCaptureSubjectContext(OUT PSECURITY_SUBJECT_CONTEXT SubjectContext)
VOID STDCALL
SeLockSubjectContext(IN PSECURITY_SUBJECT_CONTEXT SubjectContext)
{
PAGED_CODE();
KeEnterCriticalRegion();
ExAcquireResourceExclusiveLite(&SepSubjectContextLock, TRUE);
}
@ -237,6 +241,8 @@ SeLockSubjectContext(IN PSECURITY_SUBJECT_CONTEXT SubjectContext)
VOID STDCALL
SeUnlockSubjectContext(IN PSECURITY_SUBJECT_CONTEXT SubjectContext)
{
PAGED_CODE();
ExReleaseResourceLite(&SepSubjectContextLock);
KeLeaveCriticalRegion();
}
@ -248,6 +254,8 @@ SeUnlockSubjectContext(IN PSECURITY_SUBJECT_CONTEXT SubjectContext)
VOID STDCALL
SeReleaseSubjectContext(IN PSECURITY_SUBJECT_CONTEXT SubjectContext)
{
PAGED_CODE();
if (SubjectContext->PrimaryToken != NULL)
{
ObDereferenceObject(SubjectContext->PrimaryToken);
@ -266,6 +274,8 @@ SeReleaseSubjectContext(IN PSECURITY_SUBJECT_CONTEXT SubjectContext)
NTSTATUS STDCALL
SeDeassignSecurity(PSECURITY_DESCRIPTOR *SecurityDescriptor)
{
PAGED_CODE();
if (*SecurityDescriptor != NULL)
{
ExFreePool(*SecurityDescriptor);
@ -331,6 +341,8 @@ SeAssignSecurity(PSECURITY_DESCRIPTOR ParentDescriptor OPTIONAL,
PSID Group = NULL;
PACL Dacl = NULL;
PACL Sacl = NULL;
PAGED_CODE();
/* Lock subject context */
SeLockSubjectContext(SubjectContext);
@ -561,6 +573,8 @@ SepSidInToken(PACCESS_TOKEN _Token,
{
ULONG i;
PTOKEN Token = (PTOKEN)_Token;
PAGED_CODE();
if (Token->UserAndGroupCount == 0)
{
@ -624,6 +638,8 @@ SeAccessCheck(IN PSECURITY_DESCRIPTOR SecurityDescriptor,
PACE CurrentAce;
PSID Sid;
NTSTATUS Status;
PAGED_CODE();
CurrentAccess = PreviouslyGrantedAccess;
@ -795,6 +811,8 @@ NtAccessCheck(IN PSECURITY_DESCRIPTOR SecurityDescriptor,
KPROCESSOR_MODE PreviousMode;
PTOKEN Token;
NTSTATUS Status;
PAGED_CODE();
DPRINT("NtAccessCheck() called\n");

View file

@ -108,7 +108,9 @@ main(int argc, char* argv[])
}
else
{
s = s + sprintf(s, "#ifndef %s\n", argv[i]);
s = s + sprintf(s, "#define %s\n", argv[i]);
s = s + sprintf(s, "#endif /* %s */\n", argv[i]);
}
strcat(config, argv[i]);
if (i != (argc - 1))